1 /*
2 * Copyright (c) 2017-2018, 2020 The Linux Foundation. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18 /**
19 * DOC: target_if_pmo_gtk.c
20 *
21 * Target interface file for pmo component to
22 * send gtk offload related cmd and process event.
23 */
24
25 #include "target_if.h"
26 #include "target_if_pmo.h"
27 #include "wmi_unified_api.h"
28
target_if_pmo_send_gtk_offload_req(struct wlan_objmgr_vdev * vdev,struct pmo_gtk_req * gtk_req)29 QDF_STATUS target_if_pmo_send_gtk_offload_req(struct wlan_objmgr_vdev *vdev,
30 struct pmo_gtk_req *gtk_req)
31 {
32 uint8_t vdev_id;
33 QDF_STATUS status;
34 uint32_t gtk_offload_opcode;
35 struct wlan_objmgr_psoc *psoc;
36 wmi_unified_t wmi_handle;
37
38 if (!vdev) {
39 target_if_err("vdev ptr passed is NULL");
40 return QDF_STATUS_E_INVAL;
41 }
42
43 psoc = wlan_vdev_get_psoc(vdev);
44 vdev_id = wlan_vdev_get_id(vdev);
45 if (!psoc) {
46 target_if_err("psoc handle is NULL");
47 return QDF_STATUS_E_INVAL;
48 }
49
50 if (gtk_req->flags == PMO_GTK_OFFLOAD_ENABLE)
51 gtk_offload_opcode = GTK_OFFLOAD_ENABLE_OPCODE;
52 else
53 gtk_offload_opcode = GTK_OFFLOAD_DISABLE_OPCODE;
54
55 wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
56 if (!wmi_handle) {
57 target_if_err("Invalid wmi handle");
58 return QDF_STATUS_E_INVAL;
59 }
60
61 status = wmi_unified_send_gtk_offload_cmd(wmi_handle,
62 vdev_id,
63 gtk_req,
64 gtk_req->flags,
65 gtk_offload_opcode);
66 if (status)
67 target_if_err("Failed to send gtk offload cmd to fw");
68
69 return status;
70 }
71
target_if_pmo_send_gtk_response_req(struct wlan_objmgr_vdev * vdev)72 QDF_STATUS target_if_pmo_send_gtk_response_req(struct wlan_objmgr_vdev *vdev)
73 {
74 uint8_t vdev_id;
75 struct wlan_objmgr_psoc *psoc;
76 QDF_STATUS status = QDF_STATUS_SUCCESS;
77 uint32_t offload_req_opcode;
78 wmi_unified_t wmi_handle;
79
80 if (!vdev) {
81 target_if_err("vdev ptr passed is NULL");
82 return QDF_STATUS_E_INVAL;
83 }
84
85 psoc = wlan_vdev_get_psoc(vdev);
86 vdev_id = wlan_vdev_get_id(vdev);
87 if (!psoc) {
88 target_if_err("psoc handle is NULL");
89 return QDF_STATUS_E_INVAL;
90 }
91
92 /* Request for GTK offload status */
93 offload_req_opcode = GTK_OFFLOAD_REQUEST_STATUS_OPCODE;
94
95 wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
96 if (!wmi_handle) {
97 target_if_err("Invalid wmi handle");
98 return QDF_STATUS_E_INVAL;
99 }
100
101 /* send the wmi command */
102 status = wmi_unified_process_gtk_offload_getinfo_cmd(wmi_handle,
103 vdev_id, offload_req_opcode);
104
105 return status;
106 }
107
target_if_pmo_gtk_offload_status_event(void * scn_handle,uint8_t * event,uint32_t len)108 int target_if_pmo_gtk_offload_status_event(void *scn_handle,
109 uint8_t *event, uint32_t len)
110 {
111 struct pmo_gtk_rsp_params *gtk_rsp_param;
112 struct wlan_objmgr_psoc *psoc;
113 QDF_STATUS ret;
114 wmi_unified_t wmi_handle;
115
116 TARGET_IF_ENTER();
117 psoc = target_if_get_psoc_from_scn_hdl(scn_handle);
118 if (!psoc) {
119 target_if_err("psoc ptr is NULL");
120 ret = -EINVAL;
121 goto out;
122 }
123
124 gtk_rsp_param = qdf_mem_malloc(sizeof(*gtk_rsp_param));
125 if (!gtk_rsp_param) {
126 ret = -ENOMEM;
127 goto out;
128 }
129
130 wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
131 if (!wmi_handle) {
132 target_if_err("Invalid wmi handle");
133 qdf_mem_free(gtk_rsp_param);
134 ret = -EINVAL;
135 goto out;
136 }
137
138 if (wmi_extract_gtk_rsp_event(wmi_handle, event, gtk_rsp_param, len) !=
139 QDF_STATUS_SUCCESS) {
140 target_if_err("Extraction of gtk rsp event failed");
141 qdf_mem_free(gtk_rsp_param);
142 ret = -EINVAL;
143 goto out;
144 }
145
146 ret = pmo_tgt_gtk_rsp_evt(psoc, (void *)gtk_rsp_param);
147 if (ret != QDF_STATUS_SUCCESS) {
148 target_if_err("Failed to rx_gtk_rsp_event");
149 ret = -EINVAL;
150 }
151 qdf_mem_free(gtk_rsp_param);
152 out:
153 TARGET_IF_EXIT();
154
155 return ret;
156 }
157
158