1 /*
2 * NXP Wireless LAN device driver: TDLS handling
3 *
4 * Copyright 2011-2020 NXP
5 *
6 * This software file (the "File") is distributed by NXP
7 * under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available on the worldwide web at
11 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12 *
13 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
14 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
15 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
16 * this warranty disclaimer.
17 */
18
19 #include "main.h"
20 #include "wmm.h"
21 #include "11n.h"
22 #include "11n_rxreorder.h"
23 #include "11ac.h"
24
25 #define TDLS_REQ_FIX_LEN 6
26 #define TDLS_RESP_FIX_LEN 8
27 #define TDLS_CONFIRM_FIX_LEN 6
28 #define MWIFIEX_TDLS_WMM_INFO_SIZE 7
29
mwifiex_restore_tdls_packets(struct mwifiex_private * priv,const u8 * mac,u8 status)30 static void mwifiex_restore_tdls_packets(struct mwifiex_private *priv,
31 const u8 *mac, u8 status)
32 {
33 struct mwifiex_ra_list_tbl *ra_list;
34 struct list_head *tid_list;
35 struct sk_buff *skb, *tmp;
36 struct mwifiex_txinfo *tx_info;
37 u32 tid;
38 u8 tid_down;
39
40 mwifiex_dbg(priv->adapter, DATA, "%s: %pM\n", __func__, mac);
41 spin_lock_bh(&priv->wmm.ra_list_spinlock);
42
43 skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) {
44 if (!ether_addr_equal(mac, skb->data))
45 continue;
46
47 __skb_unlink(skb, &priv->tdls_txq);
48 tx_info = MWIFIEX_SKB_TXCB(skb);
49 tid = skb->priority;
50 tid_down = mwifiex_wmm_downgrade_tid(priv, tid);
51
52 if (mwifiex_is_tdls_link_setup(status)) {
53 ra_list = mwifiex_wmm_get_queue_raptr(priv, tid, mac);
54 ra_list->tdls_link = true;
55 tx_info->flags |= MWIFIEX_BUF_FLAG_TDLS_PKT;
56 } else {
57 tid_list = &priv->wmm.tid_tbl_ptr[tid_down].ra_list;
58 ra_list = list_first_entry_or_null(tid_list,
59 struct mwifiex_ra_list_tbl, list);
60 tx_info->flags &= ~MWIFIEX_BUF_FLAG_TDLS_PKT;
61 }
62
63 if (!ra_list) {
64 mwifiex_write_data_complete(priv->adapter, skb, 0, -1);
65 continue;
66 }
67
68 skb_queue_tail(&ra_list->skb_head, skb);
69
70 ra_list->ba_pkt_count++;
71 ra_list->total_pkt_count++;
72
73 if (atomic_read(&priv->wmm.highest_queued_prio) <
74 tos_to_tid_inv[tid_down])
75 atomic_set(&priv->wmm.highest_queued_prio,
76 tos_to_tid_inv[tid_down]);
77
78 atomic_inc(&priv->wmm.tx_pkts_queued);
79 }
80
81 spin_unlock_bh(&priv->wmm.ra_list_spinlock);
82 return;
83 }
84
mwifiex_hold_tdls_packets(struct mwifiex_private * priv,const u8 * mac)85 static void mwifiex_hold_tdls_packets(struct mwifiex_private *priv,
86 const u8 *mac)
87 {
88 struct mwifiex_ra_list_tbl *ra_list;
89 struct list_head *ra_list_head;
90 struct sk_buff *skb, *tmp;
91 int i;
92
93 mwifiex_dbg(priv->adapter, DATA, "%s: %pM\n", __func__, mac);
94 spin_lock_bh(&priv->wmm.ra_list_spinlock);
95
96 for (i = 0; i < MAX_NUM_TID; i++) {
97 if (!list_empty(&priv->wmm.tid_tbl_ptr[i].ra_list)) {
98 ra_list_head = &priv->wmm.tid_tbl_ptr[i].ra_list;
99 list_for_each_entry(ra_list, ra_list_head, list) {
100 skb_queue_walk_safe(&ra_list->skb_head, skb,
101 tmp) {
102 if (!ether_addr_equal(mac, skb->data))
103 continue;
104 __skb_unlink(skb, &ra_list->skb_head);
105 atomic_dec(&priv->wmm.tx_pkts_queued);
106 ra_list->total_pkt_count--;
107 skb_queue_tail(&priv->tdls_txq, skb);
108 }
109 }
110 }
111 }
112
113 spin_unlock_bh(&priv->wmm.ra_list_spinlock);
114 return;
115 }
116
117 /* This function appends rate TLV to scan config command. */
118 static int
mwifiex_tdls_append_rates_ie(struct mwifiex_private * priv,struct sk_buff * skb)119 mwifiex_tdls_append_rates_ie(struct mwifiex_private *priv,
120 struct sk_buff *skb)
121 {
122 u8 rates[MWIFIEX_SUPPORTED_RATES], *pos;
123 u16 rates_size, supp_rates_size, ext_rates_size;
124
125 memset(rates, 0, sizeof(rates));
126 rates_size = mwifiex_get_supported_rates(priv, rates);
127
128 supp_rates_size = min_t(u16, rates_size, MWIFIEX_TDLS_SUPPORTED_RATES);
129
130 if (skb_tailroom(skb) < rates_size + 4) {
131 mwifiex_dbg(priv->adapter, ERROR,
132 "Insufficient space while adding rates\n");
133 return -ENOMEM;
134 }
135
136 pos = skb_put(skb, supp_rates_size + 2);
137 *pos++ = WLAN_EID_SUPP_RATES;
138 *pos++ = supp_rates_size;
139 memcpy(pos, rates, supp_rates_size);
140
141 if (rates_size > MWIFIEX_TDLS_SUPPORTED_RATES) {
142 ext_rates_size = rates_size - MWIFIEX_TDLS_SUPPORTED_RATES;
143 pos = skb_put(skb, ext_rates_size + 2);
144 *pos++ = WLAN_EID_EXT_SUPP_RATES;
145 *pos++ = ext_rates_size;
146 memcpy(pos, rates + MWIFIEX_TDLS_SUPPORTED_RATES,
147 ext_rates_size);
148 }
149
150 return 0;
151 }
152
mwifiex_tdls_add_aid(struct mwifiex_private * priv,struct sk_buff * skb)153 static void mwifiex_tdls_add_aid(struct mwifiex_private *priv,
154 struct sk_buff *skb)
155 {
156 struct ieee_types_assoc_rsp *assoc_rsp;
157 u8 *pos;
158
159 assoc_rsp = (struct ieee_types_assoc_rsp *)&priv->assoc_rsp_buf;
160 pos = skb_put(skb, 4);
161 *pos++ = WLAN_EID_AID;
162 *pos++ = 2;
163 memcpy(pos, &assoc_rsp->a_id, sizeof(assoc_rsp->a_id));
164
165 return;
166 }
167
mwifiex_tdls_add_vht_capab(struct mwifiex_private * priv,struct sk_buff * skb)168 static int mwifiex_tdls_add_vht_capab(struct mwifiex_private *priv,
169 struct sk_buff *skb)
170 {
171 struct ieee80211_vht_cap vht_cap;
172 u8 *pos;
173
174 pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
175 *pos++ = WLAN_EID_VHT_CAPABILITY;
176 *pos++ = sizeof(struct ieee80211_vht_cap);
177
178 memset(&vht_cap, 0, sizeof(struct ieee80211_vht_cap));
179
180 mwifiex_fill_vht_cap_tlv(priv, &vht_cap, priv->curr_bss_params.band);
181 memcpy(pos, &vht_cap, sizeof(vht_cap));
182
183 return 0;
184 }
185
186 static int
mwifiex_tdls_add_ht_oper(struct mwifiex_private * priv,const u8 * mac,u8 vht_enabled,struct sk_buff * skb)187 mwifiex_tdls_add_ht_oper(struct mwifiex_private *priv, const u8 *mac,
188 u8 vht_enabled, struct sk_buff *skb)
189 {
190 struct ieee80211_ht_operation *ht_oper;
191 struct mwifiex_sta_node *sta_ptr;
192 struct mwifiex_bssdescriptor *bss_desc =
193 &priv->curr_bss_params.bss_descriptor;
194 u8 *pos;
195
196 sta_ptr = mwifiex_get_sta_entry(priv, mac);
197 if (unlikely(!sta_ptr)) {
198 mwifiex_dbg(priv->adapter, ERROR,
199 "TDLS peer station not found in list\n");
200 return -1;
201 }
202
203 if (!(le16_to_cpu(sta_ptr->tdls_cap.ht_capb.cap_info))) {
204 mwifiex_dbg(priv->adapter, WARN,
205 "TDLS peer doesn't support ht capabilities\n");
206 return 0;
207 }
208
209 pos = skb_put(skb, sizeof(struct ieee80211_ht_operation) + 2);
210 *pos++ = WLAN_EID_HT_OPERATION;
211 *pos++ = sizeof(struct ieee80211_ht_operation);
212 ht_oper = (void *)pos;
213
214 ht_oper->primary_chan = bss_desc->channel;
215
216 /* follow AP's channel bandwidth */
217 if (ISSUPP_CHANWIDTH40(priv->adapter->hw_dot_11n_dev_cap) &&
218 bss_desc->bcn_ht_oper &&
219 ISALLOWED_CHANWIDTH40(bss_desc->bcn_ht_oper->ht_param))
220 ht_oper->ht_param = bss_desc->bcn_ht_oper->ht_param;
221
222 if (vht_enabled) {
223 ht_oper->ht_param =
224 mwifiex_get_sec_chan_offset(bss_desc->channel);
225 ht_oper->ht_param |= BIT(2);
226 }
227
228 memcpy(&sta_ptr->tdls_cap.ht_oper, ht_oper,
229 sizeof(struct ieee80211_ht_operation));
230
231 return 0;
232 }
233
mwifiex_tdls_add_vht_oper(struct mwifiex_private * priv,const u8 * mac,struct sk_buff * skb)234 static int mwifiex_tdls_add_vht_oper(struct mwifiex_private *priv,
235 const u8 *mac, struct sk_buff *skb)
236 {
237 struct mwifiex_bssdescriptor *bss_desc;
238 struct ieee80211_vht_operation *vht_oper;
239 struct ieee80211_vht_cap *vht_cap, *ap_vht_cap = NULL;
240 struct mwifiex_sta_node *sta_ptr;
241 struct mwifiex_adapter *adapter = priv->adapter;
242 u8 supp_chwd_set, peer_supp_chwd_set;
243 u8 *pos, ap_supp_chwd_set, chan_bw;
244 u16 mcs_map_user, mcs_map_resp, mcs_map_result;
245 u16 mcs_user, mcs_resp, nss;
246 u32 usr_vht_cap_info;
247
248 bss_desc = &priv->curr_bss_params.bss_descriptor;
249
250 sta_ptr = mwifiex_get_sta_entry(priv, mac);
251 if (unlikely(!sta_ptr)) {
252 mwifiex_dbg(adapter, ERROR,
253 "TDLS peer station not found in list\n");
254 return -1;
255 }
256
257 if (!(le32_to_cpu(sta_ptr->tdls_cap.vhtcap.vht_cap_info))) {
258 mwifiex_dbg(adapter, WARN,
259 "TDLS peer doesn't support vht capabilities\n");
260 return 0;
261 }
262
263 if (!mwifiex_is_bss_in_11ac_mode(priv)) {
264 if (sta_ptr->tdls_cap.extcap.ext_capab[7] &
265 WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED) {
266 mwifiex_dbg(adapter, WARN,
267 "TDLS peer doesn't support wider bandwidth\n");
268 return 0;
269 }
270 } else {
271 ap_vht_cap = bss_desc->bcn_vht_cap;
272 }
273
274 pos = skb_put(skb, sizeof(struct ieee80211_vht_operation) + 2);
275 *pos++ = WLAN_EID_VHT_OPERATION;
276 *pos++ = sizeof(struct ieee80211_vht_operation);
277 vht_oper = (struct ieee80211_vht_operation *)pos;
278
279 if (bss_desc->bss_band & BAND_A)
280 usr_vht_cap_info = adapter->usr_dot_11ac_dev_cap_a;
281 else
282 usr_vht_cap_info = adapter->usr_dot_11ac_dev_cap_bg;
283
284 /* find the minimum bandwidth between AP/TDLS peers */
285 vht_cap = &sta_ptr->tdls_cap.vhtcap;
286 supp_chwd_set = GET_VHTCAP_CHWDSET(usr_vht_cap_info);
287 peer_supp_chwd_set =
288 GET_VHTCAP_CHWDSET(le32_to_cpu(vht_cap->vht_cap_info));
289 supp_chwd_set = min_t(u8, supp_chwd_set, peer_supp_chwd_set);
290
291 /* We need check AP's bandwidth when TDLS_WIDER_BANDWIDTH is off */
292
293 if (ap_vht_cap && sta_ptr->tdls_cap.extcap.ext_capab[7] &
294 WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED) {
295 ap_supp_chwd_set =
296 GET_VHTCAP_CHWDSET(le32_to_cpu(ap_vht_cap->vht_cap_info));
297 supp_chwd_set = min_t(u8, supp_chwd_set, ap_supp_chwd_set);
298 }
299
300 switch (supp_chwd_set) {
301 case IEEE80211_VHT_CHANWIDTH_80MHZ:
302 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
303 break;
304 case IEEE80211_VHT_CHANWIDTH_160MHZ:
305 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_160MHZ;
306 break;
307 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
308 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80P80MHZ;
309 break;
310 default:
311 vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT;
312 break;
313 }
314
315 mcs_map_user = GET_DEVRXMCSMAP(adapter->usr_dot_11ac_mcs_support);
316 mcs_map_resp = le16_to_cpu(vht_cap->supp_mcs.rx_mcs_map);
317 mcs_map_result = 0;
318
319 for (nss = 1; nss <= 8; nss++) {
320 mcs_user = GET_VHTNSSMCS(mcs_map_user, nss);
321 mcs_resp = GET_VHTNSSMCS(mcs_map_resp, nss);
322
323 if ((mcs_user == IEEE80211_VHT_MCS_NOT_SUPPORTED) ||
324 (mcs_resp == IEEE80211_VHT_MCS_NOT_SUPPORTED))
325 SET_VHTNSSMCS(mcs_map_result, nss,
326 IEEE80211_VHT_MCS_NOT_SUPPORTED);
327 else
328 SET_VHTNSSMCS(mcs_map_result, nss,
329 min_t(u16, mcs_user, mcs_resp));
330 }
331
332 vht_oper->basic_mcs_set = cpu_to_le16(mcs_map_result);
333
334 switch (vht_oper->chan_width) {
335 case IEEE80211_VHT_CHANWIDTH_80MHZ:
336 chan_bw = IEEE80211_VHT_CHANWIDTH_80MHZ;
337 break;
338 case IEEE80211_VHT_CHANWIDTH_160MHZ:
339 chan_bw = IEEE80211_VHT_CHANWIDTH_160MHZ;
340 break;
341 case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
342 chan_bw = IEEE80211_VHT_CHANWIDTH_80MHZ;
343 break;
344 default:
345 chan_bw = IEEE80211_VHT_CHANWIDTH_USE_HT;
346 break;
347 }
348 vht_oper->center_freq_seg0_idx =
349 mwifiex_get_center_freq_index(priv, BAND_AAC,
350 bss_desc->channel,
351 chan_bw);
352
353 return 0;
354 }
355
mwifiex_tdls_add_ext_capab(struct mwifiex_private * priv,struct sk_buff * skb)356 static void mwifiex_tdls_add_ext_capab(struct mwifiex_private *priv,
357 struct sk_buff *skb)
358 {
359 struct ieee_types_extcap *extcap;
360
361 extcap = skb_put(skb, sizeof(struct ieee_types_extcap));
362 extcap->ieee_hdr.element_id = WLAN_EID_EXT_CAPABILITY;
363 extcap->ieee_hdr.len = 8;
364 memset(extcap->ext_capab, 0, 8);
365 extcap->ext_capab[4] |= WLAN_EXT_CAPA5_TDLS_ENABLED;
366 extcap->ext_capab[3] |= WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH;
367
368 if (priv->adapter->is_hw_11ac_capable)
369 extcap->ext_capab[7] |= WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED;
370 }
371
mwifiex_tdls_add_qos_capab(struct sk_buff * skb)372 static void mwifiex_tdls_add_qos_capab(struct sk_buff *skb)
373 {
374 u8 *pos = skb_put(skb, 3);
375
376 *pos++ = WLAN_EID_QOS_CAPA;
377 *pos++ = 1;
378 *pos++ = MWIFIEX_TDLS_DEF_QOS_CAPAB;
379 }
380
381 static void
mwifiex_tdls_add_wmm_param_ie(struct mwifiex_private * priv,struct sk_buff * skb)382 mwifiex_tdls_add_wmm_param_ie(struct mwifiex_private *priv, struct sk_buff *skb)
383 {
384 struct ieee80211_wmm_param_ie *wmm;
385 u8 ac_vi[] = {0x42, 0x43, 0x5e, 0x00};
386 u8 ac_vo[] = {0x62, 0x32, 0x2f, 0x00};
387 u8 ac_be[] = {0x03, 0xa4, 0x00, 0x00};
388 u8 ac_bk[] = {0x27, 0xa4, 0x00, 0x00};
389
390 wmm = skb_put_zero(skb, sizeof(*wmm));
391
392 wmm->element_id = WLAN_EID_VENDOR_SPECIFIC;
393 wmm->len = sizeof(*wmm) - 2;
394 wmm->oui[0] = 0x00; /* Microsoft OUI 00:50:F2 */
395 wmm->oui[1] = 0x50;
396 wmm->oui[2] = 0xf2;
397 wmm->oui_type = 2; /* WME */
398 wmm->oui_subtype = 1; /* WME param */
399 wmm->version = 1; /* WME ver */
400 wmm->qos_info = 0; /* U-APSD not in use */
401
402 /* use default WMM AC parameters for TDLS link*/
403 memcpy(&wmm->ac[0], ac_be, sizeof(ac_be));
404 memcpy(&wmm->ac[1], ac_bk, sizeof(ac_bk));
405 memcpy(&wmm->ac[2], ac_vi, sizeof(ac_vi));
406 memcpy(&wmm->ac[3], ac_vo, sizeof(ac_vo));
407 }
408
409 static void
mwifiex_add_wmm_info_ie(struct mwifiex_private * priv,struct sk_buff * skb,u8 qosinfo)410 mwifiex_add_wmm_info_ie(struct mwifiex_private *priv, struct sk_buff *skb,
411 u8 qosinfo)
412 {
413 u8 *buf;
414
415 buf = skb_put(skb,
416 MWIFIEX_TDLS_WMM_INFO_SIZE + sizeof(struct ieee_types_header));
417
418 *buf++ = WLAN_EID_VENDOR_SPECIFIC;
419 *buf++ = 7; /* len */
420 *buf++ = 0x00; /* Microsoft OUI 00:50:F2 */
421 *buf++ = 0x50;
422 *buf++ = 0xf2;
423 *buf++ = 2; /* WME */
424 *buf++ = 0; /* WME info */
425 *buf++ = 1; /* WME ver */
426 *buf++ = qosinfo; /* U-APSD no in use */
427 }
428
mwifiex_tdls_add_bss_co_2040(struct sk_buff * skb)429 static void mwifiex_tdls_add_bss_co_2040(struct sk_buff *skb)
430 {
431 struct ieee_types_bss_co_2040 *bssco;
432
433 bssco = skb_put(skb, sizeof(struct ieee_types_bss_co_2040));
434 bssco->ieee_hdr.element_id = WLAN_EID_BSS_COEX_2040;
435 bssco->ieee_hdr.len = sizeof(struct ieee_types_bss_co_2040) -
436 sizeof(struct ieee_types_header);
437 bssco->bss_2040co = 0x01;
438 }
439
mwifiex_tdls_add_supported_chan(struct sk_buff * skb)440 static void mwifiex_tdls_add_supported_chan(struct sk_buff *skb)
441 {
442 struct ieee_types_generic *supp_chan;
443 u8 chan_supp[] = {1, 11};
444
445 supp_chan = skb_put(skb,
446 (sizeof(struct ieee_types_header) + sizeof(chan_supp)));
447 supp_chan->ieee_hdr.element_id = WLAN_EID_SUPPORTED_CHANNELS;
448 supp_chan->ieee_hdr.len = sizeof(chan_supp);
449 memcpy(supp_chan->data, chan_supp, sizeof(chan_supp));
450 }
451
mwifiex_tdls_add_oper_class(struct sk_buff * skb)452 static void mwifiex_tdls_add_oper_class(struct sk_buff *skb)
453 {
454 struct ieee_types_generic *reg_class;
455 u8 rc_list[] = {1,
456 1, 2, 3, 4, 12, 22, 23, 24, 25, 27, 28, 29, 30, 32, 33};
457 reg_class = skb_put(skb,
458 (sizeof(struct ieee_types_header) + sizeof(rc_list)));
459 reg_class->ieee_hdr.element_id = WLAN_EID_SUPPORTED_REGULATORY_CLASSES;
460 reg_class->ieee_hdr.len = sizeof(rc_list);
461 memcpy(reg_class->data, rc_list, sizeof(rc_list));
462 }
463
mwifiex_prep_tdls_encap_data(struct mwifiex_private * priv,const u8 * peer,u8 action_code,u8 dialog_token,u16 status_code,struct sk_buff * skb)464 static int mwifiex_prep_tdls_encap_data(struct mwifiex_private *priv,
465 const u8 *peer, u8 action_code,
466 u8 dialog_token,
467 u16 status_code, struct sk_buff *skb)
468 {
469 struct ieee80211_tdls_data *tf;
470 int ret;
471 u16 capab;
472 struct ieee80211_ht_cap *ht_cap;
473 u8 radio, *pos;
474
475 capab = priv->curr_bss_params.bss_descriptor.cap_info_bitmap;
476
477 tf = skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
478 memcpy(tf->da, peer, ETH_ALEN);
479 memcpy(tf->sa, priv->curr_addr, ETH_ALEN);
480 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
481 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
482
483 switch (action_code) {
484 case WLAN_TDLS_SETUP_REQUEST:
485 tf->category = WLAN_CATEGORY_TDLS;
486 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
487 skb_put(skb, sizeof(tf->u.setup_req));
488 tf->u.setup_req.dialog_token = dialog_token;
489 tf->u.setup_req.capability = cpu_to_le16(capab);
490 ret = mwifiex_tdls_append_rates_ie(priv, skb);
491 if (ret) {
492 dev_kfree_skb_any(skb);
493 return ret;
494 }
495
496 pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2);
497 *pos++ = WLAN_EID_HT_CAPABILITY;
498 *pos++ = sizeof(struct ieee80211_ht_cap);
499 ht_cap = (void *)pos;
500 radio = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
501 ret = mwifiex_fill_cap_info(priv, radio, ht_cap);
502 if (ret) {
503 dev_kfree_skb_any(skb);
504 return ret;
505 }
506
507 if (priv->adapter->is_hw_11ac_capable) {
508 ret = mwifiex_tdls_add_vht_capab(priv, skb);
509 if (ret) {
510 dev_kfree_skb_any(skb);
511 return ret;
512 }
513 mwifiex_tdls_add_aid(priv, skb);
514 }
515
516 mwifiex_tdls_add_ext_capab(priv, skb);
517 mwifiex_tdls_add_bss_co_2040(skb);
518 mwifiex_tdls_add_supported_chan(skb);
519 mwifiex_tdls_add_oper_class(skb);
520 mwifiex_add_wmm_info_ie(priv, skb, 0);
521 break;
522
523 case WLAN_TDLS_SETUP_RESPONSE:
524 tf->category = WLAN_CATEGORY_TDLS;
525 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
526 skb_put(skb, sizeof(tf->u.setup_resp));
527 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
528 tf->u.setup_resp.dialog_token = dialog_token;
529 tf->u.setup_resp.capability = cpu_to_le16(capab);
530 ret = mwifiex_tdls_append_rates_ie(priv, skb);
531 if (ret) {
532 dev_kfree_skb_any(skb);
533 return ret;
534 }
535
536 pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2);
537 *pos++ = WLAN_EID_HT_CAPABILITY;
538 *pos++ = sizeof(struct ieee80211_ht_cap);
539 ht_cap = (void *)pos;
540 radio = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
541 ret = mwifiex_fill_cap_info(priv, radio, ht_cap);
542 if (ret) {
543 dev_kfree_skb_any(skb);
544 return ret;
545 }
546
547 if (priv->adapter->is_hw_11ac_capable) {
548 ret = mwifiex_tdls_add_vht_capab(priv, skb);
549 if (ret) {
550 dev_kfree_skb_any(skb);
551 return ret;
552 }
553 mwifiex_tdls_add_aid(priv, skb);
554 }
555
556 mwifiex_tdls_add_ext_capab(priv, skb);
557 mwifiex_tdls_add_bss_co_2040(skb);
558 mwifiex_tdls_add_supported_chan(skb);
559 mwifiex_tdls_add_oper_class(skb);
560 mwifiex_add_wmm_info_ie(priv, skb, 0);
561 break;
562
563 case WLAN_TDLS_SETUP_CONFIRM:
564 tf->category = WLAN_CATEGORY_TDLS;
565 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
566 skb_put(skb, sizeof(tf->u.setup_cfm));
567 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
568 tf->u.setup_cfm.dialog_token = dialog_token;
569
570 mwifiex_tdls_add_wmm_param_ie(priv, skb);
571 if (priv->adapter->is_hw_11ac_capable) {
572 ret = mwifiex_tdls_add_vht_oper(priv, peer, skb);
573 if (ret) {
574 dev_kfree_skb_any(skb);
575 return ret;
576 }
577 ret = mwifiex_tdls_add_ht_oper(priv, peer, 1, skb);
578 if (ret) {
579 dev_kfree_skb_any(skb);
580 return ret;
581 }
582 } else {
583 ret = mwifiex_tdls_add_ht_oper(priv, peer, 0, skb);
584 if (ret) {
585 dev_kfree_skb_any(skb);
586 return ret;
587 }
588 }
589 break;
590
591 case WLAN_TDLS_TEARDOWN:
592 tf->category = WLAN_CATEGORY_TDLS;
593 tf->action_code = WLAN_TDLS_TEARDOWN;
594 skb_put(skb, sizeof(tf->u.teardown));
595 tf->u.teardown.reason_code = cpu_to_le16(status_code);
596 break;
597
598 case WLAN_TDLS_DISCOVERY_REQUEST:
599 tf->category = WLAN_CATEGORY_TDLS;
600 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
601 skb_put(skb, sizeof(tf->u.discover_req));
602 tf->u.discover_req.dialog_token = dialog_token;
603 break;
604 default:
605 mwifiex_dbg(priv->adapter, ERROR, "Unknown TDLS frame type.\n");
606 return -EINVAL;
607 }
608
609 return 0;
610 }
611
612 static void
mwifiex_tdls_add_link_ie(struct sk_buff * skb,const u8 * src_addr,const u8 * peer,const u8 * bssid)613 mwifiex_tdls_add_link_ie(struct sk_buff *skb, const u8 *src_addr,
614 const u8 *peer, const u8 *bssid)
615 {
616 struct ieee80211_tdls_lnkie *lnkid;
617
618 lnkid = skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
619 lnkid->ie_type = WLAN_EID_LINK_ID;
620 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) -
621 sizeof(struct ieee_types_header);
622
623 memcpy(lnkid->bssid, bssid, ETH_ALEN);
624 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
625 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
626 }
627
mwifiex_send_tdls_data_frame(struct mwifiex_private * priv,const u8 * peer,u8 action_code,u8 dialog_token,u16 status_code,const u8 * extra_ies,size_t extra_ies_len)628 int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
629 u8 action_code, u8 dialog_token,
630 u16 status_code, const u8 *extra_ies,
631 size_t extra_ies_len)
632 {
633 struct sk_buff *skb;
634 struct mwifiex_txinfo *tx_info;
635 int ret;
636 u16 skb_len;
637
638 skb_len = MWIFIEX_MIN_DATA_HEADER_LEN +
639 max(sizeof(struct ieee80211_mgmt),
640 sizeof(struct ieee80211_tdls_data)) +
641 MWIFIEX_MGMT_FRAME_HEADER_SIZE +
642 MWIFIEX_SUPPORTED_RATES +
643 3 + /* Qos Info */
644 sizeof(struct ieee_types_extcap) +
645 sizeof(struct ieee80211_ht_cap) +
646 sizeof(struct ieee_types_bss_co_2040) +
647 sizeof(struct ieee80211_ht_operation) +
648 sizeof(struct ieee80211_tdls_lnkie) +
649 (2 * (sizeof(struct ieee_types_header))) +
650 MWIFIEX_SUPPORTED_CHANNELS +
651 MWIFIEX_OPERATING_CLASSES +
652 sizeof(struct ieee80211_wmm_param_ie) +
653 extra_ies_len;
654
655 if (priv->adapter->is_hw_11ac_capable)
656 skb_len += sizeof(struct ieee_types_vht_cap) +
657 sizeof(struct ieee_types_vht_oper) +
658 sizeof(struct ieee_types_aid);
659
660 skb = dev_alloc_skb(skb_len);
661 if (!skb) {
662 mwifiex_dbg(priv->adapter, ERROR,
663 "allocate skb failed for management frame\n");
664 return -ENOMEM;
665 }
666 skb_reserve(skb, MWIFIEX_MIN_DATA_HEADER_LEN);
667
668 switch (action_code) {
669 case WLAN_TDLS_SETUP_REQUEST:
670 case WLAN_TDLS_SETUP_CONFIRM:
671 case WLAN_TDLS_TEARDOWN:
672 case WLAN_TDLS_DISCOVERY_REQUEST:
673 ret = mwifiex_prep_tdls_encap_data(priv, peer, action_code,
674 dialog_token, status_code,
675 skb);
676 if (ret) {
677 dev_kfree_skb_any(skb);
678 return ret;
679 }
680 if (extra_ies_len)
681 skb_put_data(skb, extra_ies, extra_ies_len);
682 mwifiex_tdls_add_link_ie(skb, priv->curr_addr, peer,
683 priv->cfg_bssid);
684 break;
685 case WLAN_TDLS_SETUP_RESPONSE:
686 ret = mwifiex_prep_tdls_encap_data(priv, peer, action_code,
687 dialog_token, status_code,
688 skb);
689 if (ret) {
690 dev_kfree_skb_any(skb);
691 return ret;
692 }
693 if (extra_ies_len)
694 skb_put_data(skb, extra_ies, extra_ies_len);
695 mwifiex_tdls_add_link_ie(skb, peer, priv->curr_addr,
696 priv->cfg_bssid);
697 break;
698 }
699
700 switch (action_code) {
701 case WLAN_TDLS_SETUP_REQUEST:
702 case WLAN_TDLS_SETUP_RESPONSE:
703 skb->priority = MWIFIEX_PRIO_BK;
704 break;
705 default:
706 skb->priority = MWIFIEX_PRIO_VI;
707 break;
708 }
709
710 tx_info = MWIFIEX_SKB_TXCB(skb);
711 memset(tx_info, 0, sizeof(*tx_info));
712 tx_info->bss_num = priv->bss_num;
713 tx_info->bss_type = priv->bss_type;
714
715 __net_timestamp(skb);
716 mwifiex_queue_tx_pkt(priv, skb);
717
718 /* Delay 10ms to make sure tdls setup confirm/teardown frame
719 * is received by peer
720 */
721 if (action_code == WLAN_TDLS_SETUP_CONFIRM ||
722 action_code == WLAN_TDLS_TEARDOWN)
723 msleep_interruptible(10);
724
725 return 0;
726 }
727
728 static int
mwifiex_construct_tdls_action_frame(struct mwifiex_private * priv,const u8 * peer,u8 action_code,u8 dialog_token,u16 status_code,struct sk_buff * skb)729 mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,
730 const u8 *peer,
731 u8 action_code, u8 dialog_token,
732 u16 status_code, struct sk_buff *skb)
733 {
734 struct ieee80211_mgmt *mgmt;
735 int ret;
736 u16 capab;
737 struct ieee80211_ht_cap *ht_cap;
738 unsigned int extra;
739 u8 radio, *pos;
740
741 capab = priv->curr_bss_params.bss_descriptor.cap_info_bitmap;
742
743 mgmt = skb_put(skb, offsetof(struct ieee80211_mgmt, u));
744
745 memset(mgmt, 0, 24);
746 memcpy(mgmt->da, peer, ETH_ALEN);
747 memcpy(mgmt->sa, priv->curr_addr, ETH_ALEN);
748 memcpy(mgmt->bssid, priv->cfg_bssid, ETH_ALEN);
749 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
750 IEEE80211_STYPE_ACTION);
751
752 /* add address 4 */
753 pos = skb_put(skb, ETH_ALEN);
754
755 switch (action_code) {
756 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
757 /* See the layout of 'struct ieee80211_mgmt'. */
758 extra = IEEE80211_MIN_ACTION_SIZE(tdls_discover_resp) - 24;
759 skb_put(skb, extra);
760 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
761 mgmt->u.action.action_code = WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
762 mgmt->u.action.tdls_discover_resp.dialog_token = dialog_token;
763 mgmt->u.action.tdls_discover_resp.capability = cpu_to_le16(capab);
764 /* move back for addr4 */
765 memmove(pos + ETH_ALEN, &mgmt->u.action, extra);
766 /* init address 4 */
767 eth_broadcast_addr(pos);
768
769 ret = mwifiex_tdls_append_rates_ie(priv, skb);
770 if (ret) {
771 dev_kfree_skb_any(skb);
772 return ret;
773 }
774
775 pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2);
776 *pos++ = WLAN_EID_HT_CAPABILITY;
777 *pos++ = sizeof(struct ieee80211_ht_cap);
778 ht_cap = (void *)pos;
779 radio = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
780 ret = mwifiex_fill_cap_info(priv, radio, ht_cap);
781 if (ret) {
782 dev_kfree_skb_any(skb);
783 return ret;
784 }
785
786 if (priv->adapter->is_hw_11ac_capable) {
787 ret = mwifiex_tdls_add_vht_capab(priv, skb);
788 if (ret) {
789 dev_kfree_skb_any(skb);
790 return ret;
791 }
792 mwifiex_tdls_add_aid(priv, skb);
793 }
794
795 mwifiex_tdls_add_ext_capab(priv, skb);
796 mwifiex_tdls_add_bss_co_2040(skb);
797 mwifiex_tdls_add_supported_chan(skb);
798 mwifiex_tdls_add_qos_capab(skb);
799 mwifiex_tdls_add_oper_class(skb);
800 break;
801 default:
802 mwifiex_dbg(priv->adapter, ERROR, "Unknown TDLS action frame type\n");
803 return -EINVAL;
804 }
805
806 return 0;
807 }
808
mwifiex_send_tdls_action_frame(struct mwifiex_private * priv,const u8 * peer,u8 action_code,u8 dialog_token,u16 status_code,const u8 * extra_ies,size_t extra_ies_len)809 int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
810 u8 action_code, u8 dialog_token,
811 u16 status_code, const u8 *extra_ies,
812 size_t extra_ies_len)
813 {
814 struct sk_buff *skb;
815 struct mwifiex_txinfo *tx_info;
816 u8 *pos;
817 u32 pkt_type, tx_control;
818 u16 pkt_len, skb_len;
819
820 skb_len = MWIFIEX_MIN_DATA_HEADER_LEN +
821 max(sizeof(struct ieee80211_mgmt),
822 sizeof(struct ieee80211_tdls_data)) +
823 MWIFIEX_MGMT_FRAME_HEADER_SIZE +
824 MWIFIEX_SUPPORTED_RATES +
825 sizeof(struct ieee_types_extcap) +
826 sizeof(struct ieee80211_ht_cap) +
827 sizeof(struct ieee_types_bss_co_2040) +
828 sizeof(struct ieee80211_ht_operation) +
829 sizeof(struct ieee80211_tdls_lnkie) +
830 extra_ies_len +
831 3 + /* Qos Info */
832 ETH_ALEN; /* Address4 */
833
834 if (priv->adapter->is_hw_11ac_capable)
835 skb_len += sizeof(struct ieee_types_vht_cap) +
836 sizeof(struct ieee_types_vht_oper) +
837 sizeof(struct ieee_types_aid);
838
839 skb = dev_alloc_skb(skb_len);
840 if (!skb) {
841 mwifiex_dbg(priv->adapter, ERROR,
842 "allocate skb failed for management frame\n");
843 return -ENOMEM;
844 }
845
846 skb_reserve(skb, MWIFIEX_MIN_DATA_HEADER_LEN);
847
848 pkt_type = PKT_TYPE_MGMT;
849 tx_control = 0;
850 pos = skb_put_zero(skb,
851 MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(pkt_len));
852 memcpy(pos, &pkt_type, sizeof(pkt_type));
853 memcpy(pos + sizeof(pkt_type), &tx_control, sizeof(tx_control));
854
855 if (mwifiex_construct_tdls_action_frame(priv, peer, action_code,
856 dialog_token, status_code,
857 skb)) {
858 dev_kfree_skb_any(skb);
859 return -EINVAL;
860 }
861
862 if (extra_ies_len)
863 skb_put_data(skb, extra_ies, extra_ies_len);
864
865 /* the TDLS link IE is always added last we are the responder */
866
867 mwifiex_tdls_add_link_ie(skb, peer, priv->curr_addr,
868 priv->cfg_bssid);
869
870 skb->priority = MWIFIEX_PRIO_VI;
871
872 tx_info = MWIFIEX_SKB_TXCB(skb);
873 memset(tx_info, 0, sizeof(*tx_info));
874 tx_info->bss_num = priv->bss_num;
875 tx_info->bss_type = priv->bss_type;
876 tx_info->flags |= MWIFIEX_BUF_FLAG_TDLS_PKT;
877
878 pkt_len = skb->len - MWIFIEX_MGMT_FRAME_HEADER_SIZE - sizeof(pkt_len);
879 memcpy(skb->data + MWIFIEX_MGMT_FRAME_HEADER_SIZE, &pkt_len,
880 sizeof(pkt_len));
881 __net_timestamp(skb);
882 mwifiex_queue_tx_pkt(priv, skb);
883
884 return 0;
885 }
886
887 /* This function process tdls action frame from peer.
888 * Peer capabilities are stored into station node structure.
889 */
mwifiex_process_tdls_action_frame(struct mwifiex_private * priv,u8 * buf,int len)890 void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
891 u8 *buf, int len)
892 {
893 struct mwifiex_sta_node *sta_ptr;
894 u8 *peer, *pos, *end;
895 u8 i, action, basic;
896 u16 cap = 0;
897 int ies_len = 0;
898
899 if (len < (sizeof(struct ethhdr) + 3))
900 return;
901 if (*(buf + sizeof(struct ethhdr)) != WLAN_TDLS_SNAP_RFTYPE)
902 return;
903 if (*(buf + sizeof(struct ethhdr) + 1) != WLAN_CATEGORY_TDLS)
904 return;
905
906 peer = buf + ETH_ALEN;
907 action = *(buf + sizeof(struct ethhdr) + 2);
908 mwifiex_dbg(priv->adapter, DATA,
909 "rx:tdls action: peer=%pM, action=%d\n", peer, action);
910
911 switch (action) {
912 case WLAN_TDLS_SETUP_REQUEST:
913 if (len < (sizeof(struct ethhdr) + TDLS_REQ_FIX_LEN))
914 return;
915
916 pos = buf + sizeof(struct ethhdr) + 4;
917 /* payload 1+ category 1 + action 1 + dialog 1 */
918 cap = get_unaligned_le16(pos);
919 ies_len = len - sizeof(struct ethhdr) - TDLS_REQ_FIX_LEN;
920 pos += 2;
921 break;
922
923 case WLAN_TDLS_SETUP_RESPONSE:
924 if (len < (sizeof(struct ethhdr) + TDLS_RESP_FIX_LEN))
925 return;
926 /* payload 1+ category 1 + action 1 + dialog 1 + status code 2*/
927 pos = buf + sizeof(struct ethhdr) + 6;
928 cap = get_unaligned_le16(pos);
929 ies_len = len - sizeof(struct ethhdr) - TDLS_RESP_FIX_LEN;
930 pos += 2;
931 break;
932
933 case WLAN_TDLS_SETUP_CONFIRM:
934 if (len < (sizeof(struct ethhdr) + TDLS_CONFIRM_FIX_LEN))
935 return;
936 pos = buf + sizeof(struct ethhdr) + TDLS_CONFIRM_FIX_LEN;
937 ies_len = len - sizeof(struct ethhdr) - TDLS_CONFIRM_FIX_LEN;
938 break;
939 default:
940 mwifiex_dbg(priv->adapter, ERROR, "Unknown TDLS frame type.\n");
941 return;
942 }
943
944 sta_ptr = mwifiex_add_sta_entry(priv, peer);
945 if (!sta_ptr)
946 return;
947
948 sta_ptr->tdls_cap.capab = cpu_to_le16(cap);
949
950 for (end = pos + ies_len; pos + 1 < end; pos += 2 + pos[1]) {
951 u8 ie_len = pos[1];
952
953 if (pos + 2 + ie_len > end)
954 break;
955
956 switch (*pos) {
957 case WLAN_EID_SUPP_RATES:
958 if (ie_len > sizeof(sta_ptr->tdls_cap.rates))
959 return;
960 sta_ptr->tdls_cap.rates_len = ie_len;
961 for (i = 0; i < ie_len; i++)
962 sta_ptr->tdls_cap.rates[i] = pos[i + 2];
963 break;
964
965 case WLAN_EID_EXT_SUPP_RATES:
966 if (ie_len > sizeof(sta_ptr->tdls_cap.rates))
967 return;
968 basic = sta_ptr->tdls_cap.rates_len;
969 if (ie_len > sizeof(sta_ptr->tdls_cap.rates) - basic)
970 return;
971 for (i = 0; i < ie_len; i++)
972 sta_ptr->tdls_cap.rates[basic + i] = pos[i + 2];
973 sta_ptr->tdls_cap.rates_len += ie_len;
974 break;
975 case WLAN_EID_HT_CAPABILITY:
976 if (ie_len != sizeof(struct ieee80211_ht_cap))
977 return;
978 /* copy the ie's value into ht_capb*/
979 memcpy((u8 *)&sta_ptr->tdls_cap.ht_capb, pos + 2,
980 sizeof(struct ieee80211_ht_cap));
981 sta_ptr->is_11n_enabled = 1;
982 break;
983 case WLAN_EID_HT_OPERATION:
984 if (ie_len != sizeof(struct ieee80211_ht_operation))
985 return;
986 /* copy the ie's value into ht_oper*/
987 memcpy(&sta_ptr->tdls_cap.ht_oper, pos + 2,
988 sizeof(struct ieee80211_ht_operation));
989 break;
990 case WLAN_EID_BSS_COEX_2040:
991 if (ie_len != sizeof(pos[2]))
992 return;
993 sta_ptr->tdls_cap.coex_2040 = pos[2];
994 break;
995 case WLAN_EID_EXT_CAPABILITY:
996 if (ie_len < sizeof(struct ieee_types_header))
997 return;
998 if (ie_len > 8)
999 return;
1000 memcpy((u8 *)&sta_ptr->tdls_cap.extcap, pos,
1001 sizeof(struct ieee_types_header) +
1002 min_t(u8, ie_len, 8));
1003 break;
1004 case WLAN_EID_RSN:
1005 if (ie_len < sizeof(struct ieee_types_header))
1006 return;
1007 if (ie_len > IEEE_MAX_IE_SIZE -
1008 sizeof(struct ieee_types_header))
1009 return;
1010 memcpy((u8 *)&sta_ptr->tdls_cap.rsn_ie, pos,
1011 sizeof(struct ieee_types_header) +
1012 min_t(u8, ie_len, IEEE_MAX_IE_SIZE -
1013 sizeof(struct ieee_types_header)));
1014 break;
1015 case WLAN_EID_QOS_CAPA:
1016 if (ie_len != sizeof(pos[2]))
1017 return;
1018 sta_ptr->tdls_cap.qos_info = pos[2];
1019 break;
1020 case WLAN_EID_VHT_OPERATION:
1021 if (priv->adapter->is_hw_11ac_capable) {
1022 if (ie_len !=
1023 sizeof(struct ieee80211_vht_operation))
1024 return;
1025 /* copy the ie's value into vhtoper*/
1026 memcpy(&sta_ptr->tdls_cap.vhtoper, pos + 2,
1027 sizeof(struct ieee80211_vht_operation));
1028 }
1029 break;
1030 case WLAN_EID_VHT_CAPABILITY:
1031 if (priv->adapter->is_hw_11ac_capable) {
1032 if (ie_len != sizeof(struct ieee80211_vht_cap))
1033 return;
1034 /* copy the ie's value into vhtcap*/
1035 memcpy((u8 *)&sta_ptr->tdls_cap.vhtcap, pos + 2,
1036 sizeof(struct ieee80211_vht_cap));
1037 sta_ptr->is_11ac_enabled = 1;
1038 }
1039 break;
1040 case WLAN_EID_AID:
1041 if (priv->adapter->is_hw_11ac_capable) {
1042 if (ie_len != sizeof(u16))
1043 return;
1044 sta_ptr->tdls_cap.aid =
1045 get_unaligned_le16((pos + 2));
1046 }
1047 break;
1048 default:
1049 break;
1050 }
1051 }
1052
1053 return;
1054 }
1055
1056 static int
mwifiex_tdls_process_config_link(struct mwifiex_private * priv,const u8 * peer)1057 mwifiex_tdls_process_config_link(struct mwifiex_private *priv, const u8 *peer)
1058 {
1059 struct mwifiex_sta_node *sta_ptr;
1060 struct mwifiex_ds_tdls_oper tdls_oper;
1061
1062 memset(&tdls_oper, 0, sizeof(struct mwifiex_ds_tdls_oper));
1063 sta_ptr = mwifiex_get_sta_entry(priv, peer);
1064
1065 if (!sta_ptr || sta_ptr->tdls_status == TDLS_SETUP_FAILURE) {
1066 mwifiex_dbg(priv->adapter, ERROR,
1067 "link absent for peer %pM; cannot config\n", peer);
1068 return -EINVAL;
1069 }
1070
1071 memcpy(&tdls_oper.peer_mac, peer, ETH_ALEN);
1072 tdls_oper.tdls_action = MWIFIEX_TDLS_CONFIG_LINK;
1073 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_OPER,
1074 HostCmd_ACT_GEN_SET, 0, &tdls_oper, true);
1075 }
1076
1077 static int
mwifiex_tdls_process_create_link(struct mwifiex_private * priv,const u8 * peer)1078 mwifiex_tdls_process_create_link(struct mwifiex_private *priv, const u8 *peer)
1079 {
1080 struct mwifiex_sta_node *sta_ptr;
1081 struct mwifiex_ds_tdls_oper tdls_oper;
1082
1083 memset(&tdls_oper, 0, sizeof(struct mwifiex_ds_tdls_oper));
1084 sta_ptr = mwifiex_get_sta_entry(priv, peer);
1085
1086 if (sta_ptr && sta_ptr->tdls_status == TDLS_SETUP_INPROGRESS) {
1087 mwifiex_dbg(priv->adapter, WARN,
1088 "Setup already in progress for peer %pM\n", peer);
1089 return 0;
1090 }
1091
1092 sta_ptr = mwifiex_add_sta_entry(priv, peer);
1093 if (!sta_ptr)
1094 return -ENOMEM;
1095
1096 sta_ptr->tdls_status = TDLS_SETUP_INPROGRESS;
1097 mwifiex_hold_tdls_packets(priv, peer);
1098 memcpy(&tdls_oper.peer_mac, peer, ETH_ALEN);
1099 tdls_oper.tdls_action = MWIFIEX_TDLS_CREATE_LINK;
1100 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_OPER,
1101 HostCmd_ACT_GEN_SET, 0, &tdls_oper, true);
1102 }
1103
1104 static int
mwifiex_tdls_process_disable_link(struct mwifiex_private * priv,const u8 * peer)1105 mwifiex_tdls_process_disable_link(struct mwifiex_private *priv, const u8 *peer)
1106 {
1107 struct mwifiex_sta_node *sta_ptr;
1108 struct mwifiex_ds_tdls_oper tdls_oper;
1109
1110 memset(&tdls_oper, 0, sizeof(struct mwifiex_ds_tdls_oper));
1111 sta_ptr = mwifiex_get_sta_entry(priv, peer);
1112
1113 if (sta_ptr) {
1114 if (sta_ptr->is_11n_enabled) {
1115 mwifiex_11n_cleanup_reorder_tbl(priv);
1116 spin_lock_bh(&priv->wmm.ra_list_spinlock);
1117 mwifiex_11n_delete_all_tx_ba_stream_tbl(priv);
1118 spin_unlock_bh(&priv->wmm.ra_list_spinlock);
1119 }
1120 mwifiex_del_sta_entry(priv, peer);
1121 }
1122
1123 mwifiex_restore_tdls_packets(priv, peer, TDLS_LINK_TEARDOWN);
1124 mwifiex_auto_tdls_update_peer_status(priv, peer, TDLS_NOT_SETUP);
1125 memcpy(&tdls_oper.peer_mac, peer, ETH_ALEN);
1126 tdls_oper.tdls_action = MWIFIEX_TDLS_DISABLE_LINK;
1127 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_OPER,
1128 HostCmd_ACT_GEN_SET, 0, &tdls_oper, true);
1129 }
1130
1131 static int
mwifiex_tdls_process_enable_link(struct mwifiex_private * priv,const u8 * peer)1132 mwifiex_tdls_process_enable_link(struct mwifiex_private *priv, const u8 *peer)
1133 {
1134 struct mwifiex_sta_node *sta_ptr;
1135 struct ieee80211_mcs_info mcs;
1136 int i;
1137
1138 sta_ptr = mwifiex_get_sta_entry(priv, peer);
1139
1140 if (sta_ptr && (sta_ptr->tdls_status != TDLS_SETUP_FAILURE)) {
1141 mwifiex_dbg(priv->adapter, MSG,
1142 "tdls: enable link %pM success\n", peer);
1143
1144 sta_ptr->tdls_status = TDLS_SETUP_COMPLETE;
1145
1146 mcs = sta_ptr->tdls_cap.ht_capb.mcs;
1147 if (mcs.rx_mask[0] != 0xff)
1148 sta_ptr->is_11n_enabled = true;
1149 if (sta_ptr->is_11n_enabled) {
1150 if (le16_to_cpu(sta_ptr->tdls_cap.ht_capb.cap_info) &
1151 IEEE80211_HT_CAP_MAX_AMSDU)
1152 sta_ptr->max_amsdu =
1153 MWIFIEX_TX_DATA_BUF_SIZE_8K;
1154 else
1155 sta_ptr->max_amsdu =
1156 MWIFIEX_TX_DATA_BUF_SIZE_4K;
1157
1158 for (i = 0; i < MAX_NUM_TID; i++)
1159 sta_ptr->ampdu_sta[i] =
1160 priv->aggr_prio_tbl[i].ampdu_user;
1161 } else {
1162 for (i = 0; i < MAX_NUM_TID; i++)
1163 sta_ptr->ampdu_sta[i] = BA_STREAM_NOT_ALLOWED;
1164 }
1165 if (sta_ptr->tdls_cap.extcap.ext_capab[3] &
1166 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH) {
1167 mwifiex_config_tdls_enable(priv);
1168 mwifiex_config_tdls_cs_params(priv);
1169 }
1170
1171 memset(sta_ptr->rx_seq, 0xff, sizeof(sta_ptr->rx_seq));
1172 mwifiex_restore_tdls_packets(priv, peer, TDLS_SETUP_COMPLETE);
1173 mwifiex_auto_tdls_update_peer_status(priv, peer,
1174 TDLS_SETUP_COMPLETE);
1175 } else {
1176 mwifiex_dbg(priv->adapter, ERROR,
1177 "tdls: enable link %pM failed\n", peer);
1178 if (sta_ptr) {
1179 mwifiex_11n_cleanup_reorder_tbl(priv);
1180 spin_lock_bh(&priv->wmm.ra_list_spinlock);
1181 mwifiex_11n_delete_all_tx_ba_stream_tbl(priv);
1182 spin_unlock_bh(&priv->wmm.ra_list_spinlock);
1183 mwifiex_del_sta_entry(priv, peer);
1184 }
1185 mwifiex_restore_tdls_packets(priv, peer, TDLS_LINK_TEARDOWN);
1186 mwifiex_auto_tdls_update_peer_status(priv, peer,
1187 TDLS_NOT_SETUP);
1188
1189 return -1;
1190 }
1191
1192 return 0;
1193 }
1194
mwifiex_tdls_oper(struct mwifiex_private * priv,const u8 * peer,u8 action)1195 int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action)
1196 {
1197 switch (action) {
1198 case MWIFIEX_TDLS_ENABLE_LINK:
1199 return mwifiex_tdls_process_enable_link(priv, peer);
1200 case MWIFIEX_TDLS_DISABLE_LINK:
1201 return mwifiex_tdls_process_disable_link(priv, peer);
1202 case MWIFIEX_TDLS_CREATE_LINK:
1203 return mwifiex_tdls_process_create_link(priv, peer);
1204 case MWIFIEX_TDLS_CONFIG_LINK:
1205 return mwifiex_tdls_process_config_link(priv, peer);
1206 }
1207 return 0;
1208 }
1209
mwifiex_get_tdls_link_status(struct mwifiex_private * priv,const u8 * mac)1210 int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac)
1211 {
1212 struct mwifiex_sta_node *sta_ptr;
1213
1214 sta_ptr = mwifiex_get_sta_entry(priv, mac);
1215 if (sta_ptr)
1216 return sta_ptr->tdls_status;
1217
1218 return TDLS_NOT_SETUP;
1219 }
1220
mwifiex_get_tdls_list(struct mwifiex_private * priv,struct tdls_peer_info * buf)1221 int mwifiex_get_tdls_list(struct mwifiex_private *priv,
1222 struct tdls_peer_info *buf)
1223 {
1224 struct mwifiex_sta_node *sta_ptr;
1225 struct tdls_peer_info *peer = buf;
1226 int count = 0;
1227
1228 if (!ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info))
1229 return 0;
1230
1231 /* make sure we are in station mode and connected */
1232 if (!(priv->bss_type == MWIFIEX_BSS_TYPE_STA && priv->media_connected))
1233 return 0;
1234
1235 spin_lock_bh(&priv->sta_list_spinlock);
1236 list_for_each_entry(sta_ptr, &priv->sta_list, list) {
1237 if (mwifiex_is_tdls_link_setup(sta_ptr->tdls_status)) {
1238 ether_addr_copy(peer->peer_addr, sta_ptr->mac_addr);
1239 peer++;
1240 count++;
1241 if (count >= MWIFIEX_MAX_TDLS_PEER_SUPPORTED)
1242 break;
1243 }
1244 }
1245 spin_unlock_bh(&priv->sta_list_spinlock);
1246
1247 return count;
1248 }
1249
mwifiex_disable_all_tdls_links(struct mwifiex_private * priv)1250 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv)
1251 {
1252 struct mwifiex_sta_node *sta_ptr;
1253 struct mwifiex_ds_tdls_oper tdls_oper;
1254
1255 if (list_empty(&priv->sta_list))
1256 return;
1257
1258 list_for_each_entry(sta_ptr, &priv->sta_list, list) {
1259 memset(&tdls_oper, 0, sizeof(struct mwifiex_ds_tdls_oper));
1260
1261 if (sta_ptr->is_11n_enabled) {
1262 mwifiex_11n_cleanup_reorder_tbl(priv);
1263 spin_lock_bh(&priv->wmm.ra_list_spinlock);
1264 mwifiex_11n_delete_all_tx_ba_stream_tbl(priv);
1265 spin_unlock_bh(&priv->wmm.ra_list_spinlock);
1266 }
1267
1268 mwifiex_restore_tdls_packets(priv, sta_ptr->mac_addr,
1269 TDLS_LINK_TEARDOWN);
1270 memcpy(&tdls_oper.peer_mac, sta_ptr->mac_addr, ETH_ALEN);
1271 tdls_oper.tdls_action = MWIFIEX_TDLS_DISABLE_LINK;
1272 if (mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_OPER,
1273 HostCmd_ACT_GEN_SET, 0, &tdls_oper, false))
1274 mwifiex_dbg(priv->adapter, ERROR,
1275 "Disable link failed for TDLS peer %pM",
1276 sta_ptr->mac_addr);
1277 }
1278
1279 mwifiex_del_all_sta_list(priv);
1280 }
1281
mwifiex_tdls_check_tx(struct mwifiex_private * priv,struct sk_buff * skb)1282 int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb)
1283 {
1284 struct mwifiex_auto_tdls_peer *peer;
1285 u8 mac[ETH_ALEN];
1286
1287 ether_addr_copy(mac, skb->data);
1288
1289 spin_lock_bh(&priv->auto_tdls_lock);
1290 list_for_each_entry(peer, &priv->auto_tdls_list, list) {
1291 if (!memcmp(mac, peer->mac_addr, ETH_ALEN)) {
1292 if (peer->rssi <= MWIFIEX_TDLS_RSSI_HIGH &&
1293 peer->tdls_status == TDLS_NOT_SETUP &&
1294 (peer->failure_count <
1295 MWIFIEX_TDLS_MAX_FAIL_COUNT)) {
1296 peer->tdls_status = TDLS_SETUP_INPROGRESS;
1297 mwifiex_dbg(priv->adapter, INFO,
1298 "setup TDLS link, peer=%pM rssi=%d\n",
1299 peer->mac_addr, peer->rssi);
1300
1301 cfg80211_tdls_oper_request(priv->netdev,
1302 peer->mac_addr,
1303 NL80211_TDLS_SETUP,
1304 0, GFP_ATOMIC);
1305 priv->check_tdls_tx = false;
1306 } else if (peer->failure_count <
1307 MWIFIEX_TDLS_MAX_FAIL_COUNT &&
1308 peer->do_discover) {
1309 mwifiex_send_tdls_data_frame(priv,
1310 peer->mac_addr,
1311 WLAN_TDLS_DISCOVERY_REQUEST,
1312 1, 0, NULL, 0);
1313 peer->do_discover = false;
1314 }
1315 }
1316 }
1317 spin_unlock_bh(&priv->auto_tdls_lock);
1318
1319 return 0;
1320 }
1321
mwifiex_flush_auto_tdls_list(struct mwifiex_private * priv)1322 void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv)
1323 {
1324 struct mwifiex_auto_tdls_peer *peer, *tmp_node;
1325
1326 spin_lock_bh(&priv->auto_tdls_lock);
1327 list_for_each_entry_safe(peer, tmp_node, &priv->auto_tdls_list, list) {
1328 list_del(&peer->list);
1329 kfree(peer);
1330 }
1331
1332 INIT_LIST_HEAD(&priv->auto_tdls_list);
1333 spin_unlock_bh(&priv->auto_tdls_lock);
1334 priv->check_tdls_tx = false;
1335 }
1336
mwifiex_add_auto_tdls_peer(struct mwifiex_private * priv,const u8 * mac)1337 void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac)
1338 {
1339 struct mwifiex_auto_tdls_peer *tdls_peer;
1340
1341 if (!priv->adapter->auto_tdls)
1342 return;
1343
1344 spin_lock_bh(&priv->auto_tdls_lock);
1345 list_for_each_entry(tdls_peer, &priv->auto_tdls_list, list) {
1346 if (!memcmp(tdls_peer->mac_addr, mac, ETH_ALEN)) {
1347 tdls_peer->tdls_status = TDLS_SETUP_INPROGRESS;
1348 tdls_peer->rssi_jiffies = jiffies;
1349 spin_unlock_bh(&priv->auto_tdls_lock);
1350 return;
1351 }
1352 }
1353
1354 /* create new TDLS peer */
1355 tdls_peer = kzalloc_obj(*tdls_peer, GFP_ATOMIC);
1356 if (tdls_peer) {
1357 ether_addr_copy(tdls_peer->mac_addr, mac);
1358 tdls_peer->tdls_status = TDLS_SETUP_INPROGRESS;
1359 tdls_peer->rssi_jiffies = jiffies;
1360 INIT_LIST_HEAD(&tdls_peer->list);
1361 list_add_tail(&tdls_peer->list, &priv->auto_tdls_list);
1362 mwifiex_dbg(priv->adapter, INFO,
1363 "Add auto TDLS peer= %pM to list\n", mac);
1364 }
1365
1366 spin_unlock_bh(&priv->auto_tdls_lock);
1367 }
1368
mwifiex_auto_tdls_update_peer_status(struct mwifiex_private * priv,const u8 * mac,u8 link_status)1369 void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1370 const u8 *mac, u8 link_status)
1371 {
1372 struct mwifiex_auto_tdls_peer *peer;
1373
1374 if (!priv->adapter->auto_tdls)
1375 return;
1376
1377 spin_lock_bh(&priv->auto_tdls_lock);
1378 list_for_each_entry(peer, &priv->auto_tdls_list, list) {
1379 if (!memcmp(peer->mac_addr, mac, ETH_ALEN)) {
1380 if ((link_status == TDLS_NOT_SETUP) &&
1381 (peer->tdls_status == TDLS_SETUP_INPROGRESS))
1382 peer->failure_count++;
1383 else if (mwifiex_is_tdls_link_setup(link_status))
1384 peer->failure_count = 0;
1385
1386 peer->tdls_status = link_status;
1387 break;
1388 }
1389 }
1390 spin_unlock_bh(&priv->auto_tdls_lock);
1391 }
1392
mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private * priv,u8 * mac,s8 snr,s8 nflr)1393 void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1394 u8 *mac, s8 snr, s8 nflr)
1395 {
1396 struct mwifiex_auto_tdls_peer *peer;
1397
1398 if (!priv->adapter->auto_tdls)
1399 return;
1400
1401 spin_lock_bh(&priv->auto_tdls_lock);
1402 list_for_each_entry(peer, &priv->auto_tdls_list, list) {
1403 if (!memcmp(peer->mac_addr, mac, ETH_ALEN)) {
1404 peer->rssi = nflr - snr;
1405 peer->rssi_jiffies = jiffies;
1406 break;
1407 }
1408 }
1409 spin_unlock_bh(&priv->auto_tdls_lock);
1410 }
1411
mwifiex_check_auto_tdls(struct timer_list * t)1412 void mwifiex_check_auto_tdls(struct timer_list *t)
1413 {
1414 struct mwifiex_private *priv = timer_container_of(priv, t,
1415 auto_tdls_timer);
1416 struct mwifiex_auto_tdls_peer *tdls_peer;
1417 u16 reason = WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED;
1418
1419 if (WARN_ON_ONCE(!priv || !priv->adapter)) {
1420 pr_err("mwifiex: %s: adapter or private structure is NULL\n",
1421 __func__);
1422 return;
1423 }
1424
1425 if (unlikely(!priv->adapter->auto_tdls))
1426 return;
1427
1428 if (!priv->auto_tdls_timer_active) {
1429 mwifiex_dbg(priv->adapter, INFO,
1430 "auto TDLS timer inactive; return");
1431 return;
1432 }
1433
1434 priv->check_tdls_tx = false;
1435
1436 spin_lock_bh(&priv->auto_tdls_lock);
1437 list_for_each_entry(tdls_peer, &priv->auto_tdls_list, list) {
1438 if (time_after(jiffies, tdls_peer->rssi_jiffies +
1439 MWIFIEX_AUTO_TDLS_IDLE_TIME * HZ)) {
1440 tdls_peer->rssi = 0;
1441 tdls_peer->do_discover = true;
1442 priv->check_tdls_tx = true;
1443 }
1444
1445 if (((tdls_peer->rssi >= MWIFIEX_TDLS_RSSI_LOW) ||
1446 !tdls_peer->rssi) &&
1447 mwifiex_is_tdls_link_setup(tdls_peer->tdls_status)) {
1448 tdls_peer->tdls_status = TDLS_LINK_TEARDOWN;
1449 mwifiex_dbg(priv->adapter, MSG,
1450 "teardown TDLS link,peer=%pM rssi=%d\n",
1451 tdls_peer->mac_addr, -tdls_peer->rssi);
1452 tdls_peer->do_discover = true;
1453 priv->check_tdls_tx = true;
1454 cfg80211_tdls_oper_request(priv->netdev,
1455 tdls_peer->mac_addr,
1456 NL80211_TDLS_TEARDOWN,
1457 reason, GFP_ATOMIC);
1458 } else if (tdls_peer->rssi &&
1459 tdls_peer->rssi <= MWIFIEX_TDLS_RSSI_HIGH &&
1460 tdls_peer->tdls_status == TDLS_NOT_SETUP &&
1461 tdls_peer->failure_count <
1462 MWIFIEX_TDLS_MAX_FAIL_COUNT) {
1463 priv->check_tdls_tx = true;
1464 mwifiex_dbg(priv->adapter, INFO,
1465 "check TDLS with peer=%pM\t"
1466 "rssi=%d\n", tdls_peer->mac_addr,
1467 tdls_peer->rssi);
1468 }
1469 }
1470 spin_unlock_bh(&priv->auto_tdls_lock);
1471
1472 mod_timer(&priv->auto_tdls_timer,
1473 jiffies + msecs_to_jiffies(MWIFIEX_TIMER_10S));
1474 }
1475
mwifiex_setup_auto_tdls_timer(struct mwifiex_private * priv)1476 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv)
1477 {
1478 timer_setup(&priv->auto_tdls_timer, mwifiex_check_auto_tdls, 0);
1479 priv->auto_tdls_timer_active = true;
1480 mod_timer(&priv->auto_tdls_timer,
1481 jiffies + msecs_to_jiffies(MWIFIEX_TIMER_10S));
1482 }
1483
mwifiex_clean_auto_tdls(struct mwifiex_private * priv)1484 void mwifiex_clean_auto_tdls(struct mwifiex_private *priv)
1485 {
1486 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
1487 priv->adapter->auto_tdls &&
1488 priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
1489 priv->auto_tdls_timer_active = false;
1490 timer_delete(&priv->auto_tdls_timer);
1491 mwifiex_flush_auto_tdls_list(priv);
1492 }
1493 }
1494
mwifiex_config_tdls(struct mwifiex_private * priv,u8 enable)1495 static int mwifiex_config_tdls(struct mwifiex_private *priv, u8 enable)
1496 {
1497 struct mwifiex_tdls_config config;
1498
1499 config.enable = cpu_to_le16(enable);
1500 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_CONFIG,
1501 ACT_TDLS_CS_ENABLE_CONFIG, 0, &config, true);
1502 }
1503
mwifiex_config_tdls_enable(struct mwifiex_private * priv)1504 int mwifiex_config_tdls_enable(struct mwifiex_private *priv)
1505 {
1506 return mwifiex_config_tdls(priv, true);
1507 }
1508
mwifiex_config_tdls_disable(struct mwifiex_private * priv)1509 int mwifiex_config_tdls_disable(struct mwifiex_private *priv)
1510 {
1511 return mwifiex_config_tdls(priv, false);
1512 }
1513
mwifiex_config_tdls_cs_params(struct mwifiex_private * priv)1514 int mwifiex_config_tdls_cs_params(struct mwifiex_private *priv)
1515 {
1516 struct mwifiex_tdls_config_cs_params config_tdls_cs_params;
1517
1518 config_tdls_cs_params.unit_time = MWIFIEX_DEF_CS_UNIT_TIME;
1519 config_tdls_cs_params.thr_otherlink = MWIFIEX_DEF_CS_THR_OTHERLINK;
1520 config_tdls_cs_params.thr_directlink = MWIFIEX_DEF_THR_DIRECTLINK;
1521
1522 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_CONFIG,
1523 ACT_TDLS_CS_PARAMS, 0,
1524 &config_tdls_cs_params, true);
1525 }
1526
mwifiex_stop_tdls_cs(struct mwifiex_private * priv,const u8 * peer_mac)1527 int mwifiex_stop_tdls_cs(struct mwifiex_private *priv, const u8 *peer_mac)
1528 {
1529 struct mwifiex_tdls_stop_cs_params stop_tdls_cs_params;
1530
1531 ether_addr_copy(stop_tdls_cs_params.peer_mac, peer_mac);
1532
1533 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_CONFIG,
1534 ACT_TDLS_CS_STOP, 0,
1535 &stop_tdls_cs_params, true);
1536 }
1537
mwifiex_start_tdls_cs(struct mwifiex_private * priv,const u8 * peer_mac,u8 primary_chan,u8 second_chan_offset,u8 band)1538 int mwifiex_start_tdls_cs(struct mwifiex_private *priv, const u8 *peer_mac,
1539 u8 primary_chan, u8 second_chan_offset, u8 band)
1540 {
1541 struct mwifiex_tdls_init_cs_params start_tdls_cs_params;
1542
1543 ether_addr_copy(start_tdls_cs_params.peer_mac, peer_mac);
1544 start_tdls_cs_params.primary_chan = primary_chan;
1545 start_tdls_cs_params.second_chan_offset = second_chan_offset;
1546 start_tdls_cs_params.band = band;
1547
1548 start_tdls_cs_params.switch_time = cpu_to_le16(MWIFIEX_DEF_CS_TIME);
1549 start_tdls_cs_params.switch_timeout =
1550 cpu_to_le16(MWIFIEX_DEF_CS_TIMEOUT);
1551 start_tdls_cs_params.reg_class = MWIFIEX_DEF_CS_REG_CLASS;
1552 start_tdls_cs_params.periodicity = MWIFIEX_DEF_CS_PERIODICITY;
1553
1554 return mwifiex_send_cmd(priv, HostCmd_CMD_TDLS_CONFIG,
1555 ACT_TDLS_CS_INIT, 0,
1556 &start_tdls_cs_params, true);
1557 }
1558