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.
24 static char *reg_alpha2
;
25 module_param(reg_alpha2
, charp
, 0);
27 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits
[] = {
29 .max
= 2, .types
= BIT(NL80211_IFTYPE_STATION
) |
30 BIT(NL80211_IFTYPE_P2P_GO
) |
31 BIT(NL80211_IFTYPE_P2P_CLIENT
),
34 .max
= 1, .types
= BIT(NL80211_IFTYPE_AP
),
38 static const struct ieee80211_iface_combination 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,
47 * This function maps the nl802.11 channel type into driver channel type.
49 * The mapping is as follows -
50 * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE
51 * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE
52 * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE
53 * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW
54 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE
56 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
)
59 case NL80211_CHAN_NO_HT
:
60 case NL80211_CHAN_HT20
:
61 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
62 case NL80211_CHAN_HT40PLUS
:
63 return IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
64 case NL80211_CHAN_HT40MINUS
:
65 return IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
67 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
71 /* This function maps IEEE HT secondary channel type to NL80211 channel type
73 u8
mwifiex_sec_chan_offset_to_chan_type(u8 second_chan_offset
)
75 switch (second_chan_offset
) {
76 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
77 return NL80211_CHAN_HT20
;
78 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
79 return NL80211_CHAN_HT40PLUS
;
80 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
81 return NL80211_CHAN_HT40MINUS
;
83 return NL80211_CHAN_HT20
;
88 * This function checks whether WEP is set.
91 mwifiex_is_alg_wep(u32 cipher
)
94 case WLAN_CIPHER_SUITE_WEP40
:
95 case WLAN_CIPHER_SUITE_WEP104
:
105 * This function retrieves the private structure from kernel wiphy structure.
107 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
109 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
113 * CFG802.11 operation handler to delete a network key.
116 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
117 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
119 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
120 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
121 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
123 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
124 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
128 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
133 * This function forms an skb for management frame.
136 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
138 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
140 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
142 pkt_len
= len
+ ETH_ALEN
;
144 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
145 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
146 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
148 memcpy(skb_push(skb
, sizeof(tx_control
)),
149 &tx_control
, sizeof(tx_control
));
151 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
153 /* Add packet data and address4 */
154 memcpy(skb_put(skb
, sizeof(struct ieee80211_hdr_3addr
)), buf
,
155 sizeof(struct ieee80211_hdr_3addr
));
156 memcpy(skb_put(skb
, ETH_ALEN
), addr
, ETH_ALEN
);
157 memcpy(skb_put(skb
, len
- sizeof(struct ieee80211_hdr_3addr
)),
158 buf
+ sizeof(struct ieee80211_hdr_3addr
),
159 len
- sizeof(struct ieee80211_hdr_3addr
));
161 skb
->priority
= LOW_PRIO_TID
;
162 __net_timestamp(skb
);
168 * CFG802.11 operation handler to transmit a management frame.
171 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
172 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
174 const u8
*buf
= params
->buf
;
175 size_t len
= params
->len
;
178 const struct ieee80211_mgmt
*mgmt
;
179 struct mwifiex_txinfo
*tx_info
;
180 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
183 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
187 mgmt
= (const struct ieee80211_mgmt
*)buf
;
188 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
189 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
190 /* Since we support offload probe resp, we need to skip probe
191 * resp in AP or GO mode */
192 mwifiex_dbg(priv
->adapter
, INFO
,
193 "info: skip to send probe resp in AP or GO mode\n");
197 pkt_len
= len
+ ETH_ALEN
;
198 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
199 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
200 pkt_len
+ sizeof(pkt_len
));
203 mwifiex_dbg(priv
->adapter
, ERROR
,
204 "allocate skb failed for management frame\n");
208 tx_info
= MWIFIEX_SKB_TXCB(skb
);
209 memset(tx_info
, 0, sizeof(*tx_info
));
210 tx_info
->bss_num
= priv
->bss_num
;
211 tx_info
->bss_type
= priv
->bss_type
;
212 tx_info
->pkt_len
= pkt_len
;
214 mwifiex_form_mgmt_frame(skb
, buf
, len
);
215 *cookie
= prandom_u32() | 1;
217 if (ieee80211_is_action(mgmt
->frame_control
))
218 skb
= mwifiex_clone_skb_for_tx_status(priv
,
220 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
222 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
225 mwifiex_queue_tx_pkt(priv
, skb
);
227 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
232 * CFG802.11 operation handler to register a mgmt frame.
235 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
236 struct wireless_dev
*wdev
,
237 u16 frame_type
, bool reg
)
239 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
243 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
245 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
247 if (mask
!= priv
->mgmt_frame_mask
) {
248 priv
->mgmt_frame_mask
= mask
;
249 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
250 HostCmd_ACT_GEN_SET
, 0,
251 &priv
->mgmt_frame_mask
, false);
252 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
257 * CFG802.11 operation handler to remain on channel.
260 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
261 struct wireless_dev
*wdev
,
262 struct ieee80211_channel
*chan
,
263 unsigned int duration
, u64
*cookie
)
265 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
268 if (!chan
|| !cookie
) {
269 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
273 if (priv
->roc_cfg
.cookie
) {
274 mwifiex_dbg(priv
->adapter
, INFO
,
275 "info: ongoing ROC, cookie = 0x%llx\n",
276 priv
->roc_cfg
.cookie
);
280 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
284 *cookie
= prandom_u32() | 1;
285 priv
->roc_cfg
.cookie
= *cookie
;
286 priv
->roc_cfg
.chan
= *chan
;
288 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
289 duration
, GFP_ATOMIC
);
291 mwifiex_dbg(priv
->adapter
, INFO
,
292 "info: ROC, cookie = 0x%llx\n", *cookie
);
299 * CFG802.11 operation handler to cancel remain on channel.
302 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
303 struct wireless_dev
*wdev
, u64 cookie
)
305 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
308 if (cookie
!= priv
->roc_cfg
.cookie
)
311 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
312 &priv
->roc_cfg
.chan
, 0);
315 cfg80211_remain_on_channel_expired(wdev
, cookie
,
319 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
321 mwifiex_dbg(priv
->adapter
, INFO
,
322 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
329 * CFG802.11 operation handler to set Tx power.
332 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
333 struct wireless_dev
*wdev
,
334 enum nl80211_tx_power_setting type
,
337 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
338 struct mwifiex_private
*priv
;
339 struct mwifiex_power_cfg power_cfg
;
340 int dbm
= MBM_TO_DBM(mbm
);
342 if (type
== NL80211_TX_POWER_FIXED
) {
343 power_cfg
.is_power_auto
= 0;
344 power_cfg
.power_level
= dbm
;
346 power_cfg
.is_power_auto
= 1;
349 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
351 return mwifiex_set_tx_power(priv
, &power_cfg
);
355 * CFG802.11 operation handler to set Power Save option.
357 * The timeout value, if provided, is currently ignored.
360 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
361 struct net_device
*dev
,
362 bool enabled
, int timeout
)
364 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
368 mwifiex_dbg(priv
->adapter
, INFO
,
369 "info: ignore timeout value for IEEE Power Save\n");
373 return mwifiex_drv_set_power(priv
, &ps_mode
);
377 * CFG802.11 operation handler to set the default network key.
380 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
381 u8 key_index
, bool unicast
,
384 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
386 /* Return if WEP key not configured */
387 if (!priv
->sec_info
.wep_enabled
)
390 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
391 priv
->wep_key_curr_index
= key_index
;
392 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
394 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
402 * CFG802.11 operation handler to add a network key.
405 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
406 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
407 struct key_params
*params
)
409 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
410 struct mwifiex_wep_key
*wep_key
;
411 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
412 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
414 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
415 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
416 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
417 if (params
->key
&& params
->key_len
) {
418 wep_key
= &priv
->wep_key
[key_index
];
419 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
420 memcpy(wep_key
->key_material
, params
->key
,
422 wep_key
->key_index
= key_index
;
423 wep_key
->key_length
= params
->key_len
;
424 priv
->sec_info
.wep_enabled
= 1;
429 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
430 key_index
, peer_mac
, 0)) {
431 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
439 * This function sends domain information to the firmware.
441 * The following information are passed to the firmware -
443 * - Sub bands (first channel, number of channels, maximum Tx power)
445 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
447 u8 no_of_triplet
= 0;
448 struct ieee80211_country_ie_triplet
*t
;
449 u8 no_of_parsed_chan
= 0;
450 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
452 enum ieee80211_band band
;
453 struct ieee80211_supported_band
*sband
;
454 struct ieee80211_channel
*ch
;
455 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
456 struct mwifiex_private
*priv
;
457 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
459 /* Set country code */
460 domain_info
->country_code
[0] = adapter
->country_code
[0];
461 domain_info
->country_code
[1] = adapter
->country_code
[1];
462 domain_info
->country_code
[2] = ' ';
464 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
465 if (!wiphy
->bands
[band
]) {
466 mwifiex_dbg(adapter
, ERROR
,
467 "11D: setting domain info in FW\n");
471 sband
= wiphy
->bands
[band
];
473 for (i
= 0; i
< sband
->n_channels
; i
++) {
474 ch
= &sband
->channels
[i
];
475 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
480 first_chan
= (u32
) ch
->hw_value
;
481 next_chan
= first_chan
;
482 max_pwr
= ch
->max_power
;
483 no_of_parsed_chan
= 1;
487 if (ch
->hw_value
== next_chan
+ 1 &&
488 ch
->max_power
== max_pwr
) {
492 t
= &domain_info
->triplet
[no_of_triplet
];
493 t
->chans
.first_channel
= first_chan
;
494 t
->chans
.num_channels
= no_of_parsed_chan
;
495 t
->chans
.max_power
= max_pwr
;
497 first_chan
= (u32
) ch
->hw_value
;
498 next_chan
= first_chan
;
499 max_pwr
= ch
->max_power
;
500 no_of_parsed_chan
= 1;
505 t
= &domain_info
->triplet
[no_of_triplet
];
506 t
->chans
.first_channel
= first_chan
;
507 t
->chans
.num_channels
= no_of_parsed_chan
;
508 t
->chans
.max_power
= max_pwr
;
512 domain_info
->no_of_triplet
= no_of_triplet
;
514 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
516 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
517 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
518 mwifiex_dbg(adapter
, INFO
,
519 "11D: setting domain info in FW\n");
527 * CFG802.11 regulatory domain callback function.
529 * This function is called when the regulatory domain is changed due to the
530 * following reasons -
532 * - Set by system core
534 * - Set bt Country IE
536 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
537 struct regulatory_request
*request
)
539 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
540 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
541 MWIFIEX_BSS_ROLE_ANY
);
542 mwifiex_dbg(adapter
, INFO
,
543 "info: cfg80211 regulatory domain callback for %c%c\n",
544 request
->alpha2
[0], request
->alpha2
[1]);
546 switch (request
->initiator
) {
547 case NL80211_REGDOM_SET_BY_DRIVER
:
548 case NL80211_REGDOM_SET_BY_CORE
:
549 case NL80211_REGDOM_SET_BY_USER
:
550 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
553 mwifiex_dbg(adapter
, ERROR
,
554 "unknown regdom initiator: %d\n",
559 /* Don't send world or same regdom info to firmware */
560 if (strncmp(request
->alpha2
, "00", 2) &&
561 strncmp(request
->alpha2
, adapter
->country_code
,
562 sizeof(request
->alpha2
))) {
563 memcpy(adapter
->country_code
, request
->alpha2
,
564 sizeof(request
->alpha2
));
565 mwifiex_send_domain_info_cmd_fw(wiphy
);
566 mwifiex_dnld_txpwr_table(priv
);
571 * This function sets the fragmentation threshold.
573 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
574 * and MWIFIEX_FRAG_MAX_VALUE.
577 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
579 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
580 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
581 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
583 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
584 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
589 * This function sets the RTS threshold.
591 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
592 * and MWIFIEX_RTS_MAX_VALUE.
595 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
597 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
598 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
600 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
601 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
606 * CFG802.11 operation handler to set wiphy parameters.
608 * This function can be used to set the RTS threshold and the
609 * Fragmentation threshold of the driver.
612 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
614 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
615 struct mwifiex_private
*priv
;
616 struct mwifiex_uap_bss_param
*bss_cfg
;
619 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
621 switch (priv
->bss_role
) {
622 case MWIFIEX_BSS_ROLE_UAP
:
623 if (priv
->bss_started
) {
624 mwifiex_dbg(adapter
, ERROR
,
625 "cannot change wiphy params when bss started");
629 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
633 mwifiex_set_sys_config_invalid_data(bss_cfg
);
635 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
636 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
637 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
638 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
639 if (changed
& WIPHY_PARAM_RETRY_LONG
)
640 bss_cfg
->retry_limit
= wiphy
->retry_long
;
642 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
644 UAP_BSS_PARAMS_I
, bss_cfg
,
649 mwifiex_dbg(adapter
, ERROR
,
650 "Failed to set wiphy phy params\n");
655 case MWIFIEX_BSS_ROLE_STA
:
656 if (priv
->media_connected
) {
657 mwifiex_dbg(adapter
, ERROR
,
658 "cannot change wiphy params when connected");
661 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
662 ret
= mwifiex_set_rts(priv
,
663 wiphy
->rts_threshold
);
667 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
668 ret
= mwifiex_set_frag(priv
,
669 wiphy
->frag_threshold
);
680 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
682 u16 mode
= P2P_MODE_DISABLE
;
684 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
685 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
692 * This function initializes the functionalities for P2P client.
693 * The P2P client initialization sequence is:
694 * disable -> device -> client
697 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
701 if (mwifiex_cfg80211_deinit_p2p(priv
))
704 mode
= P2P_MODE_DEVICE
;
705 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
706 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
709 mode
= P2P_MODE_CLIENT
;
710 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
711 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
718 * This function initializes the functionalities for P2P GO.
719 * The P2P GO initialization sequence is:
720 * disable -> device -> GO
723 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
727 if (mwifiex_cfg80211_deinit_p2p(priv
))
730 mode
= P2P_MODE_DEVICE
;
731 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
732 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
736 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
737 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
743 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
745 struct mwifiex_adapter
*adapter
= priv
->adapter
;
748 priv
->mgmt_frame_mask
= 0;
749 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
750 HostCmd_ACT_GEN_SET
, 0,
751 &priv
->mgmt_frame_mask
, false)) {
752 mwifiex_dbg(adapter
, ERROR
,
753 "could not unregister mgmt frame rx\n");
757 mwifiex_deauthenticate(priv
, NULL
);
759 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
760 adapter
->main_locked
= true;
761 if (adapter
->mwifiex_processing
) {
762 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
763 flush_workqueue(adapter
->workqueue
);
765 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
768 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
769 adapter
->rx_locked
= true;
770 if (adapter
->rx_processing
) {
771 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
772 flush_workqueue(adapter
->rx_workqueue
);
774 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
777 mwifiex_free_priv(priv
);
778 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
779 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
780 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
786 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
787 struct net_device
*dev
,
788 enum nl80211_iftype type
)
790 struct mwifiex_adapter
*adapter
= priv
->adapter
;
793 mwifiex_init_priv(priv
);
795 priv
->bss_mode
= type
;
796 priv
->wdev
.iftype
= type
;
798 mwifiex_init_priv_params(priv
, priv
->netdev
);
799 priv
->bss_started
= 0;
802 case NL80211_IFTYPE_STATION
:
803 case NL80211_IFTYPE_ADHOC
:
804 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
805 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
807 case NL80211_IFTYPE_P2P_CLIENT
:
808 case NL80211_IFTYPE_P2P_GO
:
809 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
810 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
812 case NL80211_IFTYPE_AP
:
813 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
814 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
817 mwifiex_dbg(adapter
, ERROR
,
818 "%s: changing to %d not supported\n",
823 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
824 adapter
->main_locked
= false;
825 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
827 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
828 adapter
->rx_locked
= false;
829 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
835 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
836 enum nl80211_iftype curr_iftype
,
837 enum nl80211_iftype type
, u32
*flags
,
838 struct vif_params
*params
)
840 struct mwifiex_private
*priv
;
841 struct mwifiex_adapter
*adapter
;
843 priv
= mwifiex_netdev_get_priv(dev
);
848 adapter
= priv
->adapter
;
850 if (adapter
->curr_iface_comb
.p2p_intf
==
851 adapter
->iface_limit
.p2p_intf
) {
852 mwifiex_dbg(adapter
, ERROR
,
853 "cannot create multiple P2P ifaces\n");
857 mwifiex_dbg(adapter
, INFO
,
858 "%s: changing role to p2p\n", dev
->name
);
860 if (mwifiex_deinit_priv_params(priv
))
862 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
866 case NL80211_IFTYPE_P2P_CLIENT
:
867 if (mwifiex_cfg80211_init_p2p_client(priv
))
870 case NL80211_IFTYPE_P2P_GO
:
871 if (mwifiex_cfg80211_init_p2p_go(priv
))
875 mwifiex_dbg(adapter
, ERROR
,
876 "%s: changing to %d not supported\n",
881 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
882 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
885 if (mwifiex_sta_init_cmd(priv
, false, false))
888 switch (curr_iftype
) {
889 case NL80211_IFTYPE_STATION
:
890 case NL80211_IFTYPE_ADHOC
:
891 adapter
->curr_iface_comb
.sta_intf
--;
893 case NL80211_IFTYPE_AP
:
894 adapter
->curr_iface_comb
.uap_intf
--;
900 adapter
->curr_iface_comb
.p2p_intf
++;
901 dev
->ieee80211_ptr
->iftype
= type
;
907 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
908 enum nl80211_iftype curr_iftype
,
909 enum nl80211_iftype type
, u32
*flags
,
910 struct vif_params
*params
)
912 struct mwifiex_private
*priv
;
913 struct mwifiex_adapter
*adapter
;
915 priv
= mwifiex_netdev_get_priv(dev
);
920 adapter
= priv
->adapter
;
922 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
923 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
924 (adapter
->curr_iface_comb
.sta_intf
==
925 adapter
->iface_limit
.sta_intf
)) {
926 mwifiex_dbg(adapter
, ERROR
,
927 "cannot create multiple station/adhoc ifaces\n");
931 if (type
== NL80211_IFTYPE_STATION
)
932 mwifiex_dbg(adapter
, INFO
,
933 "%s: changing role to station\n", dev
->name
);
935 mwifiex_dbg(adapter
, INFO
,
936 "%s: changing role to adhoc\n", dev
->name
);
938 if (mwifiex_deinit_priv_params(priv
))
940 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
942 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
943 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
945 if (mwifiex_sta_init_cmd(priv
, false, false))
948 switch (curr_iftype
) {
949 case NL80211_IFTYPE_P2P_CLIENT
:
950 case NL80211_IFTYPE_P2P_GO
:
951 adapter
->curr_iface_comb
.p2p_intf
--;
953 case NL80211_IFTYPE_AP
:
954 adapter
->curr_iface_comb
.uap_intf
--;
960 adapter
->curr_iface_comb
.sta_intf
++;
961 dev
->ieee80211_ptr
->iftype
= type
;
966 mwifiex_change_vif_to_ap(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 (adapter
->curr_iface_comb
.uap_intf
==
982 adapter
->iface_limit
.uap_intf
) {
983 mwifiex_dbg(adapter
, ERROR
,
984 "cannot create multiple AP ifaces\n");
988 mwifiex_dbg(adapter
, INFO
,
989 "%s: changing role to AP\n", dev
->name
);
991 if (mwifiex_deinit_priv_params(priv
))
993 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
995 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
996 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
998 if (mwifiex_sta_init_cmd(priv
, false, false))
1001 switch (curr_iftype
) {
1002 case NL80211_IFTYPE_P2P_CLIENT
:
1003 case NL80211_IFTYPE_P2P_GO
:
1004 adapter
->curr_iface_comb
.p2p_intf
--;
1006 case NL80211_IFTYPE_STATION
:
1007 case NL80211_IFTYPE_ADHOC
:
1008 adapter
->curr_iface_comb
.sta_intf
--;
1014 adapter
->curr_iface_comb
.uap_intf
++;
1015 dev
->ieee80211_ptr
->iftype
= type
;
1019 * CFG802.11 operation handler to change interface type.
1022 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1023 struct net_device
*dev
,
1024 enum nl80211_iftype type
, u32
*flags
,
1025 struct vif_params
*params
)
1027 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1028 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1030 switch (curr_iftype
) {
1031 case NL80211_IFTYPE_ADHOC
:
1033 case NL80211_IFTYPE_STATION
:
1034 priv
->bss_mode
= type
;
1035 priv
->sec_info
.authentication_mode
=
1036 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1037 dev
->ieee80211_ptr
->iftype
= type
;
1038 mwifiex_deauthenticate(priv
, NULL
);
1039 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1040 HostCmd_ACT_GEN_SET
, 0, NULL
,
1042 case NL80211_IFTYPE_P2P_CLIENT
:
1043 case NL80211_IFTYPE_P2P_GO
:
1044 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1045 type
, flags
, params
);
1046 case NL80211_IFTYPE_AP
:
1047 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1049 case NL80211_IFTYPE_UNSPECIFIED
:
1050 mwifiex_dbg(priv
->adapter
, INFO
,
1051 "%s: kept type as IBSS\n", dev
->name
);
1052 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1055 mwifiex_dbg(priv
->adapter
, ERROR
,
1056 "%s: changing to %d not supported\n",
1061 case NL80211_IFTYPE_STATION
:
1063 case NL80211_IFTYPE_ADHOC
:
1064 priv
->bss_mode
= type
;
1065 priv
->sec_info
.authentication_mode
=
1066 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1067 dev
->ieee80211_ptr
->iftype
= type
;
1068 mwifiex_deauthenticate(priv
, NULL
);
1069 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1070 HostCmd_ACT_GEN_SET
, 0, NULL
,
1072 case NL80211_IFTYPE_P2P_CLIENT
:
1073 case NL80211_IFTYPE_P2P_GO
:
1074 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1075 type
, flags
, params
);
1076 case NL80211_IFTYPE_AP
:
1077 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1079 case NL80211_IFTYPE_UNSPECIFIED
:
1080 mwifiex_dbg(priv
->adapter
, INFO
,
1081 "%s: kept type as STA\n", dev
->name
);
1082 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1085 mwifiex_dbg(priv
->adapter
, ERROR
,
1086 "%s: changing to %d not supported\n",
1091 case NL80211_IFTYPE_AP
:
1093 case NL80211_IFTYPE_ADHOC
:
1094 case NL80211_IFTYPE_STATION
:
1095 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1099 case NL80211_IFTYPE_P2P_CLIENT
:
1100 case NL80211_IFTYPE_P2P_GO
:
1101 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1102 type
, flags
, params
);
1103 case NL80211_IFTYPE_UNSPECIFIED
:
1104 mwifiex_dbg(priv
->adapter
, INFO
,
1105 "%s: kept type as AP\n", dev
->name
);
1106 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1109 mwifiex_dbg(priv
->adapter
, ERROR
,
1110 "%s: changing to %d not supported\n",
1115 case NL80211_IFTYPE_P2P_CLIENT
:
1116 case NL80211_IFTYPE_P2P_GO
:
1118 case NL80211_IFTYPE_STATION
:
1119 if (mwifiex_cfg80211_init_p2p_client(priv
))
1121 dev
->ieee80211_ptr
->iftype
= type
;
1123 case NL80211_IFTYPE_ADHOC
:
1124 if (mwifiex_cfg80211_deinit_p2p(priv
))
1126 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1130 case NL80211_IFTYPE_AP
:
1131 if (mwifiex_cfg80211_deinit_p2p(priv
))
1133 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1135 case NL80211_IFTYPE_UNSPECIFIED
:
1136 mwifiex_dbg(priv
->adapter
, INFO
,
1137 "%s: kept type as P2P\n", dev
->name
);
1138 case NL80211_IFTYPE_P2P_CLIENT
:
1139 case NL80211_IFTYPE_P2P_GO
:
1142 mwifiex_dbg(priv
->adapter
, ERROR
,
1143 "%s: changing to %d not supported\n",
1149 mwifiex_dbg(priv
->adapter
, ERROR
,
1150 "%s: unknown iftype: %d\n",
1151 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1160 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1161 struct rate_info
*rate
)
1163 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1165 if (adapter
->is_hw_11ac_capable
) {
1166 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1167 if (tx_htinfo
& BIT(0)) {
1169 rate
->mcs
= priv
->tx_rate
;
1170 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1172 if (tx_htinfo
& BIT(1)) {
1174 rate
->mcs
= priv
->tx_rate
& 0x0F;
1175 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1178 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1180 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1182 rate
->bw
= RATE_INFO_BW_20
;
1185 rate
->bw
= RATE_INFO_BW_40
;
1188 rate
->bw
= RATE_INFO_BW_80
;
1190 case (BIT(3) | BIT(2)):
1191 rate
->bw
= RATE_INFO_BW_160
;
1195 if (tx_htinfo
& BIT(4))
1196 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1198 if ((priv
->tx_rate
>> 4) == 1)
1205 * Bit 0 in tx_htinfo indicates that current Tx rate
1206 * is 11n rate. Valid MCS index values for us are 0 to 15.
1208 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1209 rate
->mcs
= priv
->tx_rate
;
1210 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1211 rate
->bw
= RATE_INFO_BW_20
;
1212 if (tx_htinfo
& BIT(1))
1213 rate
->bw
= RATE_INFO_BW_40
;
1214 if (tx_htinfo
& BIT(2))
1215 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1221 * This function dumps the station information on a buffer.
1223 * The following information are shown -
1224 * - Total bytes transmitted
1225 * - Total bytes received
1226 * - Total packets transmitted
1227 * - Total packets received
1228 * - Signal quality level
1229 * - Transmission rate
1232 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1233 struct mwifiex_sta_node
*node
,
1234 struct station_info
*sinfo
)
1238 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1239 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1240 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1241 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1243 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1247 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1248 BIT(NL80211_STA_INFO_TX_FAILED
);
1249 sinfo
->inactive_time
=
1250 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1252 sinfo
->signal
= node
->stats
.rssi
;
1253 sinfo
->signal_avg
= node
->stats
.rssi
;
1254 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1255 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1256 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1257 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1258 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1260 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1262 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1267 /* Get signal information from the firmware */
1268 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1269 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1270 mwifiex_dbg(priv
->adapter
, ERROR
,
1271 "failed to get signal information\n");
1275 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1276 mwifiex_dbg(priv
->adapter
, ERROR
,
1277 "getting data rate error\n");
1281 /* Get DTIM period information from firmware */
1282 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1283 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1284 &priv
->dtim_period
, true);
1286 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1288 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1289 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1290 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1291 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1292 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1293 sinfo
->signal
= priv
->bcn_rssi_avg
;
1294 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1295 sinfo
->txrate
.legacy
= rate
* 5;
1297 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1298 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1299 sinfo
->bss_param
.flags
= 0;
1300 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1301 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1302 sinfo
->bss_param
.flags
|=
1303 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1304 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1305 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1306 sinfo
->bss_param
.flags
|=
1307 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1308 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1309 sinfo
->bss_param
.beacon_interval
=
1310 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1317 * CFG802.11 operation handler to get station information.
1319 * This function only works in connected mode, and dumps the
1320 * requested station information, if available.
1323 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1324 const u8
*mac
, struct station_info
*sinfo
)
1326 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1328 if (!priv
->media_connected
)
1330 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1333 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1337 * CFG802.11 operation handler to dump station information.
1340 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1341 int idx
, u8
*mac
, struct station_info
*sinfo
)
1343 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1344 static struct mwifiex_sta_node
*node
;
1346 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1347 priv
->media_connected
&& idx
== 0) {
1348 ether_addr_copy(mac
, priv
->cfg_bssid
);
1349 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1350 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1351 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1352 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1354 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1359 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1360 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1361 ether_addr_copy(mac
, node
->mac_addr
);
1362 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1370 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1371 int idx
, struct survey_info
*survey
)
1373 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1374 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1375 enum ieee80211_band band
;
1377 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1379 memset(survey
, 0, sizeof(struct survey_info
));
1381 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1382 priv
->media_connected
&& idx
== 0) {
1383 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1384 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1386 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1387 survey
->channel
= ieee80211_get_channel(wiphy
,
1388 ieee80211_channel_to_frequency(chan
, band
));
1390 if (priv
->bcn_nf_last
) {
1391 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1392 survey
->noise
= priv
->bcn_nf_last
;
1397 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1400 if (!pchan_stats
[idx
].cca_scan_dur
)
1403 band
= pchan_stats
[idx
].bandcfg
;
1404 survey
->channel
= ieee80211_get_channel(wiphy
,
1405 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1406 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1408 SURVEY_INFO_TIME_BUSY
;
1409 survey
->noise
= pchan_stats
[idx
].noise
;
1410 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1411 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1416 /* Supported rates to be advertised to the cfg80211 */
1417 static struct ieee80211_rate mwifiex_rates
[] = {
1418 {.bitrate
= 10, .hw_value
= 2, },
1419 {.bitrate
= 20, .hw_value
= 4, },
1420 {.bitrate
= 55, .hw_value
= 11, },
1421 {.bitrate
= 110, .hw_value
= 22, },
1422 {.bitrate
= 60, .hw_value
= 12, },
1423 {.bitrate
= 90, .hw_value
= 18, },
1424 {.bitrate
= 120, .hw_value
= 24, },
1425 {.bitrate
= 180, .hw_value
= 36, },
1426 {.bitrate
= 240, .hw_value
= 48, },
1427 {.bitrate
= 360, .hw_value
= 72, },
1428 {.bitrate
= 480, .hw_value
= 96, },
1429 {.bitrate
= 540, .hw_value
= 108, },
1432 /* Channel definitions to be advertised to cfg80211 */
1433 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1434 {.center_freq
= 2412, .hw_value
= 1, },
1435 {.center_freq
= 2417, .hw_value
= 2, },
1436 {.center_freq
= 2422, .hw_value
= 3, },
1437 {.center_freq
= 2427, .hw_value
= 4, },
1438 {.center_freq
= 2432, .hw_value
= 5, },
1439 {.center_freq
= 2437, .hw_value
= 6, },
1440 {.center_freq
= 2442, .hw_value
= 7, },
1441 {.center_freq
= 2447, .hw_value
= 8, },
1442 {.center_freq
= 2452, .hw_value
= 9, },
1443 {.center_freq
= 2457, .hw_value
= 10, },
1444 {.center_freq
= 2462, .hw_value
= 11, },
1445 {.center_freq
= 2467, .hw_value
= 12, },
1446 {.center_freq
= 2472, .hw_value
= 13, },
1447 {.center_freq
= 2484, .hw_value
= 14, },
1450 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1451 .channels
= mwifiex_channels_2ghz
,
1452 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1453 .bitrates
= mwifiex_rates
,
1454 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1457 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1458 {.center_freq
= 5040, .hw_value
= 8, },
1459 {.center_freq
= 5060, .hw_value
= 12, },
1460 {.center_freq
= 5080, .hw_value
= 16, },
1461 {.center_freq
= 5170, .hw_value
= 34, },
1462 {.center_freq
= 5190, .hw_value
= 38, },
1463 {.center_freq
= 5210, .hw_value
= 42, },
1464 {.center_freq
= 5230, .hw_value
= 46, },
1465 {.center_freq
= 5180, .hw_value
= 36, },
1466 {.center_freq
= 5200, .hw_value
= 40, },
1467 {.center_freq
= 5220, .hw_value
= 44, },
1468 {.center_freq
= 5240, .hw_value
= 48, },
1469 {.center_freq
= 5260, .hw_value
= 52, },
1470 {.center_freq
= 5280, .hw_value
= 56, },
1471 {.center_freq
= 5300, .hw_value
= 60, },
1472 {.center_freq
= 5320, .hw_value
= 64, },
1473 {.center_freq
= 5500, .hw_value
= 100, },
1474 {.center_freq
= 5520, .hw_value
= 104, },
1475 {.center_freq
= 5540, .hw_value
= 108, },
1476 {.center_freq
= 5560, .hw_value
= 112, },
1477 {.center_freq
= 5580, .hw_value
= 116, },
1478 {.center_freq
= 5600, .hw_value
= 120, },
1479 {.center_freq
= 5620, .hw_value
= 124, },
1480 {.center_freq
= 5640, .hw_value
= 128, },
1481 {.center_freq
= 5660, .hw_value
= 132, },
1482 {.center_freq
= 5680, .hw_value
= 136, },
1483 {.center_freq
= 5700, .hw_value
= 140, },
1484 {.center_freq
= 5745, .hw_value
= 149, },
1485 {.center_freq
= 5765, .hw_value
= 153, },
1486 {.center_freq
= 5785, .hw_value
= 157, },
1487 {.center_freq
= 5805, .hw_value
= 161, },
1488 {.center_freq
= 5825, .hw_value
= 165, },
1491 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1492 .channels
= mwifiex_channels_5ghz
,
1493 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1494 .bitrates
= mwifiex_rates
+ 4,
1495 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1499 /* Supported crypto cipher suits to be advertised to cfg80211 */
1500 static const u32 mwifiex_cipher_suites
[] = {
1501 WLAN_CIPHER_SUITE_WEP40
,
1502 WLAN_CIPHER_SUITE_WEP104
,
1503 WLAN_CIPHER_SUITE_TKIP
,
1504 WLAN_CIPHER_SUITE_CCMP
,
1505 WLAN_CIPHER_SUITE_AES_CMAC
,
1508 /* Supported mgmt frame types to be advertised to cfg80211 */
1509 static const struct ieee80211_txrx_stypes
1510 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1511 [NL80211_IFTYPE_STATION
] = {
1512 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1513 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1514 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1515 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1517 [NL80211_IFTYPE_AP
] = {
1518 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1519 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1520 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1521 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1523 [NL80211_IFTYPE_P2P_CLIENT
] = {
1524 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1525 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1526 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1527 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1529 [NL80211_IFTYPE_P2P_GO
] = {
1530 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1531 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1532 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1533 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1538 * CFG802.11 operation handler for setting bit rates.
1540 * Function configures data rates to firmware using bitrate mask
1541 * provided by cfg80211.
1543 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1544 struct net_device
*dev
,
1546 const struct cfg80211_bitrate_mask
*mask
)
1548 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1549 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1550 enum ieee80211_band band
;
1551 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1553 if (!priv
->media_connected
) {
1554 mwifiex_dbg(adapter
, ERROR
,
1555 "Can not set Tx data rate in disconnected state\n");
1559 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1561 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1563 /* Fill HR/DSSS rates. */
1564 if (band
== IEEE80211_BAND_2GHZ
)
1565 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1567 /* Fill OFDM rates */
1568 if (band
== IEEE80211_BAND_2GHZ
)
1569 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1571 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1573 /* Fill HT MCS rates */
1574 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1575 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1576 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1578 /* Fill VHT MCS rates */
1579 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1580 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1581 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1582 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1585 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1586 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1590 * CFG802.11 operation handler for connection quality monitoring.
1592 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1595 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1596 struct net_device
*dev
,
1597 s32 rssi_thold
, u32 rssi_hyst
)
1599 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1600 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1602 priv
->cqm_rssi_thold
= rssi_thold
;
1603 priv
->cqm_rssi_hyst
= rssi_hyst
;
1605 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1606 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1608 /* Subscribe/unsubscribe low and high rssi events */
1609 if (rssi_thold
&& rssi_hyst
) {
1610 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1611 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1612 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1613 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1614 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1615 return mwifiex_send_cmd(priv
,
1616 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1617 0, 0, &subsc_evt
, true);
1619 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1620 return mwifiex_send_cmd(priv
,
1621 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1622 0, 0, &subsc_evt
, true);
1628 /* cfg80211 operation handler for change_beacon.
1629 * Function retrieves and sets modified management IEs to FW.
1631 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1632 struct net_device
*dev
,
1633 struct cfg80211_beacon_data
*data
)
1635 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1637 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1638 mwifiex_dbg(priv
->adapter
, ERROR
,
1639 "%s: bss_type mismatched\n", __func__
);
1643 if (!priv
->bss_started
) {
1644 mwifiex_dbg(priv
->adapter
, ERROR
,
1645 "%s: bss not started\n", __func__
);
1649 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1650 mwifiex_dbg(priv
->adapter
, ERROR
,
1651 "%s: setting mgmt ies failed\n", __func__
);
1658 /* cfg80211 operation handler for del_station.
1659 * Function deauthenticates station which value is provided in mac parameter.
1660 * If mac is NULL/broadcast, all stations in associated station list are
1661 * deauthenticated. If bss is not started or there are no stations in
1662 * associated stations list, no action is taken.
1665 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1666 struct station_del_parameters
*params
)
1668 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1669 struct mwifiex_sta_node
*sta_node
;
1670 u8 deauth_mac
[ETH_ALEN
];
1671 unsigned long flags
;
1673 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1676 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1679 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1680 __func__
, params
->mac
);
1682 eth_zero_addr(deauth_mac
);
1684 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1685 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1687 ether_addr_copy(deauth_mac
, params
->mac
);
1688 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1690 if (is_valid_ether_addr(deauth_mac
)) {
1691 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1692 HostCmd_ACT_GEN_SET
, 0,
1701 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1703 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1704 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1705 MWIFIEX_BSS_ROLE_ANY
);
1706 struct mwifiex_ds_ant_cfg ant_cfg
;
1708 if (!tx_ant
|| !rx_ant
)
1711 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1712 /* Not a MIMO chip. User should provide specific antenna number
1713 * for Tx/Rx path or enable all antennas for diversity
1715 if (tx_ant
!= rx_ant
)
1718 if ((tx_ant
& (tx_ant
- 1)) &&
1719 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1722 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1723 (priv
->adapter
->number_of_antenna
> 1)) {
1724 tx_ant
= RF_ANTENNA_AUTO
;
1725 rx_ant
= RF_ANTENNA_AUTO
;
1728 struct ieee80211_sta_ht_cap
*ht_info
;
1730 enum ieee80211_band band
;
1732 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1733 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1734 if (adapter
->is_hw_11ac_capable
)
1735 adapter
->usr_dot_11ac_mcs_support
=
1736 MWIFIEX_11AC_MCS_MAP_1X1
;
1738 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1739 if (adapter
->is_hw_11ac_capable
)
1740 adapter
->usr_dot_11ac_mcs_support
=
1741 MWIFIEX_11AC_MCS_MAP_2X2
;
1744 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
1745 if (!adapter
->wiphy
->bands
[band
])
1748 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1750 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1751 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1752 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1756 ant_cfg
.tx_ant
= tx_ant
;
1757 ant_cfg
.rx_ant
= rx_ant
;
1759 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1760 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1763 /* cfg80211 operation handler for stop ap.
1764 * Function stops BSS running at uAP interface.
1766 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1768 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1770 mwifiex_abort_cac(priv
);
1772 if (mwifiex_del_mgmt_ies(priv
))
1773 mwifiex_dbg(priv
->adapter
, ERROR
,
1774 "Failed to delete mgmt IEs!\n");
1776 priv
->ap_11n_enabled
= 0;
1777 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1779 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1780 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1781 mwifiex_dbg(priv
->adapter
, ERROR
,
1782 "Failed to stop the BSS\n");
1786 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1787 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1788 mwifiex_dbg(priv
->adapter
, ERROR
,
1789 "Failed to reset BSS\n");
1796 /* cfg80211 operation handler for start_ap.
1797 * Function sets beacon period, DTIM period, SSID and security into
1798 * AP config structure.
1799 * AP is configured with these settings and BSS is started.
1801 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1802 struct net_device
*dev
,
1803 struct cfg80211_ap_settings
*params
)
1805 struct mwifiex_uap_bss_param
*bss_cfg
;
1806 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1808 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1811 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1815 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1817 if (params
->beacon_interval
)
1818 bss_cfg
->beacon_period
= params
->beacon_interval
;
1819 if (params
->dtim_period
)
1820 bss_cfg
->dtim_period
= params
->dtim_period
;
1822 if (params
->ssid
&& params
->ssid_len
) {
1823 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1824 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1826 if (params
->inactivity_timeout
> 0) {
1827 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1828 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1829 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1832 switch (params
->hidden_ssid
) {
1833 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1834 bss_cfg
->bcast_ssid_ctl
= 1;
1836 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1837 bss_cfg
->bcast_ssid_ctl
= 0;
1839 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1840 /* firmware doesn't support this type of hidden SSID */
1846 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1847 mwifiex_set_uap_rates(bss_cfg
, params
);
1849 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1851 mwifiex_dbg(priv
->adapter
, ERROR
,
1852 "Failed to parse secuirty parameters!\n");
1856 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1858 if (priv
->adapter
->is_hw_11ac_capable
) {
1859 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1860 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1861 priv
->ap_11ac_enabled
);
1864 if (priv
->ap_11ac_enabled
)
1865 mwifiex_set_11ac_ba_params(priv
);
1867 mwifiex_set_ba_params(priv
);
1869 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1871 if (mwifiex_is_11h_active(priv
))
1872 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
1874 if (mwifiex_is_11h_active(priv
) &&
1875 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
1877 mwifiex_dbg(priv
->adapter
, INFO
,
1878 "Disable 11h extensions in FW\n");
1879 if (mwifiex_11h_activate(priv
, false)) {
1880 mwifiex_dbg(priv
->adapter
, ERROR
,
1881 "Failed to disable 11h extensions!!");
1884 priv
->state_11h
.is_11h_active
= false;
1887 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
1888 mwifiex_dbg(priv
->adapter
, ERROR
,
1889 "Failed to start AP\n");
1894 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
1897 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
1903 * CFG802.11 operation handler for disconnection request.
1905 * This function does not work when there is already a disconnection
1906 * procedure going on.
1909 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
1912 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1914 if (mwifiex_deauthenticate(priv
, NULL
))
1917 mwifiex_dbg(priv
->adapter
, MSG
,
1918 "info: successfully disconnected from %pM:\t"
1919 "reason code %d\n", priv
->cfg_bssid
, reason_code
);
1921 eth_zero_addr(priv
->cfg_bssid
);
1922 priv
->hs2_enabled
= false;
1928 * This function informs the CFG802.11 subsystem of a new IBSS.
1930 * The following information are sent to the CFG802.11 subsystem
1931 * to register the new IBSS. If we do not register the new IBSS,
1932 * a kernel panic will result.
1938 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
1940 struct ieee80211_channel
*chan
;
1941 struct mwifiex_bss_info bss_info
;
1942 struct cfg80211_bss
*bss
;
1944 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
1945 enum ieee80211_band band
;
1947 if (mwifiex_get_bss_info(priv
, &bss_info
))
1950 ie_buf
[0] = WLAN_EID_SSID
;
1951 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
1953 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
1954 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
1955 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
1957 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1958 chan
= __ieee80211_get_channel(priv
->wdev
.wiphy
,
1959 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
1962 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
1963 CFG80211_BSS_FTYPE_UNKNOWN
,
1964 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
1965 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
1966 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
1967 memcpy(priv
->cfg_bssid
, bss_info
.bssid
, ETH_ALEN
);
1973 * This function connects with a BSS.
1975 * This function handles both Infra and Ad-Hoc modes. It also performs
1976 * validity checking on the provided parameters, disconnects from the
1977 * current BSS (if any), sets up the association/scan parameters,
1978 * including security settings, and performs specific SSID scan before
1979 * trying to connect.
1981 * For Infra mode, the function returns failure if the specified SSID
1982 * is not found in scan table. However, for Ad-Hoc mode, it can create
1983 * the IBSS if it does not exist. On successful completion in either case,
1984 * the function notifies the CFG802.11 subsystem of the new BSS connection.
1987 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
1988 const u8
*ssid
, const u8
*bssid
, int mode
,
1989 struct ieee80211_channel
*channel
,
1990 struct cfg80211_connect_params
*sme
, bool privacy
)
1992 struct cfg80211_ssid req_ssid
;
1993 int ret
, auth_type
= 0;
1994 struct cfg80211_bss
*bss
= NULL
;
1995 u8 is_scanning_required
= 0;
1997 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
1999 req_ssid
.ssid_len
= ssid_len
;
2000 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2001 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2005 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2006 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2007 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2011 /* As this is new association, clear locally stored
2012 * keys and security related flags */
2013 priv
->sec_info
.wpa_enabled
= false;
2014 priv
->sec_info
.wpa2_enabled
= false;
2015 priv
->wep_key_curr_index
= 0;
2016 priv
->sec_info
.encryption_mode
= 0;
2017 priv
->sec_info
.is_authtype_auto
= 0;
2018 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2020 if (mode
== NL80211_IFTYPE_ADHOC
) {
2021 /* "privacy" is set only for ad-hoc mode */
2024 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2025 * the firmware can find a matching network from the
2026 * scan. The cfg80211 does not give us the encryption
2027 * mode at this stage so just setting it to WEP here.
2029 priv
->sec_info
.encryption_mode
=
2030 WLAN_CIPHER_SUITE_WEP104
;
2031 priv
->sec_info
.authentication_mode
=
2032 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2038 /* Now handle infra mode. "sme" is valid for infra mode only */
2039 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2040 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2041 priv
->sec_info
.is_authtype_auto
= 1;
2043 auth_type
= sme
->auth_type
;
2046 if (sme
->crypto
.n_ciphers_pairwise
) {
2047 priv
->sec_info
.encryption_mode
=
2048 sme
->crypto
.ciphers_pairwise
[0];
2049 priv
->sec_info
.authentication_mode
= auth_type
;
2052 if (sme
->crypto
.cipher_group
) {
2053 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2054 priv
->sec_info
.authentication_mode
= auth_type
;
2057 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2060 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2061 mwifiex_dbg(priv
->adapter
, INFO
,
2062 "info: setting wep encryption\t"
2063 "with key len %d\n", sme
->key_len
);
2064 priv
->wep_key_curr_index
= sme
->key_idx
;
2065 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2066 sme
->key_len
, sme
->key_idx
,
2072 * Scan entries are valid for some time (15 sec). So we can save one
2073 * active scan time if we just try cfg80211_get_bss first. If it fails
2074 * then request scan and cfg80211_get_bss() again for final output.
2077 if (is_scanning_required
) {
2078 /* Do specific SSID scanning */
2079 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2080 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2085 /* Find the BSS we want using available scan results */
2086 if (mode
== NL80211_IFTYPE_ADHOC
)
2087 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2088 bssid
, ssid
, ssid_len
,
2089 IEEE80211_BSS_TYPE_IBSS
,
2090 IEEE80211_PRIVACY_ANY
);
2092 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2093 bssid
, ssid
, ssid_len
,
2094 IEEE80211_BSS_TYPE_ESS
,
2095 IEEE80211_PRIVACY_ANY
);
2098 if (is_scanning_required
) {
2099 mwifiex_dbg(priv
->adapter
, WARN
,
2100 "assoc: requested bss not found in scan results\n");
2103 is_scanning_required
= 1;
2105 mwifiex_dbg(priv
->adapter
, MSG
,
2106 "info: trying to associate to '%s' bssid %pM\n",
2107 (char *)req_ssid
.ssid
, bss
->bssid
);
2108 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2113 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2117 if (mode
== NL80211_IFTYPE_ADHOC
) {
2118 /* Inform the BSS information to kernel, otherwise
2119 * kernel will give a panic after successful assoc */
2120 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2128 * CFG802.11 operation handler for association request.
2130 * This function does not work when the current mode is set to Ad-Hoc, or
2131 * when there is already an association procedure going on. The given BSS
2132 * information is used to associate.
2135 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2136 struct cfg80211_connect_params
*sme
)
2138 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2139 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2142 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2143 mwifiex_dbg(adapter
, ERROR
,
2144 "%s: reject infra assoc request in non-STA role\n",
2149 if (priv
->wdev
.current_bss
) {
2150 mwifiex_dbg(adapter
, ERROR
,
2151 "%s: already connected\n", dev
->name
);
2155 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2156 mwifiex_dbg(adapter
, ERROR
,
2157 "%s: Ignore connection.\t"
2158 "Card removed or FW in bad state\n",
2163 mwifiex_dbg(adapter
, INFO
,
2164 "info: Trying to associate to %s and bssid %pM\n",
2165 (char *)sme
->ssid
, sme
->bssid
);
2167 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2168 priv
->bss_mode
, sme
->channel
, sme
, 0);
2170 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2171 NULL
, 0, WLAN_STATUS_SUCCESS
,
2173 mwifiex_dbg(priv
->adapter
, MSG
,
2174 "info: associated to bssid %pM successfully\n",
2176 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2177 priv
->adapter
->auto_tdls
&&
2178 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2179 mwifiex_setup_auto_tdls_timer(priv
);
2181 mwifiex_dbg(priv
->adapter
, ERROR
,
2182 "info: association to bssid %pM failed\n",
2184 eth_zero_addr(priv
->cfg_bssid
);
2187 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2188 NULL
, 0, NULL
, 0, ret
,
2191 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2193 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2201 * This function sets following parameters for ibss network.
2205 * - secondary channel offset
2207 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2208 struct cfg80211_ibss_params
*params
)
2210 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2212 u8 config_bands
= 0;
2214 if (params
->chandef
.chan
->band
== IEEE80211_BAND_2GHZ
) {
2215 if (!params
->basic_rates
) {
2216 config_bands
= BAND_B
| BAND_G
;
2218 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2220 * Rates below 6 Mbps in the table are CCK
2221 * rates; 802.11b and from 6 they are OFDM;
2224 if (mwifiex_rates
[i
].bitrate
== 60) {
2230 if (params
->basic_rates
< index
) {
2231 config_bands
= BAND_B
;
2233 config_bands
= BAND_G
;
2234 if (params
->basic_rates
% index
)
2235 config_bands
|= BAND_B
;
2239 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2241 config_bands
|= BAND_G
| BAND_GN
;
2243 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2245 config_bands
= BAND_A
;
2247 config_bands
= BAND_AN
| BAND_A
;
2250 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2251 adapter
->config_bands
= config_bands
;
2252 adapter
->adhoc_start_band
= config_bands
;
2254 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2255 adapter
->adhoc_11n_enabled
= true;
2257 adapter
->adhoc_11n_enabled
= false;
2260 adapter
->sec_chan_offset
=
2261 mwifiex_chan_type_to_sec_chan_offset(
2262 cfg80211_get_chandef_type(¶ms
->chandef
));
2263 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2264 params
->chandef
.chan
->center_freq
);
2266 mwifiex_dbg(adapter
, INFO
,
2267 "info: set ibss band %d, chan %d, chan offset %d\n",
2268 config_bands
, priv
->adhoc_channel
,
2269 adapter
->sec_chan_offset
);
2275 * CFG802.11 operation handler to join an IBSS.
2277 * This function does not work in any mode other than Ad-Hoc, or if
2278 * a join operation is already in progress.
2281 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2282 struct cfg80211_ibss_params
*params
)
2284 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2287 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2288 mwifiex_dbg(priv
->adapter
, ERROR
,
2289 "request to join ibss received\t"
2290 "when station is not in ibss mode\n");
2294 mwifiex_dbg(priv
->adapter
, MSG
,
2295 "info: trying to join to %s and bssid %pM\n",
2296 (char *)params
->ssid
, params
->bssid
);
2298 mwifiex_set_ibss_params(priv
, params
);
2300 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2301 params
->bssid
, priv
->bss_mode
,
2302 params
->chandef
.chan
, NULL
,
2306 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2307 params
->chandef
.chan
, GFP_KERNEL
);
2308 mwifiex_dbg(priv
->adapter
, MSG
,
2309 "info: joined/created adhoc network with bssid\t"
2310 "%pM successfully\n", priv
->cfg_bssid
);
2312 mwifiex_dbg(priv
->adapter
, ERROR
,
2313 "info: failed creating/joining adhoc network\n");
2320 * CFG802.11 operation handler to leave an IBSS.
2322 * This function does not work if a leave operation is
2323 * already in progress.
2326 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2328 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2330 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2332 if (mwifiex_deauthenticate(priv
, NULL
))
2335 eth_zero_addr(priv
->cfg_bssid
);
2341 * CFG802.11 operation handler for scan request.
2343 * This function issues a scan request to the firmware based upon
2344 * the user specified scan configuration. On successfull completion,
2345 * it also informs the results.
2348 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2349 struct cfg80211_scan_request
*request
)
2351 struct net_device
*dev
= request
->wdev
->netdev
;
2352 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2354 struct ieee80211_channel
*chan
;
2355 struct ieee_types_header
*ie
;
2356 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2358 mwifiex_dbg(priv
->adapter
, CMD
,
2359 "info: received scan request on %s\n", dev
->name
);
2361 /* Block scan request if scan operation or scan cleanup when interface
2362 * is disabled is in process
2364 if (priv
->scan_request
|| priv
->scan_aborting
) {
2365 mwifiex_dbg(priv
->adapter
, WARN
,
2366 "cmd: Scan already in process..\n");
2370 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2374 priv
->scan_request
= request
;
2376 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2377 user_scan_cfg
->ssid_list
= request
->ssids
;
2379 if (request
->ie
&& request
->ie_len
) {
2381 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2382 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2384 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2385 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2386 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2387 offset
+= sizeof(*ie
) + ie
->len
;
2389 if (offset
>= request
->ie_len
)
2394 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2395 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2396 chan
= request
->channels
[i
];
2397 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2398 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2400 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2401 user_scan_cfg
->chan_list
[i
].scan_type
=
2402 MWIFIEX_SCAN_TYPE_PASSIVE
;
2404 user_scan_cfg
->chan_list
[i
].scan_type
=
2405 MWIFIEX_SCAN_TYPE_ACTIVE
;
2407 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2410 if (priv
->adapter
->scan_chan_gap_enabled
&&
2411 mwifiex_is_any_intf_active(priv
))
2412 user_scan_cfg
->scan_chan_gap
=
2413 priv
->adapter
->scan_chan_gap_time
;
2415 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2416 kfree(user_scan_cfg
);
2418 mwifiex_dbg(priv
->adapter
, ERROR
,
2419 "scan failed: %d\n", ret
);
2420 priv
->scan_aborting
= false;
2421 priv
->scan_request
= NULL
;
2425 if (request
->ie
&& request
->ie_len
) {
2426 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2427 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2428 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2429 memset(&priv
->vs_ie
[i
].ie
, 0,
2430 MWIFIEX_MAX_VSIE_LEN
);
2437 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2438 struct mwifiex_private
*priv
)
2440 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2442 vht_info
->vht_supported
= true;
2444 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2445 /* Update MCS support for VHT */
2446 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2447 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2448 vht_info
->vht_mcs
.rx_highest
= 0;
2449 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2450 adapter
->hw_dot_11ac_mcs_support
>> 16);
2451 vht_info
->vht_mcs
.tx_highest
= 0;
2455 * This function sets up the CFG802.11 specific HT capability fields
2456 * with default values.
2458 * The following default values are set -
2459 * - HT Supported = True
2460 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2461 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2462 * - HT Capabilities supported by firmware
2463 * - MCS information, Rx mask = 0xff
2464 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2467 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2468 struct mwifiex_private
*priv
)
2471 struct ieee80211_mcs_info mcs_set
;
2472 u8
*mcs
= (u8
*)&mcs_set
;
2473 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2475 ht_info
->ht_supported
= true;
2476 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2477 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2479 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2481 /* Fill HT capability information */
2482 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2483 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2485 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2487 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2488 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2490 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2492 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2493 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2495 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2497 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2498 ht_info
->cap
|= 3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2500 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2502 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2503 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2505 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2507 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2508 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2510 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2512 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2513 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2515 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2517 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2518 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2520 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2522 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2523 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2525 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2526 /* Set MCS for 1x1/2x2 */
2527 memset(mcs
, 0xff, rx_mcs_supp
);
2528 /* Clear all the other values */
2529 memset(&mcs
[rx_mcs_supp
], 0,
2530 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2531 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2532 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2533 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2534 SETHT_MCS32(mcs_set
.rx_mask
);
2536 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2538 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2542 * create a new virtual interface with the given name and name assign type
2544 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2546 unsigned char name_assign_type
,
2547 enum nl80211_iftype type
,
2549 struct vif_params
*params
)
2551 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2552 struct mwifiex_private
*priv
;
2553 struct net_device
*dev
;
2557 return ERR_PTR(-EFAULT
);
2560 case NL80211_IFTYPE_UNSPECIFIED
:
2561 case NL80211_IFTYPE_STATION
:
2562 case NL80211_IFTYPE_ADHOC
:
2563 if (adapter
->curr_iface_comb
.sta_intf
==
2564 adapter
->iface_limit
.sta_intf
) {
2565 mwifiex_dbg(adapter
, ERROR
,
2566 "cannot create multiple sta/adhoc ifaces\n");
2567 return ERR_PTR(-EINVAL
);
2570 priv
= mwifiex_get_unused_priv(adapter
);
2572 mwifiex_dbg(adapter
, ERROR
,
2573 "could not get free private struct\n");
2574 return ERR_PTR(-EFAULT
);
2577 priv
->wdev
.wiphy
= wiphy
;
2578 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2580 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2581 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2583 priv
->bss_mode
= type
;
2585 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2586 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2587 priv
->bss_priority
= 0;
2588 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2589 priv
->bss_num
= adapter
->curr_iface_comb
.sta_intf
;
2592 case NL80211_IFTYPE_AP
:
2593 if (adapter
->curr_iface_comb
.uap_intf
==
2594 adapter
->iface_limit
.uap_intf
) {
2595 mwifiex_dbg(adapter
, ERROR
,
2596 "cannot create multiple AP ifaces\n");
2597 return ERR_PTR(-EINVAL
);
2600 priv
= mwifiex_get_unused_priv(adapter
);
2602 mwifiex_dbg(adapter
, ERROR
,
2603 "could not get free private struct\n");
2604 return ERR_PTR(-EFAULT
);
2607 priv
->wdev
.wiphy
= wiphy
;
2608 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2610 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2611 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2612 priv
->bss_priority
= 0;
2613 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2614 priv
->bss_started
= 0;
2615 priv
->bss_num
= adapter
->curr_iface_comb
.uap_intf
;
2616 priv
->bss_mode
= type
;
2619 case NL80211_IFTYPE_P2P_CLIENT
:
2620 if (adapter
->curr_iface_comb
.p2p_intf
==
2621 adapter
->iface_limit
.p2p_intf
) {
2622 mwifiex_dbg(adapter
, ERROR
,
2623 "cannot create multiple P2P ifaces\n");
2624 return ERR_PTR(-EINVAL
);
2627 priv
= mwifiex_get_unused_priv(adapter
);
2629 mwifiex_dbg(adapter
, ERROR
,
2630 "could not get free private struct\n");
2631 return ERR_PTR(-EFAULT
);
2634 priv
->wdev
.wiphy
= wiphy
;
2635 /* At start-up, wpa_supplicant tries to change the interface
2636 * to NL80211_IFTYPE_STATION if it is not managed mode.
2638 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2639 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2641 /* Setting bss_type to P2P tells firmware that this interface
2642 * is receiving P2P peers found during find phase and doing
2643 * action frame handshake.
2645 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2647 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2648 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2649 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2650 priv
->bss_started
= 0;
2651 priv
->bss_num
= adapter
->curr_iface_comb
.p2p_intf
;
2653 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2654 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2655 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2656 return ERR_PTR(-EFAULT
);
2661 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2662 return ERR_PTR(-EINVAL
);
2665 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2666 name_assign_type
, ether_setup
,
2667 IEEE80211_NUM_ACS
, 1);
2669 mwifiex_dbg(adapter
, ERROR
,
2670 "no memory available for netdevice\n");
2671 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2672 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2673 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2674 return ERR_PTR(-ENOMEM
);
2677 mwifiex_init_priv_params(priv
, dev
);
2680 mwifiex_setup_ht_caps(&wiphy
->bands
[IEEE80211_BAND_2GHZ
]->ht_cap
, priv
);
2681 if (adapter
->is_hw_11ac_capable
)
2682 mwifiex_setup_vht_caps(
2683 &wiphy
->bands
[IEEE80211_BAND_2GHZ
]->vht_cap
, priv
);
2685 if (adapter
->config_bands
& BAND_A
)
2686 mwifiex_setup_ht_caps(
2687 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->ht_cap
, priv
);
2689 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2690 mwifiex_setup_vht_caps(
2691 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->vht_cap
, priv
);
2693 dev_net_set(dev
, wiphy_net(wiphy
));
2694 dev
->ieee80211_ptr
= &priv
->wdev
;
2695 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2696 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2697 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2699 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2700 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2701 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2702 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
2704 mdev_priv
= netdev_priv(dev
);
2705 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
2707 SET_NETDEV_DEV(dev
, adapter
->dev
);
2709 /* Register network device */
2710 if (register_netdevice(dev
)) {
2711 mwifiex_dbg(adapter
, ERROR
,
2712 "cannot register virtual network device\n");
2714 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2715 priv
->netdev
= NULL
;
2716 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2717 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2718 return ERR_PTR(-EFAULT
);
2721 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
2724 WQ_UNBOUND
, 1, name
);
2725 if (!priv
->dfs_cac_workqueue
) {
2726 mwifiex_dbg(adapter
, ERROR
,
2727 "cannot register virtual network device\n");
2729 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2730 priv
->netdev
= NULL
;
2731 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2732 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2733 return ERR_PTR(-ENOMEM
);
2736 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
2738 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
2739 WQ_HIGHPRI
| WQ_UNBOUND
|
2740 WQ_MEM_RECLAIM
, 1, name
);
2741 if (!priv
->dfs_chan_sw_workqueue
) {
2742 mwifiex_dbg(adapter
, ERROR
,
2743 "cannot register virtual network device\n");
2745 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2746 priv
->netdev
= NULL
;
2747 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2748 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2749 return ERR_PTR(-ENOMEM
);
2752 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
2753 mwifiex_dfs_chan_sw_work_queue
);
2755 sema_init(&priv
->async_sem
, 1);
2757 mwifiex_dbg(adapter
, INFO
,
2758 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
2760 #ifdef CONFIG_DEBUG_FS
2761 mwifiex_dev_debugfs_init(priv
);
2765 case NL80211_IFTYPE_UNSPECIFIED
:
2766 case NL80211_IFTYPE_STATION
:
2767 case NL80211_IFTYPE_ADHOC
:
2768 adapter
->curr_iface_comb
.sta_intf
++;
2770 case NL80211_IFTYPE_AP
:
2771 adapter
->curr_iface_comb
.uap_intf
++;
2773 case NL80211_IFTYPE_P2P_CLIENT
:
2774 adapter
->curr_iface_comb
.p2p_intf
++;
2777 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2778 return ERR_PTR(-EINVAL
);
2783 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
2786 * del_virtual_intf: remove the virtual interface determined by dev
2788 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
2790 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
2791 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2793 #ifdef CONFIG_DEBUG_FS
2794 mwifiex_dev_debugfs_remove(priv
);
2797 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
2799 if (netif_carrier_ok(priv
->netdev
))
2800 netif_carrier_off(priv
->netdev
);
2802 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
2803 unregister_netdevice(wdev
->netdev
);
2805 if (priv
->dfs_cac_workqueue
) {
2806 flush_workqueue(priv
->dfs_cac_workqueue
);
2807 destroy_workqueue(priv
->dfs_cac_workqueue
);
2808 priv
->dfs_cac_workqueue
= NULL
;
2811 if (priv
->dfs_chan_sw_workqueue
) {
2812 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
2813 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
2814 priv
->dfs_chan_sw_workqueue
= NULL
;
2816 /* Clear the priv in adapter */
2817 priv
->netdev
->ieee80211_ptr
= NULL
;
2818 priv
->netdev
= NULL
;
2819 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2821 priv
->media_connected
= false;
2823 switch (priv
->bss_mode
) {
2824 case NL80211_IFTYPE_UNSPECIFIED
:
2825 case NL80211_IFTYPE_STATION
:
2826 case NL80211_IFTYPE_ADHOC
:
2827 adapter
->curr_iface_comb
.sta_intf
++;
2829 case NL80211_IFTYPE_AP
:
2830 adapter
->curr_iface_comb
.uap_intf
++;
2832 case NL80211_IFTYPE_P2P_CLIENT
:
2833 case NL80211_IFTYPE_P2P_GO
:
2834 adapter
->curr_iface_comb
.p2p_intf
++;
2837 mwifiex_dbg(adapter
, ERROR
,
2838 "del_virtual_intf: type not supported\n");
2842 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2844 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
2845 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
2846 kfree(priv
->hist_data
);
2850 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
2853 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
2856 int j
, k
, valid_byte_cnt
= 0;
2857 bool dont_care_byte
= false;
2859 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
2860 for (k
= 0; k
< 8; k
++) {
2861 if (pat
->mask
[j
] & 1 << k
) {
2862 memcpy(byte_seq
+ valid_byte_cnt
,
2863 &pat
->pattern
[j
* 8 + k
], 1);
2869 dont_care_byte
= true;
2872 if (valid_byte_cnt
> max_byte_seq
)
2877 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
2883 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
2884 struct mwifiex_mef_entry
*mef_entry
)
2886 int i
, filt_num
= 0, num_ipv4
= 0;
2887 struct in_device
*in_dev
;
2888 struct in_ifaddr
*ifa
;
2889 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
2890 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2892 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2893 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
2895 /* Enable ARP offload feature */
2896 memset(ips
, 0, sizeof(ips
));
2897 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
2898 if (adapter
->priv
[i
]->netdev
) {
2899 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
2902 ifa
= in_dev
->ifa_list
;
2903 if (!ifa
|| !ifa
->ifa_local
)
2905 ips
[i
] = ifa
->ifa_local
;
2910 for (i
= 0; i
< num_ipv4
; i
++) {
2913 mef_entry
->filter
[filt_num
].repeat
= 1;
2914 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
2915 (u8
*)&ips
[i
], sizeof(ips
[i
]));
2916 mef_entry
->filter
[filt_num
].
2917 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
2919 mef_entry
->filter
[filt_num
].offset
= 46;
2920 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2922 mef_entry
->filter
[filt_num
].filt_action
=
2928 mef_entry
->filter
[filt_num
].repeat
= 1;
2929 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
2930 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
2931 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
2932 mef_entry
->filter
[filt_num
].offset
= 20;
2933 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2934 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
2937 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
2938 struct mwifiex_ds_mef_cfg
*mef_cfg
,
2939 struct mwifiex_mef_entry
*mef_entry
,
2940 struct cfg80211_wowlan
*wowlan
)
2942 int i
, filt_num
= 0, ret
= 0;
2943 bool first_pat
= true;
2944 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
2945 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
2946 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
2948 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2949 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
2951 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
2952 memset(byte_seq
, 0, sizeof(byte_seq
));
2953 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
2955 MWIFIEX_MEF_MAX_BYTESEQ
)) {
2956 mwifiex_dbg(priv
->adapter
, ERROR
,
2957 "Pattern not supported\n");
2962 if (!wowlan
->patterns
[i
].pkt_offset
) {
2963 if (!(byte_seq
[0] & 0x01) &&
2964 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
2965 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
2967 } else if (is_broadcast_ether_addr(byte_seq
)) {
2968 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
2970 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
2971 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
2972 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
2973 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
2974 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
2978 mef_entry
->filter
[filt_num
].repeat
= 1;
2979 mef_entry
->filter
[filt_num
].offset
=
2980 wowlan
->patterns
[i
].pkt_offset
;
2981 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
2983 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2988 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
2993 if (wowlan
->magic_pkt
) {
2994 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
2995 mef_entry
->filter
[filt_num
].repeat
= 16;
2996 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
2998 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3000 mef_entry
->filter
[filt_num
].offset
= 28;
3001 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3003 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3006 mef_entry
->filter
[filt_num
].repeat
= 16;
3007 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3009 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3011 mef_entry
->filter
[filt_num
].offset
= 56;
3012 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3013 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3018 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3019 struct cfg80211_wowlan
*wowlan
)
3021 int ret
= 0, num_entries
= 1;
3022 struct mwifiex_ds_mef_cfg mef_cfg
;
3023 struct mwifiex_mef_entry
*mef_entry
;
3025 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3028 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3032 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3033 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3034 MWIFIEX_CRITERIA_UNICAST
;
3035 mef_cfg
.num_entries
= num_entries
;
3036 mef_cfg
.mef_entry
= mef_entry
;
3038 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3040 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3041 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3042 &mef_entry
[1], wowlan
);
3044 if (!mef_cfg
.criteria
)
3045 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3046 MWIFIEX_CRITERIA_UNICAST
|
3047 MWIFIEX_CRITERIA_MULTICAST
;
3049 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3050 HostCmd_ACT_GEN_SET
, 0,
3056 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3057 struct cfg80211_wowlan
*wowlan
)
3059 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3060 struct mwifiex_ds_hs_cfg hs_cfg
;
3062 struct mwifiex_private
*priv
;
3064 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3065 priv
= adapter
->priv
[i
];
3066 mwifiex_abort_cac(priv
);
3069 mwifiex_cancel_all_pending_cmd(adapter
);
3072 mwifiex_dbg(adapter
, ERROR
,
3073 "None of the WOWLAN triggers enabled\n");
3077 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3079 if (!priv
->media_connected
) {
3080 mwifiex_dbg(adapter
, ERROR
,
3081 "Can not configure WOWLAN in disconnected state\n");
3085 ret
= mwifiex_set_mef_filter(priv
, wowlan
);
3087 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3091 if (wowlan
->disconnect
) {
3092 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3093 hs_cfg
.is_invoke_hostcmd
= false;
3094 hs_cfg
.conditions
= HS_CFG_COND_MAC_EVENT
;
3095 hs_cfg
.gpio
= HS_CFG_GPIO_DEF
;
3096 hs_cfg
.gap
= HS_CFG_GAP_DEF
;
3097 ret
= mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
3098 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3100 mwifiex_dbg(adapter
, ERROR
,
3101 "Failed to set HS params\n");
3109 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3114 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3117 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3119 device_set_wakeup_enable(adapter
->dev
, enabled
);
3123 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3125 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3126 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3127 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3129 if ((byte_seq
[0] & 0x01) &&
3130 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3131 return PACKET_TYPE_UNICAST
;
3132 else if (!memcmp(byte_seq
, bc_mac
, 4))
3133 return PACKET_TYPE_BROADCAST
;
3134 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3135 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3136 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3137 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3138 return PACKET_TYPE_MULTICAST
;
3144 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3145 struct cfg80211_coalesce_rules
*crule
,
3146 struct mwifiex_coalesce_rule
*mrule
)
3148 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3149 struct filt_field_param
*param
;
3152 mrule
->max_coalescing_delay
= crule
->delay
;
3154 param
= mrule
->params
;
3156 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3157 memset(byte_seq
, 0, sizeof(byte_seq
));
3158 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3160 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3161 mwifiex_dbg(priv
->adapter
, ERROR
,
3162 "Pattern not supported\n");
3166 if (!crule
->patterns
[i
].pkt_offset
) {
3169 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3170 if (pkt_type
&& mrule
->pkt_type
) {
3171 mwifiex_dbg(priv
->adapter
, ERROR
,
3172 "Multiple packet types not allowed\n");
3174 } else if (pkt_type
) {
3175 mrule
->pkt_type
= pkt_type
;
3180 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3181 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3183 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3185 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3186 memcpy(param
->operand_byte_stream
, byte_seq
,
3187 param
->operand_len
);
3188 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3191 mrule
->num_of_fields
++;
3194 if (!mrule
->pkt_type
) {
3195 mwifiex_dbg(priv
->adapter
, ERROR
,
3196 "Packet type can not be determined\n");
3203 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3204 struct cfg80211_coalesce
*coalesce
)
3206 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3208 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3209 struct mwifiex_private
*priv
=
3210 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3212 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3214 mwifiex_dbg(adapter
, WARN
,
3215 "Disable coalesce and reset all previous rules\n");
3216 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3217 HostCmd_ACT_GEN_SET
, 0,
3218 &coalesce_cfg
, true);
3221 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3222 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3223 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3224 &coalesce_cfg
.rule
[i
]);
3226 mwifiex_dbg(adapter
, ERROR
,
3227 "Recheck the patterns provided for rule %d\n",
3233 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3234 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3237 /* cfg80211 ops handler for tdls_mgmt.
3238 * Function prepares TDLS action frame packets and forwards them to FW
3241 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3242 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3243 u16 status_code
, u32 peer_capability
,
3244 bool initiator
, const u8
*extra_ies
,
3245 size_t extra_ies_len
)
3247 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3250 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3253 /* make sure we are in station mode and connected */
3254 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3257 switch (action_code
) {
3258 case WLAN_TDLS_SETUP_REQUEST
:
3259 mwifiex_dbg(priv
->adapter
, MSG
,
3260 "Send TDLS Setup Request to %pM status_code=%d\n",
3262 mwifiex_add_auto_tdls_peer(priv
, peer
);
3263 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3264 dialog_token
, status_code
,
3265 extra_ies
, extra_ies_len
);
3267 case WLAN_TDLS_SETUP_RESPONSE
:
3268 mwifiex_add_auto_tdls_peer(priv
, peer
);
3269 mwifiex_dbg(priv
->adapter
, MSG
,
3270 "Send TDLS Setup Response to %pM status_code=%d\n",
3272 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3273 dialog_token
, status_code
,
3274 extra_ies
, extra_ies_len
);
3276 case WLAN_TDLS_SETUP_CONFIRM
:
3277 mwifiex_dbg(priv
->adapter
, MSG
,
3278 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3280 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3281 dialog_token
, status_code
,
3282 extra_ies
, extra_ies_len
);
3284 case WLAN_TDLS_TEARDOWN
:
3285 mwifiex_dbg(priv
->adapter
, MSG
,
3286 "Send TDLS Tear down to %pM\n", peer
);
3287 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3288 dialog_token
, status_code
,
3289 extra_ies
, extra_ies_len
);
3291 case WLAN_TDLS_DISCOVERY_REQUEST
:
3292 mwifiex_dbg(priv
->adapter
, MSG
,
3293 "Send TDLS Discovery Request to %pM\n", peer
);
3294 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3295 dialog_token
, status_code
,
3296 extra_ies
, extra_ies_len
);
3298 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3299 mwifiex_dbg(priv
->adapter
, MSG
,
3300 "Send TDLS Discovery Response to %pM\n", peer
);
3301 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3302 dialog_token
, status_code
,
3303 extra_ies
, extra_ies_len
);
3306 mwifiex_dbg(priv
->adapter
, ERROR
,
3307 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3316 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3317 const u8
*peer
, enum nl80211_tdls_operation action
)
3319 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3321 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3322 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3325 /* make sure we are in station mode and connected */
3326 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3329 mwifiex_dbg(priv
->adapter
, MSG
,
3330 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3333 case NL80211_TDLS_ENABLE_LINK
:
3334 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3336 case NL80211_TDLS_DISABLE_LINK
:
3337 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3339 case NL80211_TDLS_TEARDOWN
:
3340 /* shouldn't happen!*/
3341 mwifiex_dbg(priv
->adapter
, ERROR
,
3342 "tdls_oper: teardown from driver not supported\n");
3344 case NL80211_TDLS_SETUP
:
3345 /* shouldn't happen!*/
3346 mwifiex_dbg(priv
->adapter
, ERROR
,
3347 "tdls_oper: setup from driver not supported\n");
3349 case NL80211_TDLS_DISCOVERY_REQ
:
3350 /* shouldn't happen!*/
3351 mwifiex_dbg(priv
->adapter
, ERROR
,
3352 "tdls_oper: discovery from driver not supported\n");
3355 mwifiex_dbg(priv
->adapter
, ERROR
,
3356 "tdls_oper: operation not supported\n");
3360 return mwifiex_tdls_oper(priv
, peer
, action
);
3364 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3365 const u8
*addr
, u8 oper_class
,
3366 struct cfg80211_chan_def
*chandef
)
3368 struct mwifiex_sta_node
*sta_ptr
;
3369 unsigned long flags
;
3371 u8 second_chan_offset
, band
;
3372 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3374 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3375 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3376 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3379 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3384 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3385 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3386 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3390 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3391 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3392 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3396 chan
= chandef
->chan
->hw_value
;
3397 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3398 band
= chandef
->chan
->band
;
3399 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3405 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3406 struct net_device
*dev
,
3409 struct mwifiex_sta_node
*sta_ptr
;
3410 unsigned long flags
;
3411 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3413 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3414 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3415 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3418 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3420 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3421 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3422 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3423 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3426 mwifiex_stop_tdls_cs(priv
, addr
);
3430 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3431 const u8
*mac
, struct station_parameters
*params
)
3433 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3435 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3438 /* make sure we are in station mode and connected */
3439 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3442 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3446 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3447 struct cfg80211_csa_settings
*params
)
3449 struct ieee_types_header
*chsw_ie
;
3450 struct ieee80211_channel_sw_ie
*channel_sw
;
3452 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3454 if (priv
->adapter
->scan_processing
) {
3455 mwifiex_dbg(priv
->adapter
, ERROR
,
3456 "radar detection: scan in process...\n");
3460 if (priv
->wdev
.cac_started
)
3463 if (cfg80211_chandef_identical(¶ms
->chandef
,
3464 &priv
->dfs_chandef
))
3467 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3468 params
->beacon_csa
.tail
,
3469 params
->beacon_csa
.tail_len
);
3471 mwifiex_dbg(priv
->adapter
, ERROR
,
3472 "Could not parse channel switch announcement IE\n");
3476 channel_sw
= (void *)(chsw_ie
+ 1);
3477 if (channel_sw
->mode
) {
3478 if (netif_carrier_ok(priv
->netdev
))
3479 netif_carrier_off(priv
->netdev
);
3480 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3483 if (mwifiex_del_mgmt_ies(priv
))
3484 mwifiex_dbg(priv
->adapter
, ERROR
,
3485 "Failed to delete mgmt IEs!\n");
3487 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3488 mwifiex_dbg(priv
->adapter
, ERROR
,
3489 "%s: setting mgmt ies failed\n", __func__
);
3493 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3494 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3495 sizeof(priv
->beacon_after
));
3497 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3498 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3499 msecs_to_jiffies(chsw_msec
));
3503 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3504 struct wireless_dev
*wdev
,
3505 struct cfg80211_chan_def
*chandef
)
3507 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3508 struct mwifiex_bssdescriptor
*curr_bss
;
3509 struct ieee80211_channel
*chan
;
3510 u8 second_chan_offset
;
3511 enum nl80211_channel_type chan_type
;
3512 enum ieee80211_band band
;
3516 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3517 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3518 *chandef
= priv
->bss_chandef
;
3520 } else if (priv
->media_connected
) {
3521 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3522 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3523 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3524 chan
= ieee80211_get_channel(wiphy
, freq
);
3526 if (curr_bss
->bcn_ht_oper
) {
3527 second_chan_offset
= curr_bss
->bcn_ht_oper
->ht_param
&
3528 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3529 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3530 (second_chan_offset
);
3531 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3533 cfg80211_chandef_create(chandef
, chan
,
3534 NL80211_CHAN_NO_HT
);
3543 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
3544 struct net_device
*dev
,
3545 struct cfg80211_chan_def
*chandef
,
3548 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3549 struct mwifiex_radar_params radar_params
;
3551 if (priv
->adapter
->scan_processing
) {
3552 mwifiex_dbg(priv
->adapter
, ERROR
,
3553 "radar detection: scan already in process...\n");
3557 if (!mwifiex_is_11h_active(priv
)) {
3558 mwifiex_dbg(priv
->adapter
, INFO
,
3559 "Enable 11h extensions in FW\n");
3560 if (mwifiex_11h_activate(priv
, true)) {
3561 mwifiex_dbg(priv
->adapter
, ERROR
,
3562 "Failed to activate 11h extensions!!");
3565 priv
->state_11h
.is_11h_active
= true;
3568 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
3569 radar_params
.chandef
= chandef
;
3570 radar_params
.cac_time_ms
= cac_time_ms
;
3572 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
3574 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
3575 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
3578 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
3579 msecs_to_jiffies(cac_time_ms
));
3584 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3586 struct station_parameters
*params
)
3589 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3591 /* we support change_station handler only for TDLS peers*/
3592 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3595 /* make sure we are in station mode and connected */
3596 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3599 priv
->sta_params
= params
;
3601 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
3602 priv
->sta_params
= NULL
;
3607 /* station cfg80211 operations */
3608 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
3609 .add_virtual_intf
= mwifiex_add_virtual_intf
,
3610 .del_virtual_intf
= mwifiex_del_virtual_intf
,
3611 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
3612 .scan
= mwifiex_cfg80211_scan
,
3613 .connect
= mwifiex_cfg80211_connect
,
3614 .disconnect
= mwifiex_cfg80211_disconnect
,
3615 .get_station
= mwifiex_cfg80211_get_station
,
3616 .dump_station
= mwifiex_cfg80211_dump_station
,
3617 .dump_survey
= mwifiex_cfg80211_dump_survey
,
3618 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
3619 .join_ibss
= mwifiex_cfg80211_join_ibss
,
3620 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
3621 .add_key
= mwifiex_cfg80211_add_key
,
3622 .del_key
= mwifiex_cfg80211_del_key
,
3623 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
3624 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
3625 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
3626 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
3627 .set_default_key
= mwifiex_cfg80211_set_default_key
,
3628 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
3629 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
3630 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
3631 .start_ap
= mwifiex_cfg80211_start_ap
,
3632 .stop_ap
= mwifiex_cfg80211_stop_ap
,
3633 .change_beacon
= mwifiex_cfg80211_change_beacon
,
3634 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
3635 .set_antenna
= mwifiex_cfg80211_set_antenna
,
3636 .del_station
= mwifiex_cfg80211_del_station
,
3638 .suspend
= mwifiex_cfg80211_suspend
,
3639 .resume
= mwifiex_cfg80211_resume
,
3640 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
3642 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
3643 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
3644 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
3645 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
3646 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
3647 .add_station
= mwifiex_cfg80211_add_station
,
3648 .change_station
= mwifiex_cfg80211_change_station
,
3649 .get_channel
= mwifiex_cfg80211_get_channel
,
3650 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
3651 .channel_switch
= mwifiex_cfg80211_channel_switch
,
3655 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
3656 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
,
3657 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
3658 .pattern_min_len
= 1,
3659 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3660 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3664 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
3666 if (!alpha2
|| strlen(alpha2
) != 2)
3669 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
3675 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
3676 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
3677 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
3678 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
3679 .pattern_min_len
= 1,
3680 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3681 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3684 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
3686 u32 n_channels_bg
, n_channels_a
= 0;
3688 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
3690 if (adapter
->config_bands
& BAND_A
)
3691 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
3693 adapter
->num_in_chan_stats
= max_t(u32
, n_channels_bg
, n_channels_a
);
3694 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
3695 adapter
->num_in_chan_stats
);
3697 if (!adapter
->chan_stats
)
3704 * This function registers the device with CFG802.11 subsystem.
3706 * The function creates the wireless device/wiphy, populates it with
3707 * default parameters and handler function pointers, and finally
3708 * registers the device.
3711 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
3715 struct wiphy
*wiphy
;
3716 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
3720 /* create a new wiphy for use with cfg80211 */
3721 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
3722 sizeof(struct mwifiex_adapter
*));
3724 mwifiex_dbg(adapter
, ERROR
,
3725 "%s: creating new wiphy\n", __func__
);
3728 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
3729 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
3730 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
3731 wiphy
->max_remain_on_channel_duration
= 5000;
3732 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
3733 BIT(NL80211_IFTYPE_ADHOC
) |
3734 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
3735 BIT(NL80211_IFTYPE_P2P_GO
) |
3736 BIT(NL80211_IFTYPE_AP
);
3738 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
3739 if (adapter
->config_bands
& BAND_A
)
3740 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
3742 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = NULL
;
3744 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
3745 wiphy
->n_iface_combinations
= 1;
3747 /* Initialize cipher suits */
3748 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
3749 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
3751 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
3752 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3753 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
3754 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
3755 WIPHY_FLAG_AP_UAPSD
|
3756 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
3757 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
3758 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
3760 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3761 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
3762 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
3765 wiphy
->wowlan
= &mwifiex_wowlan_support
;
3768 wiphy
->coalesce
= &mwifiex_coalesce_support
;
3770 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
3771 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
3772 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
3774 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
3775 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
3777 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
3778 NL80211_FEATURE_INACTIVITY_TIMER
|
3779 NL80211_FEATURE_NEED_OBSS_SCAN
;
3781 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3782 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
3784 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
3785 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
3787 /* Reserve space for mwifiex specific private data for BSS */
3788 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
3790 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
3792 /* Set struct mwifiex_adapter pointer in wiphy_priv */
3793 wdev_priv
= wiphy_priv(wiphy
);
3794 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
3796 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
3798 ret
= wiphy_register(wiphy
);
3800 mwifiex_dbg(adapter
, ERROR
,
3801 "%s: wiphy_register failed: %d\n", __func__
, ret
);
3806 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
3807 mwifiex_dbg(adapter
, INFO
,
3808 "driver hint alpha2: %2.2s\n", reg_alpha2
);
3809 regulatory_hint(wiphy
, reg_alpha2
);
3811 country_code
= mwifiex_11d_code_2_region(adapter
->region_code
);
3813 mwifiex_dbg(adapter
, WARN
,
3814 "ignoring F/W country code %2.2s\n",
3818 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3819 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
3820 wiphy
->frag_threshold
= thr
;
3821 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3822 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
3823 wiphy
->rts_threshold
= thr
;
3824 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3825 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
3826 wiphy
->retry_short
= (u8
) retry
;
3827 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3828 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
3829 wiphy
->retry_long
= (u8
) retry
;
3831 adapter
->wiphy
= wiphy
;