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_role
= MWIFIEX_BSS_ROLE_STA
;
829 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
831 case NL80211_IFTYPE_P2P_CLIENT
:
832 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
833 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
835 case NL80211_IFTYPE_P2P_GO
:
836 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
837 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
839 case NL80211_IFTYPE_AP
:
840 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
841 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
844 mwifiex_dbg(adapter
, ERROR
,
845 "%s: changing to %d not supported\n",
850 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
851 adapter
->main_locked
= false;
852 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
854 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
855 adapter
->rx_locked
= false;
856 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
862 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
863 enum nl80211_iftype curr_iftype
,
864 enum nl80211_iftype type
, u32
*flags
,
865 struct vif_params
*params
)
867 struct mwifiex_private
*priv
;
868 struct mwifiex_adapter
*adapter
;
870 priv
= mwifiex_netdev_get_priv(dev
);
875 adapter
= priv
->adapter
;
877 if (adapter
->curr_iface_comb
.p2p_intf
==
878 adapter
->iface_limit
.p2p_intf
) {
879 mwifiex_dbg(adapter
, ERROR
,
880 "cannot create multiple P2P ifaces\n");
884 mwifiex_dbg(adapter
, INFO
,
885 "%s: changing role to p2p\n", dev
->name
);
887 if (mwifiex_deinit_priv_params(priv
))
889 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
893 case NL80211_IFTYPE_P2P_CLIENT
:
894 if (mwifiex_cfg80211_init_p2p_client(priv
))
897 case NL80211_IFTYPE_P2P_GO
:
898 if (mwifiex_cfg80211_init_p2p_go(priv
))
902 mwifiex_dbg(adapter
, ERROR
,
903 "%s: changing to %d not supported\n",
908 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
909 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
912 if (mwifiex_sta_init_cmd(priv
, false, false))
915 switch (curr_iftype
) {
916 case NL80211_IFTYPE_STATION
:
917 case NL80211_IFTYPE_ADHOC
:
918 adapter
->curr_iface_comb
.sta_intf
--;
920 case NL80211_IFTYPE_AP
:
921 adapter
->curr_iface_comb
.uap_intf
--;
927 adapter
->curr_iface_comb
.p2p_intf
++;
928 dev
->ieee80211_ptr
->iftype
= type
;
934 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
935 enum nl80211_iftype curr_iftype
,
936 enum nl80211_iftype type
, u32
*flags
,
937 struct vif_params
*params
)
939 struct mwifiex_private
*priv
;
940 struct mwifiex_adapter
*adapter
;
942 priv
= mwifiex_netdev_get_priv(dev
);
947 adapter
= priv
->adapter
;
949 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
950 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
951 (adapter
->curr_iface_comb
.sta_intf
==
952 adapter
->iface_limit
.sta_intf
)) {
953 mwifiex_dbg(adapter
, ERROR
,
954 "cannot create multiple station/adhoc ifaces\n");
958 if (type
== NL80211_IFTYPE_STATION
)
959 mwifiex_dbg(adapter
, INFO
,
960 "%s: changing role to station\n", dev
->name
);
962 mwifiex_dbg(adapter
, INFO
,
963 "%s: changing role to adhoc\n", dev
->name
);
965 if (mwifiex_deinit_priv_params(priv
))
967 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
969 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
970 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
972 if (mwifiex_sta_init_cmd(priv
, false, false))
975 switch (curr_iftype
) {
976 case NL80211_IFTYPE_P2P_CLIENT
:
977 case NL80211_IFTYPE_P2P_GO
:
978 adapter
->curr_iface_comb
.p2p_intf
--;
980 case NL80211_IFTYPE_AP
:
981 adapter
->curr_iface_comb
.uap_intf
--;
987 adapter
->curr_iface_comb
.sta_intf
++;
988 dev
->ieee80211_ptr
->iftype
= type
;
993 mwifiex_change_vif_to_ap(struct net_device
*dev
,
994 enum nl80211_iftype curr_iftype
,
995 enum nl80211_iftype type
, u32
*flags
,
996 struct vif_params
*params
)
998 struct mwifiex_private
*priv
;
999 struct mwifiex_adapter
*adapter
;
1001 priv
= mwifiex_netdev_get_priv(dev
);
1006 adapter
= priv
->adapter
;
1008 if (adapter
->curr_iface_comb
.uap_intf
==
1009 adapter
->iface_limit
.uap_intf
) {
1010 mwifiex_dbg(adapter
, ERROR
,
1011 "cannot create multiple AP ifaces\n");
1015 mwifiex_dbg(adapter
, INFO
,
1016 "%s: changing role to AP\n", dev
->name
);
1018 if (mwifiex_deinit_priv_params(priv
))
1020 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1022 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1023 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1025 if (mwifiex_sta_init_cmd(priv
, false, false))
1028 switch (curr_iftype
) {
1029 case NL80211_IFTYPE_P2P_CLIENT
:
1030 case NL80211_IFTYPE_P2P_GO
:
1031 adapter
->curr_iface_comb
.p2p_intf
--;
1033 case NL80211_IFTYPE_STATION
:
1034 case NL80211_IFTYPE_ADHOC
:
1035 adapter
->curr_iface_comb
.sta_intf
--;
1041 adapter
->curr_iface_comb
.uap_intf
++;
1042 dev
->ieee80211_ptr
->iftype
= type
;
1046 * CFG802.11 operation handler to change interface type.
1049 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1050 struct net_device
*dev
,
1051 enum nl80211_iftype type
, u32
*flags
,
1052 struct vif_params
*params
)
1054 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1055 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1057 switch (curr_iftype
) {
1058 case NL80211_IFTYPE_ADHOC
:
1060 case NL80211_IFTYPE_STATION
:
1061 priv
->bss_mode
= type
;
1062 priv
->sec_info
.authentication_mode
=
1063 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1064 dev
->ieee80211_ptr
->iftype
= type
;
1065 mwifiex_deauthenticate(priv
, NULL
);
1066 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1067 HostCmd_ACT_GEN_SET
, 0, NULL
,
1069 case NL80211_IFTYPE_P2P_CLIENT
:
1070 case NL80211_IFTYPE_P2P_GO
:
1071 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1072 type
, flags
, params
);
1073 case NL80211_IFTYPE_AP
:
1074 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1076 case NL80211_IFTYPE_UNSPECIFIED
:
1077 mwifiex_dbg(priv
->adapter
, INFO
,
1078 "%s: kept type as IBSS\n", dev
->name
);
1079 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1082 mwifiex_dbg(priv
->adapter
, ERROR
,
1083 "%s: changing to %d not supported\n",
1088 case NL80211_IFTYPE_STATION
:
1090 case NL80211_IFTYPE_ADHOC
:
1091 priv
->bss_mode
= type
;
1092 priv
->sec_info
.authentication_mode
=
1093 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1094 dev
->ieee80211_ptr
->iftype
= type
;
1095 mwifiex_deauthenticate(priv
, NULL
);
1096 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1097 HostCmd_ACT_GEN_SET
, 0, NULL
,
1099 case NL80211_IFTYPE_P2P_CLIENT
:
1100 case NL80211_IFTYPE_P2P_GO
:
1101 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1102 type
, flags
, params
);
1103 case NL80211_IFTYPE_AP
:
1104 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1106 case NL80211_IFTYPE_UNSPECIFIED
:
1107 mwifiex_dbg(priv
->adapter
, INFO
,
1108 "%s: kept type as STA\n", dev
->name
);
1109 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1112 mwifiex_dbg(priv
->adapter
, ERROR
,
1113 "%s: changing to %d not supported\n",
1118 case NL80211_IFTYPE_AP
:
1120 case NL80211_IFTYPE_ADHOC
:
1121 case NL80211_IFTYPE_STATION
:
1122 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1126 case NL80211_IFTYPE_P2P_CLIENT
:
1127 case NL80211_IFTYPE_P2P_GO
:
1128 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1129 type
, flags
, params
);
1130 case NL80211_IFTYPE_UNSPECIFIED
:
1131 mwifiex_dbg(priv
->adapter
, INFO
,
1132 "%s: kept type as AP\n", dev
->name
);
1133 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1136 mwifiex_dbg(priv
->adapter
, ERROR
,
1137 "%s: changing to %d not supported\n",
1142 case NL80211_IFTYPE_P2P_CLIENT
:
1143 case NL80211_IFTYPE_P2P_GO
:
1145 case NL80211_IFTYPE_STATION
:
1146 if (mwifiex_cfg80211_deinit_p2p(priv
))
1148 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1149 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1150 dev
->ieee80211_ptr
->iftype
= type
;
1152 case NL80211_IFTYPE_ADHOC
:
1153 if (mwifiex_cfg80211_deinit_p2p(priv
))
1155 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1159 case NL80211_IFTYPE_AP
:
1160 if (mwifiex_cfg80211_deinit_p2p(priv
))
1162 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1164 case NL80211_IFTYPE_UNSPECIFIED
:
1165 mwifiex_dbg(priv
->adapter
, INFO
,
1166 "%s: kept type as P2P\n", dev
->name
);
1167 case NL80211_IFTYPE_P2P_CLIENT
:
1168 case NL80211_IFTYPE_P2P_GO
:
1171 mwifiex_dbg(priv
->adapter
, ERROR
,
1172 "%s: changing to %d not supported\n",
1178 mwifiex_dbg(priv
->adapter
, ERROR
,
1179 "%s: unknown iftype: %d\n",
1180 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1189 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1190 struct rate_info
*rate
)
1192 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1194 if (adapter
->is_hw_11ac_capable
) {
1195 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1196 if (tx_htinfo
& BIT(0)) {
1198 rate
->mcs
= priv
->tx_rate
;
1199 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1201 if (tx_htinfo
& BIT(1)) {
1203 rate
->mcs
= priv
->tx_rate
& 0x0F;
1204 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1207 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1209 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1211 rate
->bw
= RATE_INFO_BW_20
;
1214 rate
->bw
= RATE_INFO_BW_40
;
1217 rate
->bw
= RATE_INFO_BW_80
;
1219 case (BIT(3) | BIT(2)):
1220 rate
->bw
= RATE_INFO_BW_160
;
1224 if (tx_htinfo
& BIT(4))
1225 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1227 if ((priv
->tx_rate
>> 4) == 1)
1234 * Bit 0 in tx_htinfo indicates that current Tx rate
1235 * is 11n rate. Valid MCS index values for us are 0 to 15.
1237 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1238 rate
->mcs
= priv
->tx_rate
;
1239 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1240 rate
->bw
= RATE_INFO_BW_20
;
1241 if (tx_htinfo
& BIT(1))
1242 rate
->bw
= RATE_INFO_BW_40
;
1243 if (tx_htinfo
& BIT(2))
1244 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1250 * This function dumps the station information on a buffer.
1252 * The following information are shown -
1253 * - Total bytes transmitted
1254 * - Total bytes received
1255 * - Total packets transmitted
1256 * - Total packets received
1257 * - Signal quality level
1258 * - Transmission rate
1261 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1262 struct mwifiex_sta_node
*node
,
1263 struct station_info
*sinfo
)
1267 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1268 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1269 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1270 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1272 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1276 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1277 BIT(NL80211_STA_INFO_TX_FAILED
);
1278 sinfo
->inactive_time
=
1279 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1281 sinfo
->signal
= node
->stats
.rssi
;
1282 sinfo
->signal_avg
= node
->stats
.rssi
;
1283 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1284 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1285 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1286 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1287 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1289 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1291 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1296 /* Get signal information from the firmware */
1297 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1298 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1299 mwifiex_dbg(priv
->adapter
, ERROR
,
1300 "failed to get signal information\n");
1304 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1305 mwifiex_dbg(priv
->adapter
, ERROR
,
1306 "getting data rate error\n");
1310 /* Get DTIM period information from firmware */
1311 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1312 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1313 &priv
->dtim_period
, true);
1315 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1317 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1318 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1319 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1320 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1321 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1322 sinfo
->signal
= priv
->bcn_rssi_avg
;
1323 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1324 sinfo
->txrate
.legacy
= rate
* 5;
1326 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1327 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1328 sinfo
->bss_param
.flags
= 0;
1329 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1330 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1331 sinfo
->bss_param
.flags
|=
1332 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1333 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1334 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1335 sinfo
->bss_param
.flags
|=
1336 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1337 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1338 sinfo
->bss_param
.beacon_interval
=
1339 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1346 * CFG802.11 operation handler to get station information.
1348 * This function only works in connected mode, and dumps the
1349 * requested station information, if available.
1352 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1353 const u8
*mac
, struct station_info
*sinfo
)
1355 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1357 if (!priv
->media_connected
)
1359 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1362 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1366 * CFG802.11 operation handler to dump station information.
1369 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1370 int idx
, u8
*mac
, struct station_info
*sinfo
)
1372 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1373 static struct mwifiex_sta_node
*node
;
1375 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1376 priv
->media_connected
&& idx
== 0) {
1377 ether_addr_copy(mac
, priv
->cfg_bssid
);
1378 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1379 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1380 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1381 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1383 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1388 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1389 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1390 ether_addr_copy(mac
, node
->mac_addr
);
1391 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1399 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1400 int idx
, struct survey_info
*survey
)
1402 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1403 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1404 enum ieee80211_band band
;
1406 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1408 memset(survey
, 0, sizeof(struct survey_info
));
1410 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1411 priv
->media_connected
&& idx
== 0) {
1412 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1413 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1415 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1416 survey
->channel
= ieee80211_get_channel(wiphy
,
1417 ieee80211_channel_to_frequency(chan
, band
));
1419 if (priv
->bcn_nf_last
) {
1420 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1421 survey
->noise
= priv
->bcn_nf_last
;
1426 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1429 if (!pchan_stats
[idx
].cca_scan_dur
)
1432 band
= pchan_stats
[idx
].bandcfg
;
1433 survey
->channel
= ieee80211_get_channel(wiphy
,
1434 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1435 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1437 SURVEY_INFO_TIME_BUSY
;
1438 survey
->noise
= pchan_stats
[idx
].noise
;
1439 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1440 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1445 /* Supported rates to be advertised to the cfg80211 */
1446 static struct ieee80211_rate mwifiex_rates
[] = {
1447 {.bitrate
= 10, .hw_value
= 2, },
1448 {.bitrate
= 20, .hw_value
= 4, },
1449 {.bitrate
= 55, .hw_value
= 11, },
1450 {.bitrate
= 110, .hw_value
= 22, },
1451 {.bitrate
= 60, .hw_value
= 12, },
1452 {.bitrate
= 90, .hw_value
= 18, },
1453 {.bitrate
= 120, .hw_value
= 24, },
1454 {.bitrate
= 180, .hw_value
= 36, },
1455 {.bitrate
= 240, .hw_value
= 48, },
1456 {.bitrate
= 360, .hw_value
= 72, },
1457 {.bitrate
= 480, .hw_value
= 96, },
1458 {.bitrate
= 540, .hw_value
= 108, },
1461 /* Channel definitions to be advertised to cfg80211 */
1462 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1463 {.center_freq
= 2412, .hw_value
= 1, },
1464 {.center_freq
= 2417, .hw_value
= 2, },
1465 {.center_freq
= 2422, .hw_value
= 3, },
1466 {.center_freq
= 2427, .hw_value
= 4, },
1467 {.center_freq
= 2432, .hw_value
= 5, },
1468 {.center_freq
= 2437, .hw_value
= 6, },
1469 {.center_freq
= 2442, .hw_value
= 7, },
1470 {.center_freq
= 2447, .hw_value
= 8, },
1471 {.center_freq
= 2452, .hw_value
= 9, },
1472 {.center_freq
= 2457, .hw_value
= 10, },
1473 {.center_freq
= 2462, .hw_value
= 11, },
1474 {.center_freq
= 2467, .hw_value
= 12, },
1475 {.center_freq
= 2472, .hw_value
= 13, },
1476 {.center_freq
= 2484, .hw_value
= 14, },
1479 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1480 .channels
= mwifiex_channels_2ghz
,
1481 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1482 .bitrates
= mwifiex_rates
,
1483 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1486 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1487 {.center_freq
= 5040, .hw_value
= 8, },
1488 {.center_freq
= 5060, .hw_value
= 12, },
1489 {.center_freq
= 5080, .hw_value
= 16, },
1490 {.center_freq
= 5170, .hw_value
= 34, },
1491 {.center_freq
= 5190, .hw_value
= 38, },
1492 {.center_freq
= 5210, .hw_value
= 42, },
1493 {.center_freq
= 5230, .hw_value
= 46, },
1494 {.center_freq
= 5180, .hw_value
= 36, },
1495 {.center_freq
= 5200, .hw_value
= 40, },
1496 {.center_freq
= 5220, .hw_value
= 44, },
1497 {.center_freq
= 5240, .hw_value
= 48, },
1498 {.center_freq
= 5260, .hw_value
= 52, },
1499 {.center_freq
= 5280, .hw_value
= 56, },
1500 {.center_freq
= 5300, .hw_value
= 60, },
1501 {.center_freq
= 5320, .hw_value
= 64, },
1502 {.center_freq
= 5500, .hw_value
= 100, },
1503 {.center_freq
= 5520, .hw_value
= 104, },
1504 {.center_freq
= 5540, .hw_value
= 108, },
1505 {.center_freq
= 5560, .hw_value
= 112, },
1506 {.center_freq
= 5580, .hw_value
= 116, },
1507 {.center_freq
= 5600, .hw_value
= 120, },
1508 {.center_freq
= 5620, .hw_value
= 124, },
1509 {.center_freq
= 5640, .hw_value
= 128, },
1510 {.center_freq
= 5660, .hw_value
= 132, },
1511 {.center_freq
= 5680, .hw_value
= 136, },
1512 {.center_freq
= 5700, .hw_value
= 140, },
1513 {.center_freq
= 5745, .hw_value
= 149, },
1514 {.center_freq
= 5765, .hw_value
= 153, },
1515 {.center_freq
= 5785, .hw_value
= 157, },
1516 {.center_freq
= 5805, .hw_value
= 161, },
1517 {.center_freq
= 5825, .hw_value
= 165, },
1520 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1521 .channels
= mwifiex_channels_5ghz
,
1522 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1523 .bitrates
= mwifiex_rates
+ 4,
1524 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1528 /* Supported crypto cipher suits to be advertised to cfg80211 */
1529 static const u32 mwifiex_cipher_suites
[] = {
1530 WLAN_CIPHER_SUITE_WEP40
,
1531 WLAN_CIPHER_SUITE_WEP104
,
1532 WLAN_CIPHER_SUITE_TKIP
,
1533 WLAN_CIPHER_SUITE_CCMP
,
1534 WLAN_CIPHER_SUITE_AES_CMAC
,
1537 /* Supported mgmt frame types to be advertised to cfg80211 */
1538 static const struct ieee80211_txrx_stypes
1539 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1540 [NL80211_IFTYPE_STATION
] = {
1541 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1542 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1543 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1544 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1546 [NL80211_IFTYPE_AP
] = {
1547 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1548 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1549 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1550 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1552 [NL80211_IFTYPE_P2P_CLIENT
] = {
1553 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1554 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1555 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1556 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1558 [NL80211_IFTYPE_P2P_GO
] = {
1559 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1560 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1561 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1562 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1567 * CFG802.11 operation handler for setting bit rates.
1569 * Function configures data rates to firmware using bitrate mask
1570 * provided by cfg80211.
1572 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1573 struct net_device
*dev
,
1575 const struct cfg80211_bitrate_mask
*mask
)
1577 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1578 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1579 enum ieee80211_band band
;
1580 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1582 if (!priv
->media_connected
) {
1583 mwifiex_dbg(adapter
, ERROR
,
1584 "Can not set Tx data rate in disconnected state\n");
1588 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1590 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1592 /* Fill HR/DSSS rates. */
1593 if (band
== IEEE80211_BAND_2GHZ
)
1594 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1596 /* Fill OFDM rates */
1597 if (band
== IEEE80211_BAND_2GHZ
)
1598 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1600 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1602 /* Fill HT MCS rates */
1603 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1604 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1605 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1607 /* Fill VHT MCS rates */
1608 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1609 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1610 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1611 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1614 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1615 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1619 * CFG802.11 operation handler for connection quality monitoring.
1621 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1624 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1625 struct net_device
*dev
,
1626 s32 rssi_thold
, u32 rssi_hyst
)
1628 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1629 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1631 priv
->cqm_rssi_thold
= rssi_thold
;
1632 priv
->cqm_rssi_hyst
= rssi_hyst
;
1634 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1635 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1637 /* Subscribe/unsubscribe low and high rssi events */
1638 if (rssi_thold
&& rssi_hyst
) {
1639 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1640 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1641 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1642 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1643 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1644 return mwifiex_send_cmd(priv
,
1645 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1646 0, 0, &subsc_evt
, true);
1648 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1649 return mwifiex_send_cmd(priv
,
1650 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1651 0, 0, &subsc_evt
, true);
1657 /* cfg80211 operation handler for change_beacon.
1658 * Function retrieves and sets modified management IEs to FW.
1660 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1661 struct net_device
*dev
,
1662 struct cfg80211_beacon_data
*data
)
1664 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1666 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1667 mwifiex_dbg(priv
->adapter
, ERROR
,
1668 "%s: bss_type mismatched\n", __func__
);
1672 if (!priv
->bss_started
) {
1673 mwifiex_dbg(priv
->adapter
, ERROR
,
1674 "%s: bss not started\n", __func__
);
1678 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1679 mwifiex_dbg(priv
->adapter
, ERROR
,
1680 "%s: setting mgmt ies failed\n", __func__
);
1687 /* cfg80211 operation handler for del_station.
1688 * Function deauthenticates station which value is provided in mac parameter.
1689 * If mac is NULL/broadcast, all stations in associated station list are
1690 * deauthenticated. If bss is not started or there are no stations in
1691 * associated stations list, no action is taken.
1694 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1695 struct station_del_parameters
*params
)
1697 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1698 struct mwifiex_sta_node
*sta_node
;
1699 u8 deauth_mac
[ETH_ALEN
];
1700 unsigned long flags
;
1702 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1705 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1708 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1709 __func__
, params
->mac
);
1711 eth_zero_addr(deauth_mac
);
1713 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1714 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1716 ether_addr_copy(deauth_mac
, params
->mac
);
1717 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1719 if (is_valid_ether_addr(deauth_mac
)) {
1720 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1721 HostCmd_ACT_GEN_SET
, 0,
1730 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1732 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1733 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1734 MWIFIEX_BSS_ROLE_ANY
);
1735 struct mwifiex_ds_ant_cfg ant_cfg
;
1737 if (!tx_ant
|| !rx_ant
)
1740 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1741 /* Not a MIMO chip. User should provide specific antenna number
1742 * for Tx/Rx path or enable all antennas for diversity
1744 if (tx_ant
!= rx_ant
)
1747 if ((tx_ant
& (tx_ant
- 1)) &&
1748 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1751 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1752 (priv
->adapter
->number_of_antenna
> 1)) {
1753 tx_ant
= RF_ANTENNA_AUTO
;
1754 rx_ant
= RF_ANTENNA_AUTO
;
1757 struct ieee80211_sta_ht_cap
*ht_info
;
1759 enum ieee80211_band band
;
1761 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1762 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1763 if (adapter
->is_hw_11ac_capable
)
1764 adapter
->usr_dot_11ac_mcs_support
=
1765 MWIFIEX_11AC_MCS_MAP_1X1
;
1767 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1768 if (adapter
->is_hw_11ac_capable
)
1769 adapter
->usr_dot_11ac_mcs_support
=
1770 MWIFIEX_11AC_MCS_MAP_2X2
;
1773 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
1774 if (!adapter
->wiphy
->bands
[band
])
1777 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1779 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1780 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1781 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1785 ant_cfg
.tx_ant
= tx_ant
;
1786 ant_cfg
.rx_ant
= rx_ant
;
1788 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1789 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1792 /* cfg80211 operation handler for stop ap.
1793 * Function stops BSS running at uAP interface.
1795 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1797 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1799 mwifiex_abort_cac(priv
);
1801 if (mwifiex_del_mgmt_ies(priv
))
1802 mwifiex_dbg(priv
->adapter
, ERROR
,
1803 "Failed to delete mgmt IEs!\n");
1805 priv
->ap_11n_enabled
= 0;
1806 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1808 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1809 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1810 mwifiex_dbg(priv
->adapter
, ERROR
,
1811 "Failed to stop the BSS\n");
1815 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1816 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1817 mwifiex_dbg(priv
->adapter
, ERROR
,
1818 "Failed to reset BSS\n");
1822 if (netif_carrier_ok(priv
->netdev
))
1823 netif_carrier_off(priv
->netdev
);
1824 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1829 /* cfg80211 operation handler for start_ap.
1830 * Function sets beacon period, DTIM period, SSID and security into
1831 * AP config structure.
1832 * AP is configured with these settings and BSS is started.
1834 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1835 struct net_device
*dev
,
1836 struct cfg80211_ap_settings
*params
)
1838 struct mwifiex_uap_bss_param
*bss_cfg
;
1839 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1841 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1844 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1848 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1850 if (params
->beacon_interval
)
1851 bss_cfg
->beacon_period
= params
->beacon_interval
;
1852 if (params
->dtim_period
)
1853 bss_cfg
->dtim_period
= params
->dtim_period
;
1855 if (params
->ssid
&& params
->ssid_len
) {
1856 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1857 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1859 if (params
->inactivity_timeout
> 0) {
1860 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1861 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1862 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1865 switch (params
->hidden_ssid
) {
1866 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1867 bss_cfg
->bcast_ssid_ctl
= 1;
1869 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1870 bss_cfg
->bcast_ssid_ctl
= 0;
1872 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1873 /* firmware doesn't support this type of hidden SSID */
1879 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1880 mwifiex_set_uap_rates(bss_cfg
, params
);
1882 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1884 mwifiex_dbg(priv
->adapter
, ERROR
,
1885 "Failed to parse secuirty parameters!\n");
1889 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1891 if (priv
->adapter
->is_hw_11ac_capable
) {
1892 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1893 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1894 priv
->ap_11ac_enabled
);
1897 if (priv
->ap_11ac_enabled
)
1898 mwifiex_set_11ac_ba_params(priv
);
1900 mwifiex_set_ba_params(priv
);
1902 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1904 if (mwifiex_is_11h_active(priv
))
1905 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
1907 if (mwifiex_is_11h_active(priv
) &&
1908 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
1910 mwifiex_dbg(priv
->adapter
, INFO
,
1911 "Disable 11h extensions in FW\n");
1912 if (mwifiex_11h_activate(priv
, false)) {
1913 mwifiex_dbg(priv
->adapter
, ERROR
,
1914 "Failed to disable 11h extensions!!");
1917 priv
->state_11h
.is_11h_active
= false;
1920 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
1921 mwifiex_dbg(priv
->adapter
, ERROR
,
1922 "Failed to start AP\n");
1927 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
1930 if (!netif_carrier_ok(priv
->netdev
))
1931 netif_carrier_on(priv
->netdev
);
1932 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
1934 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
1940 * CFG802.11 operation handler for disconnection request.
1942 * This function does not work when there is already a disconnection
1943 * procedure going on.
1946 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
1949 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1951 if (mwifiex_deauthenticate(priv
, NULL
))
1954 mwifiex_dbg(priv
->adapter
, MSG
,
1955 "info: successfully disconnected from %pM:\t"
1956 "reason code %d\n", priv
->cfg_bssid
, reason_code
);
1958 eth_zero_addr(priv
->cfg_bssid
);
1959 priv
->hs2_enabled
= false;
1965 * This function informs the CFG802.11 subsystem of a new IBSS.
1967 * The following information are sent to the CFG802.11 subsystem
1968 * to register the new IBSS. If we do not register the new IBSS,
1969 * a kernel panic will result.
1975 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
1977 struct ieee80211_channel
*chan
;
1978 struct mwifiex_bss_info bss_info
;
1979 struct cfg80211_bss
*bss
;
1981 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
1982 enum ieee80211_band band
;
1984 if (mwifiex_get_bss_info(priv
, &bss_info
))
1987 ie_buf
[0] = WLAN_EID_SSID
;
1988 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
1990 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
1991 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
1992 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
1994 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1995 chan
= __ieee80211_get_channel(priv
->wdev
.wiphy
,
1996 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
1999 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2000 CFG80211_BSS_FTYPE_UNKNOWN
,
2001 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2002 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2004 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2005 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2012 * This function connects with a BSS.
2014 * This function handles both Infra and Ad-Hoc modes. It also performs
2015 * validity checking on the provided parameters, disconnects from the
2016 * current BSS (if any), sets up the association/scan parameters,
2017 * including security settings, and performs specific SSID scan before
2018 * trying to connect.
2020 * For Infra mode, the function returns failure if the specified SSID
2021 * is not found in scan table. However, for Ad-Hoc mode, it can create
2022 * the IBSS if it does not exist. On successful completion in either case,
2023 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2026 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2027 const u8
*ssid
, const u8
*bssid
, int mode
,
2028 struct ieee80211_channel
*channel
,
2029 struct cfg80211_connect_params
*sme
, bool privacy
)
2031 struct cfg80211_ssid req_ssid
;
2032 int ret
, auth_type
= 0;
2033 struct cfg80211_bss
*bss
= NULL
;
2034 u8 is_scanning_required
= 0;
2036 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2038 req_ssid
.ssid_len
= ssid_len
;
2039 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2040 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2044 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2045 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2046 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2050 /* As this is new association, clear locally stored
2051 * keys and security related flags */
2052 priv
->sec_info
.wpa_enabled
= false;
2053 priv
->sec_info
.wpa2_enabled
= false;
2054 priv
->wep_key_curr_index
= 0;
2055 priv
->sec_info
.encryption_mode
= 0;
2056 priv
->sec_info
.is_authtype_auto
= 0;
2057 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2059 if (mode
== NL80211_IFTYPE_ADHOC
) {
2060 /* "privacy" is set only for ad-hoc mode */
2063 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2064 * the firmware can find a matching network from the
2065 * scan. The cfg80211 does not give us the encryption
2066 * mode at this stage so just setting it to WEP here.
2068 priv
->sec_info
.encryption_mode
=
2069 WLAN_CIPHER_SUITE_WEP104
;
2070 priv
->sec_info
.authentication_mode
=
2071 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2077 /* Now handle infra mode. "sme" is valid for infra mode only */
2078 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2079 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2080 priv
->sec_info
.is_authtype_auto
= 1;
2082 auth_type
= sme
->auth_type
;
2085 if (sme
->crypto
.n_ciphers_pairwise
) {
2086 priv
->sec_info
.encryption_mode
=
2087 sme
->crypto
.ciphers_pairwise
[0];
2088 priv
->sec_info
.authentication_mode
= auth_type
;
2091 if (sme
->crypto
.cipher_group
) {
2092 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2093 priv
->sec_info
.authentication_mode
= auth_type
;
2096 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2099 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2100 mwifiex_dbg(priv
->adapter
, INFO
,
2101 "info: setting wep encryption\t"
2102 "with key len %d\n", sme
->key_len
);
2103 priv
->wep_key_curr_index
= sme
->key_idx
;
2104 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2105 sme
->key_len
, sme
->key_idx
,
2111 * Scan entries are valid for some time (15 sec). So we can save one
2112 * active scan time if we just try cfg80211_get_bss first. If it fails
2113 * then request scan and cfg80211_get_bss() again for final output.
2116 if (is_scanning_required
) {
2117 /* Do specific SSID scanning */
2118 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2119 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2124 /* Find the BSS we want using available scan results */
2125 if (mode
== NL80211_IFTYPE_ADHOC
)
2126 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2127 bssid
, ssid
, ssid_len
,
2128 IEEE80211_BSS_TYPE_IBSS
,
2129 IEEE80211_PRIVACY_ANY
);
2131 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2132 bssid
, ssid
, ssid_len
,
2133 IEEE80211_BSS_TYPE_ESS
,
2134 IEEE80211_PRIVACY_ANY
);
2137 if (is_scanning_required
) {
2138 mwifiex_dbg(priv
->adapter
, WARN
,
2139 "assoc: requested bss not found in scan results\n");
2142 is_scanning_required
= 1;
2144 mwifiex_dbg(priv
->adapter
, MSG
,
2145 "info: trying to associate to '%s' bssid %pM\n",
2146 (char *)req_ssid
.ssid
, bss
->bssid
);
2147 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2152 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2156 if (mode
== NL80211_IFTYPE_ADHOC
) {
2157 /* Inform the BSS information to kernel, otherwise
2158 * kernel will give a panic after successful assoc */
2159 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2167 * CFG802.11 operation handler for association request.
2169 * This function does not work when the current mode is set to Ad-Hoc, or
2170 * when there is already an association procedure going on. The given BSS
2171 * information is used to associate.
2174 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2175 struct cfg80211_connect_params
*sme
)
2177 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2178 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2181 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2182 mwifiex_dbg(adapter
, ERROR
,
2183 "%s: reject infra assoc request in non-STA role\n",
2188 if (priv
->wdev
.current_bss
) {
2189 mwifiex_dbg(adapter
, ERROR
,
2190 "%s: already connected\n", dev
->name
);
2194 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2195 mwifiex_dbg(adapter
, ERROR
,
2196 "%s: Ignore connection.\t"
2197 "Card removed or FW in bad state\n",
2202 mwifiex_dbg(adapter
, INFO
,
2203 "info: Trying to associate to %s and bssid %pM\n",
2204 (char *)sme
->ssid
, sme
->bssid
);
2206 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2207 priv
->bss_mode
, sme
->channel
, sme
, 0);
2209 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2210 NULL
, 0, WLAN_STATUS_SUCCESS
,
2212 mwifiex_dbg(priv
->adapter
, MSG
,
2213 "info: associated to bssid %pM successfully\n",
2215 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2216 priv
->adapter
->auto_tdls
&&
2217 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2218 mwifiex_setup_auto_tdls_timer(priv
);
2220 mwifiex_dbg(priv
->adapter
, ERROR
,
2221 "info: association to bssid %pM failed\n",
2223 eth_zero_addr(priv
->cfg_bssid
);
2226 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2227 NULL
, 0, NULL
, 0, ret
,
2230 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2232 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2240 * This function sets following parameters for ibss network.
2244 * - secondary channel offset
2246 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2247 struct cfg80211_ibss_params
*params
)
2249 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2251 u8 config_bands
= 0;
2253 if (params
->chandef
.chan
->band
== IEEE80211_BAND_2GHZ
) {
2254 if (!params
->basic_rates
) {
2255 config_bands
= BAND_B
| BAND_G
;
2257 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2259 * Rates below 6 Mbps in the table are CCK
2260 * rates; 802.11b and from 6 they are OFDM;
2263 if (mwifiex_rates
[i
].bitrate
== 60) {
2269 if (params
->basic_rates
< index
) {
2270 config_bands
= BAND_B
;
2272 config_bands
= BAND_G
;
2273 if (params
->basic_rates
% index
)
2274 config_bands
|= BAND_B
;
2278 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2280 config_bands
|= BAND_G
| BAND_GN
;
2282 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2284 config_bands
= BAND_A
;
2286 config_bands
= BAND_AN
| BAND_A
;
2289 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2290 adapter
->config_bands
= config_bands
;
2291 adapter
->adhoc_start_band
= config_bands
;
2293 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2294 adapter
->adhoc_11n_enabled
= true;
2296 adapter
->adhoc_11n_enabled
= false;
2299 adapter
->sec_chan_offset
=
2300 mwifiex_chan_type_to_sec_chan_offset(
2301 cfg80211_get_chandef_type(¶ms
->chandef
));
2302 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2303 params
->chandef
.chan
->center_freq
);
2305 mwifiex_dbg(adapter
, INFO
,
2306 "info: set ibss band %d, chan %d, chan offset %d\n",
2307 config_bands
, priv
->adhoc_channel
,
2308 adapter
->sec_chan_offset
);
2314 * CFG802.11 operation handler to join an IBSS.
2316 * This function does not work in any mode other than Ad-Hoc, or if
2317 * a join operation is already in progress.
2320 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2321 struct cfg80211_ibss_params
*params
)
2323 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2326 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2327 mwifiex_dbg(priv
->adapter
, ERROR
,
2328 "request to join ibss received\t"
2329 "when station is not in ibss mode\n");
2333 mwifiex_dbg(priv
->adapter
, MSG
,
2334 "info: trying to join to %s and bssid %pM\n",
2335 (char *)params
->ssid
, params
->bssid
);
2337 mwifiex_set_ibss_params(priv
, params
);
2339 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2340 params
->bssid
, priv
->bss_mode
,
2341 params
->chandef
.chan
, NULL
,
2345 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2346 params
->chandef
.chan
, GFP_KERNEL
);
2347 mwifiex_dbg(priv
->adapter
, MSG
,
2348 "info: joined/created adhoc network with bssid\t"
2349 "%pM successfully\n", priv
->cfg_bssid
);
2351 mwifiex_dbg(priv
->adapter
, ERROR
,
2352 "info: failed creating/joining adhoc network\n");
2359 * CFG802.11 operation handler to leave an IBSS.
2361 * This function does not work if a leave operation is
2362 * already in progress.
2365 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2367 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2369 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2371 if (mwifiex_deauthenticate(priv
, NULL
))
2374 eth_zero_addr(priv
->cfg_bssid
);
2380 * CFG802.11 operation handler for scan request.
2382 * This function issues a scan request to the firmware based upon
2383 * the user specified scan configuration. On successful completion,
2384 * it also informs the results.
2387 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2388 struct cfg80211_scan_request
*request
)
2390 struct net_device
*dev
= request
->wdev
->netdev
;
2391 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2393 struct ieee80211_channel
*chan
;
2394 struct ieee_types_header
*ie
;
2395 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2397 mwifiex_dbg(priv
->adapter
, CMD
,
2398 "info: received scan request on %s\n", dev
->name
);
2400 /* Block scan request if scan operation or scan cleanup when interface
2401 * is disabled is in process
2403 if (priv
->scan_request
|| priv
->scan_aborting
) {
2404 mwifiex_dbg(priv
->adapter
, WARN
,
2405 "cmd: Scan already in process..\n");
2409 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2413 priv
->scan_request
= request
;
2415 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2416 user_scan_cfg
->ssid_list
= request
->ssids
;
2418 if (request
->ie
&& request
->ie_len
) {
2420 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2421 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2423 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2424 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2425 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2426 offset
+= sizeof(*ie
) + ie
->len
;
2428 if (offset
>= request
->ie_len
)
2433 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2434 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2435 chan
= request
->channels
[i
];
2436 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2437 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2439 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2440 user_scan_cfg
->chan_list
[i
].scan_type
=
2441 MWIFIEX_SCAN_TYPE_PASSIVE
;
2443 user_scan_cfg
->chan_list
[i
].scan_type
=
2444 MWIFIEX_SCAN_TYPE_ACTIVE
;
2446 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2449 if (priv
->adapter
->scan_chan_gap_enabled
&&
2450 mwifiex_is_any_intf_active(priv
))
2451 user_scan_cfg
->scan_chan_gap
=
2452 priv
->adapter
->scan_chan_gap_time
;
2454 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2455 kfree(user_scan_cfg
);
2457 mwifiex_dbg(priv
->adapter
, ERROR
,
2458 "scan failed: %d\n", ret
);
2459 priv
->scan_aborting
= false;
2460 priv
->scan_request
= NULL
;
2464 if (request
->ie
&& request
->ie_len
) {
2465 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2466 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2467 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2468 memset(&priv
->vs_ie
[i
].ie
, 0,
2469 MWIFIEX_MAX_VSIE_LEN
);
2476 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2477 struct mwifiex_private
*priv
)
2479 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2481 vht_info
->vht_supported
= true;
2483 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2484 /* Update MCS support for VHT */
2485 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2486 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2487 vht_info
->vht_mcs
.rx_highest
= 0;
2488 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2489 adapter
->hw_dot_11ac_mcs_support
>> 16);
2490 vht_info
->vht_mcs
.tx_highest
= 0;
2494 * This function sets up the CFG802.11 specific HT capability fields
2495 * with default values.
2497 * The following default values are set -
2498 * - HT Supported = True
2499 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2500 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2501 * - HT Capabilities supported by firmware
2502 * - MCS information, Rx mask = 0xff
2503 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2506 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2507 struct mwifiex_private
*priv
)
2510 struct ieee80211_mcs_info mcs_set
;
2511 u8
*mcs
= (u8
*)&mcs_set
;
2512 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2514 ht_info
->ht_supported
= true;
2515 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2516 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2518 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2520 /* Fill HT capability information */
2521 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2522 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2524 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2526 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2527 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2529 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2531 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2532 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2534 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2536 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2537 ht_info
->cap
|= 3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2539 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2541 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2542 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2544 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2546 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2547 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2549 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2551 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2552 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2554 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2556 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2557 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2559 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2561 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2562 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2564 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2565 /* Set MCS for 1x1/2x2 */
2566 memset(mcs
, 0xff, rx_mcs_supp
);
2567 /* Clear all the other values */
2568 memset(&mcs
[rx_mcs_supp
], 0,
2569 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2570 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2571 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2572 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2573 SETHT_MCS32(mcs_set
.rx_mask
);
2575 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2577 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2581 * create a new virtual interface with the given name and name assign type
2583 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2585 unsigned char name_assign_type
,
2586 enum nl80211_iftype type
,
2588 struct vif_params
*params
)
2590 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2591 struct mwifiex_private
*priv
;
2592 struct net_device
*dev
;
2596 return ERR_PTR(-EFAULT
);
2599 case NL80211_IFTYPE_UNSPECIFIED
:
2600 case NL80211_IFTYPE_STATION
:
2601 case NL80211_IFTYPE_ADHOC
:
2602 if (adapter
->curr_iface_comb
.sta_intf
==
2603 adapter
->iface_limit
.sta_intf
) {
2604 mwifiex_dbg(adapter
, ERROR
,
2605 "cannot create multiple sta/adhoc ifaces\n");
2606 return ERR_PTR(-EINVAL
);
2609 priv
= mwifiex_get_unused_priv(adapter
);
2611 mwifiex_dbg(adapter
, ERROR
,
2612 "could not get free private struct\n");
2613 return ERR_PTR(-EFAULT
);
2616 priv
->wdev
.wiphy
= wiphy
;
2617 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2619 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2620 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2622 priv
->bss_mode
= type
;
2624 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2625 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2626 priv
->bss_priority
= 0;
2627 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2628 priv
->bss_num
= adapter
->curr_iface_comb
.sta_intf
;
2631 case NL80211_IFTYPE_AP
:
2632 if (adapter
->curr_iface_comb
.uap_intf
==
2633 adapter
->iface_limit
.uap_intf
) {
2634 mwifiex_dbg(adapter
, ERROR
,
2635 "cannot create multiple AP ifaces\n");
2636 return ERR_PTR(-EINVAL
);
2639 priv
= mwifiex_get_unused_priv(adapter
);
2641 mwifiex_dbg(adapter
, ERROR
,
2642 "could not get free private struct\n");
2643 return ERR_PTR(-EFAULT
);
2646 priv
->wdev
.wiphy
= wiphy
;
2647 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2649 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2650 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2651 priv
->bss_priority
= 0;
2652 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2653 priv
->bss_started
= 0;
2654 priv
->bss_num
= adapter
->curr_iface_comb
.uap_intf
;
2655 priv
->bss_mode
= type
;
2658 case NL80211_IFTYPE_P2P_CLIENT
:
2659 if (adapter
->curr_iface_comb
.p2p_intf
==
2660 adapter
->iface_limit
.p2p_intf
) {
2661 mwifiex_dbg(adapter
, ERROR
,
2662 "cannot create multiple P2P ifaces\n");
2663 return ERR_PTR(-EINVAL
);
2666 priv
= mwifiex_get_unused_priv(adapter
);
2668 mwifiex_dbg(adapter
, ERROR
,
2669 "could not get free private struct\n");
2670 return ERR_PTR(-EFAULT
);
2673 priv
->wdev
.wiphy
= wiphy
;
2674 /* At start-up, wpa_supplicant tries to change the interface
2675 * to NL80211_IFTYPE_STATION if it is not managed mode.
2677 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2678 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2680 /* Setting bss_type to P2P tells firmware that this interface
2681 * is receiving P2P peers found during find phase and doing
2682 * action frame handshake.
2684 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2686 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2687 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2688 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2689 priv
->bss_started
= 0;
2690 priv
->bss_num
= adapter
->curr_iface_comb
.p2p_intf
;
2692 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2693 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2694 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2695 return ERR_PTR(-EFAULT
);
2700 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2701 return ERR_PTR(-EINVAL
);
2704 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2705 name_assign_type
, ether_setup
,
2706 IEEE80211_NUM_ACS
, 1);
2708 mwifiex_dbg(adapter
, ERROR
,
2709 "no memory available for netdevice\n");
2710 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2711 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2712 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2713 return ERR_PTR(-ENOMEM
);
2716 mwifiex_init_priv_params(priv
, dev
);
2719 mwifiex_setup_ht_caps(&wiphy
->bands
[IEEE80211_BAND_2GHZ
]->ht_cap
, priv
);
2720 if (adapter
->is_hw_11ac_capable
)
2721 mwifiex_setup_vht_caps(
2722 &wiphy
->bands
[IEEE80211_BAND_2GHZ
]->vht_cap
, priv
);
2724 if (adapter
->config_bands
& BAND_A
)
2725 mwifiex_setup_ht_caps(
2726 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->ht_cap
, priv
);
2728 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2729 mwifiex_setup_vht_caps(
2730 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->vht_cap
, priv
);
2732 dev_net_set(dev
, wiphy_net(wiphy
));
2733 dev
->ieee80211_ptr
= &priv
->wdev
;
2734 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2735 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2736 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2738 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2739 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2740 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2741 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
2743 mdev_priv
= netdev_priv(dev
);
2744 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
2746 SET_NETDEV_DEV(dev
, adapter
->dev
);
2748 /* Register network device */
2749 if (register_netdevice(dev
)) {
2750 mwifiex_dbg(adapter
, ERROR
,
2751 "cannot register virtual network device\n");
2753 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2754 priv
->netdev
= NULL
;
2755 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2756 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2757 return ERR_PTR(-EFAULT
);
2760 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
2763 WQ_UNBOUND
, 1, name
);
2764 if (!priv
->dfs_cac_workqueue
) {
2765 mwifiex_dbg(adapter
, ERROR
,
2766 "cannot register virtual network device\n");
2768 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2769 priv
->netdev
= NULL
;
2770 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2771 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2772 return ERR_PTR(-ENOMEM
);
2775 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
2777 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
2778 WQ_HIGHPRI
| WQ_UNBOUND
|
2779 WQ_MEM_RECLAIM
, 1, name
);
2780 if (!priv
->dfs_chan_sw_workqueue
) {
2781 mwifiex_dbg(adapter
, ERROR
,
2782 "cannot register virtual network device\n");
2784 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2785 priv
->netdev
= NULL
;
2786 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2787 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2788 return ERR_PTR(-ENOMEM
);
2791 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
2792 mwifiex_dfs_chan_sw_work_queue
);
2794 sema_init(&priv
->async_sem
, 1);
2796 mwifiex_dbg(adapter
, INFO
,
2797 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
2799 #ifdef CONFIG_DEBUG_FS
2800 mwifiex_dev_debugfs_init(priv
);
2804 case NL80211_IFTYPE_UNSPECIFIED
:
2805 case NL80211_IFTYPE_STATION
:
2806 case NL80211_IFTYPE_ADHOC
:
2807 adapter
->curr_iface_comb
.sta_intf
++;
2809 case NL80211_IFTYPE_AP
:
2810 adapter
->curr_iface_comb
.uap_intf
++;
2812 case NL80211_IFTYPE_P2P_CLIENT
:
2813 adapter
->curr_iface_comb
.p2p_intf
++;
2816 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2817 return ERR_PTR(-EINVAL
);
2822 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
2825 * del_virtual_intf: remove the virtual interface determined by dev
2827 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
2829 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
2830 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2831 struct sk_buff
*skb
, *tmp
;
2833 #ifdef CONFIG_DEBUG_FS
2834 mwifiex_dev_debugfs_remove(priv
);
2837 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
2839 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
)
2840 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
2842 if (netif_carrier_ok(priv
->netdev
))
2843 netif_carrier_off(priv
->netdev
);
2845 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
2846 unregister_netdevice(wdev
->netdev
);
2848 if (priv
->dfs_cac_workqueue
) {
2849 flush_workqueue(priv
->dfs_cac_workqueue
);
2850 destroy_workqueue(priv
->dfs_cac_workqueue
);
2851 priv
->dfs_cac_workqueue
= NULL
;
2854 if (priv
->dfs_chan_sw_workqueue
) {
2855 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
2856 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
2857 priv
->dfs_chan_sw_workqueue
= NULL
;
2859 /* Clear the priv in adapter */
2860 priv
->netdev
->ieee80211_ptr
= NULL
;
2861 priv
->netdev
= NULL
;
2862 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2864 priv
->media_connected
= false;
2866 switch (priv
->bss_mode
) {
2867 case NL80211_IFTYPE_UNSPECIFIED
:
2868 case NL80211_IFTYPE_STATION
:
2869 case NL80211_IFTYPE_ADHOC
:
2870 adapter
->curr_iface_comb
.sta_intf
--;
2872 case NL80211_IFTYPE_AP
:
2873 adapter
->curr_iface_comb
.uap_intf
--;
2875 case NL80211_IFTYPE_P2P_CLIENT
:
2876 case NL80211_IFTYPE_P2P_GO
:
2877 adapter
->curr_iface_comb
.p2p_intf
--;
2880 mwifiex_dbg(adapter
, ERROR
,
2881 "del_virtual_intf: type not supported\n");
2885 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2887 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
2888 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
2889 kfree(priv
->hist_data
);
2893 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
2896 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
2899 int j
, k
, valid_byte_cnt
= 0;
2900 bool dont_care_byte
= false;
2902 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
2903 for (k
= 0; k
< 8; k
++) {
2904 if (pat
->mask
[j
] & 1 << k
) {
2905 memcpy(byte_seq
+ valid_byte_cnt
,
2906 &pat
->pattern
[j
* 8 + k
], 1);
2912 dont_care_byte
= true;
2915 if (valid_byte_cnt
> max_byte_seq
)
2920 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
2926 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
2927 struct mwifiex_mef_entry
*mef_entry
)
2929 int i
, filt_num
= 0, num_ipv4
= 0;
2930 struct in_device
*in_dev
;
2931 struct in_ifaddr
*ifa
;
2932 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
2933 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2935 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2936 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
2938 /* Enable ARP offload feature */
2939 memset(ips
, 0, sizeof(ips
));
2940 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
2941 if (adapter
->priv
[i
]->netdev
) {
2942 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
2945 ifa
= in_dev
->ifa_list
;
2946 if (!ifa
|| !ifa
->ifa_local
)
2948 ips
[i
] = ifa
->ifa_local
;
2953 for (i
= 0; i
< num_ipv4
; i
++) {
2956 mef_entry
->filter
[filt_num
].repeat
= 1;
2957 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
2958 (u8
*)&ips
[i
], sizeof(ips
[i
]));
2959 mef_entry
->filter
[filt_num
].
2960 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
2962 mef_entry
->filter
[filt_num
].offset
= 46;
2963 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2965 mef_entry
->filter
[filt_num
].filt_action
=
2971 mef_entry
->filter
[filt_num
].repeat
= 1;
2972 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
2973 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
2974 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
2975 mef_entry
->filter
[filt_num
].offset
= 20;
2976 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2977 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
2980 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
2981 struct mwifiex_ds_mef_cfg
*mef_cfg
,
2982 struct mwifiex_mef_entry
*mef_entry
,
2983 struct cfg80211_wowlan
*wowlan
)
2985 int i
, filt_num
= 0, ret
= 0;
2986 bool first_pat
= true;
2987 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
2988 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
2989 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
2991 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2992 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
2994 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
2995 memset(byte_seq
, 0, sizeof(byte_seq
));
2996 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
2998 MWIFIEX_MEF_MAX_BYTESEQ
)) {
2999 mwifiex_dbg(priv
->adapter
, ERROR
,
3000 "Pattern not supported\n");
3004 if (!wowlan
->patterns
[i
].pkt_offset
) {
3005 if (!(byte_seq
[0] & 0x01) &&
3006 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3007 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3009 } else if (is_broadcast_ether_addr(byte_seq
)) {
3010 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3012 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3013 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3014 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3015 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3016 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3020 mef_entry
->filter
[filt_num
].repeat
= 1;
3021 mef_entry
->filter
[filt_num
].offset
=
3022 wowlan
->patterns
[i
].pkt_offset
;
3023 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3025 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3030 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3035 if (wowlan
->magic_pkt
) {
3036 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3037 mef_entry
->filter
[filt_num
].repeat
= 16;
3038 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3040 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3042 mef_entry
->filter
[filt_num
].offset
= 28;
3043 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3045 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3048 mef_entry
->filter
[filt_num
].repeat
= 16;
3049 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3051 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3053 mef_entry
->filter
[filt_num
].offset
= 56;
3054 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3055 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3060 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3061 struct cfg80211_wowlan
*wowlan
)
3063 int ret
= 0, num_entries
= 1;
3064 struct mwifiex_ds_mef_cfg mef_cfg
;
3065 struct mwifiex_mef_entry
*mef_entry
;
3067 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3070 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3074 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3075 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3076 MWIFIEX_CRITERIA_UNICAST
;
3077 mef_cfg
.num_entries
= num_entries
;
3078 mef_cfg
.mef_entry
= mef_entry
;
3080 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3082 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3083 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3084 &mef_entry
[1], wowlan
);
3089 if (!mef_cfg
.criteria
)
3090 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3091 MWIFIEX_CRITERIA_UNICAST
|
3092 MWIFIEX_CRITERIA_MULTICAST
;
3094 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3095 HostCmd_ACT_GEN_SET
, 0,
3103 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3104 struct cfg80211_wowlan
*wowlan
)
3106 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3107 struct mwifiex_ds_hs_cfg hs_cfg
;
3109 struct mwifiex_private
*priv
;
3111 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3112 priv
= adapter
->priv
[i
];
3113 mwifiex_abort_cac(priv
);
3116 mwifiex_cancel_all_pending_cmd(adapter
);
3119 mwifiex_dbg(adapter
, ERROR
,
3120 "None of the WOWLAN triggers enabled\n");
3124 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3126 if (!priv
->media_connected
) {
3127 mwifiex_dbg(adapter
, ERROR
,
3128 "Can not configure WOWLAN in disconnected state\n");
3132 ret
= mwifiex_set_mef_filter(priv
, wowlan
);
3134 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3138 if (wowlan
->disconnect
) {
3139 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3140 hs_cfg
.is_invoke_hostcmd
= false;
3141 hs_cfg
.conditions
= HS_CFG_COND_MAC_EVENT
;
3142 hs_cfg
.gpio
= HS_CFG_GPIO_DEF
;
3143 hs_cfg
.gap
= HS_CFG_GAP_DEF
;
3144 ret
= mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
3145 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3147 mwifiex_dbg(adapter
, ERROR
,
3148 "Failed to set HS params\n");
3156 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3161 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3164 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3166 device_set_wakeup_enable(adapter
->dev
, enabled
);
3170 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3172 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3173 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3174 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3176 if ((byte_seq
[0] & 0x01) &&
3177 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3178 return PACKET_TYPE_UNICAST
;
3179 else if (!memcmp(byte_seq
, bc_mac
, 4))
3180 return PACKET_TYPE_BROADCAST
;
3181 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3182 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3183 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3184 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3185 return PACKET_TYPE_MULTICAST
;
3191 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3192 struct cfg80211_coalesce_rules
*crule
,
3193 struct mwifiex_coalesce_rule
*mrule
)
3195 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3196 struct filt_field_param
*param
;
3199 mrule
->max_coalescing_delay
= crule
->delay
;
3201 param
= mrule
->params
;
3203 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3204 memset(byte_seq
, 0, sizeof(byte_seq
));
3205 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3207 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3208 mwifiex_dbg(priv
->adapter
, ERROR
,
3209 "Pattern not supported\n");
3213 if (!crule
->patterns
[i
].pkt_offset
) {
3216 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3217 if (pkt_type
&& mrule
->pkt_type
) {
3218 mwifiex_dbg(priv
->adapter
, ERROR
,
3219 "Multiple packet types not allowed\n");
3221 } else if (pkt_type
) {
3222 mrule
->pkt_type
= pkt_type
;
3227 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3228 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3230 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3232 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3233 memcpy(param
->operand_byte_stream
, byte_seq
,
3234 param
->operand_len
);
3235 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3238 mrule
->num_of_fields
++;
3241 if (!mrule
->pkt_type
) {
3242 mwifiex_dbg(priv
->adapter
, ERROR
,
3243 "Packet type can not be determined\n");
3250 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3251 struct cfg80211_coalesce
*coalesce
)
3253 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3255 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3256 struct mwifiex_private
*priv
=
3257 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3259 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3261 mwifiex_dbg(adapter
, WARN
,
3262 "Disable coalesce and reset all previous rules\n");
3263 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3264 HostCmd_ACT_GEN_SET
, 0,
3265 &coalesce_cfg
, true);
3268 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3269 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3270 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3271 &coalesce_cfg
.rule
[i
]);
3273 mwifiex_dbg(adapter
, ERROR
,
3274 "Recheck the patterns provided for rule %d\n",
3280 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3281 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3284 /* cfg80211 ops handler for tdls_mgmt.
3285 * Function prepares TDLS action frame packets and forwards them to FW
3288 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3289 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3290 u16 status_code
, u32 peer_capability
,
3291 bool initiator
, const u8
*extra_ies
,
3292 size_t extra_ies_len
)
3294 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3297 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3300 /* make sure we are in station mode and connected */
3301 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3304 switch (action_code
) {
3305 case WLAN_TDLS_SETUP_REQUEST
:
3306 mwifiex_dbg(priv
->adapter
, MSG
,
3307 "Send TDLS Setup Request to %pM status_code=%d\n",
3309 mwifiex_add_auto_tdls_peer(priv
, peer
);
3310 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3311 dialog_token
, status_code
,
3312 extra_ies
, extra_ies_len
);
3314 case WLAN_TDLS_SETUP_RESPONSE
:
3315 mwifiex_add_auto_tdls_peer(priv
, peer
);
3316 mwifiex_dbg(priv
->adapter
, MSG
,
3317 "Send TDLS Setup Response to %pM status_code=%d\n",
3319 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3320 dialog_token
, status_code
,
3321 extra_ies
, extra_ies_len
);
3323 case WLAN_TDLS_SETUP_CONFIRM
:
3324 mwifiex_dbg(priv
->adapter
, MSG
,
3325 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3327 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3328 dialog_token
, status_code
,
3329 extra_ies
, extra_ies_len
);
3331 case WLAN_TDLS_TEARDOWN
:
3332 mwifiex_dbg(priv
->adapter
, MSG
,
3333 "Send TDLS Tear down to %pM\n", peer
);
3334 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3335 dialog_token
, status_code
,
3336 extra_ies
, extra_ies_len
);
3338 case WLAN_TDLS_DISCOVERY_REQUEST
:
3339 mwifiex_dbg(priv
->adapter
, MSG
,
3340 "Send TDLS Discovery Request to %pM\n", peer
);
3341 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3342 dialog_token
, status_code
,
3343 extra_ies
, extra_ies_len
);
3345 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3346 mwifiex_dbg(priv
->adapter
, MSG
,
3347 "Send TDLS Discovery Response to %pM\n", peer
);
3348 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3349 dialog_token
, status_code
,
3350 extra_ies
, extra_ies_len
);
3353 mwifiex_dbg(priv
->adapter
, ERROR
,
3354 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3363 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3364 const u8
*peer
, enum nl80211_tdls_operation action
)
3366 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3368 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3369 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3372 /* make sure we are in station mode and connected */
3373 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3376 mwifiex_dbg(priv
->adapter
, MSG
,
3377 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3380 case NL80211_TDLS_ENABLE_LINK
:
3381 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3383 case NL80211_TDLS_DISABLE_LINK
:
3384 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3386 case NL80211_TDLS_TEARDOWN
:
3387 /* shouldn't happen!*/
3388 mwifiex_dbg(priv
->adapter
, ERROR
,
3389 "tdls_oper: teardown from driver not supported\n");
3391 case NL80211_TDLS_SETUP
:
3392 /* shouldn't happen!*/
3393 mwifiex_dbg(priv
->adapter
, ERROR
,
3394 "tdls_oper: setup from driver not supported\n");
3396 case NL80211_TDLS_DISCOVERY_REQ
:
3397 /* shouldn't happen!*/
3398 mwifiex_dbg(priv
->adapter
, ERROR
,
3399 "tdls_oper: discovery from driver not supported\n");
3402 mwifiex_dbg(priv
->adapter
, ERROR
,
3403 "tdls_oper: operation not supported\n");
3407 return mwifiex_tdls_oper(priv
, peer
, action
);
3411 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3412 const u8
*addr
, u8 oper_class
,
3413 struct cfg80211_chan_def
*chandef
)
3415 struct mwifiex_sta_node
*sta_ptr
;
3416 unsigned long flags
;
3418 u8 second_chan_offset
, band
;
3419 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3421 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3422 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3423 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3426 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3431 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3432 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3433 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3437 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3438 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3439 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3443 chan
= chandef
->chan
->hw_value
;
3444 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3445 band
= chandef
->chan
->band
;
3446 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3452 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3453 struct net_device
*dev
,
3456 struct mwifiex_sta_node
*sta_ptr
;
3457 unsigned long flags
;
3458 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3460 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3461 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3462 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3465 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3467 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3468 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3469 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3470 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3473 mwifiex_stop_tdls_cs(priv
, addr
);
3477 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3478 const u8
*mac
, struct station_parameters
*params
)
3480 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3482 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3485 /* make sure we are in station mode and connected */
3486 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3489 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3493 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3494 struct cfg80211_csa_settings
*params
)
3496 struct ieee_types_header
*chsw_ie
;
3497 struct ieee80211_channel_sw_ie
*channel_sw
;
3499 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3501 if (priv
->adapter
->scan_processing
) {
3502 mwifiex_dbg(priv
->adapter
, ERROR
,
3503 "radar detection: scan in process...\n");
3507 if (priv
->wdev
.cac_started
)
3510 if (cfg80211_chandef_identical(¶ms
->chandef
,
3511 &priv
->dfs_chandef
))
3514 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3515 params
->beacon_csa
.tail
,
3516 params
->beacon_csa
.tail_len
);
3518 mwifiex_dbg(priv
->adapter
, ERROR
,
3519 "Could not parse channel switch announcement IE\n");
3523 channel_sw
= (void *)(chsw_ie
+ 1);
3524 if (channel_sw
->mode
) {
3525 if (netif_carrier_ok(priv
->netdev
))
3526 netif_carrier_off(priv
->netdev
);
3527 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3530 if (mwifiex_del_mgmt_ies(priv
))
3531 mwifiex_dbg(priv
->adapter
, ERROR
,
3532 "Failed to delete mgmt IEs!\n");
3534 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3535 mwifiex_dbg(priv
->adapter
, ERROR
,
3536 "%s: setting mgmt ies failed\n", __func__
);
3540 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3541 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3542 sizeof(priv
->beacon_after
));
3544 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3545 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3546 msecs_to_jiffies(chsw_msec
));
3550 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3551 struct wireless_dev
*wdev
,
3552 struct cfg80211_chan_def
*chandef
)
3554 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3555 struct mwifiex_bssdescriptor
*curr_bss
;
3556 struct ieee80211_channel
*chan
;
3557 u8 second_chan_offset
;
3558 enum nl80211_channel_type chan_type
;
3559 enum ieee80211_band band
;
3563 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3564 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3565 *chandef
= priv
->bss_chandef
;
3567 } else if (priv
->media_connected
) {
3568 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3569 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3570 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3571 chan
= ieee80211_get_channel(wiphy
, freq
);
3573 if (curr_bss
->bcn_ht_oper
) {
3574 second_chan_offset
= curr_bss
->bcn_ht_oper
->ht_param
&
3575 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3576 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3577 (second_chan_offset
);
3578 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3580 cfg80211_chandef_create(chandef
, chan
,
3581 NL80211_CHAN_NO_HT
);
3590 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
3591 struct net_device
*dev
,
3592 struct cfg80211_chan_def
*chandef
,
3595 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3596 struct mwifiex_radar_params radar_params
;
3598 if (priv
->adapter
->scan_processing
) {
3599 mwifiex_dbg(priv
->adapter
, ERROR
,
3600 "radar detection: scan already in process...\n");
3604 if (!mwifiex_is_11h_active(priv
)) {
3605 mwifiex_dbg(priv
->adapter
, INFO
,
3606 "Enable 11h extensions in FW\n");
3607 if (mwifiex_11h_activate(priv
, true)) {
3608 mwifiex_dbg(priv
->adapter
, ERROR
,
3609 "Failed to activate 11h extensions!!");
3612 priv
->state_11h
.is_11h_active
= true;
3615 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
3616 radar_params
.chandef
= chandef
;
3617 radar_params
.cac_time_ms
= cac_time_ms
;
3619 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
3621 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
3622 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
3625 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
3626 msecs_to_jiffies(cac_time_ms
));
3631 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3633 struct station_parameters
*params
)
3636 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3638 /* we support change_station handler only for TDLS peers*/
3639 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3642 /* make sure we are in station mode and connected */
3643 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3646 priv
->sta_params
= params
;
3648 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
3649 priv
->sta_params
= NULL
;
3654 /* station cfg80211 operations */
3655 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
3656 .add_virtual_intf
= mwifiex_add_virtual_intf
,
3657 .del_virtual_intf
= mwifiex_del_virtual_intf
,
3658 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
3659 .scan
= mwifiex_cfg80211_scan
,
3660 .connect
= mwifiex_cfg80211_connect
,
3661 .disconnect
= mwifiex_cfg80211_disconnect
,
3662 .get_station
= mwifiex_cfg80211_get_station
,
3663 .dump_station
= mwifiex_cfg80211_dump_station
,
3664 .dump_survey
= mwifiex_cfg80211_dump_survey
,
3665 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
3666 .join_ibss
= mwifiex_cfg80211_join_ibss
,
3667 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
3668 .add_key
= mwifiex_cfg80211_add_key
,
3669 .del_key
= mwifiex_cfg80211_del_key
,
3670 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
3671 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
3672 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
3673 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
3674 .set_default_key
= mwifiex_cfg80211_set_default_key
,
3675 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
3676 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
3677 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
3678 .start_ap
= mwifiex_cfg80211_start_ap
,
3679 .stop_ap
= mwifiex_cfg80211_stop_ap
,
3680 .change_beacon
= mwifiex_cfg80211_change_beacon
,
3681 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
3682 .set_antenna
= mwifiex_cfg80211_set_antenna
,
3683 .del_station
= mwifiex_cfg80211_del_station
,
3685 .suspend
= mwifiex_cfg80211_suspend
,
3686 .resume
= mwifiex_cfg80211_resume
,
3687 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
3689 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
3690 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
3691 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
3692 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
3693 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
3694 .add_station
= mwifiex_cfg80211_add_station
,
3695 .change_station
= mwifiex_cfg80211_change_station
,
3696 .get_channel
= mwifiex_cfg80211_get_channel
,
3697 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
3698 .channel_switch
= mwifiex_cfg80211_channel_switch
,
3702 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
3703 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
,
3704 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
3705 .pattern_min_len
= 1,
3706 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3707 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3711 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
3713 if (!alpha2
|| strlen(alpha2
) != 2)
3716 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
3722 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
3723 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
3724 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
3725 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
3726 .pattern_min_len
= 1,
3727 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3728 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3731 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
3733 u32 n_channels_bg
, n_channels_a
= 0;
3735 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
3737 if (adapter
->config_bands
& BAND_A
)
3738 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
3740 adapter
->num_in_chan_stats
= max_t(u32
, n_channels_bg
, n_channels_a
);
3741 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
3742 adapter
->num_in_chan_stats
);
3744 if (!adapter
->chan_stats
)
3751 * This function registers the device with CFG802.11 subsystem.
3753 * The function creates the wireless device/wiphy, populates it with
3754 * default parameters and handler function pointers, and finally
3755 * registers the device.
3758 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
3762 struct wiphy
*wiphy
;
3763 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
3767 /* create a new wiphy for use with cfg80211 */
3768 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
3769 sizeof(struct mwifiex_adapter
*));
3771 mwifiex_dbg(adapter
, ERROR
,
3772 "%s: creating new wiphy\n", __func__
);
3775 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
3776 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
3777 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
3778 wiphy
->max_remain_on_channel_duration
= 5000;
3779 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
3780 BIT(NL80211_IFTYPE_ADHOC
) |
3781 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
3782 BIT(NL80211_IFTYPE_P2P_GO
) |
3783 BIT(NL80211_IFTYPE_AP
);
3785 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
3786 if (adapter
->config_bands
& BAND_A
)
3787 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
3789 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = NULL
;
3791 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
3792 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
3793 else if (adapter
->is_hw_11ac_capable
)
3794 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
3796 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
3797 wiphy
->n_iface_combinations
= 1;
3799 /* Initialize cipher suits */
3800 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
3801 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
3803 if (adapter
->region_code
)
3804 wiphy
->regulatory_flags
|= REGULATORY_DISABLE_BEACON_HINTS
|
3805 REGULATORY_COUNTRY_IE_IGNORE
;
3807 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
3808 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3809 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
3810 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
3811 WIPHY_FLAG_AP_UAPSD
|
3812 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
3813 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
3814 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
3816 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3817 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
3818 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
3821 wiphy
->wowlan
= &mwifiex_wowlan_support
;
3824 wiphy
->coalesce
= &mwifiex_coalesce_support
;
3826 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
3827 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
3828 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
3830 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
3831 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
3833 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
3834 NL80211_FEATURE_INACTIVITY_TIMER
|
3835 NL80211_FEATURE_NEED_OBSS_SCAN
;
3837 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3838 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
3840 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
3841 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
3843 /* Reserve space for mwifiex specific private data for BSS */
3844 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
3846 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
3848 /* Set struct mwifiex_adapter pointer in wiphy_priv */
3849 wdev_priv
= wiphy_priv(wiphy
);
3850 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
3852 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
3854 ret
= wiphy_register(wiphy
);
3856 mwifiex_dbg(adapter
, ERROR
,
3857 "%s: wiphy_register failed: %d\n", __func__
, ret
);
3862 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
3863 mwifiex_dbg(adapter
, INFO
,
3864 "driver hint alpha2: %2.2s\n", reg_alpha2
);
3865 regulatory_hint(wiphy
, reg_alpha2
);
3867 if (adapter
->region_code
== 0x00) {
3868 mwifiex_dbg(adapter
, WARN
, "Ignore world regulatory domain\n");
3871 mwifiex_11d_code_2_region(adapter
->region_code
);
3873 regulatory_hint(wiphy
, country_code
))
3874 mwifiex_dbg(priv
->adapter
, ERROR
, "regulatory_hint() failed\n");
3878 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3879 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
3880 wiphy
->frag_threshold
= thr
;
3881 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3882 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
3883 wiphy
->rts_threshold
= thr
;
3884 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3885 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
3886 wiphy
->retry_short
= (u8
) retry
;
3887 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3888 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
3889 wiphy
->retry_long
= (u8
) retry
;
3891 adapter
->wiphy
= wiphy
;