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