xref: /wlan-driver/qca-wifi-host-cmn/wmi/src/wmi_unified_nan_tlv.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name #include <osdep.h>
21*5113495bSYour Name #include <wmi.h>
22*5113495bSYour Name #include <wmi_unified_priv.h>
23*5113495bSYour Name #include <nan_public_structs.h>
24*5113495bSYour Name #include <wmi_unified_nan_api.h>
25*5113495bSYour Name #include <wlan_nan_msg_common_v2.h>
26*5113495bSYour Name 
27*5113495bSYour Name static QDF_STATUS
extract_nan_event_rsp_tlv(wmi_unified_t wmi_handle,void * evt_buf,struct nan_event_params * evt_params,uint8_t ** msg_buf)28*5113495bSYour Name extract_nan_event_rsp_tlv(wmi_unified_t wmi_handle, void *evt_buf,
29*5113495bSYour Name 			  struct nan_event_params *evt_params,
30*5113495bSYour Name 			  uint8_t **msg_buf)
31*5113495bSYour Name {
32*5113495bSYour Name 	WMI_NAN_EVENTID_param_tlvs *event;
33*5113495bSYour Name 	wmi_nan_event_hdr *nan_rsp_event_hdr;
34*5113495bSYour Name 	nan_msg_header_t *nan_msg_hdr;
35*5113495bSYour Name 	wmi_nan_event_info *nan_evt_info;
36*5113495bSYour Name 
37*5113495bSYour Name 	/*
38*5113495bSYour Name 	 * This is how received evt looks like
39*5113495bSYour Name 	 *
40*5113495bSYour Name 	 * <-------------------- evt_buf ----------------------------------->
41*5113495bSYour Name 	 *
42*5113495bSYour Name 	 * <--wmi_nan_event_hdr--><---WMI_TLV_HDR_SIZE---><----- data -------->
43*5113495bSYour Name 	 *
44*5113495bSYour Name 	 * +-----------+---------+-----------------------+--------------------+-
45*5113495bSYour Name 	 * | tlv_header| data_len| WMITLV_TAG_ARRAY_BYTE | nan_rsp_event_data |
46*5113495bSYour Name 	 * +-----------+---------+-----------------------+--------------------+-
47*5113495bSYour Name 	 *
48*5113495bSYour Name 	 * (Only for NAN Enable Resp)
49*5113495bSYour Name 	 * <--wmi_nan_event_info-->
50*5113495bSYour Name 	 * +-----------+-----------+
51*5113495bSYour Name 	 * | tlv_header| event_info|
52*5113495bSYour Name 	 * +-----------+-----------+
53*5113495bSYour Name 	 *
54*5113495bSYour Name 	 */
55*5113495bSYour Name 
56*5113495bSYour Name 	event = (WMI_NAN_EVENTID_param_tlvs *)evt_buf;
57*5113495bSYour Name 	nan_rsp_event_hdr = event->fixed_param;
58*5113495bSYour Name 
59*5113495bSYour Name 	/* Actual data may include some padding, so data_len <= num_data */
60*5113495bSYour Name 	if (nan_rsp_event_hdr->data_len > event->num_data) {
61*5113495bSYour Name 		wmi_err("Provided NAN event length(%d) exceeding actual length(%d)!",
62*5113495bSYour Name 			 nan_rsp_event_hdr->data_len,
63*5113495bSYour Name 			 event->num_data);
64*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
65*5113495bSYour Name 	}
66*5113495bSYour Name 	evt_params->buf_len = nan_rsp_event_hdr->data_len;
67*5113495bSYour Name 	*msg_buf = event->data;
68*5113495bSYour Name 
69*5113495bSYour Name 	if (nan_rsp_event_hdr->data_len < sizeof(nan_msg_header_t) ||
70*5113495bSYour Name 	    nan_rsp_event_hdr->data_len > (WMI_SVC_MSG_MAX_SIZE -
71*5113495bSYour Name 							    WMI_TLV_HDR_SIZE)) {
72*5113495bSYour Name 		wmi_err("Invalid NAN event data length(%d)!",
73*5113495bSYour Name 			 nan_rsp_event_hdr->data_len);
74*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
75*5113495bSYour Name 	}
76*5113495bSYour Name 	nan_msg_hdr = (nan_msg_header_t *)event->data;
77*5113495bSYour Name 
78*5113495bSYour Name 	switch (nan_msg_hdr->msg_id) {
79*5113495bSYour Name 	case NAN_MSG_ID_ENABLE_RSP:
80*5113495bSYour Name 		nan_evt_info = event->event_info;
81*5113495bSYour Name 		if (!nan_evt_info) {
82*5113495bSYour Name 			if (!wmi_service_enabled(wmi_handle,
83*5113495bSYour Name 						 wmi_service_nan_dbs_support) &&
84*5113495bSYour Name 			    !wmi_service_enabled(wmi_handle,
85*5113495bSYour Name 						 wmi_service_nan_disable_support
86*5113495bSYour Name 						 )) {
87*5113495bSYour Name 				evt_params->evt_type = nan_event_id_generic_rsp;
88*5113495bSYour Name 				break;
89*5113495bSYour Name 			} else {
90*5113495bSYour Name 				wmi_err("Fail: NAN enable rsp event info Null");
91*5113495bSYour Name 				return QDF_STATUS_E_INVAL;
92*5113495bSYour Name 			}
93*5113495bSYour Name 		}
94*5113495bSYour Name 		evt_params->evt_type = nan_event_id_enable_rsp;
95*5113495bSYour Name 		evt_params->mac_id = nan_evt_info->mac_id;
96*5113495bSYour Name 		evt_params->is_nan_enable_success = (nan_evt_info->status == 0);
97*5113495bSYour Name 		evt_params->vdev_id = nan_evt_info->vdev_id;
98*5113495bSYour Name 		break;
99*5113495bSYour Name 	case NAN_MSG_ID_DISABLE_IND:
100*5113495bSYour Name 		evt_params->evt_type = nan_event_id_disable_ind;
101*5113495bSYour Name 		break;
102*5113495bSYour Name 	case NAN_MSG_ID_ERROR_RSP:
103*5113495bSYour Name 		evt_params->evt_type = nan_event_id_error_rsp;
104*5113495bSYour Name 		break;
105*5113495bSYour Name 	default:
106*5113495bSYour Name 		evt_params->evt_type = nan_event_id_generic_rsp;
107*5113495bSYour Name 		break;
108*5113495bSYour Name 	}
109*5113495bSYour Name 
110*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
111*5113495bSYour Name }
112*5113495bSYour Name 
113*5113495bSYour Name /**
114*5113495bSYour Name  * send_nan_disable_req_cmd_tlv() - to send nan disable request to target
115*5113495bSYour Name  * @wmi_handle: wmi handle
116*5113495bSYour Name  * @nan_msg: request data which will be non-null
117*5113495bSYour Name  *
118*5113495bSYour Name  * Return: QDF status
119*5113495bSYour Name  */
send_nan_disable_req_cmd_tlv(wmi_unified_t wmi_handle,struct nan_disable_req * nan_msg)120*5113495bSYour Name static QDF_STATUS send_nan_disable_req_cmd_tlv(wmi_unified_t wmi_handle,
121*5113495bSYour Name 					       struct nan_disable_req *nan_msg)
122*5113495bSYour Name {
123*5113495bSYour Name 	QDF_STATUS ret;
124*5113495bSYour Name 	wmi_nan_cmd_param *cmd;
125*5113495bSYour Name 	wmi_nan_host_config_param *cfg;
126*5113495bSYour Name 	wmi_buf_t buf;
127*5113495bSYour Name 	/* Initialize with minimum length required, which is Scenario 2*/
128*5113495bSYour Name 	uint16_t len = sizeof(*cmd) + sizeof(*cfg) + 2 * WMI_TLV_HDR_SIZE;
129*5113495bSYour Name 	uint16_t nan_data_len, nan_data_len_aligned = 0;
130*5113495bSYour Name 	uint8_t *buf_ptr;
131*5113495bSYour Name 
132*5113495bSYour Name 	/*
133*5113495bSYour Name 	 *  Scenario 1: NAN Disable with NAN msg data from upper layers
134*5113495bSYour Name 	 *
135*5113495bSYour Name 	 *    <-----nan cmd param-----><-- WMI_TLV_HDR_SIZE --><--- data ---->
136*5113495bSYour Name 	 *    +------------+----------+-----------------------+--------------+
137*5113495bSYour Name 	 *    | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_msg_data |
138*5113495bSYour Name 	 *    +------------+----------+-----------------------+--------------+
139*5113495bSYour Name 	 *
140*5113495bSYour Name 	 *    <-- WMI_TLV_HDR_SIZE --><------nan host config params----->
141*5113495bSYour Name 	 *   -+-----------------------+---------------------------------+
142*5113495bSYour Name 	 *    | WMITLV_TAG_ARRAY_STRUC| tlv_header | 2g/5g disable flags|
143*5113495bSYour Name 	 *   -+-----------------------+---------------------------------+
144*5113495bSYour Name 	 *
145*5113495bSYour Name 	 * Scenario 2: NAN Disable without any NAN msg data from upper layers
146*5113495bSYour Name 	 *
147*5113495bSYour Name 	 *    <------nan cmd param------><--WMI_TLV_HDR_SIZE--><--WMI_TLV_HDR_SI
148*5113495bSYour Name 	 *    +------------+------------+----------------------+----------------
149*5113495bSYour Name 	 *    | tlv_header | data_len=0 | WMITLV_TAG_ARRAY_BYTE| WMITLV_TAG_ARRA
150*5113495bSYour Name 	 *    +------------+------------+----------------------+----------------
151*5113495bSYour Name 	 *
152*5113495bSYour Name 	 *    ZE----><------nan host config params----->
153*5113495bSYour Name 	 *    -------+---------------------------------+
154*5113495bSYour Name 	 *    Y_STRUC| tlv_header | 2g/5g disable flags|
155*5113495bSYour Name 	 *    -------+---------------------------------+
156*5113495bSYour Name 	 */
157*5113495bSYour Name 
158*5113495bSYour Name 	if (!nan_msg) {
159*5113495bSYour Name 		wmi_err("nan req is not valid");
160*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
161*5113495bSYour Name 	}
162*5113495bSYour Name 
163*5113495bSYour Name 	nan_data_len = nan_msg->params.request_data_len;
164*5113495bSYour Name 
165*5113495bSYour Name 	if (nan_data_len) {
166*5113495bSYour Name 		nan_data_len_aligned = roundup(nan_data_len, sizeof(uint32_t));
167*5113495bSYour Name 		if (nan_data_len_aligned < nan_data_len) {
168*5113495bSYour Name 			wmi_err("Int overflow while rounding up data_len");
169*5113495bSYour Name 			return QDF_STATUS_E_FAILURE;
170*5113495bSYour Name 		}
171*5113495bSYour Name 
172*5113495bSYour Name 		if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE
173*5113495bSYour Name 							- WMI_TLV_HDR_SIZE) {
174*5113495bSYour Name 			wmi_err("nan_data_len exceeding wmi_max_msg_size");
175*5113495bSYour Name 			return QDF_STATUS_E_FAILURE;
176*5113495bSYour Name 		}
177*5113495bSYour Name 
178*5113495bSYour Name 		len += nan_data_len_aligned;
179*5113495bSYour Name 	}
180*5113495bSYour Name 
181*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
182*5113495bSYour Name 	if (!buf)
183*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
184*5113495bSYour Name 
185*5113495bSYour Name 	buf_ptr = (uint8_t *)wmi_buf_data(buf);
186*5113495bSYour Name 	cmd = (wmi_nan_cmd_param *)buf_ptr;
187*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
188*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_nan_cmd_param,
189*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
190*5113495bSYour Name 
191*5113495bSYour Name 	cmd->data_len = nan_data_len;
192*5113495bSYour Name 	wmi_debug("nan data len value is %u", nan_data_len);
193*5113495bSYour Name 	buf_ptr += sizeof(wmi_nan_cmd_param);
194*5113495bSYour Name 
195*5113495bSYour Name 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
196*5113495bSYour Name 	buf_ptr += WMI_TLV_HDR_SIZE;
197*5113495bSYour Name 
198*5113495bSYour Name 	if (nan_data_len) {
199*5113495bSYour Name 		qdf_mem_copy(buf_ptr, nan_msg->params.request_data,
200*5113495bSYour Name 			     cmd->data_len);
201*5113495bSYour Name 		buf_ptr += nan_data_len_aligned;
202*5113495bSYour Name 	}
203*5113495bSYour Name 
204*5113495bSYour Name 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
205*5113495bSYour Name 		       sizeof(wmi_nan_host_config_param));
206*5113495bSYour Name 	buf_ptr += WMI_TLV_HDR_SIZE;
207*5113495bSYour Name 
208*5113495bSYour Name 	cfg = (wmi_nan_host_config_param *)buf_ptr;
209*5113495bSYour Name 	WMITLV_SET_HDR(&cfg->tlv_header,
210*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_nan_host_config_param,
211*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_nan_host_config_param));
212*5113495bSYour Name 	cfg->nan_2g_disc_disable = nan_msg->disable_2g_discovery;
213*5113495bSYour Name 	cfg->nan_5g_disc_disable = nan_msg->disable_5g_discovery;
214*5113495bSYour Name 
215*5113495bSYour Name 	wmi_mtrace(WMI_NAN_CMDID, NO_SESSION, 0);
216*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
217*5113495bSYour Name 				   WMI_NAN_CMDID);
218*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
219*5113495bSYour Name 		wmi_err("Failed to send set param command ret = %d", ret);
220*5113495bSYour Name 		wmi_buf_free(buf);
221*5113495bSYour Name 	}
222*5113495bSYour Name 
223*5113495bSYour Name 	return ret;
224*5113495bSYour Name }
225*5113495bSYour Name 
226*5113495bSYour Name /**
227*5113495bSYour Name  * send_nan_req_cmd_tlv() - to send nan request to target
228*5113495bSYour Name  * @wmi_handle: wmi handle
229*5113495bSYour Name  * @nan_msg: request data which will be non-null
230*5113495bSYour Name  *
231*5113495bSYour Name  * Return: QDF status
232*5113495bSYour Name  */
send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,struct nan_msg_params * nan_msg)233*5113495bSYour Name static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
234*5113495bSYour Name 				       struct nan_msg_params *nan_msg)
235*5113495bSYour Name {
236*5113495bSYour Name 	QDF_STATUS ret;
237*5113495bSYour Name 	wmi_nan_cmd_param *cmd;
238*5113495bSYour Name 	wmi_buf_t buf;
239*5113495bSYour Name 	wmi_nan_host_config_param *cfg;
240*5113495bSYour Name 	uint16_t len = sizeof(*cmd) + sizeof(*cfg) + 2 * WMI_TLV_HDR_SIZE;
241*5113495bSYour Name 	uint16_t nan_data_len, nan_data_len_aligned;
242*5113495bSYour Name 	uint8_t *buf_ptr;
243*5113495bSYour Name 
244*5113495bSYour Name 	/*
245*5113495bSYour Name 	 *    <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
246*5113495bSYour Name 	 *    +------------+----------+-----------------------+--------------+
247*5113495bSYour Name 	 *    | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_msg_data |
248*5113495bSYour Name 	 *    +------------+----------+-----------------------+--------------+
249*5113495bSYour Name 	 *
250*5113495bSYour Name 	 *    <-- WMI_TLV_HDR_SIZE --><------nan host config params-------->
251*5113495bSYour Name 	 *    +-----------------------+------------------------------------+
252*5113495bSYour Name 	 *    | WMITLV_TAG_ARRAY_STRUC| tlv_header | disable flags | flags |
253*5113495bSYour Name 	 *    +-----------------------+------------------------------------+
254*5113495bSYour Name 	 */
255*5113495bSYour Name 	if (!nan_msg) {
256*5113495bSYour Name 		wmi_err("nan req is not valid");
257*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
258*5113495bSYour Name 	}
259*5113495bSYour Name 	nan_data_len = nan_msg->request_data_len;
260*5113495bSYour Name 	nan_data_len_aligned = roundup(nan_msg->request_data_len,
261*5113495bSYour Name 				       sizeof(uint32_t));
262*5113495bSYour Name 	if (nan_data_len_aligned < nan_msg->request_data_len) {
263*5113495bSYour Name 		wmi_err("integer overflow while rounding up data_len");
264*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
265*5113495bSYour Name 	}
266*5113495bSYour Name 
267*5113495bSYour Name 	if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
268*5113495bSYour Name 		wmi_err("wmi_max_msg_size overflow for given datalen");
269*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
270*5113495bSYour Name 	}
271*5113495bSYour Name 
272*5113495bSYour Name 	len += nan_data_len_aligned;
273*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
274*5113495bSYour Name 	if (!buf)
275*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
276*5113495bSYour Name 
277*5113495bSYour Name 	buf_ptr = (uint8_t *)wmi_buf_data(buf);
278*5113495bSYour Name 	cmd = (wmi_nan_cmd_param *)buf_ptr;
279*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
280*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_nan_cmd_param,
281*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
282*5113495bSYour Name 	cmd->data_len = nan_msg->request_data_len;
283*5113495bSYour Name 	buf_ptr += sizeof(wmi_nan_cmd_param);
284*5113495bSYour Name 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
285*5113495bSYour Name 	buf_ptr += WMI_TLV_HDR_SIZE;
286*5113495bSYour Name 	qdf_mem_copy(buf_ptr, nan_msg->request_data, cmd->data_len);
287*5113495bSYour Name 	buf_ptr += nan_data_len_aligned;
288*5113495bSYour Name 
289*5113495bSYour Name 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
290*5113495bSYour Name 		       sizeof(wmi_nan_host_config_param));
291*5113495bSYour Name 	buf_ptr += WMI_TLV_HDR_SIZE;
292*5113495bSYour Name 
293*5113495bSYour Name 	cfg = (wmi_nan_host_config_param *)buf_ptr;
294*5113495bSYour Name 	WMITLV_SET_HDR(&cfg->tlv_header,
295*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_nan_host_config_param,
296*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_nan_host_config_param));
297*5113495bSYour Name 
298*5113495bSYour Name 	WMI_NAN_SET_RANGING_INITIATOR_ROLE(cfg->flags, !!(nan_msg->rtt_cap &
299*5113495bSYour Name 					   WMI_FW_NAN_RTT_INITR));
300*5113495bSYour Name 	WMI_NAN_SET_RANGING_RESPONDER_ROLE(cfg->flags, !!(nan_msg->rtt_cap &
301*5113495bSYour Name 					   WMI_FW_NAN_RTT_RESPR));
302*5113495bSYour Name 	WMI_NAN_SET_NAN_6G_DISABLE(cfg->flags, nan_msg->disable_6g_nan);
303*5113495bSYour Name 
304*5113495bSYour Name 	wmi_mtrace(WMI_NAN_CMDID, NO_SESSION, 0);
305*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_NAN_CMDID);
306*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
307*5113495bSYour Name 		wmi_err("Failed to send NAN req command ret = %d", ret);
308*5113495bSYour Name 		wmi_buf_free(buf);
309*5113495bSYour Name 	}
310*5113495bSYour Name 
311*5113495bSYour Name 	return ret;
312*5113495bSYour Name }
313*5113495bSYour Name 
314*5113495bSYour Name /**
315*5113495bSYour Name  * send_terminate_all_ndps_cmd_tlv() - send NDP Terminate for all NDP's
316*5113495bSYour Name  * associated with the given vdev id
317*5113495bSYour Name  * @wmi_handle: wmi handle
318*5113495bSYour Name  * @vdev_id: vdev id
319*5113495bSYour Name  *
320*5113495bSYour Name  * Return: QDF status
321*5113495bSYour Name  */
send_terminate_all_ndps_cmd_tlv(wmi_unified_t wmi_handle,uint32_t vdev_id)322*5113495bSYour Name static QDF_STATUS send_terminate_all_ndps_cmd_tlv(wmi_unified_t wmi_handle,
323*5113495bSYour Name 						  uint32_t vdev_id)
324*5113495bSYour Name {
325*5113495bSYour Name 	wmi_ndp_cmd_param *cmd;
326*5113495bSYour Name 	wmi_buf_t wmi_buf;
327*5113495bSYour Name 	uint32_t len;
328*5113495bSYour Name 	QDF_STATUS status;
329*5113495bSYour Name 
330*5113495bSYour Name 	wmi_debug("Enter");
331*5113495bSYour Name 
332*5113495bSYour Name 	len = sizeof(*cmd);
333*5113495bSYour Name 	wmi_buf = wmi_buf_alloc(wmi_handle, len);
334*5113495bSYour Name 	if (!wmi_buf)
335*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
336*5113495bSYour Name 
337*5113495bSYour Name 	cmd = (wmi_ndp_cmd_param *)wmi_buf_data(wmi_buf);
338*5113495bSYour Name 
339*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header, WMITLV_TAG_STRUC_wmi_ndp_cmd_param,
340*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_cmd_param));
341*5113495bSYour Name 
342*5113495bSYour Name 	cmd->vdev_id = vdev_id;
343*5113495bSYour Name 	cmd->ndp_disable = 1;
344*5113495bSYour Name 
345*5113495bSYour Name 	wmi_mtrace(WMI_NDP_CMDID, NO_SESSION, 0);
346*5113495bSYour Name 	status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len, WMI_NDP_CMDID);
347*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
348*5113495bSYour Name 		wmi_err("Failed to send NDP Terminate cmd: %d", status);
349*5113495bSYour Name 		wmi_buf_free(wmi_buf);
350*5113495bSYour Name 	}
351*5113495bSYour Name 
352*5113495bSYour Name 	return status;
353*5113495bSYour Name }
354*5113495bSYour Name 
nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,struct nan_datapath_initiator_req * ndp_req)355*5113495bSYour Name static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
356*5113495bSYour Name 				struct nan_datapath_initiator_req *ndp_req)
357*5113495bSYour Name {
358*5113495bSYour Name 	uint16_t len;
359*5113495bSYour Name 	wmi_buf_t buf;
360*5113495bSYour Name 	uint8_t *tlv_ptr;
361*5113495bSYour Name 	QDF_STATUS status;
362*5113495bSYour Name 	wmi_channel *ch_tlv;
363*5113495bSYour Name 	wmi_ndp_initiator_req_fixed_param *cmd;
364*5113495bSYour Name 	uint32_t passphrase_len, service_name_len;
365*5113495bSYour Name 	uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
366*5113495bSYour Name 	wmi_ndp_transport_ip_param *tcp_ip_param;
367*5113495bSYour Name 
368*5113495bSYour Name 	/*
369*5113495bSYour Name 	 * WMI command expects 4 byte aligned len:
370*5113495bSYour Name 	 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
371*5113495bSYour Name 	 */
372*5113495bSYour Name 	ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
373*5113495bSYour Name 	ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
374*5113495bSYour Name 	pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
375*5113495bSYour Name 	passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
376*5113495bSYour Name 	service_name_len =
377*5113495bSYour Name 		   qdf_roundup(ndp_req->service_name.service_name_len, 4);
378*5113495bSYour Name 	/* allocated memory for fixed params as well as variable size data */
379*5113495bSYour Name 	len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
380*5113495bSYour Name 		+ ndp_cfg_len + ndp_app_info_len + pmk_len
381*5113495bSYour Name 		+ passphrase_len + service_name_len;
382*5113495bSYour Name 
383*5113495bSYour Name 	if (ndp_req->is_ipv6_addr_present)
384*5113495bSYour Name 		len += sizeof(*tcp_ip_param);
385*5113495bSYour Name 
386*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
387*5113495bSYour Name 	if (!buf) {
388*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
389*5113495bSYour Name 	}
390*5113495bSYour Name 
391*5113495bSYour Name 	cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
392*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
393*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
394*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(
395*5113495bSYour Name 				wmi_ndp_initiator_req_fixed_param));
396*5113495bSYour Name 	cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
397*5113495bSYour Name 	cmd->transaction_id = ndp_req->transaction_id;
398*5113495bSYour Name 	cmd->service_instance_id = ndp_req->service_instance_id;
399*5113495bSYour Name 	WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
400*5113495bSYour Name 				   &cmd->peer_discovery_mac_addr);
401*5113495bSYour Name 
402*5113495bSYour Name 	cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
403*5113495bSYour Name 	cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
404*5113495bSYour Name 	cmd->ndp_channel_cfg = ndp_req->channel_cfg;
405*5113495bSYour Name 	cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
406*5113495bSYour Name 	cmd->nan_csid = ndp_req->ncs_sk_type;
407*5113495bSYour Name 	cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
408*5113495bSYour Name 	cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
409*5113495bSYour Name 	cmd->nan_csid_cap = ndp_req->ndp_add_params.csid_cap;
410*5113495bSYour Name 	cmd->nan_gtk_required = ndp_req->ndp_add_params.gtk;
411*5113495bSYour Name 
412*5113495bSYour Name 	ch_tlv = (wmi_channel *)&cmd[1];
413*5113495bSYour Name 	WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
414*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
415*5113495bSYour Name 	ch_tlv->mhz = ndp_req->channel;
416*5113495bSYour Name 	tlv_ptr = (uint8_t *)&ch_tlv[1];
417*5113495bSYour Name 
418*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
419*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
420*5113495bSYour Name 		     ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
421*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
422*5113495bSYour Name 
423*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
424*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
425*5113495bSYour Name 		     ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
426*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
427*5113495bSYour Name 
428*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
429*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
430*5113495bSYour Name 		     cmd->nan_pmk_len);
431*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
432*5113495bSYour Name 
433*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
434*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
435*5113495bSYour Name 		     cmd->nan_passphrase_len);
436*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
437*5113495bSYour Name 
438*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
439*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
440*5113495bSYour Name 		     ndp_req->service_name.service_name,
441*5113495bSYour Name 		     cmd->nan_servicename_len);
442*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
443*5113495bSYour Name 
444*5113495bSYour Name 	if (ndp_req->is_ipv6_addr_present) {
445*5113495bSYour Name 		tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
446*5113495bSYour Name 		WMITLV_SET_HDR(tcp_ip_param,
447*5113495bSYour Name 			       WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
448*5113495bSYour Name 			       WMITLV_GET_STRUCT_TLVLEN(
449*5113495bSYour Name 						wmi_ndp_transport_ip_param));
450*5113495bSYour Name 		tcp_ip_param->ipv6_addr_present = true;
451*5113495bSYour Name 		qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
452*5113495bSYour Name 			     ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
453*5113495bSYour Name 	}
454*5113495bSYour Name 	wmi_debug("IPv6 addr present: %d, addr: %pI6",
455*5113495bSYour Name 		 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
456*5113495bSYour Name 
457*5113495bSYour Name 	wmi_debug("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
458*5113495bSYour Name 		 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
459*5113495bSYour Name 		 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid,
460*5113495bSYour Name 		 cmd->peer_discovery_mac_addr.mac_addr31to0,
461*5113495bSYour Name 		 cmd->peer_discovery_mac_addr.mac_addr47to32);
462*5113495bSYour Name 
463*5113495bSYour Name 	wmi_debug("ndp_config len: %d ndp_app_info len: %d pmk len: %d pass phrase len: %d service name len: %d",
464*5113495bSYour Name 		 cmd->ndp_cfg_len, cmd->ndp_app_info_len, cmd->nan_pmk_len,
465*5113495bSYour Name 		 cmd->nan_passphrase_len, cmd->nan_servicename_len);
466*5113495bSYour Name 
467*5113495bSYour Name 	wmi_debug("ndp_csid_cap %d, ndp_gtk_required %d", cmd->nan_csid_cap,
468*5113495bSYour Name 		  cmd->nan_gtk_required);
469*5113495bSYour Name 
470*5113495bSYour Name 	wmi_mtrace(WMI_NDP_INITIATOR_REQ_CMDID, cmd->vdev_id, 0);
471*5113495bSYour Name 	status = wmi_unified_cmd_send(wmi_handle, buf, len,
472*5113495bSYour Name 				      WMI_NDP_INITIATOR_REQ_CMDID);
473*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
474*5113495bSYour Name 		wmi_err("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
475*5113495bSYour Name 		wmi_buf_free(buf);
476*5113495bSYour Name 	}
477*5113495bSYour Name 
478*5113495bSYour Name 	return status;
479*5113495bSYour Name }
480*5113495bSYour Name 
nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,struct nan_datapath_responder_req * req)481*5113495bSYour Name static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
482*5113495bSYour Name 					struct nan_datapath_responder_req *req)
483*5113495bSYour Name {
484*5113495bSYour Name 	uint16_t len;
485*5113495bSYour Name 	wmi_buf_t buf;
486*5113495bSYour Name 	uint8_t *tlv_ptr;
487*5113495bSYour Name 	QDF_STATUS status;
488*5113495bSYour Name 	wmi_ndp_responder_req_fixed_param *cmd;
489*5113495bSYour Name 	wmi_ndp_transport_ip_param *tcp_ip_param;
490*5113495bSYour Name 	uint32_t passphrase_len, service_name_len;
491*5113495bSYour Name 	uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
492*5113495bSYour Name 
493*5113495bSYour Name 	vdev_id = wlan_vdev_get_id(req->vdev);
494*5113495bSYour Name 	wmi_debug("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
495*5113495bSYour Name 		 vdev_id, req->transaction_id,
496*5113495bSYour Name 		 req->ndp_rsp,
497*5113495bSYour Name 		 req->ndp_instance_id,
498*5113495bSYour Name 		 req->ndp_info.ndp_app_info_len);
499*5113495bSYour Name 
500*5113495bSYour Name 	/*
501*5113495bSYour Name 	 * WMI command expects 4 byte aligned len:
502*5113495bSYour Name 	 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
503*5113495bSYour Name 	 */
504*5113495bSYour Name 	ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
505*5113495bSYour Name 	ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
506*5113495bSYour Name 	pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
507*5113495bSYour Name 	passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
508*5113495bSYour Name 	service_name_len =
509*5113495bSYour Name 		qdf_roundup(req->service_name.service_name_len, 4);
510*5113495bSYour Name 
511*5113495bSYour Name 	/* allocated memory for fixed params as well as variable size data */
512*5113495bSYour Name 	len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
513*5113495bSYour Name 		+ pmk_len + passphrase_len + service_name_len;
514*5113495bSYour Name 
515*5113495bSYour Name 	if (req->is_ipv6_addr_present || req->is_port_present ||
516*5113495bSYour Name 	    req->is_protocol_present)
517*5113495bSYour Name 		len += sizeof(*tcp_ip_param);
518*5113495bSYour Name 
519*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
520*5113495bSYour Name 	if (!buf) {
521*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
522*5113495bSYour Name 	}
523*5113495bSYour Name 	cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
524*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
525*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
526*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(
527*5113495bSYour Name 				wmi_ndp_responder_req_fixed_param));
528*5113495bSYour Name 	cmd->vdev_id = vdev_id;
529*5113495bSYour Name 	cmd->transaction_id = req->transaction_id;
530*5113495bSYour Name 	cmd->ndp_instance_id = req->ndp_instance_id;
531*5113495bSYour Name 	cmd->rsp_code = req->ndp_rsp;
532*5113495bSYour Name 	cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
533*5113495bSYour Name 	cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
534*5113495bSYour Name 	cmd->nan_pmk_len = req->pmk.pmk_len;
535*5113495bSYour Name 	cmd->nan_csid = req->ncs_sk_type;
536*5113495bSYour Name 	cmd->nan_passphrase_len = req->passphrase.passphrase_len;
537*5113495bSYour Name 	cmd->nan_servicename_len = req->service_name.service_name_len;
538*5113495bSYour Name 	cmd->nan_csid_cap = req->ndp_add_params.csid_cap;
539*5113495bSYour Name 	cmd->nan_gtk_required = req->ndp_add_params.gtk;
540*5113495bSYour Name 
541*5113495bSYour Name 	tlv_ptr = (uint8_t *)&cmd[1];
542*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
543*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
544*5113495bSYour Name 		     req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
545*5113495bSYour Name 
546*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
547*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
548*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
549*5113495bSYour Name 		     req->ndp_info.ndp_app_info,
550*5113495bSYour Name 		     req->ndp_info.ndp_app_info_len);
551*5113495bSYour Name 
552*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
553*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
554*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
555*5113495bSYour Name 		     cmd->nan_pmk_len);
556*5113495bSYour Name 
557*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
558*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
559*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
560*5113495bSYour Name 		     req->passphrase.passphrase,
561*5113495bSYour Name 		     cmd->nan_passphrase_len);
562*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
563*5113495bSYour Name 
564*5113495bSYour Name 	WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
565*5113495bSYour Name 	qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
566*5113495bSYour Name 		     req->service_name.service_name,
567*5113495bSYour Name 		     cmd->nan_servicename_len);
568*5113495bSYour Name 
569*5113495bSYour Name 	tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
570*5113495bSYour Name 
571*5113495bSYour Name 	if (req->is_ipv6_addr_present || req->is_port_present ||
572*5113495bSYour Name 	    req->is_protocol_present) {
573*5113495bSYour Name 		tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
574*5113495bSYour Name 		WMITLV_SET_HDR(tcp_ip_param,
575*5113495bSYour Name 			       WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
576*5113495bSYour Name 			       WMITLV_GET_STRUCT_TLVLEN(
577*5113495bSYour Name 						wmi_ndp_transport_ip_param));
578*5113495bSYour Name 		tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
579*5113495bSYour Name 		qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
580*5113495bSYour Name 			     req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
581*5113495bSYour Name 
582*5113495bSYour Name 		tcp_ip_param->trans_port_present = req->is_port_present;
583*5113495bSYour Name 		tcp_ip_param->transport_port = req->port;
584*5113495bSYour Name 
585*5113495bSYour Name 		tcp_ip_param->trans_proto_present = req->is_protocol_present;
586*5113495bSYour Name 		tcp_ip_param->transport_protocol = req->protocol;
587*5113495bSYour Name 	}
588*5113495bSYour Name 
589*5113495bSYour Name 	wmi_debug("ndp_config len: %d ndp_app_info len: %d pmk len: %d pass phrase len: %d service name len: %d",
590*5113495bSYour Name 		 req->ndp_config.ndp_cfg_len, req->ndp_info.ndp_app_info_len,
591*5113495bSYour Name 		 cmd->nan_pmk_len, cmd->nan_passphrase_len,
592*5113495bSYour Name 		 cmd->nan_servicename_len);
593*5113495bSYour Name 
594*5113495bSYour Name 	wmi_debug("ndp_csid_cap %d, ndp_gtk_required %d", cmd->nan_csid_cap,
595*5113495bSYour Name 		  cmd->nan_gtk_required);
596*5113495bSYour Name 
597*5113495bSYour Name 	wmi_mtrace(WMI_NDP_RESPONDER_REQ_CMDID, cmd->vdev_id, 0);
598*5113495bSYour Name 	status = wmi_unified_cmd_send(wmi_handle, buf, len,
599*5113495bSYour Name 				      WMI_NDP_RESPONDER_REQ_CMDID);
600*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
601*5113495bSYour Name 		wmi_err("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
602*5113495bSYour Name 		wmi_buf_free(buf);
603*5113495bSYour Name 	}
604*5113495bSYour Name 	return status;
605*5113495bSYour Name }
606*5113495bSYour Name 
nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,struct nan_datapath_end_req * req)607*5113495bSYour Name static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
608*5113495bSYour Name 				      struct nan_datapath_end_req *req)
609*5113495bSYour Name {
610*5113495bSYour Name 	uint16_t len;
611*5113495bSYour Name 	wmi_buf_t buf;
612*5113495bSYour Name 	QDF_STATUS status;
613*5113495bSYour Name 	uint32_t ndp_end_req_len, i;
614*5113495bSYour Name 	wmi_ndp_end_req *ndp_end_req_lst;
615*5113495bSYour Name 	wmi_ndp_end_req_fixed_param *cmd;
616*5113495bSYour Name 
617*5113495bSYour Name 	/* len of tlv following fixed param  */
618*5113495bSYour Name 	ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
619*5113495bSYour Name 	/* above comes out to 4 byte aligned already, no need of padding */
620*5113495bSYour Name 	len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
621*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
622*5113495bSYour Name 	if (!buf) {
623*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
624*5113495bSYour Name 	}
625*5113495bSYour Name 
626*5113495bSYour Name 	cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
627*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
628*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
629*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
630*5113495bSYour Name 
631*5113495bSYour Name 	cmd->transaction_id = req->transaction_id;
632*5113495bSYour Name 
633*5113495bSYour Name 	/* set tlv pointer to end of fixed param */
634*5113495bSYour Name 	WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
635*5113495bSYour Name 			ndp_end_req_len);
636*5113495bSYour Name 
637*5113495bSYour Name 	ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
638*5113495bSYour Name 						WMI_TLV_HDR_SIZE);
639*5113495bSYour Name 	for (i = 0; i < req->num_ndp_instances; i++) {
640*5113495bSYour Name 		WMITLV_SET_HDR(&ndp_end_req_lst[i],
641*5113495bSYour Name 			       WMITLV_TAG_ARRAY_FIXED_STRUC,
642*5113495bSYour Name 			       (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
643*5113495bSYour Name 
644*5113495bSYour Name 		ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
645*5113495bSYour Name 
646*5113495bSYour Name 		/*
647*5113495bSYour Name 		 * vdev_id is added in NDP END TLV to facilitate fw to give it
648*5113495bSYour Name 		 * back in the NDP END indication.
649*5113495bSYour Name 		 */
650*5113495bSYour Name 		if (req->vdev) {
651*5113495bSYour Name 			ndp_end_req_lst[i].vdev_id =
652*5113495bSYour Name 						wlan_vdev_get_id(req->vdev);
653*5113495bSYour Name 			ndp_end_req_lst[i].vdev_id_valid = 1;
654*5113495bSYour Name 		}
655*5113495bSYour Name 	}
656*5113495bSYour Name 
657*5113495bSYour Name 	wmi_mtrace(WMI_NDP_END_REQ_CMDID, NO_SESSION, 0);
658*5113495bSYour Name 	status = wmi_unified_cmd_send(wmi_handle, buf, len,
659*5113495bSYour Name 				      WMI_NDP_END_REQ_CMDID);
660*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status)) {
661*5113495bSYour Name 		wmi_err("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
662*5113495bSYour Name 		wmi_buf_free(buf);
663*5113495bSYour Name 	}
664*5113495bSYour Name 
665*5113495bSYour Name 	return status;
666*5113495bSYour Name }
667*5113495bSYour Name 
668*5113495bSYour Name static QDF_STATUS
extract_ndp_host_event_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_host_event * evt)669*5113495bSYour Name extract_ndp_host_event_tlv(wmi_unified_t wmi_handle, uint8_t *data,
670*5113495bSYour Name 			   struct nan_datapath_host_event *evt)
671*5113495bSYour Name {
672*5113495bSYour Name 	WMI_NDP_EVENTID_param_tlvs *event;
673*5113495bSYour Name 	wmi_ndp_event_param *fixed_params;
674*5113495bSYour Name 
675*5113495bSYour Name 	event = (WMI_NDP_EVENTID_param_tlvs *)data;
676*5113495bSYour Name 	fixed_params = event->fixed_param;
677*5113495bSYour Name 
678*5113495bSYour Name 	evt->vdev =
679*5113495bSYour Name 		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
680*5113495bSYour Name 						     fixed_params->vdev_id,
681*5113495bSYour Name 						     WLAN_NAN_ID);
682*5113495bSYour Name 	if (!evt->vdev) {
683*5113495bSYour Name 		wmi_err("vdev is null");
684*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
685*5113495bSYour Name 	}
686*5113495bSYour Name 
687*5113495bSYour Name 	evt->ndp_termination_in_progress =
688*5113495bSYour Name 		       fixed_params->ndp_termination_in_progress ? true : false;
689*5113495bSYour Name 
690*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
691*5113495bSYour Name }
692*5113495bSYour Name 
extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_initiator_rsp * rsp)693*5113495bSYour Name static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
694*5113495bSYour Name 			uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
695*5113495bSYour Name {
696*5113495bSYour Name 	WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
697*5113495bSYour Name 	wmi_ndp_initiator_rsp_event_fixed_param  *fixed_params;
698*5113495bSYour Name 
699*5113495bSYour Name 	event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
700*5113495bSYour Name 	fixed_params = event->fixed_param;
701*5113495bSYour Name 
702*5113495bSYour Name 	rsp->vdev =
703*5113495bSYour Name 		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
704*5113495bSYour Name 						     fixed_params->vdev_id,
705*5113495bSYour Name 						     WLAN_NAN_ID);
706*5113495bSYour Name 	if (!rsp->vdev) {
707*5113495bSYour Name 		wmi_err("vdev is null");
708*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
709*5113495bSYour Name 	}
710*5113495bSYour Name 
711*5113495bSYour Name 	rsp->transaction_id = fixed_params->transaction_id;
712*5113495bSYour Name 	rsp->ndp_instance_id = fixed_params->ndp_instance_id;
713*5113495bSYour Name 	rsp->status = fixed_params->rsp_status;
714*5113495bSYour Name 	rsp->reason = fixed_params->reason_code;
715*5113495bSYour Name 
716*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
717*5113495bSYour Name }
718*5113495bSYour Name 
719*5113495bSYour Name #define MAX_NAN_MSG_LEN                 400
720*5113495bSYour Name 
extract_nan_msg_tlv(uint8_t * data,struct nan_dump_msg * msg)721*5113495bSYour Name static QDF_STATUS extract_nan_msg_tlv(uint8_t *data,
722*5113495bSYour Name 				      struct nan_dump_msg *msg)
723*5113495bSYour Name {
724*5113495bSYour Name 	WMI_NAN_DMESG_EVENTID_param_tlvs *event;
725*5113495bSYour Name 	wmi_nan_dmesg_event_fixed_param *fixed_params;
726*5113495bSYour Name 
727*5113495bSYour Name 	event = (WMI_NAN_DMESG_EVENTID_param_tlvs *)data;
728*5113495bSYour Name 	fixed_params = (wmi_nan_dmesg_event_fixed_param *)event->fixed_param;
729*5113495bSYour Name 	if (!fixed_params->msg_len ||
730*5113495bSYour Name 	    fixed_params->msg_len > MAX_NAN_MSG_LEN ||
731*5113495bSYour Name 	    fixed_params->msg_len > event->num_msg)
732*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
733*5113495bSYour Name 
734*5113495bSYour Name 	msg->data_len = fixed_params->msg_len;
735*5113495bSYour Name 	msg->msg = event->msg;
736*5113495bSYour Name 
737*5113495bSYour Name 	msg->msg[fixed_params->msg_len - 1] = (uint8_t)'\0';
738*5113495bSYour Name 
739*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
740*5113495bSYour Name }
741*5113495bSYour Name 
extract_ndp_ind_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_indication_event * rsp)742*5113495bSYour Name static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
743*5113495bSYour Name 		uint8_t *data, struct nan_datapath_indication_event *rsp)
744*5113495bSYour Name {
745*5113495bSYour Name 	WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
746*5113495bSYour Name 	wmi_ndp_indication_event_fixed_param *fixed_params;
747*5113495bSYour Name 	size_t total_array_len;
748*5113495bSYour Name 
749*5113495bSYour Name 	event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
750*5113495bSYour Name 	fixed_params =
751*5113495bSYour Name 		(wmi_ndp_indication_event_fixed_param *)event->fixed_param;
752*5113495bSYour Name 
753*5113495bSYour Name 	if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
754*5113495bSYour Name 		wmi_err("FW message ndp cfg length %d larger than TLV hdr %d",
755*5113495bSYour Name 			 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
756*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
757*5113495bSYour Name 	}
758*5113495bSYour Name 
759*5113495bSYour Name 	if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
760*5113495bSYour Name 		wmi_err("FW message ndp app info length %d more than TLV hdr %d",
761*5113495bSYour Name 			 fixed_params->ndp_app_info_len,
762*5113495bSYour Name 			 event->num_ndp_app_info);
763*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
764*5113495bSYour Name 	}
765*5113495bSYour Name 
766*5113495bSYour Name 	if (fixed_params->nan_scid_len > event->num_ndp_scid) {
767*5113495bSYour Name 		wmi_err("FW msg ndp scid info len %d more than TLV hdr %d",
768*5113495bSYour Name 			 fixed_params->nan_scid_len,
769*5113495bSYour Name 			 event->num_ndp_scid);
770*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
771*5113495bSYour Name 	}
772*5113495bSYour Name 
773*5113495bSYour Name 	if (fixed_params->service_id_len > event->num_service_id) {
774*5113495bSYour Name 		wmi_err("FW msg service id len %d more than TLV hdr %d",
775*5113495bSYour Name 			fixed_params->service_id_len,
776*5113495bSYour Name 			event->num_service_id);
777*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
778*5113495bSYour Name 	}
779*5113495bSYour Name 
780*5113495bSYour Name 	if (fixed_params->ndp_cfg_len >
781*5113495bSYour Name 		(WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
782*5113495bSYour Name 		wmi_err("excess wmi buffer: ndp_cfg_len %d",
783*5113495bSYour Name 			fixed_params->ndp_cfg_len);
784*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
785*5113495bSYour Name 	}
786*5113495bSYour Name 
787*5113495bSYour Name 	total_array_len = fixed_params->ndp_cfg_len +
788*5113495bSYour Name 					sizeof(*fixed_params);
789*5113495bSYour Name 
790*5113495bSYour Name 	if (fixed_params->ndp_app_info_len >
791*5113495bSYour Name 		(WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
792*5113495bSYour Name 		wmi_err("excess wmi buffer: ndp_cfg_len %d",
793*5113495bSYour Name 			fixed_params->ndp_app_info_len);
794*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
795*5113495bSYour Name 	}
796*5113495bSYour Name 	total_array_len += fixed_params->ndp_app_info_len;
797*5113495bSYour Name 
798*5113495bSYour Name 	if (fixed_params->nan_scid_len >
799*5113495bSYour Name 		(WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
800*5113495bSYour Name 		wmi_err("excess wmi buffer: ndp_cfg_len %d",
801*5113495bSYour Name 			fixed_params->nan_scid_len);
802*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
803*5113495bSYour Name 	}
804*5113495bSYour Name 
805*5113495bSYour Name 	total_array_len += fixed_params->nan_scid_len;
806*5113495bSYour Name 
807*5113495bSYour Name 	if (fixed_params->service_id_len >
808*5113495bSYour Name 	    (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
809*5113495bSYour Name 		wmi_err("excess wmi buffer: service_cfg_len %d",
810*5113495bSYour Name 			fixed_params->service_id_len);
811*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
812*5113495bSYour Name 	}
813*5113495bSYour Name 
814*5113495bSYour Name 	rsp->vdev =
815*5113495bSYour Name 		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
816*5113495bSYour Name 						     fixed_params->vdev_id,
817*5113495bSYour Name 						     WLAN_NAN_ID);
818*5113495bSYour Name 	if (!rsp->vdev) {
819*5113495bSYour Name 		wmi_err("vdev is null");
820*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
821*5113495bSYour Name 	}
822*5113495bSYour Name 	rsp->service_instance_id = fixed_params->service_instance_id;
823*5113495bSYour Name 	rsp->ndp_instance_id = fixed_params->ndp_instance_id;
824*5113495bSYour Name 	rsp->role = fixed_params->self_ndp_role;
825*5113495bSYour Name 	rsp->policy = fixed_params->accept_policy;
826*5113495bSYour Name 	rsp->ndp_add_params.csid_cap = fixed_params->nan_csid_cap;
827*5113495bSYour Name 	rsp->ndp_add_params.gtk = fixed_params->nan_gtk_required;
828*5113495bSYour Name 
829*5113495bSYour Name 	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
830*5113495bSYour Name 				rsp->peer_mac_addr.bytes);
831*5113495bSYour Name 	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
832*5113495bSYour Name 				rsp->peer_discovery_mac_addr.bytes);
833*5113495bSYour Name 
834*5113495bSYour Name 	wmi_debug("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d service_instance %d, ndp_instance %d, role %d, policy %d csid: %d, scid_len: %d, peer_addr: "QDF_MAC_ADDR_FMT", peer_disc_addr: "QDF_MAC_ADDR_FMT" ndp_cfg - %d bytes ndp_app_info - %d bytes ndp_csid_caps %d, ndp_gtk_required %d",
835*5113495bSYour Name 		 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
836*5113495bSYour Name 		 fixed_params->service_instance_id,
837*5113495bSYour Name 		 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
838*5113495bSYour Name 		 fixed_params->accept_policy, fixed_params->nan_csid,
839*5113495bSYour Name 		 fixed_params->nan_scid_len,
840*5113495bSYour Name 		 QDF_MAC_ADDR_REF(rsp->peer_mac_addr.bytes),
841*5113495bSYour Name 		 QDF_MAC_ADDR_REF(rsp->peer_discovery_mac_addr.bytes),
842*5113495bSYour Name 		 fixed_params->ndp_cfg_len,
843*5113495bSYour Name 		 fixed_params->ndp_app_info_len, rsp->ndp_add_params.csid_cap,
844*5113495bSYour Name 		 rsp->ndp_add_params.gtk);
845*5113495bSYour Name 
846*5113495bSYour Name 	rsp->ncs_sk_type = fixed_params->nan_csid;
847*5113495bSYour Name 	if (event->ndp_cfg) {
848*5113495bSYour Name 		rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
849*5113495bSYour Name 		if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
850*5113495bSYour Name 			rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
851*5113495bSYour Name 		qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
852*5113495bSYour Name 			     rsp->ndp_config.ndp_cfg_len);
853*5113495bSYour Name 	}
854*5113495bSYour Name 
855*5113495bSYour Name 	if (event->ndp_app_info) {
856*5113495bSYour Name 		rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
857*5113495bSYour Name 		if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
858*5113495bSYour Name 			rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
859*5113495bSYour Name 		qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
860*5113495bSYour Name 			     rsp->ndp_info.ndp_app_info_len);
861*5113495bSYour Name 	}
862*5113495bSYour Name 
863*5113495bSYour Name 	if (event->ndp_scid) {
864*5113495bSYour Name 		rsp->scid.scid_len = fixed_params->nan_scid_len;
865*5113495bSYour Name 		if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
866*5113495bSYour Name 			rsp->scid.scid_len = NDP_SCID_BUF_LEN;
867*5113495bSYour Name 		qdf_mem_copy(rsp->scid.scid, event->ndp_scid,
868*5113495bSYour Name 			     rsp->scid.scid_len);
869*5113495bSYour Name 	}
870*5113495bSYour Name 
871*5113495bSYour Name 	if (event->ndp_transport_ip_param &&
872*5113495bSYour Name 	    event->num_ndp_transport_ip_param) {
873*5113495bSYour Name 		if (event->ndp_transport_ip_param->ipv6_addr_present) {
874*5113495bSYour Name 			rsp->is_ipv6_addr_present = true;
875*5113495bSYour Name 			qdf_mem_copy(rsp->ipv6_addr,
876*5113495bSYour Name 				event->ndp_transport_ip_param->ipv6_intf_addr,
877*5113495bSYour Name 				WMI_NDP_IPV6_INTF_ADDR_LEN);
878*5113495bSYour Name 		}
879*5113495bSYour Name 	}
880*5113495bSYour Name 	wmi_debug("IPv6 addr present: %d, addr: %pI6",
881*5113495bSYour Name 		 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
882*5113495bSYour Name 
883*5113495bSYour Name 	rsp->is_service_id_present = false;
884*5113495bSYour Name 	if (fixed_params->service_id_len && event->service_id) {
885*5113495bSYour Name 		if (fixed_params->service_id_len < NDP_SERVICE_ID_LEN) {
886*5113495bSYour Name 			wmi_err("Invalid service id length %d",
887*5113495bSYour Name 				event->num_service_id);
888*5113495bSYour Name 			return QDF_STATUS_E_INVAL;
889*5113495bSYour Name 		}
890*5113495bSYour Name 		rsp->is_service_id_present = true;
891*5113495bSYour Name 		qdf_mem_copy(rsp->service_id, event->service_id,
892*5113495bSYour Name 			     NDP_SERVICE_ID_LEN);
893*5113495bSYour Name 	}
894*5113495bSYour Name 
895*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
896*5113495bSYour Name }
897*5113495bSYour Name 
extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_confirm_event * rsp)898*5113495bSYour Name static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
899*5113495bSYour Name 			uint8_t *data, struct nan_datapath_confirm_event *rsp)
900*5113495bSYour Name {
901*5113495bSYour Name 	uint8_t i;
902*5113495bSYour Name 	WMI_HOST_WLAN_PHY_MODE ch_mode;
903*5113495bSYour Name 	WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
904*5113495bSYour Name 	wmi_ndp_confirm_event_fixed_param *fixed_params;
905*5113495bSYour Name 	size_t total_array_len;
906*5113495bSYour Name 	bool ndi_dbs = wmi_service_enabled(wmi_handle,
907*5113495bSYour Name 					   wmi_service_ndi_dbs_support);
908*5113495bSYour Name 
909*5113495bSYour Name 	event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
910*5113495bSYour Name 	fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
911*5113495bSYour Name 	wmi_debug("WMI_NDP_CONFIRM_EVENTID(0x%X) received. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d num_ch: %d",
912*5113495bSYour Name 		 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
913*5113495bSYour Name 		 fixed_params->ndp_instance_id, fixed_params->rsp_code,
914*5113495bSYour Name 		 fixed_params->reason_code,
915*5113495bSYour Name 		 fixed_params->num_active_ndps_on_peer,
916*5113495bSYour Name 		 fixed_params->num_ndp_channels);
917*5113495bSYour Name 
918*5113495bSYour Name 	if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
919*5113495bSYour Name 		wmi_err("FW message ndp cfg length %d larger than TLV hdr %d",
920*5113495bSYour Name 			 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
921*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
922*5113495bSYour Name 	}
923*5113495bSYour Name 
924*5113495bSYour Name 	if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
925*5113495bSYour Name 		wmi_err("FW message ndp app info length %d more than TLV hdr %d",
926*5113495bSYour Name 			 fixed_params->ndp_app_info_len,
927*5113495bSYour Name 			 event->num_ndp_app_info);
928*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
929*5113495bSYour Name 	}
930*5113495bSYour Name 
931*5113495bSYour Name 	wmi_debug("ndp_cfg - %d bytes, ndp_app_info - %d bytes",
932*5113495bSYour Name 		 fixed_params->ndp_cfg_len, fixed_params->ndp_app_info_len);
933*5113495bSYour Name 
934*5113495bSYour Name 	if (fixed_params->ndp_cfg_len >
935*5113495bSYour Name 			(WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
936*5113495bSYour Name 		wmi_err("excess wmi buffer: ndp_cfg_len %d",
937*5113495bSYour Name 			fixed_params->ndp_cfg_len);
938*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
939*5113495bSYour Name 	}
940*5113495bSYour Name 
941*5113495bSYour Name 	total_array_len = fixed_params->ndp_cfg_len +
942*5113495bSYour Name 				sizeof(*fixed_params);
943*5113495bSYour Name 
944*5113495bSYour Name 	if (fixed_params->ndp_app_info_len >
945*5113495bSYour Name 		(WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
946*5113495bSYour Name 		wmi_err("excess wmi buffer: ndp_cfg_len %d",
947*5113495bSYour Name 			fixed_params->ndp_app_info_len);
948*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
949*5113495bSYour Name 	}
950*5113495bSYour Name 
951*5113495bSYour Name 	if (fixed_params->num_ndp_channels > event->num_ndp_channel_list ||
952*5113495bSYour Name 	    fixed_params->num_ndp_channels > event->num_nss_list) {
953*5113495bSYour Name 		wmi_err("NDP Ch count %d greater than NDP Ch TLV len(%d) or NSS TLV len(%d)",
954*5113495bSYour Name 			 fixed_params->num_ndp_channels,
955*5113495bSYour Name 			 event->num_ndp_channel_list,
956*5113495bSYour Name 			 event->num_nss_list);
957*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
958*5113495bSYour Name 	}
959*5113495bSYour Name 
960*5113495bSYour Name 	if (ndi_dbs &&
961*5113495bSYour Name 	    fixed_params->num_ndp_channels > event->num_ndp_channel_info) {
962*5113495bSYour Name 		wmi_err("NDP Ch count %d greater than NDP Ch info(%d)",
963*5113495bSYour Name 			 fixed_params->num_ndp_channels,
964*5113495bSYour Name 			 event->num_ndp_channel_info);
965*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
966*5113495bSYour Name 	}
967*5113495bSYour Name 
968*5113495bSYour Name 	rsp->vdev =
969*5113495bSYour Name 		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
970*5113495bSYour Name 						     fixed_params->vdev_id,
971*5113495bSYour Name 						     WLAN_NAN_ID);
972*5113495bSYour Name 	if (!rsp->vdev) {
973*5113495bSYour Name 		wmi_err("vdev is null");
974*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
975*5113495bSYour Name 	}
976*5113495bSYour Name 	rsp->ndp_instance_id = fixed_params->ndp_instance_id;
977*5113495bSYour Name 	rsp->rsp_code = fixed_params->rsp_code;
978*5113495bSYour Name 	rsp->reason_code = fixed_params->reason_code;
979*5113495bSYour Name 	rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
980*5113495bSYour Name 	rsp->num_channels = fixed_params->num_ndp_channels;
981*5113495bSYour Name 	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
982*5113495bSYour Name 				   rsp->peer_ndi_mac_addr.bytes);
983*5113495bSYour Name 	rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
984*5113495bSYour Name 
985*5113495bSYour Name 	if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
986*5113495bSYour Name 		rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
987*5113495bSYour Name 
988*5113495bSYour Name 	qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
989*5113495bSYour Name 		     rsp->ndp_info.ndp_app_info_len);
990*5113495bSYour Name 
991*5113495bSYour Name 	if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
992*5113495bSYour Name 		wmi_err("too many channels");
993*5113495bSYour Name 		rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
994*5113495bSYour Name 	}
995*5113495bSYour Name 
996*5113495bSYour Name 	for (i = 0; i < rsp->num_channels; i++) {
997*5113495bSYour Name 		rsp->ch[i].freq = event->ndp_channel_list[i].mhz;
998*5113495bSYour Name 		rsp->ch[i].nss = event->nss_list[i];
999*5113495bSYour Name 		ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
1000*5113495bSYour Name 		rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
1001*5113495bSYour Name 								     ch_mode);
1002*5113495bSYour Name 		if (ndi_dbs) {
1003*5113495bSYour Name 			rsp->ch[i].mac_id = event->ndp_channel_info[i].mac_id;
1004*5113495bSYour Name 			wmi_debug("Freq: %d, ch_mode: %d, nss: %d mac_id: %d",
1005*5113495bSYour Name 				 rsp->ch[i].freq, rsp->ch[i].ch_width,
1006*5113495bSYour Name 				 rsp->ch[i].nss, rsp->ch[i].mac_id);
1007*5113495bSYour Name 		} else {
1008*5113495bSYour Name 			wmi_debug("Freq: %d, ch_mode: %d, nss: %d",
1009*5113495bSYour Name 				 rsp->ch[i].freq, rsp->ch[i].ch_width,
1010*5113495bSYour Name 				 rsp->ch[i].nss);
1011*5113495bSYour Name 		}
1012*5113495bSYour Name 	}
1013*5113495bSYour Name 
1014*5113495bSYour Name 	if (event->ndp_transport_ip_param &&
1015*5113495bSYour Name 	    event->num_ndp_transport_ip_param) {
1016*5113495bSYour Name 		if (event->ndp_transport_ip_param->ipv6_addr_present) {
1017*5113495bSYour Name 			rsp->is_ipv6_addr_present = true;
1018*5113495bSYour Name 			qdf_mem_copy(rsp->ipv6_addr,
1019*5113495bSYour Name 				event->ndp_transport_ip_param->ipv6_intf_addr,
1020*5113495bSYour Name 				WMI_NDP_IPV6_INTF_ADDR_LEN);
1021*5113495bSYour Name 		}
1022*5113495bSYour Name 
1023*5113495bSYour Name 		if (event->ndp_transport_ip_param->trans_port_present) {
1024*5113495bSYour Name 			rsp->is_port_present = true;
1025*5113495bSYour Name 			rsp->port =
1026*5113495bSYour Name 			    event->ndp_transport_ip_param->transport_port;
1027*5113495bSYour Name 		}
1028*5113495bSYour Name 
1029*5113495bSYour Name 		if (event->ndp_transport_ip_param->trans_proto_present) {
1030*5113495bSYour Name 			rsp->is_protocol_present = true;
1031*5113495bSYour Name 			rsp->protocol =
1032*5113495bSYour Name 			    event->ndp_transport_ip_param->transport_protocol;
1033*5113495bSYour Name 		}
1034*5113495bSYour Name 	}
1035*5113495bSYour Name 	wmi_debug("IPv6 addr present: %d, addr: %pI6 port: %d present: %d protocol: %d present: %d",
1036*5113495bSYour Name 		 rsp->is_ipv6_addr_present, rsp->ipv6_addr, rsp->port,
1037*5113495bSYour Name 		 rsp->is_port_present, rsp->protocol, rsp->is_protocol_present);
1038*5113495bSYour Name 
1039*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1040*5113495bSYour Name }
1041*5113495bSYour Name 
extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_responder_rsp * rsp)1042*5113495bSYour Name static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
1043*5113495bSYour Name 			uint8_t *data, struct nan_datapath_responder_rsp *rsp)
1044*5113495bSYour Name {
1045*5113495bSYour Name 	WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
1046*5113495bSYour Name 	wmi_ndp_responder_rsp_event_fixed_param  *fixed_params;
1047*5113495bSYour Name 
1048*5113495bSYour Name 	event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
1049*5113495bSYour Name 	fixed_params = event->fixed_param;
1050*5113495bSYour Name 
1051*5113495bSYour Name 	rsp->vdev =
1052*5113495bSYour Name 		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
1053*5113495bSYour Name 						     fixed_params->vdev_id,
1054*5113495bSYour Name 						     WLAN_NAN_ID);
1055*5113495bSYour Name 	if (!rsp->vdev) {
1056*5113495bSYour Name 		wmi_err("vdev is null");
1057*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1058*5113495bSYour Name 	}
1059*5113495bSYour Name 	rsp->transaction_id = fixed_params->transaction_id;
1060*5113495bSYour Name 	rsp->reason = fixed_params->reason_code;
1061*5113495bSYour Name 	rsp->status = fixed_params->rsp_status;
1062*5113495bSYour Name 	rsp->create_peer = fixed_params->create_peer;
1063*5113495bSYour Name 	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
1064*5113495bSYour Name 				   rsp->peer_mac_addr.bytes);
1065*5113495bSYour Name 	wmi_debug("WMI_NDP_RESPONDER_RSP_EVENTID(0x%X) received. vdev_id: %d, peer_mac_addr: "QDF_MAC_ADDR_FMT",transaction_id: %d, status_code %d, reason_code: %d, create_peer: %d",
1066*5113495bSYour Name 		 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
1067*5113495bSYour Name 		 QDF_MAC_ADDR_REF(rsp->peer_mac_addr.bytes),
1068*5113495bSYour Name 		 rsp->transaction_id,
1069*5113495bSYour Name 		 rsp->status, rsp->reason, rsp->create_peer);
1070*5113495bSYour Name 
1071*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1072*5113495bSYour Name }
1073*5113495bSYour Name 
extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_end_rsp_event * rsp)1074*5113495bSYour Name static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
1075*5113495bSYour Name 			uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
1076*5113495bSYour Name {
1077*5113495bSYour Name 	WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
1078*5113495bSYour Name 	wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
1079*5113495bSYour Name 
1080*5113495bSYour Name 	event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
1081*5113495bSYour Name 	fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
1082*5113495bSYour Name 	wmi_debug("WMI_NDP_END_RSP_EVENTID(0x%X) received. transaction_id: %d, rsp_status: %d, reason_code: %d",
1083*5113495bSYour Name 		 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
1084*5113495bSYour Name 		 fixed_params->rsp_status, fixed_params->reason_code);
1085*5113495bSYour Name 
1086*5113495bSYour Name 	rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
1087*5113495bSYour Name 			wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
1088*5113495bSYour Name 	if (!rsp->vdev) {
1089*5113495bSYour Name 		wmi_err("vdev is null");
1090*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1091*5113495bSYour Name 	}
1092*5113495bSYour Name 	rsp->transaction_id = fixed_params->transaction_id;
1093*5113495bSYour Name 	rsp->reason = fixed_params->reason_code;
1094*5113495bSYour Name 	rsp->status = fixed_params->rsp_status;
1095*5113495bSYour Name 
1096*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1097*5113495bSYour Name }
1098*5113495bSYour Name 
extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_end_indication_event ** rsp)1099*5113495bSYour Name static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
1100*5113495bSYour Name 		uint8_t *data, struct nan_datapath_end_indication_event **rsp)
1101*5113495bSYour Name {
1102*5113495bSYour Name 	uint32_t i, buf_size;
1103*5113495bSYour Name 	wmi_ndp_end_indication *ind;
1104*5113495bSYour Name 	struct qdf_mac_addr peer_addr;
1105*5113495bSYour Name 	WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
1106*5113495bSYour Name 
1107*5113495bSYour Name 	event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
1108*5113495bSYour Name 	ind = event->ndp_end_indication_list;
1109*5113495bSYour Name 
1110*5113495bSYour Name 	if (event->num_ndp_end_indication_list == 0) {
1111*5113495bSYour Name 		wmi_err("Error: Event ignored, 0 ndp instances");
1112*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1113*5113495bSYour Name 	}
1114*5113495bSYour Name 
1115*5113495bSYour Name 	wmi_debug("number of ndp instances = %d",
1116*5113495bSYour Name 		 event->num_ndp_end_indication_list);
1117*5113495bSYour Name 
1118*5113495bSYour Name 	if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
1119*5113495bSYour Name 						sizeof((*rsp)->ndp_map[0]))) {
1120*5113495bSYour Name 		wmi_err("num_ndp_end_ind_list %d too large",
1121*5113495bSYour Name 			 event->num_ndp_end_indication_list);
1122*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1123*5113495bSYour Name 	}
1124*5113495bSYour Name 
1125*5113495bSYour Name 	buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
1126*5113495bSYour Name 			sizeof((*rsp)->ndp_map[0]);
1127*5113495bSYour Name 	*rsp = qdf_mem_malloc(buf_size);
1128*5113495bSYour Name 	if (!(*rsp))
1129*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
1130*5113495bSYour Name 
1131*5113495bSYour Name 	(*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
1132*5113495bSYour Name 	for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
1133*5113495bSYour Name 		WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
1134*5113495bSYour Name 					   peer_addr.bytes);
1135*5113495bSYour Name 		wmi_debug("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
1136*5113495bSYour Name 			 i, ind[i].type, ind[i].reason_code,
1137*5113495bSYour Name 			 ind[i].ndp_instance_id,
1138*5113495bSYour Name 			 ind[i].num_active_ndps_on_peer);
1139*5113495bSYour Name 		/* Add each instance entry to the list */
1140*5113495bSYour Name 		(*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
1141*5113495bSYour Name 		(*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
1142*5113495bSYour Name 		WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
1143*5113495bSYour Name 			(*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
1144*5113495bSYour Name 		(*rsp)->ndp_map[i].num_active_ndp_sessions =
1145*5113495bSYour Name 			ind[i].num_active_ndps_on_peer;
1146*5113495bSYour Name 		(*rsp)->ndp_map[i].type = ind[i].type;
1147*5113495bSYour Name 		(*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
1148*5113495bSYour Name 	}
1149*5113495bSYour Name 
1150*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1151*5113495bSYour Name }
1152*5113495bSYour Name 
extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,uint8_t * data,struct nan_datapath_sch_update_event * ind)1153*5113495bSYour Name static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
1154*5113495bSYour Name 		uint8_t *data, struct nan_datapath_sch_update_event *ind)
1155*5113495bSYour Name {
1156*5113495bSYour Name 	uint8_t i;
1157*5113495bSYour Name 	WMI_HOST_WLAN_PHY_MODE ch_mode;
1158*5113495bSYour Name 	WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
1159*5113495bSYour Name 	wmi_ndl_schedule_update_fixed_param *fixed_params;
1160*5113495bSYour Name 	bool ndi_dbs = wmi_service_enabled(wmi_handle,
1161*5113495bSYour Name 					   wmi_service_ndi_dbs_support);
1162*5113495bSYour Name 
1163*5113495bSYour Name 	event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
1164*5113495bSYour Name 	fixed_params = event->fixed_param;
1165*5113495bSYour Name 
1166*5113495bSYour Name 	wmi_debug("flags: %d, num_ch: %d, num_ndp_instances: %d",
1167*5113495bSYour Name 		 fixed_params->flags, fixed_params->num_channels,
1168*5113495bSYour Name 		 fixed_params->num_ndp_instances);
1169*5113495bSYour Name 
1170*5113495bSYour Name 	if (fixed_params->num_channels > event->num_ndl_channel_list ||
1171*5113495bSYour Name 	    fixed_params->num_channels > event->num_nss_list) {
1172*5113495bSYour Name 		wmi_err("Channel count %d greater than NDP Ch list TLV len(%d) or NSS list TLV len(%d)",
1173*5113495bSYour Name 			 fixed_params->num_channels,
1174*5113495bSYour Name 			 event->num_ndl_channel_list,
1175*5113495bSYour Name 			 event->num_nss_list);
1176*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1177*5113495bSYour Name 	}
1178*5113495bSYour Name 
1179*5113495bSYour Name 	if (ndi_dbs &&
1180*5113495bSYour Name 	    fixed_params->num_channels > event->num_ndp_channel_info) {
1181*5113495bSYour Name 		wmi_err("Channel count %d greater than NDP Ch info(%d)",
1182*5113495bSYour Name 			 fixed_params->num_channels,
1183*5113495bSYour Name 			 event->num_ndp_channel_info);
1184*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1185*5113495bSYour Name 	}
1186*5113495bSYour Name 
1187*5113495bSYour Name 	if (fixed_params->num_ndp_instances > event->num_ndp_instance_list) {
1188*5113495bSYour Name 		wmi_err("NDP Instance count %d greater than NDP Instancei TLV len %d",
1189*5113495bSYour Name 			 fixed_params->num_ndp_instances,
1190*5113495bSYour Name 			 event->num_ndp_instance_list);
1191*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1192*5113495bSYour Name 	}
1193*5113495bSYour Name 
1194*5113495bSYour Name 	ind->vdev =
1195*5113495bSYour Name 		wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
1196*5113495bSYour Name 						     fixed_params->vdev_id,
1197*5113495bSYour Name 						     WLAN_NAN_ID);
1198*5113495bSYour Name 	if (!ind->vdev) {
1199*5113495bSYour Name 		wmi_err("vdev is null");
1200*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1201*5113495bSYour Name 	}
1202*5113495bSYour Name 
1203*5113495bSYour Name 	ind->flags = fixed_params->flags;
1204*5113495bSYour Name 	ind->num_channels = fixed_params->num_channels;
1205*5113495bSYour Name 	ind->num_ndp_instances = fixed_params->num_ndp_instances;
1206*5113495bSYour Name 	WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
1207*5113495bSYour Name 				   ind->peer_addr.bytes);
1208*5113495bSYour Name 
1209*5113495bSYour Name 	if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
1210*5113495bSYour Name 		wmi_err("uint32 overflow");
1211*5113495bSYour Name 		wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
1212*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
1213*5113495bSYour Name 	}
1214*5113495bSYour Name 
1215*5113495bSYour Name 	qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
1216*5113495bSYour Name 		     sizeof(uint32_t) * ind->num_ndp_instances);
1217*5113495bSYour Name 
1218*5113495bSYour Name 	if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
1219*5113495bSYour Name 		wmi_err("too many channels");
1220*5113495bSYour Name 		ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
1221*5113495bSYour Name 	}
1222*5113495bSYour Name 
1223*5113495bSYour Name 	for (i = 0; i < ind->num_channels; i++) {
1224*5113495bSYour Name 		ind->ch[i].freq = event->ndl_channel_list[i].mhz;
1225*5113495bSYour Name 		ind->ch[i].nss = event->nss_list[i];
1226*5113495bSYour Name 		ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
1227*5113495bSYour Name 		ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
1228*5113495bSYour Name 								     ch_mode);
1229*5113495bSYour Name 		if (ndi_dbs) {
1230*5113495bSYour Name 			ind->ch[i].mac_id = event->ndp_channel_info[i].mac_id;
1231*5113495bSYour Name 			wmi_debug("Freq: %d, ch_mode: %d, nss: %d mac_id: %d",
1232*5113495bSYour Name 				 ind->ch[i].freq, ind->ch[i].ch_width,
1233*5113495bSYour Name 				 ind->ch[i].nss, ind->ch[i].mac_id);
1234*5113495bSYour Name 		} else {
1235*5113495bSYour Name 			wmi_debug("Freq: %d, ch_mode: %d, nss: %d",
1236*5113495bSYour Name 				 ind->ch[i].freq, ind->ch[i].ch_width,
1237*5113495bSYour Name 				 ind->ch[i].nss);
1238*5113495bSYour Name 		}
1239*5113495bSYour Name 	}
1240*5113495bSYour Name 
1241*5113495bSYour Name 	for (i = 0; i < fixed_params->num_ndp_instances; i++)
1242*5113495bSYour Name 		wmi_debug("instance_id[%d]: %d",
1243*5113495bSYour Name 			 i, event->ndp_instance_list[i]);
1244*5113495bSYour Name 
1245*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1246*5113495bSYour Name }
1247*5113495bSYour Name 
wmi_nan_attach_tlv(wmi_unified_t wmi_handle)1248*5113495bSYour Name void wmi_nan_attach_tlv(wmi_unified_t wmi_handle)
1249*5113495bSYour Name {
1250*5113495bSYour Name 	struct wmi_ops *ops = wmi_handle->ops;
1251*5113495bSYour Name 
1252*5113495bSYour Name 	ops->send_nan_req_cmd = send_nan_req_cmd_tlv;
1253*5113495bSYour Name 	ops->send_nan_disable_req_cmd = send_nan_disable_req_cmd_tlv;
1254*5113495bSYour Name 	ops->extract_nan_event_rsp = extract_nan_event_rsp_tlv;
1255*5113495bSYour Name 	ops->send_terminate_all_ndps_req_cmd = send_terminate_all_ndps_cmd_tlv;
1256*5113495bSYour Name 	ops->send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv;
1257*5113495bSYour Name 	ops->send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv;
1258*5113495bSYour Name 	ops->send_ndp_end_req_cmd = nan_ndp_end_req_tlv;
1259*5113495bSYour Name 	ops->extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv;
1260*5113495bSYour Name 	ops->extract_ndp_ind = extract_ndp_ind_tlv;
1261*5113495bSYour Name 	ops->extract_nan_msg = extract_nan_msg_tlv,
1262*5113495bSYour Name 	ops->extract_ndp_confirm = extract_ndp_confirm_tlv;
1263*5113495bSYour Name 	ops->extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv;
1264*5113495bSYour Name 	ops->extract_ndp_end_rsp = extract_ndp_end_rsp_tlv;
1265*5113495bSYour Name 	ops->extract_ndp_end_ind = extract_ndp_end_ind_tlv;
1266*5113495bSYour Name 	ops->extract_ndp_sch_update = extract_ndp_sch_update_tlv;
1267*5113495bSYour Name 	ops->extract_ndp_host_event = extract_ndp_host_event_tlv;
1268*5113495bSYour Name }
1269