1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2021-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 "wmi_unified_pmo_api.h"
24*5113495bSYour Name
25*5113495bSYour Name #ifdef FEATURE_WLAN_D0WOW
26*5113495bSYour Name /**
27*5113495bSYour Name * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
28*5113495bSYour Name * @wmi_handle: handle to WMI.
29*5113495bSYour Name * @mac_id: radio context
30*5113495bSYour Name *
31*5113495bSYour Name * Return: 0 on success and error code on failure.
32*5113495bSYour Name */
send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,uint8_t mac_id)33*5113495bSYour Name static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
34*5113495bSYour Name uint8_t mac_id)
35*5113495bSYour Name {
36*5113495bSYour Name wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
37*5113495bSYour Name wmi_buf_t buf;
38*5113495bSYour Name int32_t len;
39*5113495bSYour Name QDF_STATUS status;
40*5113495bSYour Name
41*5113495bSYour Name len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
42*5113495bSYour Name
43*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
44*5113495bSYour Name if (!buf) {
45*5113495bSYour Name return QDF_STATUS_E_NOMEM;
46*5113495bSYour Name }
47*5113495bSYour Name cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
48*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
49*5113495bSYour Name WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
50*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
51*5113495bSYour Name (wmi_d0_wow_enable_disable_cmd_fixed_param));
52*5113495bSYour Name
53*5113495bSYour Name cmd->enable = true;
54*5113495bSYour Name
55*5113495bSYour Name wmi_mtrace(WMI_D0_WOW_ENABLE_DISABLE_CMDID, NO_SESSION, 0);
56*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf, len,
57*5113495bSYour Name WMI_D0_WOW_ENABLE_DISABLE_CMDID);
58*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status))
59*5113495bSYour Name wmi_buf_free(buf);
60*5113495bSYour Name
61*5113495bSYour Name return status;
62*5113495bSYour Name }
63*5113495bSYour Name
64*5113495bSYour Name /**
65*5113495bSYour Name * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
66*5113495bSYour Name * @wmi_handle: handle to WMI.
67*5113495bSYour Name * @mac_id: radio context
68*5113495bSYour Name *
69*5113495bSYour Name * Return: 0 on success and error code on failure.
70*5113495bSYour Name */
send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,uint8_t mac_id)71*5113495bSYour Name static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
72*5113495bSYour Name uint8_t mac_id)
73*5113495bSYour Name {
74*5113495bSYour Name wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
75*5113495bSYour Name wmi_buf_t buf;
76*5113495bSYour Name int32_t len;
77*5113495bSYour Name QDF_STATUS status;
78*5113495bSYour Name
79*5113495bSYour Name len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
80*5113495bSYour Name
81*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
82*5113495bSYour Name if (!buf) {
83*5113495bSYour Name return QDF_STATUS_E_NOMEM;
84*5113495bSYour Name }
85*5113495bSYour Name cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
86*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
87*5113495bSYour Name WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
88*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
89*5113495bSYour Name (wmi_d0_wow_enable_disable_cmd_fixed_param));
90*5113495bSYour Name
91*5113495bSYour Name cmd->enable = false;
92*5113495bSYour Name
93*5113495bSYour Name wmi_mtrace(WMI_D0_WOW_ENABLE_DISABLE_CMDID, NO_SESSION, 0);
94*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf, len,
95*5113495bSYour Name WMI_D0_WOW_ENABLE_DISABLE_CMDID);
96*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status))
97*5113495bSYour Name wmi_buf_free(buf);
98*5113495bSYour Name
99*5113495bSYour Name return status;
100*5113495bSYour Name }
101*5113495bSYour Name
wmi_d0wow_attach_tlv(struct wmi_unified * wmi_handle)102*5113495bSYour Name void wmi_d0wow_attach_tlv(struct wmi_unified *wmi_handle)
103*5113495bSYour Name {
104*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
105*5113495bSYour Name
106*5113495bSYour Name ops->send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv;
107*5113495bSYour Name ops->send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv;
108*5113495bSYour Name }
109*5113495bSYour Name #endif /* FEATURE_WLAN_D0WOW */
110*5113495bSYour Name
111*5113495bSYour Name /**
112*5113495bSYour Name * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
113*5113495bSYour Name * @wmi_handle: wmi handle
114*5113495bSYour Name * @vdev_id: vdev id
115*5113495bSYour Name * @bitmap: Event bitmap
116*5113495bSYour Name * @enable: enable/disable
117*5113495bSYour Name *
118*5113495bSYour Name * Return: QDF status
119*5113495bSYour Name */
send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,uint32_t vdev_id,uint32_t * bitmap,bool enable)120*5113495bSYour Name static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
121*5113495bSYour Name uint32_t vdev_id,
122*5113495bSYour Name uint32_t *bitmap,
123*5113495bSYour Name bool enable)
124*5113495bSYour Name {
125*5113495bSYour Name WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
126*5113495bSYour Name uint16_t len;
127*5113495bSYour Name wmi_buf_t buf;
128*5113495bSYour Name int ret;
129*5113495bSYour Name
130*5113495bSYour Name len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
131*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
132*5113495bSYour Name if (!buf) {
133*5113495bSYour Name return QDF_STATUS_E_NOMEM;
134*5113495bSYour Name }
135*5113495bSYour Name cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
136*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
137*5113495bSYour Name WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
138*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
139*5113495bSYour Name (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
140*5113495bSYour Name cmd->vdev_id = vdev_id;
141*5113495bSYour Name cmd->is_add = enable;
142*5113495bSYour Name qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
143*5113495bSYour Name WMI_WOW_MAX_EVENT_BM_LEN);
144*5113495bSYour Name
145*5113495bSYour Name wmi_debug("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
146*5113495bSYour Name cmd->event_bitmaps[1], cmd->event_bitmaps[2],
147*5113495bSYour Name cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
148*5113495bSYour Name
149*5113495bSYour Name wmi_mtrace(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, cmd->vdev_id, 0);
150*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
151*5113495bSYour Name WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
152*5113495bSYour Name if (ret) {
153*5113495bSYour Name wmi_err("Failed to config wow wakeup event");
154*5113495bSYour Name wmi_buf_free(buf);
155*5113495bSYour Name return QDF_STATUS_E_FAILURE;
156*5113495bSYour Name }
157*5113495bSYour Name
158*5113495bSYour Name return QDF_STATUS_SUCCESS;
159*5113495bSYour Name }
160*5113495bSYour Name
161*5113495bSYour Name /**
162*5113495bSYour Name * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
163*5113495bSYour Name * @wmi_handle: wmi handle
164*5113495bSYour Name * @vdev_id: vdev id
165*5113495bSYour Name * @ptrn_id: pattern id
166*5113495bSYour Name * @ptrn: pattern
167*5113495bSYour Name * @ptrn_len: pattern length
168*5113495bSYour Name * @ptrn_offset: pattern offset
169*5113495bSYour Name * @mask: mask
170*5113495bSYour Name * @mask_len: mask length
171*5113495bSYour Name * @user: true for user configured pattern and false for default pattern
172*5113495bSYour Name * @default_patterns: default patterns
173*5113495bSYour Name *
174*5113495bSYour Name * Return: QDF status
175*5113495bSYour Name */
send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,uint8_t ptrn_id,const uint8_t * ptrn,uint8_t ptrn_len,uint8_t ptrn_offset,const uint8_t * mask,uint8_t mask_len,bool user,uint8_t default_patterns)176*5113495bSYour Name static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
177*5113495bSYour Name uint8_t vdev_id, uint8_t ptrn_id,
178*5113495bSYour Name const uint8_t *ptrn, uint8_t ptrn_len,
179*5113495bSYour Name uint8_t ptrn_offset, const uint8_t *mask,
180*5113495bSYour Name uint8_t mask_len, bool user,
181*5113495bSYour Name uint8_t default_patterns)
182*5113495bSYour Name {
183*5113495bSYour Name WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
184*5113495bSYour Name WOW_BITMAP_PATTERN_T *bitmap_pattern;
185*5113495bSYour Name wmi_buf_t buf;
186*5113495bSYour Name uint8_t *buf_ptr;
187*5113495bSYour Name int32_t len;
188*5113495bSYour Name int ret;
189*5113495bSYour Name
190*5113495bSYour Name len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
191*5113495bSYour Name WMI_TLV_HDR_SIZE +
192*5113495bSYour Name 1 * sizeof(WOW_BITMAP_PATTERN_T) +
193*5113495bSYour Name WMI_TLV_HDR_SIZE +
194*5113495bSYour Name 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
195*5113495bSYour Name WMI_TLV_HDR_SIZE +
196*5113495bSYour Name 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
197*5113495bSYour Name WMI_TLV_HDR_SIZE +
198*5113495bSYour Name 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
199*5113495bSYour Name WMI_TLV_HDR_SIZE +
200*5113495bSYour Name 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
201*5113495bSYour Name
202*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
203*5113495bSYour Name if (!buf) {
204*5113495bSYour Name return QDF_STATUS_E_NOMEM;
205*5113495bSYour Name }
206*5113495bSYour Name
207*5113495bSYour Name cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
208*5113495bSYour Name buf_ptr = (uint8_t *) cmd;
209*5113495bSYour Name
210*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
211*5113495bSYour Name WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
212*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
213*5113495bSYour Name (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
214*5113495bSYour Name cmd->vdev_id = vdev_id;
215*5113495bSYour Name cmd->pattern_id = ptrn_id;
216*5113495bSYour Name
217*5113495bSYour Name cmd->pattern_type = WOW_BITMAP_PATTERN;
218*5113495bSYour Name buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
219*5113495bSYour Name
220*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
221*5113495bSYour Name sizeof(WOW_BITMAP_PATTERN_T));
222*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
223*5113495bSYour Name bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
224*5113495bSYour Name
225*5113495bSYour Name WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
226*5113495bSYour Name WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
227*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
228*5113495bSYour Name
229*5113495bSYour Name qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
230*5113495bSYour Name qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
231*5113495bSYour Name
232*5113495bSYour Name bitmap_pattern->pattern_offset = ptrn_offset;
233*5113495bSYour Name bitmap_pattern->pattern_len = ptrn_len;
234*5113495bSYour Name
235*5113495bSYour Name if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
236*5113495bSYour Name bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
237*5113495bSYour Name
238*5113495bSYour Name if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
239*5113495bSYour Name bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
240*5113495bSYour Name
241*5113495bSYour Name bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
242*5113495bSYour Name bitmap_pattern->pattern_id = ptrn_id;
243*5113495bSYour Name
244*5113495bSYour Name wmi_debug("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
245*5113495bSYour Name cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
246*5113495bSYour Name bitmap_pattern->pattern_offset, user);
247*5113495bSYour Name wmi_debug("Pattern: ");
248*5113495bSYour Name QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
249*5113495bSYour Name &bitmap_pattern->patternbuf[0],
250*5113495bSYour Name bitmap_pattern->pattern_len);
251*5113495bSYour Name
252*5113495bSYour Name wmi_debug("Mask: ");
253*5113495bSYour Name QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
254*5113495bSYour Name &bitmap_pattern->bitmaskbuf[0],
255*5113495bSYour Name bitmap_pattern->pattern_len);
256*5113495bSYour Name
257*5113495bSYour Name buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
258*5113495bSYour Name
259*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
260*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
261*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
262*5113495bSYour Name
263*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
264*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
265*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
266*5113495bSYour Name
267*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
268*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
269*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
270*5113495bSYour Name
271*5113495bSYour Name /* Fill TLV for pattern_info_timeout but no data. */
272*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
273*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
274*5113495bSYour Name
275*5113495bSYour Name /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
276*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
277*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
278*5113495bSYour Name *(uint32_t *) buf_ptr = 0;
279*5113495bSYour Name
280*5113495bSYour Name wmi_mtrace(WMI_WOW_ADD_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
281*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
282*5113495bSYour Name WMI_WOW_ADD_WAKE_PATTERN_CMDID);
283*5113495bSYour Name if (ret) {
284*5113495bSYour Name wmi_err("Failed to send wow ptrn to fw");
285*5113495bSYour Name wmi_buf_free(buf);
286*5113495bSYour Name return QDF_STATUS_E_FAILURE;
287*5113495bSYour Name }
288*5113495bSYour Name
289*5113495bSYour Name return QDF_STATUS_SUCCESS;
290*5113495bSYour Name }
291*5113495bSYour Name
292*5113495bSYour Name /**
293*5113495bSYour Name * fill_arp_offload_params_tlv() - Fill ARP offload data
294*5113495bSYour Name * @wmi_handle: wmi handle
295*5113495bSYour Name * @offload_req: offload request
296*5113495bSYour Name * @buf_ptr: buffer pointer
297*5113495bSYour Name *
298*5113495bSYour Name * To fill ARP offload data to firmware
299*5113495bSYour Name * when target goes to wow mode.
300*5113495bSYour Name *
301*5113495bSYour Name * Return: None
302*5113495bSYour Name */
fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,struct pmo_arp_offload_params * offload_req,uint8_t ** buf_ptr)303*5113495bSYour Name static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
304*5113495bSYour Name struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
305*5113495bSYour Name {
306*5113495bSYour Name
307*5113495bSYour Name int i;
308*5113495bSYour Name WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
309*5113495bSYour Name bool enable_or_disable = offload_req->enable;
310*5113495bSYour Name
311*5113495bSYour Name WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
312*5113495bSYour Name (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
313*5113495bSYour Name *buf_ptr += WMI_TLV_HDR_SIZE;
314*5113495bSYour Name for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
315*5113495bSYour Name arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
316*5113495bSYour Name WMITLV_SET_HDR(&arp_tuple->tlv_header,
317*5113495bSYour Name WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
318*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
319*5113495bSYour Name
320*5113495bSYour Name /* Fill data for ARP and NS in the first tuple for LA */
321*5113495bSYour Name if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
322*5113495bSYour Name /* Copy the target ip addr and flags */
323*5113495bSYour Name arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
324*5113495bSYour Name qdf_mem_copy(&arp_tuple->target_ipaddr,
325*5113495bSYour Name offload_req->host_ipv4_addr,
326*5113495bSYour Name WMI_IPV4_ADDR_LEN);
327*5113495bSYour Name wmi_debug("ARPOffload IP4 address: %pI4",
328*5113495bSYour Name offload_req->host_ipv4_addr);
329*5113495bSYour Name }
330*5113495bSYour Name *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
331*5113495bSYour Name }
332*5113495bSYour Name }
333*5113495bSYour Name
334*5113495bSYour Name #ifdef WLAN_NS_OFFLOAD
335*5113495bSYour Name /**
336*5113495bSYour Name * fill_ns_offload_params_tlv() - Fill NS offload data
337*5113495bSYour Name * @wmi_handle: wmi handle
338*5113495bSYour Name * @ns_req: offload request
339*5113495bSYour Name * @buf_ptr: buffer pointer
340*5113495bSYour Name *
341*5113495bSYour Name * To fill NS offload data to firmware
342*5113495bSYour Name * when target goes to wow mode.
343*5113495bSYour Name *
344*5113495bSYour Name * Return: None
345*5113495bSYour Name */
fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,struct pmo_ns_offload_params * ns_req,uint8_t ** buf_ptr)346*5113495bSYour Name static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
347*5113495bSYour Name struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
348*5113495bSYour Name {
349*5113495bSYour Name
350*5113495bSYour Name int i;
351*5113495bSYour Name WMI_NS_OFFLOAD_TUPLE *ns_tuple;
352*5113495bSYour Name
353*5113495bSYour Name WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
354*5113495bSYour Name (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
355*5113495bSYour Name *buf_ptr += WMI_TLV_HDR_SIZE;
356*5113495bSYour Name for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
357*5113495bSYour Name ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
358*5113495bSYour Name WMITLV_SET_HDR(&ns_tuple->tlv_header,
359*5113495bSYour Name WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
360*5113495bSYour Name (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
361*5113495bSYour Name
362*5113495bSYour Name /*
363*5113495bSYour Name * Fill data only for NS offload in the first ARP tuple for LA
364*5113495bSYour Name */
365*5113495bSYour Name if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
366*5113495bSYour Name ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
367*5113495bSYour Name /* Copy the target/solicitation/remote ip addr */
368*5113495bSYour Name if (ns_req->target_ipv6_addr_valid[i])
369*5113495bSYour Name qdf_mem_copy(&ns_tuple->target_ipaddr[0],
370*5113495bSYour Name &ns_req->target_ipv6_addr[i],
371*5113495bSYour Name sizeof(WMI_IPV6_ADDR));
372*5113495bSYour Name qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
373*5113495bSYour Name &ns_req->self_ipv6_addr[i],
374*5113495bSYour Name sizeof(WMI_IPV6_ADDR));
375*5113495bSYour Name if (ns_req->target_ipv6_addr_ac_type[i]) {
376*5113495bSYour Name ns_tuple->flags |=
377*5113495bSYour Name WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
378*5113495bSYour Name }
379*5113495bSYour Name wmi_debug("Index %d NS solicitedIp %pI6, targetIp %pI6",
380*5113495bSYour Name i, &ns_req->self_ipv6_addr[i],
381*5113495bSYour Name &ns_req->target_ipv6_addr[i]);
382*5113495bSYour Name
383*5113495bSYour Name /* target MAC is optional, check if it is valid,
384*5113495bSYour Name * if this is not valid, the target will use the known
385*5113495bSYour Name * local MAC address rather than the tuple
386*5113495bSYour Name */
387*5113495bSYour Name WMI_CHAR_ARRAY_TO_MAC_ADDR(
388*5113495bSYour Name ns_req->self_macaddr.bytes,
389*5113495bSYour Name &ns_tuple->target_mac);
390*5113495bSYour Name if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
391*5113495bSYour Name (ns_tuple->target_mac.mac_addr47to32 != 0)) {
392*5113495bSYour Name ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
393*5113495bSYour Name }
394*5113495bSYour Name }
395*5113495bSYour Name *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
396*5113495bSYour Name }
397*5113495bSYour Name }
398*5113495bSYour Name
399*5113495bSYour Name /**
400*5113495bSYour Name * fill_nsoffload_ext_tlv() - Fill NS offload ext data
401*5113495bSYour Name * @wmi_handle: wmi handle
402*5113495bSYour Name * @ns_req: offload request
403*5113495bSYour Name * @buf_ptr: buffer pointer
404*5113495bSYour Name *
405*5113495bSYour Name * To fill extended NS offload extended data to firmware
406*5113495bSYour Name * when target goes to wow mode.
407*5113495bSYour Name *
408*5113495bSYour Name * Return: None
409*5113495bSYour Name */
fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,struct pmo_ns_offload_params * ns_req,uint8_t ** buf_ptr)410*5113495bSYour Name static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
411*5113495bSYour Name struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
412*5113495bSYour Name {
413*5113495bSYour Name int i;
414*5113495bSYour Name WMI_NS_OFFLOAD_TUPLE *ns_tuple;
415*5113495bSYour Name uint32_t count, num_ns_ext_tuples;
416*5113495bSYour Name
417*5113495bSYour Name count = ns_req->num_ns_offload_count;
418*5113495bSYour Name num_ns_ext_tuples = ns_req->num_ns_offload_count -
419*5113495bSYour Name WMI_MAX_NS_OFFLOADS;
420*5113495bSYour Name
421*5113495bSYour Name /* Populate extended NS offload tuples */
422*5113495bSYour Name WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
423*5113495bSYour Name (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
424*5113495bSYour Name *buf_ptr += WMI_TLV_HDR_SIZE;
425*5113495bSYour Name for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
426*5113495bSYour Name ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
427*5113495bSYour Name WMITLV_SET_HDR(&ns_tuple->tlv_header,
428*5113495bSYour Name WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
429*5113495bSYour Name (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
430*5113495bSYour Name
431*5113495bSYour Name /*
432*5113495bSYour Name * Fill data only for NS offload in the first ARP tuple for LA
433*5113495bSYour Name */
434*5113495bSYour Name if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
435*5113495bSYour Name ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
436*5113495bSYour Name /* Copy the target/solicitation/remote ip addr */
437*5113495bSYour Name if (ns_req->target_ipv6_addr_valid[i])
438*5113495bSYour Name qdf_mem_copy(&ns_tuple->target_ipaddr[0],
439*5113495bSYour Name &ns_req->target_ipv6_addr[i],
440*5113495bSYour Name sizeof(WMI_IPV6_ADDR));
441*5113495bSYour Name qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
442*5113495bSYour Name &ns_req->self_ipv6_addr[i],
443*5113495bSYour Name sizeof(WMI_IPV6_ADDR));
444*5113495bSYour Name if (ns_req->target_ipv6_addr_ac_type[i]) {
445*5113495bSYour Name ns_tuple->flags |=
446*5113495bSYour Name WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
447*5113495bSYour Name }
448*5113495bSYour Name wmi_debug("Index %d NS solicitedIp %pI6, targetIp %pI6",
449*5113495bSYour Name i, &ns_req->self_ipv6_addr[i],
450*5113495bSYour Name &ns_req->target_ipv6_addr[i]);
451*5113495bSYour Name
452*5113495bSYour Name /* target MAC is optional, check if it is valid,
453*5113495bSYour Name * if this is not valid, the target will use the
454*5113495bSYour Name * known local MAC address rather than the tuple
455*5113495bSYour Name */
456*5113495bSYour Name WMI_CHAR_ARRAY_TO_MAC_ADDR(
457*5113495bSYour Name ns_req->self_macaddr.bytes,
458*5113495bSYour Name &ns_tuple->target_mac);
459*5113495bSYour Name if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
460*5113495bSYour Name (ns_tuple->target_mac.mac_addr47to32 != 0)) {
461*5113495bSYour Name ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
462*5113495bSYour Name }
463*5113495bSYour Name }
464*5113495bSYour Name *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
465*5113495bSYour Name }
466*5113495bSYour Name }
467*5113495bSYour Name #else
fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,struct pmo_ns_offload_params * ns_req,uint8_t ** buf_ptr)468*5113495bSYour Name static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
469*5113495bSYour Name struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
470*5113495bSYour Name {
471*5113495bSYour Name }
472*5113495bSYour Name
fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,struct pmo_ns_offload_params * ns_req,uint8_t ** buf_ptr)473*5113495bSYour Name static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
474*5113495bSYour Name struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
475*5113495bSYour Name {
476*5113495bSYour Name }
477*5113495bSYour Name #endif
478*5113495bSYour Name
479*5113495bSYour Name /**
480*5113495bSYour Name * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
481*5113495bSYour Name * @wmi_handle: wmi handle
482*5113495bSYour Name * @arp_offload_req: arp offload request
483*5113495bSYour Name * @ns_offload_req: ns offload request
484*5113495bSYour Name * @vdev_id: vdev ID
485*5113495bSYour Name *
486*5113495bSYour Name * To configure ARP NS off load data to firmware
487*5113495bSYour Name * when target goes to wow mode.
488*5113495bSYour Name *
489*5113495bSYour Name * Return: QDF Status
490*5113495bSYour Name */
send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,struct pmo_arp_offload_params * arp_offload_req,struct pmo_ns_offload_params * ns_offload_req,uint8_t vdev_id)491*5113495bSYour Name static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
492*5113495bSYour Name struct pmo_arp_offload_params *arp_offload_req,
493*5113495bSYour Name struct pmo_ns_offload_params *ns_offload_req,
494*5113495bSYour Name uint8_t vdev_id)
495*5113495bSYour Name {
496*5113495bSYour Name int32_t res;
497*5113495bSYour Name WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
498*5113495bSYour Name uint8_t *buf_ptr;
499*5113495bSYour Name wmi_buf_t buf;
500*5113495bSYour Name int32_t len;
501*5113495bSYour Name uint32_t count = 0, num_ns_ext_tuples = 0;
502*5113495bSYour Name
503*5113495bSYour Name count = ns_offload_req->num_ns_offload_count;
504*5113495bSYour Name
505*5113495bSYour Name /*
506*5113495bSYour Name * TLV place holder size for array of NS tuples
507*5113495bSYour Name * TLV place holder size for array of ARP tuples
508*5113495bSYour Name */
509*5113495bSYour Name len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
510*5113495bSYour Name WMI_TLV_HDR_SIZE +
511*5113495bSYour Name WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
512*5113495bSYour Name WMI_TLV_HDR_SIZE +
513*5113495bSYour Name WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
514*5113495bSYour Name
515*5113495bSYour Name /*
516*5113495bSYour Name * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
517*5113495bSYour Name * extra length for extended NS offload tuples which follows ARP offload
518*5113495bSYour Name * tuples. Host needs to fill this structure in following format:
519*5113495bSYour Name * 2 NS ofload tuples
520*5113495bSYour Name * 2 ARP offload tuples
521*5113495bSYour Name * N numbers of extended NS offload tuples if HDD has given more than
522*5113495bSYour Name * 2 NS offload addresses
523*5113495bSYour Name */
524*5113495bSYour Name if (count > WMI_MAX_NS_OFFLOADS) {
525*5113495bSYour Name num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
526*5113495bSYour Name len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
527*5113495bSYour Name * sizeof(WMI_NS_OFFLOAD_TUPLE);
528*5113495bSYour Name }
529*5113495bSYour Name
530*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
531*5113495bSYour Name if (!buf) {
532*5113495bSYour Name return QDF_STATUS_E_NOMEM;
533*5113495bSYour Name }
534*5113495bSYour Name
535*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
536*5113495bSYour Name cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
537*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
538*5113495bSYour Name WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
539*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
540*5113495bSYour Name (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
541*5113495bSYour Name cmd->flags = 0;
542*5113495bSYour Name cmd->vdev_id = vdev_id;
543*5113495bSYour Name cmd->num_ns_ext_tuples = num_ns_ext_tuples;
544*5113495bSYour Name
545*5113495bSYour Name wmi_debug("ARP NS Offload vdev_id: %d", cmd->vdev_id);
546*5113495bSYour Name
547*5113495bSYour Name buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
548*5113495bSYour Name fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
549*5113495bSYour Name fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
550*5113495bSYour Name if (num_ns_ext_tuples)
551*5113495bSYour Name fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
552*5113495bSYour Name
553*5113495bSYour Name wmi_mtrace(WMI_SET_ARP_NS_OFFLOAD_CMDID, cmd->vdev_id, 0);
554*5113495bSYour Name res = wmi_unified_cmd_send(wmi_handle, buf, len,
555*5113495bSYour Name WMI_SET_ARP_NS_OFFLOAD_CMDID);
556*5113495bSYour Name if (res) {
557*5113495bSYour Name wmi_err("Failed to enable ARP NDP/NSffload");
558*5113495bSYour Name wmi_buf_free(buf);
559*5113495bSYour Name return QDF_STATUS_E_FAILURE;
560*5113495bSYour Name }
561*5113495bSYour Name
562*5113495bSYour Name return QDF_STATUS_SUCCESS;
563*5113495bSYour Name }
564*5113495bSYour Name
565*5113495bSYour Name /**
566*5113495bSYour Name * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
567*5113495bSYour Name * @wmi_handle: wmi handle
568*5113495bSYour Name * @vdev_id: vdev id
569*5113495bSYour Name * @multicast_addr: mcast address
570*5113495bSYour Name * @clearList: clear list flag
571*5113495bSYour Name *
572*5113495bSYour Name * Return: QDF_STATUS_SUCCESS for success or error code
573*5113495bSYour Name */
send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,struct qdf_mac_addr multicast_addr,bool clearList)574*5113495bSYour Name static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
575*5113495bSYour Name uint8_t vdev_id,
576*5113495bSYour Name struct qdf_mac_addr multicast_addr,
577*5113495bSYour Name bool clearList)
578*5113495bSYour Name {
579*5113495bSYour Name WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
580*5113495bSYour Name wmi_buf_t buf;
581*5113495bSYour Name int err;
582*5113495bSYour Name
583*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
584*5113495bSYour Name if (!buf) {
585*5113495bSYour Name return QDF_STATUS_E_NOMEM;
586*5113495bSYour Name }
587*5113495bSYour Name
588*5113495bSYour Name cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
589*5113495bSYour Name qdf_mem_zero(cmd, sizeof(*cmd));
590*5113495bSYour Name
591*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
592*5113495bSYour Name WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
593*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
594*5113495bSYour Name (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
595*5113495bSYour Name cmd->action =
596*5113495bSYour Name (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
597*5113495bSYour Name cmd->vdev_id = vdev_id;
598*5113495bSYour Name WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
599*5113495bSYour Name
600*5113495bSYour Name wmi_debug("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: "QDF_MAC_ADDR_FMT,
601*5113495bSYour Name cmd->action, vdev_id, clearList,
602*5113495bSYour Name QDF_MAC_ADDR_REF(multicast_addr.bytes));
603*5113495bSYour Name
604*5113495bSYour Name wmi_mtrace(WMI_SET_MCASTBCAST_FILTER_CMDID, cmd->vdev_id, 0);
605*5113495bSYour Name err = wmi_unified_cmd_send(wmi_handle, buf,
606*5113495bSYour Name sizeof(*cmd),
607*5113495bSYour Name WMI_SET_MCASTBCAST_FILTER_CMDID);
608*5113495bSYour Name if (err) {
609*5113495bSYour Name wmi_err("Failed to send set_param cmd");
610*5113495bSYour Name wmi_buf_free(buf);
611*5113495bSYour Name return QDF_STATUS_E_FAILURE;
612*5113495bSYour Name }
613*5113495bSYour Name
614*5113495bSYour Name return QDF_STATUS_SUCCESS;
615*5113495bSYour Name }
616*5113495bSYour Name
617*5113495bSYour Name /**
618*5113495bSYour Name * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
619*5113495bSYour Name * command to fw
620*5113495bSYour Name * @wmi_handle: wmi handle
621*5113495bSYour Name * @vdev_id: vdev id
622*5113495bSYour Name * @filter_param: mcast filter params
623*5113495bSYour Name *
624*5113495bSYour Name * Return: QDF_STATUS_SUCCESS for success or error code
625*5113495bSYour Name */
send_multiple_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,struct pmo_mcast_filter_params * filter_param)626*5113495bSYour Name static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
627*5113495bSYour Name wmi_unified_t wmi_handle,
628*5113495bSYour Name uint8_t vdev_id,
629*5113495bSYour Name struct pmo_mcast_filter_params *filter_param)
630*5113495bSYour Name
631*5113495bSYour Name {
632*5113495bSYour Name WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
633*5113495bSYour Name uint8_t *buf_ptr;
634*5113495bSYour Name wmi_buf_t buf;
635*5113495bSYour Name int err;
636*5113495bSYour Name int i;
637*5113495bSYour Name uint8_t *mac_addr_src_ptr = NULL;
638*5113495bSYour Name wmi_mac_addr *mac_addr_dst_ptr;
639*5113495bSYour Name uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
640*5113495bSYour Name sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
641*5113495bSYour Name
642*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
643*5113495bSYour Name if (!buf) {
644*5113495bSYour Name return QDF_STATUS_E_NOMEM;
645*5113495bSYour Name }
646*5113495bSYour Name
647*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
648*5113495bSYour Name cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
649*5113495bSYour Name wmi_buf_data(buf);
650*5113495bSYour Name qdf_mem_zero(cmd, sizeof(*cmd));
651*5113495bSYour Name
652*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
653*5113495bSYour Name WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
654*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
655*5113495bSYour Name (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
656*5113495bSYour Name cmd->operation =
657*5113495bSYour Name ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
658*5113495bSYour Name : WMI_MULTIPLE_MCAST_FILTER_ADD);
659*5113495bSYour Name cmd->vdev_id = vdev_id;
660*5113495bSYour Name cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
661*5113495bSYour Name
662*5113495bSYour Name buf_ptr += sizeof(*cmd);
663*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
664*5113495bSYour Name sizeof(wmi_mac_addr) *
665*5113495bSYour Name filter_param->multicast_addr_cnt);
666*5113495bSYour Name
667*5113495bSYour Name if (filter_param->multicast_addr_cnt == 0)
668*5113495bSYour Name goto send_cmd;
669*5113495bSYour Name
670*5113495bSYour Name mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
671*5113495bSYour Name mac_addr_dst_ptr = (wmi_mac_addr *)
672*5113495bSYour Name (buf_ptr + WMI_TLV_HDR_SIZE);
673*5113495bSYour Name
674*5113495bSYour Name wmi_debug("multicast addr cnt: %u", filter_param->multicast_addr_cnt);
675*5113495bSYour Name for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
676*5113495bSYour Name WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
677*5113495bSYour Name wmi_nofl_debug("mac addr[%d]: " QDF_MAC_ADDR_FMT, i,
678*5113495bSYour Name QDF_MAC_ADDR_REF(
679*5113495bSYour Name filter_param->multicast_addr[i].bytes));
680*5113495bSYour Name mac_addr_src_ptr += ATH_MAC_LEN;
681*5113495bSYour Name mac_addr_dst_ptr++;
682*5113495bSYour Name }
683*5113495bSYour Name
684*5113495bSYour Name send_cmd:
685*5113495bSYour Name wmi_mtrace(WMI_SET_MULTIPLE_MCAST_FILTER_CMDID, cmd->vdev_id, 0);
686*5113495bSYour Name err = wmi_unified_cmd_send(wmi_handle, buf,
687*5113495bSYour Name len,
688*5113495bSYour Name WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
689*5113495bSYour Name if (err) {
690*5113495bSYour Name wmi_err("Failed to send set_param cmd");
691*5113495bSYour Name wmi_buf_free(buf);
692*5113495bSYour Name return QDF_STATUS_E_FAILURE;
693*5113495bSYour Name }
694*5113495bSYour Name
695*5113495bSYour Name return QDF_STATUS_SUCCESS;
696*5113495bSYour Name }
697*5113495bSYour Name
send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,struct pmo_hw_filter_params * req)698*5113495bSYour Name static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
699*5113495bSYour Name struct pmo_hw_filter_params *req)
700*5113495bSYour Name {
701*5113495bSYour Name QDF_STATUS status;
702*5113495bSYour Name wmi_hw_data_filter_cmd_fixed_param *cmd;
703*5113495bSYour Name wmi_buf_t wmi_buf;
704*5113495bSYour Name
705*5113495bSYour Name if (!req) {
706*5113495bSYour Name wmi_err("req is null");
707*5113495bSYour Name return QDF_STATUS_E_INVAL;
708*5113495bSYour Name }
709*5113495bSYour Name
710*5113495bSYour Name wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
711*5113495bSYour Name if (!wmi_buf) {
712*5113495bSYour Name return QDF_STATUS_E_NOMEM;
713*5113495bSYour Name }
714*5113495bSYour Name
715*5113495bSYour Name cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
716*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
717*5113495bSYour Name WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
718*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
719*5113495bSYour Name cmd->vdev_id = req->vdev_id;
720*5113495bSYour Name cmd->enable = req->enable;
721*5113495bSYour Name /* Set all modes in case of disable */
722*5113495bSYour Name if (!cmd->enable)
723*5113495bSYour Name cmd->hw_filter_bitmap = ((uint32_t)~0U);
724*5113495bSYour Name else
725*5113495bSYour Name cmd->hw_filter_bitmap = req->mode_bitmap;
726*5113495bSYour Name
727*5113495bSYour Name wmi_debug("Send %s hw filter mode: 0x%X for vdev id %d",
728*5113495bSYour Name req->enable ? "enable" : "disable", req->mode_bitmap,
729*5113495bSYour Name req->vdev_id);
730*5113495bSYour Name
731*5113495bSYour Name wmi_mtrace(WMI_HW_DATA_FILTER_CMDID, cmd->vdev_id, 0);
732*5113495bSYour Name status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
733*5113495bSYour Name WMI_HW_DATA_FILTER_CMDID);
734*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
735*5113495bSYour Name wmi_err("Failed to configure hw filter");
736*5113495bSYour Name wmi_buf_free(wmi_buf);
737*5113495bSYour Name }
738*5113495bSYour Name
739*5113495bSYour Name return status;
740*5113495bSYour Name }
741*5113495bSYour Name
742*5113495bSYour Name static void
fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param * cmd,uint8_t vdev_id,struct pmo_gtk_req * params)743*5113495bSYour Name fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param *cmd,
744*5113495bSYour Name uint8_t vdev_id,
745*5113495bSYour Name struct pmo_gtk_req *params)
746*5113495bSYour Name {
747*5113495bSYour Name uint8_t *buf_ptr;
748*5113495bSYour Name wmi_gtk_offload_fils_tlv_param *ext_param;
749*5113495bSYour Name
750*5113495bSYour Name buf_ptr = (uint8_t *) cmd + sizeof(*cmd);
751*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
752*5113495bSYour Name sizeof(*ext_param));
753*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
754*5113495bSYour Name
755*5113495bSYour Name ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
756*5113495bSYour Name WMITLV_SET_HDR(&ext_param->tlv_header,
757*5113495bSYour Name WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
758*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(
759*5113495bSYour Name wmi_gtk_offload_fils_tlv_param));
760*5113495bSYour Name ext_param->vdev_id = vdev_id;
761*5113495bSYour Name ext_param->flags = cmd->flags;
762*5113495bSYour Name ext_param->kek_len = params->kek_len;
763*5113495bSYour Name qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
764*5113495bSYour Name qdf_mem_copy(ext_param->KCK, params->kck,
765*5113495bSYour Name WMI_GTK_OFFLOAD_KCK_BYTES);
766*5113495bSYour Name qdf_mem_copy(ext_param->replay_counter, ¶ms->replay_counter,
767*5113495bSYour Name GTK_REPLAY_COUNTER_BYTES);
768*5113495bSYour Name }
769*5113495bSYour Name
770*5113495bSYour Name #ifdef WLAN_FEATURE_IGMP_OFFLOAD
771*5113495bSYour Name /**
772*5113495bSYour Name * send_igmp_offload_cmd_tlv() - send IGMP offload command to fw
773*5113495bSYour Name * @wmi_handle: wmi handle
774*5113495bSYour Name * @pmo_igmp_req: IGMP offload parameters
775*5113495bSYour Name *
776*5113495bSYour Name * Return: QDF status
777*5113495bSYour Name */
778*5113495bSYour Name static
send_igmp_offload_cmd_tlv(wmi_unified_t wmi_handle,struct pmo_igmp_offload_req * pmo_igmp_req)779*5113495bSYour Name QDF_STATUS send_igmp_offload_cmd_tlv(wmi_unified_t wmi_handle,
780*5113495bSYour Name struct pmo_igmp_offload_req *pmo_igmp_req)
781*5113495bSYour Name {
782*5113495bSYour Name wmi_buf_t buf;
783*5113495bSYour Name uint8_t *buf_ptr;
784*5113495bSYour Name int len;
785*5113495bSYour Name int i = 0;
786*5113495bSYour Name WMI_IPV4_ADDR *ipv4_list;
787*5113495bSYour Name wmi_igmp_offload_fixed_param *cmd;
788*5113495bSYour Name QDF_STATUS status = QDF_STATUS_SUCCESS;
789*5113495bSYour Name
790*5113495bSYour Name len = sizeof(wmi_igmp_offload_fixed_param) + WMI_TLV_HDR_SIZE +
791*5113495bSYour Name (pmo_igmp_req->num_grp_ip_address) * sizeof(WMI_IPV4_ADDR);
792*5113495bSYour Name /* alloc wmi buffer */
793*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
794*5113495bSYour Name if (!buf) {
795*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
796*5113495bSYour Name goto out;
797*5113495bSYour Name }
798*5113495bSYour Name buf_ptr = (uint8_t *)wmi_buf_data(buf);
799*5113495bSYour Name cmd = (wmi_igmp_offload_fixed_param *)wmi_buf_data(buf);
800*5113495bSYour Name
801*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
802*5113495bSYour Name WMITLV_TAG_STRUC_wmi_igmp_offload_fixed_param,
803*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(wmi_igmp_offload_fixed_param));
804*5113495bSYour Name
805*5113495bSYour Name cmd->vdev_id = pmo_igmp_req->vdev_id;
806*5113495bSYour Name cmd->enable = pmo_igmp_req->enable;
807*5113495bSYour Name cmd->version_support_bitmask =
808*5113495bSYour Name pmo_igmp_req->version_support;
809*5113495bSYour Name
810*5113495bSYour Name buf_ptr += sizeof(*cmd);
811*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
812*5113495bSYour Name sizeof(WMI_IPV4_ADDR) *
813*5113495bSYour Name pmo_igmp_req->num_grp_ip_address);
814*5113495bSYour Name
815*5113495bSYour Name ipv4_list = (WMI_IPV4_ADDR *)(buf_ptr + WMI_TLV_HDR_SIZE);
816*5113495bSYour Name
817*5113495bSYour Name while (i < pmo_igmp_req->num_grp_ip_address) {
818*5113495bSYour Name qdf_mem_copy((void *)((*(ipv4_list + i)).address),
819*5113495bSYour Name (void *)&(pmo_igmp_req->grp_ip_address[i]),
820*5113495bSYour Name WMI_IPV4_ADDR_LEN);
821*5113495bSYour Name wmi_debug("piv4[%d]:%x", i, *(uint32_t *)(ipv4_list + i));
822*5113495bSYour Name i++;
823*5113495bSYour Name }
824*5113495bSYour Name
825*5113495bSYour Name wmi_debug("VDEVID:%d, FLAG:x%x version support:%d",
826*5113495bSYour Name cmd->vdev_id, cmd->enable,
827*5113495bSYour Name cmd->version_support_bitmask);
828*5113495bSYour Name
829*5113495bSYour Name /* send the wmi command */
830*5113495bSYour Name wmi_mtrace(WMI_VDEV_IGMP_OFFLOAD_CMDID, cmd->vdev_id, 0);
831*5113495bSYour Name if (wmi_unified_cmd_send(wmi_handle, buf, len,
832*5113495bSYour Name WMI_VDEV_IGMP_OFFLOAD_CMDID)) {
833*5113495bSYour Name wmi_err("Failed to send WMI_VDEV_IGMP_OFFLOAD_CMDID");
834*5113495bSYour Name wmi_buf_free(buf);
835*5113495bSYour Name status = QDF_STATUS_E_FAILURE;
836*5113495bSYour Name }
837*5113495bSYour Name out:
838*5113495bSYour Name return status;
839*5113495bSYour Name }
840*5113495bSYour Name #endif
841*5113495bSYour Name
842*5113495bSYour Name /**
843*5113495bSYour Name * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
844*5113495bSYour Name * @wmi_handle: wmi handle
845*5113495bSYour Name * @vdev_id: vdev id
846*5113495bSYour Name * @params: GTK offload parameters
847*5113495bSYour Name * @enable_offload: true to enable the offload
848*5113495bSYour Name * @gtk_offload_opcode: GTK offload opcode
849*5113495bSYour Name *
850*5113495bSYour Name * Return: QDF status
851*5113495bSYour Name */
852*5113495bSYour Name static
send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,struct pmo_gtk_req * params,bool enable_offload,uint32_t gtk_offload_opcode)853*5113495bSYour Name QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
854*5113495bSYour Name struct pmo_gtk_req *params,
855*5113495bSYour Name bool enable_offload,
856*5113495bSYour Name uint32_t gtk_offload_opcode)
857*5113495bSYour Name {
858*5113495bSYour Name int len;
859*5113495bSYour Name uint8_t *buf_ptr;
860*5113495bSYour Name wmi_buf_t buf;
861*5113495bSYour Name WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
862*5113495bSYour Name QDF_STATUS status = QDF_STATUS_SUCCESS;
863*5113495bSYour Name
864*5113495bSYour Name len = sizeof(*cmd);
865*5113495bSYour Name
866*5113495bSYour Name len += WMI_TLV_HDR_SIZE;
867*5113495bSYour Name if (params->is_fils_connection)
868*5113495bSYour Name len += sizeof(wmi_gtk_offload_fils_tlv_param);
869*5113495bSYour Name
870*5113495bSYour Name if (params->kck_len > 16)
871*5113495bSYour Name len += WMI_TLV_HDR_SIZE +
872*5113495bSYour Name roundup(params->kek_len, sizeof(uint32_t)) +
873*5113495bSYour Name WMI_TLV_HDR_SIZE +
874*5113495bSYour Name roundup(params->kck_len, sizeof(uint32_t));
875*5113495bSYour Name
876*5113495bSYour Name /* alloc wmi buffer */
877*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
878*5113495bSYour Name if (!buf) {
879*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
880*5113495bSYour Name goto out;
881*5113495bSYour Name }
882*5113495bSYour Name
883*5113495bSYour Name cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
884*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
885*5113495bSYour Name WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
886*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
887*5113495bSYour Name (WMI_GTK_OFFLOAD_CMD_fixed_param));
888*5113495bSYour Name
889*5113495bSYour Name buf_ptr = wmi_buf_data(buf);
890*5113495bSYour Name cmd->vdev_id = vdev_id;
891*5113495bSYour Name
892*5113495bSYour Name /* Request target to enable GTK offload */
893*5113495bSYour Name if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
894*5113495bSYour Name cmd->flags = gtk_offload_opcode;
895*5113495bSYour Name
896*5113495bSYour Name /* Copy the keys and replay counter */
897*5113495bSYour Name qdf_mem_copy(cmd->KCK, params->kck, sizeof(cmd->KCK));
898*5113495bSYour Name qdf_mem_copy(cmd->KEK, params->kek, sizeof(cmd->KEK));
899*5113495bSYour Name qdf_mem_copy(cmd->replay_counter, ¶ms->replay_counter,
900*5113495bSYour Name GTK_REPLAY_COUNTER_BYTES);
901*5113495bSYour Name } else {
902*5113495bSYour Name cmd->flags = gtk_offload_opcode;
903*5113495bSYour Name }
904*5113495bSYour Name
905*5113495bSYour Name buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
906*5113495bSYour Name
907*5113495bSYour Name if (params->is_fils_connection) {
908*5113495bSYour Name fill_fils_tlv_params(cmd, vdev_id, params);
909*5113495bSYour Name buf_ptr += sizeof(wmi_gtk_offload_fils_tlv_param);
910*5113495bSYour Name } else {
911*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
912*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
913*5113495bSYour Name }
914*5113495bSYour Name
915*5113495bSYour Name if (params->kck_len > 16) {
916*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
917*5113495bSYour Name roundup(params->kek_len, sizeof(uint32_t)));
918*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
919*5113495bSYour Name
920*5113495bSYour Name qdf_mem_copy(buf_ptr, params->kek, params->kek_len);
921*5113495bSYour Name buf_ptr += roundup(params->kek_len, sizeof(uint32_t));
922*5113495bSYour Name
923*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
924*5113495bSYour Name roundup(params->kck_len, sizeof(uint32_t)));
925*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
926*5113495bSYour Name
927*5113495bSYour Name qdf_mem_copy(buf_ptr, params->kck, params->kck_len);
928*5113495bSYour Name buf_ptr += roundup(params->kck_len, sizeof(uint32_t));
929*5113495bSYour Name }
930*5113495bSYour Name
931*5113495bSYour Name wmi_debug("VDEVID: %d, GTK_FLAGS: x%x kek len %d",
932*5113495bSYour Name vdev_id, cmd->flags, params->kek_len);
933*5113495bSYour Name /* send the wmi command */
934*5113495bSYour Name wmi_mtrace(WMI_GTK_OFFLOAD_CMDID, cmd->vdev_id, 0);
935*5113495bSYour Name if (wmi_unified_cmd_send(wmi_handle, buf, len,
936*5113495bSYour Name WMI_GTK_OFFLOAD_CMDID)) {
937*5113495bSYour Name wmi_err("Failed to send WMI_GTK_OFFLOAD_CMDID");
938*5113495bSYour Name wmi_buf_free(buf);
939*5113495bSYour Name status = QDF_STATUS_E_FAILURE;
940*5113495bSYour Name }
941*5113495bSYour Name
942*5113495bSYour Name out:
943*5113495bSYour Name return status;
944*5113495bSYour Name }
945*5113495bSYour Name
946*5113495bSYour Name /**
947*5113495bSYour Name * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
948*5113495bSYour Name * @wmi_handle: wmi handle
949*5113495bSYour Name * @vdev_id: vdev id
950*5113495bSYour Name * @offload_req_opcode: GTK offload request opcode
951*5113495bSYour Name *
952*5113495bSYour Name * Return: QDF status
953*5113495bSYour Name */
send_process_gtk_offload_getinfo_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,uint64_t offload_req_opcode)954*5113495bSYour Name static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
955*5113495bSYour Name wmi_unified_t wmi_handle,
956*5113495bSYour Name uint8_t vdev_id,
957*5113495bSYour Name uint64_t offload_req_opcode)
958*5113495bSYour Name {
959*5113495bSYour Name int len;
960*5113495bSYour Name wmi_buf_t buf;
961*5113495bSYour Name WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
962*5113495bSYour Name QDF_STATUS status = QDF_STATUS_SUCCESS;
963*5113495bSYour Name
964*5113495bSYour Name len = sizeof(*cmd);
965*5113495bSYour Name
966*5113495bSYour Name /* alloc wmi buffer */
967*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
968*5113495bSYour Name if (!buf) {
969*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
970*5113495bSYour Name goto out;
971*5113495bSYour Name }
972*5113495bSYour Name
973*5113495bSYour Name cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
974*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
975*5113495bSYour Name WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
976*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
977*5113495bSYour Name (WMI_GTK_OFFLOAD_CMD_fixed_param));
978*5113495bSYour Name
979*5113495bSYour Name /* Request for GTK offload status */
980*5113495bSYour Name cmd->flags = offload_req_opcode;
981*5113495bSYour Name cmd->vdev_id = vdev_id;
982*5113495bSYour Name
983*5113495bSYour Name /* send the wmi command */
984*5113495bSYour Name wmi_mtrace(WMI_GTK_OFFLOAD_CMDID, cmd->vdev_id, 0);
985*5113495bSYour Name if (wmi_unified_cmd_send(wmi_handle, buf, len,
986*5113495bSYour Name WMI_GTK_OFFLOAD_CMDID)) {
987*5113495bSYour Name wmi_err("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
988*5113495bSYour Name wmi_buf_free(buf);
989*5113495bSYour Name status = QDF_STATUS_E_FAILURE;
990*5113495bSYour Name }
991*5113495bSYour Name
992*5113495bSYour Name out:
993*5113495bSYour Name return status;
994*5113495bSYour Name }
995*5113495bSYour Name
996*5113495bSYour Name /**
997*5113495bSYour Name * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
998*5113495bSYour Name * @wmi_handle: wmi handle
999*5113495bSYour Name * @vdev_id: vdev id
1000*5113495bSYour Name * @action: true for enable else false
1001*5113495bSYour Name *
1002*5113495bSYour Name * To enable enhance multicast offload to firmware
1003*5113495bSYour Name * when target goes to wow mode.
1004*5113495bSYour Name *
1005*5113495bSYour Name * Return: QDF Status
1006*5113495bSYour Name */
1007*5113495bSYour Name
1008*5113495bSYour Name static
send_enable_enhance_multicast_offload_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,bool action)1009*5113495bSYour Name QDF_STATUS send_enable_enhance_multicast_offload_tlv(
1010*5113495bSYour Name wmi_unified_t wmi_handle,
1011*5113495bSYour Name uint8_t vdev_id, bool action)
1012*5113495bSYour Name {
1013*5113495bSYour Name QDF_STATUS status;
1014*5113495bSYour Name wmi_buf_t buf;
1015*5113495bSYour Name wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
1016*5113495bSYour Name
1017*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1018*5113495bSYour Name if (!buf) {
1019*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1020*5113495bSYour Name }
1021*5113495bSYour Name
1022*5113495bSYour Name cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
1023*5113495bSYour Name wmi_buf_data(buf);
1024*5113495bSYour Name
1025*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1026*5113495bSYour Name WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
1027*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(
1028*5113495bSYour Name wmi_config_enhanced_mcast_filter_cmd_fixed_param));
1029*5113495bSYour Name
1030*5113495bSYour Name cmd->vdev_id = vdev_id;
1031*5113495bSYour Name cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
1032*5113495bSYour Name ENHANCED_MCAST_FILTER_ENABLED);
1033*5113495bSYour Name wmi_debug("config enhance multicast offload action %d for vdev %d",
1034*5113495bSYour Name action, vdev_id);
1035*5113495bSYour Name wmi_mtrace(WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID, cmd->vdev_id, 0);
1036*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf,
1037*5113495bSYour Name sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
1038*5113495bSYour Name if (status != QDF_STATUS_SUCCESS) {
1039*5113495bSYour Name wmi_buf_free(buf);
1040*5113495bSYour Name wmi_err("Failed to send ENHANCED_MCAST_FILTER_CMDID");
1041*5113495bSYour Name }
1042*5113495bSYour Name
1043*5113495bSYour Name return status;
1044*5113495bSYour Name }
1045*5113495bSYour Name
1046*5113495bSYour Name /**
1047*5113495bSYour Name * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
1048*5113495bSYour Name * @wmi_handle: wmi handle
1049*5113495bSYour Name * @evt_buf: pointer to event buffer
1050*5113495bSYour Name * @gtk_rsp_param: Pointer to extraction buffer
1051*5113495bSYour Name * @len: length of the @evt_buf event buffer
1052*5113495bSYour Name *
1053*5113495bSYour Name * Return: QDF_STATUS_SUCCESS for success or error code
1054*5113495bSYour Name */
extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,void * evt_buf,struct pmo_gtk_rsp_params * gtk_rsp_param,uint32_t len)1055*5113495bSYour Name static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
1056*5113495bSYour Name void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
1057*5113495bSYour Name {
1058*5113495bSYour Name WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
1059*5113495bSYour Name WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
1060*5113495bSYour Name
1061*5113495bSYour Name param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
1062*5113495bSYour Name if (!param_buf) {
1063*5113495bSYour Name wmi_err("gtk param_buf is NULL");
1064*5113495bSYour Name return QDF_STATUS_E_INVAL;
1065*5113495bSYour Name }
1066*5113495bSYour Name
1067*5113495bSYour Name if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
1068*5113495bSYour Name wmi_err("Invalid length for GTK status");
1069*5113495bSYour Name return QDF_STATUS_E_INVAL;
1070*5113495bSYour Name }
1071*5113495bSYour Name
1072*5113495bSYour Name fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
1073*5113495bSYour Name param_buf->fixed_param;
1074*5113495bSYour Name
1075*5113495bSYour Name if (fixed_param->vdev_id >= WLAN_UMAC_PSOC_MAX_VDEVS) {
1076*5113495bSYour Name wmi_err_rl("Invalid vdev_id %u", fixed_param->vdev_id);
1077*5113495bSYour Name return QDF_STATUS_E_INVAL;
1078*5113495bSYour Name }
1079*5113495bSYour Name
1080*5113495bSYour Name gtk_rsp_param->vdev_id = fixed_param->vdev_id;
1081*5113495bSYour Name gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
1082*5113495bSYour Name gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
1083*5113495bSYour Name qdf_mem_copy(>k_rsp_param->replay_counter,
1084*5113495bSYour Name &fixed_param->replay_counter,
1085*5113495bSYour Name GTK_REPLAY_COUNTER_BYTES);
1086*5113495bSYour Name
1087*5113495bSYour Name return QDF_STATUS_SUCCESS;
1088*5113495bSYour Name
1089*5113495bSYour Name }
1090*5113495bSYour Name
1091*5113495bSYour Name #ifdef FEATURE_WLAN_RA_FILTERING
1092*5113495bSYour Name /**
1093*5113495bSYour Name * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
1094*5113495bSYour Name * @wmi_handle: wmi handle
1095*5113495bSYour Name * @vdev_id: vdev id
1096*5113495bSYour Name * @default_pattern: default pattern
1097*5113495bSYour Name * @rate_limit_interval: ra packets interval
1098*5113495bSYour Name *
1099*5113495bSYour Name * Return: QDF status
1100*5113495bSYour Name */
send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,uint8_t default_pattern,uint16_t rate_limit_interval)1101*5113495bSYour Name static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
1102*5113495bSYour Name uint8_t vdev_id,
1103*5113495bSYour Name uint8_t default_pattern,
1104*5113495bSYour Name uint16_t rate_limit_interval)
1105*5113495bSYour Name {
1106*5113495bSYour Name
1107*5113495bSYour Name WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
1108*5113495bSYour Name wmi_buf_t buf;
1109*5113495bSYour Name uint8_t *buf_ptr;
1110*5113495bSYour Name int32_t len;
1111*5113495bSYour Name int ret;
1112*5113495bSYour Name
1113*5113495bSYour Name len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
1114*5113495bSYour Name WMI_TLV_HDR_SIZE +
1115*5113495bSYour Name 0 * sizeof(WOW_BITMAP_PATTERN_T) +
1116*5113495bSYour Name WMI_TLV_HDR_SIZE +
1117*5113495bSYour Name 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
1118*5113495bSYour Name WMI_TLV_HDR_SIZE +
1119*5113495bSYour Name 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
1120*5113495bSYour Name WMI_TLV_HDR_SIZE +
1121*5113495bSYour Name 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
1122*5113495bSYour Name WMI_TLV_HDR_SIZE +
1123*5113495bSYour Name 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
1124*5113495bSYour Name
1125*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1126*5113495bSYour Name if (!buf) {
1127*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1128*5113495bSYour Name }
1129*5113495bSYour Name
1130*5113495bSYour Name cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
1131*5113495bSYour Name buf_ptr = (uint8_t *) cmd;
1132*5113495bSYour Name
1133*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1134*5113495bSYour Name WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
1135*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1136*5113495bSYour Name (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
1137*5113495bSYour Name cmd->vdev_id = vdev_id;
1138*5113495bSYour Name cmd->pattern_id = default_pattern,
1139*5113495bSYour Name cmd->pattern_type = WOW_IPV6_RA_PATTERN;
1140*5113495bSYour Name buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
1141*5113495bSYour Name
1142*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
1143*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1144*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1145*5113495bSYour Name
1146*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
1147*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1148*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1149*5113495bSYour Name
1150*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
1151*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1152*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1153*5113495bSYour Name
1154*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
1155*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1156*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1157*5113495bSYour Name
1158*5113495bSYour Name /* Fill TLV for pattern_info_timeout but no data. */
1159*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
1160*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1161*5113495bSYour Name
1162*5113495bSYour Name /* Fill TLV for ra_ratelimit_interval. */
1163*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
1164*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1165*5113495bSYour Name
1166*5113495bSYour Name *((uint32_t *) buf_ptr) = rate_limit_interval;
1167*5113495bSYour Name
1168*5113495bSYour Name wmi_debug("send RA rate limit [%d] to fw vdev = %d",
1169*5113495bSYour Name rate_limit_interval, vdev_id);
1170*5113495bSYour Name
1171*5113495bSYour Name wmi_mtrace(WMI_WOW_ADD_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
1172*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1173*5113495bSYour Name WMI_WOW_ADD_WAKE_PATTERN_CMDID);
1174*5113495bSYour Name if (ret) {
1175*5113495bSYour Name wmi_err("Failed to send RA rate limit to fw");
1176*5113495bSYour Name wmi_buf_free(buf);
1177*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1178*5113495bSYour Name }
1179*5113495bSYour Name
1180*5113495bSYour Name return QDF_STATUS_SUCCESS;
1181*5113495bSYour Name }
1182*5113495bSYour Name
wmi_ra_filtering_attach_tlv(struct wmi_unified * wmi_handle)1183*5113495bSYour Name void wmi_ra_filtering_attach_tlv(struct wmi_unified *wmi_handle)
1184*5113495bSYour Name {
1185*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
1186*5113495bSYour Name
1187*5113495bSYour Name ops->send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv;
1188*5113495bSYour Name }
1189*5113495bSYour Name #endif /* FEATURE_WLAN_RA_FILTERING */
1190*5113495bSYour Name
1191*5113495bSYour Name /**
1192*5113495bSYour Name * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
1193*5113495bSYour Name * @wmi_handle: wmi handler
1194*5113495bSYour Name * @action_params: pointer to action_params
1195*5113495bSYour Name *
1196*5113495bSYour Name * Return: 0 for success, otherwise appropriate error code
1197*5113495bSYour Name */
send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,struct pmo_action_wakeup_set_params * action_params)1198*5113495bSYour Name static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
1199*5113495bSYour Name struct pmo_action_wakeup_set_params *action_params)
1200*5113495bSYour Name {
1201*5113495bSYour Name WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
1202*5113495bSYour Name wmi_buf_t buf;
1203*5113495bSYour Name int i;
1204*5113495bSYour Name int32_t err;
1205*5113495bSYour Name uint32_t len = 0, *cmd_args;
1206*5113495bSYour Name uint8_t *buf_ptr;
1207*5113495bSYour Name
1208*5113495bSYour Name len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
1209*5113495bSYour Name + WMI_TLV_HDR_SIZE + sizeof(*cmd);
1210*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1211*5113495bSYour Name if (!buf) {
1212*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1213*5113495bSYour Name }
1214*5113495bSYour Name cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
1215*5113495bSYour Name buf_ptr = (uint8_t *)cmd;
1216*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1217*5113495bSYour Name WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
1218*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(
1219*5113495bSYour Name WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
1220*5113495bSYour Name
1221*5113495bSYour Name cmd->vdev_id = action_params->vdev_id;
1222*5113495bSYour Name cmd->operation = action_params->operation;
1223*5113495bSYour Name
1224*5113495bSYour Name for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
1225*5113495bSYour Name cmd->action_category_map[i] =
1226*5113495bSYour Name action_params->action_category_map[i];
1227*5113495bSYour Name
1228*5113495bSYour Name buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
1229*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
1230*5113495bSYour Name (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
1231*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1232*5113495bSYour Name cmd_args = (uint32_t *) buf_ptr;
1233*5113495bSYour Name for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
1234*5113495bSYour Name cmd_args[i] = action_params->action_per_category[i];
1235*5113495bSYour Name
1236*5113495bSYour Name wmi_mtrace(WMI_WOW_SET_ACTION_WAKE_UP_CMDID, cmd->vdev_id, 0);
1237*5113495bSYour Name err = wmi_unified_cmd_send(wmi_handle, buf,
1238*5113495bSYour Name len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
1239*5113495bSYour Name if (err) {
1240*5113495bSYour Name wmi_err("Failed to send ap_ps_egap cmd");
1241*5113495bSYour Name wmi_buf_free(buf);
1242*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1243*5113495bSYour Name }
1244*5113495bSYour Name
1245*5113495bSYour Name return QDF_STATUS_SUCCESS;
1246*5113495bSYour Name }
1247*5113495bSYour Name
1248*5113495bSYour Name #ifdef FEATURE_WLAN_LPHB
1249*5113495bSYour Name /**
1250*5113495bSYour Name * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
1251*5113495bSYour Name * @wmi_handle: wmi handle
1252*5113495bSYour Name * @params: LPHB configuration info
1253*5113495bSYour Name *
1254*5113495bSYour Name * Return: QDF status
1255*5113495bSYour Name */
send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,wmi_hb_set_enable_cmd_fixed_param * params)1256*5113495bSYour Name static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
1257*5113495bSYour Name wmi_hb_set_enable_cmd_fixed_param *params)
1258*5113495bSYour Name {
1259*5113495bSYour Name QDF_STATUS status;
1260*5113495bSYour Name wmi_buf_t buf = NULL;
1261*5113495bSYour Name uint8_t *buf_ptr;
1262*5113495bSYour Name wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
1263*5113495bSYour Name int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
1264*5113495bSYour Name
1265*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1266*5113495bSYour Name if (!buf) {
1267*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1268*5113495bSYour Name }
1269*5113495bSYour Name
1270*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
1271*5113495bSYour Name hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
1272*5113495bSYour Name WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
1273*5113495bSYour Name WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
1274*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1275*5113495bSYour Name (wmi_hb_set_enable_cmd_fixed_param));
1276*5113495bSYour Name
1277*5113495bSYour Name /* fill in values */
1278*5113495bSYour Name hb_enable_fp->vdev_id = params->session;
1279*5113495bSYour Name hb_enable_fp->enable = params->enable;
1280*5113495bSYour Name hb_enable_fp->item = params->item;
1281*5113495bSYour Name hb_enable_fp->session = params->session;
1282*5113495bSYour Name
1283*5113495bSYour Name wmi_mtrace(WMI_HB_SET_ENABLE_CMDID, NO_SESSION, 0);
1284*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf,
1285*5113495bSYour Name len, WMI_HB_SET_ENABLE_CMDID);
1286*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
1287*5113495bSYour Name wmi_err("cmd_send WMI_HB_SET_ENABLE returned Error %d",
1288*5113495bSYour Name status);
1289*5113495bSYour Name wmi_buf_free(buf);
1290*5113495bSYour Name }
1291*5113495bSYour Name
1292*5113495bSYour Name return status;
1293*5113495bSYour Name }
1294*5113495bSYour Name
1295*5113495bSYour Name /**
1296*5113495bSYour Name * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
1297*5113495bSYour Name * @wmi_handle: wmi handle
1298*5113495bSYour Name * @lphb_conf_req: lphb config request
1299*5113495bSYour Name *
1300*5113495bSYour Name * Return: QDF status
1301*5113495bSYour Name */
send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,wmi_hb_set_tcp_params_cmd_fixed_param * lphb_conf_req)1302*5113495bSYour Name static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
1303*5113495bSYour Name wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
1304*5113495bSYour Name {
1305*5113495bSYour Name QDF_STATUS status;
1306*5113495bSYour Name wmi_buf_t buf = NULL;
1307*5113495bSYour Name uint8_t *buf_ptr;
1308*5113495bSYour Name wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
1309*5113495bSYour Name int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
1310*5113495bSYour Name
1311*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1312*5113495bSYour Name if (!buf) {
1313*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1314*5113495bSYour Name }
1315*5113495bSYour Name
1316*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
1317*5113495bSYour Name hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
1318*5113495bSYour Name WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
1319*5113495bSYour Name WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
1320*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1321*5113495bSYour Name (wmi_hb_set_tcp_params_cmd_fixed_param));
1322*5113495bSYour Name
1323*5113495bSYour Name /* fill in values */
1324*5113495bSYour Name hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
1325*5113495bSYour Name hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
1326*5113495bSYour Name hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
1327*5113495bSYour Name hb_tcp_params_fp->seq = lphb_conf_req->seq;
1328*5113495bSYour Name hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
1329*5113495bSYour Name hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
1330*5113495bSYour Name hb_tcp_params_fp->interval = lphb_conf_req->interval;
1331*5113495bSYour Name hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
1332*5113495bSYour Name hb_tcp_params_fp->session = lphb_conf_req->session;
1333*5113495bSYour Name qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
1334*5113495bSYour Name &lphb_conf_req->gateway_mac,
1335*5113495bSYour Name sizeof(hb_tcp_params_fp->gateway_mac));
1336*5113495bSYour Name
1337*5113495bSYour Name wmi_mtrace(WMI_HB_SET_TCP_PARAMS_CMDID, NO_SESSION, 0);
1338*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf,
1339*5113495bSYour Name len, WMI_HB_SET_TCP_PARAMS_CMDID);
1340*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
1341*5113495bSYour Name wmi_err("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
1342*5113495bSYour Name status);
1343*5113495bSYour Name wmi_buf_free(buf);
1344*5113495bSYour Name }
1345*5113495bSYour Name
1346*5113495bSYour Name return status;
1347*5113495bSYour Name }
1348*5113495bSYour Name
1349*5113495bSYour Name /**
1350*5113495bSYour Name * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
1351*5113495bSYour Name * @wmi_handle: wmi handle
1352*5113495bSYour Name * @g_hb_tcp_filter_fp: tcp packet filter params
1353*5113495bSYour Name *
1354*5113495bSYour Name * Return: QDF status
1355*5113495bSYour Name */
1356*5113495bSYour Name static
send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,wmi_hb_set_tcp_pkt_filter_cmd_fixed_param * g_hb_tcp_filter_fp)1357*5113495bSYour Name QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
1358*5113495bSYour Name wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
1359*5113495bSYour Name {
1360*5113495bSYour Name QDF_STATUS status;
1361*5113495bSYour Name wmi_buf_t buf = NULL;
1362*5113495bSYour Name uint8_t *buf_ptr;
1363*5113495bSYour Name wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
1364*5113495bSYour Name int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
1365*5113495bSYour Name
1366*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1367*5113495bSYour Name if (!buf) {
1368*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1369*5113495bSYour Name }
1370*5113495bSYour Name
1371*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
1372*5113495bSYour Name hb_tcp_filter_fp =
1373*5113495bSYour Name (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
1374*5113495bSYour Name WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
1375*5113495bSYour Name WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
1376*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1377*5113495bSYour Name (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
1378*5113495bSYour Name
1379*5113495bSYour Name /* fill in values */
1380*5113495bSYour Name hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
1381*5113495bSYour Name hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
1382*5113495bSYour Name hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
1383*5113495bSYour Name hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
1384*5113495bSYour Name memcpy((void *)&hb_tcp_filter_fp->filter,
1385*5113495bSYour Name (void *)&g_hb_tcp_filter_fp->filter,
1386*5113495bSYour Name WMI_WLAN_HB_MAX_FILTER_SIZE);
1387*5113495bSYour Name
1388*5113495bSYour Name wmi_mtrace(WMI_HB_SET_TCP_PKT_FILTER_CMDID, NO_SESSION, 0);
1389*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf,
1390*5113495bSYour Name len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
1391*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
1392*5113495bSYour Name wmi_err("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
1393*5113495bSYour Name status);
1394*5113495bSYour Name wmi_buf_free(buf);
1395*5113495bSYour Name }
1396*5113495bSYour Name
1397*5113495bSYour Name return status;
1398*5113495bSYour Name }
1399*5113495bSYour Name
1400*5113495bSYour Name /**
1401*5113495bSYour Name * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
1402*5113495bSYour Name * @wmi_handle: wmi handle
1403*5113495bSYour Name * @lphb_conf_req: lphb config request
1404*5113495bSYour Name *
1405*5113495bSYour Name * Return: QDF status
1406*5113495bSYour Name */
send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,wmi_hb_set_udp_params_cmd_fixed_param * lphb_conf_req)1407*5113495bSYour Name static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
1408*5113495bSYour Name wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
1409*5113495bSYour Name {
1410*5113495bSYour Name QDF_STATUS status;
1411*5113495bSYour Name wmi_buf_t buf = NULL;
1412*5113495bSYour Name uint8_t *buf_ptr;
1413*5113495bSYour Name wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
1414*5113495bSYour Name int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
1415*5113495bSYour Name
1416*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1417*5113495bSYour Name if (!buf) {
1418*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1419*5113495bSYour Name }
1420*5113495bSYour Name
1421*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
1422*5113495bSYour Name hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
1423*5113495bSYour Name WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
1424*5113495bSYour Name WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
1425*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1426*5113495bSYour Name (wmi_hb_set_udp_params_cmd_fixed_param));
1427*5113495bSYour Name
1428*5113495bSYour Name /* fill in values */
1429*5113495bSYour Name hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
1430*5113495bSYour Name hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
1431*5113495bSYour Name hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
1432*5113495bSYour Name hb_udp_params_fp->src_port = lphb_conf_req->src_port;
1433*5113495bSYour Name hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
1434*5113495bSYour Name hb_udp_params_fp->interval = lphb_conf_req->interval;
1435*5113495bSYour Name hb_udp_params_fp->timeout = lphb_conf_req->timeout;
1436*5113495bSYour Name hb_udp_params_fp->session = lphb_conf_req->session;
1437*5113495bSYour Name qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
1438*5113495bSYour Name &lphb_conf_req->gateway_mac,
1439*5113495bSYour Name sizeof(lphb_conf_req->gateway_mac));
1440*5113495bSYour Name
1441*5113495bSYour Name wmi_mtrace(WMI_HB_SET_UDP_PARAMS_CMDID, NO_SESSION, 0);
1442*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf,
1443*5113495bSYour Name len, WMI_HB_SET_UDP_PARAMS_CMDID);
1444*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
1445*5113495bSYour Name wmi_err("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
1446*5113495bSYour Name status);
1447*5113495bSYour Name wmi_buf_free(buf);
1448*5113495bSYour Name }
1449*5113495bSYour Name
1450*5113495bSYour Name return status;
1451*5113495bSYour Name }
1452*5113495bSYour Name
1453*5113495bSYour Name /**
1454*5113495bSYour Name * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
1455*5113495bSYour Name * @wmi_handle: wmi handle
1456*5113495bSYour Name * @lphb_conf_req: lphb config request
1457*5113495bSYour Name *
1458*5113495bSYour Name * Return: QDF status
1459*5113495bSYour Name */
1460*5113495bSYour Name static
send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,wmi_hb_set_udp_pkt_filter_cmd_fixed_param * lphb_conf_req)1461*5113495bSYour Name QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
1462*5113495bSYour Name wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
1463*5113495bSYour Name {
1464*5113495bSYour Name QDF_STATUS status;
1465*5113495bSYour Name wmi_buf_t buf = NULL;
1466*5113495bSYour Name uint8_t *buf_ptr;
1467*5113495bSYour Name wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
1468*5113495bSYour Name int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
1469*5113495bSYour Name
1470*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1471*5113495bSYour Name if (!buf) {
1472*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1473*5113495bSYour Name }
1474*5113495bSYour Name
1475*5113495bSYour Name buf_ptr = (uint8_t *) wmi_buf_data(buf);
1476*5113495bSYour Name hb_udp_filter_fp =
1477*5113495bSYour Name (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
1478*5113495bSYour Name WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
1479*5113495bSYour Name WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
1480*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1481*5113495bSYour Name (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
1482*5113495bSYour Name
1483*5113495bSYour Name /* fill in values */
1484*5113495bSYour Name hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
1485*5113495bSYour Name hb_udp_filter_fp->length = lphb_conf_req->length;
1486*5113495bSYour Name hb_udp_filter_fp->offset = lphb_conf_req->offset;
1487*5113495bSYour Name hb_udp_filter_fp->session = lphb_conf_req->session;
1488*5113495bSYour Name memcpy((void *)&hb_udp_filter_fp->filter,
1489*5113495bSYour Name (void *)&lphb_conf_req->filter,
1490*5113495bSYour Name WMI_WLAN_HB_MAX_FILTER_SIZE);
1491*5113495bSYour Name
1492*5113495bSYour Name wmi_mtrace(WMI_HB_SET_UDP_PKT_FILTER_CMDID, NO_SESSION, 0);
1493*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf,
1494*5113495bSYour Name len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
1495*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status)) {
1496*5113495bSYour Name wmi_err("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
1497*5113495bSYour Name status);
1498*5113495bSYour Name wmi_buf_free(buf);
1499*5113495bSYour Name }
1500*5113495bSYour Name
1501*5113495bSYour Name return status;
1502*5113495bSYour Name }
1503*5113495bSYour Name
wmi_lphb_attach_tlv(struct wmi_unified * wmi_handle)1504*5113495bSYour Name void wmi_lphb_attach_tlv(struct wmi_unified *wmi_handle)
1505*5113495bSYour Name {
1506*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
1507*5113495bSYour Name
1508*5113495bSYour Name ops->send_lphb_config_hbenable_cmd =
1509*5113495bSYour Name send_lphb_config_hbenable_cmd_tlv;
1510*5113495bSYour Name ops->send_lphb_config_tcp_params_cmd =
1511*5113495bSYour Name send_lphb_config_tcp_params_cmd_tlv;
1512*5113495bSYour Name ops->send_lphb_config_tcp_pkt_filter_cmd =
1513*5113495bSYour Name send_lphb_config_tcp_pkt_filter_cmd_tlv;
1514*5113495bSYour Name ops->send_lphb_config_udp_params_cmd =
1515*5113495bSYour Name send_lphb_config_udp_params_cmd_tlv;
1516*5113495bSYour Name ops->send_lphb_config_udp_pkt_filter_cmd =
1517*5113495bSYour Name send_lphb_config_udp_pkt_filter_cmd_tlv;
1518*5113495bSYour Name }
1519*5113495bSYour Name #endif /* FEATURE_WLAN_LPHB */
1520*5113495bSYour Name
1521*5113495bSYour Name #ifdef WLAN_FEATURE_PACKET_FILTERING
1522*5113495bSYour Name /**
1523*5113495bSYour Name * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
1524*5113495bSYour Name * @wmi_handle: wmi handle
1525*5113495bSYour Name * @vdev_id: vdev id
1526*5113495bSYour Name * @enable: Flag to enable/disable packet filter
1527*5113495bSYour Name *
1528*5113495bSYour Name * Return: QDF_STATUS_SUCCESS for success or error code
1529*5113495bSYour Name */
send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,bool enable)1530*5113495bSYour Name static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
1531*5113495bSYour Name wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
1532*5113495bSYour Name {
1533*5113495bSYour Name int32_t len;
1534*5113495bSYour Name int ret = 0;
1535*5113495bSYour Name wmi_buf_t buf;
1536*5113495bSYour Name WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
1537*5113495bSYour Name
1538*5113495bSYour Name len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
1539*5113495bSYour Name
1540*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1541*5113495bSYour Name if (!buf) {
1542*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1543*5113495bSYour Name }
1544*5113495bSYour Name
1545*5113495bSYour Name cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
1546*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1547*5113495bSYour Name WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
1548*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(
1549*5113495bSYour Name WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
1550*5113495bSYour Name
1551*5113495bSYour Name cmd->vdev_id = vdev_id;
1552*5113495bSYour Name if (enable)
1553*5113495bSYour Name cmd->enable = PACKET_FILTER_SET_ENABLE;
1554*5113495bSYour Name else
1555*5113495bSYour Name cmd->enable = PACKET_FILTER_SET_DISABLE;
1556*5113495bSYour Name
1557*5113495bSYour Name wmi_err("Packet filter enable %d for vdev_id %d", cmd->enable, vdev_id);
1558*5113495bSYour Name
1559*5113495bSYour Name wmi_mtrace(WMI_PACKET_FILTER_ENABLE_CMDID, cmd->vdev_id, 0);
1560*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1561*5113495bSYour Name WMI_PACKET_FILTER_ENABLE_CMDID);
1562*5113495bSYour Name if (ret) {
1563*5113495bSYour Name wmi_err("Failed to send packet filter wmi cmd to fw");
1564*5113495bSYour Name wmi_buf_free(buf);
1565*5113495bSYour Name }
1566*5113495bSYour Name
1567*5113495bSYour Name return ret;
1568*5113495bSYour Name }
1569*5113495bSYour Name
1570*5113495bSYour Name /**
1571*5113495bSYour Name * send_config_packet_filter_cmd_tlv() - configure packet filter in target
1572*5113495bSYour Name * @wmi_handle: wmi handle
1573*5113495bSYour Name * @vdev_id: vdev id
1574*5113495bSYour Name * @rcv_filter_param: Packet filter parameters
1575*5113495bSYour Name * @filter_id: Filter id
1576*5113495bSYour Name * @enable: Flag to add/delete packet filter configuration
1577*5113495bSYour Name *
1578*5113495bSYour Name * Return: QDF_STATUS_SUCCESS for success or error code
1579*5113495bSYour Name */
send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,struct pmo_rcv_pkt_fltr_cfg * rcv_filter_param,uint8_t filter_id,bool enable)1580*5113495bSYour Name static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
1581*5113495bSYour Name uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
1582*5113495bSYour Name uint8_t filter_id, bool enable)
1583*5113495bSYour Name {
1584*5113495bSYour Name int len, i;
1585*5113495bSYour Name int err = 0;
1586*5113495bSYour Name wmi_buf_t buf;
1587*5113495bSYour Name WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
1588*5113495bSYour Name
1589*5113495bSYour Name /* allocate the memory */
1590*5113495bSYour Name len = sizeof(*cmd);
1591*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1592*5113495bSYour Name if (!buf) {
1593*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1594*5113495bSYour Name }
1595*5113495bSYour Name
1596*5113495bSYour Name cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
1597*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1598*5113495bSYour Name WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
1599*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1600*5113495bSYour Name (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
1601*5113495bSYour Name
1602*5113495bSYour Name cmd->vdev_id = vdev_id;
1603*5113495bSYour Name cmd->filter_id = filter_id;
1604*5113495bSYour Name if (enable)
1605*5113495bSYour Name cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
1606*5113495bSYour Name else
1607*5113495bSYour Name cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
1608*5113495bSYour Name
1609*5113495bSYour Name if (enable) {
1610*5113495bSYour Name cmd->num_params = QDF_MIN(
1611*5113495bSYour Name WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
1612*5113495bSYour Name rcv_filter_param->num_params);
1613*5113495bSYour Name cmd->filter_type = rcv_filter_param->filter_type;
1614*5113495bSYour Name cmd->coalesce_time = rcv_filter_param->coalesce_time;
1615*5113495bSYour Name
1616*5113495bSYour Name for (i = 0; i < cmd->num_params; i++) {
1617*5113495bSYour Name cmd->paramsData[i].proto_type =
1618*5113495bSYour Name rcv_filter_param->params_data[i].protocol_layer;
1619*5113495bSYour Name cmd->paramsData[i].cmp_type =
1620*5113495bSYour Name rcv_filter_param->params_data[i].compare_flag;
1621*5113495bSYour Name cmd->paramsData[i].data_length =
1622*5113495bSYour Name rcv_filter_param->params_data[i].data_length;
1623*5113495bSYour Name cmd->paramsData[i].data_offset =
1624*5113495bSYour Name rcv_filter_param->params_data[i].data_offset;
1625*5113495bSYour Name memcpy(&cmd->paramsData[i].compareData,
1626*5113495bSYour Name rcv_filter_param->params_data[i].compare_data,
1627*5113495bSYour Name sizeof(cmd->paramsData[i].compareData));
1628*5113495bSYour Name memcpy(&cmd->paramsData[i].dataMask,
1629*5113495bSYour Name rcv_filter_param->params_data[i].data_mask,
1630*5113495bSYour Name sizeof(cmd->paramsData[i].dataMask));
1631*5113495bSYour Name }
1632*5113495bSYour Name }
1633*5113495bSYour Name
1634*5113495bSYour Name wmi_err("Packet filter action %d filter with id: %d, num_params=%d",
1635*5113495bSYour Name cmd->filter_action, cmd->filter_id, cmd->num_params);
1636*5113495bSYour Name /* send the command along with data */
1637*5113495bSYour Name wmi_mtrace(WMI_PACKET_FILTER_CONFIG_CMDID, cmd->vdev_id, 0);
1638*5113495bSYour Name err = wmi_unified_cmd_send(wmi_handle, buf, len,
1639*5113495bSYour Name WMI_PACKET_FILTER_CONFIG_CMDID);
1640*5113495bSYour Name if (err) {
1641*5113495bSYour Name wmi_err("Failed to send pkt_filter cmd");
1642*5113495bSYour Name wmi_buf_free(buf);
1643*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1644*5113495bSYour Name }
1645*5113495bSYour Name
1646*5113495bSYour Name return QDF_STATUS_SUCCESS;
1647*5113495bSYour Name }
1648*5113495bSYour Name
wmi_packet_filtering_attach_tlv(struct wmi_unified * wmi_handle)1649*5113495bSYour Name void wmi_packet_filtering_attach_tlv(struct wmi_unified *wmi_handle)
1650*5113495bSYour Name {
1651*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
1652*5113495bSYour Name
1653*5113495bSYour Name ops->send_enable_disable_packet_filter_cmd =
1654*5113495bSYour Name send_enable_disable_packet_filter_cmd_tlv;
1655*5113495bSYour Name ops->send_config_packet_filter_cmd =
1656*5113495bSYour Name send_config_packet_filter_cmd_tlv;
1657*5113495bSYour Name }
1658*5113495bSYour Name #endif /* WLAN_FEATURE_PACKET_FILTERING */
1659*5113495bSYour Name
1660*5113495bSYour Name /**
1661*5113495bSYour Name * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
1662*5113495bSYour Name * @wmi_handle: wmi handle
1663*5113495bSYour Name * @ptrn_id: pattern id
1664*5113495bSYour Name * @vdev_id: vdev id
1665*5113495bSYour Name *
1666*5113495bSYour Name * Return: QDF status
1667*5113495bSYour Name */
send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,uint8_t ptrn_id,uint8_t vdev_id)1668*5113495bSYour Name static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
1669*5113495bSYour Name uint8_t ptrn_id,
1670*5113495bSYour Name uint8_t vdev_id)
1671*5113495bSYour Name {
1672*5113495bSYour Name WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
1673*5113495bSYour Name wmi_buf_t buf;
1674*5113495bSYour Name int32_t len;
1675*5113495bSYour Name int ret;
1676*5113495bSYour Name
1677*5113495bSYour Name len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
1678*5113495bSYour Name
1679*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1680*5113495bSYour Name if (!buf) {
1681*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1682*5113495bSYour Name }
1683*5113495bSYour Name
1684*5113495bSYour Name cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
1685*5113495bSYour Name
1686*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1687*5113495bSYour Name WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
1688*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(
1689*5113495bSYour Name WMI_WOW_DEL_PATTERN_CMD_fixed_param));
1690*5113495bSYour Name cmd->vdev_id = vdev_id;
1691*5113495bSYour Name cmd->pattern_id = ptrn_id;
1692*5113495bSYour Name cmd->pattern_type = WOW_BITMAP_PATTERN;
1693*5113495bSYour Name
1694*5113495bSYour Name wmi_mtrace(WMI_WOW_DEL_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
1695*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1696*5113495bSYour Name WMI_WOW_DEL_WAKE_PATTERN_CMDID);
1697*5113495bSYour Name if (ret) {
1698*5113495bSYour Name wmi_err("Failed to delete wow ptrn from fw");
1699*5113495bSYour Name wmi_buf_free(buf);
1700*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1701*5113495bSYour Name }
1702*5113495bSYour Name
1703*5113495bSYour Name return QDF_STATUS_SUCCESS;
1704*5113495bSYour Name }
1705*5113495bSYour Name
1706*5113495bSYour Name #ifdef WMI_HOST_WAKEUP_OVER_QMI
1707*5113495bSYour Name static inline
wmi_unified_cmd_send_chk(struct wmi_unified * wmi_handle,wmi_buf_t buf,uint32_t buflen,uint32_t cmd_id)1708*5113495bSYour Name QDF_STATUS wmi_unified_cmd_send_chk(struct wmi_unified *wmi_handle,
1709*5113495bSYour Name wmi_buf_t buf,
1710*5113495bSYour Name uint32_t buflen, uint32_t cmd_id)
1711*5113495bSYour Name {
1712*5113495bSYour Name wmi_debug("Send WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID over QMI");
1713*5113495bSYour Name return wmi_unified_cmd_send_over_qmi(wmi_handle, buf,
1714*5113495bSYour Name buflen, cmd_id);
1715*5113495bSYour Name }
1716*5113495bSYour Name #else
1717*5113495bSYour Name static inline
wmi_unified_cmd_send_chk(struct wmi_unified * wmi_handle,wmi_buf_t buf,uint32_t buflen,uint32_t cmd_id)1718*5113495bSYour Name QDF_STATUS wmi_unified_cmd_send_chk(struct wmi_unified *wmi_handle,
1719*5113495bSYour Name wmi_buf_t buf,
1720*5113495bSYour Name uint32_t buflen, uint32_t cmd_id)
1721*5113495bSYour Name {
1722*5113495bSYour Name return wmi_unified_cmd_send(wmi_handle, buf,
1723*5113495bSYour Name buflen, cmd_id);
1724*5113495bSYour Name }
1725*5113495bSYour Name #endif
1726*5113495bSYour Name
1727*5113495bSYour Name /**
1728*5113495bSYour Name * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
1729*5113495bSYour Name * @wmi_handle: wmi handle
1730*5113495bSYour Name * @tx_pending_ind: flag of TX has pending frames
1731*5113495bSYour Name *
1732*5113495bSYour Name * Sends host wakeup indication to FW. On receiving this indication,
1733*5113495bSYour Name * FW will come out of WOW.
1734*5113495bSYour Name *
1735*5113495bSYour Name * Return: QDF status
1736*5113495bSYour Name */
send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle,bool tx_pending_ind)1737*5113495bSYour Name static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
1738*5113495bSYour Name bool tx_pending_ind)
1739*5113495bSYour Name {
1740*5113495bSYour Name wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
1741*5113495bSYour Name wmi_buf_t buf;
1742*5113495bSYour Name QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
1743*5113495bSYour Name int32_t len;
1744*5113495bSYour Name int ret;
1745*5113495bSYour Name
1746*5113495bSYour Name len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
1747*5113495bSYour Name
1748*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1749*5113495bSYour Name if (!buf) {
1750*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1751*5113495bSYour Name }
1752*5113495bSYour Name
1753*5113495bSYour Name cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
1754*5113495bSYour Name wmi_buf_data(buf);
1755*5113495bSYour Name
1756*5113495bSYour Name if (tx_pending_ind) {
1757*5113495bSYour Name wmi_debug("TX pending before WoW wake, indicate FW");
1758*5113495bSYour Name cmd->flags |= WMI_WOW_RESUME_FLAG_TX_DATA;
1759*5113495bSYour Name }
1760*5113495bSYour Name
1761*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1762*5113495bSYour Name WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
1763*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1764*5113495bSYour Name (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
1765*5113495bSYour Name
1766*5113495bSYour Name wmi_mtrace(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, NO_SESSION, 0);
1767*5113495bSYour Name ret = wmi_unified_cmd_send_chk(wmi_handle, buf, len,
1768*5113495bSYour Name WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
1769*5113495bSYour Name if (ret) {
1770*5113495bSYour Name wmi_err("Failed to send host wakeup indication to fw");
1771*5113495bSYour Name wmi_buf_free(buf);
1772*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1773*5113495bSYour Name }
1774*5113495bSYour Name
1775*5113495bSYour Name return qdf_status;
1776*5113495bSYour Name }
1777*5113495bSYour Name
1778*5113495bSYour Name /**
1779*5113495bSYour Name * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
1780*5113495bSYour Name * will wake up host after specified time is elapsed
1781*5113495bSYour Name * @wmi_handle: wmi handle
1782*5113495bSYour Name * @vdev_id: vdev id
1783*5113495bSYour Name * @cookie: value to identify reason why host set up wake call.
1784*5113495bSYour Name * @time: time in ms
1785*5113495bSYour Name *
1786*5113495bSYour Name * Return: QDF status
1787*5113495bSYour Name */
send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,uint8_t vdev_id,uint32_t cookie,uint32_t time)1788*5113495bSYour Name static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
1789*5113495bSYour Name uint8_t vdev_id, uint32_t cookie, uint32_t time)
1790*5113495bSYour Name {
1791*5113495bSYour Name WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
1792*5113495bSYour Name wmi_buf_t buf;
1793*5113495bSYour Name uint8_t *buf_ptr;
1794*5113495bSYour Name int32_t len;
1795*5113495bSYour Name int ret;
1796*5113495bSYour Name
1797*5113495bSYour Name len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
1798*5113495bSYour Name WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
1799*5113495bSYour Name WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
1800*5113495bSYour Name WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
1801*5113495bSYour Name WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
1802*5113495bSYour Name WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
1803*5113495bSYour Name WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
1804*5113495bSYour Name
1805*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1806*5113495bSYour Name if (!buf) {
1807*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1808*5113495bSYour Name }
1809*5113495bSYour Name
1810*5113495bSYour Name cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
1811*5113495bSYour Name buf_ptr = (uint8_t *) cmd;
1812*5113495bSYour Name
1813*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1814*5113495bSYour Name WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
1815*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1816*5113495bSYour Name (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
1817*5113495bSYour Name cmd->vdev_id = vdev_id;
1818*5113495bSYour Name cmd->pattern_id = cookie,
1819*5113495bSYour Name cmd->pattern_type = WOW_TIMER_PATTERN;
1820*5113495bSYour Name buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
1821*5113495bSYour Name
1822*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
1823*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1824*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1825*5113495bSYour Name
1826*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
1827*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1828*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1829*5113495bSYour Name
1830*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
1831*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1832*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1833*5113495bSYour Name
1834*5113495bSYour Name /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
1835*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
1836*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1837*5113495bSYour Name
1838*5113495bSYour Name /* Fill TLV for pattern_info_timeout, and time value */
1839*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
1840*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1841*5113495bSYour Name *((uint32_t *) buf_ptr) = time;
1842*5113495bSYour Name buf_ptr += sizeof(uint32_t);
1843*5113495bSYour Name
1844*5113495bSYour Name /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
1845*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
1846*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
1847*5113495bSYour Name *((uint32_t *) buf_ptr) = 0;
1848*5113495bSYour Name
1849*5113495bSYour Name wmi_debug("send wake timer pattern with time[%d] to fw vdev = %d",
1850*5113495bSYour Name time, vdev_id);
1851*5113495bSYour Name
1852*5113495bSYour Name wmi_mtrace(WMI_WOW_ADD_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
1853*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1854*5113495bSYour Name WMI_WOW_ADD_WAKE_PATTERN_CMDID);
1855*5113495bSYour Name if (ret) {
1856*5113495bSYour Name wmi_err("Failed to send wake timer pattern to fw");
1857*5113495bSYour Name wmi_buf_free(buf);
1858*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1859*5113495bSYour Name }
1860*5113495bSYour Name
1861*5113495bSYour Name return QDF_STATUS_SUCCESS;
1862*5113495bSYour Name }
1863*5113495bSYour Name
1864*5113495bSYour Name #ifdef WLAN_FEATURE_EXTWOW_SUPPORT
1865*5113495bSYour Name /**
1866*5113495bSYour Name * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
1867*5113495bSYour Name * @wmi_handle: wmi handle
1868*5113495bSYour Name * @params: ext wow params
1869*5113495bSYour Name *
1870*5113495bSYour Name * Return:0 for success or error code
1871*5113495bSYour Name */
send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,struct ext_wow_params * params)1872*5113495bSYour Name static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
1873*5113495bSYour Name struct ext_wow_params *params)
1874*5113495bSYour Name {
1875*5113495bSYour Name wmi_extwow_enable_cmd_fixed_param *cmd;
1876*5113495bSYour Name wmi_buf_t buf;
1877*5113495bSYour Name int32_t len;
1878*5113495bSYour Name int ret;
1879*5113495bSYour Name
1880*5113495bSYour Name len = sizeof(wmi_extwow_enable_cmd_fixed_param);
1881*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1882*5113495bSYour Name if (!buf) {
1883*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1884*5113495bSYour Name }
1885*5113495bSYour Name
1886*5113495bSYour Name cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1887*5113495bSYour Name
1888*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1889*5113495bSYour Name WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
1890*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1891*5113495bSYour Name (wmi_extwow_enable_cmd_fixed_param));
1892*5113495bSYour Name
1893*5113495bSYour Name cmd->vdev_id = params->vdev_id;
1894*5113495bSYour Name cmd->type = params->type;
1895*5113495bSYour Name cmd->wakeup_pin_num = params->wakeup_pin_num;
1896*5113495bSYour Name
1897*5113495bSYour Name wmi_debug("vdev_id %d type %d Wakeup_pin_num %x",
1898*5113495bSYour Name cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
1899*5113495bSYour Name
1900*5113495bSYour Name wmi_mtrace(WMI_EXTWOW_ENABLE_CMDID, cmd->vdev_id, 0);
1901*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1902*5113495bSYour Name WMI_EXTWOW_ENABLE_CMDID);
1903*5113495bSYour Name if (ret) {
1904*5113495bSYour Name wmi_err("Failed to set EXTWOW Enable");
1905*5113495bSYour Name wmi_buf_free(buf);
1906*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1907*5113495bSYour Name }
1908*5113495bSYour Name
1909*5113495bSYour Name return QDF_STATUS_SUCCESS;
1910*5113495bSYour Name
1911*5113495bSYour Name }
1912*5113495bSYour Name
1913*5113495bSYour Name /**
1914*5113495bSYour Name * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
1915*5113495bSYour Name * @wmi_handle: wmi handle
1916*5113495bSYour Name * @appType2Params: app type2 params
1917*5113495bSYour Name *
1918*5113495bSYour Name * Return: QDF status
1919*5113495bSYour Name */
send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,struct app_type2_params * appType2Params)1920*5113495bSYour Name static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
1921*5113495bSYour Name struct app_type2_params *appType2Params)
1922*5113495bSYour Name {
1923*5113495bSYour Name wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
1924*5113495bSYour Name wmi_buf_t buf;
1925*5113495bSYour Name int32_t len;
1926*5113495bSYour Name int ret;
1927*5113495bSYour Name
1928*5113495bSYour Name len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
1929*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
1930*5113495bSYour Name if (!buf) {
1931*5113495bSYour Name return QDF_STATUS_E_NOMEM;
1932*5113495bSYour Name }
1933*5113495bSYour Name
1934*5113495bSYour Name cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
1935*5113495bSYour Name wmi_buf_data(buf);
1936*5113495bSYour Name
1937*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
1938*5113495bSYour Name WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
1939*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
1940*5113495bSYour Name (wmi_extwow_set_app_type2_params_cmd_fixed_param));
1941*5113495bSYour Name
1942*5113495bSYour Name cmd->vdev_id = appType2Params->vdev_id;
1943*5113495bSYour Name
1944*5113495bSYour Name qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
1945*5113495bSYour Name cmd->rc4_key_len = appType2Params->rc4_key_len;
1946*5113495bSYour Name
1947*5113495bSYour Name cmd->ip_id = appType2Params->ip_id;
1948*5113495bSYour Name cmd->ip_device_ip = appType2Params->ip_device_ip;
1949*5113495bSYour Name cmd->ip_server_ip = appType2Params->ip_server_ip;
1950*5113495bSYour Name
1951*5113495bSYour Name cmd->tcp_src_port = appType2Params->tcp_src_port;
1952*5113495bSYour Name cmd->tcp_dst_port = appType2Params->tcp_dst_port;
1953*5113495bSYour Name cmd->tcp_seq = appType2Params->tcp_seq;
1954*5113495bSYour Name cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
1955*5113495bSYour Name
1956*5113495bSYour Name cmd->keepalive_init = appType2Params->keepalive_init;
1957*5113495bSYour Name cmd->keepalive_min = appType2Params->keepalive_min;
1958*5113495bSYour Name cmd->keepalive_max = appType2Params->keepalive_max;
1959*5113495bSYour Name cmd->keepalive_inc = appType2Params->keepalive_inc;
1960*5113495bSYour Name
1961*5113495bSYour Name WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
1962*5113495bSYour Name &cmd->gateway_mac);
1963*5113495bSYour Name cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
1964*5113495bSYour Name cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
1965*5113495bSYour Name
1966*5113495bSYour Name wmi_debug("vdev_id %d gateway_mac "QDF_MAC_ADDR_FMT" "
1967*5113495bSYour Name "rc4_key %.16s rc4_key_len %u "
1968*5113495bSYour Name "ip_id %x ip_device_ip %x ip_server_ip %x "
1969*5113495bSYour Name "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
1970*5113495bSYour Name "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
1971*5113495bSYour Name "keepalive_max %u keepalive_inc %u "
1972*5113495bSYour Name "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
1973*5113495bSYour Name cmd->vdev_id,
1974*5113495bSYour Name QDF_MAC_ADDR_REF(appType2Params->gateway_mac.bytes),
1975*5113495bSYour Name cmd->rc4_key, cmd->rc4_key_len,
1976*5113495bSYour Name cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
1977*5113495bSYour Name cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
1978*5113495bSYour Name cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
1979*5113495bSYour Name cmd->keepalive_max, cmd->keepalive_inc,
1980*5113495bSYour Name cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
1981*5113495bSYour Name
1982*5113495bSYour Name wmi_mtrace(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID, cmd->vdev_id, 0);
1983*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1984*5113495bSYour Name WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
1985*5113495bSYour Name if (ret) {
1986*5113495bSYour Name wmi_err("Failed to set APP TYPE2 PARAMS");
1987*5113495bSYour Name wmi_buf_free(buf);
1988*5113495bSYour Name return QDF_STATUS_E_FAILURE;
1989*5113495bSYour Name }
1990*5113495bSYour Name
1991*5113495bSYour Name return QDF_STATUS_SUCCESS;
1992*5113495bSYour Name
1993*5113495bSYour Name }
1994*5113495bSYour Name
1995*5113495bSYour Name /**
1996*5113495bSYour Name * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
1997*5113495bSYour Name * @wmi_handle: wmi handle
1998*5113495bSYour Name * @app_type1_params: app type1 params
1999*5113495bSYour Name *
2000*5113495bSYour Name * Return: QDF status
2001*5113495bSYour Name */
send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,struct app_type1_params * app_type1_params)2002*5113495bSYour Name static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
2003*5113495bSYour Name struct app_type1_params *app_type1_params)
2004*5113495bSYour Name {
2005*5113495bSYour Name wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
2006*5113495bSYour Name wmi_buf_t buf;
2007*5113495bSYour Name int32_t len;
2008*5113495bSYour Name int ret;
2009*5113495bSYour Name
2010*5113495bSYour Name len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
2011*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
2012*5113495bSYour Name if (!buf) {
2013*5113495bSYour Name return QDF_STATUS_E_NOMEM;
2014*5113495bSYour Name }
2015*5113495bSYour Name
2016*5113495bSYour Name cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
2017*5113495bSYour Name wmi_buf_data(buf);
2018*5113495bSYour Name
2019*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
2020*5113495bSYour Name WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
2021*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN
2022*5113495bSYour Name (wmi_extwow_set_app_type1_params_cmd_fixed_param));
2023*5113495bSYour Name
2024*5113495bSYour Name cmd->vdev_id = app_type1_params->vdev_id;
2025*5113495bSYour Name WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
2026*5113495bSYour Name &cmd->wakee_mac);
2027*5113495bSYour Name qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
2028*5113495bSYour Name cmd->ident_len = app_type1_params->id_length;
2029*5113495bSYour Name qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
2030*5113495bSYour Name cmd->passwd_len = app_type1_params->pass_length;
2031*5113495bSYour Name
2032*5113495bSYour Name wmi_debug("vdev_id %d wakee_mac_addr "QDF_MAC_ADDR_FMT" "
2033*5113495bSYour Name "identification_id %.8s id_length %u "
2034*5113495bSYour Name "password %.16s pass_length %u",
2035*5113495bSYour Name cmd->vdev_id,
2036*5113495bSYour Name QDF_MAC_ADDR_REF(app_type1_params->wakee_mac_addr.bytes),
2037*5113495bSYour Name cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
2038*5113495bSYour Name
2039*5113495bSYour Name wmi_mtrace(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID, cmd->vdev_id, 0);
2040*5113495bSYour Name ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2041*5113495bSYour Name WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
2042*5113495bSYour Name if (ret) {
2043*5113495bSYour Name wmi_err("Failed to set APP TYPE1 PARAMS");
2044*5113495bSYour Name wmi_buf_free(buf);
2045*5113495bSYour Name return QDF_STATUS_E_FAILURE;
2046*5113495bSYour Name }
2047*5113495bSYour Name
2048*5113495bSYour Name return QDF_STATUS_SUCCESS;
2049*5113495bSYour Name }
2050*5113495bSYour Name
wmi_extwow_attach_tlv(struct wmi_unified * wmi_handle)2051*5113495bSYour Name void wmi_extwow_attach_tlv(struct wmi_unified *wmi_handle)
2052*5113495bSYour Name {
2053*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
2054*5113495bSYour Name
2055*5113495bSYour Name ops->send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv;
2056*5113495bSYour Name ops->send_set_app_type2_params_in_fw_cmd =
2057*5113495bSYour Name send_set_app_type2_params_in_fw_cmd_tlv;
2058*5113495bSYour Name ops->send_app_type1_params_in_fw_cmd =
2059*5113495bSYour Name send_app_type1_params_in_fw_cmd_tlv;
2060*5113495bSYour Name }
2061*5113495bSYour Name #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */
2062*5113495bSYour Name
2063*5113495bSYour Name #ifdef WLAN_FEATURE_ICMP_OFFLOAD
2064*5113495bSYour Name /**
2065*5113495bSYour Name * send_icmp_ipv4_config_cmd_tlv() - send ICMP IPV4 offload command to fw
2066*5113495bSYour Name * @wmi_handle: wmi handle
2067*5113495bSYour Name * @pmo_icmp_req: ICMP offload parameters
2068*5113495bSYour Name *
2069*5113495bSYour Name * Return: QDF status
2070*5113495bSYour Name */
2071*5113495bSYour Name static QDF_STATUS
send_icmp_ipv4_config_cmd_tlv(wmi_unified_t wmi_handle,struct pmo_icmp_offload * pmo_icmp_req)2072*5113495bSYour Name send_icmp_ipv4_config_cmd_tlv(wmi_unified_t wmi_handle,
2073*5113495bSYour Name struct pmo_icmp_offload *pmo_icmp_req)
2074*5113495bSYour Name {
2075*5113495bSYour Name wmi_buf_t buf;
2076*5113495bSYour Name wmi_icmp_offload_fixed_param *cmd;
2077*5113495bSYour Name uint16_t len = sizeof(*cmd);
2078*5113495bSYour Name QDF_STATUS status;
2079*5113495bSYour Name
2080*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
2081*5113495bSYour Name if (!buf) {
2082*5113495bSYour Name wmi_err_rl("Failed to allocate wmi buffer");
2083*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
2084*5113495bSYour Name return status;
2085*5113495bSYour Name }
2086*5113495bSYour Name cmd = (wmi_icmp_offload_fixed_param *)wmi_buf_data(buf);
2087*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
2088*5113495bSYour Name WMITLV_TAG_STRUC_wmi_icmp_offload_fixed_param,
2089*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(wmi_icmp_offload_fixed_param));
2090*5113495bSYour Name
2091*5113495bSYour Name cmd->vdev_id = pmo_icmp_req->vdev_id;
2092*5113495bSYour Name cmd->enable = pmo_icmp_req->enable;
2093*5113495bSYour Name cmd->valid_bitmask = 0;
2094*5113495bSYour Name
2095*5113495bSYour Name WMI_SET_ICMP_OFFLOAD_IPV4_ENABLED_BIT(cmd->valid_bitmask);
2096*5113495bSYour Name qdf_mem_copy(&cmd->ipv4_addr, pmo_icmp_req->ipv4_addr,
2097*5113495bSYour Name QDF_IPV4_ADDR_SIZE);
2098*5113495bSYour Name wmi_debug("ipv4:%pI4", &cmd->ipv4_addr);
2099*5113495bSYour Name
2100*5113495bSYour Name wmi_mtrace(WMI_VDEV_ICMP_OFFLOAD_CMDID, cmd->vdev_id, 0);
2101*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf, len,
2102*5113495bSYour Name WMI_VDEV_ICMP_OFFLOAD_CMDID);
2103*5113495bSYour Name
2104*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status))
2105*5113495bSYour Name wmi_buf_free(buf);
2106*5113495bSYour Name
2107*5113495bSYour Name return status;
2108*5113495bSYour Name }
2109*5113495bSYour Name
2110*5113495bSYour Name /**
2111*5113495bSYour Name * send_icmp_ipv6_config_cmd_tlv() - send ICMP IPV6 offload command to fw
2112*5113495bSYour Name * @wmi_handle: wmi handle
2113*5113495bSYour Name * @pmo_icmp_req: ICMP offload parameters
2114*5113495bSYour Name *
2115*5113495bSYour Name * Return: QDF status
2116*5113495bSYour Name */
2117*5113495bSYour Name static QDF_STATUS
send_icmp_ipv6_config_cmd_tlv(wmi_unified_t wmi_handle,struct pmo_icmp_offload * pmo_icmp_req)2118*5113495bSYour Name send_icmp_ipv6_config_cmd_tlv(wmi_unified_t wmi_handle,
2119*5113495bSYour Name struct pmo_icmp_offload *pmo_icmp_req)
2120*5113495bSYour Name {
2121*5113495bSYour Name wmi_buf_t buf;
2122*5113495bSYour Name uint8_t *buf_ptr;
2123*5113495bSYour Name uint16_t len;
2124*5113495bSYour Name int i;
2125*5113495bSYour Name WMI_IPV6_ADDR *ipv6_list;
2126*5113495bSYour Name wmi_icmp_offload_fixed_param *cmd;
2127*5113495bSYour Name QDF_STATUS status;
2128*5113495bSYour Name
2129*5113495bSYour Name len = sizeof(wmi_icmp_offload_fixed_param) + WMI_TLV_HDR_SIZE +
2130*5113495bSYour Name (pmo_icmp_req->ipv6_count) * sizeof(WMI_IPV6_ADDR);
2131*5113495bSYour Name
2132*5113495bSYour Name buf = wmi_buf_alloc(wmi_handle, len);
2133*5113495bSYour Name if (!buf) {
2134*5113495bSYour Name wmi_err_rl("Failed to allocate wmi buffer");
2135*5113495bSYour Name status = QDF_STATUS_E_NOMEM;
2136*5113495bSYour Name return status;
2137*5113495bSYour Name }
2138*5113495bSYour Name
2139*5113495bSYour Name buf_ptr = (uint8_t *)wmi_buf_data(buf);
2140*5113495bSYour Name cmd = (wmi_icmp_offload_fixed_param *)wmi_buf_data(buf);
2141*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
2142*5113495bSYour Name WMITLV_TAG_STRUC_wmi_icmp_offload_fixed_param,
2143*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(wmi_icmp_offload_fixed_param));
2144*5113495bSYour Name
2145*5113495bSYour Name cmd->vdev_id = pmo_icmp_req->vdev_id;
2146*5113495bSYour Name cmd->enable = pmo_icmp_req->enable;
2147*5113495bSYour Name cmd->valid_bitmask = 0;
2148*5113495bSYour Name
2149*5113495bSYour Name WMI_SET_ICMP_OFFLOAD_IPV6_ENABLED_BIT(cmd->valid_bitmask);
2150*5113495bSYour Name buf_ptr += sizeof(*cmd);
2151*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2152*5113495bSYour Name sizeof(WMI_IPV6_ADDR) * pmo_icmp_req->ipv6_count);
2153*5113495bSYour Name ipv6_list = (WMI_IPV6_ADDR *)(buf_ptr + WMI_TLV_HDR_SIZE);
2154*5113495bSYour Name
2155*5113495bSYour Name for (i = 0; i < pmo_icmp_req->ipv6_count; i++) {
2156*5113495bSYour Name qdf_mem_copy(((*(ipv6_list + i)).address),
2157*5113495bSYour Name &pmo_icmp_req->ipv6_addr[i],
2158*5113495bSYour Name sizeof(WMI_IPV6_ADDR));
2159*5113495bSYour Name wmi_debug("ipv6_list[%d]:%pI6", i, (ipv6_list + i));
2160*5113495bSYour Name }
2161*5113495bSYour Name
2162*5113495bSYour Name /* send the wmi command */
2163*5113495bSYour Name wmi_mtrace(WMI_VDEV_ICMP_OFFLOAD_CMDID, cmd->vdev_id, 0);
2164*5113495bSYour Name status = wmi_unified_cmd_send(wmi_handle, buf, len,
2165*5113495bSYour Name WMI_VDEV_ICMP_OFFLOAD_CMDID);
2166*5113495bSYour Name
2167*5113495bSYour Name if (QDF_IS_STATUS_ERROR(status))
2168*5113495bSYour Name wmi_buf_free(buf);
2169*5113495bSYour Name
2170*5113495bSYour Name return status;
2171*5113495bSYour Name }
2172*5113495bSYour Name
2173*5113495bSYour Name /**
2174*5113495bSYour Name * send_icmp_offload_config_cmd_tlv() - send ICMP offload command to fw
2175*5113495bSYour Name * @wmi_handle: wmi handle
2176*5113495bSYour Name * @pmo_icmp_req: ICMP offload parameters
2177*5113495bSYour Name *
2178*5113495bSYour Name * Return: QDF status
2179*5113495bSYour Name */
2180*5113495bSYour Name static QDF_STATUS
send_icmp_offload_config_cmd_tlv(wmi_unified_t wmi_handle,struct pmo_icmp_offload * pmo_icmp_req)2181*5113495bSYour Name send_icmp_offload_config_cmd_tlv(wmi_unified_t wmi_handle,
2182*5113495bSYour Name struct pmo_icmp_offload *pmo_icmp_req)
2183*5113495bSYour Name {
2184*5113495bSYour Name QDF_STATUS status;
2185*5113495bSYour Name
2186*5113495bSYour Name switch (pmo_icmp_req->trigger) {
2187*5113495bSYour Name case pmo_ipv4_change_notify:
2188*5113495bSYour Name status = send_icmp_ipv4_config_cmd_tlv(wmi_handle,
2189*5113495bSYour Name pmo_icmp_req);
2190*5113495bSYour Name break;
2191*5113495bSYour Name case pmo_ipv6_change_notify:
2192*5113495bSYour Name status = send_icmp_ipv6_config_cmd_tlv(wmi_handle,
2193*5113495bSYour Name pmo_icmp_req);
2194*5113495bSYour Name break;
2195*5113495bSYour Name default:
2196*5113495bSYour Name QDF_DEBUG_PANIC("Invalid ICMP trigger %d",
2197*5113495bSYour Name pmo_icmp_req->trigger);
2198*5113495bSYour Name status = QDF_STATUS_E_FAILURE;
2199*5113495bSYour Name }
2200*5113495bSYour Name
2201*5113495bSYour Name return status;
2202*5113495bSYour Name }
2203*5113495bSYour Name
wmi_icmp_offload_config_tlv(struct wmi_unified * wmi_handle)2204*5113495bSYour Name static void wmi_icmp_offload_config_tlv(struct wmi_unified *wmi_handle)
2205*5113495bSYour Name {
2206*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
2207*5113495bSYour Name
2208*5113495bSYour Name ops->send_icmp_offload_config_cmd = send_icmp_offload_config_cmd_tlv;
2209*5113495bSYour Name }
2210*5113495bSYour Name #else
wmi_icmp_offload_config_tlv(struct wmi_unified * wmi_handle)2211*5113495bSYour Name static inline void wmi_icmp_offload_config_tlv(struct wmi_unified *wmi_handle)
2212*5113495bSYour Name {}
2213*5113495bSYour Name #endif /* WLAN_FEATURE_ICMP_OFFLOAD */
2214*5113495bSYour Name
wmi_pmo_attach_tlv(wmi_unified_t wmi_handle)2215*5113495bSYour Name void wmi_pmo_attach_tlv(wmi_unified_t wmi_handle)
2216*5113495bSYour Name {
2217*5113495bSYour Name struct wmi_ops *ops = wmi_handle->ops;
2218*5113495bSYour Name
2219*5113495bSYour Name ops->send_add_wow_wakeup_event_cmd =
2220*5113495bSYour Name send_add_wow_wakeup_event_cmd_tlv;
2221*5113495bSYour Name ops->send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv;
2222*5113495bSYour Name ops->send_enable_arp_ns_offload_cmd =
2223*5113495bSYour Name send_enable_arp_ns_offload_cmd_tlv;
2224*5113495bSYour Name ops->send_add_clear_mcbc_filter_cmd =
2225*5113495bSYour Name send_add_clear_mcbc_filter_cmd_tlv;
2226*5113495bSYour Name ops->send_multiple_add_clear_mcbc_filter_cmd =
2227*5113495bSYour Name send_multiple_add_clear_mcbc_filter_cmd_tlv;
2228*5113495bSYour Name ops->send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv;
2229*5113495bSYour Name ops->send_gtk_offload_cmd = send_gtk_offload_cmd_tlv;
2230*5113495bSYour Name #ifdef WLAN_FEATURE_IGMP_OFFLOAD
2231*5113495bSYour Name ops->send_igmp_offload_cmd = send_igmp_offload_cmd_tlv;
2232*5113495bSYour Name #endif
2233*5113495bSYour Name ops->send_process_gtk_offload_getinfo_cmd =
2234*5113495bSYour Name send_process_gtk_offload_getinfo_cmd_tlv;
2235*5113495bSYour Name ops->send_enable_enhance_multicast_offload_cmd =
2236*5113495bSYour Name send_enable_enhance_multicast_offload_tlv;
2237*5113495bSYour Name ops->extract_gtk_rsp_event = extract_gtk_rsp_event_tlv;
2238*5113495bSYour Name ops->send_action_frame_patterns_cmd =
2239*5113495bSYour Name send_action_frame_patterns_cmd_tlv;
2240*5113495bSYour Name ops->send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv;
2241*5113495bSYour Name ops->send_host_wakeup_ind_to_fw_cmd =
2242*5113495bSYour Name send_host_wakeup_ind_to_fw_cmd_tlv;
2243*5113495bSYour Name ops->send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv;
2244*5113495bSYour Name
2245*5113495bSYour Name wmi_d0wow_attach_tlv(wmi_handle);
2246*5113495bSYour Name wmi_ra_filtering_attach_tlv(wmi_handle);
2247*5113495bSYour Name wmi_lphb_attach_tlv(wmi_handle);
2248*5113495bSYour Name wmi_packet_filtering_attach_tlv(wmi_handle);
2249*5113495bSYour Name wmi_extwow_attach_tlv(wmi_handle);
2250*5113495bSYour Name wmi_icmp_offload_config_tlv(wmi_handle);
2251*5113495bSYour Name }
2252