1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2016-2018, 2020 The Linux Foundation. All rights reserved.
3*5113495bSYour Name * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name *
5*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name * above copyright notice and this permission notice appear in all
8*5113495bSYour Name * copies.
9*5113495bSYour Name *
10*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name */
19*5113495bSYour Name
20*5113495bSYour Name #include "wmi_unified_action_oui_tlv.h"
21*5113495bSYour Name #include "wmi_unified_priv.h"
22*5113495bSYour Name
wmi_get_action_oui_id(enum action_oui_id action_id,wmi_vendor_oui_action_id * id)23*5113495bSYour Name bool wmi_get_action_oui_id(enum action_oui_id action_id,
24*5113495bSYour Name wmi_vendor_oui_action_id *id)
25*5113495bSYour Name {
26*5113495bSYour Name switch (action_id) {
27*5113495bSYour Name
28*5113495bSYour Name case ACTION_OUI_CONNECT_1X1:
29*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_CONNECTION_1X1;
30*5113495bSYour Name return true;
31*5113495bSYour Name
32*5113495bSYour Name case ACTION_OUI_ITO_EXTENSION:
33*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_ITO_EXTENSION;
34*5113495bSYour Name return true;
35*5113495bSYour Name
36*5113495bSYour Name case ACTION_OUI_CCKM_1X1:
37*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_CCKM_1X1;
38*5113495bSYour Name return true;
39*5113495bSYour Name
40*5113495bSYour Name case ACTION_OUI_ITO_ALTERNATE:
41*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_ALT_ITO;
42*5113495bSYour Name return true;
43*5113495bSYour Name
44*5113495bSYour Name case ACTION_OUI_SWITCH_TO_11N_MODE:
45*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_SWITCH_TO_11N_MODE;
46*5113495bSYour Name return true;
47*5113495bSYour Name
48*5113495bSYour Name case ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN:
49*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_CONNECTION_1X1_NUM_TX_RX_CHAINS_1;
50*5113495bSYour Name return true;
51*5113495bSYour Name
52*5113495bSYour Name case ACTION_OUI_DISABLE_AGGRESSIVE_TX:
53*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_DISABLE_AGGRESSIVE_TX;
54*5113495bSYour Name return true;
55*5113495bSYour Name
56*5113495bSYour Name case ACTION_OUI_DISABLE_TWT:
57*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_DISABLE_FW_TRIGGERED_TWT;
58*5113495bSYour Name return true;
59*5113495bSYour Name
60*5113495bSYour Name case ACTION_OUI_EXTEND_WOW_ITO:
61*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_EXTEND_WOW_ITO;
62*5113495bSYour Name return true;
63*5113495bSYour Name case ACTION_OUI_11BE_OUI_ALLOW:
64*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_ALLOW_11BE;
65*5113495bSYour Name return true;
66*5113495bSYour Name case ACTION_OUI_DISABLE_DYNAMIC_QOS_NULL_TX_RATE:
67*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_DISABLE_DYNAMIC_QOS_NULL_TX_RATE;
68*5113495bSYour Name return true;
69*5113495bSYour Name case ACTION_OUI_ENABLE_CTS2SELF_WITH_QOS_NULL:
70*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_ENABLE_CTS2SELF_WITH_QOS_NULL;
71*5113495bSYour Name return true;
72*5113495bSYour Name case ACTION_OUI_SEND_SMPS_FRAME_WITH_OMN:
73*5113495bSYour Name *id = WMI_VENDOR_OUI_ACTION_SEND_SMPS_FRAME_WITH_OMN;
74*5113495bSYour Name return true;
75*5113495bSYour Name default:
76*5113495bSYour Name return false;
77*5113495bSYour Name }
78*5113495bSYour Name }
79*5113495bSYour Name
wmi_get_action_oui_info_mask(uint32_t info_mask)80*5113495bSYour Name uint32_t wmi_get_action_oui_info_mask(uint32_t info_mask)
81*5113495bSYour Name {
82*5113495bSYour Name uint32_t info_presence = 0;
83*5113495bSYour Name
84*5113495bSYour Name if (info_mask & ACTION_OUI_INFO_OUI)
85*5113495bSYour Name info_presence |= WMI_BEACON_INFO_PRESENCE_OUI_EXT;
86*5113495bSYour Name
87*5113495bSYour Name if (info_mask & ACTION_OUI_INFO_MAC_ADDRESS)
88*5113495bSYour Name info_presence |= WMI_BEACON_INFO_PRESENCE_MAC_ADDRESS;
89*5113495bSYour Name
90*5113495bSYour Name if (info_mask & ACTION_OUI_INFO_AP_CAPABILITY_NSS)
91*5113495bSYour Name info_presence |= WMI_BEACON_INFO_PRESENCE_AP_CAPABILITY_NSS;
92*5113495bSYour Name
93*5113495bSYour Name if (info_mask & ACTION_OUI_INFO_AP_CAPABILITY_HT)
94*5113495bSYour Name info_presence |= WMI_BEACON_INFO_PRESENCE_AP_CAPABILITY_HT;
95*5113495bSYour Name
96*5113495bSYour Name if (info_mask & ACTION_OUI_INFO_AP_CAPABILITY_VHT)
97*5113495bSYour Name info_presence |= WMI_BEACON_INFO_PRESENCE_AP_CAPABILITY_VHT;
98*5113495bSYour Name
99*5113495bSYour Name if (info_mask & ACTION_OUI_INFO_AP_CAPABILITY_BAND)
100*5113495bSYour Name info_presence |= WMI_BEACON_INFO_PRESENCE_AP_CAPABILITY_BAND;
101*5113495bSYour Name
102*5113495bSYour Name return info_presence;
103*5113495bSYour Name }
104*5113495bSYour Name
wmi_fill_oui_extensions(struct action_oui_extension * extension,uint32_t no_oui_extns,wmi_vendor_oui_ext * cmd_ext)105*5113495bSYour Name void wmi_fill_oui_extensions(struct action_oui_extension *extension,
106*5113495bSYour Name uint32_t no_oui_extns,
107*5113495bSYour Name wmi_vendor_oui_ext *cmd_ext)
108*5113495bSYour Name {
109*5113495bSYour Name uint32_t i;
110*5113495bSYour Name uint32_t buffer_length;
111*5113495bSYour Name
112*5113495bSYour Name for (i = 0; i < no_oui_extns; i++) {
113*5113495bSYour Name WMITLV_SET_HDR(&cmd_ext->tlv_header,
114*5113495bSYour Name WMITLV_TAG_STRUC_wmi_vendor_oui_ext,
115*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui_ext));
116*5113495bSYour Name cmd_ext->info_presence_bit_mask =
117*5113495bSYour Name wmi_get_action_oui_info_mask(extension->info_mask);
118*5113495bSYour Name
119*5113495bSYour Name cmd_ext->oui_header_length = extension->oui_length;
120*5113495bSYour Name cmd_ext->oui_data_length = extension->data_length;
121*5113495bSYour Name cmd_ext->mac_address_length = extension->mac_addr_length;
122*5113495bSYour Name cmd_ext->capability_data_length =
123*5113495bSYour Name extension->capability_length;
124*5113495bSYour Name
125*5113495bSYour Name buffer_length = extension->oui_length +
126*5113495bSYour Name extension->data_length +
127*5113495bSYour Name extension->data_mask_length +
128*5113495bSYour Name extension->mac_addr_length +
129*5113495bSYour Name extension->mac_mask_length +
130*5113495bSYour Name extension->capability_length;
131*5113495bSYour Name
132*5113495bSYour Name cmd_ext->buf_data_length = buffer_length + 1;
133*5113495bSYour Name
134*5113495bSYour Name cmd_ext++;
135*5113495bSYour Name extension++;
136*5113495bSYour Name }
137*5113495bSYour Name
138*5113495bSYour Name }
139*5113495bSYour Name
140*5113495bSYour Name QDF_STATUS
wmi_fill_oui_extensions_buffer(struct action_oui_extension * extension,wmi_vendor_oui_ext * cmd_ext,uint32_t no_oui_extns,uint32_t rem_var_buf_len,uint8_t * var_buf)141*5113495bSYour Name wmi_fill_oui_extensions_buffer(struct action_oui_extension *extension,
142*5113495bSYour Name wmi_vendor_oui_ext *cmd_ext,
143*5113495bSYour Name uint32_t no_oui_extns, uint32_t rem_var_buf_len,
144*5113495bSYour Name uint8_t *var_buf)
145*5113495bSYour Name {
146*5113495bSYour Name uint8_t i;
147*5113495bSYour Name
148*5113495bSYour Name for (i = 0; i < (uint8_t)no_oui_extns; i++) {
149*5113495bSYour Name if ((rem_var_buf_len - cmd_ext->buf_data_length) < 0) {
150*5113495bSYour Name wmi_err("Invalid action oui command length");
151*5113495bSYour Name return QDF_STATUS_E_INVAL;
152*5113495bSYour Name }
153*5113495bSYour Name
154*5113495bSYour Name var_buf[0] = i;
155*5113495bSYour Name var_buf++;
156*5113495bSYour Name
157*5113495bSYour Name if (extension->oui_length) {
158*5113495bSYour Name qdf_mem_copy(var_buf, extension->oui,
159*5113495bSYour Name extension->oui_length);
160*5113495bSYour Name var_buf += extension->oui_length;
161*5113495bSYour Name }
162*5113495bSYour Name
163*5113495bSYour Name if (extension->data_length) {
164*5113495bSYour Name qdf_mem_copy(var_buf, extension->data,
165*5113495bSYour Name extension->data_length);
166*5113495bSYour Name var_buf += extension->data_length;
167*5113495bSYour Name }
168*5113495bSYour Name
169*5113495bSYour Name if (extension->data_mask_length) {
170*5113495bSYour Name qdf_mem_copy(var_buf, extension->data_mask,
171*5113495bSYour Name extension->data_mask_length);
172*5113495bSYour Name var_buf += extension->data_mask_length;
173*5113495bSYour Name }
174*5113495bSYour Name
175*5113495bSYour Name if (extension->mac_addr_length) {
176*5113495bSYour Name qdf_mem_copy(var_buf, extension->mac_addr,
177*5113495bSYour Name extension->mac_addr_length);
178*5113495bSYour Name var_buf += extension->mac_addr_length;
179*5113495bSYour Name }
180*5113495bSYour Name
181*5113495bSYour Name if (extension->mac_mask_length) {
182*5113495bSYour Name qdf_mem_copy(var_buf, extension->mac_mask,
183*5113495bSYour Name extension->mac_mask_length);
184*5113495bSYour Name var_buf += extension->mac_mask_length;
185*5113495bSYour Name }
186*5113495bSYour Name
187*5113495bSYour Name if (extension->capability_length) {
188*5113495bSYour Name qdf_mem_copy(var_buf, extension->capability,
189*5113495bSYour Name extension->capability_length);
190*5113495bSYour Name var_buf += extension->capability_length;
191*5113495bSYour Name }
192*5113495bSYour Name
193*5113495bSYour Name rem_var_buf_len -= cmd_ext->buf_data_length;
194*5113495bSYour Name cmd_ext++;
195*5113495bSYour Name extension++;
196*5113495bSYour Name }
197*5113495bSYour Name
198*5113495bSYour Name return QDF_STATUS_SUCCESS;
199*5113495bSYour Name }
200*5113495bSYour Name
201*5113495bSYour Name QDF_STATUS
send_action_oui_cmd_tlv(wmi_unified_t wmi_handle,struct action_oui_request * req)202*5113495bSYour Name send_action_oui_cmd_tlv(wmi_unified_t wmi_handle,
203*5113495bSYour Name struct action_oui_request *req)
204*5113495bSYour Name {
205*5113495bSYour Name wmi_pdev_config_vendor_oui_action_fixed_param *cmd;
206*5113495bSYour Name wmi_vendor_oui_ext *cmd_ext;
207*5113495bSYour Name wmi_buf_t wmi_buf;
208*5113495bSYour Name struct action_oui_extension *extension;
209*5113495bSYour Name uint32_t len;
210*5113495bSYour Name uint32_t i;
211*5113495bSYour Name uint8_t *buf_ptr;
212*5113495bSYour Name uint32_t no_oui_extns;
213*5113495bSYour Name uint32_t total_no_oui_extns;
214*5113495bSYour Name uint32_t var_buf_len = 0;
215*5113495bSYour Name wmi_vendor_oui_action_id action_id;
216*5113495bSYour Name bool valid;
217*5113495bSYour Name uint32_t rem_var_buf_len;
218*5113495bSYour Name QDF_STATUS status;
219*5113495bSYour Name
220*5113495bSYour Name if (!req) {
221*5113495bSYour Name wmi_err("action oui is empty");
222*5113495bSYour Name return QDF_STATUS_E_INVAL;
223*5113495bSYour Name }
224*5113495bSYour Name
225*5113495bSYour Name no_oui_extns = req->no_oui_extensions;
226*5113495bSYour Name total_no_oui_extns = req->total_no_oui_extensions;
227*5113495bSYour Name
228*5113495bSYour Name len = sizeof(*cmd);
229*5113495bSYour Name len += WMI_TLV_HDR_SIZE; /* Array of wmi_vendor_oui_ext structures */
230*5113495bSYour Name
231*5113495bSYour Name if (no_oui_extns > WMI_MAX_VENDOR_OUI_ACTION_SUPPORTED_PER_ACTION ||
232*5113495bSYour Name (total_no_oui_extns > WMI_VENDOR_OUI_ACTION_MAX_ACTION_ID *
233*5113495bSYour Name WMI_MAX_VENDOR_OUI_ACTION_SUPPORTED_PER_ACTION)) {
234*5113495bSYour Name wmi_err("Invalid number of action oui extensions");
235*5113495bSYour Name return QDF_STATUS_E_INVAL;
236*5113495bSYour Name }
237*5113495bSYour Name
238*5113495bSYour Name valid = wmi_get_action_oui_id(req->action_id, &action_id);
239*5113495bSYour Name if (!valid) {
240*5113495bSYour Name wmi_err("Invalid action id");
241*5113495bSYour Name return QDF_STATUS_E_INVAL;
242*5113495bSYour Name }
243*5113495bSYour Name wmi_debug("wmi action_id %d num %d total_num %d", action_id,
244*5113495bSYour Name no_oui_extns, total_no_oui_extns);
245*5113495bSYour Name
246*5113495bSYour Name len += no_oui_extns * sizeof(*cmd_ext);
247*5113495bSYour Name len += WMI_TLV_HDR_SIZE; /* Variable length buffer */
248*5113495bSYour Name
249*5113495bSYour Name extension = req->extension;
250*5113495bSYour Name for (i = 0; i < no_oui_extns; i++) {
251*5113495bSYour Name var_buf_len += extension->oui_length +
252*5113495bSYour Name extension->data_length +
253*5113495bSYour Name extension->data_mask_length +
254*5113495bSYour Name extension->mac_addr_length +
255*5113495bSYour Name extension->mac_mask_length +
256*5113495bSYour Name extension->capability_length;
257*5113495bSYour Name extension++;
258*5113495bSYour Name }
259*5113495bSYour Name
260*5113495bSYour Name var_buf_len += no_oui_extns; /* to store indexes */
261*5113495bSYour Name rem_var_buf_len = var_buf_len;
262*5113495bSYour Name var_buf_len = (var_buf_len + 3) & ~0x3;
263*5113495bSYour Name len += var_buf_len;
264*5113495bSYour Name
265*5113495bSYour Name wmi_buf = wmi_buf_alloc(wmi_handle, len);
266*5113495bSYour Name if (!wmi_buf) {
267*5113495bSYour Name wmi_err("Failed to allocate wmi buffer");
268*5113495bSYour Name return QDF_STATUS_E_FAILURE;
269*5113495bSYour Name }
270*5113495bSYour Name
271*5113495bSYour Name buf_ptr = (uint8_t *)wmi_buf_data(wmi_buf);
272*5113495bSYour Name cmd = (wmi_pdev_config_vendor_oui_action_fixed_param *)buf_ptr;
273*5113495bSYour Name
274*5113495bSYour Name WMITLV_SET_HDR(&cmd->tlv_header,
275*5113495bSYour Name WMITLV_TAG_STRUC_wmi_pdev_config_vendor_oui_action_fixed_param,
276*5113495bSYour Name WMITLV_GET_STRUCT_TLVLEN(
277*5113495bSYour Name wmi_pdev_config_vendor_oui_action_fixed_param));
278*5113495bSYour Name
279*5113495bSYour Name cmd->action_id = action_id;
280*5113495bSYour Name cmd->total_num_vendor_oui = total_no_oui_extns;
281*5113495bSYour Name cmd->num_vendor_oui_ext = no_oui_extns;
282*5113495bSYour Name
283*5113495bSYour Name buf_ptr += sizeof(*cmd);
284*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
285*5113495bSYour Name no_oui_extns * sizeof(*cmd_ext));
286*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
287*5113495bSYour Name cmd_ext = (wmi_vendor_oui_ext *)buf_ptr;
288*5113495bSYour Name wmi_fill_oui_extensions(req->extension, no_oui_extns, cmd_ext);
289*5113495bSYour Name
290*5113495bSYour Name buf_ptr += no_oui_extns * sizeof(*cmd_ext);
291*5113495bSYour Name WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, var_buf_len);
292*5113495bSYour Name buf_ptr += WMI_TLV_HDR_SIZE;
293*5113495bSYour Name status = wmi_fill_oui_extensions_buffer(req->extension,
294*5113495bSYour Name cmd_ext, no_oui_extns,
295*5113495bSYour Name rem_var_buf_len, buf_ptr);
296*5113495bSYour Name if (!QDF_IS_STATUS_SUCCESS(status)) {
297*5113495bSYour Name wmi_buf_free(wmi_buf);
298*5113495bSYour Name wmi_buf = NULL;
299*5113495bSYour Name wmi_err("failed to fill oui ext status %d", status);
300*5113495bSYour Name return QDF_STATUS_E_INVAL;
301*5113495bSYour Name }
302*5113495bSYour Name
303*5113495bSYour Name buf_ptr += var_buf_len;
304*5113495bSYour Name
305*5113495bSYour Name if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
306*5113495bSYour Name WMI_PDEV_CONFIG_VENDOR_OUI_ACTION_CMDID)) {
307*5113495bSYour Name wmi_err("WMI_PDEV_CONFIG_VENDOR_OUI_ACTION send fail");
308*5113495bSYour Name wmi_buf_free(wmi_buf);
309*5113495bSYour Name wmi_buf = NULL;
310*5113495bSYour Name return QDF_STATUS_E_FAILURE;
311*5113495bSYour Name }
312*5113495bSYour Name
313*5113495bSYour Name return QDF_STATUS_SUCCESS;
314*5113495bSYour Name }
315