2 * Marvell Wireless LAN device driver: CFG80211
4 * Copyright (C) 2011-2014, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. 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 by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
25 static char *reg_alpha2
;
26 module_param(reg_alpha2
, charp
, 0);
28 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits
[] = {
30 .max
= 3, .types
= BIT(NL80211_IFTYPE_STATION
) |
31 BIT(NL80211_IFTYPE_P2P_GO
) |
32 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
33 BIT(NL80211_IFTYPE_AP
),
37 static const struct ieee80211_iface_combination
38 mwifiex_iface_comb_ap_sta
= {
39 .limits
= mwifiex_ap_sta_limits
,
40 .num_different_channels
= 1,
41 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
42 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
43 .beacon_int_infra_match
= true,
44 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
45 BIT(NL80211_CHAN_WIDTH_20
) |
46 BIT(NL80211_CHAN_WIDTH_40
),
49 static const struct ieee80211_iface_combination
50 mwifiex_iface_comb_ap_sta_vht
= {
51 .limits
= mwifiex_ap_sta_limits
,
52 .num_different_channels
= 1,
53 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
54 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
55 .beacon_int_infra_match
= true,
56 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
57 BIT(NL80211_CHAN_WIDTH_20
) |
58 BIT(NL80211_CHAN_WIDTH_40
) |
59 BIT(NL80211_CHAN_WIDTH_80
),
63 ieee80211_iface_combination mwifiex_iface_comb_ap_sta_drcs
= {
64 .limits
= mwifiex_ap_sta_limits
,
65 .num_different_channels
= 2,
66 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
67 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
68 .beacon_int_infra_match
= true,
72 * This function maps the nl802.11 channel type into driver channel type.
74 * The mapping is as follows -
75 * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE
76 * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE
77 * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE
78 * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW
79 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE
81 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
)
84 case NL80211_CHAN_NO_HT
:
85 case NL80211_CHAN_HT20
:
86 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
87 case NL80211_CHAN_HT40PLUS
:
88 return IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
89 case NL80211_CHAN_HT40MINUS
:
90 return IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
92 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
96 /* This function maps IEEE HT secondary channel type to NL80211 channel type
98 u8
mwifiex_sec_chan_offset_to_chan_type(u8 second_chan_offset
)
100 switch (second_chan_offset
) {
101 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
102 return NL80211_CHAN_HT20
;
103 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
104 return NL80211_CHAN_HT40PLUS
;
105 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
106 return NL80211_CHAN_HT40MINUS
;
108 return NL80211_CHAN_HT20
;
113 * This function checks whether WEP is set.
116 mwifiex_is_alg_wep(u32 cipher
)
119 case WLAN_CIPHER_SUITE_WEP40
:
120 case WLAN_CIPHER_SUITE_WEP104
:
130 * This function retrieves the private structure from kernel wiphy structure.
132 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
134 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
138 * CFG802.11 operation handler to delete a network key.
141 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
142 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
144 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
145 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
146 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
148 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
149 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
153 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
158 * This function forms an skb for management frame.
161 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
163 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
165 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
167 pkt_len
= len
+ ETH_ALEN
;
169 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
170 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
171 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
173 memcpy(skb_push(skb
, sizeof(tx_control
)),
174 &tx_control
, sizeof(tx_control
));
176 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
178 /* Add packet data and address4 */
179 skb_put_data(skb
, buf
, sizeof(struct ieee80211_hdr_3addr
));
180 skb_put_data(skb
, addr
, ETH_ALEN
);
181 skb_put_data(skb
, buf
+ sizeof(struct ieee80211_hdr_3addr
),
182 len
- sizeof(struct ieee80211_hdr_3addr
));
184 skb
->priority
= LOW_PRIO_TID
;
185 __net_timestamp(skb
);
191 * CFG802.11 operation handler to transmit a management frame.
194 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
195 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
197 const u8
*buf
= params
->buf
;
198 size_t len
= params
->len
;
201 const struct ieee80211_mgmt
*mgmt
;
202 struct mwifiex_txinfo
*tx_info
;
203 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
206 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
210 mgmt
= (const struct ieee80211_mgmt
*)buf
;
211 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
212 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
213 /* Since we support offload probe resp, we need to skip probe
214 * resp in AP or GO mode */
215 mwifiex_dbg(priv
->adapter
, INFO
,
216 "info: skip to send probe resp in AP or GO mode\n");
220 pkt_len
= len
+ ETH_ALEN
;
221 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
222 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
223 pkt_len
+ sizeof(pkt_len
));
226 mwifiex_dbg(priv
->adapter
, ERROR
,
227 "allocate skb failed for management frame\n");
231 tx_info
= MWIFIEX_SKB_TXCB(skb
);
232 memset(tx_info
, 0, sizeof(*tx_info
));
233 tx_info
->bss_num
= priv
->bss_num
;
234 tx_info
->bss_type
= priv
->bss_type
;
235 tx_info
->pkt_len
= pkt_len
;
237 mwifiex_form_mgmt_frame(skb
, buf
, len
);
238 *cookie
= prandom_u32() | 1;
240 if (ieee80211_is_action(mgmt
->frame_control
))
241 skb
= mwifiex_clone_skb_for_tx_status(priv
,
243 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
245 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
248 mwifiex_queue_tx_pkt(priv
, skb
);
250 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
255 * CFG802.11 operation handler to register a mgmt frame.
258 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
259 struct wireless_dev
*wdev
,
260 u16 frame_type
, bool reg
)
262 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
266 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
268 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
270 if (mask
!= priv
->mgmt_frame_mask
) {
271 priv
->mgmt_frame_mask
= mask
;
272 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
273 HostCmd_ACT_GEN_SET
, 0,
274 &priv
->mgmt_frame_mask
, false);
275 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
280 * CFG802.11 operation handler to remain on channel.
283 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
284 struct wireless_dev
*wdev
,
285 struct ieee80211_channel
*chan
,
286 unsigned int duration
, u64
*cookie
)
288 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
291 if (!chan
|| !cookie
) {
292 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
296 if (priv
->roc_cfg
.cookie
) {
297 mwifiex_dbg(priv
->adapter
, INFO
,
298 "info: ongoing ROC, cookie = 0x%llx\n",
299 priv
->roc_cfg
.cookie
);
303 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
307 *cookie
= prandom_u32() | 1;
308 priv
->roc_cfg
.cookie
= *cookie
;
309 priv
->roc_cfg
.chan
= *chan
;
311 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
312 duration
, GFP_ATOMIC
);
314 mwifiex_dbg(priv
->adapter
, INFO
,
315 "info: ROC, cookie = 0x%llx\n", *cookie
);
322 * CFG802.11 operation handler to cancel remain on channel.
325 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
326 struct wireless_dev
*wdev
, u64 cookie
)
328 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
331 if (cookie
!= priv
->roc_cfg
.cookie
)
334 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
335 &priv
->roc_cfg
.chan
, 0);
338 cfg80211_remain_on_channel_expired(wdev
, cookie
,
342 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
344 mwifiex_dbg(priv
->adapter
, INFO
,
345 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
352 * CFG802.11 operation handler to set Tx power.
355 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
356 struct wireless_dev
*wdev
,
357 enum nl80211_tx_power_setting type
,
360 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
361 struct mwifiex_private
*priv
;
362 struct mwifiex_power_cfg power_cfg
;
363 int dbm
= MBM_TO_DBM(mbm
);
365 if (type
== NL80211_TX_POWER_FIXED
) {
366 power_cfg
.is_power_auto
= 0;
367 power_cfg
.power_level
= dbm
;
369 power_cfg
.is_power_auto
= 1;
372 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
374 return mwifiex_set_tx_power(priv
, &power_cfg
);
378 * CFG802.11 operation handler to get Tx power.
381 mwifiex_cfg80211_get_tx_power(struct wiphy
*wiphy
,
382 struct wireless_dev
*wdev
,
385 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
386 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
387 MWIFIEX_BSS_ROLE_ANY
);
388 int ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_RF_TX_PWR
,
389 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
394 /* tx_power_level is set in HostCmd_CMD_RF_TX_PWR command handler */
395 *dbm
= priv
->tx_power_level
;
401 * CFG802.11 operation handler to set Power Save option.
403 * The timeout value, if provided, is currently ignored.
406 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
407 struct net_device
*dev
,
408 bool enabled
, int timeout
)
410 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
414 mwifiex_dbg(priv
->adapter
, INFO
,
415 "info: ignore timeout value for IEEE Power Save\n");
419 return mwifiex_drv_set_power(priv
, &ps_mode
);
423 * CFG802.11 operation handler to set the default network key.
426 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
427 u8 key_index
, bool unicast
,
430 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
432 /* Return if WEP key not configured */
433 if (!priv
->sec_info
.wep_enabled
)
436 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
437 priv
->wep_key_curr_index
= key_index
;
438 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
440 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
448 * CFG802.11 operation handler to add a network key.
451 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
452 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
453 struct key_params
*params
)
455 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
456 struct mwifiex_wep_key
*wep_key
;
457 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
458 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
460 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
461 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
462 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
463 if (params
->key
&& params
->key_len
) {
464 wep_key
= &priv
->wep_key
[key_index
];
465 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
466 memcpy(wep_key
->key_material
, params
->key
,
468 wep_key
->key_index
= key_index
;
469 wep_key
->key_length
= params
->key_len
;
470 priv
->sec_info
.wep_enabled
= 1;
475 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
476 key_index
, peer_mac
, 0)) {
477 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
485 * CFG802.11 operation handler to set default mgmt key.
488 mwifiex_cfg80211_set_default_mgmt_key(struct wiphy
*wiphy
,
489 struct net_device
*netdev
,
492 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
493 struct mwifiex_ds_encrypt_key encrypt_key
;
495 wiphy_dbg(wiphy
, "set default mgmt key, key index=%d\n", key_index
);
497 memset(&encrypt_key
, 0, sizeof(struct mwifiex_ds_encrypt_key
));
498 encrypt_key
.key_len
= WLAN_KEY_LEN_CCMP
;
499 encrypt_key
.key_index
= key_index
;
500 encrypt_key
.is_igtk_def_key
= true;
501 eth_broadcast_addr(encrypt_key
.mac_addr
);
503 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
504 HostCmd_ACT_GEN_SET
, true, &encrypt_key
, true);
508 * This function sends domain information to the firmware.
510 * The following information are passed to the firmware -
512 * - Sub bands (first channel, number of channels, maximum Tx power)
514 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
516 u8 no_of_triplet
= 0;
517 struct ieee80211_country_ie_triplet
*t
;
518 u8 no_of_parsed_chan
= 0;
519 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
521 enum nl80211_band band
;
522 struct ieee80211_supported_band
*sband
;
523 struct ieee80211_channel
*ch
;
524 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
525 struct mwifiex_private
*priv
;
526 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
528 /* Set country code */
529 domain_info
->country_code
[0] = adapter
->country_code
[0];
530 domain_info
->country_code
[1] = adapter
->country_code
[1];
531 domain_info
->country_code
[2] = ' ';
533 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
534 if (!wiphy
->bands
[band
]) {
535 mwifiex_dbg(adapter
, ERROR
,
536 "11D: setting domain info in FW\n");
540 sband
= wiphy
->bands
[band
];
542 for (i
= 0; i
< sband
->n_channels
; i
++) {
543 ch
= &sband
->channels
[i
];
544 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
549 first_chan
= (u32
) ch
->hw_value
;
550 next_chan
= first_chan
;
551 max_pwr
= ch
->max_power
;
552 no_of_parsed_chan
= 1;
556 if (ch
->hw_value
== next_chan
+ 1 &&
557 ch
->max_power
== max_pwr
) {
561 t
= &domain_info
->triplet
[no_of_triplet
];
562 t
->chans
.first_channel
= first_chan
;
563 t
->chans
.num_channels
= no_of_parsed_chan
;
564 t
->chans
.max_power
= max_pwr
;
566 first_chan
= (u32
) ch
->hw_value
;
567 next_chan
= first_chan
;
568 max_pwr
= ch
->max_power
;
569 no_of_parsed_chan
= 1;
574 t
= &domain_info
->triplet
[no_of_triplet
];
575 t
->chans
.first_channel
= first_chan
;
576 t
->chans
.num_channels
= no_of_parsed_chan
;
577 t
->chans
.max_power
= max_pwr
;
581 domain_info
->no_of_triplet
= no_of_triplet
;
583 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
585 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
586 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
587 mwifiex_dbg(adapter
, INFO
,
588 "11D: setting domain info in FW\n");
595 static void mwifiex_reg_apply_radar_flags(struct wiphy
*wiphy
)
597 struct ieee80211_supported_band
*sband
;
598 struct ieee80211_channel
*chan
;
601 if (!wiphy
->bands
[NL80211_BAND_5GHZ
])
603 sband
= wiphy
->bands
[NL80211_BAND_5GHZ
];
605 for (i
= 0; i
< sband
->n_channels
; i
++) {
606 chan
= &sband
->channels
[i
];
607 if ((!(chan
->flags
& IEEE80211_CHAN_DISABLED
)) &&
608 (chan
->flags
& IEEE80211_CHAN_RADAR
))
609 chan
->flags
|= IEEE80211_CHAN_NO_IR
;
614 * CFG802.11 regulatory domain callback function.
616 * This function is called when the regulatory domain is changed due to the
617 * following reasons -
619 * - Set by system core
621 * - Set bt Country IE
623 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
624 struct regulatory_request
*request
)
626 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
627 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
628 MWIFIEX_BSS_ROLE_ANY
);
629 mwifiex_dbg(adapter
, INFO
,
630 "info: cfg80211 regulatory domain callback for %c%c\n",
631 request
->alpha2
[0], request
->alpha2
[1]);
632 mwifiex_reg_apply_radar_flags(wiphy
);
634 switch (request
->initiator
) {
635 case NL80211_REGDOM_SET_BY_DRIVER
:
636 case NL80211_REGDOM_SET_BY_CORE
:
637 case NL80211_REGDOM_SET_BY_USER
:
638 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
641 mwifiex_dbg(adapter
, ERROR
,
642 "unknown regdom initiator: %d\n",
647 /* Don't send world or same regdom info to firmware */
648 if (strncmp(request
->alpha2
, "00", 2) &&
649 strncmp(request
->alpha2
, adapter
->country_code
,
650 sizeof(request
->alpha2
))) {
651 memcpy(adapter
->country_code
, request
->alpha2
,
652 sizeof(request
->alpha2
));
653 mwifiex_send_domain_info_cmd_fw(wiphy
);
654 mwifiex_dnld_txpwr_table(priv
);
659 * This function sets the fragmentation threshold.
661 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
662 * and MWIFIEX_FRAG_MAX_VALUE.
665 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
667 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
668 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
669 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
671 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
672 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
677 * This function sets the RTS threshold.
679 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
680 * and MWIFIEX_RTS_MAX_VALUE.
683 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
685 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
686 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
688 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
689 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
694 * CFG802.11 operation handler to set wiphy parameters.
696 * This function can be used to set the RTS threshold and the
697 * Fragmentation threshold of the driver.
700 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
702 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
703 struct mwifiex_private
*priv
;
704 struct mwifiex_uap_bss_param
*bss_cfg
;
707 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
709 switch (priv
->bss_role
) {
710 case MWIFIEX_BSS_ROLE_UAP
:
711 if (priv
->bss_started
) {
712 mwifiex_dbg(adapter
, ERROR
,
713 "cannot change wiphy params when bss started");
717 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
721 mwifiex_set_sys_config_invalid_data(bss_cfg
);
723 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
724 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
725 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
726 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
727 if (changed
& WIPHY_PARAM_RETRY_LONG
)
728 bss_cfg
->retry_limit
= wiphy
->retry_long
;
730 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
732 UAP_BSS_PARAMS_I
, bss_cfg
,
737 mwifiex_dbg(adapter
, ERROR
,
738 "Failed to set wiphy phy params\n");
743 case MWIFIEX_BSS_ROLE_STA
:
744 if (priv
->media_connected
) {
745 mwifiex_dbg(adapter
, ERROR
,
746 "cannot change wiphy params when connected");
749 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
750 ret
= mwifiex_set_rts(priv
,
751 wiphy
->rts_threshold
);
755 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
756 ret
= mwifiex_set_frag(priv
,
757 wiphy
->frag_threshold
);
768 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
770 u16 mode
= P2P_MODE_DISABLE
;
772 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
773 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
780 * This function initializes the functionalities for P2P client.
781 * The P2P client initialization sequence is:
782 * disable -> device -> client
785 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
789 if (mwifiex_cfg80211_deinit_p2p(priv
))
792 mode
= P2P_MODE_DEVICE
;
793 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
794 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
797 mode
= P2P_MODE_CLIENT
;
798 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
799 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
806 * This function initializes the functionalities for P2P GO.
807 * The P2P GO initialization sequence is:
808 * disable -> device -> GO
811 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
815 if (mwifiex_cfg80211_deinit_p2p(priv
))
818 mode
= P2P_MODE_DEVICE
;
819 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
820 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
824 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
825 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
831 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
833 struct mwifiex_adapter
*adapter
= priv
->adapter
;
836 priv
->mgmt_frame_mask
= 0;
837 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
838 HostCmd_ACT_GEN_SET
, 0,
839 &priv
->mgmt_frame_mask
, false)) {
840 mwifiex_dbg(adapter
, ERROR
,
841 "could not unregister mgmt frame rx\n");
845 mwifiex_deauthenticate(priv
, NULL
);
847 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
848 adapter
->main_locked
= true;
849 if (adapter
->mwifiex_processing
) {
850 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
851 flush_workqueue(adapter
->workqueue
);
853 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
856 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
857 adapter
->rx_locked
= true;
858 if (adapter
->rx_processing
) {
859 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
860 flush_workqueue(adapter
->rx_workqueue
);
862 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
865 mwifiex_free_priv(priv
);
866 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
867 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
868 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
874 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
875 struct net_device
*dev
,
876 enum nl80211_iftype type
)
878 struct mwifiex_adapter
*adapter
= priv
->adapter
;
881 mwifiex_init_priv(priv
);
883 priv
->bss_mode
= type
;
884 priv
->wdev
.iftype
= type
;
886 mwifiex_init_priv_params(priv
, priv
->netdev
);
887 priv
->bss_started
= 0;
890 case NL80211_IFTYPE_STATION
:
891 case NL80211_IFTYPE_ADHOC
:
892 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
893 MWIFIEX_BSS_TYPE_STA
);
894 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
896 case NL80211_IFTYPE_P2P_CLIENT
:
897 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
898 MWIFIEX_BSS_TYPE_P2P
);
899 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
901 case NL80211_IFTYPE_P2P_GO
:
902 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
903 MWIFIEX_BSS_TYPE_P2P
);
904 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
906 case NL80211_IFTYPE_AP
:
907 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
908 MWIFIEX_BSS_TYPE_UAP
);
909 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
912 mwifiex_dbg(adapter
, ERROR
,
913 "%s: changing to %d not supported\n",
918 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
919 adapter
->main_locked
= false;
920 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
922 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
923 adapter
->rx_locked
= false;
924 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
930 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
931 enum nl80211_iftype curr_iftype
,
932 enum nl80211_iftype type
,
933 struct vif_params
*params
)
935 struct mwifiex_private
*priv
;
936 struct mwifiex_adapter
*adapter
;
938 priv
= mwifiex_netdev_get_priv(dev
);
943 adapter
= priv
->adapter
;
945 if (adapter
->curr_iface_comb
.p2p_intf
==
946 adapter
->iface_limit
.p2p_intf
) {
947 mwifiex_dbg(adapter
, ERROR
,
948 "cannot create multiple P2P ifaces\n");
952 mwifiex_dbg(adapter
, INFO
,
953 "%s: changing role to p2p\n", dev
->name
);
955 if (mwifiex_deinit_priv_params(priv
))
957 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
961 case NL80211_IFTYPE_P2P_CLIENT
:
962 if (mwifiex_cfg80211_init_p2p_client(priv
))
965 case NL80211_IFTYPE_P2P_GO
:
966 if (mwifiex_cfg80211_init_p2p_go(priv
))
970 mwifiex_dbg(adapter
, ERROR
,
971 "%s: changing to %d not supported\n",
976 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
977 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
980 if (mwifiex_sta_init_cmd(priv
, false, false))
983 switch (curr_iftype
) {
984 case NL80211_IFTYPE_STATION
:
985 case NL80211_IFTYPE_ADHOC
:
986 adapter
->curr_iface_comb
.sta_intf
--;
988 case NL80211_IFTYPE_AP
:
989 adapter
->curr_iface_comb
.uap_intf
--;
995 adapter
->curr_iface_comb
.p2p_intf
++;
996 dev
->ieee80211_ptr
->iftype
= type
;
1002 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
1003 enum nl80211_iftype curr_iftype
,
1004 enum nl80211_iftype type
,
1005 struct vif_params
*params
)
1007 struct mwifiex_private
*priv
;
1008 struct mwifiex_adapter
*adapter
;
1010 priv
= mwifiex_netdev_get_priv(dev
);
1015 adapter
= priv
->adapter
;
1017 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
1018 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
1019 (adapter
->curr_iface_comb
.sta_intf
==
1020 adapter
->iface_limit
.sta_intf
)) {
1021 mwifiex_dbg(adapter
, ERROR
,
1022 "cannot create multiple station/adhoc ifaces\n");
1026 if (type
== NL80211_IFTYPE_STATION
)
1027 mwifiex_dbg(adapter
, INFO
,
1028 "%s: changing role to station\n", dev
->name
);
1030 mwifiex_dbg(adapter
, INFO
,
1031 "%s: changing role to adhoc\n", dev
->name
);
1033 if (mwifiex_deinit_priv_params(priv
))
1035 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1037 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1038 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1040 if (mwifiex_sta_init_cmd(priv
, false, false))
1043 switch (curr_iftype
) {
1044 case NL80211_IFTYPE_P2P_CLIENT
:
1045 case NL80211_IFTYPE_P2P_GO
:
1046 adapter
->curr_iface_comb
.p2p_intf
--;
1048 case NL80211_IFTYPE_AP
:
1049 adapter
->curr_iface_comb
.uap_intf
--;
1055 adapter
->curr_iface_comb
.sta_intf
++;
1056 dev
->ieee80211_ptr
->iftype
= type
;
1061 mwifiex_change_vif_to_ap(struct net_device
*dev
,
1062 enum nl80211_iftype curr_iftype
,
1063 enum nl80211_iftype type
,
1064 struct vif_params
*params
)
1066 struct mwifiex_private
*priv
;
1067 struct mwifiex_adapter
*adapter
;
1069 priv
= mwifiex_netdev_get_priv(dev
);
1074 adapter
= priv
->adapter
;
1076 if (adapter
->curr_iface_comb
.uap_intf
==
1077 adapter
->iface_limit
.uap_intf
) {
1078 mwifiex_dbg(adapter
, ERROR
,
1079 "cannot create multiple AP ifaces\n");
1083 mwifiex_dbg(adapter
, INFO
,
1084 "%s: changing role to AP\n", dev
->name
);
1086 if (mwifiex_deinit_priv_params(priv
))
1088 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1090 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1091 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1093 if (mwifiex_sta_init_cmd(priv
, false, false))
1096 switch (curr_iftype
) {
1097 case NL80211_IFTYPE_P2P_CLIENT
:
1098 case NL80211_IFTYPE_P2P_GO
:
1099 adapter
->curr_iface_comb
.p2p_intf
--;
1101 case NL80211_IFTYPE_STATION
:
1102 case NL80211_IFTYPE_ADHOC
:
1103 adapter
->curr_iface_comb
.sta_intf
--;
1109 adapter
->curr_iface_comb
.uap_intf
++;
1110 dev
->ieee80211_ptr
->iftype
= type
;
1114 * CFG802.11 operation handler to change interface type.
1117 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1118 struct net_device
*dev
,
1119 enum nl80211_iftype type
,
1120 struct vif_params
*params
)
1122 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1123 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1125 switch (curr_iftype
) {
1126 case NL80211_IFTYPE_ADHOC
:
1128 case NL80211_IFTYPE_STATION
:
1129 priv
->bss_mode
= type
;
1130 priv
->sec_info
.authentication_mode
=
1131 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1132 dev
->ieee80211_ptr
->iftype
= type
;
1133 mwifiex_deauthenticate(priv
, NULL
);
1134 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1135 HostCmd_ACT_GEN_SET
, 0, NULL
,
1137 case NL80211_IFTYPE_P2P_CLIENT
:
1138 case NL80211_IFTYPE_P2P_GO
:
1139 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1141 case NL80211_IFTYPE_AP
:
1142 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1144 case NL80211_IFTYPE_UNSPECIFIED
:
1145 mwifiex_dbg(priv
->adapter
, INFO
,
1146 "%s: kept type as IBSS\n", dev
->name
);
1147 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1150 mwifiex_dbg(priv
->adapter
, ERROR
,
1151 "%s: changing to %d not supported\n",
1156 case NL80211_IFTYPE_STATION
:
1158 case NL80211_IFTYPE_ADHOC
:
1159 priv
->bss_mode
= type
;
1160 priv
->sec_info
.authentication_mode
=
1161 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1162 dev
->ieee80211_ptr
->iftype
= type
;
1163 mwifiex_deauthenticate(priv
, NULL
);
1164 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1165 HostCmd_ACT_GEN_SET
, 0, NULL
,
1167 case NL80211_IFTYPE_P2P_CLIENT
:
1168 case NL80211_IFTYPE_P2P_GO
:
1169 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1171 case NL80211_IFTYPE_AP
:
1172 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1174 case NL80211_IFTYPE_UNSPECIFIED
:
1175 mwifiex_dbg(priv
->adapter
, INFO
,
1176 "%s: kept type as STA\n", dev
->name
);
1177 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1180 mwifiex_dbg(priv
->adapter
, ERROR
,
1181 "%s: changing to %d not supported\n",
1186 case NL80211_IFTYPE_AP
:
1188 case NL80211_IFTYPE_ADHOC
:
1189 case NL80211_IFTYPE_STATION
:
1190 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1193 case NL80211_IFTYPE_P2P_CLIENT
:
1194 case NL80211_IFTYPE_P2P_GO
:
1195 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1197 case NL80211_IFTYPE_UNSPECIFIED
:
1198 mwifiex_dbg(priv
->adapter
, INFO
,
1199 "%s: kept type as AP\n", dev
->name
);
1200 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1203 mwifiex_dbg(priv
->adapter
, ERROR
,
1204 "%s: changing to %d not supported\n",
1209 case NL80211_IFTYPE_P2P_CLIENT
:
1210 case NL80211_IFTYPE_P2P_GO
:
1212 case NL80211_IFTYPE_STATION
:
1213 if (mwifiex_cfg80211_deinit_p2p(priv
))
1215 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1216 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1217 dev
->ieee80211_ptr
->iftype
= type
;
1218 if (mwifiex_deinit_priv_params(priv
))
1220 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1222 if (mwifiex_sta_init_cmd(priv
, false, false))
1225 case NL80211_IFTYPE_ADHOC
:
1226 if (mwifiex_cfg80211_deinit_p2p(priv
))
1228 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1231 case NL80211_IFTYPE_AP
:
1232 if (mwifiex_cfg80211_deinit_p2p(priv
))
1234 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1236 case NL80211_IFTYPE_UNSPECIFIED
:
1237 mwifiex_dbg(priv
->adapter
, INFO
,
1238 "%s: kept type as P2P\n", dev
->name
);
1239 case NL80211_IFTYPE_P2P_CLIENT
:
1240 case NL80211_IFTYPE_P2P_GO
:
1243 mwifiex_dbg(priv
->adapter
, ERROR
,
1244 "%s: changing to %d not supported\n",
1250 mwifiex_dbg(priv
->adapter
, ERROR
,
1251 "%s: unknown iftype: %d\n",
1252 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1261 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1262 struct rate_info
*rate
)
1264 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1266 if (adapter
->is_hw_11ac_capable
) {
1267 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1268 if (tx_htinfo
& BIT(0)) {
1270 rate
->mcs
= priv
->tx_rate
;
1271 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1273 if (tx_htinfo
& BIT(1)) {
1275 rate
->mcs
= priv
->tx_rate
& 0x0F;
1276 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1279 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1281 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1283 rate
->bw
= RATE_INFO_BW_20
;
1286 rate
->bw
= RATE_INFO_BW_40
;
1289 rate
->bw
= RATE_INFO_BW_80
;
1291 case (BIT(3) | BIT(2)):
1292 rate
->bw
= RATE_INFO_BW_160
;
1296 if (tx_htinfo
& BIT(4))
1297 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1299 if ((priv
->tx_rate
>> 4) == 1)
1306 * Bit 0 in tx_htinfo indicates that current Tx rate
1307 * is 11n rate. Valid MCS index values for us are 0 to 15.
1309 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1310 rate
->mcs
= priv
->tx_rate
;
1311 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1312 rate
->bw
= RATE_INFO_BW_20
;
1313 if (tx_htinfo
& BIT(1))
1314 rate
->bw
= RATE_INFO_BW_40
;
1315 if (tx_htinfo
& BIT(2))
1316 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1322 * This function dumps the station information on a buffer.
1324 * The following information are shown -
1325 * - Total bytes transmitted
1326 * - Total bytes received
1327 * - Total packets transmitted
1328 * - Total packets received
1329 * - Signal quality level
1330 * - Transmission rate
1333 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1334 struct mwifiex_sta_node
*node
,
1335 struct station_info
*sinfo
)
1339 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1340 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1341 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1342 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1344 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1348 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1349 BIT(NL80211_STA_INFO_TX_FAILED
);
1350 sinfo
->inactive_time
=
1351 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1353 sinfo
->signal
= node
->stats
.rssi
;
1354 sinfo
->signal_avg
= node
->stats
.rssi
;
1355 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1356 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1357 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1358 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1359 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1361 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1363 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1368 /* Get signal information from the firmware */
1369 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1370 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1371 mwifiex_dbg(priv
->adapter
, ERROR
,
1372 "failed to get signal information\n");
1376 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1377 mwifiex_dbg(priv
->adapter
, ERROR
,
1378 "getting data rate error\n");
1382 /* Get DTIM period information from firmware */
1383 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1384 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1385 &priv
->dtim_period
, true);
1387 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1389 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1390 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1391 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1392 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1393 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1394 sinfo
->signal
= priv
->bcn_rssi_avg
;
1395 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1396 sinfo
->txrate
.legacy
= rate
* 5;
1398 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1399 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1400 sinfo
->bss_param
.flags
= 0;
1401 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1402 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1403 sinfo
->bss_param
.flags
|=
1404 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1405 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1406 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1407 sinfo
->bss_param
.flags
|=
1408 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1409 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1410 sinfo
->bss_param
.beacon_interval
=
1411 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1418 * CFG802.11 operation handler to get station information.
1420 * This function only works in connected mode, and dumps the
1421 * requested station information, if available.
1424 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1425 const u8
*mac
, struct station_info
*sinfo
)
1427 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1429 if (!priv
->media_connected
)
1431 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1434 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1438 * CFG802.11 operation handler to dump station information.
1441 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1442 int idx
, u8
*mac
, struct station_info
*sinfo
)
1444 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1445 static struct mwifiex_sta_node
*node
;
1447 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1448 priv
->media_connected
&& idx
== 0) {
1449 ether_addr_copy(mac
, priv
->cfg_bssid
);
1450 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1451 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1452 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1453 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1455 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1460 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1461 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1462 ether_addr_copy(mac
, node
->mac_addr
);
1463 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1471 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1472 int idx
, struct survey_info
*survey
)
1474 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1475 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1476 enum nl80211_band band
;
1478 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1480 memset(survey
, 0, sizeof(struct survey_info
));
1482 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1483 priv
->media_connected
&& idx
== 0) {
1484 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1485 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1487 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1488 survey
->channel
= ieee80211_get_channel(wiphy
,
1489 ieee80211_channel_to_frequency(chan
, band
));
1491 if (priv
->bcn_nf_last
) {
1492 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1493 survey
->noise
= priv
->bcn_nf_last
;
1498 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1501 if (!pchan_stats
[idx
].cca_scan_dur
)
1504 band
= pchan_stats
[idx
].bandcfg
;
1505 survey
->channel
= ieee80211_get_channel(wiphy
,
1506 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1507 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1509 SURVEY_INFO_TIME_BUSY
;
1510 survey
->noise
= pchan_stats
[idx
].noise
;
1511 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1512 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1517 /* Supported rates to be advertised to the cfg80211 */
1518 static struct ieee80211_rate mwifiex_rates
[] = {
1519 {.bitrate
= 10, .hw_value
= 2, },
1520 {.bitrate
= 20, .hw_value
= 4, },
1521 {.bitrate
= 55, .hw_value
= 11, },
1522 {.bitrate
= 110, .hw_value
= 22, },
1523 {.bitrate
= 60, .hw_value
= 12, },
1524 {.bitrate
= 90, .hw_value
= 18, },
1525 {.bitrate
= 120, .hw_value
= 24, },
1526 {.bitrate
= 180, .hw_value
= 36, },
1527 {.bitrate
= 240, .hw_value
= 48, },
1528 {.bitrate
= 360, .hw_value
= 72, },
1529 {.bitrate
= 480, .hw_value
= 96, },
1530 {.bitrate
= 540, .hw_value
= 108, },
1533 /* Channel definitions to be advertised to cfg80211 */
1534 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1535 {.center_freq
= 2412, .hw_value
= 1, },
1536 {.center_freq
= 2417, .hw_value
= 2, },
1537 {.center_freq
= 2422, .hw_value
= 3, },
1538 {.center_freq
= 2427, .hw_value
= 4, },
1539 {.center_freq
= 2432, .hw_value
= 5, },
1540 {.center_freq
= 2437, .hw_value
= 6, },
1541 {.center_freq
= 2442, .hw_value
= 7, },
1542 {.center_freq
= 2447, .hw_value
= 8, },
1543 {.center_freq
= 2452, .hw_value
= 9, },
1544 {.center_freq
= 2457, .hw_value
= 10, },
1545 {.center_freq
= 2462, .hw_value
= 11, },
1546 {.center_freq
= 2467, .hw_value
= 12, },
1547 {.center_freq
= 2472, .hw_value
= 13, },
1548 {.center_freq
= 2484, .hw_value
= 14, },
1551 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1552 .channels
= mwifiex_channels_2ghz
,
1553 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1554 .bitrates
= mwifiex_rates
,
1555 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1558 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1559 {.center_freq
= 5040, .hw_value
= 8, },
1560 {.center_freq
= 5060, .hw_value
= 12, },
1561 {.center_freq
= 5080, .hw_value
= 16, },
1562 {.center_freq
= 5170, .hw_value
= 34, },
1563 {.center_freq
= 5190, .hw_value
= 38, },
1564 {.center_freq
= 5210, .hw_value
= 42, },
1565 {.center_freq
= 5230, .hw_value
= 46, },
1566 {.center_freq
= 5180, .hw_value
= 36, },
1567 {.center_freq
= 5200, .hw_value
= 40, },
1568 {.center_freq
= 5220, .hw_value
= 44, },
1569 {.center_freq
= 5240, .hw_value
= 48, },
1570 {.center_freq
= 5260, .hw_value
= 52, },
1571 {.center_freq
= 5280, .hw_value
= 56, },
1572 {.center_freq
= 5300, .hw_value
= 60, },
1573 {.center_freq
= 5320, .hw_value
= 64, },
1574 {.center_freq
= 5500, .hw_value
= 100, },
1575 {.center_freq
= 5520, .hw_value
= 104, },
1576 {.center_freq
= 5540, .hw_value
= 108, },
1577 {.center_freq
= 5560, .hw_value
= 112, },
1578 {.center_freq
= 5580, .hw_value
= 116, },
1579 {.center_freq
= 5600, .hw_value
= 120, },
1580 {.center_freq
= 5620, .hw_value
= 124, },
1581 {.center_freq
= 5640, .hw_value
= 128, },
1582 {.center_freq
= 5660, .hw_value
= 132, },
1583 {.center_freq
= 5680, .hw_value
= 136, },
1584 {.center_freq
= 5700, .hw_value
= 140, },
1585 {.center_freq
= 5745, .hw_value
= 149, },
1586 {.center_freq
= 5765, .hw_value
= 153, },
1587 {.center_freq
= 5785, .hw_value
= 157, },
1588 {.center_freq
= 5805, .hw_value
= 161, },
1589 {.center_freq
= 5825, .hw_value
= 165, },
1592 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1593 .channels
= mwifiex_channels_5ghz
,
1594 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1595 .bitrates
= mwifiex_rates
+ 4,
1596 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1600 /* Supported crypto cipher suits to be advertised to cfg80211 */
1601 static const u32 mwifiex_cipher_suites
[] = {
1602 WLAN_CIPHER_SUITE_WEP40
,
1603 WLAN_CIPHER_SUITE_WEP104
,
1604 WLAN_CIPHER_SUITE_TKIP
,
1605 WLAN_CIPHER_SUITE_CCMP
,
1606 WLAN_CIPHER_SUITE_SMS4
,
1607 WLAN_CIPHER_SUITE_AES_CMAC
,
1610 /* Supported mgmt frame types to be advertised to cfg80211 */
1611 static const struct ieee80211_txrx_stypes
1612 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1613 [NL80211_IFTYPE_STATION
] = {
1614 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1615 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1616 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1617 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1619 [NL80211_IFTYPE_AP
] = {
1620 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1621 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1622 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1623 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1625 [NL80211_IFTYPE_P2P_CLIENT
] = {
1626 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1627 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1628 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1629 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1631 [NL80211_IFTYPE_P2P_GO
] = {
1632 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1633 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1634 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1635 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1640 * CFG802.11 operation handler for setting bit rates.
1642 * Function configures data rates to firmware using bitrate mask
1643 * provided by cfg80211.
1645 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1646 struct net_device
*dev
,
1648 const struct cfg80211_bitrate_mask
*mask
)
1650 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1651 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1652 enum nl80211_band band
;
1653 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1655 if (!priv
->media_connected
) {
1656 mwifiex_dbg(adapter
, ERROR
,
1657 "Can not set Tx data rate in disconnected state\n");
1661 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1663 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1665 /* Fill HR/DSSS rates. */
1666 if (band
== NL80211_BAND_2GHZ
)
1667 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1669 /* Fill OFDM rates */
1670 if (band
== NL80211_BAND_2GHZ
)
1671 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1673 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1675 /* Fill HT MCS rates */
1676 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1677 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1678 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1680 /* Fill VHT MCS rates */
1681 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1682 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1683 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1684 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1687 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1688 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1692 * CFG802.11 operation handler for connection quality monitoring.
1694 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1697 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1698 struct net_device
*dev
,
1699 s32 rssi_thold
, u32 rssi_hyst
)
1701 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1702 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1704 priv
->cqm_rssi_thold
= rssi_thold
;
1705 priv
->cqm_rssi_hyst
= rssi_hyst
;
1707 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1708 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1710 /* Subscribe/unsubscribe low and high rssi events */
1711 if (rssi_thold
&& rssi_hyst
) {
1712 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1713 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1714 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1715 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1716 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1717 return mwifiex_send_cmd(priv
,
1718 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1719 0, 0, &subsc_evt
, true);
1721 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1722 return mwifiex_send_cmd(priv
,
1723 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1724 0, 0, &subsc_evt
, true);
1730 /* cfg80211 operation handler for change_beacon.
1731 * Function retrieves and sets modified management IEs to FW.
1733 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1734 struct net_device
*dev
,
1735 struct cfg80211_beacon_data
*data
)
1737 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1738 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1740 mwifiex_cancel_scan(adapter
);
1742 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1743 mwifiex_dbg(priv
->adapter
, ERROR
,
1744 "%s: bss_type mismatched\n", __func__
);
1748 if (!priv
->bss_started
) {
1749 mwifiex_dbg(priv
->adapter
, ERROR
,
1750 "%s: bss not started\n", __func__
);
1754 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1755 mwifiex_dbg(priv
->adapter
, ERROR
,
1756 "%s: setting mgmt ies failed\n", __func__
);
1763 /* cfg80211 operation handler for del_station.
1764 * Function deauthenticates station which value is provided in mac parameter.
1765 * If mac is NULL/broadcast, all stations in associated station list are
1766 * deauthenticated. If bss is not started or there are no stations in
1767 * associated stations list, no action is taken.
1770 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1771 struct station_del_parameters
*params
)
1773 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1774 struct mwifiex_sta_node
*sta_node
;
1775 u8 deauth_mac
[ETH_ALEN
];
1776 unsigned long flags
;
1778 if (!priv
->bss_started
&& priv
->wdev
.cac_started
) {
1779 mwifiex_dbg(priv
->adapter
, INFO
, "%s: abort CAC!\n", __func__
);
1780 mwifiex_abort_cac(priv
);
1783 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1786 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1789 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1790 __func__
, params
->mac
);
1792 eth_zero_addr(deauth_mac
);
1794 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1795 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1797 ether_addr_copy(deauth_mac
, params
->mac
);
1798 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1800 if (is_valid_ether_addr(deauth_mac
)) {
1801 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1802 HostCmd_ACT_GEN_SET
, 0,
1811 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1813 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1814 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1815 MWIFIEX_BSS_ROLE_ANY
);
1816 struct mwifiex_ds_ant_cfg ant_cfg
;
1818 if (!tx_ant
|| !rx_ant
)
1821 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1822 /* Not a MIMO chip. User should provide specific antenna number
1823 * for Tx/Rx path or enable all antennas for diversity
1825 if (tx_ant
!= rx_ant
)
1828 if ((tx_ant
& (tx_ant
- 1)) &&
1829 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1832 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1833 (priv
->adapter
->number_of_antenna
> 1)) {
1834 tx_ant
= RF_ANTENNA_AUTO
;
1835 rx_ant
= RF_ANTENNA_AUTO
;
1838 struct ieee80211_sta_ht_cap
*ht_info
;
1840 enum nl80211_band band
;
1842 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1843 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1844 if (adapter
->is_hw_11ac_capable
)
1845 adapter
->usr_dot_11ac_mcs_support
=
1846 MWIFIEX_11AC_MCS_MAP_1X1
;
1848 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1849 if (adapter
->is_hw_11ac_capable
)
1850 adapter
->usr_dot_11ac_mcs_support
=
1851 MWIFIEX_11AC_MCS_MAP_2X2
;
1854 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
1855 if (!adapter
->wiphy
->bands
[band
])
1858 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1860 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1861 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1862 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1866 ant_cfg
.tx_ant
= tx_ant
;
1867 ant_cfg
.rx_ant
= rx_ant
;
1869 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1870 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1874 mwifiex_cfg80211_get_antenna(struct wiphy
*wiphy
, u32
*tx_ant
, u32
*rx_ant
)
1876 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1877 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1878 MWIFIEX_BSS_ROLE_ANY
);
1879 mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1880 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1882 *tx_ant
= priv
->tx_ant
;
1883 *rx_ant
= priv
->rx_ant
;
1888 /* cfg80211 operation handler for stop ap.
1889 * Function stops BSS running at uAP interface.
1891 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1893 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1895 mwifiex_abort_cac(priv
);
1897 if (mwifiex_del_mgmt_ies(priv
))
1898 mwifiex_dbg(priv
->adapter
, ERROR
,
1899 "Failed to delete mgmt IEs!\n");
1901 priv
->ap_11n_enabled
= 0;
1902 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1904 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1905 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1906 mwifiex_dbg(priv
->adapter
, ERROR
,
1907 "Failed to stop the BSS\n");
1911 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1912 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1913 mwifiex_dbg(priv
->adapter
, ERROR
,
1914 "Failed to reset BSS\n");
1918 if (netif_carrier_ok(priv
->netdev
))
1919 netif_carrier_off(priv
->netdev
);
1920 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1925 /* cfg80211 operation handler for start_ap.
1926 * Function sets beacon period, DTIM period, SSID and security into
1927 * AP config structure.
1928 * AP is configured with these settings and BSS is started.
1930 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1931 struct net_device
*dev
,
1932 struct cfg80211_ap_settings
*params
)
1934 struct mwifiex_uap_bss_param
*bss_cfg
;
1935 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1937 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1940 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1944 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1946 if (params
->beacon_interval
)
1947 bss_cfg
->beacon_period
= params
->beacon_interval
;
1948 if (params
->dtim_period
)
1949 bss_cfg
->dtim_period
= params
->dtim_period
;
1951 if (params
->ssid
&& params
->ssid_len
) {
1952 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1953 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1955 if (params
->inactivity_timeout
> 0) {
1956 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1957 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1958 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1961 switch (params
->hidden_ssid
) {
1962 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1963 bss_cfg
->bcast_ssid_ctl
= 1;
1965 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1966 bss_cfg
->bcast_ssid_ctl
= 0;
1968 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1969 /* firmware doesn't support this type of hidden SSID */
1975 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1976 mwifiex_set_uap_rates(bss_cfg
, params
);
1978 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1979 mwifiex_dbg(priv
->adapter
, ERROR
,
1980 "Failed to parse security parameters!\n");
1984 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1986 if (priv
->adapter
->is_hw_11ac_capable
) {
1987 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1988 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1989 priv
->ap_11ac_enabled
);
1992 if (priv
->ap_11ac_enabled
)
1993 mwifiex_set_11ac_ba_params(priv
);
1995 mwifiex_set_ba_params(priv
);
1997 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1999 if (mwifiex_is_11h_active(priv
))
2000 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
2002 if (mwifiex_is_11h_active(priv
) &&
2003 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
2005 mwifiex_dbg(priv
->adapter
, INFO
,
2006 "Disable 11h extensions in FW\n");
2007 if (mwifiex_11h_activate(priv
, false)) {
2008 mwifiex_dbg(priv
->adapter
, ERROR
,
2009 "Failed to disable 11h extensions!!");
2012 priv
->state_11h
.is_11h_active
= false;
2015 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
2016 mwifiex_dbg(priv
->adapter
, ERROR
,
2017 "Failed to start AP\n");
2021 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
2024 if (!netif_carrier_ok(priv
->netdev
))
2025 netif_carrier_on(priv
->netdev
);
2026 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
2028 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
2038 * CFG802.11 operation handler for disconnection request.
2040 * This function does not work when there is already a disconnection
2041 * procedure going on.
2044 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
2047 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2049 if (!mwifiex_stop_bg_scan(priv
))
2050 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2052 if (mwifiex_deauthenticate(priv
, NULL
))
2055 eth_zero_addr(priv
->cfg_bssid
);
2056 priv
->hs2_enabled
= false;
2062 * This function informs the CFG802.11 subsystem of a new IBSS.
2064 * The following information are sent to the CFG802.11 subsystem
2065 * to register the new IBSS. If we do not register the new IBSS,
2066 * a kernel panic will result.
2072 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
2074 struct ieee80211_channel
*chan
;
2075 struct mwifiex_bss_info bss_info
;
2076 struct cfg80211_bss
*bss
;
2078 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
2079 enum nl80211_band band
;
2081 if (mwifiex_get_bss_info(priv
, &bss_info
))
2084 ie_buf
[0] = WLAN_EID_SSID
;
2085 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
2087 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
2088 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
2089 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
2091 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
2092 chan
= ieee80211_get_channel(priv
->wdev
.wiphy
,
2093 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
2096 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2097 CFG80211_BSS_FTYPE_UNKNOWN
,
2098 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2099 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2101 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2102 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2109 * This function connects with a BSS.
2111 * This function handles both Infra and Ad-Hoc modes. It also performs
2112 * validity checking on the provided parameters, disconnects from the
2113 * current BSS (if any), sets up the association/scan parameters,
2114 * including security settings, and performs specific SSID scan before
2115 * trying to connect.
2117 * For Infra mode, the function returns failure if the specified SSID
2118 * is not found in scan table. However, for Ad-Hoc mode, it can create
2119 * the IBSS if it does not exist. On successful completion in either case,
2120 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2123 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2124 const u8
*ssid
, const u8
*bssid
, int mode
,
2125 struct ieee80211_channel
*channel
,
2126 struct cfg80211_connect_params
*sme
, bool privacy
)
2128 struct cfg80211_ssid req_ssid
;
2129 int ret
, auth_type
= 0;
2130 struct cfg80211_bss
*bss
= NULL
;
2131 u8 is_scanning_required
= 0;
2133 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2135 req_ssid
.ssid_len
= ssid_len
;
2136 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2137 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2141 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2142 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2143 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2147 /* As this is new association, clear locally stored
2148 * keys and security related flags */
2149 priv
->sec_info
.wpa_enabled
= false;
2150 priv
->sec_info
.wpa2_enabled
= false;
2151 priv
->wep_key_curr_index
= 0;
2152 priv
->sec_info
.encryption_mode
= 0;
2153 priv
->sec_info
.is_authtype_auto
= 0;
2154 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2156 if (mode
== NL80211_IFTYPE_ADHOC
) {
2159 /* set ibss coalescing_status */
2160 ret
= mwifiex_send_cmd(
2162 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
,
2163 HostCmd_ACT_GEN_SET
, 0, &enable
, true);
2167 /* "privacy" is set only for ad-hoc mode */
2170 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2171 * the firmware can find a matching network from the
2172 * scan. The cfg80211 does not give us the encryption
2173 * mode at this stage so just setting it to WEP here.
2175 priv
->sec_info
.encryption_mode
=
2176 WLAN_CIPHER_SUITE_WEP104
;
2177 priv
->sec_info
.authentication_mode
=
2178 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2184 /* Now handle infra mode. "sme" is valid for infra mode only */
2185 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2186 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2187 priv
->sec_info
.is_authtype_auto
= 1;
2189 auth_type
= sme
->auth_type
;
2192 if (sme
->crypto
.n_ciphers_pairwise
) {
2193 priv
->sec_info
.encryption_mode
=
2194 sme
->crypto
.ciphers_pairwise
[0];
2195 priv
->sec_info
.authentication_mode
= auth_type
;
2198 if (sme
->crypto
.cipher_group
) {
2199 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2200 priv
->sec_info
.authentication_mode
= auth_type
;
2203 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2206 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2207 mwifiex_dbg(priv
->adapter
, INFO
,
2208 "info: setting wep encryption\t"
2209 "with key len %d\n", sme
->key_len
);
2210 priv
->wep_key_curr_index
= sme
->key_idx
;
2211 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2212 sme
->key_len
, sme
->key_idx
,
2218 * Scan entries are valid for some time (15 sec). So we can save one
2219 * active scan time if we just try cfg80211_get_bss first. If it fails
2220 * then request scan and cfg80211_get_bss() again for final output.
2223 if (is_scanning_required
) {
2224 /* Do specific SSID scanning */
2225 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2226 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2231 /* Find the BSS we want using available scan results */
2232 if (mode
== NL80211_IFTYPE_ADHOC
)
2233 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2234 bssid
, ssid
, ssid_len
,
2235 IEEE80211_BSS_TYPE_IBSS
,
2236 IEEE80211_PRIVACY_ANY
);
2238 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2239 bssid
, ssid
, ssid_len
,
2240 IEEE80211_BSS_TYPE_ESS
,
2241 IEEE80211_PRIVACY_ANY
);
2244 if (is_scanning_required
) {
2245 mwifiex_dbg(priv
->adapter
, WARN
,
2246 "assoc: requested bss not found in scan results\n");
2249 is_scanning_required
= 1;
2251 mwifiex_dbg(priv
->adapter
, MSG
,
2252 "info: trying to associate to '%.*s' bssid %pM\n",
2253 req_ssid
.ssid_len
, (char *)req_ssid
.ssid
,
2255 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2260 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2264 if (mode
== NL80211_IFTYPE_ADHOC
) {
2265 /* Inform the BSS information to kernel, otherwise
2266 * kernel will give a panic after successful assoc */
2267 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2275 * CFG802.11 operation handler for association request.
2277 * This function does not work when the current mode is set to Ad-Hoc, or
2278 * when there is already an association procedure going on. The given BSS
2279 * information is used to associate.
2282 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2283 struct cfg80211_connect_params
*sme
)
2285 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2286 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2289 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2290 mwifiex_dbg(adapter
, ERROR
,
2291 "%s: reject infra assoc request in non-STA role\n",
2296 if (priv
->wdev
.current_bss
) {
2297 mwifiex_dbg(adapter
, ERROR
,
2298 "%s: already connected\n", dev
->name
);
2302 if (priv
->scan_block
)
2303 priv
->scan_block
= false;
2305 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2306 mwifiex_dbg(adapter
, ERROR
,
2307 "%s: Ignore connection.\t"
2308 "Card removed or FW in bad state\n",
2313 mwifiex_dbg(adapter
, INFO
,
2314 "info: Trying to associate to %.*s and bssid %pM\n",
2315 (int)sme
->ssid_len
, (char *)sme
->ssid
, sme
->bssid
);
2317 if (!mwifiex_stop_bg_scan(priv
))
2318 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2320 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2321 priv
->bss_mode
, sme
->channel
, sme
, 0);
2323 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2324 NULL
, 0, WLAN_STATUS_SUCCESS
,
2326 mwifiex_dbg(priv
->adapter
, MSG
,
2327 "info: associated to bssid %pM successfully\n",
2329 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2330 priv
->adapter
->auto_tdls
&&
2331 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2332 mwifiex_setup_auto_tdls_timer(priv
);
2334 mwifiex_dbg(priv
->adapter
, ERROR
,
2335 "info: association to bssid %pM failed\n",
2337 eth_zero_addr(priv
->cfg_bssid
);
2340 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2341 NULL
, 0, NULL
, 0, ret
,
2344 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2346 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2354 * This function sets following parameters for ibss network.
2358 * - secondary channel offset
2360 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2361 struct cfg80211_ibss_params
*params
)
2363 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2365 u8 config_bands
= 0;
2367 if (params
->chandef
.chan
->band
== NL80211_BAND_2GHZ
) {
2368 if (!params
->basic_rates
) {
2369 config_bands
= BAND_B
| BAND_G
;
2371 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2373 * Rates below 6 Mbps in the table are CCK
2374 * rates; 802.11b and from 6 they are OFDM;
2377 if (mwifiex_rates
[i
].bitrate
== 60) {
2383 if (params
->basic_rates
< index
) {
2384 config_bands
= BAND_B
;
2386 config_bands
= BAND_G
;
2387 if (params
->basic_rates
% index
)
2388 config_bands
|= BAND_B
;
2392 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2394 config_bands
|= BAND_G
| BAND_GN
;
2396 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2398 config_bands
= BAND_A
;
2400 config_bands
= BAND_AN
| BAND_A
;
2403 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2404 adapter
->config_bands
= config_bands
;
2405 adapter
->adhoc_start_band
= config_bands
;
2407 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2408 adapter
->adhoc_11n_enabled
= true;
2410 adapter
->adhoc_11n_enabled
= false;
2413 adapter
->sec_chan_offset
=
2414 mwifiex_chan_type_to_sec_chan_offset(
2415 cfg80211_get_chandef_type(¶ms
->chandef
));
2416 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2417 params
->chandef
.chan
->center_freq
);
2419 mwifiex_dbg(adapter
, INFO
,
2420 "info: set ibss band %d, chan %d, chan offset %d\n",
2421 config_bands
, priv
->adhoc_channel
,
2422 adapter
->sec_chan_offset
);
2428 * CFG802.11 operation handler to join an IBSS.
2430 * This function does not work in any mode other than Ad-Hoc, or if
2431 * a join operation is already in progress.
2434 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2435 struct cfg80211_ibss_params
*params
)
2437 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2440 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2441 mwifiex_dbg(priv
->adapter
, ERROR
,
2442 "request to join ibss received\t"
2443 "when station is not in ibss mode\n");
2447 mwifiex_dbg(priv
->adapter
, MSG
,
2448 "info: trying to join to %.*s and bssid %pM\n",
2449 params
->ssid_len
, (char *)params
->ssid
, params
->bssid
);
2451 mwifiex_set_ibss_params(priv
, params
);
2453 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2454 params
->bssid
, priv
->bss_mode
,
2455 params
->chandef
.chan
, NULL
,
2459 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2460 params
->chandef
.chan
, GFP_KERNEL
);
2461 mwifiex_dbg(priv
->adapter
, MSG
,
2462 "info: joined/created adhoc network with bssid\t"
2463 "%pM successfully\n", priv
->cfg_bssid
);
2465 mwifiex_dbg(priv
->adapter
, ERROR
,
2466 "info: failed creating/joining adhoc network\n");
2473 * CFG802.11 operation handler to leave an IBSS.
2475 * This function does not work if a leave operation is
2476 * already in progress.
2479 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2481 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2483 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2485 if (mwifiex_deauthenticate(priv
, NULL
))
2488 eth_zero_addr(priv
->cfg_bssid
);
2494 * CFG802.11 operation handler for scan request.
2496 * This function issues a scan request to the firmware based upon
2497 * the user specified scan configuration. On successful completion,
2498 * it also informs the results.
2501 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2502 struct cfg80211_scan_request
*request
)
2504 struct net_device
*dev
= request
->wdev
->netdev
;
2505 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2507 struct ieee80211_channel
*chan
;
2508 struct ieee_types_header
*ie
;
2509 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2511 mwifiex_dbg(priv
->adapter
, CMD
,
2512 "info: received scan request on %s\n", dev
->name
);
2514 /* Block scan request if scan operation or scan cleanup when interface
2515 * is disabled is in process
2517 if (priv
->scan_request
|| priv
->scan_aborting
) {
2518 mwifiex_dbg(priv
->adapter
, WARN
,
2519 "cmd: Scan already in process..\n");
2523 if (!priv
->wdev
.current_bss
&& priv
->scan_block
)
2524 priv
->scan_block
= false;
2526 if (!mwifiex_stop_bg_scan(priv
))
2527 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2529 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2533 priv
->scan_request
= request
;
2535 if (request
->flags
& NL80211_SCAN_FLAG_RANDOM_ADDR
) {
2536 ether_addr_copy(priv
->random_mac
, request
->mac_addr
);
2537 for (i
= 0; i
< ETH_ALEN
; i
++) {
2538 priv
->random_mac
[i
] &= request
->mac_addr_mask
[i
];
2539 priv
->random_mac
[i
] |= get_random_int() &
2540 ~(request
->mac_addr_mask
[i
]);
2542 ether_addr_copy(user_scan_cfg
->random_mac
, priv
->random_mac
);
2544 eth_zero_addr(priv
->random_mac
);
2547 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2548 user_scan_cfg
->ssid_list
= request
->ssids
;
2550 if (request
->ie
&& request
->ie_len
) {
2552 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2553 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2555 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2556 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2557 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2558 offset
+= sizeof(*ie
) + ie
->len
;
2560 if (offset
>= request
->ie_len
)
2565 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2566 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2567 chan
= request
->channels
[i
];
2568 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2569 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2571 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2572 user_scan_cfg
->chan_list
[i
].scan_type
=
2573 MWIFIEX_SCAN_TYPE_PASSIVE
;
2575 user_scan_cfg
->chan_list
[i
].scan_type
=
2576 MWIFIEX_SCAN_TYPE_ACTIVE
;
2578 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2581 if (priv
->adapter
->scan_chan_gap_enabled
&&
2582 mwifiex_is_any_intf_active(priv
))
2583 user_scan_cfg
->scan_chan_gap
=
2584 priv
->adapter
->scan_chan_gap_time
;
2586 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2587 kfree(user_scan_cfg
);
2589 mwifiex_dbg(priv
->adapter
, ERROR
,
2590 "scan failed: %d\n", ret
);
2591 priv
->scan_aborting
= false;
2592 priv
->scan_request
= NULL
;
2596 if (request
->ie
&& request
->ie_len
) {
2597 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2598 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2599 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2600 memset(&priv
->vs_ie
[i
].ie
, 0,
2601 MWIFIEX_MAX_VSIE_LEN
);
2608 /* CFG802.11 operation handler for sched_scan_start.
2610 * This function issues a bgscan config request to the firmware based upon
2611 * the user specified sched_scan configuration. On successful completion,
2612 * firmware will generate BGSCAN_REPORT event, driver should issue bgscan
2613 * query command to get sched_scan results from firmware.
2616 mwifiex_cfg80211_sched_scan_start(struct wiphy
*wiphy
,
2617 struct net_device
*dev
,
2618 struct cfg80211_sched_scan_request
*request
)
2620 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2622 struct ieee80211_channel
*chan
;
2623 struct mwifiex_bg_scan_cfg
*bgscan_cfg
;
2624 struct ieee_types_header
*ie
;
2626 if (!request
|| (!request
->n_ssids
&& !request
->n_match_sets
)) {
2627 wiphy_err(wiphy
, "%s : Invalid Sched_scan parameters",
2632 wiphy_info(wiphy
, "sched_scan start : n_ssids=%d n_match_sets=%d ",
2633 request
->n_ssids
, request
->n_match_sets
);
2634 wiphy_info(wiphy
, "n_channels=%d interval=%d ie_len=%d\n",
2635 request
->n_channels
, request
->scan_plans
->interval
,
2636 (int)request
->ie_len
);
2638 bgscan_cfg
= kzalloc(sizeof(*bgscan_cfg
), GFP_KERNEL
);
2642 if (priv
->scan_request
|| priv
->scan_aborting
)
2643 bgscan_cfg
->start_later
= true;
2645 bgscan_cfg
->num_ssids
= request
->n_match_sets
;
2646 bgscan_cfg
->ssid_list
= request
->match_sets
;
2648 if (request
->ie
&& request
->ie_len
) {
2650 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2651 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2653 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_BGSCAN
;
2654 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2655 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2656 offset
+= sizeof(*ie
) + ie
->len
;
2658 if (offset
>= request
->ie_len
)
2663 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2664 MWIFIEX_BG_SCAN_CHAN_MAX
); i
++) {
2665 chan
= request
->channels
[i
];
2666 bgscan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2667 bgscan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2669 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2670 bgscan_cfg
->chan_list
[i
].scan_type
=
2671 MWIFIEX_SCAN_TYPE_PASSIVE
;
2673 bgscan_cfg
->chan_list
[i
].scan_type
=
2674 MWIFIEX_SCAN_TYPE_ACTIVE
;
2676 bgscan_cfg
->chan_list
[i
].scan_time
= 0;
2679 bgscan_cfg
->chan_per_scan
= min_t(u32
, request
->n_channels
,
2680 MWIFIEX_BG_SCAN_CHAN_MAX
);
2682 /* Use at least 15 second for per scan cycle */
2683 bgscan_cfg
->scan_interval
= (request
->scan_plans
->interval
>
2684 MWIFIEX_BGSCAN_INTERVAL
) ?
2685 request
->scan_plans
->interval
:
2686 MWIFIEX_BGSCAN_INTERVAL
;
2688 bgscan_cfg
->repeat_count
= MWIFIEX_BGSCAN_REPEAT_COUNT
;
2689 bgscan_cfg
->report_condition
= MWIFIEX_BGSCAN_SSID_MATCH
|
2690 MWIFIEX_BGSCAN_WAIT_ALL_CHAN_DONE
;
2691 bgscan_cfg
->bss_type
= MWIFIEX_BSS_MODE_INFRA
;
2692 bgscan_cfg
->action
= MWIFIEX_BGSCAN_ACT_SET
;
2693 bgscan_cfg
->enable
= true;
2694 if (request
->min_rssi_thold
!= NL80211_SCAN_RSSI_THOLD_OFF
) {
2695 bgscan_cfg
->report_condition
|= MWIFIEX_BGSCAN_SSID_RSSI_MATCH
;
2696 bgscan_cfg
->rssi_threshold
= request
->min_rssi_thold
;
2699 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_BG_SCAN_CONFIG
,
2700 HostCmd_ACT_GEN_SET
, 0, bgscan_cfg
, true)) {
2705 priv
->sched_scanning
= true;
2711 /* CFG802.11 operation handler for sched_scan_stop.
2713 * This function issues a bgscan config command to disable
2714 * previous bgscan configuration in the firmware
2716 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy
*wiphy
,
2717 struct net_device
*dev
, u64 reqid
)
2719 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2721 wiphy_info(wiphy
, "sched scan stop!");
2722 mwifiex_stop_bg_scan(priv
);
2727 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2728 struct mwifiex_private
*priv
)
2730 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2732 vht_info
->vht_supported
= true;
2734 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2735 /* Update MCS support for VHT */
2736 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2737 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2738 vht_info
->vht_mcs
.rx_highest
= 0;
2739 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2740 adapter
->hw_dot_11ac_mcs_support
>> 16);
2741 vht_info
->vht_mcs
.tx_highest
= 0;
2745 * This function sets up the CFG802.11 specific HT capability fields
2746 * with default values.
2748 * The following default values are set -
2749 * - HT Supported = True
2750 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2751 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2752 * - HT Capabilities supported by firmware
2753 * - MCS information, Rx mask = 0xff
2754 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2757 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2758 struct mwifiex_private
*priv
)
2761 struct ieee80211_mcs_info mcs_set
;
2762 u8
*mcs
= (u8
*)&mcs_set
;
2763 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2765 ht_info
->ht_supported
= true;
2766 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2767 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2769 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2771 /* Fill HT capability information */
2772 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2773 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2775 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2777 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2778 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2780 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2782 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2783 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2785 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2787 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2788 ht_info
->cap
|= 2 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2790 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2792 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2793 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2795 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2797 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2798 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2800 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2802 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2803 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2805 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2807 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2808 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2810 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2812 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2813 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2815 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2816 /* Set MCS for 1x1/2x2 */
2817 memset(mcs
, 0xff, rx_mcs_supp
);
2818 /* Clear all the other values */
2819 memset(&mcs
[rx_mcs_supp
], 0,
2820 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2821 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2822 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2823 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2824 SETHT_MCS32(mcs_set
.rx_mask
);
2826 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2828 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2832 * create a new virtual interface with the given name and name assign type
2834 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2836 unsigned char name_assign_type
,
2837 enum nl80211_iftype type
,
2838 struct vif_params
*params
)
2840 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2841 struct mwifiex_private
*priv
;
2842 struct net_device
*dev
;
2847 return ERR_PTR(-EFAULT
);
2850 case NL80211_IFTYPE_UNSPECIFIED
:
2851 case NL80211_IFTYPE_STATION
:
2852 case NL80211_IFTYPE_ADHOC
:
2853 if (adapter
->curr_iface_comb
.sta_intf
==
2854 adapter
->iface_limit
.sta_intf
) {
2855 mwifiex_dbg(adapter
, ERROR
,
2856 "cannot create multiple sta/adhoc ifaces\n");
2857 return ERR_PTR(-EINVAL
);
2860 priv
= mwifiex_get_unused_priv_by_bss_type(
2861 adapter
, MWIFIEX_BSS_TYPE_STA
);
2863 mwifiex_dbg(adapter
, ERROR
,
2864 "could not get free private struct\n");
2865 return ERR_PTR(-EFAULT
);
2868 priv
->wdev
.wiphy
= wiphy
;
2869 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2871 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2872 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2874 priv
->bss_mode
= type
;
2876 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2877 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2878 priv
->bss_priority
= 0;
2879 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2882 case NL80211_IFTYPE_AP
:
2883 if (adapter
->curr_iface_comb
.uap_intf
==
2884 adapter
->iface_limit
.uap_intf
) {
2885 mwifiex_dbg(adapter
, ERROR
,
2886 "cannot create multiple AP ifaces\n");
2887 return ERR_PTR(-EINVAL
);
2890 priv
= mwifiex_get_unused_priv_by_bss_type(
2891 adapter
, MWIFIEX_BSS_TYPE_UAP
);
2893 mwifiex_dbg(adapter
, ERROR
,
2894 "could not get free private struct\n");
2895 return ERR_PTR(-EFAULT
);
2898 priv
->wdev
.wiphy
= wiphy
;
2899 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2901 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2902 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2903 priv
->bss_priority
= 0;
2904 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2905 priv
->bss_started
= 0;
2906 priv
->bss_mode
= type
;
2909 case NL80211_IFTYPE_P2P_CLIENT
:
2910 if (adapter
->curr_iface_comb
.p2p_intf
==
2911 adapter
->iface_limit
.p2p_intf
) {
2912 mwifiex_dbg(adapter
, ERROR
,
2913 "cannot create multiple P2P ifaces\n");
2914 return ERR_PTR(-EINVAL
);
2917 priv
= mwifiex_get_unused_priv_by_bss_type(
2918 adapter
, MWIFIEX_BSS_TYPE_P2P
);
2920 mwifiex_dbg(adapter
, ERROR
,
2921 "could not get free private struct\n");
2922 return ERR_PTR(-EFAULT
);
2925 priv
->wdev
.wiphy
= wiphy
;
2926 /* At start-up, wpa_supplicant tries to change the interface
2927 * to NL80211_IFTYPE_STATION if it is not managed mode.
2929 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2930 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2932 /* Setting bss_type to P2P tells firmware that this interface
2933 * is receiving P2P peers found during find phase and doing
2934 * action frame handshake.
2936 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2938 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2939 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2940 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2941 priv
->bss_started
= 0;
2943 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2944 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2945 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2946 return ERR_PTR(-EFAULT
);
2951 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2952 return ERR_PTR(-EINVAL
);
2955 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2956 name_assign_type
, ether_setup
,
2957 IEEE80211_NUM_ACS
, 1);
2959 mwifiex_dbg(adapter
, ERROR
,
2960 "no memory available for netdevice\n");
2962 goto err_alloc_netdev
;
2965 mwifiex_init_priv_params(priv
, dev
);
2968 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
2969 HostCmd_ACT_GEN_SET
, 0, NULL
, true);
2971 goto err_set_bss_mode
;
2973 ret
= mwifiex_sta_init_cmd(priv
, false, false);
2977 mwifiex_setup_ht_caps(&wiphy
->bands
[NL80211_BAND_2GHZ
]->ht_cap
, priv
);
2978 if (adapter
->is_hw_11ac_capable
)
2979 mwifiex_setup_vht_caps(
2980 &wiphy
->bands
[NL80211_BAND_2GHZ
]->vht_cap
, priv
);
2982 if (adapter
->config_bands
& BAND_A
)
2983 mwifiex_setup_ht_caps(
2984 &wiphy
->bands
[NL80211_BAND_5GHZ
]->ht_cap
, priv
);
2986 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2987 mwifiex_setup_vht_caps(
2988 &wiphy
->bands
[NL80211_BAND_5GHZ
]->vht_cap
, priv
);
2990 dev_net_set(dev
, wiphy_net(wiphy
));
2991 dev
->ieee80211_ptr
= &priv
->wdev
;
2992 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2993 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2994 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2996 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2997 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2998 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2999 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
3001 mdev_priv
= netdev_priv(dev
);
3002 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
3004 SET_NETDEV_DEV(dev
, adapter
->dev
);
3006 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
3009 WQ_UNBOUND
, 1, name
);
3010 if (!priv
->dfs_cac_workqueue
) {
3011 mwifiex_dbg(adapter
, ERROR
, "cannot alloc DFS CAC queue\n");
3016 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
3018 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
3019 WQ_HIGHPRI
| WQ_UNBOUND
|
3020 WQ_MEM_RECLAIM
, 1, name
);
3021 if (!priv
->dfs_chan_sw_workqueue
) {
3022 mwifiex_dbg(adapter
, ERROR
, "cannot alloc DFS channel sw queue\n");
3024 goto err_alloc_chsw
;
3027 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
3028 mwifiex_dfs_chan_sw_work_queue
);
3030 mutex_init(&priv
->async_mutex
);
3032 /* Register network device */
3033 if (register_netdevice(dev
)) {
3034 mwifiex_dbg(adapter
, ERROR
, "cannot register network device\n");
3036 goto err_reg_netdev
;
3039 mwifiex_dbg(adapter
, INFO
,
3040 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
3042 #ifdef CONFIG_DEBUG_FS
3043 mwifiex_dev_debugfs_init(priv
);
3047 case NL80211_IFTYPE_UNSPECIFIED
:
3048 case NL80211_IFTYPE_STATION
:
3049 case NL80211_IFTYPE_ADHOC
:
3050 adapter
->curr_iface_comb
.sta_intf
++;
3052 case NL80211_IFTYPE_AP
:
3053 adapter
->curr_iface_comb
.uap_intf
++;
3055 case NL80211_IFTYPE_P2P_CLIENT
:
3056 adapter
->curr_iface_comb
.p2p_intf
++;
3059 /* This should be dead code; checked above */
3060 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
3061 return ERR_PTR(-EINVAL
);
3067 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3068 priv
->dfs_chan_sw_workqueue
= NULL
;
3070 destroy_workqueue(priv
->dfs_cac_workqueue
);
3071 priv
->dfs_cac_workqueue
= NULL
;
3074 priv
->netdev
= NULL
;
3078 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
3079 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
3080 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3081 return ERR_PTR(ret
);
3083 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
3086 * del_virtual_intf: remove the virtual interface determined by dev
3088 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
3090 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3091 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3092 struct sk_buff
*skb
, *tmp
;
3094 #ifdef CONFIG_DEBUG_FS
3095 mwifiex_dev_debugfs_remove(priv
);
3098 if (priv
->sched_scanning
)
3099 priv
->sched_scanning
= false;
3101 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
3103 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
) {
3104 skb_unlink(skb
, &priv
->bypass_txq
);
3105 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
3108 if (netif_carrier_ok(priv
->netdev
))
3109 netif_carrier_off(priv
->netdev
);
3111 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
3112 unregister_netdevice(wdev
->netdev
);
3114 if (priv
->dfs_cac_workqueue
) {
3115 flush_workqueue(priv
->dfs_cac_workqueue
);
3116 destroy_workqueue(priv
->dfs_cac_workqueue
);
3117 priv
->dfs_cac_workqueue
= NULL
;
3120 if (priv
->dfs_chan_sw_workqueue
) {
3121 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
3122 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3123 priv
->dfs_chan_sw_workqueue
= NULL
;
3125 /* Clear the priv in adapter */
3126 priv
->netdev
->ieee80211_ptr
= NULL
;
3127 priv
->netdev
= NULL
;
3128 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
3130 priv
->media_connected
= false;
3132 switch (priv
->bss_mode
) {
3133 case NL80211_IFTYPE_UNSPECIFIED
:
3134 case NL80211_IFTYPE_STATION
:
3135 case NL80211_IFTYPE_ADHOC
:
3136 adapter
->curr_iface_comb
.sta_intf
--;
3138 case NL80211_IFTYPE_AP
:
3139 adapter
->curr_iface_comb
.uap_intf
--;
3141 case NL80211_IFTYPE_P2P_CLIENT
:
3142 case NL80211_IFTYPE_P2P_GO
:
3143 adapter
->curr_iface_comb
.p2p_intf
--;
3146 mwifiex_dbg(adapter
, ERROR
,
3147 "del_virtual_intf: type not supported\n");
3151 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3153 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
3154 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
3155 kfree(priv
->hist_data
);
3159 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
3162 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
3165 int j
, k
, valid_byte_cnt
= 0;
3166 bool dont_care_byte
= false;
3168 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
3169 for (k
= 0; k
< 8; k
++) {
3170 if (pat
->mask
[j
] & 1 << k
) {
3171 memcpy(byte_seq
+ valid_byte_cnt
,
3172 &pat
->pattern
[j
* 8 + k
], 1);
3178 dont_care_byte
= true;
3181 /* wildcard bytes record as the offset
3182 * before the valid byte
3184 if (!valid_byte_cnt
&& !dont_care_byte
)
3187 if (valid_byte_cnt
> max_byte_seq
)
3192 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
3198 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
3199 struct mwifiex_mef_entry
*mef_entry
)
3201 int i
, filt_num
= 0, num_ipv4
= 0;
3202 struct in_device
*in_dev
;
3203 struct in_ifaddr
*ifa
;
3204 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
3205 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3207 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3208 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
3210 /* Enable ARP offload feature */
3211 memset(ips
, 0, sizeof(ips
));
3212 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
3213 if (adapter
->priv
[i
]->netdev
) {
3214 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
3217 ifa
= in_dev
->ifa_list
;
3218 if (!ifa
|| !ifa
->ifa_local
)
3220 ips
[i
] = ifa
->ifa_local
;
3225 for (i
= 0; i
< num_ipv4
; i
++) {
3228 mef_entry
->filter
[filt_num
].repeat
= 1;
3229 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
3230 (u8
*)&ips
[i
], sizeof(ips
[i
]));
3231 mef_entry
->filter
[filt_num
].
3232 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3234 mef_entry
->filter
[filt_num
].offset
= 46;
3235 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3237 mef_entry
->filter
[filt_num
].filt_action
=
3243 mef_entry
->filter
[filt_num
].repeat
= 1;
3244 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
3245 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
3246 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
3247 mef_entry
->filter
[filt_num
].offset
= 20;
3248 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3249 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3252 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
3253 struct mwifiex_ds_mef_cfg
*mef_cfg
,
3254 struct mwifiex_mef_entry
*mef_entry
,
3255 struct cfg80211_wowlan
*wowlan
)
3257 int i
, filt_num
= 0, ret
= 0;
3258 bool first_pat
= true;
3259 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
3260 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3261 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3263 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3264 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
3266 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
3267 memset(byte_seq
, 0, sizeof(byte_seq
));
3268 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
3270 MWIFIEX_MEF_MAX_BYTESEQ
)) {
3271 mwifiex_dbg(priv
->adapter
, ERROR
,
3272 "Pattern not supported\n");
3276 if (!wowlan
->patterns
[i
].pkt_offset
) {
3277 if (!(byte_seq
[0] & 0x01) &&
3278 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3279 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3281 } else if (is_broadcast_ether_addr(byte_seq
)) {
3282 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3284 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3285 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3286 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3287 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3288 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3292 mef_entry
->filter
[filt_num
].repeat
= 1;
3293 mef_entry
->filter
[filt_num
].offset
=
3294 wowlan
->patterns
[i
].pkt_offset
;
3295 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3297 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3301 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on patterns\n");
3303 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3309 if (wowlan
->magic_pkt
) {
3310 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3311 mef_entry
->filter
[filt_num
].repeat
= 16;
3312 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3314 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3316 mef_entry
->filter
[filt_num
].offset
= 28;
3317 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3319 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3322 mef_entry
->filter
[filt_num
].repeat
= 16;
3323 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3325 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3327 mef_entry
->filter
[filt_num
].offset
= 56;
3328 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3329 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3330 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on magic packet\n");
3335 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3336 struct cfg80211_wowlan
*wowlan
)
3338 int ret
= 0, num_entries
= 1;
3339 struct mwifiex_ds_mef_cfg mef_cfg
;
3340 struct mwifiex_mef_entry
*mef_entry
;
3342 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3345 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3349 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3350 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3351 MWIFIEX_CRITERIA_UNICAST
;
3352 mef_cfg
.num_entries
= num_entries
;
3353 mef_cfg
.mef_entry
= mef_entry
;
3355 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3357 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3358 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3359 &mef_entry
[1], wowlan
);
3364 if (!mef_cfg
.criteria
)
3365 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3366 MWIFIEX_CRITERIA_UNICAST
|
3367 MWIFIEX_CRITERIA_MULTICAST
;
3369 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3370 HostCmd_ACT_GEN_SET
, 0,
3378 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3379 struct cfg80211_wowlan
*wowlan
)
3381 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3382 struct mwifiex_ds_hs_cfg hs_cfg
;
3383 int i
, ret
= 0, retry_num
= 10;
3384 struct mwifiex_private
*priv
;
3385 struct mwifiex_private
*sta_priv
=
3386 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3388 sta_priv
->scan_aborting
= true;
3389 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3390 priv
= adapter
->priv
[i
];
3391 mwifiex_abort_cac(priv
);
3394 mwifiex_cancel_all_pending_cmd(adapter
);
3396 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3397 priv
= adapter
->priv
[i
];
3398 if (priv
&& priv
->netdev
) {
3399 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
3400 if (netif_carrier_ok(priv
->netdev
))
3401 netif_carrier_off(priv
->netdev
);
3405 for (i
= 0; i
< retry_num
; i
++) {
3406 if (!mwifiex_wmm_lists_empty(adapter
) ||
3407 !mwifiex_bypass_txlist_empty(adapter
) ||
3408 !skb_queue_empty(&adapter
->tx_data_q
))
3409 usleep_range(10000, 15000);
3415 mwifiex_dbg(adapter
, ERROR
,
3416 "None of the WOWLAN triggers enabled\n");
3421 if (!sta_priv
->media_connected
&& !wowlan
->nd_config
) {
3422 mwifiex_dbg(adapter
, ERROR
,
3423 "Can not configure WOWLAN in disconnected state\n");
3428 ret
= mwifiex_set_mef_filter(sta_priv
, wowlan
);
3430 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3434 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3435 hs_cfg
.conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
3437 if (wowlan
->nd_config
) {
3438 mwifiex_dbg(adapter
, INFO
, "Wake on net detect\n");
3439 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3440 mwifiex_cfg80211_sched_scan_start(wiphy
, sta_priv
->netdev
,
3444 if (wowlan
->disconnect
) {
3445 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3446 mwifiex_dbg(sta_priv
->adapter
, INFO
, "Wake on device disconnect\n");
3449 hs_cfg
.is_invoke_hostcmd
= false;
3450 hs_cfg
.gpio
= adapter
->hs_cfg
.gpio
;
3451 hs_cfg
.gap
= adapter
->hs_cfg
.gap
;
3452 ret
= mwifiex_set_hs_params(sta_priv
, HostCmd_ACT_GEN_SET
,
3453 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3455 mwifiex_dbg(adapter
, ERROR
, "Failed to set HS params\n");
3458 sta_priv
->scan_aborting
= false;
3462 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3464 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3465 struct mwifiex_private
*priv
;
3466 struct mwifiex_ds_wakeup_reason wakeup_reason
;
3467 struct cfg80211_wowlan_wakeup wakeup_report
;
3469 bool report_wakeup_reason
= true;
3471 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3472 priv
= adapter
->priv
[i
];
3473 if (priv
&& priv
->netdev
) {
3474 if (!netif_carrier_ok(priv
->netdev
))
3475 netif_carrier_on(priv
->netdev
);
3476 mwifiex_wake_up_net_dev_queue(priv
->netdev
, adapter
);
3480 if (!wiphy
->wowlan_config
)
3483 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3484 mwifiex_get_wakeup_reason(priv
, HostCmd_ACT_GEN_GET
, MWIFIEX_SYNC_CMD
,
3486 memset(&wakeup_report
, 0, sizeof(struct cfg80211_wowlan_wakeup
));
3488 wakeup_report
.pattern_idx
= -1;
3490 switch (wakeup_reason
.hs_wakeup_reason
) {
3491 case NO_HSWAKEUP_REASON
:
3493 case BCAST_DATA_MATCHED
:
3495 case MCAST_DATA_MATCHED
:
3497 case UCAST_DATA_MATCHED
:
3499 case MASKTABLE_EVENT_MATCHED
:
3501 case NON_MASKABLE_EVENT_MATCHED
:
3502 if (wiphy
->wowlan_config
->disconnect
)
3503 wakeup_report
.disconnect
= true;
3504 if (wiphy
->wowlan_config
->nd_config
)
3505 wakeup_report
.net_detect
= adapter
->nd_info
;
3507 case NON_MASKABLE_CONDITION_MATCHED
:
3509 case MAGIC_PATTERN_MATCHED
:
3510 if (wiphy
->wowlan_config
->magic_pkt
)
3511 wakeup_report
.magic_pkt
= true;
3512 if (wiphy
->wowlan_config
->n_patterns
)
3513 wakeup_report
.pattern_idx
= 1;
3515 case GTK_REKEY_FAILURE
:
3516 if (wiphy
->wowlan_config
->gtk_rekey_failure
)
3517 wakeup_report
.gtk_rekey_failure
= true;
3520 report_wakeup_reason
= false;
3524 if (report_wakeup_reason
)
3525 cfg80211_report_wowlan_wakeup(&priv
->wdev
, &wakeup_report
,
3529 if (adapter
->nd_info
) {
3530 for (i
= 0 ; i
< adapter
->nd_info
->n_matches
; i
++)
3531 kfree(adapter
->nd_info
->matches
[i
]);
3532 kfree(adapter
->nd_info
);
3533 adapter
->nd_info
= NULL
;
3539 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3542 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3544 device_set_wakeup_enable(adapter
->dev
, enabled
);
3547 static int mwifiex_set_rekey_data(struct wiphy
*wiphy
, struct net_device
*dev
,
3548 struct cfg80211_gtk_rekey_data
*data
)
3550 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3552 return mwifiex_send_cmd(priv
, HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG
,
3553 HostCmd_ACT_GEN_SET
, 0, data
, true);
3558 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3560 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3561 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3562 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3564 if ((byte_seq
[0] & 0x01) &&
3565 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3566 return PACKET_TYPE_UNICAST
;
3567 else if (!memcmp(byte_seq
, bc_mac
, 4))
3568 return PACKET_TYPE_BROADCAST
;
3569 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3570 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3571 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3572 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3573 return PACKET_TYPE_MULTICAST
;
3579 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3580 struct cfg80211_coalesce_rules
*crule
,
3581 struct mwifiex_coalesce_rule
*mrule
)
3583 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3584 struct filt_field_param
*param
;
3587 mrule
->max_coalescing_delay
= crule
->delay
;
3589 param
= mrule
->params
;
3591 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3592 memset(byte_seq
, 0, sizeof(byte_seq
));
3593 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3595 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3596 mwifiex_dbg(priv
->adapter
, ERROR
,
3597 "Pattern not supported\n");
3601 if (!crule
->patterns
[i
].pkt_offset
) {
3604 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3605 if (pkt_type
&& mrule
->pkt_type
) {
3606 mwifiex_dbg(priv
->adapter
, ERROR
,
3607 "Multiple packet types not allowed\n");
3609 } else if (pkt_type
) {
3610 mrule
->pkt_type
= pkt_type
;
3615 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3616 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3618 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3620 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3621 memcpy(param
->operand_byte_stream
, byte_seq
,
3622 param
->operand_len
);
3623 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3626 mrule
->num_of_fields
++;
3629 if (!mrule
->pkt_type
) {
3630 mwifiex_dbg(priv
->adapter
, ERROR
,
3631 "Packet type can not be determined\n");
3638 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3639 struct cfg80211_coalesce
*coalesce
)
3641 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3643 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3644 struct mwifiex_private
*priv
=
3645 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3647 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3649 mwifiex_dbg(adapter
, WARN
,
3650 "Disable coalesce and reset all previous rules\n");
3651 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3652 HostCmd_ACT_GEN_SET
, 0,
3653 &coalesce_cfg
, true);
3656 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3657 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3658 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3659 &coalesce_cfg
.rule
[i
]);
3661 mwifiex_dbg(adapter
, ERROR
,
3662 "Recheck the patterns provided for rule %d\n",
3668 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3669 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3672 /* cfg80211 ops handler for tdls_mgmt.
3673 * Function prepares TDLS action frame packets and forwards them to FW
3676 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3677 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3678 u16 status_code
, u32 peer_capability
,
3679 bool initiator
, const u8
*extra_ies
,
3680 size_t extra_ies_len
)
3682 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3685 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3688 /* make sure we are in station mode and connected */
3689 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3692 switch (action_code
) {
3693 case WLAN_TDLS_SETUP_REQUEST
:
3694 mwifiex_dbg(priv
->adapter
, MSG
,
3695 "Send TDLS Setup Request to %pM status_code=%d\n",
3697 mwifiex_add_auto_tdls_peer(priv
, peer
);
3698 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3699 dialog_token
, status_code
,
3700 extra_ies
, extra_ies_len
);
3702 case WLAN_TDLS_SETUP_RESPONSE
:
3703 mwifiex_add_auto_tdls_peer(priv
, peer
);
3704 mwifiex_dbg(priv
->adapter
, MSG
,
3705 "Send TDLS Setup Response to %pM status_code=%d\n",
3707 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3708 dialog_token
, status_code
,
3709 extra_ies
, extra_ies_len
);
3711 case WLAN_TDLS_SETUP_CONFIRM
:
3712 mwifiex_dbg(priv
->adapter
, MSG
,
3713 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3715 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3716 dialog_token
, status_code
,
3717 extra_ies
, extra_ies_len
);
3719 case WLAN_TDLS_TEARDOWN
:
3720 mwifiex_dbg(priv
->adapter
, MSG
,
3721 "Send TDLS Tear down to %pM\n", peer
);
3722 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3723 dialog_token
, status_code
,
3724 extra_ies
, extra_ies_len
);
3726 case WLAN_TDLS_DISCOVERY_REQUEST
:
3727 mwifiex_dbg(priv
->adapter
, MSG
,
3728 "Send TDLS Discovery Request to %pM\n", peer
);
3729 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3730 dialog_token
, status_code
,
3731 extra_ies
, extra_ies_len
);
3733 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3734 mwifiex_dbg(priv
->adapter
, MSG
,
3735 "Send TDLS Discovery Response to %pM\n", peer
);
3736 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3737 dialog_token
, status_code
,
3738 extra_ies
, extra_ies_len
);
3741 mwifiex_dbg(priv
->adapter
, ERROR
,
3742 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3751 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3752 const u8
*peer
, enum nl80211_tdls_operation action
)
3754 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3756 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3757 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3760 /* make sure we are in station mode and connected */
3761 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3764 mwifiex_dbg(priv
->adapter
, MSG
,
3765 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3768 case NL80211_TDLS_ENABLE_LINK
:
3769 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3771 case NL80211_TDLS_DISABLE_LINK
:
3772 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3774 case NL80211_TDLS_TEARDOWN
:
3775 /* shouldn't happen!*/
3776 mwifiex_dbg(priv
->adapter
, ERROR
,
3777 "tdls_oper: teardown from driver not supported\n");
3779 case NL80211_TDLS_SETUP
:
3780 /* shouldn't happen!*/
3781 mwifiex_dbg(priv
->adapter
, ERROR
,
3782 "tdls_oper: setup from driver not supported\n");
3784 case NL80211_TDLS_DISCOVERY_REQ
:
3785 /* shouldn't happen!*/
3786 mwifiex_dbg(priv
->adapter
, ERROR
,
3787 "tdls_oper: discovery from driver not supported\n");
3790 mwifiex_dbg(priv
->adapter
, ERROR
,
3791 "tdls_oper: operation not supported\n");
3795 return mwifiex_tdls_oper(priv
, peer
, action
);
3799 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3800 const u8
*addr
, u8 oper_class
,
3801 struct cfg80211_chan_def
*chandef
)
3803 struct mwifiex_sta_node
*sta_ptr
;
3804 unsigned long flags
;
3806 u8 second_chan_offset
, band
;
3807 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3809 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3810 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3811 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3814 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3819 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3820 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3821 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3825 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3826 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3827 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3831 chan
= chandef
->chan
->hw_value
;
3832 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3833 band
= chandef
->chan
->band
;
3834 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3840 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3841 struct net_device
*dev
,
3844 struct mwifiex_sta_node
*sta_ptr
;
3845 unsigned long flags
;
3846 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3848 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3849 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3850 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3853 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3855 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3856 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3857 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3858 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3861 mwifiex_stop_tdls_cs(priv
, addr
);
3865 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3866 const u8
*mac
, struct station_parameters
*params
)
3868 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3870 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3873 /* make sure we are in station mode and connected */
3874 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3877 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3881 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3882 struct cfg80211_csa_settings
*params
)
3884 struct ieee_types_header
*chsw_ie
;
3885 struct ieee80211_channel_sw_ie
*channel_sw
;
3887 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3889 if (priv
->adapter
->scan_processing
) {
3890 mwifiex_dbg(priv
->adapter
, ERROR
,
3891 "radar detection: scan in process...\n");
3895 if (priv
->wdev
.cac_started
)
3898 if (cfg80211_chandef_identical(¶ms
->chandef
,
3899 &priv
->dfs_chandef
))
3902 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3903 params
->beacon_csa
.tail
,
3904 params
->beacon_csa
.tail_len
);
3906 mwifiex_dbg(priv
->adapter
, ERROR
,
3907 "Could not parse channel switch announcement IE\n");
3911 channel_sw
= (void *)(chsw_ie
+ 1);
3912 if (channel_sw
->mode
) {
3913 if (netif_carrier_ok(priv
->netdev
))
3914 netif_carrier_off(priv
->netdev
);
3915 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3918 if (mwifiex_del_mgmt_ies(priv
))
3919 mwifiex_dbg(priv
->adapter
, ERROR
,
3920 "Failed to delete mgmt IEs!\n");
3922 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3923 mwifiex_dbg(priv
->adapter
, ERROR
,
3924 "%s: setting mgmt ies failed\n", __func__
);
3928 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3929 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3930 sizeof(priv
->beacon_after
));
3932 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3933 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3934 msecs_to_jiffies(chsw_msec
));
3938 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3939 struct wireless_dev
*wdev
,
3940 struct cfg80211_chan_def
*chandef
)
3942 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3943 struct mwifiex_bssdescriptor
*curr_bss
;
3944 struct ieee80211_channel
*chan
;
3945 u8 second_chan_offset
;
3946 enum nl80211_channel_type chan_type
;
3947 enum nl80211_band band
;
3951 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3952 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3953 *chandef
= priv
->bss_chandef
;
3955 } else if (priv
->media_connected
) {
3956 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3957 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3958 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3959 chan
= ieee80211_get_channel(wiphy
, freq
);
3961 if (priv
->ht_param_present
) {
3962 second_chan_offset
= priv
->assoc_resp_ht_param
&
3963 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3964 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3965 (second_chan_offset
);
3966 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3968 cfg80211_chandef_create(chandef
, chan
,
3969 NL80211_CHAN_NO_HT
);
3977 #ifdef CONFIG_NL80211_TESTMODE
3979 enum mwifiex_tm_attr
{
3980 __MWIFIEX_TM_ATTR_INVALID
= 0,
3981 MWIFIEX_TM_ATTR_CMD
= 1,
3982 MWIFIEX_TM_ATTR_DATA
= 2,
3985 __MWIFIEX_TM_ATTR_AFTER_LAST
,
3986 MWIFIEX_TM_ATTR_MAX
= __MWIFIEX_TM_ATTR_AFTER_LAST
- 1,
3989 static const struct nla_policy mwifiex_tm_policy
[MWIFIEX_TM_ATTR_MAX
+ 1] = {
3990 [MWIFIEX_TM_ATTR_CMD
] = { .type
= NLA_U32
},
3991 [MWIFIEX_TM_ATTR_DATA
] = { .type
= NLA_BINARY
,
3992 .len
= MWIFIEX_SIZE_OF_CMD_BUFFER
},
3995 enum mwifiex_tm_command
{
3996 MWIFIEX_TM_CMD_HOSTCMD
= 0,
3999 static int mwifiex_tm_cmd(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
4000 void *data
, int len
)
4002 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
4003 struct mwifiex_ds_misc_cmd
*hostcmd
;
4004 struct nlattr
*tb
[MWIFIEX_TM_ATTR_MAX
+ 1];
4005 struct sk_buff
*skb
;
4011 err
= nla_parse(tb
, MWIFIEX_TM_ATTR_MAX
, data
, len
, mwifiex_tm_policy
,
4016 if (!tb
[MWIFIEX_TM_ATTR_CMD
])
4019 switch (nla_get_u32(tb
[MWIFIEX_TM_ATTR_CMD
])) {
4020 case MWIFIEX_TM_CMD_HOSTCMD
:
4021 if (!tb
[MWIFIEX_TM_ATTR_DATA
])
4024 hostcmd
= kzalloc(sizeof(*hostcmd
), GFP_KERNEL
);
4028 hostcmd
->len
= nla_len(tb
[MWIFIEX_TM_ATTR_DATA
]);
4029 memcpy(hostcmd
->cmd
, nla_data(tb
[MWIFIEX_TM_ATTR_DATA
]),
4032 if (mwifiex_send_cmd(priv
, 0, 0, 0, hostcmd
, true)) {
4033 dev_err(priv
->adapter
->dev
, "Failed to process hostcmd\n");
4037 /* process hostcmd response*/
4038 skb
= cfg80211_testmode_alloc_reply_skb(wiphy
, hostcmd
->len
);
4041 err
= nla_put(skb
, MWIFIEX_TM_ATTR_DATA
,
4042 hostcmd
->len
, hostcmd
->cmd
);
4048 err
= cfg80211_testmode_reply(skb
);
4058 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
4059 struct net_device
*dev
,
4060 struct cfg80211_chan_def
*chandef
,
4063 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4064 struct mwifiex_radar_params radar_params
;
4066 if (priv
->adapter
->scan_processing
) {
4067 mwifiex_dbg(priv
->adapter
, ERROR
,
4068 "radar detection: scan already in process...\n");
4072 if (!mwifiex_is_11h_active(priv
)) {
4073 mwifiex_dbg(priv
->adapter
, INFO
,
4074 "Enable 11h extensions in FW\n");
4075 if (mwifiex_11h_activate(priv
, true)) {
4076 mwifiex_dbg(priv
->adapter
, ERROR
,
4077 "Failed to activate 11h extensions!!");
4080 priv
->state_11h
.is_11h_active
= true;
4083 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
4084 radar_params
.chandef
= chandef
;
4085 radar_params
.cac_time_ms
= cac_time_ms
;
4087 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
4089 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
4090 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
4093 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
4094 msecs_to_jiffies(cac_time_ms
));
4099 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
4101 struct station_parameters
*params
)
4104 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4106 /* we support change_station handler only for TDLS peers*/
4107 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
4110 /* make sure we are in station mode and connected */
4111 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
4114 priv
->sta_params
= params
;
4116 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
4117 priv
->sta_params
= NULL
;
4122 /* station cfg80211 operations */
4123 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
4124 .add_virtual_intf
= mwifiex_add_virtual_intf
,
4125 .del_virtual_intf
= mwifiex_del_virtual_intf
,
4126 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
4127 .scan
= mwifiex_cfg80211_scan
,
4128 .connect
= mwifiex_cfg80211_connect
,
4129 .disconnect
= mwifiex_cfg80211_disconnect
,
4130 .get_station
= mwifiex_cfg80211_get_station
,
4131 .dump_station
= mwifiex_cfg80211_dump_station
,
4132 .dump_survey
= mwifiex_cfg80211_dump_survey
,
4133 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
4134 .join_ibss
= mwifiex_cfg80211_join_ibss
,
4135 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
4136 .add_key
= mwifiex_cfg80211_add_key
,
4137 .del_key
= mwifiex_cfg80211_del_key
,
4138 .set_default_mgmt_key
= mwifiex_cfg80211_set_default_mgmt_key
,
4139 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
4140 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
4141 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
4142 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
4143 .set_default_key
= mwifiex_cfg80211_set_default_key
,
4144 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
4145 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
4146 .get_tx_power
= mwifiex_cfg80211_get_tx_power
,
4147 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
4148 .start_ap
= mwifiex_cfg80211_start_ap
,
4149 .stop_ap
= mwifiex_cfg80211_stop_ap
,
4150 .change_beacon
= mwifiex_cfg80211_change_beacon
,
4151 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
4152 .set_antenna
= mwifiex_cfg80211_set_antenna
,
4153 .get_antenna
= mwifiex_cfg80211_get_antenna
,
4154 .del_station
= mwifiex_cfg80211_del_station
,
4155 .sched_scan_start
= mwifiex_cfg80211_sched_scan_start
,
4156 .sched_scan_stop
= mwifiex_cfg80211_sched_scan_stop
,
4158 .suspend
= mwifiex_cfg80211_suspend
,
4159 .resume
= mwifiex_cfg80211_resume
,
4160 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
4161 .set_rekey_data
= mwifiex_set_rekey_data
,
4163 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
4164 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
4165 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
4166 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
4167 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
4168 .add_station
= mwifiex_cfg80211_add_station
,
4169 .change_station
= mwifiex_cfg80211_change_station
,
4170 CFG80211_TESTMODE_CMD(mwifiex_tm_cmd
)
4171 .get_channel
= mwifiex_cfg80211_get_channel
,
4172 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
4173 .channel_switch
= mwifiex_cfg80211_channel_switch
,
4177 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
4178 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
4179 WIPHY_WOWLAN_NET_DETECT
| WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
4180 WIPHY_WOWLAN_GTK_REKEY_FAILURE
,
4181 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
4182 .pattern_min_len
= 1,
4183 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4184 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4185 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
4189 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
4191 if (!alpha2
|| strlen(alpha2
) != 2)
4194 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
4200 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
4201 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
4202 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
4203 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
4204 .pattern_min_len
= 1,
4205 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4206 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4209 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
4211 u32 n_channels_bg
, n_channels_a
= 0;
4213 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
4215 if (adapter
->config_bands
& BAND_A
)
4216 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
4218 adapter
->num_in_chan_stats
= max_t(u32
, n_channels_bg
, n_channels_a
);
4219 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
4220 adapter
->num_in_chan_stats
);
4222 if (!adapter
->chan_stats
)
4229 * This function registers the device with CFG802.11 subsystem.
4231 * The function creates the wireless device/wiphy, populates it with
4232 * default parameters and handler function pointers, and finally
4233 * registers the device.
4236 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
4240 struct wiphy
*wiphy
;
4241 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
4245 /* create a new wiphy for use with cfg80211 */
4246 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
4247 sizeof(struct mwifiex_adapter
*));
4249 mwifiex_dbg(adapter
, ERROR
,
4250 "%s: creating new wiphy\n", __func__
);
4253 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4254 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4255 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
4256 wiphy
->max_remain_on_channel_duration
= 5000;
4257 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
4258 BIT(NL80211_IFTYPE_ADHOC
) |
4259 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
4260 BIT(NL80211_IFTYPE_P2P_GO
) |
4261 BIT(NL80211_IFTYPE_AP
);
4263 wiphy
->bands
[NL80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
4264 if (adapter
->config_bands
& BAND_A
)
4265 wiphy
->bands
[NL80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
4267 wiphy
->bands
[NL80211_BAND_5GHZ
] = NULL
;
4269 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
4270 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
4271 else if (adapter
->is_hw_11ac_capable
)
4272 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
4274 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
4275 wiphy
->n_iface_combinations
= 1;
4277 /* Initialize cipher suits */
4278 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
4279 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
4281 if (adapter
->regd
) {
4282 wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
4283 REGULATORY_DISABLE_BEACON_HINTS
|
4284 REGULATORY_COUNTRY_IE_IGNORE
;
4285 wiphy_apply_custom_regulatory(wiphy
, adapter
->regd
);
4288 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
4289 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
4290 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
4291 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
4292 WIPHY_FLAG_AP_UAPSD
|
4293 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
4294 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
4295 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
4297 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4298 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
4299 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
4302 wiphy
->wowlan
= &mwifiex_wowlan_support
;
4305 wiphy
->coalesce
= &mwifiex_coalesce_support
;
4307 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
4308 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
4309 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
4311 wiphy
->max_sched_scan_reqs
= 1;
4312 wiphy
->max_sched_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4313 wiphy
->max_sched_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4314 wiphy
->max_match_sets
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4316 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
4317 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
4319 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
4320 NL80211_FEATURE_INACTIVITY_TIMER
|
4321 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
4322 NL80211_FEATURE_NEED_OBSS_SCAN
|
4323 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
|
4324 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
|
4325 NL80211_FEATURE_ND_RANDOM_MAC_ADDR
;
4327 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4328 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
4330 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
4331 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
4333 /* Reserve space for mwifiex specific private data for BSS */
4334 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
4336 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
4338 /* Set struct mwifiex_adapter pointer in wiphy_priv */
4339 wdev_priv
= wiphy_priv(wiphy
);
4340 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
4342 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
4344 ret
= wiphy_register(wiphy
);
4346 mwifiex_dbg(adapter
, ERROR
,
4347 "%s: wiphy_register failed: %d\n", __func__
, ret
);
4352 if (!adapter
->regd
) {
4353 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
4354 mwifiex_dbg(adapter
, INFO
,
4355 "driver hint alpha2: %2.2s\n", reg_alpha2
);
4356 regulatory_hint(wiphy
, reg_alpha2
);
4358 if (adapter
->region_code
== 0x00) {
4359 mwifiex_dbg(adapter
, WARN
,
4360 "Ignore world regulatory domain\n");
4362 wiphy
->regulatory_flags
|=
4363 REGULATORY_DISABLE_BEACON_HINTS
|
4364 REGULATORY_COUNTRY_IE_IGNORE
;
4366 mwifiex_11d_code_2_region(
4367 adapter
->region_code
);
4369 regulatory_hint(wiphy
, country_code
))
4370 mwifiex_dbg(priv
->adapter
, ERROR
,
4371 "regulatory_hint() failed\n");
4376 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4377 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
4378 wiphy
->frag_threshold
= thr
;
4379 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4380 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
4381 wiphy
->rts_threshold
= thr
;
4382 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4383 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
4384 wiphy
->retry_short
= (u8
) retry
;
4385 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4386 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
4387 wiphy
->retry_long
= (u8
) retry
;
4389 adapter
->wiphy
= wiphy
;