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.
23 static char *reg_alpha2
;
24 module_param(reg_alpha2
, charp
, 0);
26 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits
[] = {
28 .max
= 2, .types
= BIT(NL80211_IFTYPE_STATION
) |
29 BIT(NL80211_IFTYPE_P2P_GO
) |
30 BIT(NL80211_IFTYPE_P2P_CLIENT
),
33 .max
= 1, .types
= BIT(NL80211_IFTYPE_AP
),
37 static const struct ieee80211_iface_combination mwifiex_iface_comb_ap_sta
= {
38 .limits
= mwifiex_ap_sta_limits
,
39 .num_different_channels
= 1,
40 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
41 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
42 .beacon_int_infra_match
= true,
46 * This function maps the nl802.11 channel type into driver channel type.
48 * The mapping is as follows -
49 * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE
50 * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE
51 * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE
52 * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW
53 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE
55 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
)
58 case NL80211_CHAN_NO_HT
:
59 case NL80211_CHAN_HT20
:
60 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
61 case NL80211_CHAN_HT40PLUS
:
62 return IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
63 case NL80211_CHAN_HT40MINUS
:
64 return IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
66 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
70 /* This function maps IEEE HT secondary channel type to NL80211 channel type
72 u8
mwifiex_sec_chan_offset_to_chan_type(u8 second_chan_offset
)
74 switch (second_chan_offset
) {
75 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
76 return NL80211_CHAN_HT20
;
77 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
78 return NL80211_CHAN_HT40PLUS
;
79 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
80 return NL80211_CHAN_HT40MINUS
;
82 return NL80211_CHAN_HT20
;
87 * This function checks whether WEP is set.
90 mwifiex_is_alg_wep(u32 cipher
)
93 case WLAN_CIPHER_SUITE_WEP40
:
94 case WLAN_CIPHER_SUITE_WEP104
:
104 * This function retrieves the private structure from kernel wiphy structure.
106 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
108 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
112 * CFG802.11 operation handler to delete a network key.
115 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
116 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
118 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
119 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
120 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
122 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
123 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
127 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
132 * This function forms an skb for management frame.
135 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
137 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
139 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
141 pkt_len
= len
+ ETH_ALEN
;
143 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
144 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
145 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
147 memcpy(skb_push(skb
, sizeof(tx_control
)),
148 &tx_control
, sizeof(tx_control
));
150 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
152 /* Add packet data and address4 */
153 memcpy(skb_put(skb
, sizeof(struct ieee80211_hdr_3addr
)), buf
,
154 sizeof(struct ieee80211_hdr_3addr
));
155 memcpy(skb_put(skb
, ETH_ALEN
), addr
, ETH_ALEN
);
156 memcpy(skb_put(skb
, len
- sizeof(struct ieee80211_hdr_3addr
)),
157 buf
+ sizeof(struct ieee80211_hdr_3addr
),
158 len
- sizeof(struct ieee80211_hdr_3addr
));
160 skb
->priority
= LOW_PRIO_TID
;
161 __net_timestamp(skb
);
167 * CFG802.11 operation handler to transmit a management frame.
170 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
171 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
173 const u8
*buf
= params
->buf
;
174 size_t len
= params
->len
;
177 const struct ieee80211_mgmt
*mgmt
;
178 struct mwifiex_txinfo
*tx_info
;
179 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
182 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
186 mgmt
= (const struct ieee80211_mgmt
*)buf
;
187 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
188 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
189 /* Since we support offload probe resp, we need to skip probe
190 * resp in AP or GO mode */
191 mwifiex_dbg(priv
->adapter
, INFO
,
192 "info: skip to send probe resp in AP or GO mode\n");
196 pkt_len
= len
+ ETH_ALEN
;
197 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
198 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
199 pkt_len
+ sizeof(pkt_len
));
202 mwifiex_dbg(priv
->adapter
, ERROR
,
203 "allocate skb failed for management frame\n");
207 tx_info
= MWIFIEX_SKB_TXCB(skb
);
208 memset(tx_info
, 0, sizeof(*tx_info
));
209 tx_info
->bss_num
= priv
->bss_num
;
210 tx_info
->bss_type
= priv
->bss_type
;
211 tx_info
->pkt_len
= pkt_len
;
213 mwifiex_form_mgmt_frame(skb
, buf
, len
);
214 *cookie
= prandom_u32() | 1;
216 if (ieee80211_is_action(mgmt
->frame_control
))
217 skb
= mwifiex_clone_skb_for_tx_status(priv
,
219 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
221 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
224 mwifiex_queue_tx_pkt(priv
, skb
);
226 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
231 * CFG802.11 operation handler to register a mgmt frame.
234 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
235 struct wireless_dev
*wdev
,
236 u16 frame_type
, bool reg
)
238 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
242 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
244 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
246 if (mask
!= priv
->mgmt_frame_mask
) {
247 priv
->mgmt_frame_mask
= mask
;
248 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
249 HostCmd_ACT_GEN_SET
, 0,
250 &priv
->mgmt_frame_mask
, false);
251 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
256 * CFG802.11 operation handler to remain on channel.
259 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
260 struct wireless_dev
*wdev
,
261 struct ieee80211_channel
*chan
,
262 unsigned int duration
, u64
*cookie
)
264 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
267 if (!chan
|| !cookie
) {
268 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
272 if (priv
->roc_cfg
.cookie
) {
273 mwifiex_dbg(priv
->adapter
, INFO
,
274 "info: ongoing ROC, cookie = 0x%llx\n",
275 priv
->roc_cfg
.cookie
);
279 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
283 *cookie
= prandom_u32() | 1;
284 priv
->roc_cfg
.cookie
= *cookie
;
285 priv
->roc_cfg
.chan
= *chan
;
287 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
288 duration
, GFP_ATOMIC
);
290 mwifiex_dbg(priv
->adapter
, INFO
,
291 "info: ROC, cookie = 0x%llx\n", *cookie
);
298 * CFG802.11 operation handler to cancel remain on channel.
301 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
302 struct wireless_dev
*wdev
, u64 cookie
)
304 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
307 if (cookie
!= priv
->roc_cfg
.cookie
)
310 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
311 &priv
->roc_cfg
.chan
, 0);
314 cfg80211_remain_on_channel_expired(wdev
, cookie
,
318 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
320 mwifiex_dbg(priv
->adapter
, INFO
,
321 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
328 * CFG802.11 operation handler to set Tx power.
331 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
332 struct wireless_dev
*wdev
,
333 enum nl80211_tx_power_setting type
,
336 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
337 struct mwifiex_private
*priv
;
338 struct mwifiex_power_cfg power_cfg
;
339 int dbm
= MBM_TO_DBM(mbm
);
341 if (type
== NL80211_TX_POWER_FIXED
) {
342 power_cfg
.is_power_auto
= 0;
343 power_cfg
.power_level
= dbm
;
345 power_cfg
.is_power_auto
= 1;
348 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
350 return mwifiex_set_tx_power(priv
, &power_cfg
);
354 * CFG802.11 operation handler to set Power Save option.
356 * The timeout value, if provided, is currently ignored.
359 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
360 struct net_device
*dev
,
361 bool enabled
, int timeout
)
363 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
367 mwifiex_dbg(priv
->adapter
, INFO
,
368 "info: ignore timeout value for IEEE Power Save\n");
372 return mwifiex_drv_set_power(priv
, &ps_mode
);
376 * CFG802.11 operation handler to set the default network key.
379 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
380 u8 key_index
, bool unicast
,
383 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
385 /* Return if WEP key not configured */
386 if (!priv
->sec_info
.wep_enabled
)
389 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
390 priv
->wep_key_curr_index
= key_index
;
391 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
393 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
401 * CFG802.11 operation handler to add a network key.
404 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
405 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
406 struct key_params
*params
)
408 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
409 struct mwifiex_wep_key
*wep_key
;
410 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
411 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
413 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
414 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
415 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
416 if (params
->key
&& params
->key_len
) {
417 wep_key
= &priv
->wep_key
[key_index
];
418 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
419 memcpy(wep_key
->key_material
, params
->key
,
421 wep_key
->key_index
= key_index
;
422 wep_key
->key_length
= params
->key_len
;
423 priv
->sec_info
.wep_enabled
= 1;
428 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
429 key_index
, peer_mac
, 0)) {
430 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
438 * This function sends domain information to the firmware.
440 * The following information are passed to the firmware -
442 * - Sub bands (first channel, number of channels, maximum Tx power)
444 static int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
446 u8 no_of_triplet
= 0;
447 struct ieee80211_country_ie_triplet
*t
;
448 u8 no_of_parsed_chan
= 0;
449 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
451 enum ieee80211_band band
;
452 struct ieee80211_supported_band
*sband
;
453 struct ieee80211_channel
*ch
;
454 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
455 struct mwifiex_private
*priv
;
456 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
458 /* Set country code */
459 domain_info
->country_code
[0] = adapter
->country_code
[0];
460 domain_info
->country_code
[1] = adapter
->country_code
[1];
461 domain_info
->country_code
[2] = ' ';
463 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
464 if (!wiphy
->bands
[band
]) {
465 mwifiex_dbg(adapter
, ERROR
,
466 "11D: setting domain info in FW\n");
470 sband
= wiphy
->bands
[band
];
472 for (i
= 0; i
< sband
->n_channels
; i
++) {
473 ch
= &sband
->channels
[i
];
474 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
479 first_chan
= (u32
) ch
->hw_value
;
480 next_chan
= first_chan
;
481 max_pwr
= ch
->max_power
;
482 no_of_parsed_chan
= 1;
486 if (ch
->hw_value
== next_chan
+ 1 &&
487 ch
->max_power
== max_pwr
) {
491 t
= &domain_info
->triplet
[no_of_triplet
];
492 t
->chans
.first_channel
= first_chan
;
493 t
->chans
.num_channels
= no_of_parsed_chan
;
494 t
->chans
.max_power
= max_pwr
;
496 first_chan
= (u32
) ch
->hw_value
;
497 next_chan
= first_chan
;
498 max_pwr
= ch
->max_power
;
499 no_of_parsed_chan
= 1;
504 t
= &domain_info
->triplet
[no_of_triplet
];
505 t
->chans
.first_channel
= first_chan
;
506 t
->chans
.num_channels
= no_of_parsed_chan
;
507 t
->chans
.max_power
= max_pwr
;
511 domain_info
->no_of_triplet
= no_of_triplet
;
513 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
515 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
516 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
517 mwifiex_dbg(adapter
, INFO
,
518 "11D: setting domain info in FW\n");
526 * CFG802.11 regulatory domain callback function.
528 * This function is called when the regulatory domain is changed due to the
529 * following reasons -
531 * - Set by system core
533 * - Set bt Country IE
535 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
536 struct regulatory_request
*request
)
538 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
539 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
540 MWIFIEX_BSS_ROLE_ANY
);
541 mwifiex_dbg(adapter
, INFO
,
542 "info: cfg80211 regulatory domain callback for %c%c\n",
543 request
->alpha2
[0], request
->alpha2
[1]);
545 switch (request
->initiator
) {
546 case NL80211_REGDOM_SET_BY_DRIVER
:
547 case NL80211_REGDOM_SET_BY_CORE
:
548 case NL80211_REGDOM_SET_BY_USER
:
549 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
552 mwifiex_dbg(adapter
, ERROR
,
553 "unknown regdom initiator: %d\n",
558 /* Don't send world or same regdom info to firmware */
559 if (strncmp(request
->alpha2
, "00", 2) &&
560 strncmp(request
->alpha2
, adapter
->country_code
,
561 sizeof(request
->alpha2
))) {
562 memcpy(adapter
->country_code
, request
->alpha2
,
563 sizeof(request
->alpha2
));
564 mwifiex_send_domain_info_cmd_fw(wiphy
);
565 mwifiex_dnld_txpwr_table(priv
);
570 * This function sets the fragmentation threshold.
572 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
573 * and MWIFIEX_FRAG_MAX_VALUE.
576 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
578 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
579 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
580 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
582 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
583 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
588 * This function sets the RTS threshold.
590 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
591 * and MWIFIEX_RTS_MAX_VALUE.
594 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
596 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
597 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
599 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
600 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
605 * CFG802.11 operation handler to set wiphy parameters.
607 * This function can be used to set the RTS threshold and the
608 * Fragmentation threshold of the driver.
611 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
613 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
614 struct mwifiex_private
*priv
;
615 struct mwifiex_uap_bss_param
*bss_cfg
;
618 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
620 switch (priv
->bss_role
) {
621 case MWIFIEX_BSS_ROLE_UAP
:
622 if (priv
->bss_started
) {
623 mwifiex_dbg(adapter
, ERROR
,
624 "cannot change wiphy params when bss started");
628 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
632 mwifiex_set_sys_config_invalid_data(bss_cfg
);
634 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
635 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
636 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
637 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
638 if (changed
& WIPHY_PARAM_RETRY_LONG
)
639 bss_cfg
->retry_limit
= wiphy
->retry_long
;
641 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
643 UAP_BSS_PARAMS_I
, bss_cfg
,
648 mwifiex_dbg(adapter
, ERROR
,
649 "Failed to set wiphy phy params\n");
654 case MWIFIEX_BSS_ROLE_STA
:
655 if (priv
->media_connected
) {
656 mwifiex_dbg(adapter
, ERROR
,
657 "cannot change wiphy params when connected");
660 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
661 ret
= mwifiex_set_rts(priv
,
662 wiphy
->rts_threshold
);
666 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
667 ret
= mwifiex_set_frag(priv
,
668 wiphy
->frag_threshold
);
679 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
681 u16 mode
= P2P_MODE_DISABLE
;
683 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
684 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
691 * This function initializes the functionalities for P2P client.
692 * The P2P client initialization sequence is:
693 * disable -> device -> client
696 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
700 if (mwifiex_cfg80211_deinit_p2p(priv
))
703 mode
= P2P_MODE_DEVICE
;
704 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
705 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
708 mode
= P2P_MODE_CLIENT
;
709 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
710 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
717 * This function initializes the functionalities for P2P GO.
718 * The P2P GO initialization sequence is:
719 * disable -> device -> GO
722 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
726 if (mwifiex_cfg80211_deinit_p2p(priv
))
729 mode
= P2P_MODE_DEVICE
;
730 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
731 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
735 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
736 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
742 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
744 struct mwifiex_adapter
*adapter
= priv
->adapter
;
747 priv
->mgmt_frame_mask
= 0;
748 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
749 HostCmd_ACT_GEN_SET
, 0,
750 &priv
->mgmt_frame_mask
, false)) {
751 mwifiex_dbg(adapter
, ERROR
,
752 "could not unregister mgmt frame rx\n");
756 mwifiex_deauthenticate(priv
, NULL
);
758 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
759 adapter
->main_locked
= true;
760 if (adapter
->mwifiex_processing
) {
761 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
762 flush_workqueue(adapter
->workqueue
);
764 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
767 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
768 adapter
->rx_locked
= true;
769 if (adapter
->rx_processing
) {
770 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
771 flush_workqueue(adapter
->rx_workqueue
);
773 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
776 mwifiex_free_priv(priv
);
777 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
778 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
779 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
785 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
786 struct net_device
*dev
,
787 enum nl80211_iftype type
)
789 struct mwifiex_adapter
*adapter
= priv
->adapter
;
792 mwifiex_init_priv(priv
);
794 priv
->bss_mode
= type
;
795 priv
->wdev
.iftype
= type
;
797 mwifiex_init_priv_params(priv
, priv
->netdev
);
798 priv
->bss_started
= 0;
801 case NL80211_IFTYPE_STATION
:
802 case NL80211_IFTYPE_ADHOC
:
803 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
804 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
806 case NL80211_IFTYPE_P2P_CLIENT
:
807 case NL80211_IFTYPE_P2P_GO
:
808 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
809 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
811 case NL80211_IFTYPE_AP
:
812 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
813 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
816 mwifiex_dbg(adapter
, ERROR
,
817 "%s: changing to %d not supported\n",
822 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
823 adapter
->main_locked
= false;
824 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
826 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
827 adapter
->rx_locked
= false;
828 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
834 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
835 enum nl80211_iftype curr_iftype
,
836 enum nl80211_iftype type
, u32
*flags
,
837 struct vif_params
*params
)
839 struct mwifiex_private
*priv
;
840 struct mwifiex_adapter
*adapter
;
842 priv
= mwifiex_netdev_get_priv(dev
);
847 adapter
= priv
->adapter
;
849 if (adapter
->curr_iface_comb
.p2p_intf
==
850 adapter
->iface_limit
.p2p_intf
) {
851 mwifiex_dbg(adapter
, ERROR
,
852 "cannot create multiple P2P ifaces\n");
856 mwifiex_dbg(adapter
, INFO
,
857 "%s: changing role to p2p\n", dev
->name
);
859 if (mwifiex_deinit_priv_params(priv
))
861 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
865 case NL80211_IFTYPE_P2P_CLIENT
:
866 if (mwifiex_cfg80211_init_p2p_client(priv
))
869 case NL80211_IFTYPE_P2P_GO
:
870 if (mwifiex_cfg80211_init_p2p_go(priv
))
874 mwifiex_dbg(adapter
, ERROR
,
875 "%s: changing to %d not supported\n",
880 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
881 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
884 if (mwifiex_sta_init_cmd(priv
, false, false))
887 switch (curr_iftype
) {
888 case NL80211_IFTYPE_STATION
:
889 case NL80211_IFTYPE_ADHOC
:
890 adapter
->curr_iface_comb
.sta_intf
--;
892 case NL80211_IFTYPE_AP
:
893 adapter
->curr_iface_comb
.uap_intf
--;
899 adapter
->curr_iface_comb
.p2p_intf
++;
900 dev
->ieee80211_ptr
->iftype
= type
;
906 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
907 enum nl80211_iftype curr_iftype
,
908 enum nl80211_iftype type
, u32
*flags
,
909 struct vif_params
*params
)
911 struct mwifiex_private
*priv
;
912 struct mwifiex_adapter
*adapter
;
914 priv
= mwifiex_netdev_get_priv(dev
);
919 adapter
= priv
->adapter
;
921 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
922 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
923 (adapter
->curr_iface_comb
.sta_intf
==
924 adapter
->iface_limit
.sta_intf
)) {
925 mwifiex_dbg(adapter
, ERROR
,
926 "cannot create multiple station/adhoc ifaces\n");
930 if (type
== NL80211_IFTYPE_STATION
)
931 mwifiex_dbg(adapter
, INFO
,
932 "%s: changing role to station\n", dev
->name
);
934 mwifiex_dbg(adapter
, INFO
,
935 "%s: changing role to adhoc\n", dev
->name
);
937 if (mwifiex_deinit_priv_params(priv
))
939 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
941 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
942 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
944 if (mwifiex_sta_init_cmd(priv
, false, false))
947 switch (curr_iftype
) {
948 case NL80211_IFTYPE_P2P_CLIENT
:
949 case NL80211_IFTYPE_P2P_GO
:
950 adapter
->curr_iface_comb
.p2p_intf
--;
952 case NL80211_IFTYPE_AP
:
953 adapter
->curr_iface_comb
.uap_intf
--;
959 adapter
->curr_iface_comb
.sta_intf
++;
960 dev
->ieee80211_ptr
->iftype
= type
;
965 mwifiex_change_vif_to_ap(struct net_device
*dev
,
966 enum nl80211_iftype curr_iftype
,
967 enum nl80211_iftype type
, u32
*flags
,
968 struct vif_params
*params
)
970 struct mwifiex_private
*priv
;
971 struct mwifiex_adapter
*adapter
;
973 priv
= mwifiex_netdev_get_priv(dev
);
978 adapter
= priv
->adapter
;
980 if (adapter
->curr_iface_comb
.uap_intf
==
981 adapter
->iface_limit
.uap_intf
) {
982 mwifiex_dbg(adapter
, ERROR
,
983 "cannot create multiple AP ifaces\n");
987 mwifiex_dbg(adapter
, INFO
,
988 "%s: changing role to AP\n", dev
->name
);
990 if (mwifiex_deinit_priv_params(priv
))
992 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
994 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
995 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
997 if (mwifiex_sta_init_cmd(priv
, false, false))
1000 switch (curr_iftype
) {
1001 case NL80211_IFTYPE_P2P_CLIENT
:
1002 case NL80211_IFTYPE_P2P_GO
:
1003 adapter
->curr_iface_comb
.p2p_intf
--;
1005 case NL80211_IFTYPE_STATION
:
1006 case NL80211_IFTYPE_ADHOC
:
1007 adapter
->curr_iface_comb
.sta_intf
--;
1013 adapter
->curr_iface_comb
.uap_intf
++;
1014 dev
->ieee80211_ptr
->iftype
= type
;
1018 * CFG802.11 operation handler to change interface type.
1021 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1022 struct net_device
*dev
,
1023 enum nl80211_iftype type
, u32
*flags
,
1024 struct vif_params
*params
)
1026 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1027 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1029 switch (curr_iftype
) {
1030 case NL80211_IFTYPE_ADHOC
:
1032 case NL80211_IFTYPE_STATION
:
1033 priv
->bss_mode
= type
;
1034 priv
->sec_info
.authentication_mode
=
1035 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1036 dev
->ieee80211_ptr
->iftype
= type
;
1037 mwifiex_deauthenticate(priv
, NULL
);
1038 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1039 HostCmd_ACT_GEN_SET
, 0, NULL
,
1041 case NL80211_IFTYPE_P2P_CLIENT
:
1042 case NL80211_IFTYPE_P2P_GO
:
1043 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1044 type
, flags
, params
);
1045 case NL80211_IFTYPE_AP
:
1046 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1048 case NL80211_IFTYPE_UNSPECIFIED
:
1049 mwifiex_dbg(priv
->adapter
, INFO
,
1050 "%s: kept type as IBSS\n", dev
->name
);
1051 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1054 mwifiex_dbg(priv
->adapter
, ERROR
,
1055 "%s: changing to %d not supported\n",
1060 case NL80211_IFTYPE_STATION
:
1062 case NL80211_IFTYPE_ADHOC
:
1063 priv
->bss_mode
= type
;
1064 priv
->sec_info
.authentication_mode
=
1065 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1066 dev
->ieee80211_ptr
->iftype
= type
;
1067 mwifiex_deauthenticate(priv
, NULL
);
1068 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1069 HostCmd_ACT_GEN_SET
, 0, NULL
,
1071 case NL80211_IFTYPE_P2P_CLIENT
:
1072 case NL80211_IFTYPE_P2P_GO
:
1073 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1074 type
, flags
, params
);
1075 case NL80211_IFTYPE_AP
:
1076 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1078 case NL80211_IFTYPE_UNSPECIFIED
:
1079 mwifiex_dbg(priv
->adapter
, INFO
,
1080 "%s: kept type as STA\n", dev
->name
);
1081 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1084 mwifiex_dbg(priv
->adapter
, ERROR
,
1085 "%s: changing to %d not supported\n",
1090 case NL80211_IFTYPE_AP
:
1092 case NL80211_IFTYPE_ADHOC
:
1093 case NL80211_IFTYPE_STATION
:
1094 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1098 case NL80211_IFTYPE_P2P_CLIENT
:
1099 case NL80211_IFTYPE_P2P_GO
:
1100 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1101 type
, flags
, params
);
1102 case NL80211_IFTYPE_UNSPECIFIED
:
1103 mwifiex_dbg(priv
->adapter
, INFO
,
1104 "%s: kept type as AP\n", dev
->name
);
1105 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1108 mwifiex_dbg(priv
->adapter
, ERROR
,
1109 "%s: changing to %d not supported\n",
1114 case NL80211_IFTYPE_P2P_CLIENT
:
1115 case NL80211_IFTYPE_P2P_GO
:
1117 case NL80211_IFTYPE_STATION
:
1118 if (mwifiex_cfg80211_init_p2p_client(priv
))
1120 dev
->ieee80211_ptr
->iftype
= type
;
1122 case NL80211_IFTYPE_ADHOC
:
1123 if (mwifiex_cfg80211_deinit_p2p(priv
))
1125 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1129 case NL80211_IFTYPE_AP
:
1130 if (mwifiex_cfg80211_deinit_p2p(priv
))
1132 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1134 case NL80211_IFTYPE_UNSPECIFIED
:
1135 mwifiex_dbg(priv
->adapter
, INFO
,
1136 "%s: kept type as P2P\n", dev
->name
);
1137 case NL80211_IFTYPE_P2P_CLIENT
:
1138 case NL80211_IFTYPE_P2P_GO
:
1141 mwifiex_dbg(priv
->adapter
, ERROR
,
1142 "%s: changing to %d not supported\n",
1148 mwifiex_dbg(priv
->adapter
, ERROR
,
1149 "%s: unknown iftype: %d\n",
1150 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1159 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1160 struct rate_info
*rate
)
1162 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1164 if (adapter
->is_hw_11ac_capable
) {
1165 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1166 if (tx_htinfo
& BIT(0)) {
1168 rate
->mcs
= priv
->tx_rate
;
1169 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1171 if (tx_htinfo
& BIT(1)) {
1173 rate
->mcs
= priv
->tx_rate
& 0x0F;
1174 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1177 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1179 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1181 rate
->bw
= RATE_INFO_BW_20
;
1184 rate
->bw
= RATE_INFO_BW_40
;
1187 rate
->bw
= RATE_INFO_BW_80
;
1189 case (BIT(3) | BIT(2)):
1190 rate
->bw
= RATE_INFO_BW_160
;
1194 if (tx_htinfo
& BIT(4))
1195 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1197 if ((priv
->tx_rate
>> 4) == 1)
1204 * Bit 0 in tx_htinfo indicates that current Tx rate
1205 * is 11n rate. Valid MCS index values for us are 0 to 15.
1207 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1208 rate
->mcs
= priv
->tx_rate
;
1209 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1210 rate
->bw
= RATE_INFO_BW_20
;
1211 if (tx_htinfo
& BIT(1))
1212 rate
->bw
= RATE_INFO_BW_40
;
1213 if (tx_htinfo
& BIT(2))
1214 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1220 * This function dumps the station information on a buffer.
1222 * The following information are shown -
1223 * - Total bytes transmitted
1224 * - Total bytes received
1225 * - Total packets transmitted
1226 * - Total packets received
1227 * - Signal quality level
1228 * - Transmission rate
1231 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1232 struct mwifiex_sta_node
*node
,
1233 struct station_info
*sinfo
)
1237 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1238 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1239 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1240 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1242 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1246 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1247 BIT(NL80211_STA_INFO_TX_FAILED
);
1248 sinfo
->inactive_time
=
1249 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1251 sinfo
->signal
= node
->stats
.rssi
;
1252 sinfo
->signal_avg
= node
->stats
.rssi
;
1253 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1254 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1255 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1256 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1257 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1259 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1261 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1266 /* Get signal information from the firmware */
1267 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1268 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1269 mwifiex_dbg(priv
->adapter
, ERROR
,
1270 "failed to get signal information\n");
1274 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1275 mwifiex_dbg(priv
->adapter
, ERROR
,
1276 "getting data rate error\n");
1280 /* Get DTIM period information from firmware */
1281 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1282 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1283 &priv
->dtim_period
, true);
1285 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1287 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1288 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1289 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1290 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1291 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1292 sinfo
->signal
= priv
->bcn_rssi_avg
;
1293 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1294 sinfo
->txrate
.legacy
= rate
* 5;
1296 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1297 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1298 sinfo
->bss_param
.flags
= 0;
1299 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1300 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1301 sinfo
->bss_param
.flags
|=
1302 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1303 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1304 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1305 sinfo
->bss_param
.flags
|=
1306 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1307 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1308 sinfo
->bss_param
.beacon_interval
=
1309 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1316 * CFG802.11 operation handler to get station information.
1318 * This function only works in connected mode, and dumps the
1319 * requested station information, if available.
1322 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1323 const u8
*mac
, struct station_info
*sinfo
)
1325 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1327 if (!priv
->media_connected
)
1329 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1332 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1336 * CFG802.11 operation handler to dump station information.
1339 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1340 int idx
, u8
*mac
, struct station_info
*sinfo
)
1342 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1343 static struct mwifiex_sta_node
*node
;
1345 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1346 priv
->media_connected
&& idx
== 0) {
1347 ether_addr_copy(mac
, priv
->cfg_bssid
);
1348 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1349 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1350 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1351 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1353 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1358 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1359 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1360 ether_addr_copy(mac
, node
->mac_addr
);
1361 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1369 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1370 int idx
, struct survey_info
*survey
)
1372 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1373 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1374 enum ieee80211_band band
;
1376 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1378 memset(survey
, 0, sizeof(struct survey_info
));
1380 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1381 priv
->media_connected
&& idx
== 0) {
1382 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1383 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1385 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1386 survey
->channel
= ieee80211_get_channel(wiphy
,
1387 ieee80211_channel_to_frequency(chan
, band
));
1389 if (priv
->bcn_nf_last
) {
1390 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1391 survey
->noise
= priv
->bcn_nf_last
;
1396 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1399 if (!pchan_stats
[idx
].cca_scan_dur
)
1402 band
= pchan_stats
[idx
].bandcfg
;
1403 survey
->channel
= ieee80211_get_channel(wiphy
,
1404 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1405 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1407 SURVEY_INFO_TIME_BUSY
;
1408 survey
->noise
= pchan_stats
[idx
].noise
;
1409 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1410 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1415 /* Supported rates to be advertised to the cfg80211 */
1416 static struct ieee80211_rate mwifiex_rates
[] = {
1417 {.bitrate
= 10, .hw_value
= 2, },
1418 {.bitrate
= 20, .hw_value
= 4, },
1419 {.bitrate
= 55, .hw_value
= 11, },
1420 {.bitrate
= 110, .hw_value
= 22, },
1421 {.bitrate
= 60, .hw_value
= 12, },
1422 {.bitrate
= 90, .hw_value
= 18, },
1423 {.bitrate
= 120, .hw_value
= 24, },
1424 {.bitrate
= 180, .hw_value
= 36, },
1425 {.bitrate
= 240, .hw_value
= 48, },
1426 {.bitrate
= 360, .hw_value
= 72, },
1427 {.bitrate
= 480, .hw_value
= 96, },
1428 {.bitrate
= 540, .hw_value
= 108, },
1431 /* Channel definitions to be advertised to cfg80211 */
1432 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1433 {.center_freq
= 2412, .hw_value
= 1, },
1434 {.center_freq
= 2417, .hw_value
= 2, },
1435 {.center_freq
= 2422, .hw_value
= 3, },
1436 {.center_freq
= 2427, .hw_value
= 4, },
1437 {.center_freq
= 2432, .hw_value
= 5, },
1438 {.center_freq
= 2437, .hw_value
= 6, },
1439 {.center_freq
= 2442, .hw_value
= 7, },
1440 {.center_freq
= 2447, .hw_value
= 8, },
1441 {.center_freq
= 2452, .hw_value
= 9, },
1442 {.center_freq
= 2457, .hw_value
= 10, },
1443 {.center_freq
= 2462, .hw_value
= 11, },
1444 {.center_freq
= 2467, .hw_value
= 12, },
1445 {.center_freq
= 2472, .hw_value
= 13, },
1446 {.center_freq
= 2484, .hw_value
= 14, },
1449 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1450 .channels
= mwifiex_channels_2ghz
,
1451 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1452 .bitrates
= mwifiex_rates
,
1453 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1456 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1457 {.center_freq
= 5040, .hw_value
= 8, },
1458 {.center_freq
= 5060, .hw_value
= 12, },
1459 {.center_freq
= 5080, .hw_value
= 16, },
1460 {.center_freq
= 5170, .hw_value
= 34, },
1461 {.center_freq
= 5190, .hw_value
= 38, },
1462 {.center_freq
= 5210, .hw_value
= 42, },
1463 {.center_freq
= 5230, .hw_value
= 46, },
1464 {.center_freq
= 5180, .hw_value
= 36, },
1465 {.center_freq
= 5200, .hw_value
= 40, },
1466 {.center_freq
= 5220, .hw_value
= 44, },
1467 {.center_freq
= 5240, .hw_value
= 48, },
1468 {.center_freq
= 5260, .hw_value
= 52, },
1469 {.center_freq
= 5280, .hw_value
= 56, },
1470 {.center_freq
= 5300, .hw_value
= 60, },
1471 {.center_freq
= 5320, .hw_value
= 64, },
1472 {.center_freq
= 5500, .hw_value
= 100, },
1473 {.center_freq
= 5520, .hw_value
= 104, },
1474 {.center_freq
= 5540, .hw_value
= 108, },
1475 {.center_freq
= 5560, .hw_value
= 112, },
1476 {.center_freq
= 5580, .hw_value
= 116, },
1477 {.center_freq
= 5600, .hw_value
= 120, },
1478 {.center_freq
= 5620, .hw_value
= 124, },
1479 {.center_freq
= 5640, .hw_value
= 128, },
1480 {.center_freq
= 5660, .hw_value
= 132, },
1481 {.center_freq
= 5680, .hw_value
= 136, },
1482 {.center_freq
= 5700, .hw_value
= 140, },
1483 {.center_freq
= 5745, .hw_value
= 149, },
1484 {.center_freq
= 5765, .hw_value
= 153, },
1485 {.center_freq
= 5785, .hw_value
= 157, },
1486 {.center_freq
= 5805, .hw_value
= 161, },
1487 {.center_freq
= 5825, .hw_value
= 165, },
1490 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1491 .channels
= mwifiex_channels_5ghz
,
1492 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1493 .bitrates
= mwifiex_rates
+ 4,
1494 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1498 /* Supported crypto cipher suits to be advertised to cfg80211 */
1499 static const u32 mwifiex_cipher_suites
[] = {
1500 WLAN_CIPHER_SUITE_WEP40
,
1501 WLAN_CIPHER_SUITE_WEP104
,
1502 WLAN_CIPHER_SUITE_TKIP
,
1503 WLAN_CIPHER_SUITE_CCMP
,
1504 WLAN_CIPHER_SUITE_AES_CMAC
,
1507 /* Supported mgmt frame types to be advertised to cfg80211 */
1508 static const struct ieee80211_txrx_stypes
1509 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1510 [NL80211_IFTYPE_STATION
] = {
1511 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1512 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1513 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1514 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1516 [NL80211_IFTYPE_AP
] = {
1517 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1518 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1519 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1520 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1522 [NL80211_IFTYPE_P2P_CLIENT
] = {
1523 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1524 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1525 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1526 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1528 [NL80211_IFTYPE_P2P_GO
] = {
1529 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1530 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1531 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1532 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1537 * CFG802.11 operation handler for setting bit rates.
1539 * Function configures data rates to firmware using bitrate mask
1540 * provided by cfg80211.
1542 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1543 struct net_device
*dev
,
1545 const struct cfg80211_bitrate_mask
*mask
)
1547 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1548 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1549 enum ieee80211_band band
;
1550 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1552 if (!priv
->media_connected
) {
1553 mwifiex_dbg(adapter
, ERROR
,
1554 "Can not set Tx data rate in disconnected state\n");
1558 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1560 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1562 /* Fill HR/DSSS rates. */
1563 if (band
== IEEE80211_BAND_2GHZ
)
1564 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1566 /* Fill OFDM rates */
1567 if (band
== IEEE80211_BAND_2GHZ
)
1568 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1570 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1572 /* Fill HT MCS rates */
1573 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1574 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1575 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1577 /* Fill VHT MCS rates */
1578 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1579 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1580 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1581 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1584 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1585 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1589 * CFG802.11 operation handler for connection quality monitoring.
1591 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1594 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1595 struct net_device
*dev
,
1596 s32 rssi_thold
, u32 rssi_hyst
)
1598 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1599 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1601 priv
->cqm_rssi_thold
= rssi_thold
;
1602 priv
->cqm_rssi_hyst
= rssi_hyst
;
1604 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1605 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1607 /* Subscribe/unsubscribe low and high rssi events */
1608 if (rssi_thold
&& rssi_hyst
) {
1609 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1610 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1611 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1612 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1613 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1614 return mwifiex_send_cmd(priv
,
1615 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1616 0, 0, &subsc_evt
, true);
1618 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1619 return mwifiex_send_cmd(priv
,
1620 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1621 0, 0, &subsc_evt
, true);
1627 /* cfg80211 operation handler for change_beacon.
1628 * Function retrieves and sets modified management IEs to FW.
1630 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1631 struct net_device
*dev
,
1632 struct cfg80211_beacon_data
*data
)
1634 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1636 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1637 mwifiex_dbg(priv
->adapter
, ERROR
,
1638 "%s: bss_type mismatched\n", __func__
);
1642 if (!priv
->bss_started
) {
1643 mwifiex_dbg(priv
->adapter
, ERROR
,
1644 "%s: bss not started\n", __func__
);
1648 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1649 mwifiex_dbg(priv
->adapter
, ERROR
,
1650 "%s: setting mgmt ies failed\n", __func__
);
1657 /* cfg80211 operation handler for del_station.
1658 * Function deauthenticates station which value is provided in mac parameter.
1659 * If mac is NULL/broadcast, all stations in associated station list are
1660 * deauthenticated. If bss is not started or there are no stations in
1661 * associated stations list, no action is taken.
1664 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1665 struct station_del_parameters
*params
)
1667 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1668 struct mwifiex_sta_node
*sta_node
;
1669 u8 deauth_mac
[ETH_ALEN
];
1670 unsigned long flags
;
1672 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1675 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1678 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1679 __func__
, params
->mac
);
1681 eth_zero_addr(deauth_mac
);
1683 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1684 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1686 ether_addr_copy(deauth_mac
, params
->mac
);
1687 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1689 if (is_valid_ether_addr(deauth_mac
)) {
1690 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1691 HostCmd_ACT_GEN_SET
, 0,
1700 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1702 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1703 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1704 MWIFIEX_BSS_ROLE_ANY
);
1705 struct mwifiex_ds_ant_cfg ant_cfg
;
1707 if (!tx_ant
|| !rx_ant
)
1710 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1711 /* Not a MIMO chip. User should provide specific antenna number
1712 * for Tx/Rx path or enable all antennas for diversity
1714 if (tx_ant
!= rx_ant
)
1717 if ((tx_ant
& (tx_ant
- 1)) &&
1718 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1721 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1722 (priv
->adapter
->number_of_antenna
> 1)) {
1723 tx_ant
= RF_ANTENNA_AUTO
;
1724 rx_ant
= RF_ANTENNA_AUTO
;
1727 struct ieee80211_sta_ht_cap
*ht_info
;
1729 enum ieee80211_band band
;
1731 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1732 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1733 if (adapter
->is_hw_11ac_capable
)
1734 adapter
->usr_dot_11ac_mcs_support
=
1735 MWIFIEX_11AC_MCS_MAP_1X1
;
1737 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1738 if (adapter
->is_hw_11ac_capable
)
1739 adapter
->usr_dot_11ac_mcs_support
=
1740 MWIFIEX_11AC_MCS_MAP_2X2
;
1743 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
1744 if (!adapter
->wiphy
->bands
[band
])
1747 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1749 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1750 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1751 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1755 ant_cfg
.tx_ant
= tx_ant
;
1756 ant_cfg
.rx_ant
= rx_ant
;
1758 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1759 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1762 /* cfg80211 operation handler for stop ap.
1763 * Function stops BSS running at uAP interface.
1765 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1767 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1769 mwifiex_abort_cac(priv
);
1771 if (mwifiex_del_mgmt_ies(priv
))
1772 mwifiex_dbg(priv
->adapter
, ERROR
,
1773 "Failed to delete mgmt IEs!\n");
1775 priv
->ap_11n_enabled
= 0;
1776 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1778 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1779 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1780 mwifiex_dbg(priv
->adapter
, ERROR
,
1781 "Failed to stop the BSS\n");
1785 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1786 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1787 mwifiex_dbg(priv
->adapter
, ERROR
,
1788 "Failed to reset BSS\n");
1795 /* cfg80211 operation handler for start_ap.
1796 * Function sets beacon period, DTIM period, SSID and security into
1797 * AP config structure.
1798 * AP is configured with these settings and BSS is started.
1800 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1801 struct net_device
*dev
,
1802 struct cfg80211_ap_settings
*params
)
1804 struct mwifiex_uap_bss_param
*bss_cfg
;
1805 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1807 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1810 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1814 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1816 if (params
->beacon_interval
)
1817 bss_cfg
->beacon_period
= params
->beacon_interval
;
1818 if (params
->dtim_period
)
1819 bss_cfg
->dtim_period
= params
->dtim_period
;
1821 if (params
->ssid
&& params
->ssid_len
) {
1822 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1823 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1825 if (params
->inactivity_timeout
> 0) {
1826 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1827 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1828 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1831 switch (params
->hidden_ssid
) {
1832 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1833 bss_cfg
->bcast_ssid_ctl
= 1;
1835 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1836 bss_cfg
->bcast_ssid_ctl
= 0;
1838 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1839 /* firmware doesn't support this type of hidden SSID */
1845 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1846 mwifiex_set_uap_rates(bss_cfg
, params
);
1848 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1850 mwifiex_dbg(priv
->adapter
, ERROR
,
1851 "Failed to parse secuirty parameters!\n");
1855 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1857 if (priv
->adapter
->is_hw_11ac_capable
) {
1858 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1859 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1860 priv
->ap_11ac_enabled
);
1863 if (priv
->ap_11ac_enabled
)
1864 mwifiex_set_11ac_ba_params(priv
);
1866 mwifiex_set_ba_params(priv
);
1868 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1870 if (mwifiex_is_11h_active(priv
))
1871 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
1873 if (mwifiex_is_11h_active(priv
) &&
1874 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
1876 mwifiex_dbg(priv
->adapter
, INFO
,
1877 "Disable 11h extensions in FW\n");
1878 if (mwifiex_11h_activate(priv
, false)) {
1879 mwifiex_dbg(priv
->adapter
, ERROR
,
1880 "Failed to disable 11h extensions!!");
1883 priv
->state_11h
.is_11h_active
= false;
1886 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
1887 mwifiex_dbg(priv
->adapter
, ERROR
,
1888 "Failed to start AP\n");
1893 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
1896 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
1902 * CFG802.11 operation handler for disconnection request.
1904 * This function does not work when there is already a disconnection
1905 * procedure going on.
1908 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
1911 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1913 if (mwifiex_deauthenticate(priv
, NULL
))
1916 mwifiex_dbg(priv
->adapter
, MSG
,
1917 "info: successfully disconnected from %pM:\t"
1918 "reason code %d\n", priv
->cfg_bssid
, reason_code
);
1920 eth_zero_addr(priv
->cfg_bssid
);
1921 priv
->hs2_enabled
= false;
1927 * This function informs the CFG802.11 subsystem of a new IBSS.
1929 * The following information are sent to the CFG802.11 subsystem
1930 * to register the new IBSS. If we do not register the new IBSS,
1931 * a kernel panic will result.
1937 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
1939 struct ieee80211_channel
*chan
;
1940 struct mwifiex_bss_info bss_info
;
1941 struct cfg80211_bss
*bss
;
1943 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
1944 enum ieee80211_band band
;
1946 if (mwifiex_get_bss_info(priv
, &bss_info
))
1949 ie_buf
[0] = WLAN_EID_SSID
;
1950 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
1952 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
1953 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
1954 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
1956 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1957 chan
= __ieee80211_get_channel(priv
->wdev
.wiphy
,
1958 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
1961 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
1962 CFG80211_BSS_FTYPE_UNKNOWN
,
1963 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
1964 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
1965 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
1966 memcpy(priv
->cfg_bssid
, bss_info
.bssid
, ETH_ALEN
);
1972 * This function connects with a BSS.
1974 * This function handles both Infra and Ad-Hoc modes. It also performs
1975 * validity checking on the provided parameters, disconnects from the
1976 * current BSS (if any), sets up the association/scan parameters,
1977 * including security settings, and performs specific SSID scan before
1978 * trying to connect.
1980 * For Infra mode, the function returns failure if the specified SSID
1981 * is not found in scan table. However, for Ad-Hoc mode, it can create
1982 * the IBSS if it does not exist. On successful completion in either case,
1983 * the function notifies the CFG802.11 subsystem of the new BSS connection.
1986 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
1987 const u8
*ssid
, const u8
*bssid
, int mode
,
1988 struct ieee80211_channel
*channel
,
1989 struct cfg80211_connect_params
*sme
, bool privacy
)
1991 struct cfg80211_ssid req_ssid
;
1992 int ret
, auth_type
= 0;
1993 struct cfg80211_bss
*bss
= NULL
;
1994 u8 is_scanning_required
= 0;
1996 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
1998 req_ssid
.ssid_len
= ssid_len
;
1999 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2000 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2004 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2005 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2006 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2010 /* As this is new association, clear locally stored
2011 * keys and security related flags */
2012 priv
->sec_info
.wpa_enabled
= false;
2013 priv
->sec_info
.wpa2_enabled
= false;
2014 priv
->wep_key_curr_index
= 0;
2015 priv
->sec_info
.encryption_mode
= 0;
2016 priv
->sec_info
.is_authtype_auto
= 0;
2017 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2019 if (mode
== NL80211_IFTYPE_ADHOC
) {
2020 /* "privacy" is set only for ad-hoc mode */
2023 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2024 * the firmware can find a matching network from the
2025 * scan. The cfg80211 does not give us the encryption
2026 * mode at this stage so just setting it to WEP here.
2028 priv
->sec_info
.encryption_mode
=
2029 WLAN_CIPHER_SUITE_WEP104
;
2030 priv
->sec_info
.authentication_mode
=
2031 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2037 /* Now handle infra mode. "sme" is valid for infra mode only */
2038 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2039 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2040 priv
->sec_info
.is_authtype_auto
= 1;
2042 auth_type
= sme
->auth_type
;
2045 if (sme
->crypto
.n_ciphers_pairwise
) {
2046 priv
->sec_info
.encryption_mode
=
2047 sme
->crypto
.ciphers_pairwise
[0];
2048 priv
->sec_info
.authentication_mode
= auth_type
;
2051 if (sme
->crypto
.cipher_group
) {
2052 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2053 priv
->sec_info
.authentication_mode
= auth_type
;
2056 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2059 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2060 mwifiex_dbg(priv
->adapter
, INFO
,
2061 "info: setting wep encryption\t"
2062 "with key len %d\n", sme
->key_len
);
2063 priv
->wep_key_curr_index
= sme
->key_idx
;
2064 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2065 sme
->key_len
, sme
->key_idx
,
2071 * Scan entries are valid for some time (15 sec). So we can save one
2072 * active scan time if we just try cfg80211_get_bss first. If it fails
2073 * then request scan and cfg80211_get_bss() again for final output.
2076 if (is_scanning_required
) {
2077 /* Do specific SSID scanning */
2078 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2079 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2084 /* Find the BSS we want using available scan results */
2085 if (mode
== NL80211_IFTYPE_ADHOC
)
2086 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2087 bssid
, ssid
, ssid_len
,
2088 IEEE80211_BSS_TYPE_IBSS
,
2089 IEEE80211_PRIVACY_ANY
);
2091 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2092 bssid
, ssid
, ssid_len
,
2093 IEEE80211_BSS_TYPE_ESS
,
2094 IEEE80211_PRIVACY_ANY
);
2097 if (is_scanning_required
) {
2098 mwifiex_dbg(priv
->adapter
, WARN
,
2099 "assoc: requested bss not found in scan results\n");
2102 is_scanning_required
= 1;
2104 mwifiex_dbg(priv
->adapter
, MSG
,
2105 "info: trying to associate to '%s' bssid %pM\n",
2106 (char *)req_ssid
.ssid
, bss
->bssid
);
2107 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2112 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2116 if (mode
== NL80211_IFTYPE_ADHOC
) {
2117 /* Inform the BSS information to kernel, otherwise
2118 * kernel will give a panic after successful assoc */
2119 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2127 * CFG802.11 operation handler for association request.
2129 * This function does not work when the current mode is set to Ad-Hoc, or
2130 * when there is already an association procedure going on. The given BSS
2131 * information is used to associate.
2134 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2135 struct cfg80211_connect_params
*sme
)
2137 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2138 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2141 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2142 mwifiex_dbg(adapter
, ERROR
,
2143 "%s: reject infra assoc request in non-STA role\n",
2148 if (priv
->wdev
.current_bss
) {
2149 mwifiex_dbg(adapter
, ERROR
,
2150 "%s: already connected\n", dev
->name
);
2154 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2155 mwifiex_dbg(adapter
, ERROR
,
2156 "%s: Ignore connection.\t"
2157 "Card removed or FW in bad state\n",
2162 mwifiex_dbg(adapter
, INFO
,
2163 "info: Trying to associate to %s and bssid %pM\n",
2164 (char *)sme
->ssid
, sme
->bssid
);
2166 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2167 priv
->bss_mode
, sme
->channel
, sme
, 0);
2169 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2170 NULL
, 0, WLAN_STATUS_SUCCESS
,
2172 mwifiex_dbg(priv
->adapter
, MSG
,
2173 "info: associated to bssid %pM successfully\n",
2175 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2176 priv
->adapter
->auto_tdls
&&
2177 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2178 mwifiex_setup_auto_tdls_timer(priv
);
2180 mwifiex_dbg(priv
->adapter
, ERROR
,
2181 "info: association to bssid %pM failed\n",
2183 eth_zero_addr(priv
->cfg_bssid
);
2186 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2187 NULL
, 0, NULL
, 0, ret
,
2190 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2192 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2200 * This function sets following parameters for ibss network.
2204 * - secondary channel offset
2206 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2207 struct cfg80211_ibss_params
*params
)
2209 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2211 u8 config_bands
= 0;
2213 if (params
->chandef
.chan
->band
== IEEE80211_BAND_2GHZ
) {
2214 if (!params
->basic_rates
) {
2215 config_bands
= BAND_B
| BAND_G
;
2217 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2219 * Rates below 6 Mbps in the table are CCK
2220 * rates; 802.11b and from 6 they are OFDM;
2223 if (mwifiex_rates
[i
].bitrate
== 60) {
2229 if (params
->basic_rates
< index
) {
2230 config_bands
= BAND_B
;
2232 config_bands
= BAND_G
;
2233 if (params
->basic_rates
% index
)
2234 config_bands
|= BAND_B
;
2238 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2240 config_bands
|= BAND_G
| BAND_GN
;
2242 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2244 config_bands
= BAND_A
;
2246 config_bands
= BAND_AN
| BAND_A
;
2249 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2250 adapter
->config_bands
= config_bands
;
2251 adapter
->adhoc_start_band
= config_bands
;
2253 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2254 adapter
->adhoc_11n_enabled
= true;
2256 adapter
->adhoc_11n_enabled
= false;
2259 adapter
->sec_chan_offset
=
2260 mwifiex_chan_type_to_sec_chan_offset(
2261 cfg80211_get_chandef_type(¶ms
->chandef
));
2262 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2263 params
->chandef
.chan
->center_freq
);
2265 mwifiex_dbg(adapter
, INFO
,
2266 "info: set ibss band %d, chan %d, chan offset %d\n",
2267 config_bands
, priv
->adhoc_channel
,
2268 adapter
->sec_chan_offset
);
2274 * CFG802.11 operation handler to join an IBSS.
2276 * This function does not work in any mode other than Ad-Hoc, or if
2277 * a join operation is already in progress.
2280 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2281 struct cfg80211_ibss_params
*params
)
2283 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2286 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2287 mwifiex_dbg(priv
->adapter
, ERROR
,
2288 "request to join ibss received\t"
2289 "when station is not in ibss mode\n");
2293 mwifiex_dbg(priv
->adapter
, MSG
,
2294 "info: trying to join to %s and bssid %pM\n",
2295 (char *)params
->ssid
, params
->bssid
);
2297 mwifiex_set_ibss_params(priv
, params
);
2299 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2300 params
->bssid
, priv
->bss_mode
,
2301 params
->chandef
.chan
, NULL
,
2305 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2306 params
->chandef
.chan
, GFP_KERNEL
);
2307 mwifiex_dbg(priv
->adapter
, MSG
,
2308 "info: joined/created adhoc network with bssid\t"
2309 "%pM successfully\n", priv
->cfg_bssid
);
2311 mwifiex_dbg(priv
->adapter
, ERROR
,
2312 "info: failed creating/joining adhoc network\n");
2319 * CFG802.11 operation handler to leave an IBSS.
2321 * This function does not work if a leave operation is
2322 * already in progress.
2325 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2327 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2329 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2331 if (mwifiex_deauthenticate(priv
, NULL
))
2334 eth_zero_addr(priv
->cfg_bssid
);
2340 * CFG802.11 operation handler for scan request.
2342 * This function issues a scan request to the firmware based upon
2343 * the user specified scan configuration. On successfull completion,
2344 * it also informs the results.
2347 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2348 struct cfg80211_scan_request
*request
)
2350 struct net_device
*dev
= request
->wdev
->netdev
;
2351 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2353 struct ieee80211_channel
*chan
;
2354 struct ieee_types_header
*ie
;
2355 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2357 mwifiex_dbg(priv
->adapter
, CMD
,
2358 "info: received scan request on %s\n", dev
->name
);
2360 /* Block scan request if scan operation or scan cleanup when interface
2361 * is disabled is in process
2363 if (priv
->scan_request
|| priv
->scan_aborting
) {
2364 mwifiex_dbg(priv
->adapter
, WARN
,
2365 "cmd: Scan already in process..\n");
2369 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2373 priv
->scan_request
= request
;
2375 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2376 user_scan_cfg
->ssid_list
= request
->ssids
;
2378 if (request
->ie
&& request
->ie_len
) {
2380 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2381 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2383 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2384 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2385 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2386 offset
+= sizeof(*ie
) + ie
->len
;
2388 if (offset
>= request
->ie_len
)
2393 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2394 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2395 chan
= request
->channels
[i
];
2396 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2397 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2399 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2400 user_scan_cfg
->chan_list
[i
].scan_type
=
2401 MWIFIEX_SCAN_TYPE_PASSIVE
;
2403 user_scan_cfg
->chan_list
[i
].scan_type
=
2404 MWIFIEX_SCAN_TYPE_ACTIVE
;
2406 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2409 if (priv
->adapter
->scan_chan_gap_enabled
&&
2410 mwifiex_is_any_intf_active(priv
))
2411 user_scan_cfg
->scan_chan_gap
=
2412 priv
->adapter
->scan_chan_gap_time
;
2414 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2415 kfree(user_scan_cfg
);
2417 mwifiex_dbg(priv
->adapter
, ERROR
,
2418 "scan failed: %d\n", ret
);
2419 priv
->scan_aborting
= false;
2420 priv
->scan_request
= NULL
;
2424 if (request
->ie
&& request
->ie_len
) {
2425 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2426 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2427 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2428 memset(&priv
->vs_ie
[i
].ie
, 0,
2429 MWIFIEX_MAX_VSIE_LEN
);
2436 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2437 struct mwifiex_private
*priv
)
2439 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2441 vht_info
->vht_supported
= true;
2443 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2444 /* Update MCS support for VHT */
2445 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2446 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2447 vht_info
->vht_mcs
.rx_highest
= 0;
2448 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2449 adapter
->hw_dot_11ac_mcs_support
>> 16);
2450 vht_info
->vht_mcs
.tx_highest
= 0;
2454 * This function sets up the CFG802.11 specific HT capability fields
2455 * with default values.
2457 * The following default values are set -
2458 * - HT Supported = True
2459 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2460 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2461 * - HT Capabilities supported by firmware
2462 * - MCS information, Rx mask = 0xff
2463 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2466 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2467 struct mwifiex_private
*priv
)
2470 struct ieee80211_mcs_info mcs_set
;
2471 u8
*mcs
= (u8
*)&mcs_set
;
2472 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2474 ht_info
->ht_supported
= true;
2475 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2476 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2478 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2480 /* Fill HT capability information */
2481 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2482 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2484 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2486 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2487 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2489 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2491 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2492 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2494 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2496 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2497 ht_info
->cap
|= 3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2499 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2501 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2502 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2504 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2506 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2507 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2509 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2511 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2512 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2514 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2516 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2517 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2519 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2521 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2522 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2524 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2525 /* Set MCS for 1x1/2x2 */
2526 memset(mcs
, 0xff, rx_mcs_supp
);
2527 /* Clear all the other values */
2528 memset(&mcs
[rx_mcs_supp
], 0,
2529 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2530 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2531 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2532 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2533 SETHT_MCS32(mcs_set
.rx_mask
);
2535 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2537 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2541 * create a new virtual interface with the given name and name assign type
2543 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2545 unsigned char name_assign_type
,
2546 enum nl80211_iftype type
,
2548 struct vif_params
*params
)
2550 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2551 struct mwifiex_private
*priv
;
2552 struct net_device
*dev
;
2556 return ERR_PTR(-EFAULT
);
2559 case NL80211_IFTYPE_UNSPECIFIED
:
2560 case NL80211_IFTYPE_STATION
:
2561 case NL80211_IFTYPE_ADHOC
:
2562 if (adapter
->curr_iface_comb
.sta_intf
==
2563 adapter
->iface_limit
.sta_intf
) {
2564 mwifiex_dbg(adapter
, ERROR
,
2565 "cannot create multiple sta/adhoc ifaces\n");
2566 return ERR_PTR(-EINVAL
);
2569 priv
= mwifiex_get_unused_priv(adapter
);
2571 mwifiex_dbg(adapter
, ERROR
,
2572 "could not get free private struct\n");
2573 return ERR_PTR(-EFAULT
);
2576 priv
->wdev
.wiphy
= wiphy
;
2577 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2579 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2580 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2582 priv
->bss_mode
= type
;
2584 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2585 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2586 priv
->bss_priority
= 0;
2587 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2588 priv
->bss_num
= adapter
->curr_iface_comb
.sta_intf
;
2591 case NL80211_IFTYPE_AP
:
2592 if (adapter
->curr_iface_comb
.uap_intf
==
2593 adapter
->iface_limit
.uap_intf
) {
2594 mwifiex_dbg(adapter
, ERROR
,
2595 "cannot create multiple AP ifaces\n");
2596 return ERR_PTR(-EINVAL
);
2599 priv
= mwifiex_get_unused_priv(adapter
);
2601 mwifiex_dbg(adapter
, ERROR
,
2602 "could not get free private struct\n");
2603 return ERR_PTR(-EFAULT
);
2606 priv
->wdev
.wiphy
= wiphy
;
2607 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2609 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2610 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2611 priv
->bss_priority
= 0;
2612 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2613 priv
->bss_started
= 0;
2614 priv
->bss_num
= adapter
->curr_iface_comb
.uap_intf
;
2615 priv
->bss_mode
= type
;
2618 case NL80211_IFTYPE_P2P_CLIENT
:
2619 if (adapter
->curr_iface_comb
.p2p_intf
==
2620 adapter
->iface_limit
.p2p_intf
) {
2621 mwifiex_dbg(adapter
, ERROR
,
2622 "cannot create multiple P2P ifaces\n");
2623 return ERR_PTR(-EINVAL
);
2626 priv
= mwifiex_get_unused_priv(adapter
);
2628 mwifiex_dbg(adapter
, ERROR
,
2629 "could not get free private struct\n");
2630 return ERR_PTR(-EFAULT
);
2633 priv
->wdev
.wiphy
= wiphy
;
2634 /* At start-up, wpa_supplicant tries to change the interface
2635 * to NL80211_IFTYPE_STATION if it is not managed mode.
2637 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2638 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2640 /* Setting bss_type to P2P tells firmware that this interface
2641 * is receiving P2P peers found during find phase and doing
2642 * action frame handshake.
2644 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2646 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2647 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2648 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2649 priv
->bss_started
= 0;
2650 priv
->bss_num
= adapter
->curr_iface_comb
.p2p_intf
;
2652 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2653 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2654 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2655 return ERR_PTR(-EFAULT
);
2660 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2661 return ERR_PTR(-EINVAL
);
2664 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2665 name_assign_type
, ether_setup
,
2666 IEEE80211_NUM_ACS
, 1);
2668 mwifiex_dbg(adapter
, ERROR
,
2669 "no memory available for netdevice\n");
2670 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2671 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2672 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2673 return ERR_PTR(-ENOMEM
);
2676 mwifiex_init_priv_params(priv
, dev
);
2679 mwifiex_setup_ht_caps(&wiphy
->bands
[IEEE80211_BAND_2GHZ
]->ht_cap
, priv
);
2680 if (adapter
->is_hw_11ac_capable
)
2681 mwifiex_setup_vht_caps(
2682 &wiphy
->bands
[IEEE80211_BAND_2GHZ
]->vht_cap
, priv
);
2684 if (adapter
->config_bands
& BAND_A
)
2685 mwifiex_setup_ht_caps(
2686 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->ht_cap
, priv
);
2688 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2689 mwifiex_setup_vht_caps(
2690 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->vht_cap
, priv
);
2692 dev_net_set(dev
, wiphy_net(wiphy
));
2693 dev
->ieee80211_ptr
= &priv
->wdev
;
2694 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2695 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2696 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2698 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2699 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2700 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2701 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
2703 mdev_priv
= netdev_priv(dev
);
2704 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
2706 SET_NETDEV_DEV(dev
, adapter
->dev
);
2708 /* Register network device */
2709 if (register_netdevice(dev
)) {
2710 mwifiex_dbg(adapter
, ERROR
,
2711 "cannot register virtual network device\n");
2713 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2714 priv
->netdev
= NULL
;
2715 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2716 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2717 return ERR_PTR(-EFAULT
);
2720 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
2723 WQ_UNBOUND
, 1, name
);
2724 if (!priv
->dfs_cac_workqueue
) {
2725 mwifiex_dbg(adapter
, ERROR
,
2726 "cannot register virtual network device\n");
2728 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2729 priv
->netdev
= NULL
;
2730 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2731 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2732 return ERR_PTR(-ENOMEM
);
2735 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
2737 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
2738 WQ_HIGHPRI
| WQ_UNBOUND
|
2739 WQ_MEM_RECLAIM
, 1, name
);
2740 if (!priv
->dfs_chan_sw_workqueue
) {
2741 mwifiex_dbg(adapter
, ERROR
,
2742 "cannot register virtual network device\n");
2744 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2745 priv
->netdev
= NULL
;
2746 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2747 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2748 return ERR_PTR(-ENOMEM
);
2751 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
2752 mwifiex_dfs_chan_sw_work_queue
);
2754 sema_init(&priv
->async_sem
, 1);
2756 mwifiex_dbg(adapter
, INFO
,
2757 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
2759 #ifdef CONFIG_DEBUG_FS
2760 mwifiex_dev_debugfs_init(priv
);
2764 case NL80211_IFTYPE_UNSPECIFIED
:
2765 case NL80211_IFTYPE_STATION
:
2766 case NL80211_IFTYPE_ADHOC
:
2767 adapter
->curr_iface_comb
.sta_intf
++;
2769 case NL80211_IFTYPE_AP
:
2770 adapter
->curr_iface_comb
.uap_intf
++;
2772 case NL80211_IFTYPE_P2P_CLIENT
:
2773 adapter
->curr_iface_comb
.p2p_intf
++;
2776 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2777 return ERR_PTR(-EINVAL
);
2782 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
2785 * del_virtual_intf: remove the virtual interface determined by dev
2787 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
2789 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
2790 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2792 #ifdef CONFIG_DEBUG_FS
2793 mwifiex_dev_debugfs_remove(priv
);
2796 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
2798 if (netif_carrier_ok(priv
->netdev
))
2799 netif_carrier_off(priv
->netdev
);
2801 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
2802 unregister_netdevice(wdev
->netdev
);
2804 if (priv
->dfs_cac_workqueue
) {
2805 flush_workqueue(priv
->dfs_cac_workqueue
);
2806 destroy_workqueue(priv
->dfs_cac_workqueue
);
2807 priv
->dfs_cac_workqueue
= NULL
;
2810 if (priv
->dfs_chan_sw_workqueue
) {
2811 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
2812 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
2813 priv
->dfs_chan_sw_workqueue
= NULL
;
2815 /* Clear the priv in adapter */
2816 priv
->netdev
->ieee80211_ptr
= NULL
;
2817 priv
->netdev
= NULL
;
2818 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2820 priv
->media_connected
= false;
2822 switch (priv
->bss_mode
) {
2823 case NL80211_IFTYPE_UNSPECIFIED
:
2824 case NL80211_IFTYPE_STATION
:
2825 case NL80211_IFTYPE_ADHOC
:
2826 adapter
->curr_iface_comb
.sta_intf
++;
2828 case NL80211_IFTYPE_AP
:
2829 adapter
->curr_iface_comb
.uap_intf
++;
2831 case NL80211_IFTYPE_P2P_CLIENT
:
2832 case NL80211_IFTYPE_P2P_GO
:
2833 adapter
->curr_iface_comb
.p2p_intf
++;
2836 mwifiex_dbg(adapter
, ERROR
,
2837 "del_virtual_intf: type not supported\n");
2841 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2843 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
2844 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
2845 kfree(priv
->hist_data
);
2849 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
2852 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
2855 int j
, k
, valid_byte_cnt
= 0;
2856 bool dont_care_byte
= false;
2858 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
2859 for (k
= 0; k
< 8; k
++) {
2860 if (pat
->mask
[j
] & 1 << k
) {
2861 memcpy(byte_seq
+ valid_byte_cnt
,
2862 &pat
->pattern
[j
* 8 + k
], 1);
2868 dont_care_byte
= true;
2871 if (valid_byte_cnt
> max_byte_seq
)
2876 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
2882 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
2883 struct mwifiex_mef_entry
*mef_entry
)
2885 int i
, filt_num
= 0, num_ipv4
= 0;
2886 struct in_device
*in_dev
;
2887 struct in_ifaddr
*ifa
;
2888 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
2889 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2891 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2892 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
2894 /* Enable ARP offload feature */
2895 memset(ips
, 0, sizeof(ips
));
2896 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
2897 if (adapter
->priv
[i
]->netdev
) {
2898 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
2901 ifa
= in_dev
->ifa_list
;
2902 if (!ifa
|| !ifa
->ifa_local
)
2904 ips
[i
] = ifa
->ifa_local
;
2909 for (i
= 0; i
< num_ipv4
; i
++) {
2912 mef_entry
->filter
[filt_num
].repeat
= 1;
2913 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
2914 (u8
*)&ips
[i
], sizeof(ips
[i
]));
2915 mef_entry
->filter
[filt_num
].
2916 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
2918 mef_entry
->filter
[filt_num
].offset
= 46;
2919 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2921 mef_entry
->filter
[filt_num
].filt_action
=
2927 mef_entry
->filter
[filt_num
].repeat
= 1;
2928 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
2929 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
2930 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
2931 mef_entry
->filter
[filt_num
].offset
= 20;
2932 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2933 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
2936 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
2937 struct mwifiex_ds_mef_cfg
*mef_cfg
,
2938 struct mwifiex_mef_entry
*mef_entry
,
2939 struct cfg80211_wowlan
*wowlan
)
2941 int i
, filt_num
= 0, ret
= 0;
2942 bool first_pat
= true;
2943 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
2944 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
2945 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
2947 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2948 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
2950 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
2951 memset(byte_seq
, 0, sizeof(byte_seq
));
2952 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
2954 MWIFIEX_MEF_MAX_BYTESEQ
)) {
2955 mwifiex_dbg(priv
->adapter
, ERROR
,
2956 "Pattern not supported\n");
2961 if (!wowlan
->patterns
[i
].pkt_offset
) {
2962 if (!(byte_seq
[0] & 0x01) &&
2963 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
2964 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
2966 } else if (is_broadcast_ether_addr(byte_seq
)) {
2967 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
2969 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
2970 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
2971 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
2972 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
2973 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
2977 mef_entry
->filter
[filt_num
].repeat
= 1;
2978 mef_entry
->filter
[filt_num
].offset
=
2979 wowlan
->patterns
[i
].pkt_offset
;
2980 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
2982 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2987 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
2992 if (wowlan
->magic_pkt
) {
2993 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
2994 mef_entry
->filter
[filt_num
].repeat
= 16;
2995 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
2997 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
2999 mef_entry
->filter
[filt_num
].offset
= 28;
3000 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3002 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3005 mef_entry
->filter
[filt_num
].repeat
= 16;
3006 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3008 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3010 mef_entry
->filter
[filt_num
].offset
= 56;
3011 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3012 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3017 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3018 struct cfg80211_wowlan
*wowlan
)
3020 int ret
= 0, num_entries
= 1;
3021 struct mwifiex_ds_mef_cfg mef_cfg
;
3022 struct mwifiex_mef_entry
*mef_entry
;
3024 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3027 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3031 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3032 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3033 MWIFIEX_CRITERIA_UNICAST
;
3034 mef_cfg
.num_entries
= num_entries
;
3035 mef_cfg
.mef_entry
= mef_entry
;
3037 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3039 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3040 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3041 &mef_entry
[1], wowlan
);
3043 if (!mef_cfg
.criteria
)
3044 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3045 MWIFIEX_CRITERIA_UNICAST
|
3046 MWIFIEX_CRITERIA_MULTICAST
;
3048 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3049 HostCmd_ACT_GEN_SET
, 0,
3055 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3056 struct cfg80211_wowlan
*wowlan
)
3058 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3059 struct mwifiex_ds_hs_cfg hs_cfg
;
3061 struct mwifiex_private
*priv
;
3063 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3064 priv
= adapter
->priv
[i
];
3065 mwifiex_abort_cac(priv
);
3068 mwifiex_cancel_all_pending_cmd(adapter
);
3071 mwifiex_dbg(adapter
, ERROR
,
3072 "None of the WOWLAN triggers enabled\n");
3076 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3078 if (!priv
->media_connected
) {
3079 mwifiex_dbg(adapter
, ERROR
,
3080 "Can not configure WOWLAN in disconnected state\n");
3084 ret
= mwifiex_set_mef_filter(priv
, wowlan
);
3086 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3090 if (wowlan
->disconnect
) {
3091 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3092 hs_cfg
.is_invoke_hostcmd
= false;
3093 hs_cfg
.conditions
= HS_CFG_COND_MAC_EVENT
;
3094 hs_cfg
.gpio
= HS_CFG_GPIO_DEF
;
3095 hs_cfg
.gap
= HS_CFG_GAP_DEF
;
3096 ret
= mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
3097 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3099 mwifiex_dbg(adapter
, ERROR
,
3100 "Failed to set HS params\n");
3108 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3113 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3116 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3118 device_set_wakeup_enable(adapter
->dev
, enabled
);
3122 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3124 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3125 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3126 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3128 if ((byte_seq
[0] & 0x01) &&
3129 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3130 return PACKET_TYPE_UNICAST
;
3131 else if (!memcmp(byte_seq
, bc_mac
, 4))
3132 return PACKET_TYPE_BROADCAST
;
3133 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3134 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3135 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3136 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3137 return PACKET_TYPE_MULTICAST
;
3143 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3144 struct cfg80211_coalesce_rules
*crule
,
3145 struct mwifiex_coalesce_rule
*mrule
)
3147 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3148 struct filt_field_param
*param
;
3151 mrule
->max_coalescing_delay
= crule
->delay
;
3153 param
= mrule
->params
;
3155 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3156 memset(byte_seq
, 0, sizeof(byte_seq
));
3157 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3159 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3160 mwifiex_dbg(priv
->adapter
, ERROR
,
3161 "Pattern not supported\n");
3165 if (!crule
->patterns
[i
].pkt_offset
) {
3168 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3169 if (pkt_type
&& mrule
->pkt_type
) {
3170 mwifiex_dbg(priv
->adapter
, ERROR
,
3171 "Multiple packet types not allowed\n");
3173 } else if (pkt_type
) {
3174 mrule
->pkt_type
= pkt_type
;
3179 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3180 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3182 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3184 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3185 memcpy(param
->operand_byte_stream
, byte_seq
,
3186 param
->operand_len
);
3187 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3190 mrule
->num_of_fields
++;
3193 if (!mrule
->pkt_type
) {
3194 mwifiex_dbg(priv
->adapter
, ERROR
,
3195 "Packet type can not be determined\n");
3202 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3203 struct cfg80211_coalesce
*coalesce
)
3205 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3207 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3208 struct mwifiex_private
*priv
=
3209 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3211 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3213 mwifiex_dbg(adapter
, WARN
,
3214 "Disable coalesce and reset all previous rules\n");
3215 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3216 HostCmd_ACT_GEN_SET
, 0,
3217 &coalesce_cfg
, true);
3220 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3221 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3222 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3223 &coalesce_cfg
.rule
[i
]);
3225 mwifiex_dbg(adapter
, ERROR
,
3226 "Recheck the patterns provided for rule %d\n",
3232 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3233 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3236 /* cfg80211 ops handler for tdls_mgmt.
3237 * Function prepares TDLS action frame packets and forwards them to FW
3240 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3241 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3242 u16 status_code
, u32 peer_capability
,
3243 bool initiator
, const u8
*extra_ies
,
3244 size_t extra_ies_len
)
3246 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3249 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3252 /* make sure we are in station mode and connected */
3253 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3256 switch (action_code
) {
3257 case WLAN_TDLS_SETUP_REQUEST
:
3258 mwifiex_dbg(priv
->adapter
, MSG
,
3259 "Send TDLS Setup Request to %pM status_code=%d\n",
3261 mwifiex_add_auto_tdls_peer(priv
, peer
);
3262 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3263 dialog_token
, status_code
,
3264 extra_ies
, extra_ies_len
);
3266 case WLAN_TDLS_SETUP_RESPONSE
:
3267 mwifiex_add_auto_tdls_peer(priv
, peer
);
3268 mwifiex_dbg(priv
->adapter
, MSG
,
3269 "Send TDLS Setup Response to %pM status_code=%d\n",
3271 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3272 dialog_token
, status_code
,
3273 extra_ies
, extra_ies_len
);
3275 case WLAN_TDLS_SETUP_CONFIRM
:
3276 mwifiex_dbg(priv
->adapter
, MSG
,
3277 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3279 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3280 dialog_token
, status_code
,
3281 extra_ies
, extra_ies_len
);
3283 case WLAN_TDLS_TEARDOWN
:
3284 mwifiex_dbg(priv
->adapter
, MSG
,
3285 "Send TDLS Tear down to %pM\n", peer
);
3286 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3287 dialog_token
, status_code
,
3288 extra_ies
, extra_ies_len
);
3290 case WLAN_TDLS_DISCOVERY_REQUEST
:
3291 mwifiex_dbg(priv
->adapter
, MSG
,
3292 "Send TDLS Discovery Request to %pM\n", peer
);
3293 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3294 dialog_token
, status_code
,
3295 extra_ies
, extra_ies_len
);
3297 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3298 mwifiex_dbg(priv
->adapter
, MSG
,
3299 "Send TDLS Discovery Response to %pM\n", peer
);
3300 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3301 dialog_token
, status_code
,
3302 extra_ies
, extra_ies_len
);
3305 mwifiex_dbg(priv
->adapter
, ERROR
,
3306 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3315 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3316 const u8
*peer
, enum nl80211_tdls_operation action
)
3318 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3320 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3321 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3324 /* make sure we are in station mode and connected */
3325 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3328 mwifiex_dbg(priv
->adapter
, MSG
,
3329 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3332 case NL80211_TDLS_ENABLE_LINK
:
3333 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3335 case NL80211_TDLS_DISABLE_LINK
:
3336 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3338 case NL80211_TDLS_TEARDOWN
:
3339 /* shouldn't happen!*/
3340 mwifiex_dbg(priv
->adapter
, ERROR
,
3341 "tdls_oper: teardown from driver not supported\n");
3343 case NL80211_TDLS_SETUP
:
3344 /* shouldn't happen!*/
3345 mwifiex_dbg(priv
->adapter
, ERROR
,
3346 "tdls_oper: setup from driver not supported\n");
3348 case NL80211_TDLS_DISCOVERY_REQ
:
3349 /* shouldn't happen!*/
3350 mwifiex_dbg(priv
->adapter
, ERROR
,
3351 "tdls_oper: discovery from driver not supported\n");
3354 mwifiex_dbg(priv
->adapter
, ERROR
,
3355 "tdls_oper: operation not supported\n");
3359 return mwifiex_tdls_oper(priv
, peer
, action
);
3363 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3364 const u8
*mac
, struct station_parameters
*params
)
3366 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3368 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3371 /* make sure we are in station mode and connected */
3372 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3375 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3379 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3380 struct cfg80211_csa_settings
*params
)
3382 struct ieee_types_header
*chsw_ie
;
3383 struct ieee80211_channel_sw_ie
*channel_sw
;
3385 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3387 if (priv
->adapter
->scan_processing
) {
3388 mwifiex_dbg(priv
->adapter
, ERROR
,
3389 "radar detection: scan in process...\n");
3393 if (priv
->wdev
.cac_started
)
3396 if (cfg80211_chandef_identical(¶ms
->chandef
,
3397 &priv
->dfs_chandef
))
3400 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3401 params
->beacon_csa
.tail
,
3402 params
->beacon_csa
.tail_len
);
3404 mwifiex_dbg(priv
->adapter
, ERROR
,
3405 "Could not parse channel switch announcement IE\n");
3409 channel_sw
= (void *)(chsw_ie
+ 1);
3410 if (channel_sw
->mode
) {
3411 if (netif_carrier_ok(priv
->netdev
))
3412 netif_carrier_off(priv
->netdev
);
3413 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3416 if (mwifiex_del_mgmt_ies(priv
))
3417 mwifiex_dbg(priv
->adapter
, ERROR
,
3418 "Failed to delete mgmt IEs!\n");
3420 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3421 mwifiex_dbg(priv
->adapter
, ERROR
,
3422 "%s: setting mgmt ies failed\n", __func__
);
3426 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3427 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3428 sizeof(priv
->beacon_after
));
3430 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3431 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3432 msecs_to_jiffies(chsw_msec
));
3436 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3437 struct wireless_dev
*wdev
,
3438 struct cfg80211_chan_def
*chandef
)
3440 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3441 struct mwifiex_bssdescriptor
*curr_bss
;
3442 struct ieee80211_channel
*chan
;
3443 u8 second_chan_offset
;
3444 enum nl80211_channel_type chan_type
;
3445 enum ieee80211_band band
;
3449 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3450 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3451 *chandef
= priv
->bss_chandef
;
3453 } else if (priv
->media_connected
) {
3454 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3455 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3456 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3457 chan
= ieee80211_get_channel(wiphy
, freq
);
3459 if (curr_bss
->bcn_ht_oper
) {
3460 second_chan_offset
= curr_bss
->bcn_ht_oper
->ht_param
&
3461 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3462 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3463 (second_chan_offset
);
3464 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3466 cfg80211_chandef_create(chandef
, chan
,
3467 NL80211_CHAN_NO_HT
);
3476 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
3477 struct net_device
*dev
,
3478 struct cfg80211_chan_def
*chandef
,
3481 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3482 struct mwifiex_radar_params radar_params
;
3484 if (priv
->adapter
->scan_processing
) {
3485 mwifiex_dbg(priv
->adapter
, ERROR
,
3486 "radar detection: scan already in process...\n");
3490 if (!mwifiex_is_11h_active(priv
)) {
3491 mwifiex_dbg(priv
->adapter
, INFO
,
3492 "Enable 11h extensions in FW\n");
3493 if (mwifiex_11h_activate(priv
, true)) {
3494 mwifiex_dbg(priv
->adapter
, ERROR
,
3495 "Failed to activate 11h extensions!!");
3498 priv
->state_11h
.is_11h_active
= true;
3501 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
3502 radar_params
.chandef
= chandef
;
3503 radar_params
.cac_time_ms
= cac_time_ms
;
3505 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
3507 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
3508 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
3511 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
3512 msecs_to_jiffies(cac_time_ms
));
3517 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3519 struct station_parameters
*params
)
3522 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3524 /* we support change_station handler only for TDLS peers*/
3525 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3528 /* make sure we are in station mode and connected */
3529 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3532 priv
->sta_params
= params
;
3534 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
3535 priv
->sta_params
= NULL
;
3540 /* station cfg80211 operations */
3541 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
3542 .add_virtual_intf
= mwifiex_add_virtual_intf
,
3543 .del_virtual_intf
= mwifiex_del_virtual_intf
,
3544 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
3545 .scan
= mwifiex_cfg80211_scan
,
3546 .connect
= mwifiex_cfg80211_connect
,
3547 .disconnect
= mwifiex_cfg80211_disconnect
,
3548 .get_station
= mwifiex_cfg80211_get_station
,
3549 .dump_station
= mwifiex_cfg80211_dump_station
,
3550 .dump_survey
= mwifiex_cfg80211_dump_survey
,
3551 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
3552 .join_ibss
= mwifiex_cfg80211_join_ibss
,
3553 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
3554 .add_key
= mwifiex_cfg80211_add_key
,
3555 .del_key
= mwifiex_cfg80211_del_key
,
3556 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
3557 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
3558 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
3559 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
3560 .set_default_key
= mwifiex_cfg80211_set_default_key
,
3561 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
3562 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
3563 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
3564 .start_ap
= mwifiex_cfg80211_start_ap
,
3565 .stop_ap
= mwifiex_cfg80211_stop_ap
,
3566 .change_beacon
= mwifiex_cfg80211_change_beacon
,
3567 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
3568 .set_antenna
= mwifiex_cfg80211_set_antenna
,
3569 .del_station
= mwifiex_cfg80211_del_station
,
3571 .suspend
= mwifiex_cfg80211_suspend
,
3572 .resume
= mwifiex_cfg80211_resume
,
3573 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
3575 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
3576 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
3577 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
3578 .add_station
= mwifiex_cfg80211_add_station
,
3579 .change_station
= mwifiex_cfg80211_change_station
,
3580 .get_channel
= mwifiex_cfg80211_get_channel
,
3581 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
3582 .channel_switch
= mwifiex_cfg80211_channel_switch
,
3586 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
3587 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
,
3588 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
3589 .pattern_min_len
= 1,
3590 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3591 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3595 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
3597 if (!alpha2
|| strlen(alpha2
) != 2)
3600 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
3606 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
3607 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
3608 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
3609 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
3610 .pattern_min_len
= 1,
3611 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3612 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3615 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
3617 u32 n_channels_bg
, n_channels_a
= 0;
3619 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
3621 if (adapter
->config_bands
& BAND_A
)
3622 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
3624 adapter
->num_in_chan_stats
= max_t(u32
, n_channels_bg
, n_channels_a
);
3625 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
3626 adapter
->num_in_chan_stats
);
3628 if (!adapter
->chan_stats
)
3635 * This function registers the device with CFG802.11 subsystem.
3637 * The function creates the wireless device/wiphy, populates it with
3638 * default parameters and handler function pointers, and finally
3639 * registers the device.
3642 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
3646 struct wiphy
*wiphy
;
3647 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
3651 /* create a new wiphy for use with cfg80211 */
3652 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
3653 sizeof(struct mwifiex_adapter
*));
3655 mwifiex_dbg(adapter
, ERROR
,
3656 "%s: creating new wiphy\n", __func__
);
3659 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
3660 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
3661 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
3662 wiphy
->max_remain_on_channel_duration
= 5000;
3663 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
3664 BIT(NL80211_IFTYPE_ADHOC
) |
3665 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
3666 BIT(NL80211_IFTYPE_P2P_GO
) |
3667 BIT(NL80211_IFTYPE_AP
);
3669 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
3670 if (adapter
->config_bands
& BAND_A
)
3671 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
3673 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = NULL
;
3675 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
3676 wiphy
->n_iface_combinations
= 1;
3678 /* Initialize cipher suits */
3679 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
3680 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
3682 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
3683 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3684 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
3685 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
3686 WIPHY_FLAG_AP_UAPSD
|
3687 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
3688 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
3689 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
3691 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3692 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
3693 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
3696 wiphy
->wowlan
= &mwifiex_wowlan_support
;
3699 wiphy
->coalesce
= &mwifiex_coalesce_support
;
3701 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
3702 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
3703 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
3705 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
3706 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
3708 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
3709 NL80211_FEATURE_INACTIVITY_TIMER
|
3710 NL80211_FEATURE_NEED_OBSS_SCAN
;
3712 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
3713 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
3715 /* Reserve space for mwifiex specific private data for BSS */
3716 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
3718 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
3720 /* Set struct mwifiex_adapter pointer in wiphy_priv */
3721 wdev_priv
= wiphy_priv(wiphy
);
3722 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
3724 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
3726 ret
= wiphy_register(wiphy
);
3728 mwifiex_dbg(adapter
, ERROR
,
3729 "%s: wiphy_register failed: %d\n", __func__
, ret
);
3734 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
3735 mwifiex_dbg(adapter
, INFO
,
3736 "driver hint alpha2: %2.2s\n", reg_alpha2
);
3737 regulatory_hint(wiphy
, reg_alpha2
);
3739 country_code
= mwifiex_11d_code_2_region(adapter
->region_code
);
3741 mwifiex_dbg(adapter
, WARN
,
3742 "ignoring F/W country code %2.2s\n",
3746 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3747 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
3748 wiphy
->frag_threshold
= thr
;
3749 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3750 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
3751 wiphy
->rts_threshold
= thr
;
3752 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3753 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
3754 wiphy
->retry_short
= (u8
) retry
;
3755 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3756 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
3757 wiphy
->retry_long
= (u8
) retry
;
3759 adapter
->wiphy
= wiphy
;