xref: /wlan-driver/qca-wifi-host-cmn/wmi/src/wmi_unified_fwol_tlv.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022 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 "wlan_fwol_public_structs.h"
24*5113495bSYour Name #include "wmi_unified_fwol_api.h"
25*5113495bSYour Name 
26*5113495bSYour Name #ifdef WLAN_FEATURE_ELNA
27*5113495bSYour Name /**
28*5113495bSYour Name  * send_set_elna_bypass_cmd_tlv() - send set elna bypass cmd to fw
29*5113495bSYour Name  * @wmi_handle: wmi handle
30*5113495bSYour Name  * @req: set eLNA bypass request
31*5113495bSYour Name  *
32*5113495bSYour Name  * Send WMI_SET_ELNA_BYPASS_CMDID to fw.
33*5113495bSYour Name  *
34*5113495bSYour Name  * Return: QDF_STATUS
35*5113495bSYour Name  */
36*5113495bSYour Name static QDF_STATUS
send_set_elna_bypass_cmd_tlv(wmi_unified_t wmi_handle,struct set_elna_bypass_request * req)37*5113495bSYour Name send_set_elna_bypass_cmd_tlv(wmi_unified_t wmi_handle,
38*5113495bSYour Name 			     struct set_elna_bypass_request *req)
39*5113495bSYour Name {
40*5113495bSYour Name 	wmi_buf_t buf;
41*5113495bSYour Name 	wmi_set_elna_bypass_cmd_fixed_param *cmd;
42*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
43*5113495bSYour Name 	QDF_STATUS ret;
44*5113495bSYour Name 
45*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
46*5113495bSYour Name 	if (!buf) {
47*5113495bSYour Name 		wmi_err("Failed to allocate wmi buffer");
48*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
49*5113495bSYour Name 	}
50*5113495bSYour Name 
51*5113495bSYour Name 	cmd = (wmi_set_elna_bypass_cmd_fixed_param *)wmi_buf_data(buf);
52*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
53*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_set_elna_bypass_cmd_fixed_param,
54*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
55*5113495bSYour Name 		       (wmi_set_elna_bypass_cmd_fixed_param));
56*5113495bSYour Name 	cmd->vdev_id = req->vdev_id;
57*5113495bSYour Name 	cmd->en_dis = req->elna_mode;
58*5113495bSYour Name 	wmi_mtrace(WMI_SET_ELNA_BYPASS_CMDID, req->vdev_id, req->elna_mode);
59*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
60*5113495bSYour Name 				   WMI_SET_ELNA_BYPASS_CMDID);
61*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
62*5113495bSYour Name 		wmi_err("Failed to send set param command ret = %d", ret);
63*5113495bSYour Name 		wmi_buf_free(buf);
64*5113495bSYour Name 	}
65*5113495bSYour Name 
66*5113495bSYour Name 	return ret;
67*5113495bSYour Name }
68*5113495bSYour Name 
69*5113495bSYour Name /**
70*5113495bSYour Name  * send_get_elna_bypass_cmd_tlv() - send get elna bypass cmd to fw
71*5113495bSYour Name  * @wmi_handle: wmi handle
72*5113495bSYour Name  * @req: get eLNA bypass request
73*5113495bSYour Name  *
74*5113495bSYour Name  * Send WMI_GET_ELNA_BYPASS_CMDID to fw.
75*5113495bSYour Name  *
76*5113495bSYour Name  * Return: QDF_STATUS
77*5113495bSYour Name  */
78*5113495bSYour Name static QDF_STATUS
send_get_elna_bypass_cmd_tlv(wmi_unified_t wmi_handle,struct get_elna_bypass_request * req)79*5113495bSYour Name send_get_elna_bypass_cmd_tlv(wmi_unified_t wmi_handle,
80*5113495bSYour Name 			     struct get_elna_bypass_request *req)
81*5113495bSYour Name {
82*5113495bSYour Name 	wmi_buf_t buf;
83*5113495bSYour Name 	wmi_get_elna_bypass_cmd_fixed_param *cmd;
84*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
85*5113495bSYour Name 	QDF_STATUS ret;
86*5113495bSYour Name 
87*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
88*5113495bSYour Name 	if (!buf) {
89*5113495bSYour Name 		wmi_err("Failed to allocate wmi buffer");
90*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
91*5113495bSYour Name 	}
92*5113495bSYour Name 
93*5113495bSYour Name 	cmd = (wmi_get_elna_bypass_cmd_fixed_param *)wmi_buf_data(buf);
94*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
95*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_get_elna_bypass_cmd_fixed_param,
96*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
97*5113495bSYour Name 		       (wmi_get_elna_bypass_cmd_fixed_param));
98*5113495bSYour Name 	cmd->vdev_id = req->vdev_id;
99*5113495bSYour Name 	wmi_mtrace(WMI_GET_ELNA_BYPASS_CMDID, req->vdev_id, 0);
100*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
101*5113495bSYour Name 				   WMI_GET_ELNA_BYPASS_CMDID);
102*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
103*5113495bSYour Name 		wmi_err("Failed to send set param command ret = %d", ret);
104*5113495bSYour Name 		wmi_buf_free(buf);
105*5113495bSYour Name 	}
106*5113495bSYour Name 
107*5113495bSYour Name 	return ret;
108*5113495bSYour Name }
109*5113495bSYour Name 
110*5113495bSYour Name /**
111*5113495bSYour Name  * extract_get_elna_bypass_resp_tlv() - Extract WMI get eLNA bypass response
112*5113495bSYour Name  * @wmi_handle: wmi handle
113*5113495bSYour Name  * @resp_buf: response buffer
114*5113495bSYour Name  * @resp: get eLNA bypass response
115*5113495bSYour Name  *
116*5113495bSYour Name  * Extract WMI get eLNA bypass response from firmware.
117*5113495bSYour Name  *
118*5113495bSYour Name  * Return: QDF_STATUS
119*5113495bSYour Name  */
120*5113495bSYour Name static QDF_STATUS
extract_get_elna_bypass_resp_tlv(struct wmi_unified * wmi_handle,void * resp_buf,struct get_elna_bypass_response * resp)121*5113495bSYour Name extract_get_elna_bypass_resp_tlv(struct wmi_unified *wmi_handle, void *resp_buf,
122*5113495bSYour Name 				 struct get_elna_bypass_response *resp)
123*5113495bSYour Name {
124*5113495bSYour Name 	WMI_GET_ELNA_BYPASS_EVENTID_param_tlvs *param_buf;
125*5113495bSYour Name 	wmi_get_elna_bypass_event_fixed_param *evt;
126*5113495bSYour Name 
127*5113495bSYour Name 	param_buf = resp_buf;
128*5113495bSYour Name 	evt = param_buf->fixed_param;
129*5113495bSYour Name 	if (!evt) {
130*5113495bSYour Name 		wmi_err("Invalid get elna bypass event");
131*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
132*5113495bSYour Name 	}
133*5113495bSYour Name 
134*5113495bSYour Name 	wmi_debug("Get elna bypass %d from vdev %d",
135*5113495bSYour Name 		  evt->en_dis, evt->vdev_id);
136*5113495bSYour Name 
137*5113495bSYour Name 	resp->vdev_id = evt->vdev_id;
138*5113495bSYour Name 	resp->elna_mode = evt->en_dis;
139*5113495bSYour Name 
140*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
141*5113495bSYour Name }
142*5113495bSYour Name #endif /* WLAN_FEATURE_ELNA */
143*5113495bSYour Name 
144*5113495bSYour Name #ifdef WLAN_FEATURE_ELNA
wmi_fwol_attach_elna_tlv(struct wmi_ops * ops)145*5113495bSYour Name static void wmi_fwol_attach_elna_tlv(struct wmi_ops *ops)
146*5113495bSYour Name {
147*5113495bSYour Name 	ops->send_set_elna_bypass_cmd = send_set_elna_bypass_cmd_tlv;
148*5113495bSYour Name 	ops->send_get_elna_bypass_cmd = send_get_elna_bypass_cmd_tlv;
149*5113495bSYour Name 	ops->extract_get_elna_bypass_resp = extract_get_elna_bypass_resp_tlv;
150*5113495bSYour Name }
151*5113495bSYour Name #else
wmi_fwol_attach_elna_tlv(struct wmi_ops * ops)152*5113495bSYour Name static void wmi_fwol_attach_elna_tlv(struct wmi_ops *ops)
153*5113495bSYour Name {
154*5113495bSYour Name }
155*5113495bSYour Name #endif /* WLAN_FEATURE_ELNA */
156*5113495bSYour Name 
157*5113495bSYour Name #ifdef WLAN_SEND_DSCP_UP_MAP_TO_FW
158*5113495bSYour Name /**
159*5113495bSYour Name  * send_dscp_tid_map_cmd_tlv() - send dscp to tid map  cmd to fw
160*5113495bSYour Name  * @wmi_handle: wmi handle
161*5113495bSYour Name  * @dscp_to_tid_map: array of dscp to tid map values
162*5113495bSYour Name  *
163*5113495bSYour Name  * Send WMI_PDEV_SET_DSCP_TID_MAP_CMDID to fw.
164*5113495bSYour Name  *
165*5113495bSYour Name  * Return: QDF_STATUS
166*5113495bSYour Name  */
167*5113495bSYour Name static QDF_STATUS
send_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,uint32_t * dscp_to_tid_map)168*5113495bSYour Name send_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
169*5113495bSYour Name 			  uint32_t *dscp_to_tid_map)
170*5113495bSYour Name {
171*5113495bSYour Name 	QDF_STATUS status;
172*5113495bSYour Name 	wmi_pdev_set_dscp_tid_map_cmd_fixed_param *cmd;
173*5113495bSYour Name 	wmi_buf_t buf;
174*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
175*5113495bSYour Name 
176*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
177*5113495bSYour Name 	if (!buf) {
178*5113495bSYour Name 		wmi_err("Failed to allocate wmi buffer");
179*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
180*5113495bSYour Name 	}
181*5113495bSYour Name 
182*5113495bSYour Name 	cmd = (wmi_pdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
183*5113495bSYour Name 	WMITLV_SET_HDR(
184*5113495bSYour Name 		&cmd->tlv_header,
185*5113495bSYour Name 		WMITLV_TAG_STRUC_wmi_pdev_set_dscp_tid_map_cmd_fixed_param,
186*5113495bSYour Name 		WMITLV_GET_STRUCT_TLVLEN
187*5113495bSYour Name 		(wmi_pdev_set_dscp_tid_map_cmd_fixed_param));
188*5113495bSYour Name 	cmd->reserved0 = WMI_PDEV_ID_SOC;
189*5113495bSYour Name 	qdf_mem_copy(&cmd->dscp_to_tid_map, dscp_to_tid_map,
190*5113495bSYour Name 		     sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
191*5113495bSYour Name 
192*5113495bSYour Name 	status = wmi_unified_cmd_send(wmi_handle, buf, len,
193*5113495bSYour Name 				      WMI_PDEV_SET_DSCP_TID_MAP_CMDID);
194*5113495bSYour Name 	if (status) {
195*5113495bSYour Name 		wmi_err("Failed to send dscp_up_map_to_fw %d", status);
196*5113495bSYour Name 		wmi_buf_free(buf);
197*5113495bSYour Name 	}
198*5113495bSYour Name 
199*5113495bSYour Name 	return status;
200*5113495bSYour Name }
201*5113495bSYour Name 
wmi_fwol_attach_dscp_tid_tlv(struct wmi_ops * ops)202*5113495bSYour Name static void wmi_fwol_attach_dscp_tid_tlv(struct wmi_ops *ops)
203*5113495bSYour Name {
204*5113495bSYour Name 	ops->send_dscp_tid_map_cmd = send_dscp_tid_map_cmd_tlv;
205*5113495bSYour Name }
206*5113495bSYour Name #else
wmi_fwol_attach_dscp_tid_tlv(struct wmi_ops * ops)207*5113495bSYour Name static void wmi_fwol_attach_dscp_tid_tlv(struct wmi_ops *ops)
208*5113495bSYour Name {
209*5113495bSYour Name }
210*5113495bSYour Name #endif /* WLAN_SEND_DSCP_UP_MAP_TO_FW */
211*5113495bSYour Name 
212*5113495bSYour Name #ifdef WLAN_FEATURE_MDNS_OFFLOAD
213*5113495bSYour Name /**
214*5113495bSYour Name  * send_set_mdns_fqdn_cmd_tlv() - send set mDNS FQDN cmd to fw
215*5113495bSYour Name  * @wmi_handle: wmi handle
216*5113495bSYour Name  * @mdns_info: mDNS config info
217*5113495bSYour Name  *
218*5113495bSYour Name  * Send WMI_MDNS_SET_FQDN_CMDID to fw.
219*5113495bSYour Name  *
220*5113495bSYour Name  * Return: QDF_STATUS
221*5113495bSYour Name  */
222*5113495bSYour Name static QDF_STATUS
send_set_mdns_fqdn_cmd_tlv(wmi_unified_t wmi_handle,struct mdns_config_info * mdns_info)223*5113495bSYour Name send_set_mdns_fqdn_cmd_tlv(wmi_unified_t wmi_handle,
224*5113495bSYour Name 			   struct mdns_config_info *mdns_info)
225*5113495bSYour Name {
226*5113495bSYour Name 	wmi_buf_t buf;
227*5113495bSYour Name 	uint8_t *buf_ptr;
228*5113495bSYour Name 	wmi_mdns_set_fqdn_cmd_fixed_param *cmd;
229*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
230*5113495bSYour Name 	uint16_t fqdn_len_aligned;
231*5113495bSYour Name 	QDF_STATUS ret;
232*5113495bSYour Name 
233*5113495bSYour Name 	fqdn_len_aligned = roundup(mdns_info->fqdn_len, sizeof(uint32_t));
234*5113495bSYour Name 	if (fqdn_len_aligned < mdns_info->fqdn_len) {
235*5113495bSYour Name 		wmi_err_rl("integer overflow while rounding up data_len");
236*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
237*5113495bSYour Name 	}
238*5113495bSYour Name 
239*5113495bSYour Name 	if (fqdn_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
240*5113495bSYour Name 		wmi_err_rl("wmi_max_msg_size overflow for given data_len");
241*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
242*5113495bSYour Name 	}
243*5113495bSYour Name 
244*5113495bSYour Name 	len += WMI_TLV_HDR_SIZE + fqdn_len_aligned;
245*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
246*5113495bSYour Name 	if (!buf) {
247*5113495bSYour Name 		wmi_err_rl("Failed to allocate wmi buffer");
248*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
249*5113495bSYour Name 	}
250*5113495bSYour Name 
251*5113495bSYour Name 	buf_ptr = wmi_buf_data(buf);
252*5113495bSYour Name 	cmd = (wmi_mdns_set_fqdn_cmd_fixed_param *)buf_ptr;
253*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
254*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_mdns_set_fqdn_cmd_fixed_param,
255*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
256*5113495bSYour Name 		       (wmi_mdns_set_fqdn_cmd_fixed_param));
257*5113495bSYour Name 	cmd->vdev_id = mdns_info->vdev_id;
258*5113495bSYour Name 	cmd->type = mdns_info->fqdn_type;
259*5113495bSYour Name 	cmd->fqdn_len = mdns_info->fqdn_len;
260*5113495bSYour Name 	buf_ptr += sizeof(*cmd);
261*5113495bSYour Name 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, fqdn_len_aligned);
262*5113495bSYour Name 	buf_ptr += WMI_TLV_HDR_SIZE;
263*5113495bSYour Name 	qdf_mem_copy(buf_ptr, mdns_info->fqdn_data, cmd->fqdn_len);
264*5113495bSYour Name 
265*5113495bSYour Name 	wmi_mtrace(WMI_MDNS_SET_FQDN_CMDID, mdns_info->vdev_id,
266*5113495bSYour Name 		   mdns_info->fqdn_type);
267*5113495bSYour Name 
268*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
269*5113495bSYour Name 				   WMI_MDNS_SET_FQDN_CMDID);
270*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret))
271*5113495bSYour Name 		wmi_buf_free(buf);
272*5113495bSYour Name 
273*5113495bSYour Name 	return ret;
274*5113495bSYour Name }
275*5113495bSYour Name 
276*5113495bSYour Name /**
277*5113495bSYour Name  * send_set_mdns_response_cmd_tlv() - send set mDNS response cmd to fw
278*5113495bSYour Name  * @wmi_handle: wmi handle
279*5113495bSYour Name  * @mdns_info: mDNS config info
280*5113495bSYour Name  *
281*5113495bSYour Name  * Send WMI_MDNS_SET_RESPONSE_CMDID to fw.
282*5113495bSYour Name  *
283*5113495bSYour Name  * Return: QDF_STATUS
284*5113495bSYour Name  */
285*5113495bSYour Name static QDF_STATUS
send_set_mdns_response_cmd_tlv(wmi_unified_t wmi_handle,struct mdns_config_info * mdns_info)286*5113495bSYour Name send_set_mdns_response_cmd_tlv(wmi_unified_t wmi_handle,
287*5113495bSYour Name 			       struct mdns_config_info *mdns_info)
288*5113495bSYour Name {
289*5113495bSYour Name 	wmi_buf_t buf;
290*5113495bSYour Name 	uint8_t *buf_ptr;
291*5113495bSYour Name 	wmi_mdns_set_resp_cmd_fixed_param *cmd;
292*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
293*5113495bSYour Name 	uint16_t resp_len_aligned;
294*5113495bSYour Name 	QDF_STATUS ret;
295*5113495bSYour Name 
296*5113495bSYour Name 	resp_len_aligned = roundup(mdns_info->answer_payload_len, sizeof(uint32_t));
297*5113495bSYour Name 	if (resp_len_aligned < mdns_info->answer_payload_len) {
298*5113495bSYour Name 		wmi_err_rl("integer overflow while rounding up data_len");
299*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
300*5113495bSYour Name 	}
301*5113495bSYour Name 
302*5113495bSYour Name 	if (resp_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
303*5113495bSYour Name 		wmi_err_rl("wmi_max_msg_size overflow for given data_len");
304*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
305*5113495bSYour Name 	}
306*5113495bSYour Name 
307*5113495bSYour Name 	len += WMI_TLV_HDR_SIZE + resp_len_aligned;
308*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
309*5113495bSYour Name 	if (!buf) {
310*5113495bSYour Name 		wmi_err_rl("Failed to allocate wmi buffer");
311*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
312*5113495bSYour Name 	}
313*5113495bSYour Name 
314*5113495bSYour Name 	buf_ptr = wmi_buf_data(buf);
315*5113495bSYour Name 	cmd = (wmi_mdns_set_resp_cmd_fixed_param *)buf_ptr;
316*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
317*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_mdns_set_resp_cmd_fixed_param,
318*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
319*5113495bSYour Name 		       (wmi_mdns_set_resp_cmd_fixed_param));
320*5113495bSYour Name 	cmd->vdev_id = mdns_info->vdev_id;
321*5113495bSYour Name 	cmd->AR_count = mdns_info->resource_record_count;
322*5113495bSYour Name 	cmd->resp_len = mdns_info->answer_payload_len;
323*5113495bSYour Name 	buf_ptr += sizeof(*cmd);
324*5113495bSYour Name 	WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, resp_len_aligned);
325*5113495bSYour Name 	buf_ptr += WMI_TLV_HDR_SIZE;
326*5113495bSYour Name 	qdf_mem_copy(buf_ptr, mdns_info->answer_payload_data, cmd->resp_len);
327*5113495bSYour Name 
328*5113495bSYour Name 	wmi_mtrace(WMI_MDNS_SET_RESPONSE_CMDID, mdns_info->vdev_id, 0);
329*5113495bSYour Name 
330*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
331*5113495bSYour Name 				   WMI_MDNS_SET_RESPONSE_CMDID);
332*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret))
333*5113495bSYour Name 		wmi_buf_free(buf);
334*5113495bSYour Name 
335*5113495bSYour Name 	return ret;
336*5113495bSYour Name }
337*5113495bSYour Name 
338*5113495bSYour Name /**
339*5113495bSYour Name  * send_set_mdns_offload_cmd_tlv() - send set mDNS offload cmd to fw
340*5113495bSYour Name  * @wmi_handle: wmi handle
341*5113495bSYour Name  * @mdns_info: mDNS config info
342*5113495bSYour Name  *
343*5113495bSYour Name  * Send WMI_MDNS_OFFLOAD_ENABLE_CMDID to fw.
344*5113495bSYour Name  *
345*5113495bSYour Name  * Return: QDF_STATUS
346*5113495bSYour Name  */
347*5113495bSYour Name static QDF_STATUS
send_set_mdns_offload_cmd_tlv(wmi_unified_t wmi_handle,struct mdns_config_info * mdns_info)348*5113495bSYour Name send_set_mdns_offload_cmd_tlv(wmi_unified_t wmi_handle,
349*5113495bSYour Name 			      struct mdns_config_info *mdns_info)
350*5113495bSYour Name {
351*5113495bSYour Name 	wmi_buf_t buf;
352*5113495bSYour Name 	wmi_mdns_offload_cmd_fixed_param *cmd;
353*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
354*5113495bSYour Name 	QDF_STATUS ret;
355*5113495bSYour Name 
356*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
357*5113495bSYour Name 	if (!buf) {
358*5113495bSYour Name 		wmi_err_rl("Failed to allocate wmi buffer");
359*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
360*5113495bSYour Name 	}
361*5113495bSYour Name 
362*5113495bSYour Name 	cmd = (wmi_mdns_offload_cmd_fixed_param *)wmi_buf_data(buf);
363*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
364*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_mdns_offload_cmd_fixed_param,
365*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
366*5113495bSYour Name 		       (wmi_mdns_offload_cmd_fixed_param));
367*5113495bSYour Name 	cmd->vdev_id = mdns_info->vdev_id;
368*5113495bSYour Name 	cmd->enable = mdns_info->enable;
369*5113495bSYour Name 
370*5113495bSYour Name 	wmi_mtrace(WMI_MDNS_OFFLOAD_ENABLE_CMDID, mdns_info->vdev_id, 0);
371*5113495bSYour Name 
372*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
373*5113495bSYour Name 				   WMI_MDNS_OFFLOAD_ENABLE_CMDID);
374*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret))
375*5113495bSYour Name 		wmi_buf_free(buf);
376*5113495bSYour Name 
377*5113495bSYour Name 	return ret;
378*5113495bSYour Name }
379*5113495bSYour Name 
380*5113495bSYour Name /**
381*5113495bSYour Name  * send_set_mdns_config_cmd_tlv() - send set mDNS config cmd to fw
382*5113495bSYour Name  * @wmi_handle: wmi handle
383*5113495bSYour Name  * @mdns_info: mdns config info
384*5113495bSYour Name  *
385*5113495bSYour Name  * Return: QDF_STATUS
386*5113495bSYour Name  */
387*5113495bSYour Name static QDF_STATUS
send_set_mdns_config_cmd_tlv(wmi_unified_t wmi_handle,struct mdns_config_info * mdns_info)388*5113495bSYour Name send_set_mdns_config_cmd_tlv(wmi_unified_t wmi_handle,
389*5113495bSYour Name 			     struct mdns_config_info *mdns_info)
390*5113495bSYour Name {
391*5113495bSYour Name 	QDF_STATUS ret;
392*5113495bSYour Name 
393*5113495bSYour Name 	if (!mdns_info->enable) {
394*5113495bSYour Name 		ret = send_set_mdns_offload_cmd_tlv(wmi_handle, mdns_info);
395*5113495bSYour Name 		if (QDF_IS_STATUS_ERROR(ret))
396*5113495bSYour Name 			wmi_err_rl("Failed to send mDNS offload command. ret = %d", ret);
397*5113495bSYour Name 
398*5113495bSYour Name 		return ret;
399*5113495bSYour Name 	}
400*5113495bSYour Name 
401*5113495bSYour Name 	ret = send_set_mdns_fqdn_cmd_tlv(wmi_handle, mdns_info);
402*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
403*5113495bSYour Name 		wmi_err_rl("Failed to send set fqdn command. ret = %d", ret);
404*5113495bSYour Name 		return ret;
405*5113495bSYour Name 	}
406*5113495bSYour Name 
407*5113495bSYour Name 	ret = send_set_mdns_response_cmd_tlv(wmi_handle, mdns_info);
408*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
409*5113495bSYour Name 		wmi_err_rl("Failed to send set mDNS response command. ret = %d", ret);
410*5113495bSYour Name 		return ret;
411*5113495bSYour Name 	}
412*5113495bSYour Name 
413*5113495bSYour Name 	ret = send_set_mdns_offload_cmd_tlv(wmi_handle, mdns_info);
414*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
415*5113495bSYour Name 		wmi_err_rl("Failed to send set mDNS offload  command. ret = %d", ret);
416*5113495bSYour Name 		return ret;
417*5113495bSYour Name 	}
418*5113495bSYour Name 
419*5113495bSYour Name 	return ret;
420*5113495bSYour Name }
421*5113495bSYour Name 
wmi_fwol_attach_mdns_tlv(struct wmi_ops * ops)422*5113495bSYour Name static void wmi_fwol_attach_mdns_tlv(struct wmi_ops *ops)
423*5113495bSYour Name {
424*5113495bSYour Name 	ops->send_set_mdns_config_cmd = send_set_mdns_config_cmd_tlv;
425*5113495bSYour Name }
426*5113495bSYour Name #else
wmi_fwol_attach_mdns_tlv(struct wmi_ops * ops)427*5113495bSYour Name static void wmi_fwol_attach_mdns_tlv(struct wmi_ops *ops)
428*5113495bSYour Name {
429*5113495bSYour Name }
430*5113495bSYour Name #endif /* WLAN_FEATURE_MDNS_OFFLOAD */
431*5113495bSYour Name 
432*5113495bSYour Name #ifdef THERMAL_STATS_SUPPORT
433*5113495bSYour Name /**
434*5113495bSYour Name  * send_get_thermal_stats_cmd_tlv() - send get thermal stats cmd to fw
435*5113495bSYour Name  * @wmi_handle: wmi handle
436*5113495bSYour Name  * @req_type: req type
437*5113495bSYour Name  * @temp_offset: temperature offset
438*5113495bSYour Name  *
439*5113495bSYour Name  * Send WMI_REQUEST_THERMAL_STATS_CMDID to fw.
440*5113495bSYour Name  *
441*5113495bSYour Name  * Return: QDF_STATUS
442*5113495bSYour Name  */
443*5113495bSYour Name static QDF_STATUS
send_get_thermal_stats_cmd_tlv(wmi_unified_t wmi_handle,enum thermal_stats_request_type req_type,uint8_t temp_offset)444*5113495bSYour Name send_get_thermal_stats_cmd_tlv(wmi_unified_t wmi_handle,
445*5113495bSYour Name 			       enum thermal_stats_request_type req_type,
446*5113495bSYour Name 			       uint8_t temp_offset)
447*5113495bSYour Name {
448*5113495bSYour Name 	wmi_buf_t buf;
449*5113495bSYour Name 	wmi_thermal_stats_cmd_fixed_param *cmd;
450*5113495bSYour Name 	uint16_t len = sizeof(*cmd);
451*5113495bSYour Name 	QDF_STATUS ret;
452*5113495bSYour Name 
453*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
454*5113495bSYour Name 	if (!buf) {
455*5113495bSYour Name 		wmi_err("Failed to allocate wmi buffer");
456*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
457*5113495bSYour Name 	}
458*5113495bSYour Name 
459*5113495bSYour Name 	cmd = (wmi_thermal_stats_cmd_fixed_param *)wmi_buf_data(buf);
460*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
461*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_thermal_stats_cmd_fixed_param,
462*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
463*5113495bSYour Name 		       (wmi_thermal_stats_cmd_fixed_param));
464*5113495bSYour Name 	cmd->thermal_action = req_type;
465*5113495bSYour Name 	cmd->thermal_offset = temp_offset;
466*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
467*5113495bSYour Name 				   WMI_REQUEST_THERMAL_STATS_CMDID);
468*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
469*5113495bSYour Name 		wmi_err("Failed to send get thermal stats cmd = %d", ret);
470*5113495bSYour Name 		wmi_buf_free(buf);
471*5113495bSYour Name 	}
472*5113495bSYour Name 
473*5113495bSYour Name 	return ret;
474*5113495bSYour Name }
475*5113495bSYour Name 
wmi_fwol_attach_thermal_stats_tlv(struct wmi_ops * ops)476*5113495bSYour Name static void wmi_fwol_attach_thermal_stats_tlv(struct wmi_ops *ops)
477*5113495bSYour Name {
478*5113495bSYour Name 	ops->send_get_thermal_stats_cmd = send_get_thermal_stats_cmd_tlv;
479*5113495bSYour Name }
480*5113495bSYour Name #else
wmi_fwol_attach_thermal_stats_tlv(struct wmi_ops * ops)481*5113495bSYour Name static void wmi_fwol_attach_thermal_stats_tlv(struct wmi_ops *ops)
482*5113495bSYour Name {
483*5113495bSYour Name }
484*5113495bSYour Name #endif /* FW_THERMAL_THROTTLE_SUPPORT */
485*5113495bSYour Name 
wmi_fwol_attach_tlv(wmi_unified_t wmi_handle)486*5113495bSYour Name void wmi_fwol_attach_tlv(wmi_unified_t wmi_handle)
487*5113495bSYour Name {
488*5113495bSYour Name 	struct wmi_ops *ops = wmi_handle->ops;
489*5113495bSYour Name 
490*5113495bSYour Name 	wmi_fwol_attach_elna_tlv(ops);
491*5113495bSYour Name 	wmi_fwol_attach_dscp_tid_tlv(ops);
492*5113495bSYour Name 	wmi_fwol_attach_mdns_tlv(ops);
493*5113495bSYour Name 	wmi_fwol_attach_thermal_stats_tlv(ops);
494*5113495bSYour Name }
495