2 * Marvell Wireless LAN device driver: CFG80211
4 * Copyright (C) 2011-2014, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
25 static char *reg_alpha2
;
26 module_param(reg_alpha2
, charp
, 0);
28 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits
[] = {
30 .max
= 3, .types
= BIT(NL80211_IFTYPE_STATION
) |
31 BIT(NL80211_IFTYPE_P2P_GO
) |
32 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
33 BIT(NL80211_IFTYPE_AP
),
37 static const struct ieee80211_iface_combination
38 mwifiex_iface_comb_ap_sta
= {
39 .limits
= mwifiex_ap_sta_limits
,
40 .num_different_channels
= 1,
41 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
42 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
43 .beacon_int_infra_match
= true,
44 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
45 BIT(NL80211_CHAN_WIDTH_20
) |
46 BIT(NL80211_CHAN_WIDTH_40
),
49 static const struct ieee80211_iface_combination
50 mwifiex_iface_comb_ap_sta_vht
= {
51 .limits
= mwifiex_ap_sta_limits
,
52 .num_different_channels
= 1,
53 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
54 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
55 .beacon_int_infra_match
= true,
56 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
57 BIT(NL80211_CHAN_WIDTH_20
) |
58 BIT(NL80211_CHAN_WIDTH_40
) |
59 BIT(NL80211_CHAN_WIDTH_80
),
63 ieee80211_iface_combination mwifiex_iface_comb_ap_sta_drcs
= {
64 .limits
= mwifiex_ap_sta_limits
,
65 .num_different_channels
= 2,
66 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
67 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
68 .beacon_int_infra_match
= true,
72 * This function maps the nl802.11 channel type into driver channel type.
74 * The mapping is as follows -
75 * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE
76 * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE
77 * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE
78 * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW
79 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE
81 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
)
84 case NL80211_CHAN_NO_HT
:
85 case NL80211_CHAN_HT20
:
86 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
87 case NL80211_CHAN_HT40PLUS
:
88 return IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
89 case NL80211_CHAN_HT40MINUS
:
90 return IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
92 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
96 /* This function maps IEEE HT secondary channel type to NL80211 channel type
98 u8
mwifiex_sec_chan_offset_to_chan_type(u8 second_chan_offset
)
100 switch (second_chan_offset
) {
101 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
102 return NL80211_CHAN_HT20
;
103 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
104 return NL80211_CHAN_HT40PLUS
;
105 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
106 return NL80211_CHAN_HT40MINUS
;
108 return NL80211_CHAN_HT20
;
113 * This function checks whether WEP is set.
116 mwifiex_is_alg_wep(u32 cipher
)
119 case WLAN_CIPHER_SUITE_WEP40
:
120 case WLAN_CIPHER_SUITE_WEP104
:
130 * This function retrieves the private structure from kernel wiphy structure.
132 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
134 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
138 * CFG802.11 operation handler to delete a network key.
141 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
142 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
144 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
145 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
146 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
148 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
149 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
153 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
158 * This function forms an skb for management frame.
161 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
163 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
165 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
167 pkt_len
= len
+ ETH_ALEN
;
169 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
170 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
171 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
173 memcpy(skb_push(skb
, sizeof(tx_control
)),
174 &tx_control
, sizeof(tx_control
));
176 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
178 /* Add packet data and address4 */
179 memcpy(skb_put(skb
, sizeof(struct ieee80211_hdr_3addr
)), buf
,
180 sizeof(struct ieee80211_hdr_3addr
));
181 memcpy(skb_put(skb
, ETH_ALEN
), addr
, ETH_ALEN
);
182 memcpy(skb_put(skb
, len
- sizeof(struct ieee80211_hdr_3addr
)),
183 buf
+ sizeof(struct ieee80211_hdr_3addr
),
184 len
- sizeof(struct ieee80211_hdr_3addr
));
186 skb
->priority
= LOW_PRIO_TID
;
187 __net_timestamp(skb
);
193 * CFG802.11 operation handler to transmit a management frame.
196 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
197 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
199 const u8
*buf
= params
->buf
;
200 size_t len
= params
->len
;
203 const struct ieee80211_mgmt
*mgmt
;
204 struct mwifiex_txinfo
*tx_info
;
205 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
208 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
212 mgmt
= (const struct ieee80211_mgmt
*)buf
;
213 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
214 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
215 /* Since we support offload probe resp, we need to skip probe
216 * resp in AP or GO mode */
217 mwifiex_dbg(priv
->adapter
, INFO
,
218 "info: skip to send probe resp in AP or GO mode\n");
222 pkt_len
= len
+ ETH_ALEN
;
223 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
224 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
225 pkt_len
+ sizeof(pkt_len
));
228 mwifiex_dbg(priv
->adapter
, ERROR
,
229 "allocate skb failed for management frame\n");
233 tx_info
= MWIFIEX_SKB_TXCB(skb
);
234 memset(tx_info
, 0, sizeof(*tx_info
));
235 tx_info
->bss_num
= priv
->bss_num
;
236 tx_info
->bss_type
= priv
->bss_type
;
237 tx_info
->pkt_len
= pkt_len
;
239 mwifiex_form_mgmt_frame(skb
, buf
, len
);
240 *cookie
= prandom_u32() | 1;
242 if (ieee80211_is_action(mgmt
->frame_control
))
243 skb
= mwifiex_clone_skb_for_tx_status(priv
,
245 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
247 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
250 mwifiex_queue_tx_pkt(priv
, skb
);
252 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
257 * CFG802.11 operation handler to register a mgmt frame.
260 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
261 struct wireless_dev
*wdev
,
262 u16 frame_type
, bool reg
)
264 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
268 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
270 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
272 if (mask
!= priv
->mgmt_frame_mask
) {
273 priv
->mgmt_frame_mask
= mask
;
274 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
275 HostCmd_ACT_GEN_SET
, 0,
276 &priv
->mgmt_frame_mask
, false);
277 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
282 * CFG802.11 operation handler to remain on channel.
285 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
286 struct wireless_dev
*wdev
,
287 struct ieee80211_channel
*chan
,
288 unsigned int duration
, u64
*cookie
)
290 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
293 if (!chan
|| !cookie
) {
294 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
298 if (priv
->roc_cfg
.cookie
) {
299 mwifiex_dbg(priv
->adapter
, INFO
,
300 "info: ongoing ROC, cookie = 0x%llx\n",
301 priv
->roc_cfg
.cookie
);
305 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
309 *cookie
= prandom_u32() | 1;
310 priv
->roc_cfg
.cookie
= *cookie
;
311 priv
->roc_cfg
.chan
= *chan
;
313 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
314 duration
, GFP_ATOMIC
);
316 mwifiex_dbg(priv
->adapter
, INFO
,
317 "info: ROC, cookie = 0x%llx\n", *cookie
);
324 * CFG802.11 operation handler to cancel remain on channel.
327 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
328 struct wireless_dev
*wdev
, u64 cookie
)
330 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
333 if (cookie
!= priv
->roc_cfg
.cookie
)
336 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
337 &priv
->roc_cfg
.chan
, 0);
340 cfg80211_remain_on_channel_expired(wdev
, cookie
,
344 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
346 mwifiex_dbg(priv
->adapter
, INFO
,
347 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
354 * CFG802.11 operation handler to set Tx power.
357 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
358 struct wireless_dev
*wdev
,
359 enum nl80211_tx_power_setting type
,
362 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
363 struct mwifiex_private
*priv
;
364 struct mwifiex_power_cfg power_cfg
;
365 int dbm
= MBM_TO_DBM(mbm
);
367 if (type
== NL80211_TX_POWER_FIXED
) {
368 power_cfg
.is_power_auto
= 0;
369 power_cfg
.power_level
= dbm
;
371 power_cfg
.is_power_auto
= 1;
374 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
376 return mwifiex_set_tx_power(priv
, &power_cfg
);
380 * CFG802.11 operation handler to get Tx power.
383 mwifiex_cfg80211_get_tx_power(struct wiphy
*wiphy
,
384 struct wireless_dev
*wdev
,
387 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
388 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
389 MWIFIEX_BSS_ROLE_ANY
);
390 int ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_RF_TX_PWR
,
391 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
396 /* tx_power_level is set in HostCmd_CMD_RF_TX_PWR command handler */
397 *dbm
= priv
->tx_power_level
;
403 * CFG802.11 operation handler to set Power Save option.
405 * The timeout value, if provided, is currently ignored.
408 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
409 struct net_device
*dev
,
410 bool enabled
, int timeout
)
412 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
416 mwifiex_dbg(priv
->adapter
, INFO
,
417 "info: ignore timeout value for IEEE Power Save\n");
421 return mwifiex_drv_set_power(priv
, &ps_mode
);
425 * CFG802.11 operation handler to set the default network key.
428 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
429 u8 key_index
, bool unicast
,
432 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
434 /* Return if WEP key not configured */
435 if (!priv
->sec_info
.wep_enabled
)
438 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
439 priv
->wep_key_curr_index
= key_index
;
440 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
442 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
450 * CFG802.11 operation handler to add a network key.
453 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
454 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
455 struct key_params
*params
)
457 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
458 struct mwifiex_wep_key
*wep_key
;
459 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
460 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
462 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
463 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
464 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
465 if (params
->key
&& params
->key_len
) {
466 wep_key
= &priv
->wep_key
[key_index
];
467 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
468 memcpy(wep_key
->key_material
, params
->key
,
470 wep_key
->key_index
= key_index
;
471 wep_key
->key_length
= params
->key_len
;
472 priv
->sec_info
.wep_enabled
= 1;
477 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
478 key_index
, peer_mac
, 0)) {
479 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
487 * This function sends domain information to the firmware.
489 * The following information are passed to the firmware -
491 * - Sub bands (first channel, number of channels, maximum Tx power)
493 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
495 u8 no_of_triplet
= 0;
496 struct ieee80211_country_ie_triplet
*t
;
497 u8 no_of_parsed_chan
= 0;
498 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
500 enum nl80211_band band
;
501 struct ieee80211_supported_band
*sband
;
502 struct ieee80211_channel
*ch
;
503 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
504 struct mwifiex_private
*priv
;
505 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
507 /* Set country code */
508 domain_info
->country_code
[0] = adapter
->country_code
[0];
509 domain_info
->country_code
[1] = adapter
->country_code
[1];
510 domain_info
->country_code
[2] = ' ';
512 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
513 if (!wiphy
->bands
[band
]) {
514 mwifiex_dbg(adapter
, ERROR
,
515 "11D: setting domain info in FW\n");
519 sband
= wiphy
->bands
[band
];
521 for (i
= 0; i
< sband
->n_channels
; i
++) {
522 ch
= &sband
->channels
[i
];
523 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
528 first_chan
= (u32
) ch
->hw_value
;
529 next_chan
= first_chan
;
530 max_pwr
= ch
->max_power
;
531 no_of_parsed_chan
= 1;
535 if (ch
->hw_value
== next_chan
+ 1 &&
536 ch
->max_power
== max_pwr
) {
540 t
= &domain_info
->triplet
[no_of_triplet
];
541 t
->chans
.first_channel
= first_chan
;
542 t
->chans
.num_channels
= no_of_parsed_chan
;
543 t
->chans
.max_power
= max_pwr
;
545 first_chan
= (u32
) ch
->hw_value
;
546 next_chan
= first_chan
;
547 max_pwr
= ch
->max_power
;
548 no_of_parsed_chan
= 1;
553 t
= &domain_info
->triplet
[no_of_triplet
];
554 t
->chans
.first_channel
= first_chan
;
555 t
->chans
.num_channels
= no_of_parsed_chan
;
556 t
->chans
.max_power
= max_pwr
;
560 domain_info
->no_of_triplet
= no_of_triplet
;
562 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
564 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
565 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
566 mwifiex_dbg(adapter
, INFO
,
567 "11D: setting domain info in FW\n");
575 * CFG802.11 regulatory domain callback function.
577 * This function is called when the regulatory domain is changed due to the
578 * following reasons -
580 * - Set by system core
582 * - Set bt Country IE
584 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
585 struct regulatory_request
*request
)
587 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
588 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
589 MWIFIEX_BSS_ROLE_ANY
);
590 mwifiex_dbg(adapter
, INFO
,
591 "info: cfg80211 regulatory domain callback for %c%c\n",
592 request
->alpha2
[0], request
->alpha2
[1]);
594 switch (request
->initiator
) {
595 case NL80211_REGDOM_SET_BY_DRIVER
:
596 case NL80211_REGDOM_SET_BY_CORE
:
597 case NL80211_REGDOM_SET_BY_USER
:
598 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
601 mwifiex_dbg(adapter
, ERROR
,
602 "unknown regdom initiator: %d\n",
607 /* Don't send world or same regdom info to firmware */
608 if (strncmp(request
->alpha2
, "00", 2) &&
609 strncmp(request
->alpha2
, adapter
->country_code
,
610 sizeof(request
->alpha2
))) {
611 memcpy(adapter
->country_code
, request
->alpha2
,
612 sizeof(request
->alpha2
));
613 mwifiex_send_domain_info_cmd_fw(wiphy
);
614 mwifiex_dnld_txpwr_table(priv
);
619 * This function sets the fragmentation threshold.
621 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
622 * and MWIFIEX_FRAG_MAX_VALUE.
625 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
627 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
628 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
629 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
631 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
632 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
637 * This function sets the RTS threshold.
639 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
640 * and MWIFIEX_RTS_MAX_VALUE.
643 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
645 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
646 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
648 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
649 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
654 * CFG802.11 operation handler to set wiphy parameters.
656 * This function can be used to set the RTS threshold and the
657 * Fragmentation threshold of the driver.
660 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
662 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
663 struct mwifiex_private
*priv
;
664 struct mwifiex_uap_bss_param
*bss_cfg
;
667 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
669 switch (priv
->bss_role
) {
670 case MWIFIEX_BSS_ROLE_UAP
:
671 if (priv
->bss_started
) {
672 mwifiex_dbg(adapter
, ERROR
,
673 "cannot change wiphy params when bss started");
677 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
681 mwifiex_set_sys_config_invalid_data(bss_cfg
);
683 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
684 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
685 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
686 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
687 if (changed
& WIPHY_PARAM_RETRY_LONG
)
688 bss_cfg
->retry_limit
= wiphy
->retry_long
;
690 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
692 UAP_BSS_PARAMS_I
, bss_cfg
,
697 mwifiex_dbg(adapter
, ERROR
,
698 "Failed to set wiphy phy params\n");
703 case MWIFIEX_BSS_ROLE_STA
:
704 if (priv
->media_connected
) {
705 mwifiex_dbg(adapter
, ERROR
,
706 "cannot change wiphy params when connected");
709 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
710 ret
= mwifiex_set_rts(priv
,
711 wiphy
->rts_threshold
);
715 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
716 ret
= mwifiex_set_frag(priv
,
717 wiphy
->frag_threshold
);
728 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
730 u16 mode
= P2P_MODE_DISABLE
;
732 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
733 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
740 * This function initializes the functionalities for P2P client.
741 * The P2P client initialization sequence is:
742 * disable -> device -> client
745 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
749 if (mwifiex_cfg80211_deinit_p2p(priv
))
752 mode
= P2P_MODE_DEVICE
;
753 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
754 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
757 mode
= P2P_MODE_CLIENT
;
758 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
759 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
766 * This function initializes the functionalities for P2P GO.
767 * The P2P GO initialization sequence is:
768 * disable -> device -> GO
771 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
775 if (mwifiex_cfg80211_deinit_p2p(priv
))
778 mode
= P2P_MODE_DEVICE
;
779 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
780 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
784 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
785 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
791 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
793 struct mwifiex_adapter
*adapter
= priv
->adapter
;
796 priv
->mgmt_frame_mask
= 0;
797 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
798 HostCmd_ACT_GEN_SET
, 0,
799 &priv
->mgmt_frame_mask
, false)) {
800 mwifiex_dbg(adapter
, ERROR
,
801 "could not unregister mgmt frame rx\n");
805 mwifiex_deauthenticate(priv
, NULL
);
807 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
808 adapter
->main_locked
= true;
809 if (adapter
->mwifiex_processing
) {
810 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
811 flush_workqueue(adapter
->workqueue
);
813 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
816 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
817 adapter
->rx_locked
= true;
818 if (adapter
->rx_processing
) {
819 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
820 flush_workqueue(adapter
->rx_workqueue
);
822 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
825 mwifiex_free_priv(priv
);
826 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
827 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
828 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
834 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
835 struct net_device
*dev
,
836 enum nl80211_iftype type
)
838 struct mwifiex_adapter
*adapter
= priv
->adapter
;
841 mwifiex_init_priv(priv
);
843 priv
->bss_mode
= type
;
844 priv
->wdev
.iftype
= type
;
846 mwifiex_init_priv_params(priv
, priv
->netdev
);
847 priv
->bss_started
= 0;
850 case NL80211_IFTYPE_STATION
:
851 case NL80211_IFTYPE_ADHOC
:
852 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
853 MWIFIEX_BSS_TYPE_STA
);
854 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
855 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
857 case NL80211_IFTYPE_P2P_CLIENT
:
858 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
859 MWIFIEX_BSS_TYPE_P2P
);
860 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
861 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
863 case NL80211_IFTYPE_P2P_GO
:
864 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
865 MWIFIEX_BSS_TYPE_P2P
);
866 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
867 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
869 case NL80211_IFTYPE_AP
:
870 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
871 MWIFIEX_BSS_TYPE_UAP
);
872 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
873 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
876 mwifiex_dbg(adapter
, ERROR
,
877 "%s: changing to %d not supported\n",
882 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
883 adapter
->main_locked
= false;
884 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
886 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
887 adapter
->rx_locked
= false;
888 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
894 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
895 enum nl80211_iftype curr_iftype
,
896 enum nl80211_iftype type
, u32
*flags
,
897 struct vif_params
*params
)
899 struct mwifiex_private
*priv
;
900 struct mwifiex_adapter
*adapter
;
902 priv
= mwifiex_netdev_get_priv(dev
);
907 adapter
= priv
->adapter
;
909 if (adapter
->curr_iface_comb
.p2p_intf
==
910 adapter
->iface_limit
.p2p_intf
) {
911 mwifiex_dbg(adapter
, ERROR
,
912 "cannot create multiple P2P ifaces\n");
916 mwifiex_dbg(adapter
, INFO
,
917 "%s: changing role to p2p\n", dev
->name
);
919 if (mwifiex_deinit_priv_params(priv
))
921 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
925 case NL80211_IFTYPE_P2P_CLIENT
:
926 if (mwifiex_cfg80211_init_p2p_client(priv
))
929 case NL80211_IFTYPE_P2P_GO
:
930 if (mwifiex_cfg80211_init_p2p_go(priv
))
934 mwifiex_dbg(adapter
, ERROR
,
935 "%s: changing to %d not supported\n",
940 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
941 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
944 if (mwifiex_sta_init_cmd(priv
, false, false))
947 switch (curr_iftype
) {
948 case NL80211_IFTYPE_STATION
:
949 case NL80211_IFTYPE_ADHOC
:
950 adapter
->curr_iface_comb
.sta_intf
--;
952 case NL80211_IFTYPE_AP
:
953 adapter
->curr_iface_comb
.uap_intf
--;
959 adapter
->curr_iface_comb
.p2p_intf
++;
960 dev
->ieee80211_ptr
->iftype
= type
;
966 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
967 enum nl80211_iftype curr_iftype
,
968 enum nl80211_iftype type
, u32
*flags
,
969 struct vif_params
*params
)
971 struct mwifiex_private
*priv
;
972 struct mwifiex_adapter
*adapter
;
974 priv
= mwifiex_netdev_get_priv(dev
);
979 adapter
= priv
->adapter
;
981 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
982 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
983 (adapter
->curr_iface_comb
.sta_intf
==
984 adapter
->iface_limit
.sta_intf
)) {
985 mwifiex_dbg(adapter
, ERROR
,
986 "cannot create multiple station/adhoc ifaces\n");
990 if (type
== NL80211_IFTYPE_STATION
)
991 mwifiex_dbg(adapter
, INFO
,
992 "%s: changing role to station\n", dev
->name
);
994 mwifiex_dbg(adapter
, INFO
,
995 "%s: changing role to adhoc\n", dev
->name
);
997 if (mwifiex_deinit_priv_params(priv
))
999 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1001 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1002 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1004 if (mwifiex_sta_init_cmd(priv
, false, false))
1007 switch (curr_iftype
) {
1008 case NL80211_IFTYPE_P2P_CLIENT
:
1009 case NL80211_IFTYPE_P2P_GO
:
1010 adapter
->curr_iface_comb
.p2p_intf
--;
1012 case NL80211_IFTYPE_AP
:
1013 adapter
->curr_iface_comb
.uap_intf
--;
1019 adapter
->curr_iface_comb
.sta_intf
++;
1020 dev
->ieee80211_ptr
->iftype
= type
;
1025 mwifiex_change_vif_to_ap(struct net_device
*dev
,
1026 enum nl80211_iftype curr_iftype
,
1027 enum nl80211_iftype type
, u32
*flags
,
1028 struct vif_params
*params
)
1030 struct mwifiex_private
*priv
;
1031 struct mwifiex_adapter
*adapter
;
1033 priv
= mwifiex_netdev_get_priv(dev
);
1038 adapter
= priv
->adapter
;
1040 if (adapter
->curr_iface_comb
.uap_intf
==
1041 adapter
->iface_limit
.uap_intf
) {
1042 mwifiex_dbg(adapter
, ERROR
,
1043 "cannot create multiple AP ifaces\n");
1047 mwifiex_dbg(adapter
, INFO
,
1048 "%s: changing role to AP\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_STATION
:
1066 case NL80211_IFTYPE_ADHOC
:
1067 adapter
->curr_iface_comb
.sta_intf
--;
1073 adapter
->curr_iface_comb
.uap_intf
++;
1074 dev
->ieee80211_ptr
->iftype
= type
;
1078 * CFG802.11 operation handler to change interface type.
1081 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1082 struct net_device
*dev
,
1083 enum nl80211_iftype type
, u32
*flags
,
1084 struct vif_params
*params
)
1086 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1087 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1089 switch (curr_iftype
) {
1090 case NL80211_IFTYPE_ADHOC
:
1092 case NL80211_IFTYPE_STATION
:
1093 priv
->bss_mode
= type
;
1094 priv
->sec_info
.authentication_mode
=
1095 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1096 dev
->ieee80211_ptr
->iftype
= type
;
1097 mwifiex_deauthenticate(priv
, NULL
);
1098 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1099 HostCmd_ACT_GEN_SET
, 0, NULL
,
1101 case NL80211_IFTYPE_P2P_CLIENT
:
1102 case NL80211_IFTYPE_P2P_GO
:
1103 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1104 type
, flags
, params
);
1105 case NL80211_IFTYPE_AP
:
1106 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1108 case NL80211_IFTYPE_UNSPECIFIED
:
1109 mwifiex_dbg(priv
->adapter
, INFO
,
1110 "%s: kept type as IBSS\n", dev
->name
);
1111 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1114 mwifiex_dbg(priv
->adapter
, ERROR
,
1115 "%s: changing to %d not supported\n",
1120 case NL80211_IFTYPE_STATION
:
1122 case NL80211_IFTYPE_ADHOC
:
1123 priv
->bss_mode
= type
;
1124 priv
->sec_info
.authentication_mode
=
1125 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1126 dev
->ieee80211_ptr
->iftype
= type
;
1127 mwifiex_deauthenticate(priv
, NULL
);
1128 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1129 HostCmd_ACT_GEN_SET
, 0, NULL
,
1131 case NL80211_IFTYPE_P2P_CLIENT
:
1132 case NL80211_IFTYPE_P2P_GO
:
1133 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1134 type
, flags
, params
);
1135 case NL80211_IFTYPE_AP
:
1136 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1138 case NL80211_IFTYPE_UNSPECIFIED
:
1139 mwifiex_dbg(priv
->adapter
, INFO
,
1140 "%s: kept type as STA\n", dev
->name
);
1141 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1144 mwifiex_dbg(priv
->adapter
, ERROR
,
1145 "%s: changing to %d not supported\n",
1150 case NL80211_IFTYPE_AP
:
1152 case NL80211_IFTYPE_ADHOC
:
1153 case NL80211_IFTYPE_STATION
:
1154 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1158 case NL80211_IFTYPE_P2P_CLIENT
:
1159 case NL80211_IFTYPE_P2P_GO
:
1160 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1161 type
, flags
, params
);
1162 case NL80211_IFTYPE_UNSPECIFIED
:
1163 mwifiex_dbg(priv
->adapter
, INFO
,
1164 "%s: kept type as AP\n", dev
->name
);
1165 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1168 mwifiex_dbg(priv
->adapter
, ERROR
,
1169 "%s: changing to %d not supported\n",
1174 case NL80211_IFTYPE_P2P_CLIENT
:
1175 case NL80211_IFTYPE_P2P_GO
:
1177 case NL80211_IFTYPE_STATION
:
1178 if (mwifiex_cfg80211_deinit_p2p(priv
))
1180 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1181 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1182 dev
->ieee80211_ptr
->iftype
= type
;
1184 case NL80211_IFTYPE_ADHOC
:
1185 if (mwifiex_cfg80211_deinit_p2p(priv
))
1187 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1191 case NL80211_IFTYPE_AP
:
1192 if (mwifiex_cfg80211_deinit_p2p(priv
))
1194 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1196 case NL80211_IFTYPE_UNSPECIFIED
:
1197 mwifiex_dbg(priv
->adapter
, INFO
,
1198 "%s: kept type as P2P\n", dev
->name
);
1199 case NL80211_IFTYPE_P2P_CLIENT
:
1200 case NL80211_IFTYPE_P2P_GO
:
1203 mwifiex_dbg(priv
->adapter
, ERROR
,
1204 "%s: changing to %d not supported\n",
1210 mwifiex_dbg(priv
->adapter
, ERROR
,
1211 "%s: unknown iftype: %d\n",
1212 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1221 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1222 struct rate_info
*rate
)
1224 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1226 if (adapter
->is_hw_11ac_capable
) {
1227 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1228 if (tx_htinfo
& BIT(0)) {
1230 rate
->mcs
= priv
->tx_rate
;
1231 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1233 if (tx_htinfo
& BIT(1)) {
1235 rate
->mcs
= priv
->tx_rate
& 0x0F;
1236 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1239 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1241 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1243 rate
->bw
= RATE_INFO_BW_20
;
1246 rate
->bw
= RATE_INFO_BW_40
;
1249 rate
->bw
= RATE_INFO_BW_80
;
1251 case (BIT(3) | BIT(2)):
1252 rate
->bw
= RATE_INFO_BW_160
;
1256 if (tx_htinfo
& BIT(4))
1257 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1259 if ((priv
->tx_rate
>> 4) == 1)
1266 * Bit 0 in tx_htinfo indicates that current Tx rate
1267 * is 11n rate. Valid MCS index values for us are 0 to 15.
1269 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1270 rate
->mcs
= priv
->tx_rate
;
1271 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1272 rate
->bw
= RATE_INFO_BW_20
;
1273 if (tx_htinfo
& BIT(1))
1274 rate
->bw
= RATE_INFO_BW_40
;
1275 if (tx_htinfo
& BIT(2))
1276 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1282 * This function dumps the station information on a buffer.
1284 * The following information are shown -
1285 * - Total bytes transmitted
1286 * - Total bytes received
1287 * - Total packets transmitted
1288 * - Total packets received
1289 * - Signal quality level
1290 * - Transmission rate
1293 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1294 struct mwifiex_sta_node
*node
,
1295 struct station_info
*sinfo
)
1299 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1300 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1301 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1302 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1304 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1308 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1309 BIT(NL80211_STA_INFO_TX_FAILED
);
1310 sinfo
->inactive_time
=
1311 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1313 sinfo
->signal
= node
->stats
.rssi
;
1314 sinfo
->signal_avg
= node
->stats
.rssi
;
1315 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1316 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1317 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1318 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1319 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1321 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1323 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1328 /* Get signal information from the firmware */
1329 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1330 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1331 mwifiex_dbg(priv
->adapter
, ERROR
,
1332 "failed to get signal information\n");
1336 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1337 mwifiex_dbg(priv
->adapter
, ERROR
,
1338 "getting data rate error\n");
1342 /* Get DTIM period information from firmware */
1343 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1344 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1345 &priv
->dtim_period
, true);
1347 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1349 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1350 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1351 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1352 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1353 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1354 sinfo
->signal
= priv
->bcn_rssi_avg
;
1355 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1356 sinfo
->txrate
.legacy
= rate
* 5;
1358 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1359 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1360 sinfo
->bss_param
.flags
= 0;
1361 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1362 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1363 sinfo
->bss_param
.flags
|=
1364 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1365 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1366 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1367 sinfo
->bss_param
.flags
|=
1368 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1369 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1370 sinfo
->bss_param
.beacon_interval
=
1371 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1378 * CFG802.11 operation handler to get station information.
1380 * This function only works in connected mode, and dumps the
1381 * requested station information, if available.
1384 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1385 const u8
*mac
, struct station_info
*sinfo
)
1387 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1389 if (!priv
->media_connected
)
1391 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1394 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1398 * CFG802.11 operation handler to dump station information.
1401 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1402 int idx
, u8
*mac
, struct station_info
*sinfo
)
1404 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1405 static struct mwifiex_sta_node
*node
;
1407 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1408 priv
->media_connected
&& idx
== 0) {
1409 ether_addr_copy(mac
, priv
->cfg_bssid
);
1410 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1411 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1412 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1413 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1415 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1420 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1421 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1422 ether_addr_copy(mac
, node
->mac_addr
);
1423 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1431 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1432 int idx
, struct survey_info
*survey
)
1434 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1435 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1436 enum nl80211_band band
;
1438 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1440 memset(survey
, 0, sizeof(struct survey_info
));
1442 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1443 priv
->media_connected
&& idx
== 0) {
1444 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1445 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1447 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1448 survey
->channel
= ieee80211_get_channel(wiphy
,
1449 ieee80211_channel_to_frequency(chan
, band
));
1451 if (priv
->bcn_nf_last
) {
1452 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1453 survey
->noise
= priv
->bcn_nf_last
;
1458 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1461 if (!pchan_stats
[idx
].cca_scan_dur
)
1464 band
= pchan_stats
[idx
].bandcfg
;
1465 survey
->channel
= ieee80211_get_channel(wiphy
,
1466 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1467 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1469 SURVEY_INFO_TIME_BUSY
;
1470 survey
->noise
= pchan_stats
[idx
].noise
;
1471 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1472 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1477 /* Supported rates to be advertised to the cfg80211 */
1478 static struct ieee80211_rate mwifiex_rates
[] = {
1479 {.bitrate
= 10, .hw_value
= 2, },
1480 {.bitrate
= 20, .hw_value
= 4, },
1481 {.bitrate
= 55, .hw_value
= 11, },
1482 {.bitrate
= 110, .hw_value
= 22, },
1483 {.bitrate
= 60, .hw_value
= 12, },
1484 {.bitrate
= 90, .hw_value
= 18, },
1485 {.bitrate
= 120, .hw_value
= 24, },
1486 {.bitrate
= 180, .hw_value
= 36, },
1487 {.bitrate
= 240, .hw_value
= 48, },
1488 {.bitrate
= 360, .hw_value
= 72, },
1489 {.bitrate
= 480, .hw_value
= 96, },
1490 {.bitrate
= 540, .hw_value
= 108, },
1493 /* Channel definitions to be advertised to cfg80211 */
1494 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1495 {.center_freq
= 2412, .hw_value
= 1, },
1496 {.center_freq
= 2417, .hw_value
= 2, },
1497 {.center_freq
= 2422, .hw_value
= 3, },
1498 {.center_freq
= 2427, .hw_value
= 4, },
1499 {.center_freq
= 2432, .hw_value
= 5, },
1500 {.center_freq
= 2437, .hw_value
= 6, },
1501 {.center_freq
= 2442, .hw_value
= 7, },
1502 {.center_freq
= 2447, .hw_value
= 8, },
1503 {.center_freq
= 2452, .hw_value
= 9, },
1504 {.center_freq
= 2457, .hw_value
= 10, },
1505 {.center_freq
= 2462, .hw_value
= 11, },
1506 {.center_freq
= 2467, .hw_value
= 12, },
1507 {.center_freq
= 2472, .hw_value
= 13, },
1508 {.center_freq
= 2484, .hw_value
= 14, },
1511 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1512 .channels
= mwifiex_channels_2ghz
,
1513 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1514 .bitrates
= mwifiex_rates
,
1515 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1518 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1519 {.center_freq
= 5040, .hw_value
= 8, },
1520 {.center_freq
= 5060, .hw_value
= 12, },
1521 {.center_freq
= 5080, .hw_value
= 16, },
1522 {.center_freq
= 5170, .hw_value
= 34, },
1523 {.center_freq
= 5190, .hw_value
= 38, },
1524 {.center_freq
= 5210, .hw_value
= 42, },
1525 {.center_freq
= 5230, .hw_value
= 46, },
1526 {.center_freq
= 5180, .hw_value
= 36, },
1527 {.center_freq
= 5200, .hw_value
= 40, },
1528 {.center_freq
= 5220, .hw_value
= 44, },
1529 {.center_freq
= 5240, .hw_value
= 48, },
1530 {.center_freq
= 5260, .hw_value
= 52, },
1531 {.center_freq
= 5280, .hw_value
= 56, },
1532 {.center_freq
= 5300, .hw_value
= 60, },
1533 {.center_freq
= 5320, .hw_value
= 64, },
1534 {.center_freq
= 5500, .hw_value
= 100, },
1535 {.center_freq
= 5520, .hw_value
= 104, },
1536 {.center_freq
= 5540, .hw_value
= 108, },
1537 {.center_freq
= 5560, .hw_value
= 112, },
1538 {.center_freq
= 5580, .hw_value
= 116, },
1539 {.center_freq
= 5600, .hw_value
= 120, },
1540 {.center_freq
= 5620, .hw_value
= 124, },
1541 {.center_freq
= 5640, .hw_value
= 128, },
1542 {.center_freq
= 5660, .hw_value
= 132, },
1543 {.center_freq
= 5680, .hw_value
= 136, },
1544 {.center_freq
= 5700, .hw_value
= 140, },
1545 {.center_freq
= 5745, .hw_value
= 149, },
1546 {.center_freq
= 5765, .hw_value
= 153, },
1547 {.center_freq
= 5785, .hw_value
= 157, },
1548 {.center_freq
= 5805, .hw_value
= 161, },
1549 {.center_freq
= 5825, .hw_value
= 165, },
1552 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1553 .channels
= mwifiex_channels_5ghz
,
1554 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1555 .bitrates
= mwifiex_rates
+ 4,
1556 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1560 /* Supported crypto cipher suits to be advertised to cfg80211 */
1561 static const u32 mwifiex_cipher_suites
[] = {
1562 WLAN_CIPHER_SUITE_WEP40
,
1563 WLAN_CIPHER_SUITE_WEP104
,
1564 WLAN_CIPHER_SUITE_TKIP
,
1565 WLAN_CIPHER_SUITE_CCMP
,
1566 WLAN_CIPHER_SUITE_SMS4
,
1567 WLAN_CIPHER_SUITE_AES_CMAC
,
1570 /* Supported mgmt frame types to be advertised to cfg80211 */
1571 static const struct ieee80211_txrx_stypes
1572 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1573 [NL80211_IFTYPE_STATION
] = {
1574 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1575 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1576 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1577 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1579 [NL80211_IFTYPE_AP
] = {
1580 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1581 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1582 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1583 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1585 [NL80211_IFTYPE_P2P_CLIENT
] = {
1586 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1587 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1588 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1589 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1591 [NL80211_IFTYPE_P2P_GO
] = {
1592 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1593 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1594 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1595 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1600 * CFG802.11 operation handler for setting bit rates.
1602 * Function configures data rates to firmware using bitrate mask
1603 * provided by cfg80211.
1605 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1606 struct net_device
*dev
,
1608 const struct cfg80211_bitrate_mask
*mask
)
1610 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1611 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1612 enum nl80211_band band
;
1613 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1615 if (!priv
->media_connected
) {
1616 mwifiex_dbg(adapter
, ERROR
,
1617 "Can not set Tx data rate in disconnected state\n");
1621 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1623 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1625 /* Fill HR/DSSS rates. */
1626 if (band
== NL80211_BAND_2GHZ
)
1627 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1629 /* Fill OFDM rates */
1630 if (band
== NL80211_BAND_2GHZ
)
1631 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1633 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1635 /* Fill HT MCS rates */
1636 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1637 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1638 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1640 /* Fill VHT MCS rates */
1641 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1642 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1643 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1644 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1647 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1648 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1652 * CFG802.11 operation handler for connection quality monitoring.
1654 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1657 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1658 struct net_device
*dev
,
1659 s32 rssi_thold
, u32 rssi_hyst
)
1661 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1662 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1664 priv
->cqm_rssi_thold
= rssi_thold
;
1665 priv
->cqm_rssi_hyst
= rssi_hyst
;
1667 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1668 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1670 /* Subscribe/unsubscribe low and high rssi events */
1671 if (rssi_thold
&& rssi_hyst
) {
1672 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1673 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1674 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1675 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1676 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1677 return mwifiex_send_cmd(priv
,
1678 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1679 0, 0, &subsc_evt
, true);
1681 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1682 return mwifiex_send_cmd(priv
,
1683 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1684 0, 0, &subsc_evt
, true);
1690 /* cfg80211 operation handler for change_beacon.
1691 * Function retrieves and sets modified management IEs to FW.
1693 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1694 struct net_device
*dev
,
1695 struct cfg80211_beacon_data
*data
)
1697 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1698 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1700 mwifiex_cancel_scan(adapter
);
1702 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1703 mwifiex_dbg(priv
->adapter
, ERROR
,
1704 "%s: bss_type mismatched\n", __func__
);
1708 if (!priv
->bss_started
) {
1709 mwifiex_dbg(priv
->adapter
, ERROR
,
1710 "%s: bss not started\n", __func__
);
1714 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1715 mwifiex_dbg(priv
->adapter
, ERROR
,
1716 "%s: setting mgmt ies failed\n", __func__
);
1723 /* cfg80211 operation handler for del_station.
1724 * Function deauthenticates station which value is provided in mac parameter.
1725 * If mac is NULL/broadcast, all stations in associated station list are
1726 * deauthenticated. If bss is not started or there are no stations in
1727 * associated stations list, no action is taken.
1730 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1731 struct station_del_parameters
*params
)
1733 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1734 struct mwifiex_sta_node
*sta_node
;
1735 u8 deauth_mac
[ETH_ALEN
];
1736 unsigned long flags
;
1738 if (!priv
->bss_started
&& priv
->wdev
.cac_started
) {
1739 mwifiex_dbg(priv
->adapter
, INFO
, "%s: abort CAC!\n", __func__
);
1740 mwifiex_abort_cac(priv
);
1743 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1746 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1749 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1750 __func__
, params
->mac
);
1752 eth_zero_addr(deauth_mac
);
1754 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1755 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1757 ether_addr_copy(deauth_mac
, params
->mac
);
1758 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1760 if (is_valid_ether_addr(deauth_mac
)) {
1761 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1762 HostCmd_ACT_GEN_SET
, 0,
1771 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1773 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1774 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1775 MWIFIEX_BSS_ROLE_ANY
);
1776 struct mwifiex_ds_ant_cfg ant_cfg
;
1778 if (!tx_ant
|| !rx_ant
)
1781 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1782 /* Not a MIMO chip. User should provide specific antenna number
1783 * for Tx/Rx path or enable all antennas for diversity
1785 if (tx_ant
!= rx_ant
)
1788 if ((tx_ant
& (tx_ant
- 1)) &&
1789 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1792 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1793 (priv
->adapter
->number_of_antenna
> 1)) {
1794 tx_ant
= RF_ANTENNA_AUTO
;
1795 rx_ant
= RF_ANTENNA_AUTO
;
1798 struct ieee80211_sta_ht_cap
*ht_info
;
1800 enum nl80211_band band
;
1802 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1803 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1804 if (adapter
->is_hw_11ac_capable
)
1805 adapter
->usr_dot_11ac_mcs_support
=
1806 MWIFIEX_11AC_MCS_MAP_1X1
;
1808 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1809 if (adapter
->is_hw_11ac_capable
)
1810 adapter
->usr_dot_11ac_mcs_support
=
1811 MWIFIEX_11AC_MCS_MAP_2X2
;
1814 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
1815 if (!adapter
->wiphy
->bands
[band
])
1818 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1820 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1821 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1822 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1826 ant_cfg
.tx_ant
= tx_ant
;
1827 ant_cfg
.rx_ant
= rx_ant
;
1829 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1830 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1834 mwifiex_cfg80211_get_antenna(struct wiphy
*wiphy
, u32
*tx_ant
, u32
*rx_ant
)
1836 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1837 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1838 MWIFIEX_BSS_ROLE_ANY
);
1839 mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1840 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1842 *tx_ant
= priv
->tx_ant
;
1843 *rx_ant
= priv
->rx_ant
;
1848 /* cfg80211 operation handler for stop ap.
1849 * Function stops BSS running at uAP interface.
1851 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1853 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1855 mwifiex_abort_cac(priv
);
1857 if (mwifiex_del_mgmt_ies(priv
))
1858 mwifiex_dbg(priv
->adapter
, ERROR
,
1859 "Failed to delete mgmt IEs!\n");
1861 priv
->ap_11n_enabled
= 0;
1862 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1864 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1865 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1866 mwifiex_dbg(priv
->adapter
, ERROR
,
1867 "Failed to stop the BSS\n");
1871 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1872 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1873 mwifiex_dbg(priv
->adapter
, ERROR
,
1874 "Failed to reset BSS\n");
1878 if (netif_carrier_ok(priv
->netdev
))
1879 netif_carrier_off(priv
->netdev
);
1880 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1885 /* cfg80211 operation handler for start_ap.
1886 * Function sets beacon period, DTIM period, SSID and security into
1887 * AP config structure.
1888 * AP is configured with these settings and BSS is started.
1890 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1891 struct net_device
*dev
,
1892 struct cfg80211_ap_settings
*params
)
1894 struct mwifiex_uap_bss_param
*bss_cfg
;
1895 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1897 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1900 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1904 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1906 if (params
->beacon_interval
)
1907 bss_cfg
->beacon_period
= params
->beacon_interval
;
1908 if (params
->dtim_period
)
1909 bss_cfg
->dtim_period
= params
->dtim_period
;
1911 if (params
->ssid
&& params
->ssid_len
) {
1912 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1913 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1915 if (params
->inactivity_timeout
> 0) {
1916 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1917 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1918 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1921 switch (params
->hidden_ssid
) {
1922 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1923 bss_cfg
->bcast_ssid_ctl
= 1;
1925 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1926 bss_cfg
->bcast_ssid_ctl
= 0;
1928 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1929 /* firmware doesn't support this type of hidden SSID */
1935 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1936 mwifiex_set_uap_rates(bss_cfg
, params
);
1938 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1939 mwifiex_dbg(priv
->adapter
, ERROR
,
1940 "Failed to parse secuirty parameters!\n");
1944 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1946 if (priv
->adapter
->is_hw_11ac_capable
) {
1947 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1948 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1949 priv
->ap_11ac_enabled
);
1952 if (priv
->ap_11ac_enabled
)
1953 mwifiex_set_11ac_ba_params(priv
);
1955 mwifiex_set_ba_params(priv
);
1957 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1959 if (mwifiex_is_11h_active(priv
))
1960 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
1962 if (mwifiex_is_11h_active(priv
) &&
1963 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
1965 mwifiex_dbg(priv
->adapter
, INFO
,
1966 "Disable 11h extensions in FW\n");
1967 if (mwifiex_11h_activate(priv
, false)) {
1968 mwifiex_dbg(priv
->adapter
, ERROR
,
1969 "Failed to disable 11h extensions!!");
1972 priv
->state_11h
.is_11h_active
= false;
1975 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
1976 mwifiex_dbg(priv
->adapter
, ERROR
,
1977 "Failed to start AP\n");
1981 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
1984 if (!netif_carrier_ok(priv
->netdev
))
1985 netif_carrier_on(priv
->netdev
);
1986 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
1988 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
1998 * CFG802.11 operation handler for disconnection request.
2000 * This function does not work when there is already a disconnection
2001 * procedure going on.
2004 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
2007 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2009 if (!mwifiex_stop_bg_scan(priv
))
2010 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
);
2012 if (mwifiex_deauthenticate(priv
, NULL
))
2015 eth_zero_addr(priv
->cfg_bssid
);
2016 priv
->hs2_enabled
= false;
2022 * This function informs the CFG802.11 subsystem of a new IBSS.
2024 * The following information are sent to the CFG802.11 subsystem
2025 * to register the new IBSS. If we do not register the new IBSS,
2026 * a kernel panic will result.
2032 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
2034 struct ieee80211_channel
*chan
;
2035 struct mwifiex_bss_info bss_info
;
2036 struct cfg80211_bss
*bss
;
2038 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
2039 enum nl80211_band band
;
2041 if (mwifiex_get_bss_info(priv
, &bss_info
))
2044 ie_buf
[0] = WLAN_EID_SSID
;
2045 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
2047 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
2048 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
2049 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
2051 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
2052 chan
= __ieee80211_get_channel(priv
->wdev
.wiphy
,
2053 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
2056 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2057 CFG80211_BSS_FTYPE_UNKNOWN
,
2058 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2059 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2061 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2062 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2069 * This function connects with a BSS.
2071 * This function handles both Infra and Ad-Hoc modes. It also performs
2072 * validity checking on the provided parameters, disconnects from the
2073 * current BSS (if any), sets up the association/scan parameters,
2074 * including security settings, and performs specific SSID scan before
2075 * trying to connect.
2077 * For Infra mode, the function returns failure if the specified SSID
2078 * is not found in scan table. However, for Ad-Hoc mode, it can create
2079 * the IBSS if it does not exist. On successful completion in either case,
2080 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2083 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2084 const u8
*ssid
, const u8
*bssid
, int mode
,
2085 struct ieee80211_channel
*channel
,
2086 struct cfg80211_connect_params
*sme
, bool privacy
)
2088 struct cfg80211_ssid req_ssid
;
2089 int ret
, auth_type
= 0;
2090 struct cfg80211_bss
*bss
= NULL
;
2091 u8 is_scanning_required
= 0;
2093 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2095 req_ssid
.ssid_len
= ssid_len
;
2096 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2097 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2101 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2102 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2103 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2107 /* As this is new association, clear locally stored
2108 * keys and security related flags */
2109 priv
->sec_info
.wpa_enabled
= false;
2110 priv
->sec_info
.wpa2_enabled
= false;
2111 priv
->wep_key_curr_index
= 0;
2112 priv
->sec_info
.encryption_mode
= 0;
2113 priv
->sec_info
.is_authtype_auto
= 0;
2114 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2116 if (mode
== NL80211_IFTYPE_ADHOC
) {
2117 /* "privacy" is set only for ad-hoc mode */
2120 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2121 * the firmware can find a matching network from the
2122 * scan. The cfg80211 does not give us the encryption
2123 * mode at this stage so just setting it to WEP here.
2125 priv
->sec_info
.encryption_mode
=
2126 WLAN_CIPHER_SUITE_WEP104
;
2127 priv
->sec_info
.authentication_mode
=
2128 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2134 /* Now handle infra mode. "sme" is valid for infra mode only */
2135 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2136 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2137 priv
->sec_info
.is_authtype_auto
= 1;
2139 auth_type
= sme
->auth_type
;
2142 if (sme
->crypto
.n_ciphers_pairwise
) {
2143 priv
->sec_info
.encryption_mode
=
2144 sme
->crypto
.ciphers_pairwise
[0];
2145 priv
->sec_info
.authentication_mode
= auth_type
;
2148 if (sme
->crypto
.cipher_group
) {
2149 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2150 priv
->sec_info
.authentication_mode
= auth_type
;
2153 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2156 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2157 mwifiex_dbg(priv
->adapter
, INFO
,
2158 "info: setting wep encryption\t"
2159 "with key len %d\n", sme
->key_len
);
2160 priv
->wep_key_curr_index
= sme
->key_idx
;
2161 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2162 sme
->key_len
, sme
->key_idx
,
2168 * Scan entries are valid for some time (15 sec). So we can save one
2169 * active scan time if we just try cfg80211_get_bss first. If it fails
2170 * then request scan and cfg80211_get_bss() again for final output.
2173 if (is_scanning_required
) {
2174 /* Do specific SSID scanning */
2175 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2176 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2181 /* Find the BSS we want using available scan results */
2182 if (mode
== NL80211_IFTYPE_ADHOC
)
2183 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2184 bssid
, ssid
, ssid_len
,
2185 IEEE80211_BSS_TYPE_IBSS
,
2186 IEEE80211_PRIVACY_ANY
);
2188 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2189 bssid
, ssid
, ssid_len
,
2190 IEEE80211_BSS_TYPE_ESS
,
2191 IEEE80211_PRIVACY_ANY
);
2194 if (is_scanning_required
) {
2195 mwifiex_dbg(priv
->adapter
, WARN
,
2196 "assoc: requested bss not found in scan results\n");
2199 is_scanning_required
= 1;
2201 mwifiex_dbg(priv
->adapter
, MSG
,
2202 "info: trying to associate to '%s' bssid %pM\n",
2203 (char *)req_ssid
.ssid
, bss
->bssid
);
2204 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2209 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2213 if (mode
== NL80211_IFTYPE_ADHOC
) {
2214 /* Inform the BSS information to kernel, otherwise
2215 * kernel will give a panic after successful assoc */
2216 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2224 * CFG802.11 operation handler for association request.
2226 * This function does not work when the current mode is set to Ad-Hoc, or
2227 * when there is already an association procedure going on. The given BSS
2228 * information is used to associate.
2231 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2232 struct cfg80211_connect_params
*sme
)
2234 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2235 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2238 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2239 mwifiex_dbg(adapter
, ERROR
,
2240 "%s: reject infra assoc request in non-STA role\n",
2245 if (priv
->wdev
.current_bss
) {
2246 mwifiex_dbg(adapter
, ERROR
,
2247 "%s: already connected\n", dev
->name
);
2251 if (priv
->scan_block
)
2252 priv
->scan_block
= false;
2254 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2255 mwifiex_dbg(adapter
, ERROR
,
2256 "%s: Ignore connection.\t"
2257 "Card removed or FW in bad state\n",
2262 mwifiex_dbg(adapter
, INFO
,
2263 "info: Trying to associate to %s and bssid %pM\n",
2264 (char *)sme
->ssid
, sme
->bssid
);
2266 if (!mwifiex_stop_bg_scan(priv
))
2267 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
);
2269 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2270 priv
->bss_mode
, sme
->channel
, sme
, 0);
2272 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2273 NULL
, 0, WLAN_STATUS_SUCCESS
,
2275 mwifiex_dbg(priv
->adapter
, MSG
,
2276 "info: associated to bssid %pM successfully\n",
2278 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2279 priv
->adapter
->auto_tdls
&&
2280 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2281 mwifiex_setup_auto_tdls_timer(priv
);
2283 mwifiex_dbg(priv
->adapter
, ERROR
,
2284 "info: association to bssid %pM failed\n",
2286 eth_zero_addr(priv
->cfg_bssid
);
2289 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2290 NULL
, 0, NULL
, 0, ret
,
2293 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2295 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2303 * This function sets following parameters for ibss network.
2307 * - secondary channel offset
2309 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2310 struct cfg80211_ibss_params
*params
)
2312 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2314 u8 config_bands
= 0;
2316 if (params
->chandef
.chan
->band
== NL80211_BAND_2GHZ
) {
2317 if (!params
->basic_rates
) {
2318 config_bands
= BAND_B
| BAND_G
;
2320 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2322 * Rates below 6 Mbps in the table are CCK
2323 * rates; 802.11b and from 6 they are OFDM;
2326 if (mwifiex_rates
[i
].bitrate
== 60) {
2332 if (params
->basic_rates
< index
) {
2333 config_bands
= BAND_B
;
2335 config_bands
= BAND_G
;
2336 if (params
->basic_rates
% index
)
2337 config_bands
|= BAND_B
;
2341 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2343 config_bands
|= BAND_G
| BAND_GN
;
2345 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2347 config_bands
= BAND_A
;
2349 config_bands
= BAND_AN
| BAND_A
;
2352 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2353 adapter
->config_bands
= config_bands
;
2354 adapter
->adhoc_start_band
= config_bands
;
2356 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2357 adapter
->adhoc_11n_enabled
= true;
2359 adapter
->adhoc_11n_enabled
= false;
2362 adapter
->sec_chan_offset
=
2363 mwifiex_chan_type_to_sec_chan_offset(
2364 cfg80211_get_chandef_type(¶ms
->chandef
));
2365 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2366 params
->chandef
.chan
->center_freq
);
2368 mwifiex_dbg(adapter
, INFO
,
2369 "info: set ibss band %d, chan %d, chan offset %d\n",
2370 config_bands
, priv
->adhoc_channel
,
2371 adapter
->sec_chan_offset
);
2377 * CFG802.11 operation handler to join an IBSS.
2379 * This function does not work in any mode other than Ad-Hoc, or if
2380 * a join operation is already in progress.
2383 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2384 struct cfg80211_ibss_params
*params
)
2386 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2389 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2390 mwifiex_dbg(priv
->adapter
, ERROR
,
2391 "request to join ibss received\t"
2392 "when station is not in ibss mode\n");
2396 mwifiex_dbg(priv
->adapter
, MSG
,
2397 "info: trying to join to %s and bssid %pM\n",
2398 (char *)params
->ssid
, params
->bssid
);
2400 mwifiex_set_ibss_params(priv
, params
);
2402 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2403 params
->bssid
, priv
->bss_mode
,
2404 params
->chandef
.chan
, NULL
,
2408 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2409 params
->chandef
.chan
, GFP_KERNEL
);
2410 mwifiex_dbg(priv
->adapter
, MSG
,
2411 "info: joined/created adhoc network with bssid\t"
2412 "%pM successfully\n", priv
->cfg_bssid
);
2414 mwifiex_dbg(priv
->adapter
, ERROR
,
2415 "info: failed creating/joining adhoc network\n");
2422 * CFG802.11 operation handler to leave an IBSS.
2424 * This function does not work if a leave operation is
2425 * already in progress.
2428 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2430 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2432 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2434 if (mwifiex_deauthenticate(priv
, NULL
))
2437 eth_zero_addr(priv
->cfg_bssid
);
2443 * CFG802.11 operation handler for scan request.
2445 * This function issues a scan request to the firmware based upon
2446 * the user specified scan configuration. On successful completion,
2447 * it also informs the results.
2450 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2451 struct cfg80211_scan_request
*request
)
2453 struct net_device
*dev
= request
->wdev
->netdev
;
2454 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2456 struct ieee80211_channel
*chan
;
2457 struct ieee_types_header
*ie
;
2458 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2460 mwifiex_dbg(priv
->adapter
, CMD
,
2461 "info: received scan request on %s\n", dev
->name
);
2463 /* Block scan request if scan operation or scan cleanup when interface
2464 * is disabled is in process
2466 if (priv
->scan_request
|| priv
->scan_aborting
) {
2467 mwifiex_dbg(priv
->adapter
, WARN
,
2468 "cmd: Scan already in process..\n");
2472 if (!priv
->wdev
.current_bss
&& priv
->scan_block
)
2473 priv
->scan_block
= false;
2475 if (!mwifiex_stop_bg_scan(priv
))
2476 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
);
2478 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2482 priv
->scan_request
= request
;
2484 if (request
->flags
& NL80211_SCAN_FLAG_RANDOM_ADDR
) {
2485 ether_addr_copy(priv
->random_mac
, request
->mac_addr
);
2486 for (i
= 0; i
< ETH_ALEN
; i
++) {
2487 priv
->random_mac
[i
] &= request
->mac_addr_mask
[i
];
2488 priv
->random_mac
[i
] |= get_random_int() &
2489 ~(request
->mac_addr_mask
[i
]);
2493 ether_addr_copy(user_scan_cfg
->random_mac
, priv
->random_mac
);
2494 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2495 user_scan_cfg
->ssid_list
= request
->ssids
;
2497 if (request
->ie
&& request
->ie_len
) {
2499 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2500 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2502 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2503 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2504 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2505 offset
+= sizeof(*ie
) + ie
->len
;
2507 if (offset
>= request
->ie_len
)
2512 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2513 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2514 chan
= request
->channels
[i
];
2515 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2516 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2518 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2519 user_scan_cfg
->chan_list
[i
].scan_type
=
2520 MWIFIEX_SCAN_TYPE_PASSIVE
;
2522 user_scan_cfg
->chan_list
[i
].scan_type
=
2523 MWIFIEX_SCAN_TYPE_ACTIVE
;
2525 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2528 if (priv
->adapter
->scan_chan_gap_enabled
&&
2529 mwifiex_is_any_intf_active(priv
))
2530 user_scan_cfg
->scan_chan_gap
=
2531 priv
->adapter
->scan_chan_gap_time
;
2533 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2534 kfree(user_scan_cfg
);
2536 mwifiex_dbg(priv
->adapter
, ERROR
,
2537 "scan failed: %d\n", ret
);
2538 priv
->scan_aborting
= false;
2539 priv
->scan_request
= NULL
;
2543 if (request
->ie
&& request
->ie_len
) {
2544 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2545 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2546 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2547 memset(&priv
->vs_ie
[i
].ie
, 0,
2548 MWIFIEX_MAX_VSIE_LEN
);
2555 /* CFG802.11 operation handler for sched_scan_start.
2557 * This function issues a bgscan config request to the firmware based upon
2558 * the user specified sched_scan configuration. On successful completion,
2559 * firmware will generate BGSCAN_REPORT event, driver should issue bgscan
2560 * query command to get sched_scan results from firmware.
2563 mwifiex_cfg80211_sched_scan_start(struct wiphy
*wiphy
,
2564 struct net_device
*dev
,
2565 struct cfg80211_sched_scan_request
*request
)
2567 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2569 struct ieee80211_channel
*chan
;
2570 struct mwifiex_bg_scan_cfg
*bgscan_cfg
;
2571 struct ieee_types_header
*ie
;
2573 if (!request
|| (!request
->n_ssids
&& !request
->n_match_sets
)) {
2574 wiphy_err(wiphy
, "%s : Invalid Sched_scan parameters",
2579 wiphy_info(wiphy
, "sched_scan start : n_ssids=%d n_match_sets=%d ",
2580 request
->n_ssids
, request
->n_match_sets
);
2581 wiphy_info(wiphy
, "n_channels=%d interval=%d ie_len=%d\n",
2582 request
->n_channels
, request
->scan_plans
->interval
,
2583 (int)request
->ie_len
);
2585 bgscan_cfg
= kzalloc(sizeof(*bgscan_cfg
), GFP_KERNEL
);
2589 if (priv
->scan_request
|| priv
->scan_aborting
)
2590 bgscan_cfg
->start_later
= true;
2592 bgscan_cfg
->num_ssids
= request
->n_match_sets
;
2593 bgscan_cfg
->ssid_list
= request
->match_sets
;
2595 if (request
->ie
&& request
->ie_len
) {
2597 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2598 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2600 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_BGSCAN
;
2601 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2602 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2603 offset
+= sizeof(*ie
) + ie
->len
;
2605 if (offset
>= request
->ie_len
)
2610 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2611 MWIFIEX_BG_SCAN_CHAN_MAX
); i
++) {
2612 chan
= request
->channels
[i
];
2613 bgscan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2614 bgscan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2616 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2617 bgscan_cfg
->chan_list
[i
].scan_type
=
2618 MWIFIEX_SCAN_TYPE_PASSIVE
;
2620 bgscan_cfg
->chan_list
[i
].scan_type
=
2621 MWIFIEX_SCAN_TYPE_ACTIVE
;
2623 bgscan_cfg
->chan_list
[i
].scan_time
= 0;
2626 bgscan_cfg
->chan_per_scan
= min_t(u32
, request
->n_channels
,
2627 MWIFIEX_BG_SCAN_CHAN_MAX
);
2629 /* Use at least 15 second for per scan cycle */
2630 bgscan_cfg
->scan_interval
= (request
->scan_plans
->interval
>
2631 MWIFIEX_BGSCAN_INTERVAL
) ?
2632 request
->scan_plans
->interval
:
2633 MWIFIEX_BGSCAN_INTERVAL
;
2635 bgscan_cfg
->repeat_count
= MWIFIEX_BGSCAN_REPEAT_COUNT
;
2636 bgscan_cfg
->report_condition
= MWIFIEX_BGSCAN_SSID_MATCH
|
2637 MWIFIEX_BGSCAN_WAIT_ALL_CHAN_DONE
;
2638 bgscan_cfg
->bss_type
= MWIFIEX_BSS_MODE_INFRA
;
2639 bgscan_cfg
->action
= MWIFIEX_BGSCAN_ACT_SET
;
2640 bgscan_cfg
->enable
= true;
2641 if (request
->min_rssi_thold
!= NL80211_SCAN_RSSI_THOLD_OFF
) {
2642 bgscan_cfg
->report_condition
|= MWIFIEX_BGSCAN_SSID_RSSI_MATCH
;
2643 bgscan_cfg
->rssi_threshold
= request
->min_rssi_thold
;
2646 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_BG_SCAN_CONFIG
,
2647 HostCmd_ACT_GEN_SET
, 0, bgscan_cfg
, true)) {
2652 priv
->sched_scanning
= true;
2658 /* CFG802.11 operation handler for sched_scan_stop.
2660 * This function issues a bgscan config command to disable
2661 * previous bgscan configuration in the firmware
2663 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy
*wiphy
,
2664 struct net_device
*dev
)
2666 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2668 wiphy_info(wiphy
, "sched scan stop!");
2669 mwifiex_stop_bg_scan(priv
);
2674 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2675 struct mwifiex_private
*priv
)
2677 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2679 vht_info
->vht_supported
= true;
2681 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2682 /* Update MCS support for VHT */
2683 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2684 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2685 vht_info
->vht_mcs
.rx_highest
= 0;
2686 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2687 adapter
->hw_dot_11ac_mcs_support
>> 16);
2688 vht_info
->vht_mcs
.tx_highest
= 0;
2692 * This function sets up the CFG802.11 specific HT capability fields
2693 * with default values.
2695 * The following default values are set -
2696 * - HT Supported = True
2697 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2698 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2699 * - HT Capabilities supported by firmware
2700 * - MCS information, Rx mask = 0xff
2701 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2704 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2705 struct mwifiex_private
*priv
)
2708 struct ieee80211_mcs_info mcs_set
;
2709 u8
*mcs
= (u8
*)&mcs_set
;
2710 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2712 ht_info
->ht_supported
= true;
2713 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2714 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2716 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2718 /* Fill HT capability information */
2719 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2720 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2722 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2724 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2725 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2727 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2729 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2730 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2732 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2734 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2735 ht_info
->cap
|= 3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2737 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2739 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2740 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2742 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2744 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2745 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2747 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2749 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2750 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2752 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2754 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2755 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2757 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2759 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2760 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2762 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2763 /* Set MCS for 1x1/2x2 */
2764 memset(mcs
, 0xff, rx_mcs_supp
);
2765 /* Clear all the other values */
2766 memset(&mcs
[rx_mcs_supp
], 0,
2767 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2768 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2769 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2770 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2771 SETHT_MCS32(mcs_set
.rx_mask
);
2773 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2775 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2779 * create a new virtual interface with the given name and name assign type
2781 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2783 unsigned char name_assign_type
,
2784 enum nl80211_iftype type
,
2786 struct vif_params
*params
)
2788 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2789 struct mwifiex_private
*priv
;
2790 struct net_device
*dev
;
2795 return ERR_PTR(-EFAULT
);
2798 case NL80211_IFTYPE_UNSPECIFIED
:
2799 case NL80211_IFTYPE_STATION
:
2800 case NL80211_IFTYPE_ADHOC
:
2801 if (adapter
->curr_iface_comb
.sta_intf
==
2802 adapter
->iface_limit
.sta_intf
) {
2803 mwifiex_dbg(adapter
, ERROR
,
2804 "cannot create multiple sta/adhoc ifaces\n");
2805 return ERR_PTR(-EINVAL
);
2808 priv
= mwifiex_get_unused_priv_by_bss_type(
2809 adapter
, MWIFIEX_BSS_TYPE_STA
);
2811 mwifiex_dbg(adapter
, ERROR
,
2812 "could not get free private struct\n");
2813 return ERR_PTR(-EFAULT
);
2816 priv
->wdev
.wiphy
= wiphy
;
2817 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2819 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2820 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2822 priv
->bss_mode
= type
;
2824 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2825 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2826 priv
->bss_priority
= 0;
2827 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2830 case NL80211_IFTYPE_AP
:
2831 if (adapter
->curr_iface_comb
.uap_intf
==
2832 adapter
->iface_limit
.uap_intf
) {
2833 mwifiex_dbg(adapter
, ERROR
,
2834 "cannot create multiple AP ifaces\n");
2835 return ERR_PTR(-EINVAL
);
2838 priv
= mwifiex_get_unused_priv_by_bss_type(
2839 adapter
, MWIFIEX_BSS_TYPE_UAP
);
2841 mwifiex_dbg(adapter
, ERROR
,
2842 "could not get free private struct\n");
2843 return ERR_PTR(-EFAULT
);
2846 priv
->wdev
.wiphy
= wiphy
;
2847 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2849 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2850 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2851 priv
->bss_priority
= 0;
2852 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2853 priv
->bss_started
= 0;
2854 priv
->bss_mode
= type
;
2857 case NL80211_IFTYPE_P2P_CLIENT
:
2858 if (adapter
->curr_iface_comb
.p2p_intf
==
2859 adapter
->iface_limit
.p2p_intf
) {
2860 mwifiex_dbg(adapter
, ERROR
,
2861 "cannot create multiple P2P ifaces\n");
2862 return ERR_PTR(-EINVAL
);
2865 priv
= mwifiex_get_unused_priv_by_bss_type(
2866 adapter
, MWIFIEX_BSS_TYPE_P2P
);
2868 mwifiex_dbg(adapter
, ERROR
,
2869 "could not get free private struct\n");
2870 return ERR_PTR(-EFAULT
);
2873 priv
->wdev
.wiphy
= wiphy
;
2874 /* At start-up, wpa_supplicant tries to change the interface
2875 * to NL80211_IFTYPE_STATION if it is not managed mode.
2877 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2878 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2880 /* Setting bss_type to P2P tells firmware that this interface
2881 * is receiving P2P peers found during find phase and doing
2882 * action frame handshake.
2884 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2886 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2887 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2888 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2889 priv
->bss_started
= 0;
2891 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2892 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2893 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2894 return ERR_PTR(-EFAULT
);
2899 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2900 return ERR_PTR(-EINVAL
);
2903 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2904 name_assign_type
, ether_setup
,
2905 IEEE80211_NUM_ACS
, 1);
2907 mwifiex_dbg(adapter
, ERROR
,
2908 "no memory available for netdevice\n");
2909 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2910 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2911 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2912 return ERR_PTR(-ENOMEM
);
2915 mwifiex_init_priv_params(priv
, dev
);
2918 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
2919 HostCmd_ACT_GEN_SET
, 0, NULL
, true);
2921 return ERR_PTR(ret
);
2923 ret
= mwifiex_sta_init_cmd(priv
, false, false);
2925 return ERR_PTR(ret
);
2927 mwifiex_setup_ht_caps(&wiphy
->bands
[NL80211_BAND_2GHZ
]->ht_cap
, priv
);
2928 if (adapter
->is_hw_11ac_capable
)
2929 mwifiex_setup_vht_caps(
2930 &wiphy
->bands
[NL80211_BAND_2GHZ
]->vht_cap
, priv
);
2932 if (adapter
->config_bands
& BAND_A
)
2933 mwifiex_setup_ht_caps(
2934 &wiphy
->bands
[NL80211_BAND_5GHZ
]->ht_cap
, priv
);
2936 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2937 mwifiex_setup_vht_caps(
2938 &wiphy
->bands
[NL80211_BAND_5GHZ
]->vht_cap
, priv
);
2940 dev_net_set(dev
, wiphy_net(wiphy
));
2941 dev
->ieee80211_ptr
= &priv
->wdev
;
2942 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2943 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2944 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2946 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2947 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2948 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2949 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
2951 mdev_priv
= netdev_priv(dev
);
2952 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
2954 SET_NETDEV_DEV(dev
, adapter
->dev
);
2956 /* Register network device */
2957 if (register_netdevice(dev
)) {
2958 mwifiex_dbg(adapter
, ERROR
,
2959 "cannot register virtual network device\n");
2961 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2962 priv
->netdev
= NULL
;
2963 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2964 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2965 return ERR_PTR(-EFAULT
);
2968 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
2971 WQ_UNBOUND
, 1, name
);
2972 if (!priv
->dfs_cac_workqueue
) {
2973 mwifiex_dbg(adapter
, ERROR
,
2974 "cannot register virtual network device\n");
2976 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2977 priv
->netdev
= NULL
;
2978 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2979 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2980 return ERR_PTR(-ENOMEM
);
2983 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
2985 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
2986 WQ_HIGHPRI
| WQ_UNBOUND
|
2987 WQ_MEM_RECLAIM
, 1, name
);
2988 if (!priv
->dfs_chan_sw_workqueue
) {
2989 mwifiex_dbg(adapter
, ERROR
,
2990 "cannot register virtual network device\n");
2992 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2993 priv
->netdev
= NULL
;
2994 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2995 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2996 return ERR_PTR(-ENOMEM
);
2999 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
3000 mwifiex_dfs_chan_sw_work_queue
);
3002 sema_init(&priv
->async_sem
, 1);
3004 mwifiex_dbg(adapter
, INFO
,
3005 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
3007 #ifdef CONFIG_DEBUG_FS
3008 mwifiex_dev_debugfs_init(priv
);
3012 case NL80211_IFTYPE_UNSPECIFIED
:
3013 case NL80211_IFTYPE_STATION
:
3014 case NL80211_IFTYPE_ADHOC
:
3015 adapter
->curr_iface_comb
.sta_intf
++;
3017 case NL80211_IFTYPE_AP
:
3018 adapter
->curr_iface_comb
.uap_intf
++;
3020 case NL80211_IFTYPE_P2P_CLIENT
:
3021 adapter
->curr_iface_comb
.p2p_intf
++;
3024 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
3025 return ERR_PTR(-EINVAL
);
3030 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
3033 * del_virtual_intf: remove the virtual interface determined by dev
3035 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
3037 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3038 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3039 struct sk_buff
*skb
, *tmp
;
3041 #ifdef CONFIG_DEBUG_FS
3042 mwifiex_dev_debugfs_remove(priv
);
3045 if (priv
->sched_scanning
)
3046 priv
->sched_scanning
= false;
3048 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
3050 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
)
3051 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
3053 if (netif_carrier_ok(priv
->netdev
))
3054 netif_carrier_off(priv
->netdev
);
3056 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
3057 unregister_netdevice(wdev
->netdev
);
3059 if (priv
->dfs_cac_workqueue
) {
3060 flush_workqueue(priv
->dfs_cac_workqueue
);
3061 destroy_workqueue(priv
->dfs_cac_workqueue
);
3062 priv
->dfs_cac_workqueue
= NULL
;
3065 if (priv
->dfs_chan_sw_workqueue
) {
3066 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
3067 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3068 priv
->dfs_chan_sw_workqueue
= NULL
;
3070 /* Clear the priv in adapter */
3071 priv
->netdev
->ieee80211_ptr
= NULL
;
3072 priv
->netdev
= NULL
;
3073 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
3075 priv
->media_connected
= false;
3077 switch (priv
->bss_mode
) {
3078 case NL80211_IFTYPE_UNSPECIFIED
:
3079 case NL80211_IFTYPE_STATION
:
3080 case NL80211_IFTYPE_ADHOC
:
3081 adapter
->curr_iface_comb
.sta_intf
--;
3083 case NL80211_IFTYPE_AP
:
3084 adapter
->curr_iface_comb
.uap_intf
--;
3086 case NL80211_IFTYPE_P2P_CLIENT
:
3087 case NL80211_IFTYPE_P2P_GO
:
3088 adapter
->curr_iface_comb
.p2p_intf
--;
3091 mwifiex_dbg(adapter
, ERROR
,
3092 "del_virtual_intf: type not supported\n");
3096 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3098 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
3099 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
3100 kfree(priv
->hist_data
);
3104 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
3107 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
3110 int j
, k
, valid_byte_cnt
= 0;
3111 bool dont_care_byte
= false;
3113 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
3114 for (k
= 0; k
< 8; k
++) {
3115 if (pat
->mask
[j
] & 1 << k
) {
3116 memcpy(byte_seq
+ valid_byte_cnt
,
3117 &pat
->pattern
[j
* 8 + k
], 1);
3123 dont_care_byte
= true;
3126 /* wildcard bytes record as the offset
3127 * before the valid byte
3129 if (!valid_byte_cnt
&& !dont_care_byte
)
3132 if (valid_byte_cnt
> max_byte_seq
)
3137 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
3143 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
3144 struct mwifiex_mef_entry
*mef_entry
)
3146 int i
, filt_num
= 0, num_ipv4
= 0;
3147 struct in_device
*in_dev
;
3148 struct in_ifaddr
*ifa
;
3149 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
3150 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3152 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3153 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
3155 /* Enable ARP offload feature */
3156 memset(ips
, 0, sizeof(ips
));
3157 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
3158 if (adapter
->priv
[i
]->netdev
) {
3159 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
3162 ifa
= in_dev
->ifa_list
;
3163 if (!ifa
|| !ifa
->ifa_local
)
3165 ips
[i
] = ifa
->ifa_local
;
3170 for (i
= 0; i
< num_ipv4
; i
++) {
3173 mef_entry
->filter
[filt_num
].repeat
= 1;
3174 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
3175 (u8
*)&ips
[i
], sizeof(ips
[i
]));
3176 mef_entry
->filter
[filt_num
].
3177 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3179 mef_entry
->filter
[filt_num
].offset
= 46;
3180 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3182 mef_entry
->filter
[filt_num
].filt_action
=
3188 mef_entry
->filter
[filt_num
].repeat
= 1;
3189 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
3190 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
3191 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
3192 mef_entry
->filter
[filt_num
].offset
= 20;
3193 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3194 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3197 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
3198 struct mwifiex_ds_mef_cfg
*mef_cfg
,
3199 struct mwifiex_mef_entry
*mef_entry
,
3200 struct cfg80211_wowlan
*wowlan
)
3202 int i
, filt_num
= 0, ret
= 0;
3203 bool first_pat
= true;
3204 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
3205 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3206 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3208 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3209 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
3211 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
3212 memset(byte_seq
, 0, sizeof(byte_seq
));
3213 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
3215 MWIFIEX_MEF_MAX_BYTESEQ
)) {
3216 mwifiex_dbg(priv
->adapter
, ERROR
,
3217 "Pattern not supported\n");
3221 if (!wowlan
->patterns
[i
].pkt_offset
) {
3222 if (!(byte_seq
[0] & 0x01) &&
3223 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3224 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3226 } else if (is_broadcast_ether_addr(byte_seq
)) {
3227 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3229 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3230 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3231 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3232 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3233 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3237 mef_entry
->filter
[filt_num
].repeat
= 1;
3238 mef_entry
->filter
[filt_num
].offset
=
3239 wowlan
->patterns
[i
].pkt_offset
;
3240 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3242 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3246 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on patterns\n");
3248 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3254 if (wowlan
->magic_pkt
) {
3255 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3256 mef_entry
->filter
[filt_num
].repeat
= 16;
3257 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3259 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3261 mef_entry
->filter
[filt_num
].offset
= 28;
3262 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3264 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3267 mef_entry
->filter
[filt_num
].repeat
= 16;
3268 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3270 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3272 mef_entry
->filter
[filt_num
].offset
= 56;
3273 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3274 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3275 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on magic packet\n");
3280 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3281 struct cfg80211_wowlan
*wowlan
)
3283 int ret
= 0, num_entries
= 1;
3284 struct mwifiex_ds_mef_cfg mef_cfg
;
3285 struct mwifiex_mef_entry
*mef_entry
;
3287 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3290 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3294 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3295 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3296 MWIFIEX_CRITERIA_UNICAST
;
3297 mef_cfg
.num_entries
= num_entries
;
3298 mef_cfg
.mef_entry
= mef_entry
;
3300 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3302 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3303 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3304 &mef_entry
[1], wowlan
);
3309 if (!mef_cfg
.criteria
)
3310 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3311 MWIFIEX_CRITERIA_UNICAST
|
3312 MWIFIEX_CRITERIA_MULTICAST
;
3314 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3315 HostCmd_ACT_GEN_SET
, 0,
3323 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3324 struct cfg80211_wowlan
*wowlan
)
3326 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3327 struct mwifiex_ds_hs_cfg hs_cfg
;
3328 int i
, ret
= 0, retry_num
= 10;
3329 struct mwifiex_private
*priv
;
3330 struct mwifiex_private
*sta_priv
=
3331 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3333 sta_priv
->scan_aborting
= true;
3334 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3335 priv
= adapter
->priv
[i
];
3336 mwifiex_abort_cac(priv
);
3339 mwifiex_cancel_all_pending_cmd(adapter
);
3341 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3342 priv
= adapter
->priv
[i
];
3343 if (priv
&& priv
->netdev
) {
3344 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
3345 if (netif_carrier_ok(priv
->netdev
))
3346 netif_carrier_off(priv
->netdev
);
3350 for (i
= 0; i
< retry_num
; i
++) {
3351 if (!mwifiex_wmm_lists_empty(adapter
) ||
3352 !mwifiex_bypass_txlist_empty(adapter
) ||
3353 !skb_queue_empty(&adapter
->tx_data_q
))
3354 usleep_range(10000, 15000);
3360 mwifiex_dbg(adapter
, ERROR
,
3361 "None of the WOWLAN triggers enabled\n");
3366 if (!sta_priv
->media_connected
&& !wowlan
->nd_config
) {
3367 mwifiex_dbg(adapter
, ERROR
,
3368 "Can not configure WOWLAN in disconnected state\n");
3373 ret
= mwifiex_set_mef_filter(sta_priv
, wowlan
);
3375 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3379 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3380 hs_cfg
.conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
3382 if (wowlan
->nd_config
) {
3383 mwifiex_dbg(adapter
, INFO
, "Wake on net detect\n");
3384 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3385 mwifiex_cfg80211_sched_scan_start(wiphy
, sta_priv
->netdev
,
3389 if (wowlan
->disconnect
) {
3390 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3391 mwifiex_dbg(sta_priv
->adapter
, INFO
, "Wake on device disconnect\n");
3394 hs_cfg
.is_invoke_hostcmd
= false;
3395 hs_cfg
.gpio
= adapter
->hs_cfg
.gpio
;
3396 hs_cfg
.gap
= adapter
->hs_cfg
.gap
;
3397 ret
= mwifiex_set_hs_params(sta_priv
, HostCmd_ACT_GEN_SET
,
3398 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3400 mwifiex_dbg(adapter
, ERROR
, "Failed to set HS params\n");
3403 sta_priv
->scan_aborting
= false;
3407 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3409 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3410 struct mwifiex_private
*priv
;
3411 struct mwifiex_ds_wakeup_reason wakeup_reason
;
3412 struct cfg80211_wowlan_wakeup wakeup_report
;
3414 bool report_wakeup_reason
= true;
3416 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3417 priv
= adapter
->priv
[i
];
3418 if (priv
&& priv
->netdev
) {
3419 if (!netif_carrier_ok(priv
->netdev
))
3420 netif_carrier_on(priv
->netdev
);
3421 mwifiex_wake_up_net_dev_queue(priv
->netdev
, adapter
);
3425 if (!wiphy
->wowlan_config
)
3428 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3429 mwifiex_get_wakeup_reason(priv
, HostCmd_ACT_GEN_GET
, MWIFIEX_SYNC_CMD
,
3431 memset(&wakeup_report
, 0, sizeof(struct cfg80211_wowlan_wakeup
));
3433 wakeup_report
.pattern_idx
= -1;
3435 switch (wakeup_reason
.hs_wakeup_reason
) {
3436 case NO_HSWAKEUP_REASON
:
3438 case BCAST_DATA_MATCHED
:
3440 case MCAST_DATA_MATCHED
:
3442 case UCAST_DATA_MATCHED
:
3444 case MASKTABLE_EVENT_MATCHED
:
3446 case NON_MASKABLE_EVENT_MATCHED
:
3447 if (wiphy
->wowlan_config
->disconnect
)
3448 wakeup_report
.disconnect
= true;
3449 if (wiphy
->wowlan_config
->nd_config
)
3450 wakeup_report
.net_detect
= adapter
->nd_info
;
3452 case NON_MASKABLE_CONDITION_MATCHED
:
3454 case MAGIC_PATTERN_MATCHED
:
3455 if (wiphy
->wowlan_config
->magic_pkt
)
3456 wakeup_report
.magic_pkt
= true;
3457 if (wiphy
->wowlan_config
->n_patterns
)
3458 wakeup_report
.pattern_idx
= 1;
3460 case GTK_REKEY_FAILURE
:
3461 if (wiphy
->wowlan_config
->gtk_rekey_failure
)
3462 wakeup_report
.gtk_rekey_failure
= true;
3465 report_wakeup_reason
= false;
3469 if (report_wakeup_reason
)
3470 cfg80211_report_wowlan_wakeup(&priv
->wdev
, &wakeup_report
,
3474 if (adapter
->nd_info
) {
3475 for (i
= 0 ; i
< adapter
->nd_info
->n_matches
; i
++)
3476 kfree(adapter
->nd_info
->matches
[i
]);
3477 kfree(adapter
->nd_info
);
3478 adapter
->nd_info
= NULL
;
3484 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3487 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3489 device_set_wakeup_enable(adapter
->dev
, enabled
);
3492 static int mwifiex_set_rekey_data(struct wiphy
*wiphy
, struct net_device
*dev
,
3493 struct cfg80211_gtk_rekey_data
*data
)
3495 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3497 return mwifiex_send_cmd(priv
, HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG
,
3498 HostCmd_ACT_GEN_SET
, 0, data
, true);
3503 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3505 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3506 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3507 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3509 if ((byte_seq
[0] & 0x01) &&
3510 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3511 return PACKET_TYPE_UNICAST
;
3512 else if (!memcmp(byte_seq
, bc_mac
, 4))
3513 return PACKET_TYPE_BROADCAST
;
3514 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3515 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3516 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3517 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3518 return PACKET_TYPE_MULTICAST
;
3524 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3525 struct cfg80211_coalesce_rules
*crule
,
3526 struct mwifiex_coalesce_rule
*mrule
)
3528 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3529 struct filt_field_param
*param
;
3532 mrule
->max_coalescing_delay
= crule
->delay
;
3534 param
= mrule
->params
;
3536 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3537 memset(byte_seq
, 0, sizeof(byte_seq
));
3538 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3540 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3541 mwifiex_dbg(priv
->adapter
, ERROR
,
3542 "Pattern not supported\n");
3546 if (!crule
->patterns
[i
].pkt_offset
) {
3549 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3550 if (pkt_type
&& mrule
->pkt_type
) {
3551 mwifiex_dbg(priv
->adapter
, ERROR
,
3552 "Multiple packet types not allowed\n");
3554 } else if (pkt_type
) {
3555 mrule
->pkt_type
= pkt_type
;
3560 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3561 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3563 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3565 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3566 memcpy(param
->operand_byte_stream
, byte_seq
,
3567 param
->operand_len
);
3568 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3571 mrule
->num_of_fields
++;
3574 if (!mrule
->pkt_type
) {
3575 mwifiex_dbg(priv
->adapter
, ERROR
,
3576 "Packet type can not be determined\n");
3583 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3584 struct cfg80211_coalesce
*coalesce
)
3586 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3588 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3589 struct mwifiex_private
*priv
=
3590 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3592 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3594 mwifiex_dbg(adapter
, WARN
,
3595 "Disable coalesce and reset all previous rules\n");
3596 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3597 HostCmd_ACT_GEN_SET
, 0,
3598 &coalesce_cfg
, true);
3601 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3602 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3603 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3604 &coalesce_cfg
.rule
[i
]);
3606 mwifiex_dbg(adapter
, ERROR
,
3607 "Recheck the patterns provided for rule %d\n",
3613 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3614 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3617 /* cfg80211 ops handler for tdls_mgmt.
3618 * Function prepares TDLS action frame packets and forwards them to FW
3621 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3622 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3623 u16 status_code
, u32 peer_capability
,
3624 bool initiator
, const u8
*extra_ies
,
3625 size_t extra_ies_len
)
3627 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3630 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3633 /* make sure we are in station mode and connected */
3634 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3637 switch (action_code
) {
3638 case WLAN_TDLS_SETUP_REQUEST
:
3639 mwifiex_dbg(priv
->adapter
, MSG
,
3640 "Send TDLS Setup Request to %pM status_code=%d\n",
3642 mwifiex_add_auto_tdls_peer(priv
, peer
);
3643 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3644 dialog_token
, status_code
,
3645 extra_ies
, extra_ies_len
);
3647 case WLAN_TDLS_SETUP_RESPONSE
:
3648 mwifiex_add_auto_tdls_peer(priv
, peer
);
3649 mwifiex_dbg(priv
->adapter
, MSG
,
3650 "Send TDLS Setup Response to %pM status_code=%d\n",
3652 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3653 dialog_token
, status_code
,
3654 extra_ies
, extra_ies_len
);
3656 case WLAN_TDLS_SETUP_CONFIRM
:
3657 mwifiex_dbg(priv
->adapter
, MSG
,
3658 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3660 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3661 dialog_token
, status_code
,
3662 extra_ies
, extra_ies_len
);
3664 case WLAN_TDLS_TEARDOWN
:
3665 mwifiex_dbg(priv
->adapter
, MSG
,
3666 "Send TDLS Tear down to %pM\n", peer
);
3667 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3668 dialog_token
, status_code
,
3669 extra_ies
, extra_ies_len
);
3671 case WLAN_TDLS_DISCOVERY_REQUEST
:
3672 mwifiex_dbg(priv
->adapter
, MSG
,
3673 "Send TDLS Discovery Request to %pM\n", peer
);
3674 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3675 dialog_token
, status_code
,
3676 extra_ies
, extra_ies_len
);
3678 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3679 mwifiex_dbg(priv
->adapter
, MSG
,
3680 "Send TDLS Discovery Response to %pM\n", peer
);
3681 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3682 dialog_token
, status_code
,
3683 extra_ies
, extra_ies_len
);
3686 mwifiex_dbg(priv
->adapter
, ERROR
,
3687 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3696 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3697 const u8
*peer
, enum nl80211_tdls_operation action
)
3699 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3701 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3702 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3705 /* make sure we are in station mode and connected */
3706 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3709 mwifiex_dbg(priv
->adapter
, MSG
,
3710 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3713 case NL80211_TDLS_ENABLE_LINK
:
3714 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3716 case NL80211_TDLS_DISABLE_LINK
:
3717 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3719 case NL80211_TDLS_TEARDOWN
:
3720 /* shouldn't happen!*/
3721 mwifiex_dbg(priv
->adapter
, ERROR
,
3722 "tdls_oper: teardown from driver not supported\n");
3724 case NL80211_TDLS_SETUP
:
3725 /* shouldn't happen!*/
3726 mwifiex_dbg(priv
->adapter
, ERROR
,
3727 "tdls_oper: setup from driver not supported\n");
3729 case NL80211_TDLS_DISCOVERY_REQ
:
3730 /* shouldn't happen!*/
3731 mwifiex_dbg(priv
->adapter
, ERROR
,
3732 "tdls_oper: discovery from driver not supported\n");
3735 mwifiex_dbg(priv
->adapter
, ERROR
,
3736 "tdls_oper: operation not supported\n");
3740 return mwifiex_tdls_oper(priv
, peer
, action
);
3744 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3745 const u8
*addr
, u8 oper_class
,
3746 struct cfg80211_chan_def
*chandef
)
3748 struct mwifiex_sta_node
*sta_ptr
;
3749 unsigned long flags
;
3751 u8 second_chan_offset
, band
;
3752 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3754 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3755 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3756 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3759 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3764 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3765 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3766 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3770 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3771 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3772 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3776 chan
= chandef
->chan
->hw_value
;
3777 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3778 band
= chandef
->chan
->band
;
3779 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3785 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3786 struct net_device
*dev
,
3789 struct mwifiex_sta_node
*sta_ptr
;
3790 unsigned long flags
;
3791 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3793 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3794 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3795 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3798 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3800 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3801 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3802 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3803 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3806 mwifiex_stop_tdls_cs(priv
, addr
);
3810 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3811 const u8
*mac
, struct station_parameters
*params
)
3813 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3815 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3818 /* make sure we are in station mode and connected */
3819 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3822 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3826 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3827 struct cfg80211_csa_settings
*params
)
3829 struct ieee_types_header
*chsw_ie
;
3830 struct ieee80211_channel_sw_ie
*channel_sw
;
3832 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3834 if (priv
->adapter
->scan_processing
) {
3835 mwifiex_dbg(priv
->adapter
, ERROR
,
3836 "radar detection: scan in process...\n");
3840 if (priv
->wdev
.cac_started
)
3843 if (cfg80211_chandef_identical(¶ms
->chandef
,
3844 &priv
->dfs_chandef
))
3847 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3848 params
->beacon_csa
.tail
,
3849 params
->beacon_csa
.tail_len
);
3851 mwifiex_dbg(priv
->adapter
, ERROR
,
3852 "Could not parse channel switch announcement IE\n");
3856 channel_sw
= (void *)(chsw_ie
+ 1);
3857 if (channel_sw
->mode
) {
3858 if (netif_carrier_ok(priv
->netdev
))
3859 netif_carrier_off(priv
->netdev
);
3860 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3863 if (mwifiex_del_mgmt_ies(priv
))
3864 mwifiex_dbg(priv
->adapter
, ERROR
,
3865 "Failed to delete mgmt IEs!\n");
3867 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3868 mwifiex_dbg(priv
->adapter
, ERROR
,
3869 "%s: setting mgmt ies failed\n", __func__
);
3873 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3874 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3875 sizeof(priv
->beacon_after
));
3877 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3878 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3879 msecs_to_jiffies(chsw_msec
));
3883 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3884 struct wireless_dev
*wdev
,
3885 struct cfg80211_chan_def
*chandef
)
3887 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3888 struct mwifiex_bssdescriptor
*curr_bss
;
3889 struct ieee80211_channel
*chan
;
3890 u8 second_chan_offset
;
3891 enum nl80211_channel_type chan_type
;
3892 enum nl80211_band band
;
3896 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3897 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3898 *chandef
= priv
->bss_chandef
;
3900 } else if (priv
->media_connected
) {
3901 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3902 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3903 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3904 chan
= ieee80211_get_channel(wiphy
, freq
);
3906 if (priv
->ht_param_present
) {
3907 second_chan_offset
= priv
->assoc_resp_ht_param
&
3908 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3909 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3910 (second_chan_offset
);
3911 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3913 cfg80211_chandef_create(chandef
, chan
,
3914 NL80211_CHAN_NO_HT
);
3922 #ifdef CONFIG_NL80211_TESTMODE
3924 enum mwifiex_tm_attr
{
3925 __MWIFIEX_TM_ATTR_INVALID
= 0,
3926 MWIFIEX_TM_ATTR_CMD
= 1,
3927 MWIFIEX_TM_ATTR_DATA
= 2,
3930 __MWIFIEX_TM_ATTR_AFTER_LAST
,
3931 MWIFIEX_TM_ATTR_MAX
= __MWIFIEX_TM_ATTR_AFTER_LAST
- 1,
3934 static const struct nla_policy mwifiex_tm_policy
[MWIFIEX_TM_ATTR_MAX
+ 1] = {
3935 [MWIFIEX_TM_ATTR_CMD
] = { .type
= NLA_U32
},
3936 [MWIFIEX_TM_ATTR_DATA
] = { .type
= NLA_BINARY
,
3937 .len
= MWIFIEX_SIZE_OF_CMD_BUFFER
},
3940 enum mwifiex_tm_command
{
3941 MWIFIEX_TM_CMD_HOSTCMD
= 0,
3944 static int mwifiex_tm_cmd(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
3945 void *data
, int len
)
3947 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3948 struct mwifiex_ds_misc_cmd
*hostcmd
;
3949 struct nlattr
*tb
[MWIFIEX_TM_ATTR_MAX
+ 1];
3950 struct mwifiex_adapter
*adapter
;
3951 struct sk_buff
*skb
;
3956 adapter
= priv
->adapter
;
3958 err
= nla_parse(tb
, MWIFIEX_TM_ATTR_MAX
, data
, len
,
3963 if (!tb
[MWIFIEX_TM_ATTR_CMD
])
3966 switch (nla_get_u32(tb
[MWIFIEX_TM_ATTR_CMD
])) {
3967 case MWIFIEX_TM_CMD_HOSTCMD
:
3968 if (!tb
[MWIFIEX_TM_ATTR_DATA
])
3971 hostcmd
= kzalloc(sizeof(*hostcmd
), GFP_KERNEL
);
3975 hostcmd
->len
= nla_len(tb
[MWIFIEX_TM_ATTR_DATA
]);
3976 memcpy(hostcmd
->cmd
, nla_data(tb
[MWIFIEX_TM_ATTR_DATA
]),
3979 if (mwifiex_send_cmd(priv
, 0, 0, 0, hostcmd
, true)) {
3980 dev_err(priv
->adapter
->dev
, "Failed to process hostcmd\n");
3984 /* process hostcmd response*/
3985 skb
= cfg80211_testmode_alloc_reply_skb(wiphy
, hostcmd
->len
);
3988 err
= nla_put(skb
, MWIFIEX_TM_ATTR_DATA
,
3989 hostcmd
->len
, hostcmd
->cmd
);
3995 err
= cfg80211_testmode_reply(skb
);
4005 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
4006 struct net_device
*dev
,
4007 struct cfg80211_chan_def
*chandef
,
4010 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4011 struct mwifiex_radar_params radar_params
;
4013 if (priv
->adapter
->scan_processing
) {
4014 mwifiex_dbg(priv
->adapter
, ERROR
,
4015 "radar detection: scan already in process...\n");
4019 if (!mwifiex_is_11h_active(priv
)) {
4020 mwifiex_dbg(priv
->adapter
, INFO
,
4021 "Enable 11h extensions in FW\n");
4022 if (mwifiex_11h_activate(priv
, true)) {
4023 mwifiex_dbg(priv
->adapter
, ERROR
,
4024 "Failed to activate 11h extensions!!");
4027 priv
->state_11h
.is_11h_active
= true;
4030 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
4031 radar_params
.chandef
= chandef
;
4032 radar_params
.cac_time_ms
= cac_time_ms
;
4034 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
4036 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
4037 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
4040 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
4041 msecs_to_jiffies(cac_time_ms
));
4046 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
4048 struct station_parameters
*params
)
4051 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
4053 /* we support change_station handler only for TDLS peers*/
4054 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
4057 /* make sure we are in station mode and connected */
4058 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
4061 priv
->sta_params
= params
;
4063 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
4064 priv
->sta_params
= NULL
;
4069 /* station cfg80211 operations */
4070 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
4071 .add_virtual_intf
= mwifiex_add_virtual_intf
,
4072 .del_virtual_intf
= mwifiex_del_virtual_intf
,
4073 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
4074 .scan
= mwifiex_cfg80211_scan
,
4075 .connect
= mwifiex_cfg80211_connect
,
4076 .disconnect
= mwifiex_cfg80211_disconnect
,
4077 .get_station
= mwifiex_cfg80211_get_station
,
4078 .dump_station
= mwifiex_cfg80211_dump_station
,
4079 .dump_survey
= mwifiex_cfg80211_dump_survey
,
4080 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
4081 .join_ibss
= mwifiex_cfg80211_join_ibss
,
4082 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
4083 .add_key
= mwifiex_cfg80211_add_key
,
4084 .del_key
= mwifiex_cfg80211_del_key
,
4085 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
4086 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
4087 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
4088 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
4089 .set_default_key
= mwifiex_cfg80211_set_default_key
,
4090 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
4091 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
4092 .get_tx_power
= mwifiex_cfg80211_get_tx_power
,
4093 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
4094 .start_ap
= mwifiex_cfg80211_start_ap
,
4095 .stop_ap
= mwifiex_cfg80211_stop_ap
,
4096 .change_beacon
= mwifiex_cfg80211_change_beacon
,
4097 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
4098 .set_antenna
= mwifiex_cfg80211_set_antenna
,
4099 .get_antenna
= mwifiex_cfg80211_get_antenna
,
4100 .del_station
= mwifiex_cfg80211_del_station
,
4101 .sched_scan_start
= mwifiex_cfg80211_sched_scan_start
,
4102 .sched_scan_stop
= mwifiex_cfg80211_sched_scan_stop
,
4104 .suspend
= mwifiex_cfg80211_suspend
,
4105 .resume
= mwifiex_cfg80211_resume
,
4106 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
4107 .set_rekey_data
= mwifiex_set_rekey_data
,
4109 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
4110 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
4111 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
4112 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
4113 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
4114 .add_station
= mwifiex_cfg80211_add_station
,
4115 .change_station
= mwifiex_cfg80211_change_station
,
4116 CFG80211_TESTMODE_CMD(mwifiex_tm_cmd
)
4117 .get_channel
= mwifiex_cfg80211_get_channel
,
4118 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
4119 .channel_switch
= mwifiex_cfg80211_channel_switch
,
4123 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
4124 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
4125 WIPHY_WOWLAN_NET_DETECT
| WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
4126 WIPHY_WOWLAN_GTK_REKEY_FAILURE
,
4127 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
4128 .pattern_min_len
= 1,
4129 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4130 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4131 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
4135 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
4137 if (!alpha2
|| strlen(alpha2
) != 2)
4140 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
4146 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
4147 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
4148 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
4149 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
4150 .pattern_min_len
= 1,
4151 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
4152 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
4155 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
4157 u32 n_channels_bg
, n_channels_a
= 0;
4159 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
4161 if (adapter
->config_bands
& BAND_A
)
4162 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
4164 adapter
->num_in_chan_stats
= max_t(u32
, n_channels_bg
, n_channels_a
);
4165 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
4166 adapter
->num_in_chan_stats
);
4168 if (!adapter
->chan_stats
)
4175 * This function registers the device with CFG802.11 subsystem.
4177 * The function creates the wireless device/wiphy, populates it with
4178 * default parameters and handler function pointers, and finally
4179 * registers the device.
4182 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
4186 struct wiphy
*wiphy
;
4187 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
4191 /* create a new wiphy for use with cfg80211 */
4192 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
4193 sizeof(struct mwifiex_adapter
*));
4195 mwifiex_dbg(adapter
, ERROR
,
4196 "%s: creating new wiphy\n", __func__
);
4199 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4200 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4201 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
4202 wiphy
->max_remain_on_channel_duration
= 5000;
4203 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
4204 BIT(NL80211_IFTYPE_ADHOC
) |
4205 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
4206 BIT(NL80211_IFTYPE_P2P_GO
) |
4207 BIT(NL80211_IFTYPE_AP
);
4209 wiphy
->bands
[NL80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
4210 if (adapter
->config_bands
& BAND_A
)
4211 wiphy
->bands
[NL80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
4213 wiphy
->bands
[NL80211_BAND_5GHZ
] = NULL
;
4215 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
4216 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
4217 else if (adapter
->is_hw_11ac_capable
)
4218 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
4220 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
4221 wiphy
->n_iface_combinations
= 1;
4223 /* Initialize cipher suits */
4224 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
4225 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
4227 if (adapter
->regd
) {
4228 wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
4229 REGULATORY_DISABLE_BEACON_HINTS
|
4230 REGULATORY_COUNTRY_IE_IGNORE
;
4231 wiphy_apply_custom_regulatory(wiphy
, adapter
->regd
);
4234 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
4235 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
4236 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
4237 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
4238 WIPHY_FLAG_AP_UAPSD
|
4239 WIPHY_FLAG_SUPPORTS_SCHED_SCAN
|
4240 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
4241 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
4242 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
4244 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4245 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
4246 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
4249 wiphy
->wowlan
= &mwifiex_wowlan_support
;
4252 wiphy
->coalesce
= &mwifiex_coalesce_support
;
4254 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
4255 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
4256 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
4258 wiphy
->max_sched_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4259 wiphy
->max_sched_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4260 wiphy
->max_match_sets
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4262 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
4263 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
4265 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
4266 NL80211_FEATURE_INACTIVITY_TIMER
|
4267 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
4268 NL80211_FEATURE_NEED_OBSS_SCAN
|
4269 NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR
|
4270 NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR
|
4271 NL80211_FEATURE_ND_RANDOM_MAC_ADDR
;
4273 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4274 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
4276 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
4277 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
4279 /* Reserve space for mwifiex specific private data for BSS */
4280 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
4282 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
4284 /* Set struct mwifiex_adapter pointer in wiphy_priv */
4285 wdev_priv
= wiphy_priv(wiphy
);
4286 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
4288 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
4290 ret
= wiphy_register(wiphy
);
4292 mwifiex_dbg(adapter
, ERROR
,
4293 "%s: wiphy_register failed: %d\n", __func__
, ret
);
4298 if (!adapter
->regd
) {
4299 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
4300 mwifiex_dbg(adapter
, INFO
,
4301 "driver hint alpha2: %2.2s\n", reg_alpha2
);
4302 regulatory_hint(wiphy
, reg_alpha2
);
4304 if (adapter
->region_code
== 0x00) {
4305 mwifiex_dbg(adapter
, WARN
,
4306 "Ignore world regulatory domain\n");
4308 wiphy
->regulatory_flags
|=
4309 REGULATORY_DISABLE_BEACON_HINTS
|
4310 REGULATORY_COUNTRY_IE_IGNORE
;
4312 mwifiex_11d_code_2_region(
4313 adapter
->region_code
);
4315 regulatory_hint(wiphy
, country_code
))
4316 mwifiex_dbg(priv
->adapter
, ERROR
,
4317 "regulatory_hint() failed\n");
4322 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4323 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
4324 wiphy
->frag_threshold
= thr
;
4325 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4326 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
4327 wiphy
->rts_threshold
= thr
;
4328 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4329 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
4330 wiphy
->retry_short
= (u8
) retry
;
4331 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4332 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
4333 wiphy
->retry_long
= (u8
) retry
;
4335 adapter
->wiphy
= wiphy
;