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_get_chan_type(struct mwifiex_private
*priv
)
100 struct mwifiex_channel_band channel_band
;
103 ret
= mwifiex_get_chan_info(priv
, &channel_band
);
106 switch (channel_band
.band_config
.chan_width
) {
108 if (IS_11N_ENABLED(priv
))
109 return NL80211_CHAN_HT20
;
111 return NL80211_CHAN_NO_HT
;
113 if (channel_band
.band_config
.chan2_offset
==
115 return NL80211_CHAN_HT40PLUS
;
117 return NL80211_CHAN_HT40MINUS
;
119 return NL80211_CHAN_HT20
;
123 return NL80211_CHAN_HT20
;
127 * This function checks whether WEP is set.
130 mwifiex_is_alg_wep(u32 cipher
)
133 case WLAN_CIPHER_SUITE_WEP40
:
134 case WLAN_CIPHER_SUITE_WEP104
:
144 * This function retrieves the private structure from kernel wiphy structure.
146 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
148 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
152 * CFG802.11 operation handler to delete a network key.
155 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
156 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
158 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
159 static const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
160 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
162 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
163 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
167 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
172 * This function forms an skb for management frame.
175 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
177 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
179 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
181 pkt_len
= len
+ ETH_ALEN
;
183 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
184 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
185 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
187 memcpy(skb_push(skb
, sizeof(tx_control
)),
188 &tx_control
, sizeof(tx_control
));
190 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
192 /* Add packet data and address4 */
193 skb_put_data(skb
, buf
, sizeof(struct ieee80211_hdr_3addr
));
194 skb_put_data(skb
, addr
, ETH_ALEN
);
195 skb_put_data(skb
, buf
+ sizeof(struct ieee80211_hdr_3addr
),
196 len
- sizeof(struct ieee80211_hdr_3addr
));
198 skb
->priority
= LOW_PRIO_TID
;
199 __net_timestamp(skb
);
205 * CFG802.11 operation handler to transmit a management frame.
208 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
209 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
211 const u8
*buf
= params
->buf
;
212 size_t len
= params
->len
;
215 const struct ieee80211_mgmt
*mgmt
;
216 struct mwifiex_txinfo
*tx_info
;
217 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
220 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
224 mgmt
= (const struct ieee80211_mgmt
*)buf
;
225 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
226 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
227 /* Since we support offload probe resp, we need to skip probe
228 * resp in AP or GO mode */
229 mwifiex_dbg(priv
->adapter
, INFO
,
230 "info: skip to send probe resp in AP or GO mode\n");
234 pkt_len
= len
+ ETH_ALEN
;
235 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
236 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
237 pkt_len
+ sizeof(pkt_len
));
240 mwifiex_dbg(priv
->adapter
, ERROR
,
241 "allocate skb failed for management frame\n");
245 tx_info
= MWIFIEX_SKB_TXCB(skb
);
246 memset(tx_info
, 0, sizeof(*tx_info
));
247 tx_info
->bss_num
= priv
->bss_num
;
248 tx_info
->bss_type
= priv
->bss_type
;
249 tx_info
->pkt_len
= pkt_len
;
251 mwifiex_form_mgmt_frame(skb
, buf
, len
);
252 *cookie
= prandom_u32() | 1;
254 if (ieee80211_is_action(mgmt
->frame_control
))
255 skb
= mwifiex_clone_skb_for_tx_status(priv
,
257 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
259 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
262 mwifiex_queue_tx_pkt(priv
, skb
);
264 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
269 * CFG802.11 operation handler to register a mgmt frame.
272 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
273 struct wireless_dev
*wdev
,
274 u16 frame_type
, bool reg
)
276 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
280 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
282 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
284 if (mask
!= priv
->mgmt_frame_mask
) {
285 priv
->mgmt_frame_mask
= mask
;
286 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
287 HostCmd_ACT_GEN_SET
, 0,
288 &priv
->mgmt_frame_mask
, false);
289 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
294 * CFG802.11 operation handler to remain on channel.
297 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
298 struct wireless_dev
*wdev
,
299 struct ieee80211_channel
*chan
,
300 unsigned int duration
, u64
*cookie
)
302 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
305 if (!chan
|| !cookie
) {
306 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
310 if (priv
->roc_cfg
.cookie
) {
311 mwifiex_dbg(priv
->adapter
, INFO
,
312 "info: ongoing ROC, cookie = 0x%llx\n",
313 priv
->roc_cfg
.cookie
);
317 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
321 *cookie
= prandom_u32() | 1;
322 priv
->roc_cfg
.cookie
= *cookie
;
323 priv
->roc_cfg
.chan
= *chan
;
325 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
326 duration
, GFP_ATOMIC
);
328 mwifiex_dbg(priv
->adapter
, INFO
,
329 "info: ROC, cookie = 0x%llx\n", *cookie
);
336 * CFG802.11 operation handler to cancel remain on channel.
339 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
340 struct wireless_dev
*wdev
, u64 cookie
)
342 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
345 if (cookie
!= priv
->roc_cfg
.cookie
)
348 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
349 &priv
->roc_cfg
.chan
, 0);
352 cfg80211_remain_on_channel_expired(wdev
, cookie
,
356 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
358 mwifiex_dbg(priv
->adapter
, INFO
,
359 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
366 * CFG802.11 operation handler to set Tx power.
369 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
370 struct wireless_dev
*wdev
,
371 enum nl80211_tx_power_setting type
,
374 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
375 struct mwifiex_private
*priv
;
376 struct mwifiex_power_cfg power_cfg
;
377 int dbm
= MBM_TO_DBM(mbm
);
379 if (type
== NL80211_TX_POWER_FIXED
) {
380 power_cfg
.is_power_auto
= 0;
381 power_cfg
.power_level
= dbm
;
383 power_cfg
.is_power_auto
= 1;
386 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
388 return mwifiex_set_tx_power(priv
, &power_cfg
);
392 * CFG802.11 operation handler to get Tx power.
395 mwifiex_cfg80211_get_tx_power(struct wiphy
*wiphy
,
396 struct wireless_dev
*wdev
,
399 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
400 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
401 MWIFIEX_BSS_ROLE_ANY
);
402 int ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_RF_TX_PWR
,
403 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
408 /* tx_power_level is set in HostCmd_CMD_RF_TX_PWR command handler */
409 *dbm
= priv
->tx_power_level
;
415 * CFG802.11 operation handler to set Power Save option.
417 * The timeout value, if provided, is currently ignored.
420 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
421 struct net_device
*dev
,
422 bool enabled
, int timeout
)
424 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
428 mwifiex_dbg(priv
->adapter
, INFO
,
429 "info: ignore timeout value for IEEE Power Save\n");
433 return mwifiex_drv_set_power(priv
, &ps_mode
);
437 * CFG802.11 operation handler to set the default network key.
440 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
441 u8 key_index
, bool unicast
,
444 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
446 /* Return if WEP key not configured */
447 if (!priv
->sec_info
.wep_enabled
)
450 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
451 priv
->wep_key_curr_index
= key_index
;
452 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
454 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
462 * CFG802.11 operation handler to add a network key.
465 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
466 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
467 struct key_params
*params
)
469 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
470 struct mwifiex_wep_key
*wep_key
;
471 static const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
472 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
474 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
475 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
476 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
477 if (params
->key
&& params
->key_len
) {
478 wep_key
= &priv
->wep_key
[key_index
];
479 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
480 memcpy(wep_key
->key_material
, params
->key
,
482 wep_key
->key_index
= key_index
;
483 wep_key
->key_length
= params
->key_len
;
484 priv
->sec_info
.wep_enabled
= 1;
489 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
490 key_index
, peer_mac
, 0)) {
491 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
499 * CFG802.11 operation handler to set default mgmt key.
502 mwifiex_cfg80211_set_default_mgmt_key(struct wiphy
*wiphy
,
503 struct net_device
*netdev
,
506 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
507 struct mwifiex_ds_encrypt_key encrypt_key
;
509 wiphy_dbg(wiphy
, "set default mgmt key, key index=%d\n", key_index
);
511 memset(&encrypt_key
, 0, sizeof(struct mwifiex_ds_encrypt_key
));
512 encrypt_key
.key_len
= WLAN_KEY_LEN_CCMP
;
513 encrypt_key
.key_index
= key_index
;
514 encrypt_key
.is_igtk_def_key
= true;
515 eth_broadcast_addr(encrypt_key
.mac_addr
);
517 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
518 HostCmd_ACT_GEN_SET
, true, &encrypt_key
, true);
522 * This function sends domain information to the firmware.
524 * The following information are passed to the firmware -
526 * - Sub bands (first channel, number of channels, maximum Tx power)
528 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
530 u8 no_of_triplet
= 0;
531 struct ieee80211_country_ie_triplet
*t
;
532 u8 no_of_parsed_chan
= 0;
533 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
535 enum nl80211_band band
;
536 struct ieee80211_supported_band
*sband
;
537 struct ieee80211_channel
*ch
;
538 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
539 struct mwifiex_private
*priv
;
540 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
542 /* Set country code */
543 domain_info
->country_code
[0] = adapter
->country_code
[0];
544 domain_info
->country_code
[1] = adapter
->country_code
[1];
545 domain_info
->country_code
[2] = ' ';
547 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
548 if (!wiphy
->bands
[band
]) {
549 mwifiex_dbg(adapter
, ERROR
,
550 "11D: setting domain info in FW\n");
554 sband
= wiphy
->bands
[band
];
556 for (i
= 0; i
< sband
->n_channels
; i
++) {
557 ch
= &sband
->channels
[i
];
558 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
563 first_chan
= (u32
) ch
->hw_value
;
564 next_chan
= first_chan
;
565 max_pwr
= ch
->max_power
;
566 no_of_parsed_chan
= 1;
570 if (ch
->hw_value
== next_chan
+ 1 &&
571 ch
->max_power
== max_pwr
) {
575 t
= &domain_info
->triplet
[no_of_triplet
];
576 t
->chans
.first_channel
= first_chan
;
577 t
->chans
.num_channels
= no_of_parsed_chan
;
578 t
->chans
.max_power
= max_pwr
;
580 first_chan
= (u32
) ch
->hw_value
;
581 next_chan
= first_chan
;
582 max_pwr
= ch
->max_power
;
583 no_of_parsed_chan
= 1;
588 t
= &domain_info
->triplet
[no_of_triplet
];
589 t
->chans
.first_channel
= first_chan
;
590 t
->chans
.num_channels
= no_of_parsed_chan
;
591 t
->chans
.max_power
= max_pwr
;
595 domain_info
->no_of_triplet
= no_of_triplet
;
597 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
599 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
600 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
601 mwifiex_dbg(adapter
, INFO
,
602 "11D: setting domain info in FW\n");
609 static void mwifiex_reg_apply_radar_flags(struct wiphy
*wiphy
)
611 struct ieee80211_supported_band
*sband
;
612 struct ieee80211_channel
*chan
;
615 if (!wiphy
->bands
[NL80211_BAND_5GHZ
])
617 sband
= wiphy
->bands
[NL80211_BAND_5GHZ
];
619 for (i
= 0; i
< sband
->n_channels
; i
++) {
620 chan
= &sband
->channels
[i
];
621 if ((!(chan
->flags
& IEEE80211_CHAN_DISABLED
)) &&
622 (chan
->flags
& IEEE80211_CHAN_RADAR
))
623 chan
->flags
|= IEEE80211_CHAN_NO_IR
;
628 * CFG802.11 regulatory domain callback function.
630 * This function is called when the regulatory domain is changed due to the
631 * following reasons -
633 * - Set by system core
635 * - Set bt Country IE
637 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
638 struct regulatory_request
*request
)
640 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
641 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
642 MWIFIEX_BSS_ROLE_ANY
);
643 mwifiex_dbg(adapter
, INFO
,
644 "info: cfg80211 regulatory domain callback for %c%c\n",
645 request
->alpha2
[0], request
->alpha2
[1]);
646 mwifiex_reg_apply_radar_flags(wiphy
);
648 switch (request
->initiator
) {
649 case NL80211_REGDOM_SET_BY_DRIVER
:
650 case NL80211_REGDOM_SET_BY_CORE
:
651 case NL80211_REGDOM_SET_BY_USER
:
652 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
655 mwifiex_dbg(adapter
, ERROR
,
656 "unknown regdom initiator: %d\n",
661 /* Don't send world or same regdom info to firmware */
662 if (strncmp(request
->alpha2
, "00", 2) &&
663 strncmp(request
->alpha2
, adapter
->country_code
,
664 sizeof(request
->alpha2
))) {
665 memcpy(adapter
->country_code
, request
->alpha2
,
666 sizeof(request
->alpha2
));
667 mwifiex_send_domain_info_cmd_fw(wiphy
);
668 mwifiex_dnld_txpwr_table(priv
);
673 * This function sets the fragmentation threshold.
675 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
676 * and MWIFIEX_FRAG_MAX_VALUE.
679 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
681 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
682 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
683 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
685 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
686 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
691 * This function sets the RTS threshold.
693 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
694 * and MWIFIEX_RTS_MAX_VALUE.
697 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
699 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
700 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
702 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
703 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
708 * CFG802.11 operation handler to set wiphy parameters.
710 * This function can be used to set the RTS threshold and the
711 * Fragmentation threshold of the driver.
714 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
716 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
717 struct mwifiex_private
*priv
;
718 struct mwifiex_uap_bss_param
*bss_cfg
;
721 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
723 switch (priv
->bss_role
) {
724 case MWIFIEX_BSS_ROLE_UAP
:
725 if (priv
->bss_started
) {
726 mwifiex_dbg(adapter
, ERROR
,
727 "cannot change wiphy params when bss started");
731 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
735 mwifiex_set_sys_config_invalid_data(bss_cfg
);
737 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
738 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
739 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
740 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
741 if (changed
& WIPHY_PARAM_RETRY_LONG
)
742 bss_cfg
->retry_limit
= wiphy
->retry_long
;
744 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
746 UAP_BSS_PARAMS_I
, bss_cfg
,
751 mwifiex_dbg(adapter
, ERROR
,
752 "Failed to set wiphy phy params\n");
757 case MWIFIEX_BSS_ROLE_STA
:
758 if (priv
->media_connected
) {
759 mwifiex_dbg(adapter
, ERROR
,
760 "cannot change wiphy params when connected");
763 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
764 ret
= mwifiex_set_rts(priv
,
765 wiphy
->rts_threshold
);
769 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
770 ret
= mwifiex_set_frag(priv
,
771 wiphy
->frag_threshold
);
782 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
784 u16 mode
= P2P_MODE_DISABLE
;
786 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
787 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
794 * This function initializes the functionalities for P2P client.
795 * The P2P client initialization sequence is:
796 * disable -> device -> client
799 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
803 if (mwifiex_cfg80211_deinit_p2p(priv
))
806 mode
= P2P_MODE_DEVICE
;
807 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
808 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
811 mode
= P2P_MODE_CLIENT
;
812 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
813 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
820 * This function initializes the functionalities for P2P GO.
821 * The P2P GO initialization sequence is:
822 * disable -> device -> GO
825 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
829 if (mwifiex_cfg80211_deinit_p2p(priv
))
832 mode
= P2P_MODE_DEVICE
;
833 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
834 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
838 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
839 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
845 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
847 struct mwifiex_adapter
*adapter
= priv
->adapter
;
850 priv
->mgmt_frame_mask
= 0;
851 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
852 HostCmd_ACT_GEN_SET
, 0,
853 &priv
->mgmt_frame_mask
, false)) {
854 mwifiex_dbg(adapter
, ERROR
,
855 "could not unregister mgmt frame rx\n");
859 mwifiex_deauthenticate(priv
, NULL
);
861 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
862 adapter
->main_locked
= true;
863 if (adapter
->mwifiex_processing
) {
864 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
865 flush_workqueue(adapter
->workqueue
);
867 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
870 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
871 adapter
->rx_locked
= true;
872 if (adapter
->rx_processing
) {
873 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
874 flush_workqueue(adapter
->rx_workqueue
);
876 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
879 mwifiex_free_priv(priv
);
880 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
881 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
882 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
888 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
889 struct net_device
*dev
,
890 enum nl80211_iftype type
)
892 struct mwifiex_adapter
*adapter
= priv
->adapter
;
895 mwifiex_init_priv(priv
);
897 priv
->bss_mode
= type
;
898 priv
->wdev
.iftype
= type
;
900 mwifiex_init_priv_params(priv
, priv
->netdev
);
901 priv
->bss_started
= 0;
904 case NL80211_IFTYPE_STATION
:
905 case NL80211_IFTYPE_ADHOC
:
906 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
908 case NL80211_IFTYPE_P2P_CLIENT
:
909 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
911 case NL80211_IFTYPE_P2P_GO
:
912 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
914 case NL80211_IFTYPE_AP
:
915 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
918 mwifiex_dbg(adapter
, ERROR
,
919 "%s: changing to %d not supported\n",
924 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
925 adapter
->main_locked
= false;
926 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
928 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
929 adapter
->rx_locked
= false;
930 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
932 mwifiex_set_mac_address(priv
, dev
, false, NULL
);
938 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
939 enum nl80211_iftype curr_iftype
,
940 enum nl80211_iftype type
,
941 struct vif_params
*params
)
943 struct mwifiex_private
*priv
;
944 struct mwifiex_adapter
*adapter
;
946 priv
= mwifiex_netdev_get_priv(dev
);
951 adapter
= priv
->adapter
;
953 if (adapter
->curr_iface_comb
.p2p_intf
==
954 adapter
->iface_limit
.p2p_intf
) {
955 mwifiex_dbg(adapter
, ERROR
,
956 "cannot create multiple P2P ifaces\n");
960 mwifiex_dbg(adapter
, INFO
,
961 "%s: changing role to p2p\n", dev
->name
);
963 if (mwifiex_deinit_priv_params(priv
))
965 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
969 case NL80211_IFTYPE_P2P_CLIENT
:
970 if (mwifiex_cfg80211_init_p2p_client(priv
))
973 case NL80211_IFTYPE_P2P_GO
:
974 if (mwifiex_cfg80211_init_p2p_go(priv
))
978 mwifiex_dbg(adapter
, ERROR
,
979 "%s: changing to %d not supported\n",
984 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
985 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
988 if (mwifiex_sta_init_cmd(priv
, false, false))
991 switch (curr_iftype
) {
992 case NL80211_IFTYPE_STATION
:
993 case NL80211_IFTYPE_ADHOC
:
994 adapter
->curr_iface_comb
.sta_intf
--;
996 case NL80211_IFTYPE_AP
:
997 adapter
->curr_iface_comb
.uap_intf
--;
1003 adapter
->curr_iface_comb
.p2p_intf
++;
1004 dev
->ieee80211_ptr
->iftype
= type
;
1010 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
1011 enum nl80211_iftype curr_iftype
,
1012 enum nl80211_iftype type
,
1013 struct vif_params
*params
)
1015 struct mwifiex_private
*priv
;
1016 struct mwifiex_adapter
*adapter
;
1018 priv
= mwifiex_netdev_get_priv(dev
);
1023 adapter
= priv
->adapter
;
1025 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
1026 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
1027 (adapter
->curr_iface_comb
.sta_intf
==
1028 adapter
->iface_limit
.sta_intf
)) {
1029 mwifiex_dbg(adapter
, ERROR
,
1030 "cannot create multiple station/adhoc ifaces\n");
1034 if (type
== NL80211_IFTYPE_STATION
)
1035 mwifiex_dbg(adapter
, INFO
,
1036 "%s: changing role to station\n", dev
->name
);
1038 mwifiex_dbg(adapter
, INFO
,
1039 "%s: changing role to adhoc\n", dev
->name
);
1041 if (mwifiex_deinit_priv_params(priv
))
1043 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1045 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1046 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1048 if (mwifiex_sta_init_cmd(priv
, false, false))
1051 switch (curr_iftype
) {
1052 case NL80211_IFTYPE_P2P_CLIENT
:
1053 case NL80211_IFTYPE_P2P_GO
:
1054 adapter
->curr_iface_comb
.p2p_intf
--;
1056 case NL80211_IFTYPE_AP
:
1057 adapter
->curr_iface_comb
.uap_intf
--;
1063 adapter
->curr_iface_comb
.sta_intf
++;
1064 dev
->ieee80211_ptr
->iftype
= type
;
1069 mwifiex_change_vif_to_ap(struct net_device
*dev
,
1070 enum nl80211_iftype curr_iftype
,
1071 enum nl80211_iftype type
,
1072 struct vif_params
*params
)
1074 struct mwifiex_private
*priv
;
1075 struct mwifiex_adapter
*adapter
;
1077 priv
= mwifiex_netdev_get_priv(dev
);
1082 adapter
= priv
->adapter
;
1084 if (adapter
->curr_iface_comb
.uap_intf
==
1085 adapter
->iface_limit
.uap_intf
) {
1086 mwifiex_dbg(adapter
, ERROR
,
1087 "cannot create multiple AP ifaces\n");
1091 mwifiex_dbg(adapter
, INFO
,
1092 "%s: changing role to AP\n", dev
->name
);
1094 if (mwifiex_deinit_priv_params(priv
))
1096 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1098 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1099 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1101 if (mwifiex_sta_init_cmd(priv
, false, false))
1104 switch (curr_iftype
) {
1105 case NL80211_IFTYPE_P2P_CLIENT
:
1106 case NL80211_IFTYPE_P2P_GO
:
1107 adapter
->curr_iface_comb
.p2p_intf
--;
1109 case NL80211_IFTYPE_STATION
:
1110 case NL80211_IFTYPE_ADHOC
:
1111 adapter
->curr_iface_comb
.sta_intf
--;
1117 adapter
->curr_iface_comb
.uap_intf
++;
1118 dev
->ieee80211_ptr
->iftype
= type
;
1122 * CFG802.11 operation handler to change interface type.
1125 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1126 struct net_device
*dev
,
1127 enum nl80211_iftype type
,
1128 struct vif_params
*params
)
1130 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1131 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1133 if (priv
->scan_request
) {
1134 mwifiex_dbg(priv
->adapter
, ERROR
,
1135 "change virtual interface: scan in process\n");
1139 switch (curr_iftype
) {
1140 case NL80211_IFTYPE_ADHOC
:
1142 case NL80211_IFTYPE_STATION
:
1143 priv
->bss_mode
= type
;
1144 priv
->sec_info
.authentication_mode
=
1145 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1146 dev
->ieee80211_ptr
->iftype
= type
;
1147 mwifiex_deauthenticate(priv
, NULL
);
1148 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1149 HostCmd_ACT_GEN_SET
, 0, NULL
,
1151 case NL80211_IFTYPE_P2P_CLIENT
:
1152 case NL80211_IFTYPE_P2P_GO
:
1153 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1155 case NL80211_IFTYPE_AP
:
1156 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1158 case NL80211_IFTYPE_UNSPECIFIED
:
1159 mwifiex_dbg(priv
->adapter
, INFO
,
1160 "%s: kept type as IBSS\n", dev
->name
);
1162 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1165 mwifiex_dbg(priv
->adapter
, ERROR
,
1166 "%s: changing to %d not supported\n",
1171 case NL80211_IFTYPE_STATION
:
1173 case NL80211_IFTYPE_ADHOC
:
1174 priv
->bss_mode
= type
;
1175 priv
->sec_info
.authentication_mode
=
1176 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1177 dev
->ieee80211_ptr
->iftype
= type
;
1178 mwifiex_deauthenticate(priv
, NULL
);
1179 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1180 HostCmd_ACT_GEN_SET
, 0, NULL
,
1182 case NL80211_IFTYPE_P2P_CLIENT
:
1183 case NL80211_IFTYPE_P2P_GO
:
1184 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1186 case NL80211_IFTYPE_AP
:
1187 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1189 case NL80211_IFTYPE_UNSPECIFIED
:
1190 mwifiex_dbg(priv
->adapter
, INFO
,
1191 "%s: kept type as STA\n", dev
->name
);
1193 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1196 mwifiex_dbg(priv
->adapter
, ERROR
,
1197 "%s: changing to %d not supported\n",
1202 case NL80211_IFTYPE_AP
:
1204 case NL80211_IFTYPE_ADHOC
:
1205 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1208 case NL80211_IFTYPE_P2P_CLIENT
:
1209 case NL80211_IFTYPE_P2P_GO
:
1210 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1212 case NL80211_IFTYPE_UNSPECIFIED
:
1213 mwifiex_dbg(priv
->adapter
, INFO
,
1214 "%s: kept type as AP\n", dev
->name
);
1216 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1219 mwifiex_dbg(priv
->adapter
, ERROR
,
1220 "%s: changing to %d not supported\n",
1225 case NL80211_IFTYPE_P2P_CLIENT
:
1226 case NL80211_IFTYPE_P2P_GO
:
1228 case NL80211_IFTYPE_STATION
:
1229 if (mwifiex_cfg80211_deinit_p2p(priv
))
1231 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1232 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1233 dev
->ieee80211_ptr
->iftype
= type
;
1234 if (mwifiex_deinit_priv_params(priv
))
1236 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1238 if (mwifiex_sta_init_cmd(priv
, false, false))
1241 case NL80211_IFTYPE_ADHOC
:
1242 if (mwifiex_cfg80211_deinit_p2p(priv
))
1244 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1247 case NL80211_IFTYPE_AP
:
1248 if (mwifiex_cfg80211_deinit_p2p(priv
))
1250 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1252 case NL80211_IFTYPE_UNSPECIFIED
:
1253 mwifiex_dbg(priv
->adapter
, INFO
,
1254 "%s: kept type as P2P\n", dev
->name
);
1256 case NL80211_IFTYPE_P2P_CLIENT
:
1257 case NL80211_IFTYPE_P2P_GO
:
1260 mwifiex_dbg(priv
->adapter
, ERROR
,
1261 "%s: changing to %d not supported\n",
1267 mwifiex_dbg(priv
->adapter
, ERROR
,
1268 "%s: unknown iftype: %d\n",
1269 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1278 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 rateinfo
, u8 htinfo
,
1279 struct rate_info
*rate
)
1281 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1283 if (adapter
->is_hw_11ac_capable
) {
1284 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1285 if (htinfo
& BIT(0)) {
1287 rate
->mcs
= rateinfo
;
1288 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1290 if (htinfo
& BIT(1)) {
1292 rate
->mcs
= rateinfo
& 0x0F;
1293 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1296 if (htinfo
& (BIT(1) | BIT(0))) {
1298 switch (htinfo
& (BIT(3) | BIT(2))) {
1300 rate
->bw
= RATE_INFO_BW_20
;
1303 rate
->bw
= RATE_INFO_BW_40
;
1306 rate
->bw
= RATE_INFO_BW_80
;
1308 case (BIT(3) | BIT(2)):
1309 rate
->bw
= RATE_INFO_BW_160
;
1313 if (htinfo
& BIT(4))
1314 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1316 if ((rateinfo
>> 4) == 1)
1323 * Bit 0 in htinfo indicates that current rate is 11n. Valid
1324 * MCS index values for us are 0 to 15.
1326 if ((htinfo
& BIT(0)) && (rateinfo
< 16)) {
1327 rate
->mcs
= rateinfo
;
1328 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1329 rate
->bw
= RATE_INFO_BW_20
;
1330 if (htinfo
& BIT(1))
1331 rate
->bw
= RATE_INFO_BW_40
;
1332 if (htinfo
& BIT(2))
1333 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1339 * This function dumps the station information on a buffer.
1341 * The following information are shown -
1342 * - Total bytes transmitted
1343 * - Total bytes received
1344 * - Total packets transmitted
1345 * - Total packets received
1346 * - Signal quality level
1347 * - Transmission rate
1350 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1351 struct mwifiex_sta_node
*node
,
1352 struct station_info
*sinfo
)
1356 sinfo
->filled
= BIT_ULL(NL80211_STA_INFO_RX_BYTES
) | BIT_ULL(NL80211_STA_INFO_TX_BYTES
) |
1357 BIT_ULL(NL80211_STA_INFO_RX_PACKETS
) | BIT_ULL(NL80211_STA_INFO_TX_PACKETS
) |
1358 BIT_ULL(NL80211_STA_INFO_TX_BITRATE
) |
1359 BIT_ULL(NL80211_STA_INFO_SIGNAL
) | BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG
);
1361 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1365 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME
) |
1366 BIT_ULL(NL80211_STA_INFO_TX_FAILED
);
1367 sinfo
->inactive_time
=
1368 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1370 sinfo
->signal
= node
->stats
.rssi
;
1371 sinfo
->signal_avg
= node
->stats
.rssi
;
1372 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1373 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1374 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1375 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1376 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1378 mwifiex_parse_htinfo(priv
, priv
->tx_rate
,
1379 node
->stats
.last_tx_htinfo
,
1381 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1386 /* Get signal information from the firmware */
1387 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1388 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1389 mwifiex_dbg(priv
->adapter
, ERROR
,
1390 "failed to get signal information\n");
1394 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1395 mwifiex_dbg(priv
->adapter
, ERROR
,
1396 "getting data rate error\n");
1400 /* Get DTIM period information from firmware */
1401 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1402 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1403 &priv
->dtim_period
, true);
1405 mwifiex_parse_htinfo(priv
, priv
->tx_rate
, priv
->tx_htinfo
,
1408 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1409 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1410 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1411 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1412 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1413 sinfo
->signal
= priv
->bcn_rssi_avg
;
1414 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1415 sinfo
->txrate
.legacy
= rate
* 5;
1417 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1418 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_BSS_PARAM
);
1419 sinfo
->bss_param
.flags
= 0;
1420 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1421 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1422 sinfo
->bss_param
.flags
|=
1423 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1424 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1425 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1426 sinfo
->bss_param
.flags
|=
1427 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1428 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1429 sinfo
->bss_param
.beacon_interval
=
1430 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1437 * CFG802.11 operation handler to get station information.
1439 * This function only works in connected mode, and dumps the
1440 * requested station information, if available.
1443 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1444 const u8
*mac
, struct station_info
*sinfo
)
1446 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1448 if (!priv
->media_connected
)
1450 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1453 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1457 * CFG802.11 operation handler to dump station information.
1460 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1461 int idx
, u8
*mac
, struct station_info
*sinfo
)
1463 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1464 static struct mwifiex_sta_node
*node
;
1466 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1467 priv
->media_connected
&& idx
== 0) {
1468 ether_addr_copy(mac
, priv
->cfg_bssid
);
1469 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1470 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1471 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1472 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1474 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1479 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1480 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1481 ether_addr_copy(mac
, node
->mac_addr
);
1482 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1490 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1491 int idx
, struct survey_info
*survey
)
1493 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1494 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1495 enum nl80211_band band
;
1497 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1499 memset(survey
, 0, sizeof(struct survey_info
));
1501 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1502 priv
->media_connected
&& idx
== 0) {
1503 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1504 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1506 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1507 survey
->channel
= ieee80211_get_channel(wiphy
,
1508 ieee80211_channel_to_frequency(chan
, band
));
1510 if (priv
->bcn_nf_last
) {
1511 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1512 survey
->noise
= priv
->bcn_nf_last
;
1517 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1520 if (!pchan_stats
[idx
].cca_scan_dur
)
1523 band
= pchan_stats
[idx
].bandcfg
;
1524 survey
->channel
= ieee80211_get_channel(wiphy
,
1525 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1526 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1528 SURVEY_INFO_TIME_BUSY
;
1529 survey
->noise
= pchan_stats
[idx
].noise
;
1530 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1531 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1536 /* Supported rates to be advertised to the cfg80211 */
1537 static struct ieee80211_rate mwifiex_rates
[] = {
1538 {.bitrate
= 10, .hw_value
= 2, },
1539 {.bitrate
= 20, .hw_value
= 4, },
1540 {.bitrate
= 55, .hw_value
= 11, },
1541 {.bitrate
= 110, .hw_value
= 22, },
1542 {.bitrate
= 60, .hw_value
= 12, },
1543 {.bitrate
= 90, .hw_value
= 18, },
1544 {.bitrate
= 120, .hw_value
= 24, },
1545 {.bitrate
= 180, .hw_value
= 36, },
1546 {.bitrate
= 240, .hw_value
= 48, },
1547 {.bitrate
= 360, .hw_value
= 72, },
1548 {.bitrate
= 480, .hw_value
= 96, },
1549 {.bitrate
= 540, .hw_value
= 108, },
1552 /* Channel definitions to be advertised to cfg80211 */
1553 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1554 {.center_freq
= 2412, .hw_value
= 1, },
1555 {.center_freq
= 2417, .hw_value
= 2, },
1556 {.center_freq
= 2422, .hw_value
= 3, },
1557 {.center_freq
= 2427, .hw_value
= 4, },
1558 {.center_freq
= 2432, .hw_value
= 5, },
1559 {.center_freq
= 2437, .hw_value
= 6, },
1560 {.center_freq
= 2442, .hw_value
= 7, },
1561 {.center_freq
= 2447, .hw_value
= 8, },
1562 {.center_freq
= 2452, .hw_value
= 9, },
1563 {.center_freq
= 2457, .hw_value
= 10, },
1564 {.center_freq
= 2462, .hw_value
= 11, },
1565 {.center_freq
= 2467, .hw_value
= 12, },
1566 {.center_freq
= 2472, .hw_value
= 13, },
1567 {.center_freq
= 2484, .hw_value
= 14, },
1570 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1571 .channels
= mwifiex_channels_2ghz
,
1572 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1573 .bitrates
= mwifiex_rates
,
1574 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1577 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1578 {.center_freq
= 5040, .hw_value
= 8, },
1579 {.center_freq
= 5060, .hw_value
= 12, },
1580 {.center_freq
= 5080, .hw_value
= 16, },
1581 {.center_freq
= 5170, .hw_value
= 34, },
1582 {.center_freq
= 5190, .hw_value
= 38, },
1583 {.center_freq
= 5210, .hw_value
= 42, },
1584 {.center_freq
= 5230, .hw_value
= 46, },
1585 {.center_freq
= 5180, .hw_value
= 36, },
1586 {.center_freq
= 5200, .hw_value
= 40, },
1587 {.center_freq
= 5220, .hw_value
= 44, },
1588 {.center_freq
= 5240, .hw_value
= 48, },
1589 {.center_freq
= 5260, .hw_value
= 52, },
1590 {.center_freq
= 5280, .hw_value
= 56, },
1591 {.center_freq
= 5300, .hw_value
= 60, },
1592 {.center_freq
= 5320, .hw_value
= 64, },
1593 {.center_freq
= 5500, .hw_value
= 100, },
1594 {.center_freq
= 5520, .hw_value
= 104, },
1595 {.center_freq
= 5540, .hw_value
= 108, },
1596 {.center_freq
= 5560, .hw_value
= 112, },
1597 {.center_freq
= 5580, .hw_value
= 116, },
1598 {.center_freq
= 5600, .hw_value
= 120, },
1599 {.center_freq
= 5620, .hw_value
= 124, },
1600 {.center_freq
= 5640, .hw_value
= 128, },
1601 {.center_freq
= 5660, .hw_value
= 132, },
1602 {.center_freq
= 5680, .hw_value
= 136, },
1603 {.center_freq
= 5700, .hw_value
= 140, },
1604 {.center_freq
= 5745, .hw_value
= 149, },
1605 {.center_freq
= 5765, .hw_value
= 153, },
1606 {.center_freq
= 5785, .hw_value
= 157, },
1607 {.center_freq
= 5805, .hw_value
= 161, },
1608 {.center_freq
= 5825, .hw_value
= 165, },
1611 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1612 .channels
= mwifiex_channels_5ghz
,
1613 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1614 .bitrates
= mwifiex_rates
+ 4,
1615 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1619 /* Supported crypto cipher suits to be advertised to cfg80211 */
1620 static const u32 mwifiex_cipher_suites
[] = {
1621 WLAN_CIPHER_SUITE_WEP40
,
1622 WLAN_CIPHER_SUITE_WEP104
,
1623 WLAN_CIPHER_SUITE_TKIP
,
1624 WLAN_CIPHER_SUITE_CCMP
,
1625 WLAN_CIPHER_SUITE_SMS4
,
1626 WLAN_CIPHER_SUITE_AES_CMAC
,
1629 /* Supported mgmt frame types to be advertised to cfg80211 */
1630 static const struct ieee80211_txrx_stypes
1631 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1632 [NL80211_IFTYPE_STATION
] = {
1633 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1634 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1635 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1636 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1638 [NL80211_IFTYPE_AP
] = {
1639 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1640 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1641 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1642 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1644 [NL80211_IFTYPE_P2P_CLIENT
] = {
1645 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1646 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1647 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1648 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1650 [NL80211_IFTYPE_P2P_GO
] = {
1651 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1652 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1653 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1654 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1659 * CFG802.11 operation handler for setting bit rates.
1661 * Function configures data rates to firmware using bitrate mask
1662 * provided by cfg80211.
1664 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1665 struct net_device
*dev
,
1667 const struct cfg80211_bitrate_mask
*mask
)
1669 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1670 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1671 enum nl80211_band band
;
1672 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1674 if (!priv
->media_connected
) {
1675 mwifiex_dbg(adapter
, ERROR
,
1676 "Can not set Tx data rate in disconnected state\n");
1680 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1682 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1684 /* Fill HR/DSSS rates. */
1685 if (band
== NL80211_BAND_2GHZ
)
1686 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1688 /* Fill OFDM rates */
1689 if (band
== NL80211_BAND_2GHZ
)
1690 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1692 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1694 /* Fill HT MCS rates */
1695 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1696 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1697 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1699 /* Fill VHT MCS rates */
1700 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1701 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1702 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1703 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1706 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1707 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1711 * CFG802.11 operation handler for connection quality monitoring.
1713 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1716 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1717 struct net_device
*dev
,
1718 s32 rssi_thold
, u32 rssi_hyst
)
1720 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1721 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1723 priv
->cqm_rssi_thold
= rssi_thold
;
1724 priv
->cqm_rssi_hyst
= rssi_hyst
;
1726 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1727 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1729 /* Subscribe/unsubscribe low and high rssi events */
1730 if (rssi_thold
&& rssi_hyst
) {
1731 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1732 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1733 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1734 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1735 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1736 return mwifiex_send_cmd(priv
,
1737 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1738 0, 0, &subsc_evt
, true);
1740 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1741 return mwifiex_send_cmd(priv
,
1742 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1743 0, 0, &subsc_evt
, true);
1749 /* cfg80211 operation handler for change_beacon.
1750 * Function retrieves and sets modified management IEs to FW.
1752 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1753 struct net_device
*dev
,
1754 struct cfg80211_beacon_data
*data
)
1756 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1757 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1759 mwifiex_cancel_scan(adapter
);
1761 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1762 mwifiex_dbg(priv
->adapter
, ERROR
,
1763 "%s: bss_type mismatched\n", __func__
);
1767 if (!priv
->bss_started
) {
1768 mwifiex_dbg(priv
->adapter
, ERROR
,
1769 "%s: bss not started\n", __func__
);
1773 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1774 mwifiex_dbg(priv
->adapter
, ERROR
,
1775 "%s: setting mgmt ies failed\n", __func__
);
1782 /* cfg80211 operation handler for del_station.
1783 * Function deauthenticates station which value is provided in mac parameter.
1784 * If mac is NULL/broadcast, all stations in associated station list are
1785 * deauthenticated. If bss is not started or there are no stations in
1786 * associated stations list, no action is taken.
1789 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1790 struct station_del_parameters
*params
)
1792 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1793 struct mwifiex_sta_node
*sta_node
;
1794 u8 deauth_mac
[ETH_ALEN
];
1795 unsigned long flags
;
1797 if (!priv
->bss_started
&& priv
->wdev
.cac_started
) {
1798 mwifiex_dbg(priv
->adapter
, INFO
, "%s: abort CAC!\n", __func__
);
1799 mwifiex_abort_cac(priv
);
1802 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1805 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1808 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1809 __func__
, params
->mac
);
1811 eth_zero_addr(deauth_mac
);
1813 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1814 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1816 ether_addr_copy(deauth_mac
, params
->mac
);
1817 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1819 if (is_valid_ether_addr(deauth_mac
)) {
1820 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1821 HostCmd_ACT_GEN_SET
, 0,
1830 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1832 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1833 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1834 MWIFIEX_BSS_ROLE_ANY
);
1835 struct mwifiex_ds_ant_cfg ant_cfg
;
1837 if (!tx_ant
|| !rx_ant
)
1840 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1841 /* Not a MIMO chip. User should provide specific antenna number
1842 * for Tx/Rx path or enable all antennas for diversity
1844 if (tx_ant
!= rx_ant
)
1847 if ((tx_ant
& (tx_ant
- 1)) &&
1848 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1851 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1852 (priv
->adapter
->number_of_antenna
> 1)) {
1853 tx_ant
= RF_ANTENNA_AUTO
;
1854 rx_ant
= RF_ANTENNA_AUTO
;
1857 struct ieee80211_sta_ht_cap
*ht_info
;
1859 enum nl80211_band band
;
1861 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1862 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1863 if (adapter
->is_hw_11ac_capable
)
1864 adapter
->usr_dot_11ac_mcs_support
=
1865 MWIFIEX_11AC_MCS_MAP_1X1
;
1867 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1868 if (adapter
->is_hw_11ac_capable
)
1869 adapter
->usr_dot_11ac_mcs_support
=
1870 MWIFIEX_11AC_MCS_MAP_2X2
;
1873 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
1874 if (!adapter
->wiphy
->bands
[band
])
1877 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1879 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1880 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1881 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1885 ant_cfg
.tx_ant
= tx_ant
;
1886 ant_cfg
.rx_ant
= rx_ant
;
1888 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1889 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1893 mwifiex_cfg80211_get_antenna(struct wiphy
*wiphy
, u32
*tx_ant
, u32
*rx_ant
)
1895 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1896 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1897 MWIFIEX_BSS_ROLE_ANY
);
1898 mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1899 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1901 *tx_ant
= priv
->tx_ant
;
1902 *rx_ant
= priv
->rx_ant
;
1907 /* cfg80211 operation handler for stop ap.
1908 * Function stops BSS running at uAP interface.
1910 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1912 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1914 mwifiex_abort_cac(priv
);
1916 if (mwifiex_del_mgmt_ies(priv
))
1917 mwifiex_dbg(priv
->adapter
, ERROR
,
1918 "Failed to delete mgmt IEs!\n");
1920 priv
->ap_11n_enabled
= 0;
1921 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1923 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1924 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1925 mwifiex_dbg(priv
->adapter
, ERROR
,
1926 "Failed to stop the BSS\n");
1930 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1931 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1932 mwifiex_dbg(priv
->adapter
, ERROR
,
1933 "Failed to reset BSS\n");
1937 if (netif_carrier_ok(priv
->netdev
))
1938 netif_carrier_off(priv
->netdev
);
1939 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1944 /* cfg80211 operation handler for start_ap.
1945 * Function sets beacon period, DTIM period, SSID and security into
1946 * AP config structure.
1947 * AP is configured with these settings and BSS is started.
1949 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1950 struct net_device
*dev
,
1951 struct cfg80211_ap_settings
*params
)
1953 struct mwifiex_uap_bss_param
*bss_cfg
;
1954 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1956 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1959 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1963 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1965 if (params
->beacon_interval
)
1966 bss_cfg
->beacon_period
= params
->beacon_interval
;
1967 if (params
->dtim_period
)
1968 bss_cfg
->dtim_period
= params
->dtim_period
;
1970 if (params
->ssid
&& params
->ssid_len
) {
1971 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1972 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1974 if (params
->inactivity_timeout
> 0) {
1975 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1976 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1977 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1980 switch (params
->hidden_ssid
) {
1981 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1982 bss_cfg
->bcast_ssid_ctl
= 1;
1984 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1985 bss_cfg
->bcast_ssid_ctl
= 0;
1987 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1988 bss_cfg
->bcast_ssid_ctl
= 2;
1995 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1996 mwifiex_set_uap_rates(bss_cfg
, params
);
1998 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1999 mwifiex_dbg(priv
->adapter
, ERROR
,
2000 "Failed to parse security parameters!\n");
2004 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
2006 if (priv
->adapter
->is_hw_11ac_capable
) {
2007 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
2008 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
2009 priv
->ap_11ac_enabled
);
2012 if (priv
->ap_11ac_enabled
)
2013 mwifiex_set_11ac_ba_params(priv
);
2015 mwifiex_set_ba_params(priv
);
2017 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
2019 if (mwifiex_is_11h_active(priv
))
2020 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
2022 if (mwifiex_is_11h_active(priv
) &&
2023 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
2025 mwifiex_dbg(priv
->adapter
, INFO
,
2026 "Disable 11h extensions in FW\n");
2027 if (mwifiex_11h_activate(priv
, false)) {
2028 mwifiex_dbg(priv
->adapter
, ERROR
,
2029 "Failed to disable 11h extensions!!");
2032 priv
->state_11h
.is_11h_active
= false;
2035 mwifiex_config_uap_11d(priv
, ¶ms
->beacon
);
2037 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
2038 mwifiex_dbg(priv
->adapter
, ERROR
,
2039 "Failed to start AP\n");
2043 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
2046 if (!netif_carrier_ok(priv
->netdev
))
2047 netif_carrier_on(priv
->netdev
);
2048 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
2050 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
2060 * CFG802.11 operation handler for disconnection request.
2062 * This function does not work when there is already a disconnection
2063 * procedure going on.
2066 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
2069 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2071 if (!mwifiex_stop_bg_scan(priv
))
2072 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2074 if (mwifiex_deauthenticate(priv
, NULL
))
2077 eth_zero_addr(priv
->cfg_bssid
);
2078 priv
->hs2_enabled
= false;
2084 * This function informs the CFG802.11 subsystem of a new IBSS.
2086 * The following information are sent to the CFG802.11 subsystem
2087 * to register the new IBSS. If we do not register the new IBSS,
2088 * a kernel panic will result.
2094 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
2096 struct ieee80211_channel
*chan
;
2097 struct mwifiex_bss_info bss_info
;
2098 struct cfg80211_bss
*bss
;
2100 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
2101 enum nl80211_band band
;
2103 if (mwifiex_get_bss_info(priv
, &bss_info
))
2106 ie_buf
[0] = WLAN_EID_SSID
;
2107 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
2109 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
2110 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
2111 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
2113 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
2114 chan
= ieee80211_get_channel(priv
->wdev
.wiphy
,
2115 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
2118 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2119 CFG80211_BSS_FTYPE_UNKNOWN
,
2120 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2121 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2123 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2124 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2131 * This function connects with a BSS.
2133 * This function handles both Infra and Ad-Hoc modes. It also performs
2134 * validity checking on the provided parameters, disconnects from the
2135 * current BSS (if any), sets up the association/scan parameters,
2136 * including security settings, and performs specific SSID scan before
2137 * trying to connect.
2139 * For Infra mode, the function returns failure if the specified SSID
2140 * is not found in scan table. However, for Ad-Hoc mode, it can create
2141 * the IBSS if it does not exist. On successful completion in either case,
2142 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2145 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2146 const u8
*ssid
, const u8
*bssid
, int mode
,
2147 struct ieee80211_channel
*channel
,
2148 struct cfg80211_connect_params
*sme
, bool privacy
)
2150 struct cfg80211_ssid req_ssid
;
2151 int ret
, auth_type
= 0;
2152 struct cfg80211_bss
*bss
= NULL
;
2153 u8 is_scanning_required
= 0;
2155 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2157 req_ssid
.ssid_len
= ssid_len
;
2158 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2159 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2163 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2164 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2165 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2169 /* As this is new association, clear locally stored
2170 * keys and security related flags */
2171 priv
->sec_info
.wpa_enabled
= false;
2172 priv
->sec_info
.wpa2_enabled
= false;
2173 priv
->wep_key_curr_index
= 0;
2174 priv
->sec_info
.encryption_mode
= 0;
2175 priv
->sec_info
.is_authtype_auto
= 0;
2176 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2178 if (mode
== NL80211_IFTYPE_ADHOC
) {
2181 /* set ibss coalescing_status */
2182 ret
= mwifiex_send_cmd(
2184 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
,
2185 HostCmd_ACT_GEN_SET
, 0, &enable
, true);
2189 /* "privacy" is set only for ad-hoc mode */
2192 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2193 * the firmware can find a matching network from the
2194 * scan. The cfg80211 does not give us the encryption
2195 * mode at this stage so just setting it to WEP here.
2197 priv
->sec_info
.encryption_mode
=
2198 WLAN_CIPHER_SUITE_WEP104
;
2199 priv
->sec_info
.authentication_mode
=
2200 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2206 /* Now handle infra mode. "sme" is valid for infra mode only */
2207 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2208 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2209 priv
->sec_info
.is_authtype_auto
= 1;
2211 auth_type
= sme
->auth_type
;
2214 if (sme
->crypto
.n_ciphers_pairwise
) {
2215 priv
->sec_info
.encryption_mode
=
2216 sme
->crypto
.ciphers_pairwise
[0];
2217 priv
->sec_info
.authentication_mode
= auth_type
;
2220 if (sme
->crypto
.cipher_group
) {
2221 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2222 priv
->sec_info
.authentication_mode
= auth_type
;
2225 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2228 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2229 mwifiex_dbg(priv
->adapter
, INFO
,
2230 "info: setting wep encryption\t"
2231 "with key len %d\n", sme
->key_len
);
2232 priv
->wep_key_curr_index
= sme
->key_idx
;
2233 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2234 sme
->key_len
, sme
->key_idx
,
2240 * Scan entries are valid for some time (15 sec). So we can save one
2241 * active scan time if we just try cfg80211_get_bss first. If it fails
2242 * then request scan and cfg80211_get_bss() again for final output.
2245 if (is_scanning_required
) {
2246 /* Do specific SSID scanning */
2247 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2248 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2253 /* Find the BSS we want using available scan results */
2254 if (mode
== NL80211_IFTYPE_ADHOC
)
2255 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2256 bssid
, ssid
, ssid_len
,
2257 IEEE80211_BSS_TYPE_IBSS
,
2258 IEEE80211_PRIVACY_ANY
);
2260 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2261 bssid
, ssid
, ssid_len
,
2262 IEEE80211_BSS_TYPE_ESS
,
2263 IEEE80211_PRIVACY_ANY
);
2266 if (is_scanning_required
) {
2267 mwifiex_dbg(priv
->adapter
, MSG
,
2268 "assoc: requested bss not found in scan results\n");
2271 is_scanning_required
= 1;
2273 mwifiex_dbg(priv
->adapter
, MSG
,
2274 "info: trying to associate to '%.*s' bssid %pM\n",
2275 req_ssid
.ssid_len
, (char *)req_ssid
.ssid
,
2277 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2282 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2286 if (mode
== NL80211_IFTYPE_ADHOC
) {
2287 /* Inform the BSS information to kernel, otherwise
2288 * kernel will give a panic after successful assoc */
2289 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2297 * CFG802.11 operation handler for association request.
2299 * This function does not work when the current mode is set to Ad-Hoc, or
2300 * when there is already an association procedure going on. The given BSS
2301 * information is used to associate.
2304 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2305 struct cfg80211_connect_params
*sme
)
2307 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2308 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2311 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2312 mwifiex_dbg(adapter
, ERROR
,
2313 "%s: reject infra assoc request in non-STA role\n",
2318 if (priv
->wdev
.current_bss
) {
2319 mwifiex_dbg(adapter
, ERROR
,
2320 "%s: already connected\n", dev
->name
);
2324 if (priv
->scan_block
)
2325 priv
->scan_block
= false;
2327 if (test_bit(MWIFIEX_SURPRISE_REMOVED
, &adapter
->work_flags
) ||
2328 test_bit(MWIFIEX_IS_CMD_TIMEDOUT
, &adapter
->work_flags
)) {
2329 mwifiex_dbg(adapter
, ERROR
,
2330 "%s: Ignore connection.\t"
2331 "Card removed or FW in bad state\n",
2336 mwifiex_dbg(adapter
, INFO
,
2337 "info: Trying to associate to %.*s and bssid %pM\n",
2338 (int)sme
->ssid_len
, (char *)sme
->ssid
, sme
->bssid
);
2340 if (!mwifiex_stop_bg_scan(priv
))
2341 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2343 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2344 priv
->bss_mode
, sme
->channel
, sme
, 0);
2346 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2347 NULL
, 0, WLAN_STATUS_SUCCESS
,
2349 mwifiex_dbg(priv
->adapter
, MSG
,
2350 "info: associated to bssid %pM successfully\n",
2352 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2353 priv
->adapter
->auto_tdls
&&
2354 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2355 mwifiex_setup_auto_tdls_timer(priv
);
2357 mwifiex_dbg(priv
->adapter
, ERROR
,
2358 "info: association to bssid %pM failed\n",
2360 eth_zero_addr(priv
->cfg_bssid
);
2363 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2364 NULL
, 0, NULL
, 0, ret
,
2367 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2369 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2377 * This function sets following parameters for ibss network.
2381 * - secondary channel offset
2383 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2384 struct cfg80211_ibss_params
*params
)
2386 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2388 u8 config_bands
= 0;
2390 if (params
->chandef
.chan
->band
== NL80211_BAND_2GHZ
) {
2391 if (!params
->basic_rates
) {
2392 config_bands
= BAND_B
| BAND_G
;
2394 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2396 * Rates below 6 Mbps in the table are CCK
2397 * rates; 802.11b and from 6 they are OFDM;
2400 if (mwifiex_rates
[i
].bitrate
== 60) {
2406 if (params
->basic_rates
< index
) {
2407 config_bands
= BAND_B
;
2409 config_bands
= BAND_G
;
2410 if (params
->basic_rates
% index
)
2411 config_bands
|= BAND_B
;
2415 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2417 config_bands
|= BAND_G
| BAND_GN
;
2419 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2421 config_bands
= BAND_A
;
2423 config_bands
= BAND_AN
| BAND_A
;
2426 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2427 adapter
->config_bands
= config_bands
;
2428 adapter
->adhoc_start_band
= config_bands
;
2430 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2431 adapter
->adhoc_11n_enabled
= true;
2433 adapter
->adhoc_11n_enabled
= false;
2436 adapter
->sec_chan_offset
=
2437 mwifiex_chan_type_to_sec_chan_offset(
2438 cfg80211_get_chandef_type(¶ms
->chandef
));
2439 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2440 params
->chandef
.chan
->center_freq
);
2442 mwifiex_dbg(adapter
, INFO
,
2443 "info: set ibss band %d, chan %d, chan offset %d\n",
2444 config_bands
, priv
->adhoc_channel
,
2445 adapter
->sec_chan_offset
);
2451 * CFG802.11 operation handler to join an IBSS.
2453 * This function does not work in any mode other than Ad-Hoc, or if
2454 * a join operation is already in progress.
2457 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2458 struct cfg80211_ibss_params
*params
)
2460 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2463 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2464 mwifiex_dbg(priv
->adapter
, ERROR
,
2465 "request to join ibss received\t"
2466 "when station is not in ibss mode\n");
2470 mwifiex_dbg(priv
->adapter
, MSG
,
2471 "info: trying to join to %.*s and bssid %pM\n",
2472 params
->ssid_len
, (char *)params
->ssid
, params
->bssid
);
2474 mwifiex_set_ibss_params(priv
, params
);
2476 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2477 params
->bssid
, priv
->bss_mode
,
2478 params
->chandef
.chan
, NULL
,
2482 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2483 params
->chandef
.chan
, GFP_KERNEL
);
2484 mwifiex_dbg(priv
->adapter
, MSG
,
2485 "info: joined/created adhoc network with bssid\t"
2486 "%pM successfully\n", priv
->cfg_bssid
);
2488 mwifiex_dbg(priv
->adapter
, ERROR
,
2489 "info: failed creating/joining adhoc network\n");
2496 * CFG802.11 operation handler to leave an IBSS.
2498 * This function does not work if a leave operation is
2499 * already in progress.
2502 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2504 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2506 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2508 if (mwifiex_deauthenticate(priv
, NULL
))
2511 eth_zero_addr(priv
->cfg_bssid
);
2517 * CFG802.11 operation handler for scan request.
2519 * This function issues a scan request to the firmware based upon
2520 * the user specified scan configuration. On successful completion,
2521 * it also informs the results.
2524 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2525 struct cfg80211_scan_request
*request
)
2527 struct net_device
*dev
= request
->wdev
->netdev
;
2528 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2530 struct ieee80211_channel
*chan
;
2531 struct ieee_types_header
*ie
;
2532 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2533 u8 mac_addr
[ETH_ALEN
];
2535 mwifiex_dbg(priv
->adapter
, CMD
,
2536 "info: received scan request on %s\n", dev
->name
);
2538 /* Block scan request if scan operation or scan cleanup when interface
2539 * is disabled is in process
2541 if (priv
->scan_request
|| priv
->scan_aborting
) {
2542 mwifiex_dbg(priv
->adapter
, WARN
,
2543 "cmd: Scan already in process..\n");
2547 if (!priv
->wdev
.current_bss
&& priv
->scan_block
)
2548 priv
->scan_block
= false;
2550 if (!mwifiex_stop_bg_scan(priv
))
2551 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2553 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2557 priv
->scan_request
= request
;
2559 if (request
->flags
& NL80211_SCAN_FLAG_RANDOM_ADDR
) {
2560 get_random_mask_addr(mac_addr
, request
->mac_addr
,
2561 request
->mac_addr_mask
);
2562 ether_addr_copy(request
->mac_addr
, mac_addr
);
2563 ether_addr_copy(user_scan_cfg
->random_mac
, mac_addr
);
2566 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2567 user_scan_cfg
->ssid_list
= request
->ssids
;
2569 if (request
->ie
&& request
->ie_len
) {
2571 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2572 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2574 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2575 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2576 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2577 offset
+= sizeof(*ie
) + ie
->len
;
2579 if (offset
>= request
->ie_len
)
2584 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2585 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2586 chan
= request
->channels
[i
];
2587 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2588 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2590 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2591 user_scan_cfg
->chan_list
[i
].scan_type
=
2592 MWIFIEX_SCAN_TYPE_PASSIVE
;
2594 user_scan_cfg
->chan_list
[i
].scan_type
=
2595 MWIFIEX_SCAN_TYPE_ACTIVE
;
2597 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2600 if (priv
->adapter
->scan_chan_gap_enabled
&&
2601 mwifiex_is_any_intf_active(priv
))
2602 user_scan_cfg
->scan_chan_gap
=
2603 priv
->adapter
->scan_chan_gap_time
;
2605 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2606 kfree(user_scan_cfg
);
2608 mwifiex_dbg(priv
->adapter
, ERROR
,
2609 "scan failed: %d\n", ret
);
2610 priv
->scan_aborting
= false;
2611 priv
->scan_request
= NULL
;
2615 if (request
->ie
&& request
->ie_len
) {
2616 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2617 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2618 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2619 memset(&priv
->vs_ie
[i
].ie
, 0,
2620 MWIFIEX_MAX_VSIE_LEN
);
2627 /* CFG802.11 operation handler for sched_scan_start.
2629 * This function issues a bgscan config request to the firmware based upon
2630 * the user specified sched_scan configuration. On successful completion,
2631 * firmware will generate BGSCAN_REPORT event, driver should issue bgscan
2632 * query command to get sched_scan results from firmware.
2635 mwifiex_cfg80211_sched_scan_start(struct wiphy
*wiphy
,
2636 struct net_device
*dev
,
2637 struct cfg80211_sched_scan_request
*request
)
2639 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2641 struct ieee80211_channel
*chan
;
2642 struct mwifiex_bg_scan_cfg
*bgscan_cfg
;
2643 struct ieee_types_header
*ie
;
2645 if (!request
|| (!request
->n_ssids
&& !request
->n_match_sets
)) {
2646 wiphy_err(wiphy
, "%s : Invalid Sched_scan parameters",
2651 wiphy_info(wiphy
, "sched_scan start : n_ssids=%d n_match_sets=%d ",
2652 request
->n_ssids
, request
->n_match_sets
);
2653 wiphy_info(wiphy
, "n_channels=%d interval=%d ie_len=%d\n",
2654 request
->n_channels
, request
->scan_plans
->interval
,
2655 (int)request
->ie_len
);
2657 bgscan_cfg
= kzalloc(sizeof(*bgscan_cfg
), GFP_KERNEL
);
2661 if (priv
->scan_request
|| priv
->scan_aborting
)
2662 bgscan_cfg
->start_later
= true;
2664 bgscan_cfg
->num_ssids
= request
->n_match_sets
;
2665 bgscan_cfg
->ssid_list
= request
->match_sets
;
2667 if (request
->ie
&& request
->ie_len
) {
2669 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2670 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2672 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_BGSCAN
;
2673 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2674 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2675 offset
+= sizeof(*ie
) + ie
->len
;
2677 if (offset
>= request
->ie_len
)
2682 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2683 MWIFIEX_BG_SCAN_CHAN_MAX
); i
++) {
2684 chan
= request
->channels
[i
];
2685 bgscan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2686 bgscan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2688 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2689 bgscan_cfg
->chan_list
[i
].scan_type
=
2690 MWIFIEX_SCAN_TYPE_PASSIVE
;
2692 bgscan_cfg
->chan_list
[i
].scan_type
=
2693 MWIFIEX_SCAN_TYPE_ACTIVE
;
2695 bgscan_cfg
->chan_list
[i
].scan_time
= 0;
2698 bgscan_cfg
->chan_per_scan
= min_t(u32
, request
->n_channels
,
2699 MWIFIEX_BG_SCAN_CHAN_MAX
);
2701 /* Use at least 15 second for per scan cycle */
2702 bgscan_cfg
->scan_interval
= (request
->scan_plans
->interval
>
2703 MWIFIEX_BGSCAN_INTERVAL
) ?
2704 request
->scan_plans
->interval
:
2705 MWIFIEX_BGSCAN_INTERVAL
;
2707 bgscan_cfg
->repeat_count
= MWIFIEX_BGSCAN_REPEAT_COUNT
;
2708 bgscan_cfg
->report_condition
= MWIFIEX_BGSCAN_SSID_MATCH
|
2709 MWIFIEX_BGSCAN_WAIT_ALL_CHAN_DONE
;
2710 bgscan_cfg
->bss_type
= MWIFIEX_BSS_MODE_INFRA
;
2711 bgscan_cfg
->action
= MWIFIEX_BGSCAN_ACT_SET
;
2712 bgscan_cfg
->enable
= true;
2713 if (request
->min_rssi_thold
!= NL80211_SCAN_RSSI_THOLD_OFF
) {
2714 bgscan_cfg
->report_condition
|= MWIFIEX_BGSCAN_SSID_RSSI_MATCH
;
2715 bgscan_cfg
->rssi_threshold
= request
->min_rssi_thold
;
2718 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_BG_SCAN_CONFIG
,
2719 HostCmd_ACT_GEN_SET
, 0, bgscan_cfg
, true)) {
2724 priv
->sched_scanning
= true;
2730 /* CFG802.11 operation handler for sched_scan_stop.
2732 * This function issues a bgscan config command to disable
2733 * previous bgscan configuration in the firmware
2735 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy
*wiphy
,
2736 struct net_device
*dev
, u64 reqid
)
2738 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2740 wiphy_info(wiphy
, "sched scan stop!");
2741 mwifiex_stop_bg_scan(priv
);
2746 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2747 struct mwifiex_private
*priv
)
2749 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2751 vht_info
->vht_supported
= true;
2753 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2754 /* Update MCS support for VHT */
2755 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2756 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2757 vht_info
->vht_mcs
.rx_highest
= 0;
2758 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2759 adapter
->hw_dot_11ac_mcs_support
>> 16);
2760 vht_info
->vht_mcs
.tx_highest
= 0;
2764 * This function sets up the CFG802.11 specific HT capability fields
2765 * with default values.
2767 * The following default values are set -
2768 * - HT Supported = True
2769 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2770 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2771 * - HT Capabilities supported by firmware
2772 * - MCS information, Rx mask = 0xff
2773 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2776 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2777 struct mwifiex_private
*priv
)
2780 struct ieee80211_mcs_info mcs_set
;
2781 u8
*mcs
= (u8
*)&mcs_set
;
2782 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2784 ht_info
->ht_supported
= true;
2785 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2786 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2788 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2790 /* Fill HT capability information */
2791 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2792 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2794 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2796 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2797 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2799 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2801 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2802 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2804 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2806 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2807 ht_info
->cap
|= 2 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2809 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2811 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2812 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2814 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2816 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2817 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2819 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2821 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2822 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2824 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2826 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2827 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2829 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2831 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2832 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2834 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2835 /* Set MCS for 1x1/2x2 */
2836 memset(mcs
, 0xff, rx_mcs_supp
);
2837 /* Clear all the other values */
2838 memset(&mcs
[rx_mcs_supp
], 0,
2839 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2840 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2841 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2842 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2843 SETHT_MCS32(mcs_set
.rx_mask
);
2845 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2847 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2851 * create a new virtual interface with the given name and name assign type
2853 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2855 unsigned char name_assign_type
,
2856 enum nl80211_iftype type
,
2857 struct vif_params
*params
)
2859 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2860 struct mwifiex_private
*priv
;
2861 struct net_device
*dev
;
2866 return ERR_PTR(-EFAULT
);
2869 case NL80211_IFTYPE_UNSPECIFIED
:
2870 case NL80211_IFTYPE_STATION
:
2871 case NL80211_IFTYPE_ADHOC
:
2872 if (adapter
->curr_iface_comb
.sta_intf
==
2873 adapter
->iface_limit
.sta_intf
) {
2874 mwifiex_dbg(adapter
, ERROR
,
2875 "cannot create multiple sta/adhoc ifaces\n");
2876 return ERR_PTR(-EINVAL
);
2879 priv
= mwifiex_get_unused_priv_by_bss_type(
2880 adapter
, MWIFIEX_BSS_TYPE_STA
);
2882 mwifiex_dbg(adapter
, ERROR
,
2883 "could not get free private struct\n");
2884 return ERR_PTR(-EFAULT
);
2887 priv
->wdev
.wiphy
= wiphy
;
2888 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2890 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2891 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2893 priv
->bss_mode
= type
;
2895 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2896 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2897 priv
->bss_priority
= 0;
2898 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2901 case NL80211_IFTYPE_AP
:
2902 if (adapter
->curr_iface_comb
.uap_intf
==
2903 adapter
->iface_limit
.uap_intf
) {
2904 mwifiex_dbg(adapter
, ERROR
,
2905 "cannot create multiple AP ifaces\n");
2906 return ERR_PTR(-EINVAL
);
2909 priv
= mwifiex_get_unused_priv_by_bss_type(
2910 adapter
, MWIFIEX_BSS_TYPE_UAP
);
2912 mwifiex_dbg(adapter
, ERROR
,
2913 "could not get free private struct\n");
2914 return ERR_PTR(-EFAULT
);
2917 priv
->wdev
.wiphy
= wiphy
;
2918 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2920 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2921 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2922 priv
->bss_priority
= 0;
2923 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2924 priv
->bss_started
= 0;
2925 priv
->bss_mode
= type
;
2928 case NL80211_IFTYPE_P2P_CLIENT
:
2929 if (adapter
->curr_iface_comb
.p2p_intf
==
2930 adapter
->iface_limit
.p2p_intf
) {
2931 mwifiex_dbg(adapter
, ERROR
,
2932 "cannot create multiple P2P ifaces\n");
2933 return ERR_PTR(-EINVAL
);
2936 priv
= mwifiex_get_unused_priv_by_bss_type(
2937 adapter
, MWIFIEX_BSS_TYPE_P2P
);
2939 mwifiex_dbg(adapter
, ERROR
,
2940 "could not get free private struct\n");
2941 return ERR_PTR(-EFAULT
);
2944 priv
->wdev
.wiphy
= wiphy
;
2945 /* At start-up, wpa_supplicant tries to change the interface
2946 * to NL80211_IFTYPE_STATION if it is not managed mode.
2948 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2949 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2951 /* Setting bss_type to P2P tells firmware that this interface
2952 * is receiving P2P peers found during find phase and doing
2953 * action frame handshake.
2955 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2957 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2958 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2959 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2960 priv
->bss_started
= 0;
2962 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2963 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2964 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2965 return ERR_PTR(-EFAULT
);
2970 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2971 return ERR_PTR(-EINVAL
);
2974 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2975 name_assign_type
, ether_setup
,
2976 IEEE80211_NUM_ACS
, 1);
2978 mwifiex_dbg(adapter
, ERROR
,
2979 "no memory available for netdevice\n");
2981 goto err_alloc_netdev
;
2984 mwifiex_init_priv_params(priv
, dev
);
2988 if (!adapter
->mfg_mode
) {
2989 mwifiex_set_mac_address(priv
, dev
, false, NULL
);
2991 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
2992 HostCmd_ACT_GEN_SET
, 0, NULL
, true);
2994 goto err_set_bss_mode
;
2996 ret
= mwifiex_sta_init_cmd(priv
, false, false);
3001 mwifiex_setup_ht_caps(&wiphy
->bands
[NL80211_BAND_2GHZ
]->ht_cap
, priv
);
3002 if (adapter
->is_hw_11ac_capable
)
3003 mwifiex_setup_vht_caps(
3004 &wiphy
->bands
[NL80211_BAND_2GHZ
]->vht_cap
, priv
);
3006 if (adapter
->config_bands
& BAND_A
)
3007 mwifiex_setup_ht_caps(
3008 &wiphy
->bands
[NL80211_BAND_5GHZ
]->ht_cap
, priv
);
3010 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
3011 mwifiex_setup_vht_caps(
3012 &wiphy
->bands
[NL80211_BAND_5GHZ
]->vht_cap
, priv
);
3014 dev_net_set(dev
, wiphy_net(wiphy
));
3015 dev
->ieee80211_ptr
= &priv
->wdev
;
3016 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
3017 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
3019 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
3020 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
3021 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
3022 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
3024 mdev_priv
= netdev_priv(dev
);
3025 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
3027 SET_NETDEV_DEV(dev
, adapter
->dev
);
3029 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
3032 WQ_UNBOUND
, 1, name
);
3033 if (!priv
->dfs_cac_workqueue
) {
3034 mwifiex_dbg(adapter
, ERROR
, "cannot alloc DFS CAC queue\n");
3039 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
3041 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
3042 WQ_HIGHPRI
| WQ_UNBOUND
|
3043 WQ_MEM_RECLAIM
, 1, name
);
3044 if (!priv
->dfs_chan_sw_workqueue
) {
3045 mwifiex_dbg(adapter
, ERROR
, "cannot alloc DFS channel sw queue\n");
3047 goto err_alloc_chsw
;
3050 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
3051 mwifiex_dfs_chan_sw_work_queue
);
3053 mutex_init(&priv
->async_mutex
);
3055 /* Register network device */
3056 if (register_netdevice(dev
)) {
3057 mwifiex_dbg(adapter
, ERROR
, "cannot register network device\n");
3059 goto err_reg_netdev
;
3062 mwifiex_dbg(adapter
, INFO
,
3063 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
3065 #ifdef CONFIG_DEBUG_FS
3066 mwifiex_dev_debugfs_init(priv
);
3070 case NL80211_IFTYPE_UNSPECIFIED
:
3071 case NL80211_IFTYPE_STATION
:
3072 case NL80211_IFTYPE_ADHOC
:
3073 adapter
->curr_iface_comb
.sta_intf
++;
3075 case NL80211_IFTYPE_AP
:
3076 adapter
->curr_iface_comb
.uap_intf
++;
3078 case NL80211_IFTYPE_P2P_CLIENT
:
3079 adapter
->curr_iface_comb
.p2p_intf
++;
3082 /* This should be dead code; checked above */
3083 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
3084 return ERR_PTR(-EINVAL
);
3090 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3091 priv
->dfs_chan_sw_workqueue
= NULL
;
3093 destroy_workqueue(priv
->dfs_cac_workqueue
);
3094 priv
->dfs_cac_workqueue
= NULL
;
3097 priv
->netdev
= NULL
;
3101 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
3102 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
3103 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3104 return ERR_PTR(ret
);
3106 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
3109 * del_virtual_intf: remove the virtual interface determined by dev
3111 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
3113 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3114 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3115 struct sk_buff
*skb
, *tmp
;
3117 #ifdef CONFIG_DEBUG_FS
3118 mwifiex_dev_debugfs_remove(priv
);
3121 if (priv
->sched_scanning
)
3122 priv
->sched_scanning
= false;
3124 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
3126 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
) {
3127 skb_unlink(skb
, &priv
->bypass_txq
);
3128 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
3131 if (netif_carrier_ok(priv
->netdev
))
3132 netif_carrier_off(priv
->netdev
);
3134 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
3135 unregister_netdevice(wdev
->netdev
);
3137 if (priv
->dfs_cac_workqueue
) {
3138 flush_workqueue(priv
->dfs_cac_workqueue
);
3139 destroy_workqueue(priv
->dfs_cac_workqueue
);
3140 priv
->dfs_cac_workqueue
= NULL
;
3143 if (priv
->dfs_chan_sw_workqueue
) {
3144 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
3145 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3146 priv
->dfs_chan_sw_workqueue
= NULL
;
3148 /* Clear the priv in adapter */
3149 priv
->netdev
= NULL
;
3151 switch (priv
->bss_mode
) {
3152 case NL80211_IFTYPE_UNSPECIFIED
:
3153 case NL80211_IFTYPE_STATION
:
3154 case NL80211_IFTYPE_ADHOC
:
3155 adapter
->curr_iface_comb
.sta_intf
--;
3157 case NL80211_IFTYPE_AP
:
3158 adapter
->curr_iface_comb
.uap_intf
--;
3160 case NL80211_IFTYPE_P2P_CLIENT
:
3161 case NL80211_IFTYPE_P2P_GO
:
3162 adapter
->curr_iface_comb
.p2p_intf
--;
3165 mwifiex_dbg(adapter
, ERROR
,
3166 "del_virtual_intf: type not supported\n");
3170 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3172 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
3173 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
3174 kfree(priv
->hist_data
);
3178 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
3181 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
3184 int j
, k
, valid_byte_cnt
= 0;
3185 bool dont_care_byte
= false;
3187 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
3188 for (k
= 0; k
< 8; k
++) {
3189 if (pat
->mask
[j
] & 1 << k
) {
3190 memcpy(byte_seq
+ valid_byte_cnt
,
3191 &pat
->pattern
[j
* 8 + k
], 1);
3197 dont_care_byte
= true;
3200 /* wildcard bytes record as the offset
3201 * before the valid byte
3203 if (!valid_byte_cnt
&& !dont_care_byte
)
3206 if (valid_byte_cnt
> max_byte_seq
)
3211 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
3217 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
3218 struct mwifiex_mef_entry
*mef_entry
)
3220 int i
, filt_num
= 0, num_ipv4
= 0;
3221 struct in_device
*in_dev
;
3222 struct in_ifaddr
*ifa
;
3223 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
3224 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3226 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3227 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
3229 /* Enable ARP offload feature */
3230 memset(ips
, 0, sizeof(ips
));
3231 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
3232 if (adapter
->priv
[i
]->netdev
) {
3233 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
3236 ifa
= in_dev
->ifa_list
;
3237 if (!ifa
|| !ifa
->ifa_local
)
3239 ips
[i
] = ifa
->ifa_local
;
3244 for (i
= 0; i
< num_ipv4
; i
++) {
3247 mef_entry
->filter
[filt_num
].repeat
= 1;
3248 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
3249 (u8
*)&ips
[i
], sizeof(ips
[i
]));
3250 mef_entry
->filter
[filt_num
].
3251 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3253 mef_entry
->filter
[filt_num
].offset
= 46;
3254 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3256 mef_entry
->filter
[filt_num
].filt_action
=
3262 mef_entry
->filter
[filt_num
].repeat
= 1;
3263 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
3264 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
3265 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
3266 mef_entry
->filter
[filt_num
].offset
= 20;
3267 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3268 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3271 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
3272 struct mwifiex_ds_mef_cfg
*mef_cfg
,
3273 struct mwifiex_mef_entry
*mef_entry
,
3274 struct cfg80211_wowlan
*wowlan
)
3276 int i
, filt_num
= 0, ret
= 0;
3277 bool first_pat
= true;
3278 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
3279 static const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3280 static const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3282 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3283 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
3285 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
3286 memset(byte_seq
, 0, sizeof(byte_seq
));
3287 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
3289 MWIFIEX_MEF_MAX_BYTESEQ
)) {
3290 mwifiex_dbg(priv
->adapter
, ERROR
,
3291 "Pattern not supported\n");
3295 if (!wowlan
->patterns
[i
].pkt_offset
) {
3296 if (!(byte_seq
[0] & 0x01) &&
3297 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3298 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3300 } else if (is_broadcast_ether_addr(byte_seq
)) {
3301 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3303 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3304 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3305 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3306 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3307 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3311 mef_entry
->filter
[filt_num
].repeat
= 1;
3312 mef_entry
->filter
[filt_num
].offset
=
3313 wowlan
->patterns
[i
].pkt_offset
;
3314 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3316 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3320 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on patterns\n");
3322 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3328 if (wowlan
->magic_pkt
) {
3329 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3330 mef_entry
->filter
[filt_num
].repeat
= 16;
3331 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3333 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3335 mef_entry
->filter
[filt_num
].offset
= 28;
3336 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3338 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3341 mef_entry
->filter
[filt_num
].repeat
= 16;
3342 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3344 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3346 mef_entry
->filter
[filt_num
].offset
= 56;
3347 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3348 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3349 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on magic packet\n");
3354 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3355 struct cfg80211_wowlan
*wowlan
)
3357 int ret
= 0, num_entries
= 1;
3358 struct mwifiex_ds_mef_cfg mef_cfg
;
3359 struct mwifiex_mef_entry
*mef_entry
;
3361 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3364 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3368 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3369 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3370 MWIFIEX_CRITERIA_UNICAST
;
3371 mef_cfg
.num_entries
= num_entries
;
3372 mef_cfg
.mef_entry
= mef_entry
;
3374 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3376 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3377 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3378 &mef_entry
[1], wowlan
);
3383 if (!mef_cfg
.criteria
)
3384 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3385 MWIFIEX_CRITERIA_UNICAST
|
3386 MWIFIEX_CRITERIA_MULTICAST
;
3388 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3389 HostCmd_ACT_GEN_SET
, 0,
3397 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3398 struct cfg80211_wowlan
*wowlan
)
3400 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3401 struct mwifiex_ds_hs_cfg hs_cfg
;
3402 int i
, ret
= 0, retry_num
= 10;
3403 struct mwifiex_private
*priv
;
3404 struct mwifiex_private
*sta_priv
=
3405 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3407 sta_priv
->scan_aborting
= true;
3408 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3409 priv
= adapter
->priv
[i
];
3410 mwifiex_abort_cac(priv
);
3413 mwifiex_cancel_all_pending_cmd(adapter
);
3415 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3416 priv
= adapter
->priv
[i
];
3417 if (priv
&& priv
->netdev
)
3418 netif_device_detach(priv
->netdev
);
3421 for (i
= 0; i
< retry_num
; i
++) {
3422 if (!mwifiex_wmm_lists_empty(adapter
) ||
3423 !mwifiex_bypass_txlist_empty(adapter
) ||
3424 !skb_queue_empty(&adapter
->tx_data_q
))
3425 usleep_range(10000, 15000);
3431 mwifiex_dbg(adapter
, ERROR
,
3432 "None of the WOWLAN triggers enabled\n");
3437 if (!sta_priv
->media_connected
&& !wowlan
->nd_config
) {
3438 mwifiex_dbg(adapter
, ERROR
,
3439 "Can not configure WOWLAN in disconnected state\n");
3444 ret
= mwifiex_set_mef_filter(sta_priv
, wowlan
);
3446 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3450 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3451 hs_cfg
.conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
3453 if (wowlan
->nd_config
) {
3454 mwifiex_dbg(adapter
, INFO
, "Wake on net detect\n");
3455 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3456 mwifiex_cfg80211_sched_scan_start(wiphy
, sta_priv
->netdev
,
3460 if (wowlan
->disconnect
) {
3461 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3462 mwifiex_dbg(sta_priv
->adapter
, INFO
, "Wake on device disconnect\n");
3465 hs_cfg
.is_invoke_hostcmd
= false;
3466 hs_cfg
.gpio
= adapter
->hs_cfg
.gpio
;
3467 hs_cfg
.gap
= adapter
->hs_cfg
.gap
;
3468 ret
= mwifiex_set_hs_params(sta_priv
, HostCmd_ACT_GEN_SET
,
3469 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3471 mwifiex_dbg(adapter
, ERROR
, "Failed to set HS params\n");
3474 sta_priv
->scan_aborting
= false;
3478 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3480 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3481 struct mwifiex_private
*priv
;
3482 struct mwifiex_ds_wakeup_reason wakeup_reason
;
3483 struct cfg80211_wowlan_wakeup wakeup_report
;
3485 bool report_wakeup_reason
= true;
3487 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3488 priv
= adapter
->priv
[i
];
3489 if (priv
&& priv
->netdev
)
3490 netif_device_attach(priv
->netdev
);
3493 if (!wiphy
->wowlan_config
)
3496 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3497 mwifiex_get_wakeup_reason(priv
, HostCmd_ACT_GEN_GET
, MWIFIEX_SYNC_CMD
,
3499 memset(&wakeup_report
, 0, sizeof(struct cfg80211_wowlan_wakeup
));
3501 wakeup_report
.pattern_idx
= -1;
3503 switch (wakeup_reason
.hs_wakeup_reason
) {
3504 case NO_HSWAKEUP_REASON
:
3506 case BCAST_DATA_MATCHED
:
3508 case MCAST_DATA_MATCHED
:
3510 case UCAST_DATA_MATCHED
:
3512 case MASKTABLE_EVENT_MATCHED
:
3514 case NON_MASKABLE_EVENT_MATCHED
:
3515 if (wiphy
->wowlan_config
->disconnect
)
3516 wakeup_report
.disconnect
= true;
3517 if (wiphy
->wowlan_config
->nd_config
)
3518 wakeup_report
.net_detect
= adapter
->nd_info
;
3520 case NON_MASKABLE_CONDITION_MATCHED
:
3522 case MAGIC_PATTERN_MATCHED
:
3523 if (wiphy
->wowlan_config
->magic_pkt
)
3524 wakeup_report
.magic_pkt
= true;
3525 if (wiphy
->wowlan_config
->n_patterns
)
3526 wakeup_report
.pattern_idx
= 1;
3528 case GTK_REKEY_FAILURE
:
3529 if (wiphy
->wowlan_config
->gtk_rekey_failure
)
3530 wakeup_report
.gtk_rekey_failure
= true;
3533 report_wakeup_reason
= false;
3537 if (report_wakeup_reason
)
3538 cfg80211_report_wowlan_wakeup(&priv
->wdev
, &wakeup_report
,
3542 if (adapter
->nd_info
) {
3543 for (i
= 0 ; i
< adapter
->nd_info
->n_matches
; i
++)
3544 kfree(adapter
->nd_info
->matches
[i
]);
3545 kfree(adapter
->nd_info
);
3546 adapter
->nd_info
= NULL
;
3552 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3555 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3557 device_set_wakeup_enable(adapter
->dev
, enabled
);
3560 static int mwifiex_set_rekey_data(struct wiphy
*wiphy
, struct net_device
*dev
,
3561 struct cfg80211_gtk_rekey_data
*data
)
3563 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3565 if (!ISSUPP_FIRMWARE_SUPPLICANT(priv
->adapter
->fw_cap_info
))
3568 return mwifiex_send_cmd(priv
, HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG
,
3569 HostCmd_ACT_GEN_SET
, 0, data
, true);
3574 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3576 static const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3577 static const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3578 static const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3580 if ((byte_seq
[0] & 0x01) &&
3581 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3582 return PACKET_TYPE_UNICAST
;
3583 else if (!memcmp(byte_seq
, bc_mac
, 4))
3584 return PACKET_TYPE_BROADCAST
;
3585 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3586 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3587 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3588 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3589 return PACKET_TYPE_MULTICAST
;
3595 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3596 struct cfg80211_coalesce_rules
*crule
,
3597 struct mwifiex_coalesce_rule
*mrule
)
3599 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3600 struct filt_field_param
*param
;
3603 mrule
->max_coalescing_delay
= crule
->delay
;
3605 param
= mrule
->params
;
3607 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3608 memset(byte_seq
, 0, sizeof(byte_seq
));
3609 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3611 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3612 mwifiex_dbg(priv
->adapter
, ERROR
,
3613 "Pattern not supported\n");
3617 if (!crule
->patterns
[i
].pkt_offset
) {
3620 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3621 if (pkt_type
&& mrule
->pkt_type
) {
3622 mwifiex_dbg(priv
->adapter
, ERROR
,
3623 "Multiple packet types not allowed\n");
3625 } else if (pkt_type
) {
3626 mrule
->pkt_type
= pkt_type
;
3631 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3632 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3634 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3636 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3637 memcpy(param
->operand_byte_stream
, byte_seq
,
3638 param
->operand_len
);
3639 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3642 mrule
->num_of_fields
++;
3645 if (!mrule
->pkt_type
) {
3646 mwifiex_dbg(priv
->adapter
, ERROR
,
3647 "Packet type can not be determined\n");
3654 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3655 struct cfg80211_coalesce
*coalesce
)
3657 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3659 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3660 struct mwifiex_private
*priv
=
3661 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3663 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3665 mwifiex_dbg(adapter
, WARN
,
3666 "Disable coalesce and reset all previous rules\n");
3667 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3668 HostCmd_ACT_GEN_SET
, 0,
3669 &coalesce_cfg
, true);
3672 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3673 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3674 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3675 &coalesce_cfg
.rule
[i
]);
3677 mwifiex_dbg(adapter
, ERROR
,
3678 "Recheck the patterns provided for rule %d\n",
3684 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3685 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3688 /* cfg80211 ops handler for tdls_mgmt.
3689 * Function prepares TDLS action frame packets and forwards them to FW
3692 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3693 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3694 u16 status_code
, u32 peer_capability
,
3695 bool initiator
, const u8
*extra_ies
,
3696 size_t extra_ies_len
)
3698 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3701 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3704 /* make sure we are in station mode and connected */
3705 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3708 switch (action_code
) {
3709 case WLAN_TDLS_SETUP_REQUEST
:
3710 mwifiex_dbg(priv
->adapter
, MSG
,
3711 "Send TDLS Setup Request to %pM status_code=%d\n",
3713 mwifiex_add_auto_tdls_peer(priv
, peer
);
3714 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3715 dialog_token
, status_code
,
3716 extra_ies
, extra_ies_len
);
3718 case WLAN_TDLS_SETUP_RESPONSE
:
3719 mwifiex_add_auto_tdls_peer(priv
, peer
);
3720 mwifiex_dbg(priv
->adapter
, MSG
,
3721 "Send TDLS Setup Response to %pM status_code=%d\n",
3723 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3724 dialog_token
, status_code
,
3725 extra_ies
, extra_ies_len
);
3727 case WLAN_TDLS_SETUP_CONFIRM
:
3728 mwifiex_dbg(priv
->adapter
, MSG
,
3729 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3731 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3732 dialog_token
, status_code
,
3733 extra_ies
, extra_ies_len
);
3735 case WLAN_TDLS_TEARDOWN
:
3736 mwifiex_dbg(priv
->adapter
, MSG
,
3737 "Send TDLS Tear down to %pM\n", peer
);
3738 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3739 dialog_token
, status_code
,
3740 extra_ies
, extra_ies_len
);
3742 case WLAN_TDLS_DISCOVERY_REQUEST
:
3743 mwifiex_dbg(priv
->adapter
, MSG
,
3744 "Send TDLS Discovery Request to %pM\n", peer
);
3745 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3746 dialog_token
, status_code
,
3747 extra_ies
, extra_ies_len
);
3749 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3750 mwifiex_dbg(priv
->adapter
, MSG
,
3751 "Send TDLS Discovery Response to %pM\n", peer
);
3752 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3753 dialog_token
, status_code
,
3754 extra_ies
, extra_ies_len
);
3757 mwifiex_dbg(priv
->adapter
, ERROR
,
3758 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3767 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3768 const u8
*peer
, enum nl80211_tdls_operation action
)
3770 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3772 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3773 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3776 /* make sure we are in station mode and connected */
3777 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3780 mwifiex_dbg(priv
->adapter
, MSG
,
3781 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3784 case NL80211_TDLS_ENABLE_LINK
:
3785 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3787 case NL80211_TDLS_DISABLE_LINK
:
3788 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3790 case NL80211_TDLS_TEARDOWN
:
3791 /* shouldn't happen!*/
3792 mwifiex_dbg(priv
->adapter
, ERROR
,
3793 "tdls_oper: teardown from driver not supported\n");
3795 case NL80211_TDLS_SETUP
:
3796 /* shouldn't happen!*/
3797 mwifiex_dbg(priv
->adapter
, ERROR
,
3798 "tdls_oper: setup from driver not supported\n");
3800 case NL80211_TDLS_DISCOVERY_REQ
:
3801 /* shouldn't happen!*/
3802 mwifiex_dbg(priv
->adapter
, ERROR
,
3803 "tdls_oper: discovery from driver not supported\n");
3806 mwifiex_dbg(priv
->adapter
, ERROR
,
3807 "tdls_oper: operation not supported\n");
3811 return mwifiex_tdls_oper(priv
, peer
, action
);
3815 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3816 const u8
*addr
, u8 oper_class
,
3817 struct cfg80211_chan_def
*chandef
)
3819 struct mwifiex_sta_node
*sta_ptr
;
3820 unsigned long flags
;
3822 u8 second_chan_offset
, band
;
3823 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3825 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3826 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3828 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3829 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3834 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3835 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3836 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3837 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3841 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3842 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3843 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3844 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3847 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3849 chan
= chandef
->chan
->hw_value
;
3850 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3851 band
= chandef
->chan
->band
;
3852 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3858 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3859 struct net_device
*dev
,
3862 struct mwifiex_sta_node
*sta_ptr
;
3863 unsigned long flags
;
3864 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3866 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3867 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3869 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3870 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3872 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3873 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3874 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3875 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3876 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3879 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3880 mwifiex_stop_tdls_cs(priv
, addr
);
3885 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3886 const u8
*mac
, struct station_parameters
*params
)
3888 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3890 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3893 /* make sure we are in station mode and connected */
3894 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3897 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3901 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3902 struct cfg80211_csa_settings
*params
)
3904 struct ieee_types_header
*chsw_ie
;
3905 struct ieee80211_channel_sw_ie
*channel_sw
;
3907 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3909 if (priv
->adapter
->scan_processing
) {
3910 mwifiex_dbg(priv
->adapter
, ERROR
,
3911 "radar detection: scan in process...\n");
3915 if (priv
->wdev
.cac_started
)
3918 if (cfg80211_chandef_identical(¶ms
->chandef
,
3919 &priv
->dfs_chandef
))
3922 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3923 params
->beacon_csa
.tail
,
3924 params
->beacon_csa
.tail_len
);
3926 mwifiex_dbg(priv
->adapter
, ERROR
,
3927 "Could not parse channel switch announcement IE\n");
3931 channel_sw
= (void *)(chsw_ie
+ 1);
3932 if (channel_sw
->mode
) {
3933 if (netif_carrier_ok(priv
->netdev
))
3934 netif_carrier_off(priv
->netdev
);
3935 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3938 if (mwifiex_del_mgmt_ies(priv
))
3939 mwifiex_dbg(priv
->adapter
, ERROR
,
3940 "Failed to delete mgmt IEs!\n");
3942 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3943 mwifiex_dbg(priv
->adapter
, ERROR
,
3944 "%s: setting mgmt ies failed\n", __func__
);
3948 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3949 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3950 sizeof(priv
->beacon_after
));
3952 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3953 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3954 msecs_to_jiffies(chsw_msec
));
3958 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3959 struct wireless_dev
*wdev
,
3960 struct cfg80211_chan_def
*chandef
)
3962 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3963 struct mwifiex_bssdescriptor
*curr_bss
;
3964 struct ieee80211_channel
*chan
;
3965 enum nl80211_channel_type chan_type
;
3966 enum nl80211_band band
;
3970 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3971 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3972 *chandef
= priv
->bss_chandef
;
3974 } else if (priv
->media_connected
) {
3975 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3976 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3977 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3978 chan
= ieee80211_get_channel(wiphy
, freq
);
3980 if (priv
->ht_param_present
) {
3981 chan_type
= mwifiex_get_chan_type(priv
);
3982 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3984 cfg80211_chandef_create(chandef
, chan
,
3985 NL80211_CHAN_NO_HT
);
3993 #ifdef CONFIG_NL80211_TESTMODE
3995 enum mwifiex_tm_attr
{
3996 __MWIFIEX_TM_ATTR_INVALID
= 0,
3997 MWIFIEX_TM_ATTR_CMD
= 1,
3998 MWIFIEX_TM_ATTR_DATA
= 2,
4001 __MWIFIEX_TM_ATTR_AFTER_LAST
,
4002 MWIFIEX_TM_ATTR_MAX
= __MWIFIEX_TM_ATTR_AFTER_LAST
- 1,
4005 static const struct nla_policy mwifiex_tm_policy
[MWIFIEX_TM_ATTR_MAX
+ 1] = {
4006 [MWIFIEX_TM_ATTR_CMD
] = { .type
= NLA_U32
},
4007 [MWIFIEX_TM_ATTR_DATA
] = { .type
= NLA_BINARY
,
4008 .len
= MWIFIEX_SIZE_OF_CMD_BUFFER
},
4011 enum mwifiex_tm_command
{
4012 MWIFIEX_TM_CMD_HOSTCMD
= 0,
4015 static int mwifiex_tm_cmd(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
4016 void *data
, int len
)
4018 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
4019 struct mwifiex_ds_misc_cmd
*hostcmd
;
4020 struct nlattr
*tb
[MWIFIEX_TM_ATTR_MAX
+ 1];
4021 struct sk_buff
*skb
;
4027 err
= nla_parse(tb
, MWIFIEX_TM_ATTR_MAX
, data
, len
, mwifiex_tm_policy
,
4032 if (!tb
[MWIFIEX_TM_ATTR_CMD
])
4035 switch (nla_get_u32(tb
[MWIFIEX_TM_ATTR_CMD
])) {
4036 case MWIFIEX_TM_CMD_HOSTCMD
:
4037 if (!tb
[MWIFIEX_TM_ATTR_DATA
])
4040 hostcmd
= kzalloc(sizeof(*hostcmd
), GFP_KERNEL
);
4044 hostcmd
->len
= nla_len(tb
[MWIFIEX_TM_ATTR_DATA
]);
4045 memcpy(hostcmd
->cmd
, nla_data(tb
[MWIFIEX_TM_ATTR_DATA
]),
4048 if (mwifiex_send_cmd(priv
, 0, 0, 0, hostcmd
, true)) {
4049 dev_err(priv
->adapter
->dev
, "Failed to process hostcmd\n");
4053 /* process hostcmd response*/
4054 skb
= cfg80211_testmode_alloc_reply_skb(wiphy
, hostcmd
->len
);
4057 err
= nla_put(skb
, MWIFIEX_TM_ATTR_DATA
,
4058 hostcmd
->len
, hostcmd
->cmd
);
4064 err
= cfg80211_testmode_reply(skb
);
4074 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
4075 struct net_device
*dev
,
4076 struct cfg80211_chan_def
*chandef
,
4079 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4080 struct mwifiex_radar_params radar_params
;
4082 if (priv
->adapter
->scan_processing
) {
4083 mwifiex_dbg(priv
->adapter
, ERROR
,
4084 "radar detection: scan already in process...\n");
4088 if (!mwifiex_is_11h_active(priv
)) {
4089 mwifiex_dbg(priv
->adapter
, INFO
,
4090 "Enable 11h extensions in FW\n");
4091 if (mwifiex_11h_activate(priv
, true)) {
4092 mwifiex_dbg(priv
->adapter
, ERROR
,
4093 "Failed to activate 11h extensions!!");
4096 priv
->state_11h
.is_11h_active
= true;
4099 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
4100 radar_params
.chandef
= chandef
;
4101 radar_params
.cac_time_ms
= cac_time_ms
;
4103 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
4105 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
4106 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
4109 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
4110 msecs_to_jiffies(cac_time_ms
));
4115 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
4117 struct station_parameters
*params
)
4120 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4122 /* we support change_station handler only for TDLS peers*/
4123 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
4126 /* make sure we are in station mode and connected */
4127 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
4130 priv
->sta_params
= params
;
4132 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
4133 priv
->sta_params
= NULL
;
4138 /* station cfg80211 operations */
4139 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
4140 .add_virtual_intf
= mwifiex_add_virtual_intf
,
4141 .del_virtual_intf
= mwifiex_del_virtual_intf
,
4142 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
4143 .scan
= mwifiex_cfg80211_scan
,
4144 .connect
= mwifiex_cfg80211_connect
,
4145 .disconnect
= mwifiex_cfg80211_disconnect
,
4146 .get_station
= mwifiex_cfg80211_get_station
,
4147 .dump_station
= mwifiex_cfg80211_dump_station
,
4148 .dump_survey
= mwifiex_cfg80211_dump_survey
,
4149 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
4150 .join_ibss
= mwifiex_cfg80211_join_ibss
,
4151 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
4152 .add_key
= mwifiex_cfg80211_add_key
,
4153 .del_key
= mwifiex_cfg80211_del_key
,
4154 .set_default_mgmt_key
= mwifiex_cfg80211_set_default_mgmt_key
,
4155 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
4156 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
4157 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
4158 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
4159 .set_default_key
= mwifiex_cfg80211_set_default_key
,
4160 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
4161 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
4162 .get_tx_power
= mwifiex_cfg80211_get_tx_power
,
4163 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
4164 .start_ap
= mwifiex_cfg80211_start_ap
,
4165 .stop_ap
= mwifiex_cfg80211_stop_ap
,
4166 .change_beacon
= mwifiex_cfg80211_change_beacon
,
4167 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
4168 .set_antenna
= mwifiex_cfg80211_set_antenna
,
4169 .get_antenna
= mwifiex_cfg80211_get_antenna
,
4170 .del_station
= mwifiex_cfg80211_del_station
,
4171 .sched_scan_start
= mwifiex_cfg80211_sched_scan_start
,
4172 .sched_scan_stop
= mwifiex_cfg80211_sched_scan_stop
,
4174 .suspend
= mwifiex_cfg80211_suspend
,
4175 .resume
= mwifiex_cfg80211_resume
,
4176 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
4177 .set_rekey_data
= mwifiex_set_rekey_data
,
4179 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
4180 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
4181 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
4182 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
4183 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
4184 .add_station
= mwifiex_cfg80211_add_station
,
4185 .change_station
= mwifiex_cfg80211_change_station
,
4186 CFG80211_TESTMODE_CMD(mwifiex_tm_cmd
)
4187 .get_channel
= mwifiex_cfg80211_get_channel
,
4188 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
4189 .channel_switch
= mwifiex_cfg80211_channel_switch
,
4193 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
4194 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
4195 WIPHY_WOWLAN_NET_DETECT
| WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
4196 WIPHY_WOWLAN_GTK_REKEY_FAILURE
,
4197 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
4198 .pattern_min_len
= 1,
4199 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4200 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4201 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
4204 static const struct wiphy_wowlan_support mwifiex_wowlan_support_no_gtk
= {
4205 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
4206 WIPHY_WOWLAN_NET_DETECT
,
4207 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
4208 .pattern_min_len
= 1,
4209 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4210 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4211 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
4215 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
4217 if (!alpha2
|| strlen(alpha2
) != 2)
4220 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
4226 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
4227 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
4228 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
4229 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
4230 .pattern_min_len
= 1,
4231 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4232 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4235 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
4237 u32 n_channels_bg
, n_channels_a
= 0;
4239 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
4241 if (adapter
->config_bands
& BAND_A
)
4242 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
4244 /* allocate twice the number total channels, since the driver issues an
4245 * additional active scan request for hidden SSIDs on passive channels.
4247 adapter
->num_in_chan_stats
= 2 * (n_channels_bg
+ n_channels_a
);
4248 adapter
->chan_stats
= vmalloc(array_size(sizeof(*adapter
->chan_stats
),
4249 adapter
->num_in_chan_stats
));
4251 if (!adapter
->chan_stats
)
4258 * This function registers the device with CFG802.11 subsystem.
4260 * The function creates the wireless device/wiphy, populates it with
4261 * default parameters and handler function pointers, and finally
4262 * registers the device.
4265 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
4269 struct wiphy
*wiphy
;
4270 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
4274 /* create a new wiphy for use with cfg80211 */
4275 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
4276 sizeof(struct mwifiex_adapter
*));
4278 mwifiex_dbg(adapter
, ERROR
,
4279 "%s: creating new wiphy\n", __func__
);
4282 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4283 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4284 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
4285 wiphy
->max_remain_on_channel_duration
= 5000;
4286 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
4287 BIT(NL80211_IFTYPE_ADHOC
) |
4288 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
4289 BIT(NL80211_IFTYPE_P2P_GO
) |
4290 BIT(NL80211_IFTYPE_AP
);
4292 wiphy
->bands
[NL80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
4293 if (adapter
->config_bands
& BAND_A
)
4294 wiphy
->bands
[NL80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
4296 wiphy
->bands
[NL80211_BAND_5GHZ
] = NULL
;
4298 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
4299 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
4300 else if (adapter
->is_hw_11ac_capable
)
4301 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
4303 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
4304 wiphy
->n_iface_combinations
= 1;
4306 /* Initialize cipher suits */
4307 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
4308 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
4310 if (adapter
->regd
) {
4311 wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
4312 REGULATORY_DISABLE_BEACON_HINTS
|
4313 REGULATORY_COUNTRY_IE_IGNORE
;
4314 wiphy_apply_custom_regulatory(wiphy
, adapter
->regd
);
4317 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
4318 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
4319 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
4320 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
4321 WIPHY_FLAG_AP_UAPSD
|
4322 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
4323 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
4324 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
4326 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4327 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
4328 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
4331 if (ISSUPP_FIRMWARE_SUPPLICANT(priv
->adapter
->fw_cap_info
))
4332 wiphy
->wowlan
= &mwifiex_wowlan_support
;
4334 wiphy
->wowlan
= &mwifiex_wowlan_support_no_gtk
;
4337 wiphy
->coalesce
= &mwifiex_coalesce_support
;
4339 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
4340 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
4341 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
4343 wiphy
->max_sched_scan_reqs
= 1;
4344 wiphy
->max_sched_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4345 wiphy
->max_sched_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4346 wiphy
->max_match_sets
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4348 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
4349 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
4351 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
4352 NL80211_FEATURE_INACTIVITY_TIMER
|
4353 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
4354 NL80211_FEATURE_NEED_OBSS_SCAN
;
4356 if (ISSUPP_RANDOM_MAC(adapter
->fw_cap_info
))
4357 wiphy
->features
|= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
|
4358 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
|
4359 NL80211_FEATURE_ND_RANDOM_MAC_ADDR
;
4361 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4362 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
4364 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
4365 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
4367 /* Reserve space for mwifiex specific private data for BSS */
4368 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
4370 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
4372 /* Set struct mwifiex_adapter pointer in wiphy_priv */
4373 wdev_priv
= wiphy_priv(wiphy
);
4374 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
4376 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
4378 ret
= wiphy_register(wiphy
);
4380 mwifiex_dbg(adapter
, ERROR
,
4381 "%s: wiphy_register failed: %d\n", __func__
, ret
);
4386 if (!adapter
->regd
) {
4387 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
4388 mwifiex_dbg(adapter
, INFO
,
4389 "driver hint alpha2: %2.2s\n", reg_alpha2
);
4390 regulatory_hint(wiphy
, reg_alpha2
);
4392 if (adapter
->region_code
== 0x00) {
4393 mwifiex_dbg(adapter
, WARN
,
4394 "Ignore world regulatory domain\n");
4396 wiphy
->regulatory_flags
|=
4397 REGULATORY_DISABLE_BEACON_HINTS
|
4398 REGULATORY_COUNTRY_IE_IGNORE
;
4400 mwifiex_11d_code_2_region(
4401 adapter
->region_code
);
4403 regulatory_hint(wiphy
, country_code
))
4404 mwifiex_dbg(priv
->adapter
, ERROR
,
4405 "regulatory_hint() failed\n");
4410 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4411 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
4412 wiphy
->frag_threshold
= thr
;
4413 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4414 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
4415 wiphy
->rts_threshold
= thr
;
4416 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4417 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
4418 wiphy
->retry_short
= (u8
) retry
;
4419 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4420 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
4421 wiphy
->retry_long
= (u8
) retry
;
4423 adapter
->wiphy
= wiphy
;