2 * NXP Wireless LAN device driver: CFG80211
4 * Copyright 2011-2020 NXP
6 * This software file (the "File") is distributed by NXP
7 * under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available 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
);
380 case NL80211_TX_POWER_FIXED
:
381 power_cfg
.is_power_auto
= 0;
382 power_cfg
.is_power_fixed
= 1;
383 power_cfg
.power_level
= dbm
;
385 case NL80211_TX_POWER_LIMITED
:
386 power_cfg
.is_power_auto
= 0;
387 power_cfg
.is_power_fixed
= 0;
388 power_cfg
.power_level
= dbm
;
390 case NL80211_TX_POWER_AUTOMATIC
:
391 power_cfg
.is_power_auto
= 1;
395 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
397 return mwifiex_set_tx_power(priv
, &power_cfg
);
401 * CFG802.11 operation handler to get Tx power.
404 mwifiex_cfg80211_get_tx_power(struct wiphy
*wiphy
,
405 struct wireless_dev
*wdev
,
408 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
409 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
410 MWIFIEX_BSS_ROLE_ANY
);
411 int ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_RF_TX_PWR
,
412 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
417 /* tx_power_level is set in HostCmd_CMD_RF_TX_PWR command handler */
418 *dbm
= priv
->tx_power_level
;
424 * CFG802.11 operation handler to set Power Save option.
426 * The timeout value, if provided, is currently ignored.
429 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
430 struct net_device
*dev
,
431 bool enabled
, int timeout
)
433 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
437 mwifiex_dbg(priv
->adapter
, INFO
,
438 "info: ignore timeout value for IEEE Power Save\n");
442 return mwifiex_drv_set_power(priv
, &ps_mode
);
446 * CFG802.11 operation handler to set the default network key.
449 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
450 u8 key_index
, bool unicast
,
453 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
455 /* Return if WEP key not configured */
456 if (!priv
->sec_info
.wep_enabled
)
459 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
460 priv
->wep_key_curr_index
= key_index
;
461 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
463 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
471 * CFG802.11 operation handler to add a network key.
474 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
475 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
476 struct key_params
*params
)
478 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
479 struct mwifiex_wep_key
*wep_key
;
480 static const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
481 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
483 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
484 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
485 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
486 if (params
->key
&& params
->key_len
) {
487 wep_key
= &priv
->wep_key
[key_index
];
488 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
489 memcpy(wep_key
->key_material
, params
->key
,
491 wep_key
->key_index
= key_index
;
492 wep_key
->key_length
= params
->key_len
;
493 priv
->sec_info
.wep_enabled
= 1;
498 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
499 key_index
, peer_mac
, 0)) {
500 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
508 * CFG802.11 operation handler to set default mgmt key.
511 mwifiex_cfg80211_set_default_mgmt_key(struct wiphy
*wiphy
,
512 struct net_device
*netdev
,
515 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
516 struct mwifiex_ds_encrypt_key encrypt_key
;
518 wiphy_dbg(wiphy
, "set default mgmt key, key index=%d\n", key_index
);
520 memset(&encrypt_key
, 0, sizeof(struct mwifiex_ds_encrypt_key
));
521 encrypt_key
.key_len
= WLAN_KEY_LEN_CCMP
;
522 encrypt_key
.key_index
= key_index
;
523 encrypt_key
.is_igtk_def_key
= true;
524 eth_broadcast_addr(encrypt_key
.mac_addr
);
526 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_KEY_MATERIAL
,
527 HostCmd_ACT_GEN_SET
, true, &encrypt_key
, true);
531 * This function sends domain information to the firmware.
533 * The following information are passed to the firmware -
535 * - Sub bands (first channel, number of channels, maximum Tx power)
537 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
539 u8 no_of_triplet
= 0;
540 struct ieee80211_country_ie_triplet
*t
;
541 u8 no_of_parsed_chan
= 0;
542 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
544 enum nl80211_band band
;
545 struct ieee80211_supported_band
*sband
;
546 struct ieee80211_channel
*ch
;
547 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
548 struct mwifiex_private
*priv
;
549 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
551 /* Set country code */
552 domain_info
->country_code
[0] = adapter
->country_code
[0];
553 domain_info
->country_code
[1] = adapter
->country_code
[1];
554 domain_info
->country_code
[2] = ' ';
556 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
557 if (!wiphy
->bands
[band
]) {
558 mwifiex_dbg(adapter
, ERROR
,
559 "11D: setting domain info in FW\n");
563 sband
= wiphy
->bands
[band
];
565 for (i
= 0; i
< sband
->n_channels
; i
++) {
566 ch
= &sband
->channels
[i
];
567 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
572 first_chan
= (u32
) ch
->hw_value
;
573 next_chan
= first_chan
;
574 max_pwr
= ch
->max_power
;
575 no_of_parsed_chan
= 1;
579 if (ch
->hw_value
== next_chan
+ 1 &&
580 ch
->max_power
== max_pwr
) {
584 t
= &domain_info
->triplet
[no_of_triplet
];
585 t
->chans
.first_channel
= first_chan
;
586 t
->chans
.num_channels
= no_of_parsed_chan
;
587 t
->chans
.max_power
= max_pwr
;
589 first_chan
= (u32
) ch
->hw_value
;
590 next_chan
= first_chan
;
591 max_pwr
= ch
->max_power
;
592 no_of_parsed_chan
= 1;
597 t
= &domain_info
->triplet
[no_of_triplet
];
598 t
->chans
.first_channel
= first_chan
;
599 t
->chans
.num_channels
= no_of_parsed_chan
;
600 t
->chans
.max_power
= max_pwr
;
604 domain_info
->no_of_triplet
= no_of_triplet
;
606 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
608 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
609 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
610 mwifiex_dbg(adapter
, INFO
,
611 "11D: setting domain info in FW\n");
618 static void mwifiex_reg_apply_radar_flags(struct wiphy
*wiphy
)
620 struct ieee80211_supported_band
*sband
;
621 struct ieee80211_channel
*chan
;
624 if (!wiphy
->bands
[NL80211_BAND_5GHZ
])
626 sband
= wiphy
->bands
[NL80211_BAND_5GHZ
];
628 for (i
= 0; i
< sband
->n_channels
; i
++) {
629 chan
= &sband
->channels
[i
];
630 if ((!(chan
->flags
& IEEE80211_CHAN_DISABLED
)) &&
631 (chan
->flags
& IEEE80211_CHAN_RADAR
))
632 chan
->flags
|= IEEE80211_CHAN_NO_IR
;
637 * CFG802.11 regulatory domain callback function.
639 * This function is called when the regulatory domain is changed due to the
640 * following reasons -
642 * - Set by system core
644 * - Set bt Country IE
646 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
647 struct regulatory_request
*request
)
649 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
650 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
651 MWIFIEX_BSS_ROLE_ANY
);
652 mwifiex_dbg(adapter
, INFO
,
653 "info: cfg80211 regulatory domain callback for %c%c\n",
654 request
->alpha2
[0], request
->alpha2
[1]);
655 mwifiex_reg_apply_radar_flags(wiphy
);
657 switch (request
->initiator
) {
658 case NL80211_REGDOM_SET_BY_DRIVER
:
659 case NL80211_REGDOM_SET_BY_CORE
:
660 case NL80211_REGDOM_SET_BY_USER
:
661 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
664 mwifiex_dbg(adapter
, ERROR
,
665 "unknown regdom initiator: %d\n",
670 /* Don't send world or same regdom info to firmware */
671 if (strncmp(request
->alpha2
, "00", 2) &&
672 strncmp(request
->alpha2
, adapter
->country_code
,
673 sizeof(request
->alpha2
))) {
674 memcpy(adapter
->country_code
, request
->alpha2
,
675 sizeof(request
->alpha2
));
676 mwifiex_send_domain_info_cmd_fw(wiphy
);
677 mwifiex_dnld_txpwr_table(priv
);
682 * This function sets the fragmentation threshold.
684 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
685 * and MWIFIEX_FRAG_MAX_VALUE.
688 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
690 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
691 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
692 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
694 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
695 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
700 * This function sets the RTS threshold.
702 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
703 * and MWIFIEX_RTS_MAX_VALUE.
706 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
708 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
709 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
711 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
712 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
717 * CFG802.11 operation handler to set wiphy parameters.
719 * This function can be used to set the RTS threshold and the
720 * Fragmentation threshold of the driver.
723 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
725 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
726 struct mwifiex_private
*priv
;
727 struct mwifiex_uap_bss_param
*bss_cfg
;
730 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
732 switch (priv
->bss_role
) {
733 case MWIFIEX_BSS_ROLE_UAP
:
734 if (priv
->bss_started
) {
735 mwifiex_dbg(adapter
, ERROR
,
736 "cannot change wiphy params when bss started");
740 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
744 mwifiex_set_sys_config_invalid_data(bss_cfg
);
746 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
747 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
748 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
749 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
750 if (changed
& WIPHY_PARAM_RETRY_LONG
)
751 bss_cfg
->retry_limit
= wiphy
->retry_long
;
753 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
755 UAP_BSS_PARAMS_I
, bss_cfg
,
760 mwifiex_dbg(adapter
, ERROR
,
761 "Failed to set wiphy phy params\n");
766 case MWIFIEX_BSS_ROLE_STA
:
767 if (priv
->media_connected
) {
768 mwifiex_dbg(adapter
, ERROR
,
769 "cannot change wiphy params when connected");
772 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
773 ret
= mwifiex_set_rts(priv
,
774 wiphy
->rts_threshold
);
778 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
779 ret
= mwifiex_set_frag(priv
,
780 wiphy
->frag_threshold
);
791 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
793 u16 mode
= P2P_MODE_DISABLE
;
795 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
796 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
803 * This function initializes the functionalities for P2P client.
804 * The P2P client initialization sequence is:
805 * disable -> device -> client
808 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
812 if (mwifiex_cfg80211_deinit_p2p(priv
))
815 mode
= P2P_MODE_DEVICE
;
816 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
817 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
820 mode
= P2P_MODE_CLIENT
;
821 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
822 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
829 * This function initializes the functionalities for P2P GO.
830 * The P2P GO initialization sequence is:
831 * disable -> device -> GO
834 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
838 if (mwifiex_cfg80211_deinit_p2p(priv
))
841 mode
= P2P_MODE_DEVICE
;
842 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
843 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
847 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
848 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
854 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
856 struct mwifiex_adapter
*adapter
= priv
->adapter
;
859 priv
->mgmt_frame_mask
= 0;
860 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
861 HostCmd_ACT_GEN_SET
, 0,
862 &priv
->mgmt_frame_mask
, false)) {
863 mwifiex_dbg(adapter
, ERROR
,
864 "could not unregister mgmt frame rx\n");
868 mwifiex_deauthenticate(priv
, NULL
);
870 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
871 adapter
->main_locked
= true;
872 if (adapter
->mwifiex_processing
) {
873 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
874 flush_workqueue(adapter
->workqueue
);
876 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
879 spin_lock_bh(&adapter
->rx_proc_lock
);
880 adapter
->rx_locked
= true;
881 if (adapter
->rx_processing
) {
882 spin_unlock_bh(&adapter
->rx_proc_lock
);
883 flush_workqueue(adapter
->rx_workqueue
);
885 spin_unlock_bh(&adapter
->rx_proc_lock
);
888 mwifiex_free_priv(priv
);
889 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
890 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
891 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
897 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
898 struct net_device
*dev
,
899 enum nl80211_iftype type
)
901 struct mwifiex_adapter
*adapter
= priv
->adapter
;
904 mwifiex_init_priv(priv
);
906 priv
->bss_mode
= type
;
907 priv
->wdev
.iftype
= type
;
909 mwifiex_init_priv_params(priv
, priv
->netdev
);
910 priv
->bss_started
= 0;
913 case NL80211_IFTYPE_STATION
:
914 case NL80211_IFTYPE_ADHOC
:
915 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
917 case NL80211_IFTYPE_P2P_CLIENT
:
918 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
920 case NL80211_IFTYPE_P2P_GO
:
921 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
923 case NL80211_IFTYPE_AP
:
924 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
927 mwifiex_dbg(adapter
, ERROR
,
928 "%s: changing to %d not supported\n",
933 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
934 adapter
->main_locked
= false;
935 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
937 spin_lock_bh(&adapter
->rx_proc_lock
);
938 adapter
->rx_locked
= false;
939 spin_unlock_bh(&adapter
->rx_proc_lock
);
941 mwifiex_set_mac_address(priv
, dev
, false, NULL
);
947 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
948 enum nl80211_iftype curr_iftype
,
949 enum nl80211_iftype type
,
950 struct vif_params
*params
)
952 struct mwifiex_private
*priv
;
953 struct mwifiex_adapter
*adapter
;
955 priv
= mwifiex_netdev_get_priv(dev
);
960 adapter
= priv
->adapter
;
962 if (adapter
->curr_iface_comb
.p2p_intf
==
963 adapter
->iface_limit
.p2p_intf
) {
964 mwifiex_dbg(adapter
, ERROR
,
965 "cannot create multiple P2P ifaces\n");
969 mwifiex_dbg(adapter
, INFO
,
970 "%s: changing role to p2p\n", dev
->name
);
972 if (mwifiex_deinit_priv_params(priv
))
974 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
978 case NL80211_IFTYPE_P2P_CLIENT
:
979 if (mwifiex_cfg80211_init_p2p_client(priv
))
982 case NL80211_IFTYPE_P2P_GO
:
983 if (mwifiex_cfg80211_init_p2p_go(priv
))
987 mwifiex_dbg(adapter
, ERROR
,
988 "%s: changing to %d not supported\n",
993 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
994 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
997 if (mwifiex_sta_init_cmd(priv
, false, false))
1000 switch (curr_iftype
) {
1001 case NL80211_IFTYPE_STATION
:
1002 case NL80211_IFTYPE_ADHOC
:
1003 adapter
->curr_iface_comb
.sta_intf
--;
1005 case NL80211_IFTYPE_AP
:
1006 adapter
->curr_iface_comb
.uap_intf
--;
1012 adapter
->curr_iface_comb
.p2p_intf
++;
1013 dev
->ieee80211_ptr
->iftype
= type
;
1019 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
1020 enum nl80211_iftype curr_iftype
,
1021 enum nl80211_iftype type
,
1022 struct vif_params
*params
)
1024 struct mwifiex_private
*priv
;
1025 struct mwifiex_adapter
*adapter
;
1027 priv
= mwifiex_netdev_get_priv(dev
);
1032 adapter
= priv
->adapter
;
1034 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
1035 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
1036 (adapter
->curr_iface_comb
.sta_intf
==
1037 adapter
->iface_limit
.sta_intf
)) {
1038 mwifiex_dbg(adapter
, ERROR
,
1039 "cannot create multiple station/adhoc ifaces\n");
1043 if (type
== NL80211_IFTYPE_STATION
)
1044 mwifiex_dbg(adapter
, INFO
,
1045 "%s: changing role to station\n", dev
->name
);
1047 mwifiex_dbg(adapter
, INFO
,
1048 "%s: changing role to adhoc\n", dev
->name
);
1050 if (mwifiex_deinit_priv_params(priv
))
1052 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1054 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1055 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1057 if (mwifiex_sta_init_cmd(priv
, false, false))
1060 switch (curr_iftype
) {
1061 case NL80211_IFTYPE_P2P_CLIENT
:
1062 case NL80211_IFTYPE_P2P_GO
:
1063 adapter
->curr_iface_comb
.p2p_intf
--;
1065 case NL80211_IFTYPE_AP
:
1066 adapter
->curr_iface_comb
.uap_intf
--;
1072 adapter
->curr_iface_comb
.sta_intf
++;
1073 dev
->ieee80211_ptr
->iftype
= type
;
1078 mwifiex_change_vif_to_ap(struct net_device
*dev
,
1079 enum nl80211_iftype curr_iftype
,
1080 enum nl80211_iftype type
,
1081 struct vif_params
*params
)
1083 struct mwifiex_private
*priv
;
1084 struct mwifiex_adapter
*adapter
;
1086 priv
= mwifiex_netdev_get_priv(dev
);
1091 adapter
= priv
->adapter
;
1093 if (adapter
->curr_iface_comb
.uap_intf
==
1094 adapter
->iface_limit
.uap_intf
) {
1095 mwifiex_dbg(adapter
, ERROR
,
1096 "cannot create multiple AP ifaces\n");
1100 mwifiex_dbg(adapter
, INFO
,
1101 "%s: changing role to AP\n", dev
->name
);
1103 if (mwifiex_deinit_priv_params(priv
))
1105 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1107 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1108 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1110 if (mwifiex_sta_init_cmd(priv
, false, false))
1113 switch (curr_iftype
) {
1114 case NL80211_IFTYPE_P2P_CLIENT
:
1115 case NL80211_IFTYPE_P2P_GO
:
1116 adapter
->curr_iface_comb
.p2p_intf
--;
1118 case NL80211_IFTYPE_STATION
:
1119 case NL80211_IFTYPE_ADHOC
:
1120 adapter
->curr_iface_comb
.sta_intf
--;
1126 adapter
->curr_iface_comb
.uap_intf
++;
1127 dev
->ieee80211_ptr
->iftype
= type
;
1131 * CFG802.11 operation handler to change interface type.
1134 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1135 struct net_device
*dev
,
1136 enum nl80211_iftype type
,
1137 struct vif_params
*params
)
1139 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1140 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1142 if (priv
->scan_request
) {
1143 mwifiex_dbg(priv
->adapter
, ERROR
,
1144 "change virtual interface: scan in process\n");
1148 switch (curr_iftype
) {
1149 case NL80211_IFTYPE_ADHOC
:
1151 case NL80211_IFTYPE_STATION
:
1152 priv
->bss_mode
= type
;
1153 priv
->sec_info
.authentication_mode
=
1154 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1155 dev
->ieee80211_ptr
->iftype
= type
;
1156 mwifiex_deauthenticate(priv
, NULL
);
1157 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1158 HostCmd_ACT_GEN_SET
, 0, NULL
,
1160 case NL80211_IFTYPE_P2P_CLIENT
:
1161 case NL80211_IFTYPE_P2P_GO
:
1162 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1164 case NL80211_IFTYPE_AP
:
1165 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1167 case NL80211_IFTYPE_UNSPECIFIED
:
1168 mwifiex_dbg(priv
->adapter
, INFO
,
1169 "%s: kept type as IBSS\n", dev
->name
);
1171 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1174 mwifiex_dbg(priv
->adapter
, ERROR
,
1175 "%s: changing to %d not supported\n",
1180 case NL80211_IFTYPE_STATION
:
1182 case NL80211_IFTYPE_ADHOC
:
1183 priv
->bss_mode
= type
;
1184 priv
->sec_info
.authentication_mode
=
1185 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1186 dev
->ieee80211_ptr
->iftype
= type
;
1187 mwifiex_deauthenticate(priv
, NULL
);
1188 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1189 HostCmd_ACT_GEN_SET
, 0, NULL
,
1191 case NL80211_IFTYPE_P2P_CLIENT
:
1192 case NL80211_IFTYPE_P2P_GO
:
1193 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1195 case NL80211_IFTYPE_AP
:
1196 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1198 case NL80211_IFTYPE_UNSPECIFIED
:
1199 mwifiex_dbg(priv
->adapter
, INFO
,
1200 "%s: kept type as STA\n", dev
->name
);
1202 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1205 mwifiex_dbg(priv
->adapter
, ERROR
,
1206 "%s: changing to %d not supported\n",
1211 case NL80211_IFTYPE_AP
:
1213 case NL80211_IFTYPE_ADHOC
:
1214 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1217 case NL80211_IFTYPE_P2P_CLIENT
:
1218 case NL80211_IFTYPE_P2P_GO
:
1219 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1221 case NL80211_IFTYPE_UNSPECIFIED
:
1222 mwifiex_dbg(priv
->adapter
, INFO
,
1223 "%s: kept type as AP\n", dev
->name
);
1225 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1228 mwifiex_dbg(priv
->adapter
, ERROR
,
1229 "%s: changing to %d not supported\n",
1234 case NL80211_IFTYPE_P2P_CLIENT
:
1235 case NL80211_IFTYPE_P2P_GO
:
1237 case NL80211_IFTYPE_STATION
:
1238 if (mwifiex_cfg80211_deinit_p2p(priv
))
1240 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1241 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1242 dev
->ieee80211_ptr
->iftype
= type
;
1243 if (mwifiex_deinit_priv_params(priv
))
1245 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1247 if (mwifiex_sta_init_cmd(priv
, false, false))
1250 case NL80211_IFTYPE_ADHOC
:
1251 if (mwifiex_cfg80211_deinit_p2p(priv
))
1253 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1256 case NL80211_IFTYPE_AP
:
1257 if (mwifiex_cfg80211_deinit_p2p(priv
))
1259 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1261 case NL80211_IFTYPE_UNSPECIFIED
:
1262 mwifiex_dbg(priv
->adapter
, INFO
,
1263 "%s: kept type as P2P\n", dev
->name
);
1265 case NL80211_IFTYPE_P2P_CLIENT
:
1266 case NL80211_IFTYPE_P2P_GO
:
1269 mwifiex_dbg(priv
->adapter
, ERROR
,
1270 "%s: changing to %d not supported\n",
1276 mwifiex_dbg(priv
->adapter
, ERROR
,
1277 "%s: unknown iftype: %d\n",
1278 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1287 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 rateinfo
, u8 htinfo
,
1288 struct rate_info
*rate
)
1290 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1292 if (adapter
->is_hw_11ac_capable
) {
1293 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1294 if (htinfo
& BIT(0)) {
1296 rate
->mcs
= rateinfo
;
1297 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1299 if (htinfo
& BIT(1)) {
1301 rate
->mcs
= rateinfo
& 0x0F;
1302 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1305 if (htinfo
& (BIT(1) | BIT(0))) {
1307 switch (htinfo
& (BIT(3) | BIT(2))) {
1309 rate
->bw
= RATE_INFO_BW_20
;
1312 rate
->bw
= RATE_INFO_BW_40
;
1315 rate
->bw
= RATE_INFO_BW_80
;
1317 case (BIT(3) | BIT(2)):
1318 rate
->bw
= RATE_INFO_BW_160
;
1322 if (htinfo
& BIT(4))
1323 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1325 if ((rateinfo
>> 4) == 1)
1332 * Bit 0 in htinfo indicates that current rate is 11n. Valid
1333 * MCS index values for us are 0 to 15.
1335 if ((htinfo
& BIT(0)) && (rateinfo
< 16)) {
1336 rate
->mcs
= rateinfo
;
1337 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1338 rate
->bw
= RATE_INFO_BW_20
;
1339 if (htinfo
& BIT(1))
1340 rate
->bw
= RATE_INFO_BW_40
;
1341 if (htinfo
& BIT(2))
1342 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1346 /* Decode legacy rates for non-HT. */
1347 if (!(htinfo
& (BIT(0) | BIT(1)))) {
1348 /* Bitrates in multiples of 100kb/s. */
1349 static const int legacy_rates
[] = {
1354 [4] = 60, /* MWIFIEX_RATE_INDEX_OFDM0 */
1364 if (rateinfo
< ARRAY_SIZE(legacy_rates
))
1365 rate
->legacy
= legacy_rates
[rateinfo
];
1370 * This function dumps the station information on a buffer.
1372 * The following information are shown -
1373 * - Total bytes transmitted
1374 * - Total bytes received
1375 * - Total packets transmitted
1376 * - Total packets received
1377 * - Signal quality level
1378 * - Transmission rate
1381 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1382 struct mwifiex_sta_node
*node
,
1383 struct station_info
*sinfo
)
1387 sinfo
->filled
= BIT_ULL(NL80211_STA_INFO_RX_BYTES
) | BIT_ULL(NL80211_STA_INFO_TX_BYTES
) |
1388 BIT_ULL(NL80211_STA_INFO_RX_PACKETS
) | BIT_ULL(NL80211_STA_INFO_TX_PACKETS
) |
1389 BIT_ULL(NL80211_STA_INFO_TX_BITRATE
) |
1390 BIT_ULL(NL80211_STA_INFO_SIGNAL
) | BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG
);
1392 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1396 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME
) |
1397 BIT_ULL(NL80211_STA_INFO_TX_FAILED
);
1398 sinfo
->inactive_time
=
1399 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1401 sinfo
->signal
= node
->stats
.rssi
;
1402 sinfo
->signal_avg
= node
->stats
.rssi
;
1403 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1404 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1405 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1406 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1407 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1409 mwifiex_parse_htinfo(priv
, priv
->tx_rate
,
1410 node
->stats
.last_tx_htinfo
,
1412 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1417 /* Get signal information from the firmware */
1418 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1419 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1420 mwifiex_dbg(priv
->adapter
, ERROR
,
1421 "failed to get signal information\n");
1425 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1426 mwifiex_dbg(priv
->adapter
, ERROR
,
1427 "getting data rate error\n");
1431 /* Get DTIM period information from firmware */
1432 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1433 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1434 &priv
->dtim_period
, true);
1436 mwifiex_parse_htinfo(priv
, priv
->tx_rate
, priv
->tx_htinfo
,
1439 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1440 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1441 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1442 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1443 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1444 sinfo
->signal
= priv
->bcn_rssi_avg
;
1445 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1446 sinfo
->txrate
.legacy
= rate
* 5;
1448 sinfo
->filled
|= BIT(NL80211_STA_INFO_RX_BITRATE
);
1449 mwifiex_parse_htinfo(priv
, priv
->rxpd_rate
, priv
->rxpd_htinfo
,
1452 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1453 sinfo
->filled
|= BIT_ULL(NL80211_STA_INFO_BSS_PARAM
);
1454 sinfo
->bss_param
.flags
= 0;
1455 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1456 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1457 sinfo
->bss_param
.flags
|=
1458 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1459 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1460 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1461 sinfo
->bss_param
.flags
|=
1462 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1463 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1464 sinfo
->bss_param
.beacon_interval
=
1465 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1472 * CFG802.11 operation handler to get station information.
1474 * This function only works in connected mode, and dumps the
1475 * requested station information, if available.
1478 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1479 const u8
*mac
, struct station_info
*sinfo
)
1481 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1483 if (!priv
->media_connected
)
1485 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1488 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1492 * CFG802.11 operation handler to dump station information.
1495 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1496 int idx
, u8
*mac
, struct station_info
*sinfo
)
1498 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1499 static struct mwifiex_sta_node
*node
;
1501 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1502 priv
->media_connected
&& idx
== 0) {
1503 ether_addr_copy(mac
, priv
->cfg_bssid
);
1504 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1505 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1506 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1507 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1509 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1514 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1515 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1516 ether_addr_copy(mac
, node
->mac_addr
);
1517 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1525 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1526 int idx
, struct survey_info
*survey
)
1528 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1529 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1530 enum nl80211_band band
;
1532 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1534 memset(survey
, 0, sizeof(struct survey_info
));
1536 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1537 priv
->media_connected
&& idx
== 0) {
1538 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1539 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1541 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1542 survey
->channel
= ieee80211_get_channel(wiphy
,
1543 ieee80211_channel_to_frequency(chan
, band
));
1545 if (priv
->bcn_nf_last
) {
1546 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1547 survey
->noise
= priv
->bcn_nf_last
;
1552 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1555 if (!pchan_stats
[idx
].cca_scan_dur
)
1558 band
= pchan_stats
[idx
].bandcfg
;
1559 survey
->channel
= ieee80211_get_channel(wiphy
,
1560 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1561 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1563 SURVEY_INFO_TIME_BUSY
;
1564 survey
->noise
= pchan_stats
[idx
].noise
;
1565 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1566 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1571 /* Supported rates to be advertised to the cfg80211 */
1572 static struct ieee80211_rate mwifiex_rates
[] = {
1573 {.bitrate
= 10, .hw_value
= 2, },
1574 {.bitrate
= 20, .hw_value
= 4, },
1575 {.bitrate
= 55, .hw_value
= 11, },
1576 {.bitrate
= 110, .hw_value
= 22, },
1577 {.bitrate
= 60, .hw_value
= 12, },
1578 {.bitrate
= 90, .hw_value
= 18, },
1579 {.bitrate
= 120, .hw_value
= 24, },
1580 {.bitrate
= 180, .hw_value
= 36, },
1581 {.bitrate
= 240, .hw_value
= 48, },
1582 {.bitrate
= 360, .hw_value
= 72, },
1583 {.bitrate
= 480, .hw_value
= 96, },
1584 {.bitrate
= 540, .hw_value
= 108, },
1587 /* Channel definitions to be advertised to cfg80211 */
1588 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1589 {.center_freq
= 2412, .hw_value
= 1, },
1590 {.center_freq
= 2417, .hw_value
= 2, },
1591 {.center_freq
= 2422, .hw_value
= 3, },
1592 {.center_freq
= 2427, .hw_value
= 4, },
1593 {.center_freq
= 2432, .hw_value
= 5, },
1594 {.center_freq
= 2437, .hw_value
= 6, },
1595 {.center_freq
= 2442, .hw_value
= 7, },
1596 {.center_freq
= 2447, .hw_value
= 8, },
1597 {.center_freq
= 2452, .hw_value
= 9, },
1598 {.center_freq
= 2457, .hw_value
= 10, },
1599 {.center_freq
= 2462, .hw_value
= 11, },
1600 {.center_freq
= 2467, .hw_value
= 12, },
1601 {.center_freq
= 2472, .hw_value
= 13, },
1602 {.center_freq
= 2484, .hw_value
= 14, },
1605 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1606 .channels
= mwifiex_channels_2ghz
,
1607 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1608 .bitrates
= mwifiex_rates
,
1609 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1612 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1613 {.center_freq
= 5040, .hw_value
= 8, },
1614 {.center_freq
= 5060, .hw_value
= 12, },
1615 {.center_freq
= 5080, .hw_value
= 16, },
1616 {.center_freq
= 5170, .hw_value
= 34, },
1617 {.center_freq
= 5190, .hw_value
= 38, },
1618 {.center_freq
= 5210, .hw_value
= 42, },
1619 {.center_freq
= 5230, .hw_value
= 46, },
1620 {.center_freq
= 5180, .hw_value
= 36, },
1621 {.center_freq
= 5200, .hw_value
= 40, },
1622 {.center_freq
= 5220, .hw_value
= 44, },
1623 {.center_freq
= 5240, .hw_value
= 48, },
1624 {.center_freq
= 5260, .hw_value
= 52, },
1625 {.center_freq
= 5280, .hw_value
= 56, },
1626 {.center_freq
= 5300, .hw_value
= 60, },
1627 {.center_freq
= 5320, .hw_value
= 64, },
1628 {.center_freq
= 5500, .hw_value
= 100, },
1629 {.center_freq
= 5520, .hw_value
= 104, },
1630 {.center_freq
= 5540, .hw_value
= 108, },
1631 {.center_freq
= 5560, .hw_value
= 112, },
1632 {.center_freq
= 5580, .hw_value
= 116, },
1633 {.center_freq
= 5600, .hw_value
= 120, },
1634 {.center_freq
= 5620, .hw_value
= 124, },
1635 {.center_freq
= 5640, .hw_value
= 128, },
1636 {.center_freq
= 5660, .hw_value
= 132, },
1637 {.center_freq
= 5680, .hw_value
= 136, },
1638 {.center_freq
= 5700, .hw_value
= 140, },
1639 {.center_freq
= 5745, .hw_value
= 149, },
1640 {.center_freq
= 5765, .hw_value
= 153, },
1641 {.center_freq
= 5785, .hw_value
= 157, },
1642 {.center_freq
= 5805, .hw_value
= 161, },
1643 {.center_freq
= 5825, .hw_value
= 165, },
1646 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1647 .channels
= mwifiex_channels_5ghz
,
1648 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1649 .bitrates
= mwifiex_rates
+ 4,
1650 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1654 /* Supported crypto cipher suits to be advertised to cfg80211 */
1655 static const u32 mwifiex_cipher_suites
[] = {
1656 WLAN_CIPHER_SUITE_WEP40
,
1657 WLAN_CIPHER_SUITE_WEP104
,
1658 WLAN_CIPHER_SUITE_TKIP
,
1659 WLAN_CIPHER_SUITE_CCMP
,
1660 WLAN_CIPHER_SUITE_SMS4
,
1661 WLAN_CIPHER_SUITE_AES_CMAC
,
1664 /* Supported mgmt frame types to be advertised to cfg80211 */
1665 static const struct ieee80211_txrx_stypes
1666 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1667 [NL80211_IFTYPE_STATION
] = {
1668 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1669 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1670 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1671 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1673 [NL80211_IFTYPE_AP
] = {
1674 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1675 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1676 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1677 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1679 [NL80211_IFTYPE_P2P_CLIENT
] = {
1680 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1681 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1682 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1683 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1685 [NL80211_IFTYPE_P2P_GO
] = {
1686 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1687 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1688 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1689 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1694 * CFG802.11 operation handler for setting bit rates.
1696 * Function configures data rates to firmware using bitrate mask
1697 * provided by cfg80211.
1699 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1700 struct net_device
*dev
,
1702 const struct cfg80211_bitrate_mask
*mask
)
1704 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1705 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1706 enum nl80211_band band
;
1707 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1709 if (!priv
->media_connected
) {
1710 mwifiex_dbg(adapter
, ERROR
,
1711 "Can not set Tx data rate in disconnected state\n");
1715 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1717 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1719 /* Fill HR/DSSS rates. */
1720 if (band
== NL80211_BAND_2GHZ
)
1721 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1723 /* Fill OFDM rates */
1724 if (band
== NL80211_BAND_2GHZ
)
1725 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1727 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1729 /* Fill HT MCS rates */
1730 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1731 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1732 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1734 /* Fill VHT MCS rates */
1735 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1736 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1737 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1738 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1741 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1742 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1746 * CFG802.11 operation handler for connection quality monitoring.
1748 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1751 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1752 struct net_device
*dev
,
1753 s32 rssi_thold
, u32 rssi_hyst
)
1755 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1756 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1758 priv
->cqm_rssi_thold
= rssi_thold
;
1759 priv
->cqm_rssi_hyst
= rssi_hyst
;
1761 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1762 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1764 /* Subscribe/unsubscribe low and high rssi events */
1765 if (rssi_thold
&& rssi_hyst
) {
1766 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1767 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1768 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1769 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1770 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1771 return mwifiex_send_cmd(priv
,
1772 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1773 0, 0, &subsc_evt
, true);
1775 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1776 return mwifiex_send_cmd(priv
,
1777 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1778 0, 0, &subsc_evt
, true);
1784 /* cfg80211 operation handler for change_beacon.
1785 * Function retrieves and sets modified management IEs to FW.
1787 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1788 struct net_device
*dev
,
1789 struct cfg80211_beacon_data
*data
)
1791 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1792 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1794 mwifiex_cancel_scan(adapter
);
1796 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1797 mwifiex_dbg(priv
->adapter
, ERROR
,
1798 "%s: bss_type mismatched\n", __func__
);
1802 if (!priv
->bss_started
) {
1803 mwifiex_dbg(priv
->adapter
, ERROR
,
1804 "%s: bss not started\n", __func__
);
1808 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1809 mwifiex_dbg(priv
->adapter
, ERROR
,
1810 "%s: setting mgmt ies failed\n", __func__
);
1817 /* cfg80211 operation handler for del_station.
1818 * Function deauthenticates station which value is provided in mac parameter.
1819 * If mac is NULL/broadcast, all stations in associated station list are
1820 * deauthenticated. If bss is not started or there are no stations in
1821 * associated stations list, no action is taken.
1824 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1825 struct station_del_parameters
*params
)
1827 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1828 struct mwifiex_sta_node
*sta_node
;
1829 u8 deauth_mac
[ETH_ALEN
];
1831 if (!priv
->bss_started
&& priv
->wdev
.cac_started
) {
1832 mwifiex_dbg(priv
->adapter
, INFO
, "%s: abort CAC!\n", __func__
);
1833 mwifiex_abort_cac(priv
);
1836 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1839 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1842 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1843 __func__
, params
->mac
);
1845 eth_zero_addr(deauth_mac
);
1847 spin_lock_bh(&priv
->sta_list_spinlock
);
1848 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1850 ether_addr_copy(deauth_mac
, params
->mac
);
1851 spin_unlock_bh(&priv
->sta_list_spinlock
);
1853 if (is_valid_ether_addr(deauth_mac
)) {
1854 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1855 HostCmd_ACT_GEN_SET
, 0,
1864 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1866 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1867 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1868 MWIFIEX_BSS_ROLE_ANY
);
1869 struct mwifiex_ds_ant_cfg ant_cfg
;
1871 if (!tx_ant
|| !rx_ant
)
1874 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1875 /* Not a MIMO chip. User should provide specific antenna number
1876 * for Tx/Rx path or enable all antennas for diversity
1878 if (tx_ant
!= rx_ant
)
1881 if ((tx_ant
& (tx_ant
- 1)) &&
1882 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1885 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1886 (priv
->adapter
->number_of_antenna
> 1)) {
1887 tx_ant
= RF_ANTENNA_AUTO
;
1888 rx_ant
= RF_ANTENNA_AUTO
;
1891 struct ieee80211_sta_ht_cap
*ht_info
;
1893 enum nl80211_band band
;
1895 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1896 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1897 if (adapter
->is_hw_11ac_capable
)
1898 adapter
->usr_dot_11ac_mcs_support
=
1899 MWIFIEX_11AC_MCS_MAP_1X1
;
1901 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1902 if (adapter
->is_hw_11ac_capable
)
1903 adapter
->usr_dot_11ac_mcs_support
=
1904 MWIFIEX_11AC_MCS_MAP_2X2
;
1907 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
1908 if (!adapter
->wiphy
->bands
[band
])
1911 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1913 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1914 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1915 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1919 ant_cfg
.tx_ant
= tx_ant
;
1920 ant_cfg
.rx_ant
= rx_ant
;
1922 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1923 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1927 mwifiex_cfg80211_get_antenna(struct wiphy
*wiphy
, u32
*tx_ant
, u32
*rx_ant
)
1929 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1930 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1931 MWIFIEX_BSS_ROLE_ANY
);
1932 mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1933 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1935 *tx_ant
= priv
->tx_ant
;
1936 *rx_ant
= priv
->rx_ant
;
1941 /* cfg80211 operation handler for stop ap.
1942 * Function stops BSS running at uAP interface.
1944 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1946 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1948 mwifiex_abort_cac(priv
);
1950 if (mwifiex_del_mgmt_ies(priv
))
1951 mwifiex_dbg(priv
->adapter
, ERROR
,
1952 "Failed to delete mgmt IEs!\n");
1954 priv
->ap_11n_enabled
= 0;
1955 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1957 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1958 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1959 mwifiex_dbg(priv
->adapter
, ERROR
,
1960 "Failed to stop the BSS\n");
1964 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1965 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1966 mwifiex_dbg(priv
->adapter
, ERROR
,
1967 "Failed to reset BSS\n");
1971 if (netif_carrier_ok(priv
->netdev
))
1972 netif_carrier_off(priv
->netdev
);
1973 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1978 /* cfg80211 operation handler for start_ap.
1979 * Function sets beacon period, DTIM period, SSID and security into
1980 * AP config structure.
1981 * AP is configured with these settings and BSS is started.
1983 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1984 struct net_device
*dev
,
1985 struct cfg80211_ap_settings
*params
)
1987 struct mwifiex_uap_bss_param
*bss_cfg
;
1988 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1990 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1993 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1997 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1999 if (params
->beacon_interval
)
2000 bss_cfg
->beacon_period
= params
->beacon_interval
;
2001 if (params
->dtim_period
)
2002 bss_cfg
->dtim_period
= params
->dtim_period
;
2004 if (params
->ssid
&& params
->ssid_len
) {
2005 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
2006 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
2008 if (params
->inactivity_timeout
> 0) {
2009 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
2010 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
2011 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
2014 switch (params
->hidden_ssid
) {
2015 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
2016 bss_cfg
->bcast_ssid_ctl
= 1;
2018 case NL80211_HIDDEN_SSID_ZERO_LEN
:
2019 bss_cfg
->bcast_ssid_ctl
= 0;
2021 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
2022 bss_cfg
->bcast_ssid_ctl
= 2;
2029 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
2030 mwifiex_set_uap_rates(bss_cfg
, params
);
2032 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
2033 mwifiex_dbg(priv
->adapter
, ERROR
,
2034 "Failed to parse security parameters!\n");
2038 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
2040 if (priv
->adapter
->is_hw_11ac_capable
) {
2041 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
2042 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
2043 priv
->ap_11ac_enabled
);
2046 if (priv
->ap_11ac_enabled
)
2047 mwifiex_set_11ac_ba_params(priv
);
2049 mwifiex_set_ba_params(priv
);
2051 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
2053 if (mwifiex_is_11h_active(priv
))
2054 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
2056 if (mwifiex_is_11h_active(priv
) &&
2057 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
2059 mwifiex_dbg(priv
->adapter
, INFO
,
2060 "Disable 11h extensions in FW\n");
2061 if (mwifiex_11h_activate(priv
, false)) {
2062 mwifiex_dbg(priv
->adapter
, ERROR
,
2063 "Failed to disable 11h extensions!!");
2066 priv
->state_11h
.is_11h_active
= false;
2069 mwifiex_config_uap_11d(priv
, ¶ms
->beacon
);
2071 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
2072 mwifiex_dbg(priv
->adapter
, ERROR
,
2073 "Failed to start AP\n");
2077 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
2080 if (!netif_carrier_ok(priv
->netdev
))
2081 netif_carrier_on(priv
->netdev
);
2082 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
2084 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
2094 * CFG802.11 operation handler for disconnection request.
2096 * This function does not work when there is already a disconnection
2097 * procedure going on.
2100 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
2103 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2105 if (!mwifiex_stop_bg_scan(priv
))
2106 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2108 if (mwifiex_deauthenticate(priv
, NULL
))
2111 eth_zero_addr(priv
->cfg_bssid
);
2112 priv
->hs2_enabled
= false;
2118 * This function informs the CFG802.11 subsystem of a new IBSS.
2120 * The following information are sent to the CFG802.11 subsystem
2121 * to register the new IBSS. If we do not register the new IBSS,
2122 * a kernel panic will result.
2128 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
2130 struct ieee80211_channel
*chan
;
2131 struct mwifiex_bss_info bss_info
;
2132 struct cfg80211_bss
*bss
;
2134 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
2135 enum nl80211_band band
;
2137 if (mwifiex_get_bss_info(priv
, &bss_info
))
2140 ie_buf
[0] = WLAN_EID_SSID
;
2141 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
2143 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
2144 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
2145 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
2147 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
2148 chan
= ieee80211_get_channel(priv
->wdev
.wiphy
,
2149 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
2152 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2153 CFG80211_BSS_FTYPE_UNKNOWN
,
2154 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2155 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2157 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2158 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2165 * This function connects with a BSS.
2167 * This function handles both Infra and Ad-Hoc modes. It also performs
2168 * validity checking on the provided parameters, disconnects from the
2169 * current BSS (if any), sets up the association/scan parameters,
2170 * including security settings, and performs specific SSID scan before
2171 * trying to connect.
2173 * For Infra mode, the function returns failure if the specified SSID
2174 * is not found in scan table. However, for Ad-Hoc mode, it can create
2175 * the IBSS if it does not exist. On successful completion in either case,
2176 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2179 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2180 const u8
*ssid
, const u8
*bssid
, int mode
,
2181 struct ieee80211_channel
*channel
,
2182 struct cfg80211_connect_params
*sme
, bool privacy
)
2184 struct cfg80211_ssid req_ssid
;
2185 int ret
, auth_type
= 0;
2186 struct cfg80211_bss
*bss
= NULL
;
2187 u8 is_scanning_required
= 0;
2189 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2191 req_ssid
.ssid_len
= ssid_len
;
2192 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2193 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2197 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2198 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2199 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2203 /* As this is new association, clear locally stored
2204 * keys and security related flags */
2205 priv
->sec_info
.wpa_enabled
= false;
2206 priv
->sec_info
.wpa2_enabled
= false;
2207 priv
->wep_key_curr_index
= 0;
2208 priv
->sec_info
.encryption_mode
= 0;
2209 priv
->sec_info
.is_authtype_auto
= 0;
2210 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2212 if (mode
== NL80211_IFTYPE_ADHOC
) {
2215 /* set ibss coalescing_status */
2216 ret
= mwifiex_send_cmd(
2218 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
,
2219 HostCmd_ACT_GEN_SET
, 0, &enable
, true);
2223 /* "privacy" is set only for ad-hoc mode */
2226 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2227 * the firmware can find a matching network from the
2228 * scan. The cfg80211 does not give us the encryption
2229 * mode at this stage so just setting it to WEP here.
2231 priv
->sec_info
.encryption_mode
=
2232 WLAN_CIPHER_SUITE_WEP104
;
2233 priv
->sec_info
.authentication_mode
=
2234 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2240 /* Now handle infra mode. "sme" is valid for infra mode only */
2241 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2242 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2243 priv
->sec_info
.is_authtype_auto
= 1;
2245 auth_type
= sme
->auth_type
;
2248 if (sme
->crypto
.n_ciphers_pairwise
) {
2249 priv
->sec_info
.encryption_mode
=
2250 sme
->crypto
.ciphers_pairwise
[0];
2251 priv
->sec_info
.authentication_mode
= auth_type
;
2254 if (sme
->crypto
.cipher_group
) {
2255 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2256 priv
->sec_info
.authentication_mode
= auth_type
;
2259 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2262 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2263 mwifiex_dbg(priv
->adapter
, INFO
,
2264 "info: setting wep encryption\t"
2265 "with key len %d\n", sme
->key_len
);
2266 priv
->wep_key_curr_index
= sme
->key_idx
;
2267 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2268 sme
->key_len
, sme
->key_idx
,
2274 * Scan entries are valid for some time (15 sec). So we can save one
2275 * active scan time if we just try cfg80211_get_bss first. If it fails
2276 * then request scan and cfg80211_get_bss() again for final output.
2279 if (is_scanning_required
) {
2280 /* Do specific SSID scanning */
2281 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2282 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2287 /* Find the BSS we want using available scan results */
2288 if (mode
== NL80211_IFTYPE_ADHOC
)
2289 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2290 bssid
, ssid
, ssid_len
,
2291 IEEE80211_BSS_TYPE_IBSS
,
2292 IEEE80211_PRIVACY_ANY
);
2294 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2295 bssid
, ssid
, ssid_len
,
2296 IEEE80211_BSS_TYPE_ESS
,
2297 IEEE80211_PRIVACY_ANY
);
2300 if (is_scanning_required
) {
2301 mwifiex_dbg(priv
->adapter
, MSG
,
2302 "assoc: requested bss not found in scan results\n");
2305 is_scanning_required
= 1;
2307 mwifiex_dbg(priv
->adapter
, MSG
,
2308 "info: trying to associate to '%.*s' bssid %pM\n",
2309 req_ssid
.ssid_len
, (char *)req_ssid
.ssid
,
2311 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2316 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2320 if (mode
== NL80211_IFTYPE_ADHOC
) {
2321 /* Inform the BSS information to kernel, otherwise
2322 * kernel will give a panic after successful assoc */
2323 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2331 * CFG802.11 operation handler for association request.
2333 * This function does not work when the current mode is set to Ad-Hoc, or
2334 * when there is already an association procedure going on. The given BSS
2335 * information is used to associate.
2338 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2339 struct cfg80211_connect_params
*sme
)
2341 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2342 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2345 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2346 mwifiex_dbg(adapter
, ERROR
,
2347 "%s: reject infra assoc request in non-STA role\n",
2352 if (priv
->wdev
.current_bss
) {
2353 mwifiex_dbg(adapter
, ERROR
,
2354 "%s: already connected\n", dev
->name
);
2358 if (priv
->scan_block
)
2359 priv
->scan_block
= false;
2361 if (test_bit(MWIFIEX_SURPRISE_REMOVED
, &adapter
->work_flags
) ||
2362 test_bit(MWIFIEX_IS_CMD_TIMEDOUT
, &adapter
->work_flags
)) {
2363 mwifiex_dbg(adapter
, ERROR
,
2364 "%s: Ignore connection.\t"
2365 "Card removed or FW in bad state\n",
2370 mwifiex_dbg(adapter
, INFO
,
2371 "info: Trying to associate to %.*s and bssid %pM\n",
2372 (int)sme
->ssid_len
, (char *)sme
->ssid
, sme
->bssid
);
2374 if (!mwifiex_stop_bg_scan(priv
))
2375 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2377 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2378 priv
->bss_mode
, sme
->channel
, sme
, 0);
2380 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2381 NULL
, 0, WLAN_STATUS_SUCCESS
,
2383 mwifiex_dbg(priv
->adapter
, MSG
,
2384 "info: associated to bssid %pM successfully\n",
2386 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2387 priv
->adapter
->auto_tdls
&&
2388 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2389 mwifiex_setup_auto_tdls_timer(priv
);
2391 mwifiex_dbg(priv
->adapter
, ERROR
,
2392 "info: association to bssid %pM failed\n",
2394 eth_zero_addr(priv
->cfg_bssid
);
2397 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2398 NULL
, 0, NULL
, 0, ret
,
2401 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2403 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2411 * This function sets following parameters for ibss network.
2415 * - secondary channel offset
2417 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2418 struct cfg80211_ibss_params
*params
)
2420 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2422 u8 config_bands
= 0;
2424 if (params
->chandef
.chan
->band
== NL80211_BAND_2GHZ
) {
2425 if (!params
->basic_rates
) {
2426 config_bands
= BAND_B
| BAND_G
;
2428 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2430 * Rates below 6 Mbps in the table are CCK
2431 * rates; 802.11b and from 6 they are OFDM;
2434 if (mwifiex_rates
[i
].bitrate
== 60) {
2440 if (params
->basic_rates
< index
) {
2441 config_bands
= BAND_B
;
2443 config_bands
= BAND_G
;
2444 if (params
->basic_rates
% index
)
2445 config_bands
|= BAND_B
;
2449 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2451 config_bands
|= BAND_G
| BAND_GN
;
2453 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2455 config_bands
= BAND_A
;
2457 config_bands
= BAND_AN
| BAND_A
;
2460 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2461 adapter
->config_bands
= config_bands
;
2462 adapter
->adhoc_start_band
= config_bands
;
2464 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2465 adapter
->adhoc_11n_enabled
= true;
2467 adapter
->adhoc_11n_enabled
= false;
2470 adapter
->sec_chan_offset
=
2471 mwifiex_chan_type_to_sec_chan_offset(
2472 cfg80211_get_chandef_type(¶ms
->chandef
));
2473 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2474 params
->chandef
.chan
->center_freq
);
2476 mwifiex_dbg(adapter
, INFO
,
2477 "info: set ibss band %d, chan %d, chan offset %d\n",
2478 config_bands
, priv
->adhoc_channel
,
2479 adapter
->sec_chan_offset
);
2485 * CFG802.11 operation handler to join an IBSS.
2487 * This function does not work in any mode other than Ad-Hoc, or if
2488 * a join operation is already in progress.
2491 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2492 struct cfg80211_ibss_params
*params
)
2494 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2497 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2498 mwifiex_dbg(priv
->adapter
, ERROR
,
2499 "request to join ibss received\t"
2500 "when station is not in ibss mode\n");
2504 mwifiex_dbg(priv
->adapter
, MSG
,
2505 "info: trying to join to %.*s and bssid %pM\n",
2506 params
->ssid_len
, (char *)params
->ssid
, params
->bssid
);
2508 mwifiex_set_ibss_params(priv
, params
);
2510 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2511 params
->bssid
, priv
->bss_mode
,
2512 params
->chandef
.chan
, NULL
,
2516 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2517 params
->chandef
.chan
, GFP_KERNEL
);
2518 mwifiex_dbg(priv
->adapter
, MSG
,
2519 "info: joined/created adhoc network with bssid\t"
2520 "%pM successfully\n", priv
->cfg_bssid
);
2522 mwifiex_dbg(priv
->adapter
, ERROR
,
2523 "info: failed creating/joining adhoc network\n");
2530 * CFG802.11 operation handler to leave an IBSS.
2532 * This function does not work if a leave operation is
2533 * already in progress.
2536 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2538 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2540 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2542 if (mwifiex_deauthenticate(priv
, NULL
))
2545 eth_zero_addr(priv
->cfg_bssid
);
2551 * CFG802.11 operation handler for scan request.
2553 * This function issues a scan request to the firmware based upon
2554 * the user specified scan configuration. On successful completion,
2555 * it also informs the results.
2558 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2559 struct cfg80211_scan_request
*request
)
2561 struct net_device
*dev
= request
->wdev
->netdev
;
2562 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2564 struct ieee80211_channel
*chan
;
2565 struct ieee_types_header
*ie
;
2566 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2567 u8 mac_addr
[ETH_ALEN
];
2569 mwifiex_dbg(priv
->adapter
, CMD
,
2570 "info: received scan request on %s\n", dev
->name
);
2572 /* Block scan request if scan operation or scan cleanup when interface
2573 * is disabled is in process
2575 if (priv
->scan_request
|| priv
->scan_aborting
) {
2576 mwifiex_dbg(priv
->adapter
, WARN
,
2577 "cmd: Scan already in process..\n");
2581 if (!priv
->wdev
.current_bss
&& priv
->scan_block
)
2582 priv
->scan_block
= false;
2584 if (!mwifiex_stop_bg_scan(priv
))
2585 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
, 0);
2587 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2591 priv
->scan_request
= request
;
2593 if (request
->flags
& NL80211_SCAN_FLAG_RANDOM_ADDR
) {
2594 get_random_mask_addr(mac_addr
, request
->mac_addr
,
2595 request
->mac_addr_mask
);
2596 ether_addr_copy(request
->mac_addr
, mac_addr
);
2597 ether_addr_copy(user_scan_cfg
->random_mac
, mac_addr
);
2600 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2601 user_scan_cfg
->ssid_list
= request
->ssids
;
2603 if (request
->ie
&& request
->ie_len
) {
2605 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2606 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2608 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2609 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2610 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2611 offset
+= sizeof(*ie
) + ie
->len
;
2613 if (offset
>= request
->ie_len
)
2618 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2619 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2620 chan
= request
->channels
[i
];
2621 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2622 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2624 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2625 user_scan_cfg
->chan_list
[i
].scan_type
=
2626 MWIFIEX_SCAN_TYPE_PASSIVE
;
2628 user_scan_cfg
->chan_list
[i
].scan_type
=
2629 MWIFIEX_SCAN_TYPE_ACTIVE
;
2631 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2634 if (priv
->adapter
->scan_chan_gap_enabled
&&
2635 mwifiex_is_any_intf_active(priv
))
2636 user_scan_cfg
->scan_chan_gap
=
2637 priv
->adapter
->scan_chan_gap_time
;
2639 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2640 kfree(user_scan_cfg
);
2642 mwifiex_dbg(priv
->adapter
, ERROR
,
2643 "scan failed: %d\n", ret
);
2644 priv
->scan_aborting
= false;
2645 priv
->scan_request
= NULL
;
2649 if (request
->ie
&& request
->ie_len
) {
2650 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2651 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2652 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2653 memset(&priv
->vs_ie
[i
].ie
, 0,
2654 MWIFIEX_MAX_VSIE_LEN
);
2661 /* CFG802.11 operation handler for sched_scan_start.
2663 * This function issues a bgscan config request to the firmware based upon
2664 * the user specified sched_scan configuration. On successful completion,
2665 * firmware will generate BGSCAN_REPORT event, driver should issue bgscan
2666 * query command to get sched_scan results from firmware.
2669 mwifiex_cfg80211_sched_scan_start(struct wiphy
*wiphy
,
2670 struct net_device
*dev
,
2671 struct cfg80211_sched_scan_request
*request
)
2673 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2675 struct ieee80211_channel
*chan
;
2676 struct mwifiex_bg_scan_cfg
*bgscan_cfg
;
2677 struct ieee_types_header
*ie
;
2679 if (!request
|| (!request
->n_ssids
&& !request
->n_match_sets
)) {
2680 wiphy_err(wiphy
, "%s : Invalid Sched_scan parameters",
2685 wiphy_info(wiphy
, "sched_scan start : n_ssids=%d n_match_sets=%d ",
2686 request
->n_ssids
, request
->n_match_sets
);
2687 wiphy_info(wiphy
, "n_channels=%d interval=%d ie_len=%d\n",
2688 request
->n_channels
, request
->scan_plans
->interval
,
2689 (int)request
->ie_len
);
2691 bgscan_cfg
= kzalloc(sizeof(*bgscan_cfg
), GFP_KERNEL
);
2695 if (priv
->scan_request
|| priv
->scan_aborting
)
2696 bgscan_cfg
->start_later
= true;
2698 bgscan_cfg
->num_ssids
= request
->n_match_sets
;
2699 bgscan_cfg
->ssid_list
= request
->match_sets
;
2701 if (request
->ie
&& request
->ie_len
) {
2703 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2704 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2706 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_BGSCAN
;
2707 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2708 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2709 offset
+= sizeof(*ie
) + ie
->len
;
2711 if (offset
>= request
->ie_len
)
2716 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2717 MWIFIEX_BG_SCAN_CHAN_MAX
); i
++) {
2718 chan
= request
->channels
[i
];
2719 bgscan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2720 bgscan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2722 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2723 bgscan_cfg
->chan_list
[i
].scan_type
=
2724 MWIFIEX_SCAN_TYPE_PASSIVE
;
2726 bgscan_cfg
->chan_list
[i
].scan_type
=
2727 MWIFIEX_SCAN_TYPE_ACTIVE
;
2729 bgscan_cfg
->chan_list
[i
].scan_time
= 0;
2732 bgscan_cfg
->chan_per_scan
= min_t(u32
, request
->n_channels
,
2733 MWIFIEX_BG_SCAN_CHAN_MAX
);
2735 /* Use at least 15 second for per scan cycle */
2736 bgscan_cfg
->scan_interval
= (request
->scan_plans
->interval
>
2737 MWIFIEX_BGSCAN_INTERVAL
) ?
2738 request
->scan_plans
->interval
:
2739 MWIFIEX_BGSCAN_INTERVAL
;
2741 bgscan_cfg
->repeat_count
= MWIFIEX_BGSCAN_REPEAT_COUNT
;
2742 bgscan_cfg
->report_condition
= MWIFIEX_BGSCAN_SSID_MATCH
|
2743 MWIFIEX_BGSCAN_WAIT_ALL_CHAN_DONE
;
2744 bgscan_cfg
->bss_type
= MWIFIEX_BSS_MODE_INFRA
;
2745 bgscan_cfg
->action
= MWIFIEX_BGSCAN_ACT_SET
;
2746 bgscan_cfg
->enable
= true;
2747 if (request
->min_rssi_thold
!= NL80211_SCAN_RSSI_THOLD_OFF
) {
2748 bgscan_cfg
->report_condition
|= MWIFIEX_BGSCAN_SSID_RSSI_MATCH
;
2749 bgscan_cfg
->rssi_threshold
= request
->min_rssi_thold
;
2752 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_BG_SCAN_CONFIG
,
2753 HostCmd_ACT_GEN_SET
, 0, bgscan_cfg
, true)) {
2758 priv
->sched_scanning
= true;
2764 /* CFG802.11 operation handler for sched_scan_stop.
2766 * This function issues a bgscan config command to disable
2767 * previous bgscan configuration in the firmware
2769 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy
*wiphy
,
2770 struct net_device
*dev
, u64 reqid
)
2772 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2774 wiphy_info(wiphy
, "sched scan stop!");
2775 mwifiex_stop_bg_scan(priv
);
2780 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2781 struct mwifiex_private
*priv
)
2783 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2785 vht_info
->vht_supported
= true;
2787 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2788 /* Update MCS support for VHT */
2789 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2790 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2791 vht_info
->vht_mcs
.rx_highest
= 0;
2792 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2793 adapter
->hw_dot_11ac_mcs_support
>> 16);
2794 vht_info
->vht_mcs
.tx_highest
= 0;
2798 * This function sets up the CFG802.11 specific HT capability fields
2799 * with default values.
2801 * The following default values are set -
2802 * - HT Supported = True
2803 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2804 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2805 * - HT Capabilities supported by firmware
2806 * - MCS information, Rx mask = 0xff
2807 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2810 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2811 struct mwifiex_private
*priv
)
2814 struct ieee80211_mcs_info mcs_set
;
2815 u8
*mcs
= (u8
*)&mcs_set
;
2816 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2818 ht_info
->ht_supported
= true;
2819 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2820 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2822 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2824 /* Fill HT capability information */
2825 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2826 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2828 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2830 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2831 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2833 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2835 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2836 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2838 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2840 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2841 ht_info
->cap
|= 2 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2843 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2845 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2846 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2848 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2850 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2851 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2853 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2855 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2856 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2858 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2860 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2861 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2863 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2865 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2866 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2868 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2869 /* Set MCS for 1x1/2x2 */
2870 memset(mcs
, 0xff, rx_mcs_supp
);
2871 /* Clear all the other values */
2872 memset(&mcs
[rx_mcs_supp
], 0,
2873 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2874 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2875 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2876 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2877 SETHT_MCS32(mcs_set
.rx_mask
);
2879 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2881 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2885 * create a new virtual interface with the given name and name assign type
2887 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2889 unsigned char name_assign_type
,
2890 enum nl80211_iftype type
,
2891 struct vif_params
*params
)
2893 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2894 struct mwifiex_private
*priv
;
2895 struct net_device
*dev
;
2900 return ERR_PTR(-EFAULT
);
2903 case NL80211_IFTYPE_UNSPECIFIED
:
2904 case NL80211_IFTYPE_STATION
:
2905 case NL80211_IFTYPE_ADHOC
:
2906 if (adapter
->curr_iface_comb
.sta_intf
==
2907 adapter
->iface_limit
.sta_intf
) {
2908 mwifiex_dbg(adapter
, ERROR
,
2909 "cannot create multiple sta/adhoc ifaces\n");
2910 return ERR_PTR(-EINVAL
);
2913 priv
= mwifiex_get_unused_priv_by_bss_type(
2914 adapter
, MWIFIEX_BSS_TYPE_STA
);
2916 mwifiex_dbg(adapter
, ERROR
,
2917 "could not get free private struct\n");
2918 return ERR_PTR(-EFAULT
);
2921 priv
->wdev
.wiphy
= wiphy
;
2922 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2924 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2925 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2927 priv
->bss_mode
= type
;
2929 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2930 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2931 priv
->bss_priority
= 0;
2932 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2935 case NL80211_IFTYPE_AP
:
2936 if (adapter
->curr_iface_comb
.uap_intf
==
2937 adapter
->iface_limit
.uap_intf
) {
2938 mwifiex_dbg(adapter
, ERROR
,
2939 "cannot create multiple AP ifaces\n");
2940 return ERR_PTR(-EINVAL
);
2943 priv
= mwifiex_get_unused_priv_by_bss_type(
2944 adapter
, MWIFIEX_BSS_TYPE_UAP
);
2946 mwifiex_dbg(adapter
, ERROR
,
2947 "could not get free private struct\n");
2948 return ERR_PTR(-EFAULT
);
2951 priv
->wdev
.wiphy
= wiphy
;
2952 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2954 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2955 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2956 priv
->bss_priority
= 0;
2957 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2958 priv
->bss_started
= 0;
2959 priv
->bss_mode
= type
;
2962 case NL80211_IFTYPE_P2P_CLIENT
:
2963 if (adapter
->curr_iface_comb
.p2p_intf
==
2964 adapter
->iface_limit
.p2p_intf
) {
2965 mwifiex_dbg(adapter
, ERROR
,
2966 "cannot create multiple P2P ifaces\n");
2967 return ERR_PTR(-EINVAL
);
2970 priv
= mwifiex_get_unused_priv_by_bss_type(
2971 adapter
, MWIFIEX_BSS_TYPE_P2P
);
2973 mwifiex_dbg(adapter
, ERROR
,
2974 "could not get free private struct\n");
2975 return ERR_PTR(-EFAULT
);
2978 priv
->wdev
.wiphy
= wiphy
;
2979 /* At start-up, wpa_supplicant tries to change the interface
2980 * to NL80211_IFTYPE_STATION if it is not managed mode.
2982 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2983 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2985 /* Setting bss_type to P2P tells firmware that this interface
2986 * is receiving P2P peers found during find phase and doing
2987 * action frame handshake.
2989 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2991 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2992 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2993 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2994 priv
->bss_started
= 0;
2996 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2997 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2998 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2999 return ERR_PTR(-EFAULT
);
3004 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
3005 return ERR_PTR(-EINVAL
);
3008 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
3009 name_assign_type
, ether_setup
,
3010 IEEE80211_NUM_ACS
, 1);
3012 mwifiex_dbg(adapter
, ERROR
,
3013 "no memory available for netdevice\n");
3015 goto err_alloc_netdev
;
3018 mwifiex_init_priv_params(priv
, dev
);
3022 if (!adapter
->mfg_mode
) {
3023 mwifiex_set_mac_address(priv
, dev
, false, NULL
);
3025 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
3026 HostCmd_ACT_GEN_SET
, 0, NULL
, true);
3028 goto err_set_bss_mode
;
3030 ret
= mwifiex_sta_init_cmd(priv
, false, false);
3035 mwifiex_setup_ht_caps(&wiphy
->bands
[NL80211_BAND_2GHZ
]->ht_cap
, priv
);
3036 if (adapter
->is_hw_11ac_capable
)
3037 mwifiex_setup_vht_caps(
3038 &wiphy
->bands
[NL80211_BAND_2GHZ
]->vht_cap
, priv
);
3040 if (adapter
->config_bands
& BAND_A
)
3041 mwifiex_setup_ht_caps(
3042 &wiphy
->bands
[NL80211_BAND_5GHZ
]->ht_cap
, priv
);
3044 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
3045 mwifiex_setup_vht_caps(
3046 &wiphy
->bands
[NL80211_BAND_5GHZ
]->vht_cap
, priv
);
3048 dev_net_set(dev
, wiphy_net(wiphy
));
3049 dev
->ieee80211_ptr
= &priv
->wdev
;
3050 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
3051 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
3053 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
3054 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
3055 dev
->needed_headroom
= MWIFIEX_MIN_DATA_HEADER_LEN
;
3056 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
3058 mdev_priv
= netdev_priv(dev
);
3059 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
3061 SET_NETDEV_DEV(dev
, adapter
->dev
);
3063 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
3066 WQ_UNBOUND
, 1, name
);
3067 if (!priv
->dfs_cac_workqueue
) {
3068 mwifiex_dbg(adapter
, ERROR
, "cannot alloc DFS CAC queue\n");
3073 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
3075 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
3076 WQ_HIGHPRI
| WQ_UNBOUND
|
3077 WQ_MEM_RECLAIM
, 1, name
);
3078 if (!priv
->dfs_chan_sw_workqueue
) {
3079 mwifiex_dbg(adapter
, ERROR
, "cannot alloc DFS channel sw queue\n");
3081 goto err_alloc_chsw
;
3084 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
3085 mwifiex_dfs_chan_sw_work_queue
);
3087 mutex_init(&priv
->async_mutex
);
3089 /* Register network device */
3090 if (register_netdevice(dev
)) {
3091 mwifiex_dbg(adapter
, ERROR
, "cannot register network device\n");
3093 goto err_reg_netdev
;
3096 mwifiex_dbg(adapter
, INFO
,
3097 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
3099 #ifdef CONFIG_DEBUG_FS
3100 mwifiex_dev_debugfs_init(priv
);
3104 case NL80211_IFTYPE_UNSPECIFIED
:
3105 case NL80211_IFTYPE_STATION
:
3106 case NL80211_IFTYPE_ADHOC
:
3107 adapter
->curr_iface_comb
.sta_intf
++;
3109 case NL80211_IFTYPE_AP
:
3110 adapter
->curr_iface_comb
.uap_intf
++;
3112 case NL80211_IFTYPE_P2P_CLIENT
:
3113 adapter
->curr_iface_comb
.p2p_intf
++;
3116 /* This should be dead code; checked above */
3117 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
3118 return ERR_PTR(-EINVAL
);
3124 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3125 priv
->dfs_chan_sw_workqueue
= NULL
;
3127 destroy_workqueue(priv
->dfs_cac_workqueue
);
3128 priv
->dfs_cac_workqueue
= NULL
;
3131 priv
->netdev
= NULL
;
3135 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
3136 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
3137 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3138 return ERR_PTR(ret
);
3140 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
3143 * del_virtual_intf: remove the virtual interface determined by dev
3145 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
3147 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3148 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3149 struct sk_buff
*skb
, *tmp
;
3151 #ifdef CONFIG_DEBUG_FS
3152 mwifiex_dev_debugfs_remove(priv
);
3155 if (priv
->sched_scanning
)
3156 priv
->sched_scanning
= false;
3158 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
3160 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
) {
3161 skb_unlink(skb
, &priv
->bypass_txq
);
3162 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
3165 if (netif_carrier_ok(priv
->netdev
))
3166 netif_carrier_off(priv
->netdev
);
3168 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
3169 unregister_netdevice(wdev
->netdev
);
3171 if (priv
->dfs_cac_workqueue
) {
3172 flush_workqueue(priv
->dfs_cac_workqueue
);
3173 destroy_workqueue(priv
->dfs_cac_workqueue
);
3174 priv
->dfs_cac_workqueue
= NULL
;
3177 if (priv
->dfs_chan_sw_workqueue
) {
3178 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
3179 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3180 priv
->dfs_chan_sw_workqueue
= NULL
;
3182 /* Clear the priv in adapter */
3183 priv
->netdev
= NULL
;
3185 switch (priv
->bss_mode
) {
3186 case NL80211_IFTYPE_UNSPECIFIED
:
3187 case NL80211_IFTYPE_STATION
:
3188 case NL80211_IFTYPE_ADHOC
:
3189 adapter
->curr_iface_comb
.sta_intf
--;
3191 case NL80211_IFTYPE_AP
:
3192 adapter
->curr_iface_comb
.uap_intf
--;
3194 case NL80211_IFTYPE_P2P_CLIENT
:
3195 case NL80211_IFTYPE_P2P_GO
:
3196 adapter
->curr_iface_comb
.p2p_intf
--;
3199 mwifiex_dbg(adapter
, ERROR
,
3200 "del_virtual_intf: type not supported\n");
3204 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3206 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
3207 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
3208 kfree(priv
->hist_data
);
3212 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
3215 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
3218 int j
, k
, valid_byte_cnt
= 0;
3219 bool dont_care_byte
= false;
3221 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
3222 for (k
= 0; k
< 8; k
++) {
3223 if (pat
->mask
[j
] & 1 << k
) {
3224 memcpy(byte_seq
+ valid_byte_cnt
,
3225 &pat
->pattern
[j
* 8 + k
], 1);
3231 dont_care_byte
= true;
3234 /* wildcard bytes record as the offset
3235 * before the valid byte
3237 if (!valid_byte_cnt
&& !dont_care_byte
)
3240 if (valid_byte_cnt
> max_byte_seq
)
3245 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
3251 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
3252 struct mwifiex_mef_entry
*mef_entry
)
3254 int i
, filt_num
= 0, num_ipv4
= 0;
3255 struct in_device
*in_dev
;
3256 struct in_ifaddr
*ifa
;
3257 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
3258 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3260 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3261 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
3263 /* Enable ARP offload feature */
3264 memset(ips
, 0, sizeof(ips
));
3265 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
3266 if (adapter
->priv
[i
]->netdev
) {
3267 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
3270 ifa
= rtnl_dereference(in_dev
->ifa_list
);
3271 if (!ifa
|| !ifa
->ifa_local
)
3273 ips
[i
] = ifa
->ifa_local
;
3278 for (i
= 0; i
< num_ipv4
; i
++) {
3281 mef_entry
->filter
[filt_num
].repeat
= 1;
3282 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
3283 (u8
*)&ips
[i
], sizeof(ips
[i
]));
3284 mef_entry
->filter
[filt_num
].
3285 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3287 mef_entry
->filter
[filt_num
].offset
= 46;
3288 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3290 mef_entry
->filter
[filt_num
].filt_action
=
3296 mef_entry
->filter
[filt_num
].repeat
= 1;
3297 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
3298 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
3299 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
3300 mef_entry
->filter
[filt_num
].offset
= 20;
3301 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3302 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3305 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
3306 struct mwifiex_ds_mef_cfg
*mef_cfg
,
3307 struct mwifiex_mef_entry
*mef_entry
,
3308 struct cfg80211_wowlan
*wowlan
)
3310 int i
, filt_num
= 0, ret
= 0;
3311 bool first_pat
= true;
3312 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
3313 static const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3314 static const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3316 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3317 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
3319 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
3320 memset(byte_seq
, 0, sizeof(byte_seq
));
3321 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
3323 MWIFIEX_MEF_MAX_BYTESEQ
)) {
3324 mwifiex_dbg(priv
->adapter
, ERROR
,
3325 "Pattern not supported\n");
3329 if (!wowlan
->patterns
[i
].pkt_offset
) {
3330 if (!(byte_seq
[0] & 0x01) &&
3331 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3332 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3334 } else if (is_broadcast_ether_addr(byte_seq
)) {
3335 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3337 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3338 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3339 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3340 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3341 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3345 mef_entry
->filter
[filt_num
].repeat
= 1;
3346 mef_entry
->filter
[filt_num
].offset
=
3347 wowlan
->patterns
[i
].pkt_offset
;
3348 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3350 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3354 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on patterns\n");
3356 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3362 if (wowlan
->magic_pkt
) {
3363 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3364 mef_entry
->filter
[filt_num
].repeat
= 16;
3365 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3367 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3369 mef_entry
->filter
[filt_num
].offset
= 28;
3370 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3372 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3375 mef_entry
->filter
[filt_num
].repeat
= 16;
3376 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3378 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3380 mef_entry
->filter
[filt_num
].offset
= 56;
3381 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3382 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3383 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on magic packet\n");
3388 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3389 struct cfg80211_wowlan
*wowlan
)
3391 int ret
= 0, num_entries
= 1;
3392 struct mwifiex_ds_mef_cfg mef_cfg
;
3393 struct mwifiex_mef_entry
*mef_entry
;
3395 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3398 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3402 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3403 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3404 MWIFIEX_CRITERIA_UNICAST
;
3405 mef_cfg
.num_entries
= num_entries
;
3406 mef_cfg
.mef_entry
= mef_entry
;
3408 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3410 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3411 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3412 &mef_entry
[1], wowlan
);
3417 if (!mef_cfg
.criteria
)
3418 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3419 MWIFIEX_CRITERIA_UNICAST
|
3420 MWIFIEX_CRITERIA_MULTICAST
;
3422 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3423 HostCmd_ACT_GEN_SET
, 0,
3431 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3432 struct cfg80211_wowlan
*wowlan
)
3434 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3435 struct mwifiex_ds_hs_cfg hs_cfg
;
3436 int i
, ret
= 0, retry_num
= 10;
3437 struct mwifiex_private
*priv
;
3438 struct mwifiex_private
*sta_priv
=
3439 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3441 sta_priv
->scan_aborting
= true;
3442 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3443 priv
= adapter
->priv
[i
];
3444 mwifiex_abort_cac(priv
);
3447 mwifiex_cancel_all_pending_cmd(adapter
);
3449 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3450 priv
= adapter
->priv
[i
];
3451 if (priv
&& priv
->netdev
)
3452 netif_device_detach(priv
->netdev
);
3455 for (i
= 0; i
< retry_num
; i
++) {
3456 if (!mwifiex_wmm_lists_empty(adapter
) ||
3457 !mwifiex_bypass_txlist_empty(adapter
) ||
3458 !skb_queue_empty(&adapter
->tx_data_q
))
3459 usleep_range(10000, 15000);
3465 mwifiex_dbg(adapter
, ERROR
,
3466 "None of the WOWLAN triggers enabled\n");
3471 if (!sta_priv
->media_connected
&& !wowlan
->nd_config
) {
3472 mwifiex_dbg(adapter
, ERROR
,
3473 "Can not configure WOWLAN in disconnected state\n");
3478 ret
= mwifiex_set_mef_filter(sta_priv
, wowlan
);
3480 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3484 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3485 hs_cfg
.conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
3487 if (wowlan
->nd_config
) {
3488 mwifiex_dbg(adapter
, INFO
, "Wake on net detect\n");
3489 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3490 mwifiex_cfg80211_sched_scan_start(wiphy
, sta_priv
->netdev
,
3494 if (wowlan
->disconnect
) {
3495 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3496 mwifiex_dbg(sta_priv
->adapter
, INFO
, "Wake on device disconnect\n");
3499 hs_cfg
.is_invoke_hostcmd
= false;
3500 hs_cfg
.gpio
= adapter
->hs_cfg
.gpio
;
3501 hs_cfg
.gap
= adapter
->hs_cfg
.gap
;
3502 ret
= mwifiex_set_hs_params(sta_priv
, HostCmd_ACT_GEN_SET
,
3503 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3505 mwifiex_dbg(adapter
, ERROR
, "Failed to set HS params\n");
3508 sta_priv
->scan_aborting
= false;
3512 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3514 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3515 struct mwifiex_private
*priv
;
3516 struct mwifiex_ds_wakeup_reason wakeup_reason
;
3517 struct cfg80211_wowlan_wakeup wakeup_report
;
3519 bool report_wakeup_reason
= true;
3521 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3522 priv
= adapter
->priv
[i
];
3523 if (priv
&& priv
->netdev
)
3524 netif_device_attach(priv
->netdev
);
3527 if (!wiphy
->wowlan_config
)
3530 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3531 mwifiex_get_wakeup_reason(priv
, HostCmd_ACT_GEN_GET
, MWIFIEX_SYNC_CMD
,
3533 memset(&wakeup_report
, 0, sizeof(struct cfg80211_wowlan_wakeup
));
3535 wakeup_report
.pattern_idx
= -1;
3537 switch (wakeup_reason
.hs_wakeup_reason
) {
3538 case NO_HSWAKEUP_REASON
:
3540 case BCAST_DATA_MATCHED
:
3542 case MCAST_DATA_MATCHED
:
3544 case UCAST_DATA_MATCHED
:
3546 case MASKTABLE_EVENT_MATCHED
:
3548 case NON_MASKABLE_EVENT_MATCHED
:
3549 if (wiphy
->wowlan_config
->disconnect
)
3550 wakeup_report
.disconnect
= true;
3551 if (wiphy
->wowlan_config
->nd_config
)
3552 wakeup_report
.net_detect
= adapter
->nd_info
;
3554 case NON_MASKABLE_CONDITION_MATCHED
:
3556 case MAGIC_PATTERN_MATCHED
:
3557 if (wiphy
->wowlan_config
->magic_pkt
)
3558 wakeup_report
.magic_pkt
= true;
3559 if (wiphy
->wowlan_config
->n_patterns
)
3560 wakeup_report
.pattern_idx
= 1;
3562 case GTK_REKEY_FAILURE
:
3563 if (wiphy
->wowlan_config
->gtk_rekey_failure
)
3564 wakeup_report
.gtk_rekey_failure
= true;
3567 report_wakeup_reason
= false;
3571 if (report_wakeup_reason
)
3572 cfg80211_report_wowlan_wakeup(&priv
->wdev
, &wakeup_report
,
3576 if (adapter
->nd_info
) {
3577 for (i
= 0 ; i
< adapter
->nd_info
->n_matches
; i
++)
3578 kfree(adapter
->nd_info
->matches
[i
]);
3579 kfree(adapter
->nd_info
);
3580 adapter
->nd_info
= NULL
;
3586 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3589 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3591 device_set_wakeup_enable(adapter
->dev
, enabled
);
3594 static int mwifiex_set_rekey_data(struct wiphy
*wiphy
, struct net_device
*dev
,
3595 struct cfg80211_gtk_rekey_data
*data
)
3597 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3599 if (!ISSUPP_FIRMWARE_SUPPLICANT(priv
->adapter
->fw_cap_info
))
3602 return mwifiex_send_cmd(priv
, HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG
,
3603 HostCmd_ACT_GEN_SET
, 0, data
, true);
3608 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3610 static const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3611 static const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3612 static const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3614 if ((byte_seq
[0] & 0x01) &&
3615 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3616 return PACKET_TYPE_UNICAST
;
3617 else if (!memcmp(byte_seq
, bc_mac
, 4))
3618 return PACKET_TYPE_BROADCAST
;
3619 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3620 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3621 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3622 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3623 return PACKET_TYPE_MULTICAST
;
3629 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3630 struct cfg80211_coalesce_rules
*crule
,
3631 struct mwifiex_coalesce_rule
*mrule
)
3633 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3634 struct filt_field_param
*param
;
3637 mrule
->max_coalescing_delay
= crule
->delay
;
3639 param
= mrule
->params
;
3641 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3642 memset(byte_seq
, 0, sizeof(byte_seq
));
3643 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3645 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3646 mwifiex_dbg(priv
->adapter
, ERROR
,
3647 "Pattern not supported\n");
3651 if (!crule
->patterns
[i
].pkt_offset
) {
3654 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3655 if (pkt_type
&& mrule
->pkt_type
) {
3656 mwifiex_dbg(priv
->adapter
, ERROR
,
3657 "Multiple packet types not allowed\n");
3659 } else if (pkt_type
) {
3660 mrule
->pkt_type
= pkt_type
;
3665 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3666 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3668 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3670 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3671 memcpy(param
->operand_byte_stream
, byte_seq
,
3672 param
->operand_len
);
3673 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3676 mrule
->num_of_fields
++;
3679 if (!mrule
->pkt_type
) {
3680 mwifiex_dbg(priv
->adapter
, ERROR
,
3681 "Packet type can not be determined\n");
3688 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3689 struct cfg80211_coalesce
*coalesce
)
3691 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3693 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3694 struct mwifiex_private
*priv
=
3695 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3697 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3699 mwifiex_dbg(adapter
, WARN
,
3700 "Disable coalesce and reset all previous rules\n");
3701 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3702 HostCmd_ACT_GEN_SET
, 0,
3703 &coalesce_cfg
, true);
3706 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3707 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3708 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3709 &coalesce_cfg
.rule
[i
]);
3711 mwifiex_dbg(adapter
, ERROR
,
3712 "Recheck the patterns provided for rule %d\n",
3718 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3719 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3722 /* cfg80211 ops handler for tdls_mgmt.
3723 * Function prepares TDLS action frame packets and forwards them to FW
3726 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3727 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3728 u16 status_code
, u32 peer_capability
,
3729 bool initiator
, const u8
*extra_ies
,
3730 size_t extra_ies_len
)
3732 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3735 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3738 /* make sure we are in station mode and connected */
3739 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3742 switch (action_code
) {
3743 case WLAN_TDLS_SETUP_REQUEST
:
3744 mwifiex_dbg(priv
->adapter
, MSG
,
3745 "Send TDLS Setup Request to %pM status_code=%d\n",
3747 mwifiex_add_auto_tdls_peer(priv
, peer
);
3748 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3749 dialog_token
, status_code
,
3750 extra_ies
, extra_ies_len
);
3752 case WLAN_TDLS_SETUP_RESPONSE
:
3753 mwifiex_add_auto_tdls_peer(priv
, peer
);
3754 mwifiex_dbg(priv
->adapter
, MSG
,
3755 "Send TDLS Setup Response to %pM status_code=%d\n",
3757 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3758 dialog_token
, status_code
,
3759 extra_ies
, extra_ies_len
);
3761 case WLAN_TDLS_SETUP_CONFIRM
:
3762 mwifiex_dbg(priv
->adapter
, MSG
,
3763 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3765 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3766 dialog_token
, status_code
,
3767 extra_ies
, extra_ies_len
);
3769 case WLAN_TDLS_TEARDOWN
:
3770 mwifiex_dbg(priv
->adapter
, MSG
,
3771 "Send TDLS Tear down to %pM\n", peer
);
3772 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3773 dialog_token
, status_code
,
3774 extra_ies
, extra_ies_len
);
3776 case WLAN_TDLS_DISCOVERY_REQUEST
:
3777 mwifiex_dbg(priv
->adapter
, MSG
,
3778 "Send TDLS Discovery Request to %pM\n", peer
);
3779 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3780 dialog_token
, status_code
,
3781 extra_ies
, extra_ies_len
);
3783 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3784 mwifiex_dbg(priv
->adapter
, MSG
,
3785 "Send TDLS Discovery Response to %pM\n", peer
);
3786 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3787 dialog_token
, status_code
,
3788 extra_ies
, extra_ies_len
);
3791 mwifiex_dbg(priv
->adapter
, ERROR
,
3792 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3801 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3802 const u8
*peer
, enum nl80211_tdls_operation action
)
3804 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3806 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3807 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3810 /* make sure we are in station mode and connected */
3811 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3814 mwifiex_dbg(priv
->adapter
, MSG
,
3815 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3818 case NL80211_TDLS_ENABLE_LINK
:
3819 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3821 case NL80211_TDLS_DISABLE_LINK
:
3822 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3824 case NL80211_TDLS_TEARDOWN
:
3825 /* shouldn't happen!*/
3826 mwifiex_dbg(priv
->adapter
, ERROR
,
3827 "tdls_oper: teardown from driver not supported\n");
3829 case NL80211_TDLS_SETUP
:
3830 /* shouldn't happen!*/
3831 mwifiex_dbg(priv
->adapter
, ERROR
,
3832 "tdls_oper: setup from driver not supported\n");
3834 case NL80211_TDLS_DISCOVERY_REQ
:
3835 /* shouldn't happen!*/
3836 mwifiex_dbg(priv
->adapter
, ERROR
,
3837 "tdls_oper: discovery from driver not supported\n");
3840 mwifiex_dbg(priv
->adapter
, ERROR
,
3841 "tdls_oper: operation not supported\n");
3845 return mwifiex_tdls_oper(priv
, peer
, action
);
3849 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3850 const u8
*addr
, u8 oper_class
,
3851 struct cfg80211_chan_def
*chandef
)
3853 struct mwifiex_sta_node
*sta_ptr
;
3855 u8 second_chan_offset
, band
;
3856 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3858 spin_lock_bh(&priv
->sta_list_spinlock
);
3859 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3861 spin_unlock_bh(&priv
->sta_list_spinlock
);
3862 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3867 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3868 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3869 spin_unlock_bh(&priv
->sta_list_spinlock
);
3870 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3874 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3875 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3876 spin_unlock_bh(&priv
->sta_list_spinlock
);
3877 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3880 spin_unlock_bh(&priv
->sta_list_spinlock
);
3882 chan
= chandef
->chan
->hw_value
;
3883 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3884 band
= chandef
->chan
->band
;
3885 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3891 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3892 struct net_device
*dev
,
3895 struct mwifiex_sta_node
*sta_ptr
;
3896 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3898 spin_lock_bh(&priv
->sta_list_spinlock
);
3899 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3901 spin_unlock_bh(&priv
->sta_list_spinlock
);
3902 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3904 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3905 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3906 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3907 spin_unlock_bh(&priv
->sta_list_spinlock
);
3908 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3911 spin_unlock_bh(&priv
->sta_list_spinlock
);
3912 mwifiex_stop_tdls_cs(priv
, addr
);
3917 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3918 const u8
*mac
, struct station_parameters
*params
)
3920 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3922 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3925 /* make sure we are in station mode and connected */
3926 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3929 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3933 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3934 struct cfg80211_csa_settings
*params
)
3936 struct ieee_types_header
*chsw_ie
;
3937 struct ieee80211_channel_sw_ie
*channel_sw
;
3939 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3941 if (priv
->adapter
->scan_processing
) {
3942 mwifiex_dbg(priv
->adapter
, ERROR
,
3943 "radar detection: scan in process...\n");
3947 if (priv
->wdev
.cac_started
)
3950 if (cfg80211_chandef_identical(¶ms
->chandef
,
3951 &priv
->dfs_chandef
))
3954 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3955 params
->beacon_csa
.tail
,
3956 params
->beacon_csa
.tail_len
);
3958 mwifiex_dbg(priv
->adapter
, ERROR
,
3959 "Could not parse channel switch announcement IE\n");
3963 channel_sw
= (void *)(chsw_ie
+ 1);
3964 if (channel_sw
->mode
) {
3965 if (netif_carrier_ok(priv
->netdev
))
3966 netif_carrier_off(priv
->netdev
);
3967 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3970 if (mwifiex_del_mgmt_ies(priv
))
3971 mwifiex_dbg(priv
->adapter
, ERROR
,
3972 "Failed to delete mgmt IEs!\n");
3974 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3975 mwifiex_dbg(priv
->adapter
, ERROR
,
3976 "%s: setting mgmt ies failed\n", __func__
);
3980 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3981 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3982 sizeof(priv
->beacon_after
));
3984 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3985 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3986 msecs_to_jiffies(chsw_msec
));
3990 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3991 struct wireless_dev
*wdev
,
3992 struct cfg80211_chan_def
*chandef
)
3994 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3995 struct mwifiex_bssdescriptor
*curr_bss
;
3996 struct ieee80211_channel
*chan
;
3997 enum nl80211_channel_type chan_type
;
3998 enum nl80211_band band
;
4002 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
4003 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
4004 *chandef
= priv
->bss_chandef
;
4006 } else if (priv
->media_connected
) {
4007 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
4008 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
4009 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
4010 chan
= ieee80211_get_channel(wiphy
, freq
);
4012 if (priv
->ht_param_present
) {
4013 chan_type
= mwifiex_get_chan_type(priv
);
4014 cfg80211_chandef_create(chandef
, chan
, chan_type
);
4016 cfg80211_chandef_create(chandef
, chan
,
4017 NL80211_CHAN_NO_HT
);
4025 #ifdef CONFIG_NL80211_TESTMODE
4027 enum mwifiex_tm_attr
{
4028 __MWIFIEX_TM_ATTR_INVALID
= 0,
4029 MWIFIEX_TM_ATTR_CMD
= 1,
4030 MWIFIEX_TM_ATTR_DATA
= 2,
4033 __MWIFIEX_TM_ATTR_AFTER_LAST
,
4034 MWIFIEX_TM_ATTR_MAX
= __MWIFIEX_TM_ATTR_AFTER_LAST
- 1,
4037 static const struct nla_policy mwifiex_tm_policy
[MWIFIEX_TM_ATTR_MAX
+ 1] = {
4038 [MWIFIEX_TM_ATTR_CMD
] = { .type
= NLA_U32
},
4039 [MWIFIEX_TM_ATTR_DATA
] = { .type
= NLA_BINARY
,
4040 .len
= MWIFIEX_SIZE_OF_CMD_BUFFER
},
4043 enum mwifiex_tm_command
{
4044 MWIFIEX_TM_CMD_HOSTCMD
= 0,
4047 static int mwifiex_tm_cmd(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
4048 void *data
, int len
)
4050 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
4051 struct mwifiex_ds_misc_cmd
*hostcmd
;
4052 struct nlattr
*tb
[MWIFIEX_TM_ATTR_MAX
+ 1];
4053 struct sk_buff
*skb
;
4059 err
= nla_parse_deprecated(tb
, MWIFIEX_TM_ATTR_MAX
, data
, len
,
4060 mwifiex_tm_policy
, NULL
);
4064 if (!tb
[MWIFIEX_TM_ATTR_CMD
])
4067 switch (nla_get_u32(tb
[MWIFIEX_TM_ATTR_CMD
])) {
4068 case MWIFIEX_TM_CMD_HOSTCMD
:
4069 if (!tb
[MWIFIEX_TM_ATTR_DATA
])
4072 hostcmd
= kzalloc(sizeof(*hostcmd
), GFP_KERNEL
);
4076 hostcmd
->len
= nla_len(tb
[MWIFIEX_TM_ATTR_DATA
]);
4077 memcpy(hostcmd
->cmd
, nla_data(tb
[MWIFIEX_TM_ATTR_DATA
]),
4080 if (mwifiex_send_cmd(priv
, 0, 0, 0, hostcmd
, true)) {
4081 dev_err(priv
->adapter
->dev
, "Failed to process hostcmd\n");
4086 /* process hostcmd response*/
4087 skb
= cfg80211_testmode_alloc_reply_skb(wiphy
, hostcmd
->len
);
4092 err
= nla_put(skb
, MWIFIEX_TM_ATTR_DATA
,
4093 hostcmd
->len
, hostcmd
->cmd
);
4100 err
= cfg80211_testmode_reply(skb
);
4110 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
4111 struct net_device
*dev
,
4112 struct cfg80211_chan_def
*chandef
,
4115 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4116 struct mwifiex_radar_params radar_params
;
4118 if (priv
->adapter
->scan_processing
) {
4119 mwifiex_dbg(priv
->adapter
, ERROR
,
4120 "radar detection: scan already in process...\n");
4124 if (!mwifiex_is_11h_active(priv
)) {
4125 mwifiex_dbg(priv
->adapter
, INFO
,
4126 "Enable 11h extensions in FW\n");
4127 if (mwifiex_11h_activate(priv
, true)) {
4128 mwifiex_dbg(priv
->adapter
, ERROR
,
4129 "Failed to activate 11h extensions!!");
4132 priv
->state_11h
.is_11h_active
= true;
4135 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
4136 radar_params
.chandef
= chandef
;
4137 radar_params
.cac_time_ms
= cac_time_ms
;
4139 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
4141 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
4142 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
4145 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
4146 msecs_to_jiffies(cac_time_ms
));
4151 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
4153 struct station_parameters
*params
)
4156 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4158 /* we support change_station handler only for TDLS peers*/
4159 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
4162 /* make sure we are in station mode and connected */
4163 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
4166 priv
->sta_params
= params
;
4168 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
4169 priv
->sta_params
= NULL
;
4174 /* station cfg80211 operations */
4175 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
4176 .add_virtual_intf
= mwifiex_add_virtual_intf
,
4177 .del_virtual_intf
= mwifiex_del_virtual_intf
,
4178 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
4179 .scan
= mwifiex_cfg80211_scan
,
4180 .connect
= mwifiex_cfg80211_connect
,
4181 .disconnect
= mwifiex_cfg80211_disconnect
,
4182 .get_station
= mwifiex_cfg80211_get_station
,
4183 .dump_station
= mwifiex_cfg80211_dump_station
,
4184 .dump_survey
= mwifiex_cfg80211_dump_survey
,
4185 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
4186 .join_ibss
= mwifiex_cfg80211_join_ibss
,
4187 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
4188 .add_key
= mwifiex_cfg80211_add_key
,
4189 .del_key
= mwifiex_cfg80211_del_key
,
4190 .set_default_mgmt_key
= mwifiex_cfg80211_set_default_mgmt_key
,
4191 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
4192 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
4193 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
4194 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
4195 .set_default_key
= mwifiex_cfg80211_set_default_key
,
4196 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
4197 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
4198 .get_tx_power
= mwifiex_cfg80211_get_tx_power
,
4199 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
4200 .start_ap
= mwifiex_cfg80211_start_ap
,
4201 .stop_ap
= mwifiex_cfg80211_stop_ap
,
4202 .change_beacon
= mwifiex_cfg80211_change_beacon
,
4203 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
4204 .set_antenna
= mwifiex_cfg80211_set_antenna
,
4205 .get_antenna
= mwifiex_cfg80211_get_antenna
,
4206 .del_station
= mwifiex_cfg80211_del_station
,
4207 .sched_scan_start
= mwifiex_cfg80211_sched_scan_start
,
4208 .sched_scan_stop
= mwifiex_cfg80211_sched_scan_stop
,
4210 .suspend
= mwifiex_cfg80211_suspend
,
4211 .resume
= mwifiex_cfg80211_resume
,
4212 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
4213 .set_rekey_data
= mwifiex_set_rekey_data
,
4215 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
4216 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
4217 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
4218 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
4219 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
4220 .add_station
= mwifiex_cfg80211_add_station
,
4221 .change_station
= mwifiex_cfg80211_change_station
,
4222 CFG80211_TESTMODE_CMD(mwifiex_tm_cmd
)
4223 .get_channel
= mwifiex_cfg80211_get_channel
,
4224 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
4225 .channel_switch
= mwifiex_cfg80211_channel_switch
,
4229 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
4230 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
4231 WIPHY_WOWLAN_NET_DETECT
| WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
4232 WIPHY_WOWLAN_GTK_REKEY_FAILURE
,
4233 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
4234 .pattern_min_len
= 1,
4235 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4236 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4237 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
4240 static const struct wiphy_wowlan_support mwifiex_wowlan_support_no_gtk
= {
4241 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
4242 WIPHY_WOWLAN_NET_DETECT
,
4243 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
4244 .pattern_min_len
= 1,
4245 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4246 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4247 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
4251 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
4253 if (!alpha2
|| strlen(alpha2
) != 2)
4256 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
4262 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
4263 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
4264 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
4265 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
4266 .pattern_min_len
= 1,
4267 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4268 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4271 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
4273 u32 n_channels_bg
, n_channels_a
= 0;
4275 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
4277 if (adapter
->config_bands
& BAND_A
)
4278 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
4280 /* allocate twice the number total channels, since the driver issues an
4281 * additional active scan request for hidden SSIDs on passive channels.
4283 adapter
->num_in_chan_stats
= 2 * (n_channels_bg
+ n_channels_a
);
4284 adapter
->chan_stats
= vmalloc(array_size(sizeof(*adapter
->chan_stats
),
4285 adapter
->num_in_chan_stats
));
4287 if (!adapter
->chan_stats
)
4294 * This function registers the device with CFG802.11 subsystem.
4296 * The function creates the wireless device/wiphy, populates it with
4297 * default parameters and handler function pointers, and finally
4298 * registers the device.
4301 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
4305 struct wiphy
*wiphy
;
4306 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
4310 /* create a new wiphy for use with cfg80211 */
4311 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
4312 sizeof(struct mwifiex_adapter
*));
4314 mwifiex_dbg(adapter
, ERROR
,
4315 "%s: creating new wiphy\n", __func__
);
4318 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4319 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4320 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
4321 wiphy
->max_remain_on_channel_duration
= 5000;
4322 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
4323 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
4324 BIT(NL80211_IFTYPE_P2P_GO
) |
4325 BIT(NL80211_IFTYPE_AP
);
4327 if (ISSUPP_ADHOC_ENABLED(adapter
->fw_cap_info
))
4328 wiphy
->interface_modes
|= BIT(NL80211_IFTYPE_ADHOC
);
4330 wiphy
->bands
[NL80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
4331 if (adapter
->config_bands
& BAND_A
)
4332 wiphy
->bands
[NL80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
4334 wiphy
->bands
[NL80211_BAND_5GHZ
] = NULL
;
4336 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
4337 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
4338 else if (adapter
->is_hw_11ac_capable
)
4339 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
4341 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
4342 wiphy
->n_iface_combinations
= 1;
4344 /* Initialize cipher suits */
4345 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
4346 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
4348 if (adapter
->regd
) {
4349 wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
4350 REGULATORY_DISABLE_BEACON_HINTS
|
4351 REGULATORY_COUNTRY_IE_IGNORE
;
4352 wiphy_apply_custom_regulatory(wiphy
, adapter
->regd
);
4355 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
4356 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
4357 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
4358 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
4359 WIPHY_FLAG_AP_UAPSD
|
4360 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
4361 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
4362 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
4364 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4365 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
4366 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
4369 if (ISSUPP_FIRMWARE_SUPPLICANT(priv
->adapter
->fw_cap_info
))
4370 wiphy
->wowlan
= &mwifiex_wowlan_support
;
4372 wiphy
->wowlan
= &mwifiex_wowlan_support_no_gtk
;
4375 wiphy
->coalesce
= &mwifiex_coalesce_support
;
4377 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
4378 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
4379 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
4381 wiphy
->max_sched_scan_reqs
= 1;
4382 wiphy
->max_sched_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4383 wiphy
->max_sched_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4384 wiphy
->max_match_sets
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4386 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
4387 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
4389 wiphy
->features
|= NL80211_FEATURE_INACTIVITY_TIMER
|
4390 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
4391 NL80211_FEATURE_NEED_OBSS_SCAN
;
4393 if (ISSUPP_ADHOC_ENABLED(adapter
->fw_cap_info
))
4394 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
;
4396 if (ISSUPP_RANDOM_MAC(adapter
->fw_cap_info
))
4397 wiphy
->features
|= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
|
4398 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
|
4399 NL80211_FEATURE_ND_RANDOM_MAC_ADDR
;
4401 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4402 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
4404 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
4405 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
4407 /* Reserve space for mwifiex specific private data for BSS */
4408 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
4410 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
4412 /* Set struct mwifiex_adapter pointer in wiphy_priv */
4413 wdev_priv
= wiphy_priv(wiphy
);
4414 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
4416 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
4418 ret
= wiphy_register(wiphy
);
4420 mwifiex_dbg(adapter
, ERROR
,
4421 "%s: wiphy_register failed: %d\n", __func__
, ret
);
4426 if (!adapter
->regd
) {
4427 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
4428 mwifiex_dbg(adapter
, INFO
,
4429 "driver hint alpha2: %2.2s\n", reg_alpha2
);
4430 regulatory_hint(wiphy
, reg_alpha2
);
4432 if (adapter
->region_code
== 0x00) {
4433 mwifiex_dbg(adapter
, WARN
,
4434 "Ignore world regulatory domain\n");
4436 wiphy
->regulatory_flags
|=
4437 REGULATORY_DISABLE_BEACON_HINTS
|
4438 REGULATORY_COUNTRY_IE_IGNORE
;
4440 mwifiex_11d_code_2_region(
4441 adapter
->region_code
);
4443 regulatory_hint(wiphy
, country_code
))
4444 mwifiex_dbg(priv
->adapter
, ERROR
,
4445 "regulatory_hint() failed\n");
4450 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4451 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
4452 wiphy
->frag_threshold
= thr
;
4453 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4454 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
4455 wiphy
->rts_threshold
= thr
;
4456 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4457 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
4458 wiphy
->retry_short
= (u8
) retry
;
4459 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4460 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
4461 wiphy
->retry_long
= (u8
) retry
;
4463 adapter
->wiphy
= wiphy
;