2 * Marvell Wireless LAN device driver: CFG80211
4 * Copyright (C) 2011-2014, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
24 static char *reg_alpha2
;
25 module_param(reg_alpha2
, charp
, 0);
27 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits
[] = {
29 .max
= 3, .types
= BIT(NL80211_IFTYPE_STATION
) |
30 BIT(NL80211_IFTYPE_P2P_GO
) |
31 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
32 BIT(NL80211_IFTYPE_AP
),
36 static const struct ieee80211_iface_combination
37 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,
43 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
44 BIT(NL80211_CHAN_WIDTH_20
) |
45 BIT(NL80211_CHAN_WIDTH_40
),
48 static const struct ieee80211_iface_combination
49 mwifiex_iface_comb_ap_sta_vht
= {
50 .limits
= mwifiex_ap_sta_limits
,
51 .num_different_channels
= 1,
52 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
53 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
54 .beacon_int_infra_match
= true,
55 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
56 BIT(NL80211_CHAN_WIDTH_20
) |
57 BIT(NL80211_CHAN_WIDTH_40
) |
58 BIT(NL80211_CHAN_WIDTH_80
),
62 ieee80211_iface_combination mwifiex_iface_comb_ap_sta_drcs
= {
63 .limits
= mwifiex_ap_sta_limits
,
64 .num_different_channels
= 2,
65 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
66 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
67 .beacon_int_infra_match
= true,
71 * This function maps the nl802.11 channel type into driver channel type.
73 * The mapping is as follows -
74 * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE
75 * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE
76 * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE
77 * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW
78 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE
80 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
)
83 case NL80211_CHAN_NO_HT
:
84 case NL80211_CHAN_HT20
:
85 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
86 case NL80211_CHAN_HT40PLUS
:
87 return IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
88 case NL80211_CHAN_HT40MINUS
:
89 return IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
91 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
95 /* This function maps IEEE HT secondary channel type to NL80211 channel type
97 u8
mwifiex_sec_chan_offset_to_chan_type(u8 second_chan_offset
)
99 switch (second_chan_offset
) {
100 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
101 return NL80211_CHAN_HT20
;
102 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
103 return NL80211_CHAN_HT40PLUS
;
104 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
105 return NL80211_CHAN_HT40MINUS
;
107 return NL80211_CHAN_HT20
;
112 * This function checks whether WEP is set.
115 mwifiex_is_alg_wep(u32 cipher
)
118 case WLAN_CIPHER_SUITE_WEP40
:
119 case WLAN_CIPHER_SUITE_WEP104
:
129 * This function retrieves the private structure from kernel wiphy structure.
131 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
133 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
137 * CFG802.11 operation handler to delete a network key.
140 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
141 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
143 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
144 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
145 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
147 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
148 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
152 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
157 * This function forms an skb for management frame.
160 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
162 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
164 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
166 pkt_len
= len
+ ETH_ALEN
;
168 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
169 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
170 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
172 memcpy(skb_push(skb
, sizeof(tx_control
)),
173 &tx_control
, sizeof(tx_control
));
175 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
177 /* Add packet data and address4 */
178 memcpy(skb_put(skb
, sizeof(struct ieee80211_hdr_3addr
)), buf
,
179 sizeof(struct ieee80211_hdr_3addr
));
180 memcpy(skb_put(skb
, ETH_ALEN
), addr
, ETH_ALEN
);
181 memcpy(skb_put(skb
, len
- sizeof(struct ieee80211_hdr_3addr
)),
182 buf
+ sizeof(struct ieee80211_hdr_3addr
),
183 len
- sizeof(struct ieee80211_hdr_3addr
));
185 skb
->priority
= LOW_PRIO_TID
;
186 __net_timestamp(skb
);
192 * CFG802.11 operation handler to transmit a management frame.
195 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
196 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
198 const u8
*buf
= params
->buf
;
199 size_t len
= params
->len
;
202 const struct ieee80211_mgmt
*mgmt
;
203 struct mwifiex_txinfo
*tx_info
;
204 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
207 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
211 mgmt
= (const struct ieee80211_mgmt
*)buf
;
212 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
213 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
214 /* Since we support offload probe resp, we need to skip probe
215 * resp in AP or GO mode */
216 mwifiex_dbg(priv
->adapter
, INFO
,
217 "info: skip to send probe resp in AP or GO mode\n");
221 pkt_len
= len
+ ETH_ALEN
;
222 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
223 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
224 pkt_len
+ sizeof(pkt_len
));
227 mwifiex_dbg(priv
->adapter
, ERROR
,
228 "allocate skb failed for management frame\n");
232 tx_info
= MWIFIEX_SKB_TXCB(skb
);
233 memset(tx_info
, 0, sizeof(*tx_info
));
234 tx_info
->bss_num
= priv
->bss_num
;
235 tx_info
->bss_type
= priv
->bss_type
;
236 tx_info
->pkt_len
= pkt_len
;
238 mwifiex_form_mgmt_frame(skb
, buf
, len
);
239 *cookie
= prandom_u32() | 1;
241 if (ieee80211_is_action(mgmt
->frame_control
))
242 skb
= mwifiex_clone_skb_for_tx_status(priv
,
244 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
246 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
249 mwifiex_queue_tx_pkt(priv
, skb
);
251 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
256 * CFG802.11 operation handler to register a mgmt frame.
259 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
260 struct wireless_dev
*wdev
,
261 u16 frame_type
, bool reg
)
263 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
267 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
269 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
271 if (mask
!= priv
->mgmt_frame_mask
) {
272 priv
->mgmt_frame_mask
= mask
;
273 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
274 HostCmd_ACT_GEN_SET
, 0,
275 &priv
->mgmt_frame_mask
, false);
276 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
281 * CFG802.11 operation handler to remain on channel.
284 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
285 struct wireless_dev
*wdev
,
286 struct ieee80211_channel
*chan
,
287 unsigned int duration
, u64
*cookie
)
289 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
292 if (!chan
|| !cookie
) {
293 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
297 if (priv
->roc_cfg
.cookie
) {
298 mwifiex_dbg(priv
->adapter
, INFO
,
299 "info: ongoing ROC, cookie = 0x%llx\n",
300 priv
->roc_cfg
.cookie
);
304 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
308 *cookie
= prandom_u32() | 1;
309 priv
->roc_cfg
.cookie
= *cookie
;
310 priv
->roc_cfg
.chan
= *chan
;
312 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
313 duration
, GFP_ATOMIC
);
315 mwifiex_dbg(priv
->adapter
, INFO
,
316 "info: ROC, cookie = 0x%llx\n", *cookie
);
323 * CFG802.11 operation handler to cancel remain on channel.
326 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
327 struct wireless_dev
*wdev
, u64 cookie
)
329 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
332 if (cookie
!= priv
->roc_cfg
.cookie
)
335 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
336 &priv
->roc_cfg
.chan
, 0);
339 cfg80211_remain_on_channel_expired(wdev
, cookie
,
343 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
345 mwifiex_dbg(priv
->adapter
, INFO
,
346 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
353 * CFG802.11 operation handler to set Tx power.
356 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
357 struct wireless_dev
*wdev
,
358 enum nl80211_tx_power_setting type
,
361 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
362 struct mwifiex_private
*priv
;
363 struct mwifiex_power_cfg power_cfg
;
364 int dbm
= MBM_TO_DBM(mbm
);
366 if (type
== NL80211_TX_POWER_FIXED
) {
367 power_cfg
.is_power_auto
= 0;
368 power_cfg
.power_level
= dbm
;
370 power_cfg
.is_power_auto
= 1;
373 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
375 return mwifiex_set_tx_power(priv
, &power_cfg
);
379 * CFG802.11 operation handler to set Power Save option.
381 * The timeout value, if provided, is currently ignored.
384 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
385 struct net_device
*dev
,
386 bool enabled
, int timeout
)
388 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
392 mwifiex_dbg(priv
->adapter
, INFO
,
393 "info: ignore timeout value for IEEE Power Save\n");
397 return mwifiex_drv_set_power(priv
, &ps_mode
);
401 * CFG802.11 operation handler to set the default network key.
404 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
405 u8 key_index
, bool unicast
,
408 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
410 /* Return if WEP key not configured */
411 if (!priv
->sec_info
.wep_enabled
)
414 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
415 priv
->wep_key_curr_index
= key_index
;
416 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
418 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
426 * CFG802.11 operation handler to add a network key.
429 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
430 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
431 struct key_params
*params
)
433 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
434 struct mwifiex_wep_key
*wep_key
;
435 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
436 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
438 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
439 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
440 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
441 if (params
->key
&& params
->key_len
) {
442 wep_key
= &priv
->wep_key
[key_index
];
443 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
444 memcpy(wep_key
->key_material
, params
->key
,
446 wep_key
->key_index
= key_index
;
447 wep_key
->key_length
= params
->key_len
;
448 priv
->sec_info
.wep_enabled
= 1;
453 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
454 key_index
, peer_mac
, 0)) {
455 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
463 * This function sends domain information to the firmware.
465 * The following information are passed to the firmware -
467 * - Sub bands (first channel, number of channels, maximum Tx power)
469 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
471 u8 no_of_triplet
= 0;
472 struct ieee80211_country_ie_triplet
*t
;
473 u8 no_of_parsed_chan
= 0;
474 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
476 enum ieee80211_band band
;
477 struct ieee80211_supported_band
*sband
;
478 struct ieee80211_channel
*ch
;
479 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
480 struct mwifiex_private
*priv
;
481 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
483 /* Set country code */
484 domain_info
->country_code
[0] = adapter
->country_code
[0];
485 domain_info
->country_code
[1] = adapter
->country_code
[1];
486 domain_info
->country_code
[2] = ' ';
488 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
489 if (!wiphy
->bands
[band
]) {
490 mwifiex_dbg(adapter
, ERROR
,
491 "11D: setting domain info in FW\n");
495 sband
= wiphy
->bands
[band
];
497 for (i
= 0; i
< sband
->n_channels
; i
++) {
498 ch
= &sband
->channels
[i
];
499 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
504 first_chan
= (u32
) ch
->hw_value
;
505 next_chan
= first_chan
;
506 max_pwr
= ch
->max_power
;
507 no_of_parsed_chan
= 1;
511 if (ch
->hw_value
== next_chan
+ 1 &&
512 ch
->max_power
== max_pwr
) {
516 t
= &domain_info
->triplet
[no_of_triplet
];
517 t
->chans
.first_channel
= first_chan
;
518 t
->chans
.num_channels
= no_of_parsed_chan
;
519 t
->chans
.max_power
= max_pwr
;
521 first_chan
= (u32
) ch
->hw_value
;
522 next_chan
= first_chan
;
523 max_pwr
= ch
->max_power
;
524 no_of_parsed_chan
= 1;
529 t
= &domain_info
->triplet
[no_of_triplet
];
530 t
->chans
.first_channel
= first_chan
;
531 t
->chans
.num_channels
= no_of_parsed_chan
;
532 t
->chans
.max_power
= max_pwr
;
536 domain_info
->no_of_triplet
= no_of_triplet
;
538 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
540 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
541 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
542 mwifiex_dbg(adapter
, INFO
,
543 "11D: setting domain info in FW\n");
551 * CFG802.11 regulatory domain callback function.
553 * This function is called when the regulatory domain is changed due to the
554 * following reasons -
556 * - Set by system core
558 * - Set bt Country IE
560 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
561 struct regulatory_request
*request
)
563 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
564 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
565 MWIFIEX_BSS_ROLE_ANY
);
566 mwifiex_dbg(adapter
, INFO
,
567 "info: cfg80211 regulatory domain callback for %c%c\n",
568 request
->alpha2
[0], request
->alpha2
[1]);
570 switch (request
->initiator
) {
571 case NL80211_REGDOM_SET_BY_DRIVER
:
572 case NL80211_REGDOM_SET_BY_CORE
:
573 case NL80211_REGDOM_SET_BY_USER
:
574 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
577 mwifiex_dbg(adapter
, ERROR
,
578 "unknown regdom initiator: %d\n",
583 /* Don't send world or same regdom info to firmware */
584 if (strncmp(request
->alpha2
, "00", 2) &&
585 strncmp(request
->alpha2
, adapter
->country_code
,
586 sizeof(request
->alpha2
))) {
587 memcpy(adapter
->country_code
, request
->alpha2
,
588 sizeof(request
->alpha2
));
589 mwifiex_send_domain_info_cmd_fw(wiphy
);
590 mwifiex_dnld_txpwr_table(priv
);
595 * This function sets the fragmentation threshold.
597 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
598 * and MWIFIEX_FRAG_MAX_VALUE.
601 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
603 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
604 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
605 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
607 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
608 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
613 * This function sets the RTS threshold.
615 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
616 * and MWIFIEX_RTS_MAX_VALUE.
619 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
621 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
622 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
624 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
625 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
630 * CFG802.11 operation handler to set wiphy parameters.
632 * This function can be used to set the RTS threshold and the
633 * Fragmentation threshold of the driver.
636 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
638 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
639 struct mwifiex_private
*priv
;
640 struct mwifiex_uap_bss_param
*bss_cfg
;
643 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
645 switch (priv
->bss_role
) {
646 case MWIFIEX_BSS_ROLE_UAP
:
647 if (priv
->bss_started
) {
648 mwifiex_dbg(adapter
, ERROR
,
649 "cannot change wiphy params when bss started");
653 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
657 mwifiex_set_sys_config_invalid_data(bss_cfg
);
659 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
660 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
661 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
662 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
663 if (changed
& WIPHY_PARAM_RETRY_LONG
)
664 bss_cfg
->retry_limit
= wiphy
->retry_long
;
666 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
668 UAP_BSS_PARAMS_I
, bss_cfg
,
673 mwifiex_dbg(adapter
, ERROR
,
674 "Failed to set wiphy phy params\n");
679 case MWIFIEX_BSS_ROLE_STA
:
680 if (priv
->media_connected
) {
681 mwifiex_dbg(adapter
, ERROR
,
682 "cannot change wiphy params when connected");
685 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
686 ret
= mwifiex_set_rts(priv
,
687 wiphy
->rts_threshold
);
691 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
692 ret
= mwifiex_set_frag(priv
,
693 wiphy
->frag_threshold
);
704 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
706 u16 mode
= P2P_MODE_DISABLE
;
708 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
709 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
716 * This function initializes the functionalities for P2P client.
717 * The P2P client initialization sequence is:
718 * disable -> device -> client
721 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
725 if (mwifiex_cfg80211_deinit_p2p(priv
))
728 mode
= P2P_MODE_DEVICE
;
729 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
730 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
733 mode
= P2P_MODE_CLIENT
;
734 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
735 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
742 * This function initializes the functionalities for P2P GO.
743 * The P2P GO initialization sequence is:
744 * disable -> device -> GO
747 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
751 if (mwifiex_cfg80211_deinit_p2p(priv
))
754 mode
= P2P_MODE_DEVICE
;
755 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
756 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
760 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
761 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
767 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
769 struct mwifiex_adapter
*adapter
= priv
->adapter
;
772 priv
->mgmt_frame_mask
= 0;
773 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
774 HostCmd_ACT_GEN_SET
, 0,
775 &priv
->mgmt_frame_mask
, false)) {
776 mwifiex_dbg(adapter
, ERROR
,
777 "could not unregister mgmt frame rx\n");
781 mwifiex_deauthenticate(priv
, NULL
);
783 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
784 adapter
->main_locked
= true;
785 if (adapter
->mwifiex_processing
) {
786 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
787 flush_workqueue(adapter
->workqueue
);
789 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
792 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
793 adapter
->rx_locked
= true;
794 if (adapter
->rx_processing
) {
795 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
796 flush_workqueue(adapter
->rx_workqueue
);
798 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
801 mwifiex_free_priv(priv
);
802 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
803 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
804 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
810 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
811 struct net_device
*dev
,
812 enum nl80211_iftype type
)
814 struct mwifiex_adapter
*adapter
= priv
->adapter
;
817 mwifiex_init_priv(priv
);
819 priv
->bss_mode
= type
;
820 priv
->wdev
.iftype
= type
;
822 mwifiex_init_priv_params(priv
, priv
->netdev
);
823 priv
->bss_started
= 0;
826 case NL80211_IFTYPE_STATION
:
827 case NL80211_IFTYPE_ADHOC
:
828 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
829 MWIFIEX_BSS_TYPE_STA
);
830 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
831 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
833 case NL80211_IFTYPE_P2P_CLIENT
:
834 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
835 MWIFIEX_BSS_TYPE_P2P
);
836 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
837 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
839 case NL80211_IFTYPE_P2P_GO
:
840 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
841 MWIFIEX_BSS_TYPE_P2P
);
842 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
843 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
845 case NL80211_IFTYPE_AP
:
846 priv
->bss_num
= mwifiex_get_unused_bss_num(adapter
,
847 MWIFIEX_BSS_TYPE_UAP
);
848 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
849 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
852 mwifiex_dbg(adapter
, ERROR
,
853 "%s: changing to %d not supported\n",
858 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
859 adapter
->main_locked
= false;
860 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
862 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
863 adapter
->rx_locked
= false;
864 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
870 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
871 enum nl80211_iftype curr_iftype
,
872 enum nl80211_iftype type
, u32
*flags
,
873 struct vif_params
*params
)
875 struct mwifiex_private
*priv
;
876 struct mwifiex_adapter
*adapter
;
878 priv
= mwifiex_netdev_get_priv(dev
);
883 adapter
= priv
->adapter
;
885 if (adapter
->curr_iface_comb
.p2p_intf
==
886 adapter
->iface_limit
.p2p_intf
) {
887 mwifiex_dbg(adapter
, ERROR
,
888 "cannot create multiple P2P ifaces\n");
892 mwifiex_dbg(adapter
, INFO
,
893 "%s: changing role to p2p\n", dev
->name
);
895 if (mwifiex_deinit_priv_params(priv
))
897 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
901 case NL80211_IFTYPE_P2P_CLIENT
:
902 if (mwifiex_cfg80211_init_p2p_client(priv
))
905 case NL80211_IFTYPE_P2P_GO
:
906 if (mwifiex_cfg80211_init_p2p_go(priv
))
910 mwifiex_dbg(adapter
, ERROR
,
911 "%s: changing to %d not supported\n",
916 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
917 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
920 if (mwifiex_sta_init_cmd(priv
, false, false))
923 switch (curr_iftype
) {
924 case NL80211_IFTYPE_STATION
:
925 case NL80211_IFTYPE_ADHOC
:
926 adapter
->curr_iface_comb
.sta_intf
--;
928 case NL80211_IFTYPE_AP
:
929 adapter
->curr_iface_comb
.uap_intf
--;
935 adapter
->curr_iface_comb
.p2p_intf
++;
936 dev
->ieee80211_ptr
->iftype
= type
;
942 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
943 enum nl80211_iftype curr_iftype
,
944 enum nl80211_iftype type
, u32
*flags
,
945 struct vif_params
*params
)
947 struct mwifiex_private
*priv
;
948 struct mwifiex_adapter
*adapter
;
950 priv
= mwifiex_netdev_get_priv(dev
);
955 adapter
= priv
->adapter
;
957 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
958 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
959 (adapter
->curr_iface_comb
.sta_intf
==
960 adapter
->iface_limit
.sta_intf
)) {
961 mwifiex_dbg(adapter
, ERROR
,
962 "cannot create multiple station/adhoc ifaces\n");
966 if (type
== NL80211_IFTYPE_STATION
)
967 mwifiex_dbg(adapter
, INFO
,
968 "%s: changing role to station\n", dev
->name
);
970 mwifiex_dbg(adapter
, INFO
,
971 "%s: changing role to adhoc\n", dev
->name
);
973 if (mwifiex_deinit_priv_params(priv
))
975 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
977 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
978 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
980 if (mwifiex_sta_init_cmd(priv
, false, false))
983 switch (curr_iftype
) {
984 case NL80211_IFTYPE_P2P_CLIENT
:
985 case NL80211_IFTYPE_P2P_GO
:
986 adapter
->curr_iface_comb
.p2p_intf
--;
988 case NL80211_IFTYPE_AP
:
989 adapter
->curr_iface_comb
.uap_intf
--;
995 adapter
->curr_iface_comb
.sta_intf
++;
996 dev
->ieee80211_ptr
->iftype
= type
;
1001 mwifiex_change_vif_to_ap(struct net_device
*dev
,
1002 enum nl80211_iftype curr_iftype
,
1003 enum nl80211_iftype type
, u32
*flags
,
1004 struct vif_params
*params
)
1006 struct mwifiex_private
*priv
;
1007 struct mwifiex_adapter
*adapter
;
1009 priv
= mwifiex_netdev_get_priv(dev
);
1014 adapter
= priv
->adapter
;
1016 if (adapter
->curr_iface_comb
.uap_intf
==
1017 adapter
->iface_limit
.uap_intf
) {
1018 mwifiex_dbg(adapter
, ERROR
,
1019 "cannot create multiple AP ifaces\n");
1023 mwifiex_dbg(adapter
, INFO
,
1024 "%s: changing role to AP\n", dev
->name
);
1026 if (mwifiex_deinit_priv_params(priv
))
1028 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1030 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1031 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1033 if (mwifiex_sta_init_cmd(priv
, false, false))
1036 switch (curr_iftype
) {
1037 case NL80211_IFTYPE_P2P_CLIENT
:
1038 case NL80211_IFTYPE_P2P_GO
:
1039 adapter
->curr_iface_comb
.p2p_intf
--;
1041 case NL80211_IFTYPE_STATION
:
1042 case NL80211_IFTYPE_ADHOC
:
1043 adapter
->curr_iface_comb
.sta_intf
--;
1049 adapter
->curr_iface_comb
.uap_intf
++;
1050 dev
->ieee80211_ptr
->iftype
= type
;
1054 * CFG802.11 operation handler to change interface type.
1057 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1058 struct net_device
*dev
,
1059 enum nl80211_iftype type
, u32
*flags
,
1060 struct vif_params
*params
)
1062 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1063 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1065 switch (curr_iftype
) {
1066 case NL80211_IFTYPE_ADHOC
:
1068 case NL80211_IFTYPE_STATION
:
1069 priv
->bss_mode
= type
;
1070 priv
->sec_info
.authentication_mode
=
1071 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1072 dev
->ieee80211_ptr
->iftype
= type
;
1073 mwifiex_deauthenticate(priv
, NULL
);
1074 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1075 HostCmd_ACT_GEN_SET
, 0, NULL
,
1077 case NL80211_IFTYPE_P2P_CLIENT
:
1078 case NL80211_IFTYPE_P2P_GO
:
1079 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1080 type
, flags
, params
);
1081 case NL80211_IFTYPE_AP
:
1082 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1084 case NL80211_IFTYPE_UNSPECIFIED
:
1085 mwifiex_dbg(priv
->adapter
, INFO
,
1086 "%s: kept type as IBSS\n", dev
->name
);
1087 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1090 mwifiex_dbg(priv
->adapter
, ERROR
,
1091 "%s: changing to %d not supported\n",
1096 case NL80211_IFTYPE_STATION
:
1098 case NL80211_IFTYPE_ADHOC
:
1099 priv
->bss_mode
= type
;
1100 priv
->sec_info
.authentication_mode
=
1101 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1102 dev
->ieee80211_ptr
->iftype
= type
;
1103 mwifiex_deauthenticate(priv
, NULL
);
1104 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1105 HostCmd_ACT_GEN_SET
, 0, NULL
,
1107 case NL80211_IFTYPE_P2P_CLIENT
:
1108 case NL80211_IFTYPE_P2P_GO
:
1109 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1110 type
, flags
, params
);
1111 case NL80211_IFTYPE_AP
:
1112 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1114 case NL80211_IFTYPE_UNSPECIFIED
:
1115 mwifiex_dbg(priv
->adapter
, INFO
,
1116 "%s: kept type as STA\n", dev
->name
);
1117 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1120 mwifiex_dbg(priv
->adapter
, ERROR
,
1121 "%s: changing to %d not supported\n",
1126 case NL80211_IFTYPE_AP
:
1128 case NL80211_IFTYPE_ADHOC
:
1129 case NL80211_IFTYPE_STATION
:
1130 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1134 case NL80211_IFTYPE_P2P_CLIENT
:
1135 case NL80211_IFTYPE_P2P_GO
:
1136 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1137 type
, flags
, params
);
1138 case NL80211_IFTYPE_UNSPECIFIED
:
1139 mwifiex_dbg(priv
->adapter
, INFO
,
1140 "%s: kept type as AP\n", dev
->name
);
1141 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1144 mwifiex_dbg(priv
->adapter
, ERROR
,
1145 "%s: changing to %d not supported\n",
1150 case NL80211_IFTYPE_P2P_CLIENT
:
1151 case NL80211_IFTYPE_P2P_GO
:
1153 case NL80211_IFTYPE_STATION
:
1154 if (mwifiex_cfg80211_deinit_p2p(priv
))
1156 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1157 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1158 dev
->ieee80211_ptr
->iftype
= type
;
1160 case NL80211_IFTYPE_ADHOC
:
1161 if (mwifiex_cfg80211_deinit_p2p(priv
))
1163 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1167 case NL80211_IFTYPE_AP
:
1168 if (mwifiex_cfg80211_deinit_p2p(priv
))
1170 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1172 case NL80211_IFTYPE_UNSPECIFIED
:
1173 mwifiex_dbg(priv
->adapter
, INFO
,
1174 "%s: kept type as P2P\n", dev
->name
);
1175 case NL80211_IFTYPE_P2P_CLIENT
:
1176 case NL80211_IFTYPE_P2P_GO
:
1179 mwifiex_dbg(priv
->adapter
, ERROR
,
1180 "%s: changing to %d not supported\n",
1186 mwifiex_dbg(priv
->adapter
, ERROR
,
1187 "%s: unknown iftype: %d\n",
1188 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1197 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1198 struct rate_info
*rate
)
1200 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1202 if (adapter
->is_hw_11ac_capable
) {
1203 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1204 if (tx_htinfo
& BIT(0)) {
1206 rate
->mcs
= priv
->tx_rate
;
1207 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1209 if (tx_htinfo
& BIT(1)) {
1211 rate
->mcs
= priv
->tx_rate
& 0x0F;
1212 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1215 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1217 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1219 rate
->bw
= RATE_INFO_BW_20
;
1222 rate
->bw
= RATE_INFO_BW_40
;
1225 rate
->bw
= RATE_INFO_BW_80
;
1227 case (BIT(3) | BIT(2)):
1228 rate
->bw
= RATE_INFO_BW_160
;
1232 if (tx_htinfo
& BIT(4))
1233 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1235 if ((priv
->tx_rate
>> 4) == 1)
1242 * Bit 0 in tx_htinfo indicates that current Tx rate
1243 * is 11n rate. Valid MCS index values for us are 0 to 15.
1245 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1246 rate
->mcs
= priv
->tx_rate
;
1247 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1248 rate
->bw
= RATE_INFO_BW_20
;
1249 if (tx_htinfo
& BIT(1))
1250 rate
->bw
= RATE_INFO_BW_40
;
1251 if (tx_htinfo
& BIT(2))
1252 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1258 * This function dumps the station information on a buffer.
1260 * The following information are shown -
1261 * - Total bytes transmitted
1262 * - Total bytes received
1263 * - Total packets transmitted
1264 * - Total packets received
1265 * - Signal quality level
1266 * - Transmission rate
1269 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1270 struct mwifiex_sta_node
*node
,
1271 struct station_info
*sinfo
)
1275 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1276 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1277 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1278 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1280 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1284 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1285 BIT(NL80211_STA_INFO_TX_FAILED
);
1286 sinfo
->inactive_time
=
1287 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1289 sinfo
->signal
= node
->stats
.rssi
;
1290 sinfo
->signal_avg
= node
->stats
.rssi
;
1291 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1292 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1293 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1294 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1295 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1297 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1299 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1304 /* Get signal information from the firmware */
1305 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1306 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1307 mwifiex_dbg(priv
->adapter
, ERROR
,
1308 "failed to get signal information\n");
1312 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1313 mwifiex_dbg(priv
->adapter
, ERROR
,
1314 "getting data rate error\n");
1318 /* Get DTIM period information from firmware */
1319 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1320 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1321 &priv
->dtim_period
, true);
1323 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1325 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1326 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1327 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1328 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1329 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1330 sinfo
->signal
= priv
->bcn_rssi_avg
;
1331 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1332 sinfo
->txrate
.legacy
= rate
* 5;
1334 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1335 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1336 sinfo
->bss_param
.flags
= 0;
1337 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1338 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1339 sinfo
->bss_param
.flags
|=
1340 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1341 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1342 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1343 sinfo
->bss_param
.flags
|=
1344 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1345 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1346 sinfo
->bss_param
.beacon_interval
=
1347 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1354 * CFG802.11 operation handler to get station information.
1356 * This function only works in connected mode, and dumps the
1357 * requested station information, if available.
1360 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1361 const u8
*mac
, struct station_info
*sinfo
)
1363 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1365 if (!priv
->media_connected
)
1367 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1370 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1374 * CFG802.11 operation handler to dump station information.
1377 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1378 int idx
, u8
*mac
, struct station_info
*sinfo
)
1380 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1381 static struct mwifiex_sta_node
*node
;
1383 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1384 priv
->media_connected
&& idx
== 0) {
1385 ether_addr_copy(mac
, priv
->cfg_bssid
);
1386 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1387 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1388 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1389 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1391 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1396 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1397 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1398 ether_addr_copy(mac
, node
->mac_addr
);
1399 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1407 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1408 int idx
, struct survey_info
*survey
)
1410 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1411 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1412 enum ieee80211_band band
;
1414 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1416 memset(survey
, 0, sizeof(struct survey_info
));
1418 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1419 priv
->media_connected
&& idx
== 0) {
1420 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1421 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1423 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1424 survey
->channel
= ieee80211_get_channel(wiphy
,
1425 ieee80211_channel_to_frequency(chan
, band
));
1427 if (priv
->bcn_nf_last
) {
1428 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1429 survey
->noise
= priv
->bcn_nf_last
;
1434 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1437 if (!pchan_stats
[idx
].cca_scan_dur
)
1440 band
= pchan_stats
[idx
].bandcfg
;
1441 survey
->channel
= ieee80211_get_channel(wiphy
,
1442 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1443 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1445 SURVEY_INFO_TIME_BUSY
;
1446 survey
->noise
= pchan_stats
[idx
].noise
;
1447 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1448 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1453 /* Supported rates to be advertised to the cfg80211 */
1454 static struct ieee80211_rate mwifiex_rates
[] = {
1455 {.bitrate
= 10, .hw_value
= 2, },
1456 {.bitrate
= 20, .hw_value
= 4, },
1457 {.bitrate
= 55, .hw_value
= 11, },
1458 {.bitrate
= 110, .hw_value
= 22, },
1459 {.bitrate
= 60, .hw_value
= 12, },
1460 {.bitrate
= 90, .hw_value
= 18, },
1461 {.bitrate
= 120, .hw_value
= 24, },
1462 {.bitrate
= 180, .hw_value
= 36, },
1463 {.bitrate
= 240, .hw_value
= 48, },
1464 {.bitrate
= 360, .hw_value
= 72, },
1465 {.bitrate
= 480, .hw_value
= 96, },
1466 {.bitrate
= 540, .hw_value
= 108, },
1469 /* Channel definitions to be advertised to cfg80211 */
1470 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1471 {.center_freq
= 2412, .hw_value
= 1, },
1472 {.center_freq
= 2417, .hw_value
= 2, },
1473 {.center_freq
= 2422, .hw_value
= 3, },
1474 {.center_freq
= 2427, .hw_value
= 4, },
1475 {.center_freq
= 2432, .hw_value
= 5, },
1476 {.center_freq
= 2437, .hw_value
= 6, },
1477 {.center_freq
= 2442, .hw_value
= 7, },
1478 {.center_freq
= 2447, .hw_value
= 8, },
1479 {.center_freq
= 2452, .hw_value
= 9, },
1480 {.center_freq
= 2457, .hw_value
= 10, },
1481 {.center_freq
= 2462, .hw_value
= 11, },
1482 {.center_freq
= 2467, .hw_value
= 12, },
1483 {.center_freq
= 2472, .hw_value
= 13, },
1484 {.center_freq
= 2484, .hw_value
= 14, },
1487 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1488 .channels
= mwifiex_channels_2ghz
,
1489 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1490 .bitrates
= mwifiex_rates
,
1491 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1494 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1495 {.center_freq
= 5040, .hw_value
= 8, },
1496 {.center_freq
= 5060, .hw_value
= 12, },
1497 {.center_freq
= 5080, .hw_value
= 16, },
1498 {.center_freq
= 5170, .hw_value
= 34, },
1499 {.center_freq
= 5190, .hw_value
= 38, },
1500 {.center_freq
= 5210, .hw_value
= 42, },
1501 {.center_freq
= 5230, .hw_value
= 46, },
1502 {.center_freq
= 5180, .hw_value
= 36, },
1503 {.center_freq
= 5200, .hw_value
= 40, },
1504 {.center_freq
= 5220, .hw_value
= 44, },
1505 {.center_freq
= 5240, .hw_value
= 48, },
1506 {.center_freq
= 5260, .hw_value
= 52, },
1507 {.center_freq
= 5280, .hw_value
= 56, },
1508 {.center_freq
= 5300, .hw_value
= 60, },
1509 {.center_freq
= 5320, .hw_value
= 64, },
1510 {.center_freq
= 5500, .hw_value
= 100, },
1511 {.center_freq
= 5520, .hw_value
= 104, },
1512 {.center_freq
= 5540, .hw_value
= 108, },
1513 {.center_freq
= 5560, .hw_value
= 112, },
1514 {.center_freq
= 5580, .hw_value
= 116, },
1515 {.center_freq
= 5600, .hw_value
= 120, },
1516 {.center_freq
= 5620, .hw_value
= 124, },
1517 {.center_freq
= 5640, .hw_value
= 128, },
1518 {.center_freq
= 5660, .hw_value
= 132, },
1519 {.center_freq
= 5680, .hw_value
= 136, },
1520 {.center_freq
= 5700, .hw_value
= 140, },
1521 {.center_freq
= 5745, .hw_value
= 149, },
1522 {.center_freq
= 5765, .hw_value
= 153, },
1523 {.center_freq
= 5785, .hw_value
= 157, },
1524 {.center_freq
= 5805, .hw_value
= 161, },
1525 {.center_freq
= 5825, .hw_value
= 165, },
1528 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1529 .channels
= mwifiex_channels_5ghz
,
1530 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1531 .bitrates
= mwifiex_rates
+ 4,
1532 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1536 /* Supported crypto cipher suits to be advertised to cfg80211 */
1537 static const u32 mwifiex_cipher_suites
[] = {
1538 WLAN_CIPHER_SUITE_WEP40
,
1539 WLAN_CIPHER_SUITE_WEP104
,
1540 WLAN_CIPHER_SUITE_TKIP
,
1541 WLAN_CIPHER_SUITE_CCMP
,
1542 WLAN_CIPHER_SUITE_SMS4
,
1543 WLAN_CIPHER_SUITE_AES_CMAC
,
1546 /* Supported mgmt frame types to be advertised to cfg80211 */
1547 static const struct ieee80211_txrx_stypes
1548 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1549 [NL80211_IFTYPE_STATION
] = {
1550 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1551 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1552 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1553 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1555 [NL80211_IFTYPE_AP
] = {
1556 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1557 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1558 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1559 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1561 [NL80211_IFTYPE_P2P_CLIENT
] = {
1562 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1563 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1564 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1565 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1567 [NL80211_IFTYPE_P2P_GO
] = {
1568 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1569 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1570 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1571 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1576 * CFG802.11 operation handler for setting bit rates.
1578 * Function configures data rates to firmware using bitrate mask
1579 * provided by cfg80211.
1581 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1582 struct net_device
*dev
,
1584 const struct cfg80211_bitrate_mask
*mask
)
1586 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1587 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1588 enum ieee80211_band band
;
1589 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1591 if (!priv
->media_connected
) {
1592 mwifiex_dbg(adapter
, ERROR
,
1593 "Can not set Tx data rate in disconnected state\n");
1597 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1599 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1601 /* Fill HR/DSSS rates. */
1602 if (band
== IEEE80211_BAND_2GHZ
)
1603 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1605 /* Fill OFDM rates */
1606 if (band
== IEEE80211_BAND_2GHZ
)
1607 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1609 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1611 /* Fill HT MCS rates */
1612 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1613 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1614 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1616 /* Fill VHT MCS rates */
1617 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1618 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1619 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1620 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1623 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1624 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1628 * CFG802.11 operation handler for connection quality monitoring.
1630 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1633 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1634 struct net_device
*dev
,
1635 s32 rssi_thold
, u32 rssi_hyst
)
1637 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1638 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1640 priv
->cqm_rssi_thold
= rssi_thold
;
1641 priv
->cqm_rssi_hyst
= rssi_hyst
;
1643 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1644 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1646 /* Subscribe/unsubscribe low and high rssi events */
1647 if (rssi_thold
&& rssi_hyst
) {
1648 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1649 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1650 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1651 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1652 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1653 return mwifiex_send_cmd(priv
,
1654 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1655 0, 0, &subsc_evt
, true);
1657 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1658 return mwifiex_send_cmd(priv
,
1659 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1660 0, 0, &subsc_evt
, true);
1666 /* cfg80211 operation handler for change_beacon.
1667 * Function retrieves and sets modified management IEs to FW.
1669 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1670 struct net_device
*dev
,
1671 struct cfg80211_beacon_data
*data
)
1673 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1675 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1676 mwifiex_dbg(priv
->adapter
, ERROR
,
1677 "%s: bss_type mismatched\n", __func__
);
1681 if (!priv
->bss_started
) {
1682 mwifiex_dbg(priv
->adapter
, ERROR
,
1683 "%s: bss not started\n", __func__
);
1687 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1688 mwifiex_dbg(priv
->adapter
, ERROR
,
1689 "%s: setting mgmt ies failed\n", __func__
);
1696 /* cfg80211 operation handler for del_station.
1697 * Function deauthenticates station which value is provided in mac parameter.
1698 * If mac is NULL/broadcast, all stations in associated station list are
1699 * deauthenticated. If bss is not started or there are no stations in
1700 * associated stations list, no action is taken.
1703 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1704 struct station_del_parameters
*params
)
1706 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1707 struct mwifiex_sta_node
*sta_node
;
1708 u8 deauth_mac
[ETH_ALEN
];
1709 unsigned long flags
;
1711 if (!priv
->bss_started
&& priv
->wdev
.cac_started
) {
1712 mwifiex_dbg(priv
->adapter
, INFO
, "%s: abort CAC!\n", __func__
);
1713 mwifiex_abort_cac(priv
);
1716 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1719 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1722 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1723 __func__
, params
->mac
);
1725 eth_zero_addr(deauth_mac
);
1727 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1728 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1730 ether_addr_copy(deauth_mac
, params
->mac
);
1731 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1733 if (is_valid_ether_addr(deauth_mac
)) {
1734 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1735 HostCmd_ACT_GEN_SET
, 0,
1744 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1746 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1747 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1748 MWIFIEX_BSS_ROLE_ANY
);
1749 struct mwifiex_ds_ant_cfg ant_cfg
;
1751 if (!tx_ant
|| !rx_ant
)
1754 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1755 /* Not a MIMO chip. User should provide specific antenna number
1756 * for Tx/Rx path or enable all antennas for diversity
1758 if (tx_ant
!= rx_ant
)
1761 if ((tx_ant
& (tx_ant
- 1)) &&
1762 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1765 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1766 (priv
->adapter
->number_of_antenna
> 1)) {
1767 tx_ant
= RF_ANTENNA_AUTO
;
1768 rx_ant
= RF_ANTENNA_AUTO
;
1771 struct ieee80211_sta_ht_cap
*ht_info
;
1773 enum ieee80211_band band
;
1775 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1776 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1777 if (adapter
->is_hw_11ac_capable
)
1778 adapter
->usr_dot_11ac_mcs_support
=
1779 MWIFIEX_11AC_MCS_MAP_1X1
;
1781 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1782 if (adapter
->is_hw_11ac_capable
)
1783 adapter
->usr_dot_11ac_mcs_support
=
1784 MWIFIEX_11AC_MCS_MAP_2X2
;
1787 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
1788 if (!adapter
->wiphy
->bands
[band
])
1791 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1793 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1794 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1795 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1799 ant_cfg
.tx_ant
= tx_ant
;
1800 ant_cfg
.rx_ant
= rx_ant
;
1802 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1803 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1806 /* cfg80211 operation handler for stop ap.
1807 * Function stops BSS running at uAP interface.
1809 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1811 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1813 mwifiex_abort_cac(priv
);
1815 if (mwifiex_del_mgmt_ies(priv
))
1816 mwifiex_dbg(priv
->adapter
, ERROR
,
1817 "Failed to delete mgmt IEs!\n");
1819 priv
->ap_11n_enabled
= 0;
1820 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1822 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1823 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1824 mwifiex_dbg(priv
->adapter
, ERROR
,
1825 "Failed to stop the BSS\n");
1829 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1830 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1831 mwifiex_dbg(priv
->adapter
, ERROR
,
1832 "Failed to reset BSS\n");
1836 if (netif_carrier_ok(priv
->netdev
))
1837 netif_carrier_off(priv
->netdev
);
1838 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1843 /* cfg80211 operation handler for start_ap.
1844 * Function sets beacon period, DTIM period, SSID and security into
1845 * AP config structure.
1846 * AP is configured with these settings and BSS is started.
1848 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1849 struct net_device
*dev
,
1850 struct cfg80211_ap_settings
*params
)
1852 struct mwifiex_uap_bss_param
*bss_cfg
;
1853 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1855 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1858 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1862 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1864 if (params
->beacon_interval
)
1865 bss_cfg
->beacon_period
= params
->beacon_interval
;
1866 if (params
->dtim_period
)
1867 bss_cfg
->dtim_period
= params
->dtim_period
;
1869 if (params
->ssid
&& params
->ssid_len
) {
1870 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1871 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1873 if (params
->inactivity_timeout
> 0) {
1874 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1875 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1876 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1879 switch (params
->hidden_ssid
) {
1880 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1881 bss_cfg
->bcast_ssid_ctl
= 1;
1883 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1884 bss_cfg
->bcast_ssid_ctl
= 0;
1886 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1887 /* firmware doesn't support this type of hidden SSID */
1893 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1894 mwifiex_set_uap_rates(bss_cfg
, params
);
1896 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1898 mwifiex_dbg(priv
->adapter
, ERROR
,
1899 "Failed to parse secuirty parameters!\n");
1903 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1905 if (priv
->adapter
->is_hw_11ac_capable
) {
1906 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1907 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1908 priv
->ap_11ac_enabled
);
1911 if (priv
->ap_11ac_enabled
)
1912 mwifiex_set_11ac_ba_params(priv
);
1914 mwifiex_set_ba_params(priv
);
1916 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1918 if (mwifiex_is_11h_active(priv
))
1919 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
1921 if (mwifiex_is_11h_active(priv
) &&
1922 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
1924 mwifiex_dbg(priv
->adapter
, INFO
,
1925 "Disable 11h extensions in FW\n");
1926 if (mwifiex_11h_activate(priv
, false)) {
1927 mwifiex_dbg(priv
->adapter
, ERROR
,
1928 "Failed to disable 11h extensions!!");
1931 priv
->state_11h
.is_11h_active
= false;
1934 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
1935 mwifiex_dbg(priv
->adapter
, ERROR
,
1936 "Failed to start AP\n");
1941 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
1944 if (!netif_carrier_ok(priv
->netdev
))
1945 netif_carrier_on(priv
->netdev
);
1946 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
1948 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
1954 * CFG802.11 operation handler for disconnection request.
1956 * This function does not work when there is already a disconnection
1957 * procedure going on.
1960 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
1963 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1965 if (!mwifiex_stop_bg_scan(priv
))
1966 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
);
1968 if (mwifiex_deauthenticate(priv
, NULL
))
1971 mwifiex_dbg(priv
->adapter
, MSG
,
1972 "info: successfully disconnected from %pM:\t"
1973 "reason code %d\n", priv
->cfg_bssid
, reason_code
);
1975 eth_zero_addr(priv
->cfg_bssid
);
1976 priv
->hs2_enabled
= false;
1982 * This function informs the CFG802.11 subsystem of a new IBSS.
1984 * The following information are sent to the CFG802.11 subsystem
1985 * to register the new IBSS. If we do not register the new IBSS,
1986 * a kernel panic will result.
1992 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
1994 struct ieee80211_channel
*chan
;
1995 struct mwifiex_bss_info bss_info
;
1996 struct cfg80211_bss
*bss
;
1998 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
1999 enum ieee80211_band band
;
2001 if (mwifiex_get_bss_info(priv
, &bss_info
))
2004 ie_buf
[0] = WLAN_EID_SSID
;
2005 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
2007 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
2008 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
2009 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
2011 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
2012 chan
= __ieee80211_get_channel(priv
->wdev
.wiphy
,
2013 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
2016 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2017 CFG80211_BSS_FTYPE_UNKNOWN
,
2018 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2019 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2021 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2022 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2029 * This function connects with a BSS.
2031 * This function handles both Infra and Ad-Hoc modes. It also performs
2032 * validity checking on the provided parameters, disconnects from the
2033 * current BSS (if any), sets up the association/scan parameters,
2034 * including security settings, and performs specific SSID scan before
2035 * trying to connect.
2037 * For Infra mode, the function returns failure if the specified SSID
2038 * is not found in scan table. However, for Ad-Hoc mode, it can create
2039 * the IBSS if it does not exist. On successful completion in either case,
2040 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2043 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2044 const u8
*ssid
, const u8
*bssid
, int mode
,
2045 struct ieee80211_channel
*channel
,
2046 struct cfg80211_connect_params
*sme
, bool privacy
)
2048 struct cfg80211_ssid req_ssid
;
2049 int ret
, auth_type
= 0;
2050 struct cfg80211_bss
*bss
= NULL
;
2051 u8 is_scanning_required
= 0;
2053 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2055 req_ssid
.ssid_len
= ssid_len
;
2056 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2057 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2061 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2062 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2063 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2067 /* As this is new association, clear locally stored
2068 * keys and security related flags */
2069 priv
->sec_info
.wpa_enabled
= false;
2070 priv
->sec_info
.wpa2_enabled
= false;
2071 priv
->wep_key_curr_index
= 0;
2072 priv
->sec_info
.encryption_mode
= 0;
2073 priv
->sec_info
.is_authtype_auto
= 0;
2074 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2076 if (mode
== NL80211_IFTYPE_ADHOC
) {
2077 /* "privacy" is set only for ad-hoc mode */
2080 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2081 * the firmware can find a matching network from the
2082 * scan. The cfg80211 does not give us the encryption
2083 * mode at this stage so just setting it to WEP here.
2085 priv
->sec_info
.encryption_mode
=
2086 WLAN_CIPHER_SUITE_WEP104
;
2087 priv
->sec_info
.authentication_mode
=
2088 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2094 /* Now handle infra mode. "sme" is valid for infra mode only */
2095 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2096 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2097 priv
->sec_info
.is_authtype_auto
= 1;
2099 auth_type
= sme
->auth_type
;
2102 if (sme
->crypto
.n_ciphers_pairwise
) {
2103 priv
->sec_info
.encryption_mode
=
2104 sme
->crypto
.ciphers_pairwise
[0];
2105 priv
->sec_info
.authentication_mode
= auth_type
;
2108 if (sme
->crypto
.cipher_group
) {
2109 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2110 priv
->sec_info
.authentication_mode
= auth_type
;
2113 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2116 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2117 mwifiex_dbg(priv
->adapter
, INFO
,
2118 "info: setting wep encryption\t"
2119 "with key len %d\n", sme
->key_len
);
2120 priv
->wep_key_curr_index
= sme
->key_idx
;
2121 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2122 sme
->key_len
, sme
->key_idx
,
2128 * Scan entries are valid for some time (15 sec). So we can save one
2129 * active scan time if we just try cfg80211_get_bss first. If it fails
2130 * then request scan and cfg80211_get_bss() again for final output.
2133 if (is_scanning_required
) {
2134 /* Do specific SSID scanning */
2135 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2136 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2141 /* Find the BSS we want using available scan results */
2142 if (mode
== NL80211_IFTYPE_ADHOC
)
2143 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2144 bssid
, ssid
, ssid_len
,
2145 IEEE80211_BSS_TYPE_IBSS
,
2146 IEEE80211_PRIVACY_ANY
);
2148 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2149 bssid
, ssid
, ssid_len
,
2150 IEEE80211_BSS_TYPE_ESS
,
2151 IEEE80211_PRIVACY_ANY
);
2154 if (is_scanning_required
) {
2155 mwifiex_dbg(priv
->adapter
, WARN
,
2156 "assoc: requested bss not found in scan results\n");
2159 is_scanning_required
= 1;
2161 mwifiex_dbg(priv
->adapter
, MSG
,
2162 "info: trying to associate to '%s' bssid %pM\n",
2163 (char *)req_ssid
.ssid
, bss
->bssid
);
2164 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2169 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2173 if (mode
== NL80211_IFTYPE_ADHOC
) {
2174 /* Inform the BSS information to kernel, otherwise
2175 * kernel will give a panic after successful assoc */
2176 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2184 * CFG802.11 operation handler for association request.
2186 * This function does not work when the current mode is set to Ad-Hoc, or
2187 * when there is already an association procedure going on. The given BSS
2188 * information is used to associate.
2191 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2192 struct cfg80211_connect_params
*sme
)
2194 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2195 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2198 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2199 mwifiex_dbg(adapter
, ERROR
,
2200 "%s: reject infra assoc request in non-STA role\n",
2205 if (priv
->wdev
.current_bss
) {
2206 mwifiex_dbg(adapter
, ERROR
,
2207 "%s: already connected\n", dev
->name
);
2211 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2212 mwifiex_dbg(adapter
, ERROR
,
2213 "%s: Ignore connection.\t"
2214 "Card removed or FW in bad state\n",
2219 mwifiex_dbg(adapter
, INFO
,
2220 "info: Trying to associate to %s and bssid %pM\n",
2221 (char *)sme
->ssid
, sme
->bssid
);
2223 if (!mwifiex_stop_bg_scan(priv
))
2224 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
);
2226 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2227 priv
->bss_mode
, sme
->channel
, sme
, 0);
2229 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2230 NULL
, 0, WLAN_STATUS_SUCCESS
,
2232 mwifiex_dbg(priv
->adapter
, MSG
,
2233 "info: associated to bssid %pM successfully\n",
2235 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2236 priv
->adapter
->auto_tdls
&&
2237 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2238 mwifiex_setup_auto_tdls_timer(priv
);
2240 mwifiex_dbg(priv
->adapter
, ERROR
,
2241 "info: association to bssid %pM failed\n",
2243 eth_zero_addr(priv
->cfg_bssid
);
2246 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2247 NULL
, 0, NULL
, 0, ret
,
2250 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2252 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2260 * This function sets following parameters for ibss network.
2264 * - secondary channel offset
2266 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2267 struct cfg80211_ibss_params
*params
)
2269 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2271 u8 config_bands
= 0;
2273 if (params
->chandef
.chan
->band
== IEEE80211_BAND_2GHZ
) {
2274 if (!params
->basic_rates
) {
2275 config_bands
= BAND_B
| BAND_G
;
2277 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2279 * Rates below 6 Mbps in the table are CCK
2280 * rates; 802.11b and from 6 they are OFDM;
2283 if (mwifiex_rates
[i
].bitrate
== 60) {
2289 if (params
->basic_rates
< index
) {
2290 config_bands
= BAND_B
;
2292 config_bands
= BAND_G
;
2293 if (params
->basic_rates
% index
)
2294 config_bands
|= BAND_B
;
2298 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2300 config_bands
|= BAND_G
| BAND_GN
;
2302 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2304 config_bands
= BAND_A
;
2306 config_bands
= BAND_AN
| BAND_A
;
2309 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2310 adapter
->config_bands
= config_bands
;
2311 adapter
->adhoc_start_band
= config_bands
;
2313 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2314 adapter
->adhoc_11n_enabled
= true;
2316 adapter
->adhoc_11n_enabled
= false;
2319 adapter
->sec_chan_offset
=
2320 mwifiex_chan_type_to_sec_chan_offset(
2321 cfg80211_get_chandef_type(¶ms
->chandef
));
2322 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2323 params
->chandef
.chan
->center_freq
);
2325 mwifiex_dbg(adapter
, INFO
,
2326 "info: set ibss band %d, chan %d, chan offset %d\n",
2327 config_bands
, priv
->adhoc_channel
,
2328 adapter
->sec_chan_offset
);
2334 * CFG802.11 operation handler to join an IBSS.
2336 * This function does not work in any mode other than Ad-Hoc, or if
2337 * a join operation is already in progress.
2340 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2341 struct cfg80211_ibss_params
*params
)
2343 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2346 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2347 mwifiex_dbg(priv
->adapter
, ERROR
,
2348 "request to join ibss received\t"
2349 "when station is not in ibss mode\n");
2353 mwifiex_dbg(priv
->adapter
, MSG
,
2354 "info: trying to join to %s and bssid %pM\n",
2355 (char *)params
->ssid
, params
->bssid
);
2357 mwifiex_set_ibss_params(priv
, params
);
2359 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2360 params
->bssid
, priv
->bss_mode
,
2361 params
->chandef
.chan
, NULL
,
2365 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2366 params
->chandef
.chan
, GFP_KERNEL
);
2367 mwifiex_dbg(priv
->adapter
, MSG
,
2368 "info: joined/created adhoc network with bssid\t"
2369 "%pM successfully\n", priv
->cfg_bssid
);
2371 mwifiex_dbg(priv
->adapter
, ERROR
,
2372 "info: failed creating/joining adhoc network\n");
2379 * CFG802.11 operation handler to leave an IBSS.
2381 * This function does not work if a leave operation is
2382 * already in progress.
2385 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2387 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2389 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2391 if (mwifiex_deauthenticate(priv
, NULL
))
2394 eth_zero_addr(priv
->cfg_bssid
);
2400 * CFG802.11 operation handler for scan request.
2402 * This function issues a scan request to the firmware based upon
2403 * the user specified scan configuration. On successful completion,
2404 * it also informs the results.
2407 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2408 struct cfg80211_scan_request
*request
)
2410 struct net_device
*dev
= request
->wdev
->netdev
;
2411 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2413 struct ieee80211_channel
*chan
;
2414 struct ieee_types_header
*ie
;
2415 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2417 mwifiex_dbg(priv
->adapter
, CMD
,
2418 "info: received scan request on %s\n", dev
->name
);
2420 /* Block scan request if scan operation or scan cleanup when interface
2421 * is disabled is in process
2423 if (priv
->scan_request
|| priv
->scan_aborting
) {
2424 mwifiex_dbg(priv
->adapter
, WARN
,
2425 "cmd: Scan already in process..\n");
2429 if (!mwifiex_stop_bg_scan(priv
))
2430 cfg80211_sched_scan_stopped_rtnl(priv
->wdev
.wiphy
);
2432 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2436 priv
->scan_request
= request
;
2438 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2439 user_scan_cfg
->ssid_list
= request
->ssids
;
2441 if (request
->ie
&& request
->ie_len
) {
2443 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2444 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2446 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2447 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2448 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2449 offset
+= sizeof(*ie
) + ie
->len
;
2451 if (offset
>= request
->ie_len
)
2456 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2457 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2458 chan
= request
->channels
[i
];
2459 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2460 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2462 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2463 user_scan_cfg
->chan_list
[i
].scan_type
=
2464 MWIFIEX_SCAN_TYPE_PASSIVE
;
2466 user_scan_cfg
->chan_list
[i
].scan_type
=
2467 MWIFIEX_SCAN_TYPE_ACTIVE
;
2469 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2472 if (priv
->adapter
->scan_chan_gap_enabled
&&
2473 mwifiex_is_any_intf_active(priv
))
2474 user_scan_cfg
->scan_chan_gap
=
2475 priv
->adapter
->scan_chan_gap_time
;
2477 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2478 kfree(user_scan_cfg
);
2480 mwifiex_dbg(priv
->adapter
, ERROR
,
2481 "scan failed: %d\n", ret
);
2482 priv
->scan_aborting
= false;
2483 priv
->scan_request
= NULL
;
2487 if (request
->ie
&& request
->ie_len
) {
2488 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2489 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2490 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2491 memset(&priv
->vs_ie
[i
].ie
, 0,
2492 MWIFIEX_MAX_VSIE_LEN
);
2499 /* CFG802.11 operation handler for sched_scan_start.
2501 * This function issues a bgscan config request to the firmware based upon
2502 * the user specified sched_scan configuration. On successful completion,
2503 * firmware will generate BGSCAN_REPORT event, driver should issue bgscan
2504 * query command to get sched_scan results from firmware.
2507 mwifiex_cfg80211_sched_scan_start(struct wiphy
*wiphy
,
2508 struct net_device
*dev
,
2509 struct cfg80211_sched_scan_request
*request
)
2511 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2513 struct ieee80211_channel
*chan
;
2514 struct mwifiex_bg_scan_cfg
*bgscan_cfg
;
2515 struct ieee_types_header
*ie
;
2517 if (!request
|| (!request
->n_ssids
&& !request
->n_match_sets
)) {
2518 wiphy_err(wiphy
, "%s : Invalid Sched_scan parameters",
2523 wiphy_info(wiphy
, "sched_scan start : n_ssids=%d n_match_sets=%d ",
2524 request
->n_ssids
, request
->n_match_sets
);
2525 wiphy_info(wiphy
, "n_channels=%d interval=%d ie_len=%d\n",
2526 request
->n_channels
, request
->scan_plans
->interval
,
2527 (int)request
->ie_len
);
2529 bgscan_cfg
= kzalloc(sizeof(*bgscan_cfg
), GFP_KERNEL
);
2533 if (priv
->scan_request
|| priv
->scan_aborting
)
2534 bgscan_cfg
->start_later
= true;
2536 bgscan_cfg
->num_ssids
= request
->n_match_sets
;
2537 bgscan_cfg
->ssid_list
= request
->match_sets
;
2539 if (request
->ie
&& request
->ie_len
) {
2541 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2542 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2544 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_BGSCAN
;
2545 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2546 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2547 offset
+= sizeof(*ie
) + ie
->len
;
2549 if (offset
>= request
->ie_len
)
2554 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2555 MWIFIEX_BG_SCAN_CHAN_MAX
); i
++) {
2556 chan
= request
->channels
[i
];
2557 bgscan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2558 bgscan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2560 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2561 bgscan_cfg
->chan_list
[i
].scan_type
=
2562 MWIFIEX_SCAN_TYPE_PASSIVE
;
2564 bgscan_cfg
->chan_list
[i
].scan_type
=
2565 MWIFIEX_SCAN_TYPE_ACTIVE
;
2567 bgscan_cfg
->chan_list
[i
].scan_time
= 0;
2570 bgscan_cfg
->chan_per_scan
= min_t(u32
, request
->n_channels
,
2571 MWIFIEX_BG_SCAN_CHAN_MAX
);
2573 /* Use at least 15 second for per scan cycle */
2574 bgscan_cfg
->scan_interval
= (request
->scan_plans
->interval
>
2575 MWIFIEX_BGSCAN_INTERVAL
) ?
2576 request
->scan_plans
->interval
:
2577 MWIFIEX_BGSCAN_INTERVAL
;
2579 bgscan_cfg
->repeat_count
= MWIFIEX_BGSCAN_REPEAT_COUNT
;
2580 bgscan_cfg
->report_condition
= MWIFIEX_BGSCAN_SSID_MATCH
|
2581 MWIFIEX_BGSCAN_WAIT_ALL_CHAN_DONE
;
2582 bgscan_cfg
->bss_type
= MWIFIEX_BSS_MODE_INFRA
;
2583 bgscan_cfg
->action
= MWIFIEX_BGSCAN_ACT_SET
;
2584 bgscan_cfg
->enable
= true;
2585 if (request
->min_rssi_thold
!= NL80211_SCAN_RSSI_THOLD_OFF
) {
2586 bgscan_cfg
->report_condition
|= MWIFIEX_BGSCAN_SSID_RSSI_MATCH
;
2587 bgscan_cfg
->rssi_threshold
= request
->min_rssi_thold
;
2590 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_BG_SCAN_CONFIG
,
2591 HostCmd_ACT_GEN_SET
, 0, bgscan_cfg
, true)) {
2596 priv
->sched_scanning
= true;
2602 /* CFG802.11 operation handler for sched_scan_stop.
2604 * This function issues a bgscan config command to disable
2605 * previous bgscan configuration in the firmware
2607 static int mwifiex_cfg80211_sched_scan_stop(struct wiphy
*wiphy
,
2608 struct net_device
*dev
)
2610 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2612 wiphy_info(wiphy
, "sched scan stop!");
2613 mwifiex_stop_bg_scan(priv
);
2618 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2619 struct mwifiex_private
*priv
)
2621 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2623 vht_info
->vht_supported
= true;
2625 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2626 /* Update MCS support for VHT */
2627 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2628 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2629 vht_info
->vht_mcs
.rx_highest
= 0;
2630 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2631 adapter
->hw_dot_11ac_mcs_support
>> 16);
2632 vht_info
->vht_mcs
.tx_highest
= 0;
2636 * This function sets up the CFG802.11 specific HT capability fields
2637 * with default values.
2639 * The following default values are set -
2640 * - HT Supported = True
2641 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2642 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2643 * - HT Capabilities supported by firmware
2644 * - MCS information, Rx mask = 0xff
2645 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2648 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2649 struct mwifiex_private
*priv
)
2652 struct ieee80211_mcs_info mcs_set
;
2653 u8
*mcs
= (u8
*)&mcs_set
;
2654 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2656 ht_info
->ht_supported
= true;
2657 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2658 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2660 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2662 /* Fill HT capability information */
2663 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2664 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2666 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2668 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2669 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2671 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2673 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2674 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2676 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2678 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2679 ht_info
->cap
|= 3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2681 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2683 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2684 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2686 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2688 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2689 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2691 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2693 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2694 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2696 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2698 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2699 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2701 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2703 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2704 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2706 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2707 /* Set MCS for 1x1/2x2 */
2708 memset(mcs
, 0xff, rx_mcs_supp
);
2709 /* Clear all the other values */
2710 memset(&mcs
[rx_mcs_supp
], 0,
2711 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2712 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2713 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2714 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2715 SETHT_MCS32(mcs_set
.rx_mask
);
2717 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2719 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2723 * create a new virtual interface with the given name and name assign type
2725 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2727 unsigned char name_assign_type
,
2728 enum nl80211_iftype type
,
2730 struct vif_params
*params
)
2732 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2733 struct mwifiex_private
*priv
;
2734 struct net_device
*dev
;
2738 return ERR_PTR(-EFAULT
);
2741 case NL80211_IFTYPE_UNSPECIFIED
:
2742 case NL80211_IFTYPE_STATION
:
2743 case NL80211_IFTYPE_ADHOC
:
2744 if (adapter
->curr_iface_comb
.sta_intf
==
2745 adapter
->iface_limit
.sta_intf
) {
2746 mwifiex_dbg(adapter
, ERROR
,
2747 "cannot create multiple sta/adhoc ifaces\n");
2748 return ERR_PTR(-EINVAL
);
2751 priv
= mwifiex_get_unused_priv_by_bss_type(
2752 adapter
, MWIFIEX_BSS_TYPE_STA
);
2754 mwifiex_dbg(adapter
, ERROR
,
2755 "could not get free private struct\n");
2756 return ERR_PTR(-EFAULT
);
2759 priv
->wdev
.wiphy
= wiphy
;
2760 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2762 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2763 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2765 priv
->bss_mode
= type
;
2767 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2768 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2769 priv
->bss_priority
= 0;
2770 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2773 case NL80211_IFTYPE_AP
:
2774 if (adapter
->curr_iface_comb
.uap_intf
==
2775 adapter
->iface_limit
.uap_intf
) {
2776 mwifiex_dbg(adapter
, ERROR
,
2777 "cannot create multiple AP ifaces\n");
2778 return ERR_PTR(-EINVAL
);
2781 priv
= mwifiex_get_unused_priv_by_bss_type(
2782 adapter
, MWIFIEX_BSS_TYPE_UAP
);
2784 mwifiex_dbg(adapter
, ERROR
,
2785 "could not get free private struct\n");
2786 return ERR_PTR(-EFAULT
);
2789 priv
->wdev
.wiphy
= wiphy
;
2790 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2792 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2793 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2794 priv
->bss_priority
= 0;
2795 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2796 priv
->bss_started
= 0;
2797 priv
->bss_mode
= type
;
2800 case NL80211_IFTYPE_P2P_CLIENT
:
2801 if (adapter
->curr_iface_comb
.p2p_intf
==
2802 adapter
->iface_limit
.p2p_intf
) {
2803 mwifiex_dbg(adapter
, ERROR
,
2804 "cannot create multiple P2P ifaces\n");
2805 return ERR_PTR(-EINVAL
);
2808 priv
= mwifiex_get_unused_priv_by_bss_type(
2809 adapter
, MWIFIEX_BSS_TYPE_P2P
);
2811 mwifiex_dbg(adapter
, ERROR
,
2812 "could not get free private struct\n");
2813 return ERR_PTR(-EFAULT
);
2816 priv
->wdev
.wiphy
= wiphy
;
2817 /* At start-up, wpa_supplicant tries to change the interface
2818 * to NL80211_IFTYPE_STATION if it is not managed mode.
2820 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2821 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2823 /* Setting bss_type to P2P tells firmware that this interface
2824 * is receiving P2P peers found during find phase and doing
2825 * action frame handshake.
2827 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2829 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2830 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2831 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2832 priv
->bss_started
= 0;
2834 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2835 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2836 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2837 return ERR_PTR(-EFAULT
);
2842 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2843 return ERR_PTR(-EINVAL
);
2846 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2847 name_assign_type
, ether_setup
,
2848 IEEE80211_NUM_ACS
, 1);
2850 mwifiex_dbg(adapter
, ERROR
,
2851 "no memory available for netdevice\n");
2852 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2853 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2854 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2855 return ERR_PTR(-ENOMEM
);
2858 mwifiex_init_priv_params(priv
, dev
);
2861 mwifiex_setup_ht_caps(&wiphy
->bands
[IEEE80211_BAND_2GHZ
]->ht_cap
, priv
);
2862 if (adapter
->is_hw_11ac_capable
)
2863 mwifiex_setup_vht_caps(
2864 &wiphy
->bands
[IEEE80211_BAND_2GHZ
]->vht_cap
, priv
);
2866 if (adapter
->config_bands
& BAND_A
)
2867 mwifiex_setup_ht_caps(
2868 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->ht_cap
, priv
);
2870 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2871 mwifiex_setup_vht_caps(
2872 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->vht_cap
, priv
);
2874 dev_net_set(dev
, wiphy_net(wiphy
));
2875 dev
->ieee80211_ptr
= &priv
->wdev
;
2876 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2877 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2878 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2880 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2881 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2882 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2883 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
2885 mdev_priv
= netdev_priv(dev
);
2886 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
2888 SET_NETDEV_DEV(dev
, adapter
->dev
);
2890 /* Register network device */
2891 if (register_netdevice(dev
)) {
2892 mwifiex_dbg(adapter
, ERROR
,
2893 "cannot register virtual network device\n");
2895 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2896 priv
->netdev
= NULL
;
2897 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2898 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2899 return ERR_PTR(-EFAULT
);
2902 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
2905 WQ_UNBOUND
, 1, name
);
2906 if (!priv
->dfs_cac_workqueue
) {
2907 mwifiex_dbg(adapter
, ERROR
,
2908 "cannot register virtual network device\n");
2910 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2911 priv
->netdev
= NULL
;
2912 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2913 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2914 return ERR_PTR(-ENOMEM
);
2917 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
2919 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
2920 WQ_HIGHPRI
| WQ_UNBOUND
|
2921 WQ_MEM_RECLAIM
, 1, name
);
2922 if (!priv
->dfs_chan_sw_workqueue
) {
2923 mwifiex_dbg(adapter
, ERROR
,
2924 "cannot register virtual network device\n");
2926 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2927 priv
->netdev
= NULL
;
2928 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2929 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2930 return ERR_PTR(-ENOMEM
);
2933 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
2934 mwifiex_dfs_chan_sw_work_queue
);
2936 sema_init(&priv
->async_sem
, 1);
2938 mwifiex_dbg(adapter
, INFO
,
2939 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
2941 #ifdef CONFIG_DEBUG_FS
2942 mwifiex_dev_debugfs_init(priv
);
2946 case NL80211_IFTYPE_UNSPECIFIED
:
2947 case NL80211_IFTYPE_STATION
:
2948 case NL80211_IFTYPE_ADHOC
:
2949 adapter
->curr_iface_comb
.sta_intf
++;
2951 case NL80211_IFTYPE_AP
:
2952 adapter
->curr_iface_comb
.uap_intf
++;
2954 case NL80211_IFTYPE_P2P_CLIENT
:
2955 adapter
->curr_iface_comb
.p2p_intf
++;
2958 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2959 return ERR_PTR(-EINVAL
);
2964 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
2967 * del_virtual_intf: remove the virtual interface determined by dev
2969 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
2971 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
2972 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2973 struct sk_buff
*skb
, *tmp
;
2975 #ifdef CONFIG_DEBUG_FS
2976 mwifiex_dev_debugfs_remove(priv
);
2979 if (priv
->sched_scanning
)
2980 priv
->sched_scanning
= false;
2982 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
2984 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
)
2985 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
2987 if (netif_carrier_ok(priv
->netdev
))
2988 netif_carrier_off(priv
->netdev
);
2990 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
2991 unregister_netdevice(wdev
->netdev
);
2993 if (priv
->dfs_cac_workqueue
) {
2994 flush_workqueue(priv
->dfs_cac_workqueue
);
2995 destroy_workqueue(priv
->dfs_cac_workqueue
);
2996 priv
->dfs_cac_workqueue
= NULL
;
2999 if (priv
->dfs_chan_sw_workqueue
) {
3000 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
3001 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
3002 priv
->dfs_chan_sw_workqueue
= NULL
;
3004 /* Clear the priv in adapter */
3005 priv
->netdev
->ieee80211_ptr
= NULL
;
3006 priv
->netdev
= NULL
;
3007 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
3009 priv
->media_connected
= false;
3011 switch (priv
->bss_mode
) {
3012 case NL80211_IFTYPE_UNSPECIFIED
:
3013 case NL80211_IFTYPE_STATION
:
3014 case NL80211_IFTYPE_ADHOC
:
3015 adapter
->curr_iface_comb
.sta_intf
--;
3017 case NL80211_IFTYPE_AP
:
3018 adapter
->curr_iface_comb
.uap_intf
--;
3020 case NL80211_IFTYPE_P2P_CLIENT
:
3021 case NL80211_IFTYPE_P2P_GO
:
3022 adapter
->curr_iface_comb
.p2p_intf
--;
3025 mwifiex_dbg(adapter
, ERROR
,
3026 "del_virtual_intf: type not supported\n");
3030 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
3032 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
3033 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
3034 kfree(priv
->hist_data
);
3038 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
3041 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
3044 int j
, k
, valid_byte_cnt
= 0;
3045 bool dont_care_byte
= false;
3047 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
3048 for (k
= 0; k
< 8; k
++) {
3049 if (pat
->mask
[j
] & 1 << k
) {
3050 memcpy(byte_seq
+ valid_byte_cnt
,
3051 &pat
->pattern
[j
* 8 + k
], 1);
3057 dont_care_byte
= true;
3060 /* wildcard bytes record as the offset
3061 * before the valid byte
3063 if (!valid_byte_cnt
&& !dont_care_byte
)
3066 if (valid_byte_cnt
> max_byte_seq
)
3071 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
3077 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
3078 struct mwifiex_mef_entry
*mef_entry
)
3080 int i
, filt_num
= 0, num_ipv4
= 0;
3081 struct in_device
*in_dev
;
3082 struct in_ifaddr
*ifa
;
3083 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
3084 struct mwifiex_adapter
*adapter
= priv
->adapter
;
3086 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3087 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
3089 /* Enable ARP offload feature */
3090 memset(ips
, 0, sizeof(ips
));
3091 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
3092 if (adapter
->priv
[i
]->netdev
) {
3093 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
3096 ifa
= in_dev
->ifa_list
;
3097 if (!ifa
|| !ifa
->ifa_local
)
3099 ips
[i
] = ifa
->ifa_local
;
3104 for (i
= 0; i
< num_ipv4
; i
++) {
3107 mef_entry
->filter
[filt_num
].repeat
= 1;
3108 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
3109 (u8
*)&ips
[i
], sizeof(ips
[i
]));
3110 mef_entry
->filter
[filt_num
].
3111 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3113 mef_entry
->filter
[filt_num
].offset
= 46;
3114 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3116 mef_entry
->filter
[filt_num
].filt_action
=
3122 mef_entry
->filter
[filt_num
].repeat
= 1;
3123 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
3124 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
3125 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
3126 mef_entry
->filter
[filt_num
].offset
= 20;
3127 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3128 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3131 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
3132 struct mwifiex_ds_mef_cfg
*mef_cfg
,
3133 struct mwifiex_mef_entry
*mef_entry
,
3134 struct cfg80211_wowlan
*wowlan
)
3136 int i
, filt_num
= 0, ret
= 0;
3137 bool first_pat
= true;
3138 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
3139 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3140 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3142 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
3143 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
3145 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
3146 memset(byte_seq
, 0, sizeof(byte_seq
));
3147 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
3149 MWIFIEX_MEF_MAX_BYTESEQ
)) {
3150 mwifiex_dbg(priv
->adapter
, ERROR
,
3151 "Pattern not supported\n");
3155 if (!wowlan
->patterns
[i
].pkt_offset
) {
3156 if (!(byte_seq
[0] & 0x01) &&
3157 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3158 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3160 } else if (is_broadcast_ether_addr(byte_seq
)) {
3161 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3163 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3164 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3165 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3166 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3167 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3171 mef_entry
->filter
[filt_num
].repeat
= 1;
3172 mef_entry
->filter
[filt_num
].offset
=
3173 wowlan
->patterns
[i
].pkt_offset
;
3174 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3176 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3180 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on patterns\n");
3182 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3188 if (wowlan
->magic_pkt
) {
3189 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3190 mef_entry
->filter
[filt_num
].repeat
= 16;
3191 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3193 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3195 mef_entry
->filter
[filt_num
].offset
= 28;
3196 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3198 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3201 mef_entry
->filter
[filt_num
].repeat
= 16;
3202 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3204 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3206 mef_entry
->filter
[filt_num
].offset
= 56;
3207 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3208 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3209 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on magic packet\n");
3214 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3215 struct cfg80211_wowlan
*wowlan
)
3217 int ret
= 0, num_entries
= 1;
3218 struct mwifiex_ds_mef_cfg mef_cfg
;
3219 struct mwifiex_mef_entry
*mef_entry
;
3221 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3224 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3228 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3229 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3230 MWIFIEX_CRITERIA_UNICAST
;
3231 mef_cfg
.num_entries
= num_entries
;
3232 mef_cfg
.mef_entry
= mef_entry
;
3234 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3236 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3237 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3238 &mef_entry
[1], wowlan
);
3243 if (!mef_cfg
.criteria
)
3244 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3245 MWIFIEX_CRITERIA_UNICAST
|
3246 MWIFIEX_CRITERIA_MULTICAST
;
3248 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3249 HostCmd_ACT_GEN_SET
, 0,
3257 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3258 struct cfg80211_wowlan
*wowlan
)
3260 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3261 struct mwifiex_ds_hs_cfg hs_cfg
;
3263 struct mwifiex_private
*priv
;
3265 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3266 priv
= adapter
->priv
[i
];
3267 mwifiex_abort_cac(priv
);
3270 mwifiex_cancel_all_pending_cmd(adapter
);
3273 mwifiex_dbg(adapter
, ERROR
,
3274 "None of the WOWLAN triggers enabled\n");
3278 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3280 if (!priv
->media_connected
&& !wowlan
->nd_config
) {
3281 mwifiex_dbg(adapter
, ERROR
,
3282 "Can not configure WOWLAN in disconnected state\n");
3286 ret
= mwifiex_set_mef_filter(priv
, wowlan
);
3288 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3292 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3293 hs_cfg
.conditions
= le32_to_cpu(adapter
->hs_cfg
.conditions
);
3295 if (wowlan
->nd_config
) {
3296 mwifiex_dbg(adapter
, INFO
, "Wake on net detect\n");
3297 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3298 mwifiex_cfg80211_sched_scan_start(wiphy
, priv
->netdev
,
3302 if (wowlan
->disconnect
) {
3303 hs_cfg
.conditions
|= HS_CFG_COND_MAC_EVENT
;
3304 mwifiex_dbg(priv
->adapter
, INFO
, "Wake on device disconnect\n");
3307 hs_cfg
.is_invoke_hostcmd
= false;
3308 hs_cfg
.gpio
= adapter
->hs_cfg
.gpio
;
3309 hs_cfg
.gap
= adapter
->hs_cfg
.gap
;
3310 ret
= mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
3311 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3313 mwifiex_dbg(adapter
, ERROR
,
3314 "Failed to set HS params\n");
3321 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3323 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3324 struct mwifiex_private
*priv
=
3325 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3326 struct mwifiex_ds_wakeup_reason wakeup_reason
;
3327 struct cfg80211_wowlan_wakeup wakeup_report
;
3330 mwifiex_get_wakeup_reason(priv
, HostCmd_ACT_GEN_GET
, MWIFIEX_SYNC_CMD
,
3332 memset(&wakeup_report
, 0, sizeof(struct cfg80211_wowlan_wakeup
));
3334 wakeup_report
.pattern_idx
= -1;
3336 switch (wakeup_reason
.hs_wakeup_reason
) {
3337 case NO_HSWAKEUP_REASON
:
3339 case BCAST_DATA_MATCHED
:
3341 case MCAST_DATA_MATCHED
:
3343 case UCAST_DATA_MATCHED
:
3345 case MASKTABLE_EVENT_MATCHED
:
3347 case NON_MASKABLE_EVENT_MATCHED
:
3348 if (wiphy
->wowlan_config
->disconnect
)
3349 wakeup_report
.disconnect
= true;
3350 if (wiphy
->wowlan_config
->nd_config
)
3351 wakeup_report
.net_detect
= adapter
->nd_info
;
3353 case NON_MASKABLE_CONDITION_MATCHED
:
3355 case MAGIC_PATTERN_MATCHED
:
3356 if (wiphy
->wowlan_config
->magic_pkt
)
3357 wakeup_report
.magic_pkt
= true;
3358 if (wiphy
->wowlan_config
->n_patterns
)
3359 wakeup_report
.pattern_idx
= 1;
3361 case CONTROL_FRAME_MATCHED
:
3363 case MANAGEMENT_FRAME_MATCHED
:
3369 if ((wakeup_reason
.hs_wakeup_reason
> 0) &&
3370 (wakeup_reason
.hs_wakeup_reason
<= 7))
3371 cfg80211_report_wowlan_wakeup(&priv
->wdev
, &wakeup_report
,
3374 if (adapter
->nd_info
) {
3375 for (i
= 0 ; i
< adapter
->nd_info
->n_matches
; i
++)
3376 kfree(adapter
->nd_info
->matches
[i
]);
3377 kfree(adapter
->nd_info
);
3378 adapter
->nd_info
= NULL
;
3384 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3387 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3389 device_set_wakeup_enable(adapter
->dev
, enabled
);
3393 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3395 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3396 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3397 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3399 if ((byte_seq
[0] & 0x01) &&
3400 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3401 return PACKET_TYPE_UNICAST
;
3402 else if (!memcmp(byte_seq
, bc_mac
, 4))
3403 return PACKET_TYPE_BROADCAST
;
3404 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3405 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3406 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3407 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3408 return PACKET_TYPE_MULTICAST
;
3414 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3415 struct cfg80211_coalesce_rules
*crule
,
3416 struct mwifiex_coalesce_rule
*mrule
)
3418 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3419 struct filt_field_param
*param
;
3422 mrule
->max_coalescing_delay
= crule
->delay
;
3424 param
= mrule
->params
;
3426 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3427 memset(byte_seq
, 0, sizeof(byte_seq
));
3428 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3430 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3431 mwifiex_dbg(priv
->adapter
, ERROR
,
3432 "Pattern not supported\n");
3436 if (!crule
->patterns
[i
].pkt_offset
) {
3439 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3440 if (pkt_type
&& mrule
->pkt_type
) {
3441 mwifiex_dbg(priv
->adapter
, ERROR
,
3442 "Multiple packet types not allowed\n");
3444 } else if (pkt_type
) {
3445 mrule
->pkt_type
= pkt_type
;
3450 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3451 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3453 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3455 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3456 memcpy(param
->operand_byte_stream
, byte_seq
,
3457 param
->operand_len
);
3458 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3461 mrule
->num_of_fields
++;
3464 if (!mrule
->pkt_type
) {
3465 mwifiex_dbg(priv
->adapter
, ERROR
,
3466 "Packet type can not be determined\n");
3473 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3474 struct cfg80211_coalesce
*coalesce
)
3476 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3478 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3479 struct mwifiex_private
*priv
=
3480 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3482 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3484 mwifiex_dbg(adapter
, WARN
,
3485 "Disable coalesce and reset all previous rules\n");
3486 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3487 HostCmd_ACT_GEN_SET
, 0,
3488 &coalesce_cfg
, true);
3491 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3492 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3493 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3494 &coalesce_cfg
.rule
[i
]);
3496 mwifiex_dbg(adapter
, ERROR
,
3497 "Recheck the patterns provided for rule %d\n",
3503 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3504 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3507 /* cfg80211 ops handler for tdls_mgmt.
3508 * Function prepares TDLS action frame packets and forwards them to FW
3511 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3512 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3513 u16 status_code
, u32 peer_capability
,
3514 bool initiator
, const u8
*extra_ies
,
3515 size_t extra_ies_len
)
3517 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3520 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3523 /* make sure we are in station mode and connected */
3524 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3527 switch (action_code
) {
3528 case WLAN_TDLS_SETUP_REQUEST
:
3529 mwifiex_dbg(priv
->adapter
, MSG
,
3530 "Send TDLS Setup Request to %pM status_code=%d\n",
3532 mwifiex_add_auto_tdls_peer(priv
, peer
);
3533 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3534 dialog_token
, status_code
,
3535 extra_ies
, extra_ies_len
);
3537 case WLAN_TDLS_SETUP_RESPONSE
:
3538 mwifiex_add_auto_tdls_peer(priv
, peer
);
3539 mwifiex_dbg(priv
->adapter
, MSG
,
3540 "Send TDLS Setup Response to %pM status_code=%d\n",
3542 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3543 dialog_token
, status_code
,
3544 extra_ies
, extra_ies_len
);
3546 case WLAN_TDLS_SETUP_CONFIRM
:
3547 mwifiex_dbg(priv
->adapter
, MSG
,
3548 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3550 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3551 dialog_token
, status_code
,
3552 extra_ies
, extra_ies_len
);
3554 case WLAN_TDLS_TEARDOWN
:
3555 mwifiex_dbg(priv
->adapter
, MSG
,
3556 "Send TDLS Tear down to %pM\n", peer
);
3557 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3558 dialog_token
, status_code
,
3559 extra_ies
, extra_ies_len
);
3561 case WLAN_TDLS_DISCOVERY_REQUEST
:
3562 mwifiex_dbg(priv
->adapter
, MSG
,
3563 "Send TDLS Discovery Request to %pM\n", peer
);
3564 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3565 dialog_token
, status_code
,
3566 extra_ies
, extra_ies_len
);
3568 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3569 mwifiex_dbg(priv
->adapter
, MSG
,
3570 "Send TDLS Discovery Response to %pM\n", peer
);
3571 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3572 dialog_token
, status_code
,
3573 extra_ies
, extra_ies_len
);
3576 mwifiex_dbg(priv
->adapter
, ERROR
,
3577 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3586 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3587 const u8
*peer
, enum nl80211_tdls_operation action
)
3589 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3591 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3592 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3595 /* make sure we are in station mode and connected */
3596 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3599 mwifiex_dbg(priv
->adapter
, MSG
,
3600 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3603 case NL80211_TDLS_ENABLE_LINK
:
3604 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3606 case NL80211_TDLS_DISABLE_LINK
:
3607 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3609 case NL80211_TDLS_TEARDOWN
:
3610 /* shouldn't happen!*/
3611 mwifiex_dbg(priv
->adapter
, ERROR
,
3612 "tdls_oper: teardown from driver not supported\n");
3614 case NL80211_TDLS_SETUP
:
3615 /* shouldn't happen!*/
3616 mwifiex_dbg(priv
->adapter
, ERROR
,
3617 "tdls_oper: setup from driver not supported\n");
3619 case NL80211_TDLS_DISCOVERY_REQ
:
3620 /* shouldn't happen!*/
3621 mwifiex_dbg(priv
->adapter
, ERROR
,
3622 "tdls_oper: discovery from driver not supported\n");
3625 mwifiex_dbg(priv
->adapter
, ERROR
,
3626 "tdls_oper: operation not supported\n");
3630 return mwifiex_tdls_oper(priv
, peer
, action
);
3634 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3635 const u8
*addr
, u8 oper_class
,
3636 struct cfg80211_chan_def
*chandef
)
3638 struct mwifiex_sta_node
*sta_ptr
;
3639 unsigned long flags
;
3641 u8 second_chan_offset
, band
;
3642 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3644 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3645 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3646 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3649 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3654 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3655 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3656 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3660 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3661 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3662 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3666 chan
= chandef
->chan
->hw_value
;
3667 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3668 band
= chandef
->chan
->band
;
3669 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3675 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3676 struct net_device
*dev
,
3679 struct mwifiex_sta_node
*sta_ptr
;
3680 unsigned long flags
;
3681 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3683 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3684 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3685 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3688 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3690 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3691 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3692 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3693 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3696 mwifiex_stop_tdls_cs(priv
, addr
);
3700 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3701 const u8
*mac
, struct station_parameters
*params
)
3703 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3705 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3708 /* make sure we are in station mode and connected */
3709 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3712 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3716 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3717 struct cfg80211_csa_settings
*params
)
3719 struct ieee_types_header
*chsw_ie
;
3720 struct ieee80211_channel_sw_ie
*channel_sw
;
3722 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3724 if (priv
->adapter
->scan_processing
) {
3725 mwifiex_dbg(priv
->adapter
, ERROR
,
3726 "radar detection: scan in process...\n");
3730 if (priv
->wdev
.cac_started
)
3733 if (cfg80211_chandef_identical(¶ms
->chandef
,
3734 &priv
->dfs_chandef
))
3737 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3738 params
->beacon_csa
.tail
,
3739 params
->beacon_csa
.tail_len
);
3741 mwifiex_dbg(priv
->adapter
, ERROR
,
3742 "Could not parse channel switch announcement IE\n");
3746 channel_sw
= (void *)(chsw_ie
+ 1);
3747 if (channel_sw
->mode
) {
3748 if (netif_carrier_ok(priv
->netdev
))
3749 netif_carrier_off(priv
->netdev
);
3750 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3753 if (mwifiex_del_mgmt_ies(priv
))
3754 mwifiex_dbg(priv
->adapter
, ERROR
,
3755 "Failed to delete mgmt IEs!\n");
3757 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3758 mwifiex_dbg(priv
->adapter
, ERROR
,
3759 "%s: setting mgmt ies failed\n", __func__
);
3763 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3764 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3765 sizeof(priv
->beacon_after
));
3767 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3768 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3769 msecs_to_jiffies(chsw_msec
));
3773 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3774 struct wireless_dev
*wdev
,
3775 struct cfg80211_chan_def
*chandef
)
3777 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3778 struct mwifiex_bssdescriptor
*curr_bss
;
3779 struct ieee80211_channel
*chan
;
3780 u8 second_chan_offset
;
3781 enum nl80211_channel_type chan_type
;
3782 enum ieee80211_band band
;
3786 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3787 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3788 *chandef
= priv
->bss_chandef
;
3790 } else if (priv
->media_connected
) {
3791 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3792 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3793 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3794 chan
= ieee80211_get_channel(wiphy
, freq
);
3796 if (priv
->ht_param_present
) {
3797 second_chan_offset
= priv
->assoc_resp_ht_param
&
3798 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3799 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3800 (second_chan_offset
);
3801 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3803 cfg80211_chandef_create(chandef
, chan
,
3804 NL80211_CHAN_NO_HT
);
3813 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
3814 struct net_device
*dev
,
3815 struct cfg80211_chan_def
*chandef
,
3818 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3819 struct mwifiex_radar_params radar_params
;
3821 if (priv
->adapter
->scan_processing
) {
3822 mwifiex_dbg(priv
->adapter
, ERROR
,
3823 "radar detection: scan already in process...\n");
3827 if (!mwifiex_is_11h_active(priv
)) {
3828 mwifiex_dbg(priv
->adapter
, INFO
,
3829 "Enable 11h extensions in FW\n");
3830 if (mwifiex_11h_activate(priv
, true)) {
3831 mwifiex_dbg(priv
->adapter
, ERROR
,
3832 "Failed to activate 11h extensions!!");
3835 priv
->state_11h
.is_11h_active
= true;
3838 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
3839 radar_params
.chandef
= chandef
;
3840 radar_params
.cac_time_ms
= cac_time_ms
;
3842 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
3844 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
3845 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
3848 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
3849 msecs_to_jiffies(cac_time_ms
));
3854 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3856 struct station_parameters
*params
)
3859 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3861 /* we support change_station handler only for TDLS peers*/
3862 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3865 /* make sure we are in station mode and connected */
3866 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3869 priv
->sta_params
= params
;
3871 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
3872 priv
->sta_params
= NULL
;
3877 /* station cfg80211 operations */
3878 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
3879 .add_virtual_intf
= mwifiex_add_virtual_intf
,
3880 .del_virtual_intf
= mwifiex_del_virtual_intf
,
3881 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
3882 .scan
= mwifiex_cfg80211_scan
,
3883 .connect
= mwifiex_cfg80211_connect
,
3884 .disconnect
= mwifiex_cfg80211_disconnect
,
3885 .get_station
= mwifiex_cfg80211_get_station
,
3886 .dump_station
= mwifiex_cfg80211_dump_station
,
3887 .dump_survey
= mwifiex_cfg80211_dump_survey
,
3888 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
3889 .join_ibss
= mwifiex_cfg80211_join_ibss
,
3890 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
3891 .add_key
= mwifiex_cfg80211_add_key
,
3892 .del_key
= mwifiex_cfg80211_del_key
,
3893 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
3894 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
3895 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
3896 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
3897 .set_default_key
= mwifiex_cfg80211_set_default_key
,
3898 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
3899 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
3900 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
3901 .start_ap
= mwifiex_cfg80211_start_ap
,
3902 .stop_ap
= mwifiex_cfg80211_stop_ap
,
3903 .change_beacon
= mwifiex_cfg80211_change_beacon
,
3904 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
3905 .set_antenna
= mwifiex_cfg80211_set_antenna
,
3906 .del_station
= mwifiex_cfg80211_del_station
,
3907 .sched_scan_start
= mwifiex_cfg80211_sched_scan_start
,
3908 .sched_scan_stop
= mwifiex_cfg80211_sched_scan_stop
,
3910 .suspend
= mwifiex_cfg80211_suspend
,
3911 .resume
= mwifiex_cfg80211_resume
,
3912 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
3914 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
3915 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
3916 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
3917 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
3918 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
3919 .add_station
= mwifiex_cfg80211_add_station
,
3920 .change_station
= mwifiex_cfg80211_change_station
,
3921 .get_channel
= mwifiex_cfg80211_get_channel
,
3922 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
3923 .channel_switch
= mwifiex_cfg80211_channel_switch
,
3927 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
3928 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
|
3929 WIPHY_WOWLAN_NET_DETECT
,
3930 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
3931 .pattern_min_len
= 1,
3932 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3933 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3934 .max_nd_match_sets
= MWIFIEX_MAX_ND_MATCH_SETS
,
3938 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
3940 if (!alpha2
|| strlen(alpha2
) != 2)
3943 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
3949 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
3950 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
3951 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
3952 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
3953 .pattern_min_len
= 1,
3954 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3955 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3958 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
3960 u32 n_channels_bg
, n_channels_a
= 0;
3962 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
3964 if (adapter
->config_bands
& BAND_A
)
3965 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
3967 adapter
->num_in_chan_stats
= max_t(u32
, n_channels_bg
, n_channels_a
);
3968 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
3969 adapter
->num_in_chan_stats
);
3971 if (!adapter
->chan_stats
)
3978 * This function registers the device with CFG802.11 subsystem.
3980 * The function creates the wireless device/wiphy, populates it with
3981 * default parameters and handler function pointers, and finally
3982 * registers the device.
3985 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
3989 struct wiphy
*wiphy
;
3990 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
3994 /* create a new wiphy for use with cfg80211 */
3995 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
3996 sizeof(struct mwifiex_adapter
*));
3998 mwifiex_dbg(adapter
, ERROR
,
3999 "%s: creating new wiphy\n", __func__
);
4002 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4003 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4004 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
4005 wiphy
->max_remain_on_channel_duration
= 5000;
4006 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
4007 BIT(NL80211_IFTYPE_ADHOC
) |
4008 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
4009 BIT(NL80211_IFTYPE_P2P_GO
) |
4010 BIT(NL80211_IFTYPE_AP
);
4012 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
4013 if (adapter
->config_bands
& BAND_A
)
4014 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
4016 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = NULL
;
4018 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
4019 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
4020 else if (adapter
->is_hw_11ac_capable
)
4021 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
4023 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
4024 wiphy
->n_iface_combinations
= 1;
4026 /* Initialize cipher suits */
4027 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
4028 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
4030 if (adapter
->region_code
)
4031 wiphy
->regulatory_flags
|= REGULATORY_DISABLE_BEACON_HINTS
|
4032 REGULATORY_COUNTRY_IE_IGNORE
;
4034 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
4035 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
4036 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
4037 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
4038 WIPHY_FLAG_AP_UAPSD
|
4039 WIPHY_FLAG_SUPPORTS_SCHED_SCAN
|
4040 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
4041 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
4042 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
4044 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4045 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
4046 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
4049 wiphy
->wowlan
= &mwifiex_wowlan_support
;
4052 wiphy
->coalesce
= &mwifiex_coalesce_support
;
4054 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
4055 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
4056 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
4058 wiphy
->max_sched_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4059 wiphy
->max_sched_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
4060 wiphy
->max_match_sets
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
4062 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
4063 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
4065 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
4066 NL80211_FEATURE_INACTIVITY_TIMER
|
4067 NL80211_FEATURE_NEED_OBSS_SCAN
;
4069 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
4070 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
4072 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
4073 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
4075 /* Reserve space for mwifiex specific private data for BSS */
4076 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
4078 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
4080 /* Set struct mwifiex_adapter pointer in wiphy_priv */
4081 wdev_priv
= wiphy_priv(wiphy
);
4082 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
4084 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
4086 ret
= wiphy_register(wiphy
);
4088 mwifiex_dbg(adapter
, ERROR
,
4089 "%s: wiphy_register failed: %d\n", __func__
, ret
);
4094 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
4095 mwifiex_dbg(adapter
, INFO
,
4096 "driver hint alpha2: %2.2s\n", reg_alpha2
);
4097 regulatory_hint(wiphy
, reg_alpha2
);
4099 if (adapter
->region_code
== 0x00) {
4100 mwifiex_dbg(adapter
, WARN
, "Ignore world regulatory domain\n");
4103 mwifiex_11d_code_2_region(adapter
->region_code
);
4105 regulatory_hint(wiphy
, country_code
))
4106 mwifiex_dbg(priv
->adapter
, ERROR
, "regulatory_hint() failed\n");
4110 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4111 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
4112 wiphy
->frag_threshold
= thr
;
4113 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4114 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
4115 wiphy
->rts_threshold
= thr
;
4116 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4117 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
4118 wiphy
->retry_short
= (u8
) retry
;
4119 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
4120 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
4121 wiphy
->retry_long
= (u8
) retry
;
4123 adapter
->wiphy
= wiphy
;