2 * Marvell Wireless LAN device driver: CFG80211
4 * Copyright (C) 2011-2014, Marvell International Ltd.
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
24 static char *reg_alpha2
;
25 module_param(reg_alpha2
, charp
, 0);
27 static const struct ieee80211_iface_limit mwifiex_ap_sta_limits
[] = {
29 .max
= 2, .types
= BIT(NL80211_IFTYPE_STATION
) |
30 BIT(NL80211_IFTYPE_P2P_GO
) |
31 BIT(NL80211_IFTYPE_P2P_CLIENT
),
34 .max
= 1, .types
= BIT(NL80211_IFTYPE_AP
),
38 static const struct ieee80211_iface_combination
39 mwifiex_iface_comb_ap_sta
= {
40 .limits
= mwifiex_ap_sta_limits
,
41 .num_different_channels
= 1,
42 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
43 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
44 .beacon_int_infra_match
= true,
45 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
46 BIT(NL80211_CHAN_WIDTH_20
) |
47 BIT(NL80211_CHAN_WIDTH_40
),
50 static const struct ieee80211_iface_combination
51 mwifiex_iface_comb_ap_sta_vht
= {
52 .limits
= mwifiex_ap_sta_limits
,
53 .num_different_channels
= 1,
54 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
55 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
56 .beacon_int_infra_match
= true,
57 .radar_detect_widths
= BIT(NL80211_CHAN_WIDTH_20_NOHT
) |
58 BIT(NL80211_CHAN_WIDTH_20
) |
59 BIT(NL80211_CHAN_WIDTH_40
) |
60 BIT(NL80211_CHAN_WIDTH_80
),
64 ieee80211_iface_combination mwifiex_iface_comb_ap_sta_drcs
= {
65 .limits
= mwifiex_ap_sta_limits
,
66 .num_different_channels
= 2,
67 .n_limits
= ARRAY_SIZE(mwifiex_ap_sta_limits
),
68 .max_interfaces
= MWIFIEX_MAX_BSS_NUM
,
69 .beacon_int_infra_match
= true,
73 * This function maps the nl802.11 channel type into driver channel type.
75 * The mapping is as follows -
76 * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE
77 * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE
78 * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE
79 * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW
80 * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE
82 u8
mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type
)
85 case NL80211_CHAN_NO_HT
:
86 case NL80211_CHAN_HT20
:
87 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
88 case NL80211_CHAN_HT40PLUS
:
89 return IEEE80211_HT_PARAM_CHA_SEC_ABOVE
;
90 case NL80211_CHAN_HT40MINUS
:
91 return IEEE80211_HT_PARAM_CHA_SEC_BELOW
;
93 return IEEE80211_HT_PARAM_CHA_SEC_NONE
;
97 /* This function maps IEEE HT secondary channel type to NL80211 channel type
99 u8
mwifiex_sec_chan_offset_to_chan_type(u8 second_chan_offset
)
101 switch (second_chan_offset
) {
102 case IEEE80211_HT_PARAM_CHA_SEC_NONE
:
103 return NL80211_CHAN_HT20
;
104 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE
:
105 return NL80211_CHAN_HT40PLUS
;
106 case IEEE80211_HT_PARAM_CHA_SEC_BELOW
:
107 return NL80211_CHAN_HT40MINUS
;
109 return NL80211_CHAN_HT20
;
114 * This function checks whether WEP is set.
117 mwifiex_is_alg_wep(u32 cipher
)
120 case WLAN_CIPHER_SUITE_WEP40
:
121 case WLAN_CIPHER_SUITE_WEP104
:
131 * This function retrieves the private structure from kernel wiphy structure.
133 static void *mwifiex_cfg80211_get_adapter(struct wiphy
*wiphy
)
135 return (void *) (*(unsigned long *) wiphy_priv(wiphy
));
139 * CFG802.11 operation handler to delete a network key.
142 mwifiex_cfg80211_del_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
143 u8 key_index
, bool pairwise
, const u8
*mac_addr
)
145 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
146 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
147 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
149 if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
, peer_mac
, 1)) {
150 mwifiex_dbg(priv
->adapter
, ERROR
, "deleting the crypto keys\n");
154 mwifiex_dbg(priv
->adapter
, INFO
, "info: crypto keys deleted\n");
159 * This function forms an skb for management frame.
162 mwifiex_form_mgmt_frame(struct sk_buff
*skb
, const u8
*buf
, size_t len
)
164 u8 addr
[ETH_ALEN
] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
166 u32 tx_control
= 0, pkt_type
= PKT_TYPE_MGMT
;
168 pkt_len
= len
+ ETH_ALEN
;
170 skb_reserve(skb
, MWIFIEX_MIN_DATA_HEADER_LEN
+
171 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+ sizeof(pkt_len
));
172 memcpy(skb_push(skb
, sizeof(pkt_len
)), &pkt_len
, sizeof(pkt_len
));
174 memcpy(skb_push(skb
, sizeof(tx_control
)),
175 &tx_control
, sizeof(tx_control
));
177 memcpy(skb_push(skb
, sizeof(pkt_type
)), &pkt_type
, sizeof(pkt_type
));
179 /* Add packet data and address4 */
180 memcpy(skb_put(skb
, sizeof(struct ieee80211_hdr_3addr
)), buf
,
181 sizeof(struct ieee80211_hdr_3addr
));
182 memcpy(skb_put(skb
, ETH_ALEN
), addr
, ETH_ALEN
);
183 memcpy(skb_put(skb
, len
- sizeof(struct ieee80211_hdr_3addr
)),
184 buf
+ sizeof(struct ieee80211_hdr_3addr
),
185 len
- sizeof(struct ieee80211_hdr_3addr
));
187 skb
->priority
= LOW_PRIO_TID
;
188 __net_timestamp(skb
);
194 * CFG802.11 operation handler to transmit a management frame.
197 mwifiex_cfg80211_mgmt_tx(struct wiphy
*wiphy
, struct wireless_dev
*wdev
,
198 struct cfg80211_mgmt_tx_params
*params
, u64
*cookie
)
200 const u8
*buf
= params
->buf
;
201 size_t len
= params
->len
;
204 const struct ieee80211_mgmt
*mgmt
;
205 struct mwifiex_txinfo
*tx_info
;
206 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
209 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid buffer and length\n");
213 mgmt
= (const struct ieee80211_mgmt
*)buf
;
214 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
&&
215 ieee80211_is_probe_resp(mgmt
->frame_control
)) {
216 /* Since we support offload probe resp, we need to skip probe
217 * resp in AP or GO mode */
218 mwifiex_dbg(priv
->adapter
, INFO
,
219 "info: skip to send probe resp in AP or GO mode\n");
223 pkt_len
= len
+ ETH_ALEN
;
224 skb
= dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN
+
225 MWIFIEX_MGMT_FRAME_HEADER_SIZE
+
226 pkt_len
+ sizeof(pkt_len
));
229 mwifiex_dbg(priv
->adapter
, ERROR
,
230 "allocate skb failed for management frame\n");
234 tx_info
= MWIFIEX_SKB_TXCB(skb
);
235 memset(tx_info
, 0, sizeof(*tx_info
));
236 tx_info
->bss_num
= priv
->bss_num
;
237 tx_info
->bss_type
= priv
->bss_type
;
238 tx_info
->pkt_len
= pkt_len
;
240 mwifiex_form_mgmt_frame(skb
, buf
, len
);
241 *cookie
= prandom_u32() | 1;
243 if (ieee80211_is_action(mgmt
->frame_control
))
244 skb
= mwifiex_clone_skb_for_tx_status(priv
,
246 MWIFIEX_BUF_FLAG_ACTION_TX_STATUS
, cookie
);
248 cfg80211_mgmt_tx_status(wdev
, *cookie
, buf
, len
, true,
251 mwifiex_queue_tx_pkt(priv
, skb
);
253 mwifiex_dbg(priv
->adapter
, INFO
, "info: management frame transmitted\n");
258 * CFG802.11 operation handler to register a mgmt frame.
261 mwifiex_cfg80211_mgmt_frame_register(struct wiphy
*wiphy
,
262 struct wireless_dev
*wdev
,
263 u16 frame_type
, bool reg
)
265 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
269 mask
= priv
->mgmt_frame_mask
| BIT(frame_type
>> 4);
271 mask
= priv
->mgmt_frame_mask
& ~BIT(frame_type
>> 4);
273 if (mask
!= priv
->mgmt_frame_mask
) {
274 priv
->mgmt_frame_mask
= mask
;
275 mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
276 HostCmd_ACT_GEN_SET
, 0,
277 &priv
->mgmt_frame_mask
, false);
278 mwifiex_dbg(priv
->adapter
, INFO
, "info: mgmt frame registered\n");
283 * CFG802.11 operation handler to remain on channel.
286 mwifiex_cfg80211_remain_on_channel(struct wiphy
*wiphy
,
287 struct wireless_dev
*wdev
,
288 struct ieee80211_channel
*chan
,
289 unsigned int duration
, u64
*cookie
)
291 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
294 if (!chan
|| !cookie
) {
295 mwifiex_dbg(priv
->adapter
, ERROR
, "Invalid parameter for ROC\n");
299 if (priv
->roc_cfg
.cookie
) {
300 mwifiex_dbg(priv
->adapter
, INFO
,
301 "info: ongoing ROC, cookie = 0x%llx\n",
302 priv
->roc_cfg
.cookie
);
306 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_SET
, chan
,
310 *cookie
= prandom_u32() | 1;
311 priv
->roc_cfg
.cookie
= *cookie
;
312 priv
->roc_cfg
.chan
= *chan
;
314 cfg80211_ready_on_channel(wdev
, *cookie
, chan
,
315 duration
, GFP_ATOMIC
);
317 mwifiex_dbg(priv
->adapter
, INFO
,
318 "info: ROC, cookie = 0x%llx\n", *cookie
);
325 * CFG802.11 operation handler to cancel remain on channel.
328 mwifiex_cfg80211_cancel_remain_on_channel(struct wiphy
*wiphy
,
329 struct wireless_dev
*wdev
, u64 cookie
)
331 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
334 if (cookie
!= priv
->roc_cfg
.cookie
)
337 ret
= mwifiex_remain_on_chan_cfg(priv
, HostCmd_ACT_GEN_REMOVE
,
338 &priv
->roc_cfg
.chan
, 0);
341 cfg80211_remain_on_channel_expired(wdev
, cookie
,
345 memset(&priv
->roc_cfg
, 0, sizeof(struct mwifiex_roc_cfg
));
347 mwifiex_dbg(priv
->adapter
, INFO
,
348 "info: cancel ROC, cookie = 0x%llx\n", cookie
);
355 * CFG802.11 operation handler to set Tx power.
358 mwifiex_cfg80211_set_tx_power(struct wiphy
*wiphy
,
359 struct wireless_dev
*wdev
,
360 enum nl80211_tx_power_setting type
,
363 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
364 struct mwifiex_private
*priv
;
365 struct mwifiex_power_cfg power_cfg
;
366 int dbm
= MBM_TO_DBM(mbm
);
368 if (type
== NL80211_TX_POWER_FIXED
) {
369 power_cfg
.is_power_auto
= 0;
370 power_cfg
.power_level
= dbm
;
372 power_cfg
.is_power_auto
= 1;
375 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
377 return mwifiex_set_tx_power(priv
, &power_cfg
);
381 * CFG802.11 operation handler to set Power Save option.
383 * The timeout value, if provided, is currently ignored.
386 mwifiex_cfg80211_set_power_mgmt(struct wiphy
*wiphy
,
387 struct net_device
*dev
,
388 bool enabled
, int timeout
)
390 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
394 mwifiex_dbg(priv
->adapter
, INFO
,
395 "info: ignore timeout value for IEEE Power Save\n");
399 return mwifiex_drv_set_power(priv
, &ps_mode
);
403 * CFG802.11 operation handler to set the default network key.
406 mwifiex_cfg80211_set_default_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
407 u8 key_index
, bool unicast
,
410 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
412 /* Return if WEP key not configured */
413 if (!priv
->sec_info
.wep_enabled
)
416 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_UAP
) {
417 priv
->wep_key_curr_index
= key_index
;
418 } else if (mwifiex_set_encode(priv
, NULL
, NULL
, 0, key_index
,
420 mwifiex_dbg(priv
->adapter
, ERROR
, "set default Tx key index\n");
428 * CFG802.11 operation handler to add a network key.
431 mwifiex_cfg80211_add_key(struct wiphy
*wiphy
, struct net_device
*netdev
,
432 u8 key_index
, bool pairwise
, const u8
*mac_addr
,
433 struct key_params
*params
)
435 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(netdev
);
436 struct mwifiex_wep_key
*wep_key
;
437 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
438 const u8
*peer_mac
= pairwise
? mac_addr
: bc_mac
;
440 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
441 (params
->cipher
== WLAN_CIPHER_SUITE_WEP40
||
442 params
->cipher
== WLAN_CIPHER_SUITE_WEP104
)) {
443 if (params
->key
&& params
->key_len
) {
444 wep_key
= &priv
->wep_key
[key_index
];
445 memset(wep_key
, 0, sizeof(struct mwifiex_wep_key
));
446 memcpy(wep_key
->key_material
, params
->key
,
448 wep_key
->key_index
= key_index
;
449 wep_key
->key_length
= params
->key_len
;
450 priv
->sec_info
.wep_enabled
= 1;
455 if (mwifiex_set_encode(priv
, params
, params
->key
, params
->key_len
,
456 key_index
, peer_mac
, 0)) {
457 mwifiex_dbg(priv
->adapter
, ERROR
, "crypto keys added\n");
465 * This function sends domain information to the firmware.
467 * The following information are passed to the firmware -
469 * - Sub bands (first channel, number of channels, maximum Tx power)
471 int mwifiex_send_domain_info_cmd_fw(struct wiphy
*wiphy
)
473 u8 no_of_triplet
= 0;
474 struct ieee80211_country_ie_triplet
*t
;
475 u8 no_of_parsed_chan
= 0;
476 u8 first_chan
= 0, next_chan
= 0, max_pwr
= 0;
478 enum ieee80211_band band
;
479 struct ieee80211_supported_band
*sband
;
480 struct ieee80211_channel
*ch
;
481 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
482 struct mwifiex_private
*priv
;
483 struct mwifiex_802_11d_domain_reg
*domain_info
= &adapter
->domain_reg
;
485 /* Set country code */
486 domain_info
->country_code
[0] = adapter
->country_code
[0];
487 domain_info
->country_code
[1] = adapter
->country_code
[1];
488 domain_info
->country_code
[2] = ' ';
490 band
= mwifiex_band_to_radio_type(adapter
->config_bands
);
491 if (!wiphy
->bands
[band
]) {
492 mwifiex_dbg(adapter
, ERROR
,
493 "11D: setting domain info in FW\n");
497 sband
= wiphy
->bands
[band
];
499 for (i
= 0; i
< sband
->n_channels
; i
++) {
500 ch
= &sband
->channels
[i
];
501 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
506 first_chan
= (u32
) ch
->hw_value
;
507 next_chan
= first_chan
;
508 max_pwr
= ch
->max_power
;
509 no_of_parsed_chan
= 1;
513 if (ch
->hw_value
== next_chan
+ 1 &&
514 ch
->max_power
== max_pwr
) {
518 t
= &domain_info
->triplet
[no_of_triplet
];
519 t
->chans
.first_channel
= first_chan
;
520 t
->chans
.num_channels
= no_of_parsed_chan
;
521 t
->chans
.max_power
= max_pwr
;
523 first_chan
= (u32
) ch
->hw_value
;
524 next_chan
= first_chan
;
525 max_pwr
= ch
->max_power
;
526 no_of_parsed_chan
= 1;
531 t
= &domain_info
->triplet
[no_of_triplet
];
532 t
->chans
.first_channel
= first_chan
;
533 t
->chans
.num_channels
= no_of_parsed_chan
;
534 t
->chans
.max_power
= max_pwr
;
538 domain_info
->no_of_triplet
= no_of_triplet
;
540 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
542 if (mwifiex_send_cmd(priv
, HostCmd_CMD_802_11D_DOMAIN_INFO
,
543 HostCmd_ACT_GEN_SET
, 0, NULL
, false)) {
544 mwifiex_dbg(adapter
, INFO
,
545 "11D: setting domain info in FW\n");
553 * CFG802.11 regulatory domain callback function.
555 * This function is called when the regulatory domain is changed due to the
556 * following reasons -
558 * - Set by system core
560 * - Set bt Country IE
562 static void mwifiex_reg_notifier(struct wiphy
*wiphy
,
563 struct regulatory_request
*request
)
565 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
566 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
567 MWIFIEX_BSS_ROLE_ANY
);
568 mwifiex_dbg(adapter
, INFO
,
569 "info: cfg80211 regulatory domain callback for %c%c\n",
570 request
->alpha2
[0], request
->alpha2
[1]);
572 switch (request
->initiator
) {
573 case NL80211_REGDOM_SET_BY_DRIVER
:
574 case NL80211_REGDOM_SET_BY_CORE
:
575 case NL80211_REGDOM_SET_BY_USER
:
576 case NL80211_REGDOM_SET_BY_COUNTRY_IE
:
579 mwifiex_dbg(adapter
, ERROR
,
580 "unknown regdom initiator: %d\n",
585 /* Don't send world or same regdom info to firmware */
586 if (strncmp(request
->alpha2
, "00", 2) &&
587 strncmp(request
->alpha2
, adapter
->country_code
,
588 sizeof(request
->alpha2
))) {
589 memcpy(adapter
->country_code
, request
->alpha2
,
590 sizeof(request
->alpha2
));
591 mwifiex_send_domain_info_cmd_fw(wiphy
);
592 mwifiex_dnld_txpwr_table(priv
);
597 * This function sets the fragmentation threshold.
599 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
600 * and MWIFIEX_FRAG_MAX_VALUE.
603 mwifiex_set_frag(struct mwifiex_private
*priv
, u32 frag_thr
)
605 if (frag_thr
< MWIFIEX_FRAG_MIN_VALUE
||
606 frag_thr
> MWIFIEX_FRAG_MAX_VALUE
)
607 frag_thr
= MWIFIEX_FRAG_MAX_VALUE
;
609 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
610 HostCmd_ACT_GEN_SET
, FRAG_THRESH_I
,
615 * This function sets the RTS threshold.
617 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
618 * and MWIFIEX_RTS_MAX_VALUE.
621 mwifiex_set_rts(struct mwifiex_private
*priv
, u32 rts_thr
)
623 if (rts_thr
< MWIFIEX_RTS_MIN_VALUE
|| rts_thr
> MWIFIEX_RTS_MAX_VALUE
)
624 rts_thr
= MWIFIEX_RTS_MAX_VALUE
;
626 return mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
627 HostCmd_ACT_GEN_SET
, RTS_THRESH_I
,
632 * CFG802.11 operation handler to set wiphy parameters.
634 * This function can be used to set the RTS threshold and the
635 * Fragmentation threshold of the driver.
638 mwifiex_cfg80211_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
640 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
641 struct mwifiex_private
*priv
;
642 struct mwifiex_uap_bss_param
*bss_cfg
;
645 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_ANY
);
647 switch (priv
->bss_role
) {
648 case MWIFIEX_BSS_ROLE_UAP
:
649 if (priv
->bss_started
) {
650 mwifiex_dbg(adapter
, ERROR
,
651 "cannot change wiphy params when bss started");
655 bss_cfg
= kzalloc(sizeof(*bss_cfg
), GFP_KERNEL
);
659 mwifiex_set_sys_config_invalid_data(bss_cfg
);
661 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
)
662 bss_cfg
->rts_threshold
= wiphy
->rts_threshold
;
663 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
)
664 bss_cfg
->frag_threshold
= wiphy
->frag_threshold
;
665 if (changed
& WIPHY_PARAM_RETRY_LONG
)
666 bss_cfg
->retry_limit
= wiphy
->retry_long
;
668 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_SYS_CONFIG
,
670 UAP_BSS_PARAMS_I
, bss_cfg
,
675 mwifiex_dbg(adapter
, ERROR
,
676 "Failed to set wiphy phy params\n");
681 case MWIFIEX_BSS_ROLE_STA
:
682 if (priv
->media_connected
) {
683 mwifiex_dbg(adapter
, ERROR
,
684 "cannot change wiphy params when connected");
687 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
688 ret
= mwifiex_set_rts(priv
,
689 wiphy
->rts_threshold
);
693 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
694 ret
= mwifiex_set_frag(priv
,
695 wiphy
->frag_threshold
);
706 mwifiex_cfg80211_deinit_p2p(struct mwifiex_private
*priv
)
708 u16 mode
= P2P_MODE_DISABLE
;
710 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
711 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
718 * This function initializes the functionalities for P2P client.
719 * The P2P client initialization sequence is:
720 * disable -> device -> client
723 mwifiex_cfg80211_init_p2p_client(struct mwifiex_private
*priv
)
727 if (mwifiex_cfg80211_deinit_p2p(priv
))
730 mode
= P2P_MODE_DEVICE
;
731 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
732 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
735 mode
= P2P_MODE_CLIENT
;
736 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
737 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
744 * This function initializes the functionalities for P2P GO.
745 * The P2P GO initialization sequence is:
746 * disable -> device -> GO
749 mwifiex_cfg80211_init_p2p_go(struct mwifiex_private
*priv
)
753 if (mwifiex_cfg80211_deinit_p2p(priv
))
756 mode
= P2P_MODE_DEVICE
;
757 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
758 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
762 if (mwifiex_send_cmd(priv
, HostCmd_CMD_P2P_MODE_CFG
,
763 HostCmd_ACT_GEN_SET
, 0, &mode
, true))
769 static int mwifiex_deinit_priv_params(struct mwifiex_private
*priv
)
771 struct mwifiex_adapter
*adapter
= priv
->adapter
;
774 priv
->mgmt_frame_mask
= 0;
775 if (mwifiex_send_cmd(priv
, HostCmd_CMD_MGMT_FRAME_REG
,
776 HostCmd_ACT_GEN_SET
, 0,
777 &priv
->mgmt_frame_mask
, false)) {
778 mwifiex_dbg(adapter
, ERROR
,
779 "could not unregister mgmt frame rx\n");
783 mwifiex_deauthenticate(priv
, NULL
);
785 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
786 adapter
->main_locked
= true;
787 if (adapter
->mwifiex_processing
) {
788 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
789 flush_workqueue(adapter
->workqueue
);
791 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
794 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
795 adapter
->rx_locked
= true;
796 if (adapter
->rx_processing
) {
797 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
798 flush_workqueue(adapter
->rx_workqueue
);
800 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
803 mwifiex_free_priv(priv
);
804 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
805 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
806 priv
->sec_info
.authentication_mode
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
812 mwifiex_init_new_priv_params(struct mwifiex_private
*priv
,
813 struct net_device
*dev
,
814 enum nl80211_iftype type
)
816 struct mwifiex_adapter
*adapter
= priv
->adapter
;
819 mwifiex_init_priv(priv
);
821 priv
->bss_mode
= type
;
822 priv
->wdev
.iftype
= type
;
824 mwifiex_init_priv_params(priv
, priv
->netdev
);
825 priv
->bss_started
= 0;
828 case NL80211_IFTYPE_STATION
:
829 case NL80211_IFTYPE_ADHOC
:
830 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
831 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
833 case NL80211_IFTYPE_P2P_CLIENT
:
834 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
835 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
837 case NL80211_IFTYPE_P2P_GO
:
838 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
839 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
841 case NL80211_IFTYPE_AP
:
842 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
843 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
846 mwifiex_dbg(adapter
, ERROR
,
847 "%s: changing to %d not supported\n",
852 spin_lock_irqsave(&adapter
->main_proc_lock
, flags
);
853 adapter
->main_locked
= false;
854 spin_unlock_irqrestore(&adapter
->main_proc_lock
, flags
);
856 spin_lock_irqsave(&adapter
->rx_proc_lock
, flags
);
857 adapter
->rx_locked
= false;
858 spin_unlock_irqrestore(&adapter
->rx_proc_lock
, flags
);
864 mwifiex_change_vif_to_p2p(struct net_device
*dev
,
865 enum nl80211_iftype curr_iftype
,
866 enum nl80211_iftype type
, u32
*flags
,
867 struct vif_params
*params
)
869 struct mwifiex_private
*priv
;
870 struct mwifiex_adapter
*adapter
;
872 priv
= mwifiex_netdev_get_priv(dev
);
877 adapter
= priv
->adapter
;
879 if (adapter
->curr_iface_comb
.p2p_intf
==
880 adapter
->iface_limit
.p2p_intf
) {
881 mwifiex_dbg(adapter
, ERROR
,
882 "cannot create multiple P2P ifaces\n");
886 mwifiex_dbg(adapter
, INFO
,
887 "%s: changing role to p2p\n", dev
->name
);
889 if (mwifiex_deinit_priv_params(priv
))
891 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
895 case NL80211_IFTYPE_P2P_CLIENT
:
896 if (mwifiex_cfg80211_init_p2p_client(priv
))
899 case NL80211_IFTYPE_P2P_GO
:
900 if (mwifiex_cfg80211_init_p2p_go(priv
))
904 mwifiex_dbg(adapter
, ERROR
,
905 "%s: changing to %d not supported\n",
910 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
911 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
914 if (mwifiex_sta_init_cmd(priv
, false, false))
917 switch (curr_iftype
) {
918 case NL80211_IFTYPE_STATION
:
919 case NL80211_IFTYPE_ADHOC
:
920 adapter
->curr_iface_comb
.sta_intf
--;
922 case NL80211_IFTYPE_AP
:
923 adapter
->curr_iface_comb
.uap_intf
--;
929 adapter
->curr_iface_comb
.p2p_intf
++;
930 dev
->ieee80211_ptr
->iftype
= type
;
936 mwifiex_change_vif_to_sta_adhoc(struct net_device
*dev
,
937 enum nl80211_iftype curr_iftype
,
938 enum nl80211_iftype type
, u32
*flags
,
939 struct vif_params
*params
)
941 struct mwifiex_private
*priv
;
942 struct mwifiex_adapter
*adapter
;
944 priv
= mwifiex_netdev_get_priv(dev
);
949 adapter
= priv
->adapter
;
951 if ((curr_iftype
!= NL80211_IFTYPE_P2P_CLIENT
&&
952 curr_iftype
!= NL80211_IFTYPE_P2P_GO
) &&
953 (adapter
->curr_iface_comb
.sta_intf
==
954 adapter
->iface_limit
.sta_intf
)) {
955 mwifiex_dbg(adapter
, ERROR
,
956 "cannot create multiple station/adhoc ifaces\n");
960 if (type
== NL80211_IFTYPE_STATION
)
961 mwifiex_dbg(adapter
, INFO
,
962 "%s: changing role to station\n", dev
->name
);
964 mwifiex_dbg(adapter
, INFO
,
965 "%s: changing role to adhoc\n", dev
->name
);
967 if (mwifiex_deinit_priv_params(priv
))
969 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
971 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
972 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
974 if (mwifiex_sta_init_cmd(priv
, false, false))
977 switch (curr_iftype
) {
978 case NL80211_IFTYPE_P2P_CLIENT
:
979 case NL80211_IFTYPE_P2P_GO
:
980 adapter
->curr_iface_comb
.p2p_intf
--;
982 case NL80211_IFTYPE_AP
:
983 adapter
->curr_iface_comb
.uap_intf
--;
989 adapter
->curr_iface_comb
.sta_intf
++;
990 dev
->ieee80211_ptr
->iftype
= type
;
995 mwifiex_change_vif_to_ap(struct net_device
*dev
,
996 enum nl80211_iftype curr_iftype
,
997 enum nl80211_iftype type
, u32
*flags
,
998 struct vif_params
*params
)
1000 struct mwifiex_private
*priv
;
1001 struct mwifiex_adapter
*adapter
;
1003 priv
= mwifiex_netdev_get_priv(dev
);
1008 adapter
= priv
->adapter
;
1010 if (adapter
->curr_iface_comb
.uap_intf
==
1011 adapter
->iface_limit
.uap_intf
) {
1012 mwifiex_dbg(adapter
, ERROR
,
1013 "cannot create multiple AP ifaces\n");
1017 mwifiex_dbg(adapter
, INFO
,
1018 "%s: changing role to AP\n", dev
->name
);
1020 if (mwifiex_deinit_priv_params(priv
))
1022 if (mwifiex_init_new_priv_params(priv
, dev
, type
))
1024 if (mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1025 HostCmd_ACT_GEN_SET
, 0, NULL
, true))
1027 if (mwifiex_sta_init_cmd(priv
, false, false))
1030 switch (curr_iftype
) {
1031 case NL80211_IFTYPE_P2P_CLIENT
:
1032 case NL80211_IFTYPE_P2P_GO
:
1033 adapter
->curr_iface_comb
.p2p_intf
--;
1035 case NL80211_IFTYPE_STATION
:
1036 case NL80211_IFTYPE_ADHOC
:
1037 adapter
->curr_iface_comb
.sta_intf
--;
1043 adapter
->curr_iface_comb
.uap_intf
++;
1044 dev
->ieee80211_ptr
->iftype
= type
;
1048 * CFG802.11 operation handler to change interface type.
1051 mwifiex_cfg80211_change_virtual_intf(struct wiphy
*wiphy
,
1052 struct net_device
*dev
,
1053 enum nl80211_iftype type
, u32
*flags
,
1054 struct vif_params
*params
)
1056 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1057 enum nl80211_iftype curr_iftype
= dev
->ieee80211_ptr
->iftype
;
1059 switch (curr_iftype
) {
1060 case NL80211_IFTYPE_ADHOC
:
1062 case NL80211_IFTYPE_STATION
:
1063 priv
->bss_mode
= type
;
1064 priv
->sec_info
.authentication_mode
=
1065 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1066 dev
->ieee80211_ptr
->iftype
= type
;
1067 mwifiex_deauthenticate(priv
, NULL
);
1068 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1069 HostCmd_ACT_GEN_SET
, 0, NULL
,
1071 case NL80211_IFTYPE_P2P_CLIENT
:
1072 case NL80211_IFTYPE_P2P_GO
:
1073 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1074 type
, flags
, params
);
1075 case NL80211_IFTYPE_AP
:
1076 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1078 case NL80211_IFTYPE_UNSPECIFIED
:
1079 mwifiex_dbg(priv
->adapter
, INFO
,
1080 "%s: kept type as IBSS\n", dev
->name
);
1081 case NL80211_IFTYPE_ADHOC
: /* This shouldn't happen */
1084 mwifiex_dbg(priv
->adapter
, ERROR
,
1085 "%s: changing to %d not supported\n",
1090 case NL80211_IFTYPE_STATION
:
1092 case NL80211_IFTYPE_ADHOC
:
1093 priv
->bss_mode
= type
;
1094 priv
->sec_info
.authentication_mode
=
1095 NL80211_AUTHTYPE_OPEN_SYSTEM
;
1096 dev
->ieee80211_ptr
->iftype
= type
;
1097 mwifiex_deauthenticate(priv
, NULL
);
1098 return mwifiex_send_cmd(priv
, HostCmd_CMD_SET_BSS_MODE
,
1099 HostCmd_ACT_GEN_SET
, 0, NULL
,
1101 case NL80211_IFTYPE_P2P_CLIENT
:
1102 case NL80211_IFTYPE_P2P_GO
:
1103 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1104 type
, flags
, params
);
1105 case NL80211_IFTYPE_AP
:
1106 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1108 case NL80211_IFTYPE_UNSPECIFIED
:
1109 mwifiex_dbg(priv
->adapter
, INFO
,
1110 "%s: kept type as STA\n", dev
->name
);
1111 case NL80211_IFTYPE_STATION
: /* This shouldn't happen */
1114 mwifiex_dbg(priv
->adapter
, ERROR
,
1115 "%s: changing to %d not supported\n",
1120 case NL80211_IFTYPE_AP
:
1122 case NL80211_IFTYPE_ADHOC
:
1123 case NL80211_IFTYPE_STATION
:
1124 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1128 case NL80211_IFTYPE_P2P_CLIENT
:
1129 case NL80211_IFTYPE_P2P_GO
:
1130 return mwifiex_change_vif_to_p2p(dev
, curr_iftype
,
1131 type
, flags
, params
);
1132 case NL80211_IFTYPE_UNSPECIFIED
:
1133 mwifiex_dbg(priv
->adapter
, INFO
,
1134 "%s: kept type as AP\n", dev
->name
);
1135 case NL80211_IFTYPE_AP
: /* This shouldn't happen */
1138 mwifiex_dbg(priv
->adapter
, ERROR
,
1139 "%s: changing to %d not supported\n",
1144 case NL80211_IFTYPE_P2P_CLIENT
:
1145 case NL80211_IFTYPE_P2P_GO
:
1147 case NL80211_IFTYPE_STATION
:
1148 if (mwifiex_cfg80211_deinit_p2p(priv
))
1150 priv
->adapter
->curr_iface_comb
.p2p_intf
--;
1151 priv
->adapter
->curr_iface_comb
.sta_intf
++;
1152 dev
->ieee80211_ptr
->iftype
= type
;
1154 case NL80211_IFTYPE_ADHOC
:
1155 if (mwifiex_cfg80211_deinit_p2p(priv
))
1157 return mwifiex_change_vif_to_sta_adhoc(dev
, curr_iftype
,
1161 case NL80211_IFTYPE_AP
:
1162 if (mwifiex_cfg80211_deinit_p2p(priv
))
1164 return mwifiex_change_vif_to_ap(dev
, curr_iftype
, type
,
1166 case NL80211_IFTYPE_UNSPECIFIED
:
1167 mwifiex_dbg(priv
->adapter
, INFO
,
1168 "%s: kept type as P2P\n", dev
->name
);
1169 case NL80211_IFTYPE_P2P_CLIENT
:
1170 case NL80211_IFTYPE_P2P_GO
:
1173 mwifiex_dbg(priv
->adapter
, ERROR
,
1174 "%s: changing to %d not supported\n",
1180 mwifiex_dbg(priv
->adapter
, ERROR
,
1181 "%s: unknown iftype: %d\n",
1182 dev
->name
, dev
->ieee80211_ptr
->iftype
);
1191 mwifiex_parse_htinfo(struct mwifiex_private
*priv
, u8 tx_htinfo
,
1192 struct rate_info
*rate
)
1194 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1196 if (adapter
->is_hw_11ac_capable
) {
1197 /* bit[1-0]: 00=LG 01=HT 10=VHT */
1198 if (tx_htinfo
& BIT(0)) {
1200 rate
->mcs
= priv
->tx_rate
;
1201 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1203 if (tx_htinfo
& BIT(1)) {
1205 rate
->mcs
= priv
->tx_rate
& 0x0F;
1206 rate
->flags
|= RATE_INFO_FLAGS_VHT_MCS
;
1209 if (tx_htinfo
& (BIT(1) | BIT(0))) {
1211 switch (tx_htinfo
& (BIT(3) | BIT(2))) {
1213 rate
->bw
= RATE_INFO_BW_20
;
1216 rate
->bw
= RATE_INFO_BW_40
;
1219 rate
->bw
= RATE_INFO_BW_80
;
1221 case (BIT(3) | BIT(2)):
1222 rate
->bw
= RATE_INFO_BW_160
;
1226 if (tx_htinfo
& BIT(4))
1227 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1229 if ((priv
->tx_rate
>> 4) == 1)
1236 * Bit 0 in tx_htinfo indicates that current Tx rate
1237 * is 11n rate. Valid MCS index values for us are 0 to 15.
1239 if ((tx_htinfo
& BIT(0)) && (priv
->tx_rate
< 16)) {
1240 rate
->mcs
= priv
->tx_rate
;
1241 rate
->flags
|= RATE_INFO_FLAGS_MCS
;
1242 rate
->bw
= RATE_INFO_BW_20
;
1243 if (tx_htinfo
& BIT(1))
1244 rate
->bw
= RATE_INFO_BW_40
;
1245 if (tx_htinfo
& BIT(2))
1246 rate
->flags
|= RATE_INFO_FLAGS_SHORT_GI
;
1252 * This function dumps the station information on a buffer.
1254 * The following information are shown -
1255 * - Total bytes transmitted
1256 * - Total bytes received
1257 * - Total packets transmitted
1258 * - Total packets received
1259 * - Signal quality level
1260 * - Transmission rate
1263 mwifiex_dump_station_info(struct mwifiex_private
*priv
,
1264 struct mwifiex_sta_node
*node
,
1265 struct station_info
*sinfo
)
1269 sinfo
->filled
= BIT(NL80211_STA_INFO_RX_BYTES
) | BIT(NL80211_STA_INFO_TX_BYTES
) |
1270 BIT(NL80211_STA_INFO_RX_PACKETS
) | BIT(NL80211_STA_INFO_TX_PACKETS
) |
1271 BIT(NL80211_STA_INFO_TX_BITRATE
) |
1272 BIT(NL80211_STA_INFO_SIGNAL
) | BIT(NL80211_STA_INFO_SIGNAL_AVG
);
1274 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1278 sinfo
->filled
|= BIT(NL80211_STA_INFO_INACTIVE_TIME
) |
1279 BIT(NL80211_STA_INFO_TX_FAILED
);
1280 sinfo
->inactive_time
=
1281 jiffies_to_msecs(jiffies
- node
->stats
.last_rx
);
1283 sinfo
->signal
= node
->stats
.rssi
;
1284 sinfo
->signal_avg
= node
->stats
.rssi
;
1285 sinfo
->rx_bytes
= node
->stats
.rx_bytes
;
1286 sinfo
->tx_bytes
= node
->stats
.tx_bytes
;
1287 sinfo
->rx_packets
= node
->stats
.rx_packets
;
1288 sinfo
->tx_packets
= node
->stats
.tx_packets
;
1289 sinfo
->tx_failed
= node
->stats
.tx_failed
;
1291 mwifiex_parse_htinfo(priv
, node
->stats
.last_tx_htinfo
,
1293 sinfo
->txrate
.legacy
= node
->stats
.last_tx_rate
* 5;
1298 /* Get signal information from the firmware */
1299 if (mwifiex_send_cmd(priv
, HostCmd_CMD_RSSI_INFO
,
1300 HostCmd_ACT_GEN_GET
, 0, NULL
, true)) {
1301 mwifiex_dbg(priv
->adapter
, ERROR
,
1302 "failed to get signal information\n");
1306 if (mwifiex_drv_get_data_rate(priv
, &rate
)) {
1307 mwifiex_dbg(priv
->adapter
, ERROR
,
1308 "getting data rate error\n");
1312 /* Get DTIM period information from firmware */
1313 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
1314 HostCmd_ACT_GEN_GET
, DTIM_PERIOD_I
,
1315 &priv
->dtim_period
, true);
1317 mwifiex_parse_htinfo(priv
, priv
->tx_htinfo
, &sinfo
->txrate
);
1319 sinfo
->signal_avg
= priv
->bcn_rssi_avg
;
1320 sinfo
->rx_bytes
= priv
->stats
.rx_bytes
;
1321 sinfo
->tx_bytes
= priv
->stats
.tx_bytes
;
1322 sinfo
->rx_packets
= priv
->stats
.rx_packets
;
1323 sinfo
->tx_packets
= priv
->stats
.tx_packets
;
1324 sinfo
->signal
= priv
->bcn_rssi_avg
;
1325 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
1326 sinfo
->txrate
.legacy
= rate
* 5;
1328 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
) {
1329 sinfo
->filled
|= BIT(NL80211_STA_INFO_BSS_PARAM
);
1330 sinfo
->bss_param
.flags
= 0;
1331 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1332 WLAN_CAPABILITY_SHORT_PREAMBLE
)
1333 sinfo
->bss_param
.flags
|=
1334 BSS_PARAM_FLAGS_SHORT_PREAMBLE
;
1335 if (priv
->curr_bss_params
.bss_descriptor
.cap_info_bitmap
&
1336 WLAN_CAPABILITY_SHORT_SLOT_TIME
)
1337 sinfo
->bss_param
.flags
|=
1338 BSS_PARAM_FLAGS_SHORT_SLOT_TIME
;
1339 sinfo
->bss_param
.dtim_period
= priv
->dtim_period
;
1340 sinfo
->bss_param
.beacon_interval
=
1341 priv
->curr_bss_params
.bss_descriptor
.beacon_period
;
1348 * CFG802.11 operation handler to get station information.
1350 * This function only works in connected mode, and dumps the
1351 * requested station information, if available.
1354 mwifiex_cfg80211_get_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1355 const u8
*mac
, struct station_info
*sinfo
)
1357 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1359 if (!priv
->media_connected
)
1361 if (memcmp(mac
, priv
->cfg_bssid
, ETH_ALEN
))
1364 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1368 * CFG802.11 operation handler to dump station information.
1371 mwifiex_cfg80211_dump_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1372 int idx
, u8
*mac
, struct station_info
*sinfo
)
1374 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1375 static struct mwifiex_sta_node
*node
;
1377 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1378 priv
->media_connected
&& idx
== 0) {
1379 ether_addr_copy(mac
, priv
->cfg_bssid
);
1380 return mwifiex_dump_station_info(priv
, NULL
, sinfo
);
1381 } else if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
1382 mwifiex_send_cmd(priv
, HOST_CMD_APCMD_STA_LIST
,
1383 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
1385 if (node
&& (&node
->list
== &priv
->sta_list
)) {
1390 node
= list_prepare_entry(node
, &priv
->sta_list
, list
);
1391 list_for_each_entry_continue(node
, &priv
->sta_list
, list
) {
1392 ether_addr_copy(mac
, node
->mac_addr
);
1393 return mwifiex_dump_station_info(priv
, node
, sinfo
);
1401 mwifiex_cfg80211_dump_survey(struct wiphy
*wiphy
, struct net_device
*dev
,
1402 int idx
, struct survey_info
*survey
)
1404 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1405 struct mwifiex_chan_stats
*pchan_stats
= priv
->adapter
->chan_stats
;
1406 enum ieee80211_band band
;
1408 mwifiex_dbg(priv
->adapter
, DUMP
, "dump_survey idx=%d\n", idx
);
1410 memset(survey
, 0, sizeof(struct survey_info
));
1412 if ((GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
) &&
1413 priv
->media_connected
&& idx
== 0) {
1414 u8 curr_bss_band
= priv
->curr_bss_params
.band
;
1415 u32 chan
= priv
->curr_bss_params
.bss_descriptor
.channel
;
1417 band
= mwifiex_band_to_radio_type(curr_bss_band
);
1418 survey
->channel
= ieee80211_get_channel(wiphy
,
1419 ieee80211_channel_to_frequency(chan
, band
));
1421 if (priv
->bcn_nf_last
) {
1422 survey
->filled
= SURVEY_INFO_NOISE_DBM
;
1423 survey
->noise
= priv
->bcn_nf_last
;
1428 if (idx
>= priv
->adapter
->num_in_chan_stats
)
1431 if (!pchan_stats
[idx
].cca_scan_dur
)
1434 band
= pchan_stats
[idx
].bandcfg
;
1435 survey
->channel
= ieee80211_get_channel(wiphy
,
1436 ieee80211_channel_to_frequency(pchan_stats
[idx
].chan_num
, band
));
1437 survey
->filled
= SURVEY_INFO_NOISE_DBM
|
1439 SURVEY_INFO_TIME_BUSY
;
1440 survey
->noise
= pchan_stats
[idx
].noise
;
1441 survey
->time
= pchan_stats
[idx
].cca_scan_dur
;
1442 survey
->time_busy
= pchan_stats
[idx
].cca_busy_dur
;
1447 /* Supported rates to be advertised to the cfg80211 */
1448 static struct ieee80211_rate mwifiex_rates
[] = {
1449 {.bitrate
= 10, .hw_value
= 2, },
1450 {.bitrate
= 20, .hw_value
= 4, },
1451 {.bitrate
= 55, .hw_value
= 11, },
1452 {.bitrate
= 110, .hw_value
= 22, },
1453 {.bitrate
= 60, .hw_value
= 12, },
1454 {.bitrate
= 90, .hw_value
= 18, },
1455 {.bitrate
= 120, .hw_value
= 24, },
1456 {.bitrate
= 180, .hw_value
= 36, },
1457 {.bitrate
= 240, .hw_value
= 48, },
1458 {.bitrate
= 360, .hw_value
= 72, },
1459 {.bitrate
= 480, .hw_value
= 96, },
1460 {.bitrate
= 540, .hw_value
= 108, },
1463 /* Channel definitions to be advertised to cfg80211 */
1464 static struct ieee80211_channel mwifiex_channels_2ghz
[] = {
1465 {.center_freq
= 2412, .hw_value
= 1, },
1466 {.center_freq
= 2417, .hw_value
= 2, },
1467 {.center_freq
= 2422, .hw_value
= 3, },
1468 {.center_freq
= 2427, .hw_value
= 4, },
1469 {.center_freq
= 2432, .hw_value
= 5, },
1470 {.center_freq
= 2437, .hw_value
= 6, },
1471 {.center_freq
= 2442, .hw_value
= 7, },
1472 {.center_freq
= 2447, .hw_value
= 8, },
1473 {.center_freq
= 2452, .hw_value
= 9, },
1474 {.center_freq
= 2457, .hw_value
= 10, },
1475 {.center_freq
= 2462, .hw_value
= 11, },
1476 {.center_freq
= 2467, .hw_value
= 12, },
1477 {.center_freq
= 2472, .hw_value
= 13, },
1478 {.center_freq
= 2484, .hw_value
= 14, },
1481 static struct ieee80211_supported_band mwifiex_band_2ghz
= {
1482 .channels
= mwifiex_channels_2ghz
,
1483 .n_channels
= ARRAY_SIZE(mwifiex_channels_2ghz
),
1484 .bitrates
= mwifiex_rates
,
1485 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
),
1488 static struct ieee80211_channel mwifiex_channels_5ghz
[] = {
1489 {.center_freq
= 5040, .hw_value
= 8, },
1490 {.center_freq
= 5060, .hw_value
= 12, },
1491 {.center_freq
= 5080, .hw_value
= 16, },
1492 {.center_freq
= 5170, .hw_value
= 34, },
1493 {.center_freq
= 5190, .hw_value
= 38, },
1494 {.center_freq
= 5210, .hw_value
= 42, },
1495 {.center_freq
= 5230, .hw_value
= 46, },
1496 {.center_freq
= 5180, .hw_value
= 36, },
1497 {.center_freq
= 5200, .hw_value
= 40, },
1498 {.center_freq
= 5220, .hw_value
= 44, },
1499 {.center_freq
= 5240, .hw_value
= 48, },
1500 {.center_freq
= 5260, .hw_value
= 52, },
1501 {.center_freq
= 5280, .hw_value
= 56, },
1502 {.center_freq
= 5300, .hw_value
= 60, },
1503 {.center_freq
= 5320, .hw_value
= 64, },
1504 {.center_freq
= 5500, .hw_value
= 100, },
1505 {.center_freq
= 5520, .hw_value
= 104, },
1506 {.center_freq
= 5540, .hw_value
= 108, },
1507 {.center_freq
= 5560, .hw_value
= 112, },
1508 {.center_freq
= 5580, .hw_value
= 116, },
1509 {.center_freq
= 5600, .hw_value
= 120, },
1510 {.center_freq
= 5620, .hw_value
= 124, },
1511 {.center_freq
= 5640, .hw_value
= 128, },
1512 {.center_freq
= 5660, .hw_value
= 132, },
1513 {.center_freq
= 5680, .hw_value
= 136, },
1514 {.center_freq
= 5700, .hw_value
= 140, },
1515 {.center_freq
= 5745, .hw_value
= 149, },
1516 {.center_freq
= 5765, .hw_value
= 153, },
1517 {.center_freq
= 5785, .hw_value
= 157, },
1518 {.center_freq
= 5805, .hw_value
= 161, },
1519 {.center_freq
= 5825, .hw_value
= 165, },
1522 static struct ieee80211_supported_band mwifiex_band_5ghz
= {
1523 .channels
= mwifiex_channels_5ghz
,
1524 .n_channels
= ARRAY_SIZE(mwifiex_channels_5ghz
),
1525 .bitrates
= mwifiex_rates
+ 4,
1526 .n_bitrates
= ARRAY_SIZE(mwifiex_rates
) - 4,
1530 /* Supported crypto cipher suits to be advertised to cfg80211 */
1531 static const u32 mwifiex_cipher_suites
[] = {
1532 WLAN_CIPHER_SUITE_WEP40
,
1533 WLAN_CIPHER_SUITE_WEP104
,
1534 WLAN_CIPHER_SUITE_TKIP
,
1535 WLAN_CIPHER_SUITE_CCMP
,
1536 WLAN_CIPHER_SUITE_AES_CMAC
,
1539 /* Supported mgmt frame types to be advertised to cfg80211 */
1540 static const struct ieee80211_txrx_stypes
1541 mwifiex_mgmt_stypes
[NUM_NL80211_IFTYPES
] = {
1542 [NL80211_IFTYPE_STATION
] = {
1543 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1544 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1545 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1546 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1548 [NL80211_IFTYPE_AP
] = {
1549 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1550 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1551 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1552 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1554 [NL80211_IFTYPE_P2P_CLIENT
] = {
1555 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1556 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1557 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1558 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1560 [NL80211_IFTYPE_P2P_GO
] = {
1561 .tx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1562 BIT(IEEE80211_STYPE_PROBE_RESP
>> 4),
1563 .rx
= BIT(IEEE80211_STYPE_ACTION
>> 4) |
1564 BIT(IEEE80211_STYPE_PROBE_REQ
>> 4),
1569 * CFG802.11 operation handler for setting bit rates.
1571 * Function configures data rates to firmware using bitrate mask
1572 * provided by cfg80211.
1574 static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy
*wiphy
,
1575 struct net_device
*dev
,
1577 const struct cfg80211_bitrate_mask
*mask
)
1579 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1580 u16 bitmap_rates
[MAX_BITMAP_RATES_SIZE
];
1581 enum ieee80211_band band
;
1582 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1584 if (!priv
->media_connected
) {
1585 mwifiex_dbg(adapter
, ERROR
,
1586 "Can not set Tx data rate in disconnected state\n");
1590 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1592 memset(bitmap_rates
, 0, sizeof(bitmap_rates
));
1594 /* Fill HR/DSSS rates. */
1595 if (band
== IEEE80211_BAND_2GHZ
)
1596 bitmap_rates
[0] = mask
->control
[band
].legacy
& 0x000f;
1598 /* Fill OFDM rates */
1599 if (band
== IEEE80211_BAND_2GHZ
)
1600 bitmap_rates
[1] = (mask
->control
[band
].legacy
& 0x0ff0) >> 4;
1602 bitmap_rates
[1] = mask
->control
[band
].legacy
;
1604 /* Fill HT MCS rates */
1605 bitmap_rates
[2] = mask
->control
[band
].ht_mcs
[0];
1606 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1607 bitmap_rates
[2] |= mask
->control
[band
].ht_mcs
[1] << 8;
1609 /* Fill VHT MCS rates */
1610 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
1611 bitmap_rates
[10] = mask
->control
[band
].vht_mcs
[0];
1612 if (adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
)
1613 bitmap_rates
[11] = mask
->control
[band
].vht_mcs
[1];
1616 return mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
1617 HostCmd_ACT_GEN_SET
, 0, bitmap_rates
, true);
1621 * CFG802.11 operation handler for connection quality monitoring.
1623 * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI
1626 static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy
*wiphy
,
1627 struct net_device
*dev
,
1628 s32 rssi_thold
, u32 rssi_hyst
)
1630 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1631 struct mwifiex_ds_misc_subsc_evt subsc_evt
;
1633 priv
->cqm_rssi_thold
= rssi_thold
;
1634 priv
->cqm_rssi_hyst
= rssi_hyst
;
1636 memset(&subsc_evt
, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt
));
1637 subsc_evt
.events
= BITMASK_BCN_RSSI_LOW
| BITMASK_BCN_RSSI_HIGH
;
1639 /* Subscribe/unsubscribe low and high rssi events */
1640 if (rssi_thold
&& rssi_hyst
) {
1641 subsc_evt
.action
= HostCmd_ACT_BITWISE_SET
;
1642 subsc_evt
.bcn_l_rssi_cfg
.abs_value
= abs(rssi_thold
);
1643 subsc_evt
.bcn_h_rssi_cfg
.abs_value
= abs(rssi_thold
);
1644 subsc_evt
.bcn_l_rssi_cfg
.evt_freq
= 1;
1645 subsc_evt
.bcn_h_rssi_cfg
.evt_freq
= 1;
1646 return mwifiex_send_cmd(priv
,
1647 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1648 0, 0, &subsc_evt
, true);
1650 subsc_evt
.action
= HostCmd_ACT_BITWISE_CLR
;
1651 return mwifiex_send_cmd(priv
,
1652 HostCmd_CMD_802_11_SUBSCRIBE_EVENT
,
1653 0, 0, &subsc_evt
, true);
1659 /* cfg80211 operation handler for change_beacon.
1660 * Function retrieves and sets modified management IEs to FW.
1662 static int mwifiex_cfg80211_change_beacon(struct wiphy
*wiphy
,
1663 struct net_device
*dev
,
1664 struct cfg80211_beacon_data
*data
)
1666 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1668 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
) {
1669 mwifiex_dbg(priv
->adapter
, ERROR
,
1670 "%s: bss_type mismatched\n", __func__
);
1674 if (!priv
->bss_started
) {
1675 mwifiex_dbg(priv
->adapter
, ERROR
,
1676 "%s: bss not started\n", __func__
);
1680 if (mwifiex_set_mgmt_ies(priv
, data
)) {
1681 mwifiex_dbg(priv
->adapter
, ERROR
,
1682 "%s: setting mgmt ies failed\n", __func__
);
1689 /* cfg80211 operation handler for del_station.
1690 * Function deauthenticates station which value is provided in mac parameter.
1691 * If mac is NULL/broadcast, all stations in associated station list are
1692 * deauthenticated. If bss is not started or there are no stations in
1693 * associated stations list, no action is taken.
1696 mwifiex_cfg80211_del_station(struct wiphy
*wiphy
, struct net_device
*dev
,
1697 struct station_del_parameters
*params
)
1699 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1700 struct mwifiex_sta_node
*sta_node
;
1701 u8 deauth_mac
[ETH_ALEN
];
1702 unsigned long flags
;
1704 if (list_empty(&priv
->sta_list
) || !priv
->bss_started
)
1707 if (!params
->mac
|| is_broadcast_ether_addr(params
->mac
))
1710 mwifiex_dbg(priv
->adapter
, INFO
, "%s: mac address %pM\n",
1711 __func__
, params
->mac
);
1713 eth_zero_addr(deauth_mac
);
1715 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
1716 sta_node
= mwifiex_get_sta_entry(priv
, params
->mac
);
1718 ether_addr_copy(deauth_mac
, params
->mac
);
1719 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
1721 if (is_valid_ether_addr(deauth_mac
)) {
1722 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_STA_DEAUTH
,
1723 HostCmd_ACT_GEN_SET
, 0,
1732 mwifiex_cfg80211_set_antenna(struct wiphy
*wiphy
, u32 tx_ant
, u32 rx_ant
)
1734 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
1735 struct mwifiex_private
*priv
= mwifiex_get_priv(adapter
,
1736 MWIFIEX_BSS_ROLE_ANY
);
1737 struct mwifiex_ds_ant_cfg ant_cfg
;
1739 if (!tx_ant
|| !rx_ant
)
1742 if (adapter
->hw_dev_mcs_support
!= HT_STREAM_2X2
) {
1743 /* Not a MIMO chip. User should provide specific antenna number
1744 * for Tx/Rx path or enable all antennas for diversity
1746 if (tx_ant
!= rx_ant
)
1749 if ((tx_ant
& (tx_ant
- 1)) &&
1750 (tx_ant
!= BIT(adapter
->number_of_antenna
) - 1))
1753 if ((tx_ant
== BIT(adapter
->number_of_antenna
) - 1) &&
1754 (priv
->adapter
->number_of_antenna
> 1)) {
1755 tx_ant
= RF_ANTENNA_AUTO
;
1756 rx_ant
= RF_ANTENNA_AUTO
;
1759 struct ieee80211_sta_ht_cap
*ht_info
;
1761 enum ieee80211_band band
;
1763 if ((tx_ant
== 0x1 && rx_ant
== 0x1)) {
1764 adapter
->user_dev_mcs_support
= HT_STREAM_1X1
;
1765 if (adapter
->is_hw_11ac_capable
)
1766 adapter
->usr_dot_11ac_mcs_support
=
1767 MWIFIEX_11AC_MCS_MAP_1X1
;
1769 adapter
->user_dev_mcs_support
= HT_STREAM_2X2
;
1770 if (adapter
->is_hw_11ac_capable
)
1771 adapter
->usr_dot_11ac_mcs_support
=
1772 MWIFIEX_11AC_MCS_MAP_2X2
;
1775 for (band
= 0; band
< IEEE80211_NUM_BANDS
; band
++) {
1776 if (!adapter
->wiphy
->bands
[band
])
1779 ht_info
= &adapter
->wiphy
->bands
[band
]->ht_cap
;
1781 GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
1782 memset(&ht_info
->mcs
, 0, adapter
->number_of_antenna
);
1783 memset(&ht_info
->mcs
, 0xff, rx_mcs_supp
);
1787 ant_cfg
.tx_ant
= tx_ant
;
1788 ant_cfg
.rx_ant
= rx_ant
;
1790 return mwifiex_send_cmd(priv
, HostCmd_CMD_RF_ANTENNA
,
1791 HostCmd_ACT_GEN_SET
, 0, &ant_cfg
, true);
1794 /* cfg80211 operation handler for stop ap.
1795 * Function stops BSS running at uAP interface.
1797 static int mwifiex_cfg80211_stop_ap(struct wiphy
*wiphy
, struct net_device
*dev
)
1799 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1801 mwifiex_abort_cac(priv
);
1803 if (mwifiex_del_mgmt_ies(priv
))
1804 mwifiex_dbg(priv
->adapter
, ERROR
,
1805 "Failed to delete mgmt IEs!\n");
1807 priv
->ap_11n_enabled
= 0;
1808 memset(&priv
->bss_cfg
, 0, sizeof(priv
->bss_cfg
));
1810 if (mwifiex_send_cmd(priv
, HostCmd_CMD_UAP_BSS_STOP
,
1811 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1812 mwifiex_dbg(priv
->adapter
, ERROR
,
1813 "Failed to stop the BSS\n");
1817 if (mwifiex_send_cmd(priv
, HOST_CMD_APCMD_SYS_RESET
,
1818 HostCmd_ACT_GEN_SET
, 0, NULL
, true)) {
1819 mwifiex_dbg(priv
->adapter
, ERROR
,
1820 "Failed to reset BSS\n");
1824 if (netif_carrier_ok(priv
->netdev
))
1825 netif_carrier_off(priv
->netdev
);
1826 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
1831 /* cfg80211 operation handler for start_ap.
1832 * Function sets beacon period, DTIM period, SSID and security into
1833 * AP config structure.
1834 * AP is configured with these settings and BSS is started.
1836 static int mwifiex_cfg80211_start_ap(struct wiphy
*wiphy
,
1837 struct net_device
*dev
,
1838 struct cfg80211_ap_settings
*params
)
1840 struct mwifiex_uap_bss_param
*bss_cfg
;
1841 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1843 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_UAP
)
1846 bss_cfg
= kzalloc(sizeof(struct mwifiex_uap_bss_param
), GFP_KERNEL
);
1850 mwifiex_set_sys_config_invalid_data(bss_cfg
);
1852 if (params
->beacon_interval
)
1853 bss_cfg
->beacon_period
= params
->beacon_interval
;
1854 if (params
->dtim_period
)
1855 bss_cfg
->dtim_period
= params
->dtim_period
;
1857 if (params
->ssid
&& params
->ssid_len
) {
1858 memcpy(bss_cfg
->ssid
.ssid
, params
->ssid
, params
->ssid_len
);
1859 bss_cfg
->ssid
.ssid_len
= params
->ssid_len
;
1861 if (params
->inactivity_timeout
> 0) {
1862 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1863 bss_cfg
->sta_ao_timer
= 10 * params
->inactivity_timeout
;
1864 bss_cfg
->ps_sta_ao_timer
= 10 * params
->inactivity_timeout
;
1867 switch (params
->hidden_ssid
) {
1868 case NL80211_HIDDEN_SSID_NOT_IN_USE
:
1869 bss_cfg
->bcast_ssid_ctl
= 1;
1871 case NL80211_HIDDEN_SSID_ZERO_LEN
:
1872 bss_cfg
->bcast_ssid_ctl
= 0;
1874 case NL80211_HIDDEN_SSID_ZERO_CONTENTS
:
1875 /* firmware doesn't support this type of hidden SSID */
1881 mwifiex_uap_set_channel(priv
, bss_cfg
, params
->chandef
);
1882 mwifiex_set_uap_rates(bss_cfg
, params
);
1884 if (mwifiex_set_secure_params(priv
, bss_cfg
, params
)) {
1886 mwifiex_dbg(priv
->adapter
, ERROR
,
1887 "Failed to parse secuirty parameters!\n");
1891 mwifiex_set_ht_params(priv
, bss_cfg
, params
);
1893 if (priv
->adapter
->is_hw_11ac_capable
) {
1894 mwifiex_set_vht_params(priv
, bss_cfg
, params
);
1895 mwifiex_set_vht_width(priv
, params
->chandef
.width
,
1896 priv
->ap_11ac_enabled
);
1899 if (priv
->ap_11ac_enabled
)
1900 mwifiex_set_11ac_ba_params(priv
);
1902 mwifiex_set_ba_params(priv
);
1904 mwifiex_set_wmm_params(priv
, bss_cfg
, params
);
1906 if (mwifiex_is_11h_active(priv
))
1907 mwifiex_set_tpc_params(priv
, bss_cfg
, params
);
1909 if (mwifiex_is_11h_active(priv
) &&
1910 !cfg80211_chandef_dfs_required(wiphy
, ¶ms
->chandef
,
1912 mwifiex_dbg(priv
->adapter
, INFO
,
1913 "Disable 11h extensions in FW\n");
1914 if (mwifiex_11h_activate(priv
, false)) {
1915 mwifiex_dbg(priv
->adapter
, ERROR
,
1916 "Failed to disable 11h extensions!!");
1919 priv
->state_11h
.is_11h_active
= false;
1922 if (mwifiex_config_start_uap(priv
, bss_cfg
)) {
1923 mwifiex_dbg(priv
->adapter
, ERROR
,
1924 "Failed to start AP\n");
1929 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon
))
1932 if (!netif_carrier_ok(priv
->netdev
))
1933 netif_carrier_on(priv
->netdev
);
1934 mwifiex_wake_up_net_dev_queue(priv
->netdev
, priv
->adapter
);
1936 memcpy(&priv
->bss_cfg
, bss_cfg
, sizeof(priv
->bss_cfg
));
1942 * CFG802.11 operation handler for disconnection request.
1944 * This function does not work when there is already a disconnection
1945 * procedure going on.
1948 mwifiex_cfg80211_disconnect(struct wiphy
*wiphy
, struct net_device
*dev
,
1951 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
1953 if (mwifiex_deauthenticate(priv
, NULL
))
1956 mwifiex_dbg(priv
->adapter
, MSG
,
1957 "info: successfully disconnected from %pM:\t"
1958 "reason code %d\n", priv
->cfg_bssid
, reason_code
);
1960 eth_zero_addr(priv
->cfg_bssid
);
1961 priv
->hs2_enabled
= false;
1967 * This function informs the CFG802.11 subsystem of a new IBSS.
1969 * The following information are sent to the CFG802.11 subsystem
1970 * to register the new IBSS. If we do not register the new IBSS,
1971 * a kernel panic will result.
1977 static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private
*priv
)
1979 struct ieee80211_channel
*chan
;
1980 struct mwifiex_bss_info bss_info
;
1981 struct cfg80211_bss
*bss
;
1983 u8 ie_buf
[IEEE80211_MAX_SSID_LEN
+ sizeof(struct ieee_types_header
)];
1984 enum ieee80211_band band
;
1986 if (mwifiex_get_bss_info(priv
, &bss_info
))
1989 ie_buf
[0] = WLAN_EID_SSID
;
1990 ie_buf
[1] = bss_info
.ssid
.ssid_len
;
1992 memcpy(&ie_buf
[sizeof(struct ieee_types_header
)],
1993 &bss_info
.ssid
.ssid
, bss_info
.ssid
.ssid_len
);
1994 ie_len
= ie_buf
[1] + sizeof(struct ieee_types_header
);
1996 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
1997 chan
= __ieee80211_get_channel(priv
->wdev
.wiphy
,
1998 ieee80211_channel_to_frequency(bss_info
.bss_chan
,
2001 bss
= cfg80211_inform_bss(priv
->wdev
.wiphy
, chan
,
2002 CFG80211_BSS_FTYPE_UNKNOWN
,
2003 bss_info
.bssid
, 0, WLAN_CAPABILITY_IBSS
,
2004 0, ie_buf
, ie_len
, 0, GFP_KERNEL
);
2006 cfg80211_put_bss(priv
->wdev
.wiphy
, bss
);
2007 ether_addr_copy(priv
->cfg_bssid
, bss_info
.bssid
);
2014 * This function connects with a BSS.
2016 * This function handles both Infra and Ad-Hoc modes. It also performs
2017 * validity checking on the provided parameters, disconnects from the
2018 * current BSS (if any), sets up the association/scan parameters,
2019 * including security settings, and performs specific SSID scan before
2020 * trying to connect.
2022 * For Infra mode, the function returns failure if the specified SSID
2023 * is not found in scan table. However, for Ad-Hoc mode, it can create
2024 * the IBSS if it does not exist. On successful completion in either case,
2025 * the function notifies the CFG802.11 subsystem of the new BSS connection.
2028 mwifiex_cfg80211_assoc(struct mwifiex_private
*priv
, size_t ssid_len
,
2029 const u8
*ssid
, const u8
*bssid
, int mode
,
2030 struct ieee80211_channel
*channel
,
2031 struct cfg80211_connect_params
*sme
, bool privacy
)
2033 struct cfg80211_ssid req_ssid
;
2034 int ret
, auth_type
= 0;
2035 struct cfg80211_bss
*bss
= NULL
;
2036 u8 is_scanning_required
= 0;
2038 memset(&req_ssid
, 0, sizeof(struct cfg80211_ssid
));
2040 req_ssid
.ssid_len
= ssid_len
;
2041 if (ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2042 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2046 memcpy(req_ssid
.ssid
, ssid
, ssid_len
);
2047 if (!req_ssid
.ssid_len
|| req_ssid
.ssid
[0] < 0x20) {
2048 mwifiex_dbg(priv
->adapter
, ERROR
, "invalid SSID - aborting\n");
2052 /* As this is new association, clear locally stored
2053 * keys and security related flags */
2054 priv
->sec_info
.wpa_enabled
= false;
2055 priv
->sec_info
.wpa2_enabled
= false;
2056 priv
->wep_key_curr_index
= 0;
2057 priv
->sec_info
.encryption_mode
= 0;
2058 priv
->sec_info
.is_authtype_auto
= 0;
2059 ret
= mwifiex_set_encode(priv
, NULL
, NULL
, 0, 0, NULL
, 1);
2061 if (mode
== NL80211_IFTYPE_ADHOC
) {
2062 /* "privacy" is set only for ad-hoc mode */
2065 * Keep WLAN_CIPHER_SUITE_WEP104 for now so that
2066 * the firmware can find a matching network from the
2067 * scan. The cfg80211 does not give us the encryption
2068 * mode at this stage so just setting it to WEP here.
2070 priv
->sec_info
.encryption_mode
=
2071 WLAN_CIPHER_SUITE_WEP104
;
2072 priv
->sec_info
.authentication_mode
=
2073 NL80211_AUTHTYPE_OPEN_SYSTEM
;
2079 /* Now handle infra mode. "sme" is valid for infra mode only */
2080 if (sme
->auth_type
== NL80211_AUTHTYPE_AUTOMATIC
) {
2081 auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
2082 priv
->sec_info
.is_authtype_auto
= 1;
2084 auth_type
= sme
->auth_type
;
2087 if (sme
->crypto
.n_ciphers_pairwise
) {
2088 priv
->sec_info
.encryption_mode
=
2089 sme
->crypto
.ciphers_pairwise
[0];
2090 priv
->sec_info
.authentication_mode
= auth_type
;
2093 if (sme
->crypto
.cipher_group
) {
2094 priv
->sec_info
.encryption_mode
= sme
->crypto
.cipher_group
;
2095 priv
->sec_info
.authentication_mode
= auth_type
;
2098 ret
= mwifiex_set_gen_ie(priv
, sme
->ie
, sme
->ie_len
);
2101 if (mwifiex_is_alg_wep(priv
->sec_info
.encryption_mode
)) {
2102 mwifiex_dbg(priv
->adapter
, INFO
,
2103 "info: setting wep encryption\t"
2104 "with key len %d\n", sme
->key_len
);
2105 priv
->wep_key_curr_index
= sme
->key_idx
;
2106 ret
= mwifiex_set_encode(priv
, NULL
, sme
->key
,
2107 sme
->key_len
, sme
->key_idx
,
2113 * Scan entries are valid for some time (15 sec). So we can save one
2114 * active scan time if we just try cfg80211_get_bss first. If it fails
2115 * then request scan and cfg80211_get_bss() again for final output.
2118 if (is_scanning_required
) {
2119 /* Do specific SSID scanning */
2120 if (mwifiex_request_scan(priv
, &req_ssid
)) {
2121 mwifiex_dbg(priv
->adapter
, ERROR
, "scan error\n");
2126 /* Find the BSS we want using available scan results */
2127 if (mode
== NL80211_IFTYPE_ADHOC
)
2128 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2129 bssid
, ssid
, ssid_len
,
2130 IEEE80211_BSS_TYPE_IBSS
,
2131 IEEE80211_PRIVACY_ANY
);
2133 bss
= cfg80211_get_bss(priv
->wdev
.wiphy
, channel
,
2134 bssid
, ssid
, ssid_len
,
2135 IEEE80211_BSS_TYPE_ESS
,
2136 IEEE80211_PRIVACY_ANY
);
2139 if (is_scanning_required
) {
2140 mwifiex_dbg(priv
->adapter
, WARN
,
2141 "assoc: requested bss not found in scan results\n");
2144 is_scanning_required
= 1;
2146 mwifiex_dbg(priv
->adapter
, MSG
,
2147 "info: trying to associate to '%.*s' bssid %pM\n",
2148 req_ssid
.ssid_len
, (char *)req_ssid
.ssid
,
2150 memcpy(&priv
->cfg_bssid
, bss
->bssid
, ETH_ALEN
);
2155 ret
= mwifiex_bss_start(priv
, bss
, &req_ssid
);
2159 if (mode
== NL80211_IFTYPE_ADHOC
) {
2160 /* Inform the BSS information to kernel, otherwise
2161 * kernel will give a panic after successful assoc */
2162 if (mwifiex_cfg80211_inform_ibss_bss(priv
))
2170 * CFG802.11 operation handler for association request.
2172 * This function does not work when the current mode is set to Ad-Hoc, or
2173 * when there is already an association procedure going on. The given BSS
2174 * information is used to associate.
2177 mwifiex_cfg80211_connect(struct wiphy
*wiphy
, struct net_device
*dev
,
2178 struct cfg80211_connect_params
*sme
)
2180 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2181 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2184 if (GET_BSS_ROLE(priv
) != MWIFIEX_BSS_ROLE_STA
) {
2185 mwifiex_dbg(adapter
, ERROR
,
2186 "%s: reject infra assoc request in non-STA role\n",
2191 if (priv
->wdev
.current_bss
) {
2192 mwifiex_dbg(adapter
, ERROR
,
2193 "%s: already connected\n", dev
->name
);
2197 if (adapter
->surprise_removed
|| adapter
->is_cmd_timedout
) {
2198 mwifiex_dbg(adapter
, ERROR
,
2199 "%s: Ignore connection.\t"
2200 "Card removed or FW in bad state\n",
2205 mwifiex_dbg(adapter
, INFO
,
2206 "info: Trying to associate to %.*s and bssid %pM\n",
2207 (int)sme
->ssid_len
, (char *)sme
->ssid
, sme
->bssid
);
2209 ret
= mwifiex_cfg80211_assoc(priv
, sme
->ssid_len
, sme
->ssid
, sme
->bssid
,
2210 priv
->bss_mode
, sme
->channel
, sme
, 0);
2212 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
, NULL
, 0,
2213 NULL
, 0, WLAN_STATUS_SUCCESS
,
2215 mwifiex_dbg(priv
->adapter
, MSG
,
2216 "info: associated to bssid %pM successfully\n",
2218 if (ISSUPP_TDLS_ENABLED(priv
->adapter
->fw_cap_info
) &&
2219 priv
->adapter
->auto_tdls
&&
2220 priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
)
2221 mwifiex_setup_auto_tdls_timer(priv
);
2223 mwifiex_dbg(priv
->adapter
, ERROR
,
2224 "info: association to bssid %pM failed\n",
2226 eth_zero_addr(priv
->cfg_bssid
);
2229 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2230 NULL
, 0, NULL
, 0, ret
,
2233 cfg80211_connect_result(priv
->netdev
, priv
->cfg_bssid
,
2235 WLAN_STATUS_UNSPECIFIED_FAILURE
,
2243 * This function sets following parameters for ibss network.
2247 * - secondary channel offset
2249 static int mwifiex_set_ibss_params(struct mwifiex_private
*priv
,
2250 struct cfg80211_ibss_params
*params
)
2252 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2254 u8 config_bands
= 0;
2256 if (params
->chandef
.chan
->band
== IEEE80211_BAND_2GHZ
) {
2257 if (!params
->basic_rates
) {
2258 config_bands
= BAND_B
| BAND_G
;
2260 for (i
= 0; i
< mwifiex_band_2ghz
.n_bitrates
; i
++) {
2262 * Rates below 6 Mbps in the table are CCK
2263 * rates; 802.11b and from 6 they are OFDM;
2266 if (mwifiex_rates
[i
].bitrate
== 60) {
2272 if (params
->basic_rates
< index
) {
2273 config_bands
= BAND_B
;
2275 config_bands
= BAND_G
;
2276 if (params
->basic_rates
% index
)
2277 config_bands
|= BAND_B
;
2281 if (cfg80211_get_chandef_type(¶ms
->chandef
) !=
2283 config_bands
|= BAND_G
| BAND_GN
;
2285 if (cfg80211_get_chandef_type(¶ms
->chandef
) ==
2287 config_bands
= BAND_A
;
2289 config_bands
= BAND_AN
| BAND_A
;
2292 if (!((config_bands
| adapter
->fw_bands
) & ~adapter
->fw_bands
)) {
2293 adapter
->config_bands
= config_bands
;
2294 adapter
->adhoc_start_band
= config_bands
;
2296 if ((config_bands
& BAND_GN
) || (config_bands
& BAND_AN
))
2297 adapter
->adhoc_11n_enabled
= true;
2299 adapter
->adhoc_11n_enabled
= false;
2302 adapter
->sec_chan_offset
=
2303 mwifiex_chan_type_to_sec_chan_offset(
2304 cfg80211_get_chandef_type(¶ms
->chandef
));
2305 priv
->adhoc_channel
= ieee80211_frequency_to_channel(
2306 params
->chandef
.chan
->center_freq
);
2308 mwifiex_dbg(adapter
, INFO
,
2309 "info: set ibss band %d, chan %d, chan offset %d\n",
2310 config_bands
, priv
->adhoc_channel
,
2311 adapter
->sec_chan_offset
);
2317 * CFG802.11 operation handler to join an IBSS.
2319 * This function does not work in any mode other than Ad-Hoc, or if
2320 * a join operation is already in progress.
2323 mwifiex_cfg80211_join_ibss(struct wiphy
*wiphy
, struct net_device
*dev
,
2324 struct cfg80211_ibss_params
*params
)
2326 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2329 if (priv
->bss_mode
!= NL80211_IFTYPE_ADHOC
) {
2330 mwifiex_dbg(priv
->adapter
, ERROR
,
2331 "request to join ibss received\t"
2332 "when station is not in ibss mode\n");
2336 mwifiex_dbg(priv
->adapter
, MSG
,
2337 "info: trying to join to %.*s and bssid %pM\n",
2338 params
->ssid_len
, (char *)params
->ssid
, params
->bssid
);
2340 mwifiex_set_ibss_params(priv
, params
);
2342 ret
= mwifiex_cfg80211_assoc(priv
, params
->ssid_len
, params
->ssid
,
2343 params
->bssid
, priv
->bss_mode
,
2344 params
->chandef
.chan
, NULL
,
2348 cfg80211_ibss_joined(priv
->netdev
, priv
->cfg_bssid
,
2349 params
->chandef
.chan
, GFP_KERNEL
);
2350 mwifiex_dbg(priv
->adapter
, MSG
,
2351 "info: joined/created adhoc network with bssid\t"
2352 "%pM successfully\n", priv
->cfg_bssid
);
2354 mwifiex_dbg(priv
->adapter
, ERROR
,
2355 "info: failed creating/joining adhoc network\n");
2362 * CFG802.11 operation handler to leave an IBSS.
2364 * This function does not work if a leave operation is
2365 * already in progress.
2368 mwifiex_cfg80211_leave_ibss(struct wiphy
*wiphy
, struct net_device
*dev
)
2370 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2372 mwifiex_dbg(priv
->adapter
, MSG
, "info: disconnecting from essid %pM\n",
2374 if (mwifiex_deauthenticate(priv
, NULL
))
2377 eth_zero_addr(priv
->cfg_bssid
);
2383 * CFG802.11 operation handler for scan request.
2385 * This function issues a scan request to the firmware based upon
2386 * the user specified scan configuration. On successful completion,
2387 * it also informs the results.
2390 mwifiex_cfg80211_scan(struct wiphy
*wiphy
,
2391 struct cfg80211_scan_request
*request
)
2393 struct net_device
*dev
= request
->wdev
->netdev
;
2394 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
2396 struct ieee80211_channel
*chan
;
2397 struct ieee_types_header
*ie
;
2398 struct mwifiex_user_scan_cfg
*user_scan_cfg
;
2400 mwifiex_dbg(priv
->adapter
, CMD
,
2401 "info: received scan request on %s\n", dev
->name
);
2403 /* Block scan request if scan operation or scan cleanup when interface
2404 * is disabled is in process
2406 if (priv
->scan_request
|| priv
->scan_aborting
) {
2407 mwifiex_dbg(priv
->adapter
, WARN
,
2408 "cmd: Scan already in process..\n");
2412 user_scan_cfg
= kzalloc(sizeof(*user_scan_cfg
), GFP_KERNEL
);
2416 priv
->scan_request
= request
;
2418 user_scan_cfg
->num_ssids
= request
->n_ssids
;
2419 user_scan_cfg
->ssid_list
= request
->ssids
;
2421 if (request
->ie
&& request
->ie_len
) {
2423 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2424 if (priv
->vs_ie
[i
].mask
!= MWIFIEX_VSIE_MASK_CLEAR
)
2426 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_SCAN
;
2427 ie
= (struct ieee_types_header
*)(request
->ie
+ offset
);
2428 memcpy(&priv
->vs_ie
[i
].ie
, ie
, sizeof(*ie
) + ie
->len
);
2429 offset
+= sizeof(*ie
) + ie
->len
;
2431 if (offset
>= request
->ie_len
)
2436 for (i
= 0; i
< min_t(u32
, request
->n_channels
,
2437 MWIFIEX_USER_SCAN_CHAN_MAX
); i
++) {
2438 chan
= request
->channels
[i
];
2439 user_scan_cfg
->chan_list
[i
].chan_number
= chan
->hw_value
;
2440 user_scan_cfg
->chan_list
[i
].radio_type
= chan
->band
;
2442 if ((chan
->flags
& IEEE80211_CHAN_NO_IR
) || !request
->n_ssids
)
2443 user_scan_cfg
->chan_list
[i
].scan_type
=
2444 MWIFIEX_SCAN_TYPE_PASSIVE
;
2446 user_scan_cfg
->chan_list
[i
].scan_type
=
2447 MWIFIEX_SCAN_TYPE_ACTIVE
;
2449 user_scan_cfg
->chan_list
[i
].scan_time
= 0;
2452 if (priv
->adapter
->scan_chan_gap_enabled
&&
2453 mwifiex_is_any_intf_active(priv
))
2454 user_scan_cfg
->scan_chan_gap
=
2455 priv
->adapter
->scan_chan_gap_time
;
2457 ret
= mwifiex_scan_networks(priv
, user_scan_cfg
);
2458 kfree(user_scan_cfg
);
2460 mwifiex_dbg(priv
->adapter
, ERROR
,
2461 "scan failed: %d\n", ret
);
2462 priv
->scan_aborting
= false;
2463 priv
->scan_request
= NULL
;
2467 if (request
->ie
&& request
->ie_len
) {
2468 for (i
= 0; i
< MWIFIEX_MAX_VSIE_NUM
; i
++) {
2469 if (priv
->vs_ie
[i
].mask
== MWIFIEX_VSIE_MASK_SCAN
) {
2470 priv
->vs_ie
[i
].mask
= MWIFIEX_VSIE_MASK_CLEAR
;
2471 memset(&priv
->vs_ie
[i
].ie
, 0,
2472 MWIFIEX_MAX_VSIE_LEN
);
2479 static void mwifiex_setup_vht_caps(struct ieee80211_sta_vht_cap
*vht_info
,
2480 struct mwifiex_private
*priv
)
2482 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2484 vht_info
->vht_supported
= true;
2486 vht_info
->cap
= adapter
->hw_dot_11ac_dev_cap
;
2487 /* Update MCS support for VHT */
2488 vht_info
->vht_mcs
.rx_mcs_map
= cpu_to_le16(
2489 adapter
->hw_dot_11ac_mcs_support
& 0xFFFF);
2490 vht_info
->vht_mcs
.rx_highest
= 0;
2491 vht_info
->vht_mcs
.tx_mcs_map
= cpu_to_le16(
2492 adapter
->hw_dot_11ac_mcs_support
>> 16);
2493 vht_info
->vht_mcs
.tx_highest
= 0;
2497 * This function sets up the CFG802.11 specific HT capability fields
2498 * with default values.
2500 * The following default values are set -
2501 * - HT Supported = True
2502 * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K
2503 * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE
2504 * - HT Capabilities supported by firmware
2505 * - MCS information, Rx mask = 0xff
2506 * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01)
2509 mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap
*ht_info
,
2510 struct mwifiex_private
*priv
)
2513 struct ieee80211_mcs_info mcs_set
;
2514 u8
*mcs
= (u8
*)&mcs_set
;
2515 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2517 ht_info
->ht_supported
= true;
2518 ht_info
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
2519 ht_info
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
2521 memset(&ht_info
->mcs
, 0, sizeof(ht_info
->mcs
));
2523 /* Fill HT capability information */
2524 if (ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2525 ht_info
->cap
|= IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2527 ht_info
->cap
&= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
2529 if (ISSUPP_SHORTGI20(adapter
->hw_dot_11n_dev_cap
))
2530 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_20
;
2532 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_20
;
2534 if (ISSUPP_SHORTGI40(adapter
->hw_dot_11n_dev_cap
))
2535 ht_info
->cap
|= IEEE80211_HT_CAP_SGI_40
;
2537 ht_info
->cap
&= ~IEEE80211_HT_CAP_SGI_40
;
2539 if (adapter
->user_dev_mcs_support
== HT_STREAM_2X2
)
2540 ht_info
->cap
|= 3 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2542 ht_info
->cap
|= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT
;
2544 if (ISSUPP_TXSTBC(adapter
->hw_dot_11n_dev_cap
))
2545 ht_info
->cap
|= IEEE80211_HT_CAP_TX_STBC
;
2547 ht_info
->cap
&= ~IEEE80211_HT_CAP_TX_STBC
;
2549 if (ISSUPP_GREENFIELD(adapter
->hw_dot_11n_dev_cap
))
2550 ht_info
->cap
|= IEEE80211_HT_CAP_GRN_FLD
;
2552 ht_info
->cap
&= ~IEEE80211_HT_CAP_GRN_FLD
;
2554 if (ISENABLED_40MHZ_INTOLERANT(adapter
->hw_dot_11n_dev_cap
))
2555 ht_info
->cap
|= IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2557 ht_info
->cap
&= ~IEEE80211_HT_CAP_40MHZ_INTOLERANT
;
2559 if (ISSUPP_RXLDPC(adapter
->hw_dot_11n_dev_cap
))
2560 ht_info
->cap
|= IEEE80211_HT_CAP_LDPC_CODING
;
2562 ht_info
->cap
&= ~IEEE80211_HT_CAP_LDPC_CODING
;
2564 ht_info
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
2565 ht_info
->cap
|= IEEE80211_HT_CAP_SM_PS
;
2567 rx_mcs_supp
= GET_RXMCSSUPP(adapter
->user_dev_mcs_support
);
2568 /* Set MCS for 1x1/2x2 */
2569 memset(mcs
, 0xff, rx_mcs_supp
);
2570 /* Clear all the other values */
2571 memset(&mcs
[rx_mcs_supp
], 0,
2572 sizeof(struct ieee80211_mcs_info
) - rx_mcs_supp
);
2573 if (priv
->bss_mode
== NL80211_IFTYPE_STATION
||
2574 ISSUPP_CHANWIDTH40(adapter
->hw_dot_11n_dev_cap
))
2575 /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
2576 SETHT_MCS32(mcs_set
.rx_mask
);
2578 memcpy((u8
*) &ht_info
->mcs
, mcs
, sizeof(struct ieee80211_mcs_info
));
2580 ht_info
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
2584 * create a new virtual interface with the given name and name assign type
2586 struct wireless_dev
*mwifiex_add_virtual_intf(struct wiphy
*wiphy
,
2588 unsigned char name_assign_type
,
2589 enum nl80211_iftype type
,
2591 struct vif_params
*params
)
2593 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
2594 struct mwifiex_private
*priv
;
2595 struct net_device
*dev
;
2599 return ERR_PTR(-EFAULT
);
2602 case NL80211_IFTYPE_UNSPECIFIED
:
2603 case NL80211_IFTYPE_STATION
:
2604 case NL80211_IFTYPE_ADHOC
:
2605 if (adapter
->curr_iface_comb
.sta_intf
==
2606 adapter
->iface_limit
.sta_intf
) {
2607 mwifiex_dbg(adapter
, ERROR
,
2608 "cannot create multiple sta/adhoc ifaces\n");
2609 return ERR_PTR(-EINVAL
);
2612 priv
= mwifiex_get_unused_priv(adapter
);
2614 mwifiex_dbg(adapter
, ERROR
,
2615 "could not get free private struct\n");
2616 return ERR_PTR(-EFAULT
);
2619 priv
->wdev
.wiphy
= wiphy
;
2620 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2622 if (type
== NL80211_IFTYPE_UNSPECIFIED
)
2623 priv
->bss_mode
= NL80211_IFTYPE_STATION
;
2625 priv
->bss_mode
= type
;
2627 priv
->bss_type
= MWIFIEX_BSS_TYPE_STA
;
2628 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2629 priv
->bss_priority
= 0;
2630 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2631 priv
->bss_num
= adapter
->curr_iface_comb
.sta_intf
;
2634 case NL80211_IFTYPE_AP
:
2635 if (adapter
->curr_iface_comb
.uap_intf
==
2636 adapter
->iface_limit
.uap_intf
) {
2637 mwifiex_dbg(adapter
, ERROR
,
2638 "cannot create multiple AP ifaces\n");
2639 return ERR_PTR(-EINVAL
);
2642 priv
= mwifiex_get_unused_priv(adapter
);
2644 mwifiex_dbg(adapter
, ERROR
,
2645 "could not get free private struct\n");
2646 return ERR_PTR(-EFAULT
);
2649 priv
->wdev
.wiphy
= wiphy
;
2650 priv
->wdev
.iftype
= NL80211_IFTYPE_AP
;
2652 priv
->bss_type
= MWIFIEX_BSS_TYPE_UAP
;
2653 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2654 priv
->bss_priority
= 0;
2655 priv
->bss_role
= MWIFIEX_BSS_ROLE_UAP
;
2656 priv
->bss_started
= 0;
2657 priv
->bss_num
= adapter
->curr_iface_comb
.uap_intf
;
2658 priv
->bss_mode
= type
;
2661 case NL80211_IFTYPE_P2P_CLIENT
:
2662 if (adapter
->curr_iface_comb
.p2p_intf
==
2663 adapter
->iface_limit
.p2p_intf
) {
2664 mwifiex_dbg(adapter
, ERROR
,
2665 "cannot create multiple P2P ifaces\n");
2666 return ERR_PTR(-EINVAL
);
2669 priv
= mwifiex_get_unused_priv(adapter
);
2671 mwifiex_dbg(adapter
, ERROR
,
2672 "could not get free private struct\n");
2673 return ERR_PTR(-EFAULT
);
2676 priv
->wdev
.wiphy
= wiphy
;
2677 /* At start-up, wpa_supplicant tries to change the interface
2678 * to NL80211_IFTYPE_STATION if it is not managed mode.
2680 priv
->wdev
.iftype
= NL80211_IFTYPE_P2P_CLIENT
;
2681 priv
->bss_mode
= NL80211_IFTYPE_P2P_CLIENT
;
2683 /* Setting bss_type to P2P tells firmware that this interface
2684 * is receiving P2P peers found during find phase and doing
2685 * action frame handshake.
2687 priv
->bss_type
= MWIFIEX_BSS_TYPE_P2P
;
2689 priv
->frame_type
= MWIFIEX_DATA_FRAME_TYPE_ETH_II
;
2690 priv
->bss_priority
= MWIFIEX_BSS_ROLE_STA
;
2691 priv
->bss_role
= MWIFIEX_BSS_ROLE_STA
;
2692 priv
->bss_started
= 0;
2693 priv
->bss_num
= adapter
->curr_iface_comb
.p2p_intf
;
2695 if (mwifiex_cfg80211_init_p2p_client(priv
)) {
2696 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2697 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2698 return ERR_PTR(-EFAULT
);
2703 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2704 return ERR_PTR(-EINVAL
);
2707 dev
= alloc_netdev_mqs(sizeof(struct mwifiex_private
*), name
,
2708 name_assign_type
, ether_setup
,
2709 IEEE80211_NUM_ACS
, 1);
2711 mwifiex_dbg(adapter
, ERROR
,
2712 "no memory available for netdevice\n");
2713 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2714 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2715 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2716 return ERR_PTR(-ENOMEM
);
2719 mwifiex_init_priv_params(priv
, dev
);
2722 mwifiex_setup_ht_caps(&wiphy
->bands
[IEEE80211_BAND_2GHZ
]->ht_cap
, priv
);
2723 if (adapter
->is_hw_11ac_capable
)
2724 mwifiex_setup_vht_caps(
2725 &wiphy
->bands
[IEEE80211_BAND_2GHZ
]->vht_cap
, priv
);
2727 if (adapter
->config_bands
& BAND_A
)
2728 mwifiex_setup_ht_caps(
2729 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->ht_cap
, priv
);
2731 if ((adapter
->config_bands
& BAND_A
) && adapter
->is_hw_11ac_capable
)
2732 mwifiex_setup_vht_caps(
2733 &wiphy
->bands
[IEEE80211_BAND_5GHZ
]->vht_cap
, priv
);
2735 dev_net_set(dev
, wiphy_net(wiphy
));
2736 dev
->ieee80211_ptr
= &priv
->wdev
;
2737 dev
->ieee80211_ptr
->iftype
= priv
->bss_mode
;
2738 memcpy(dev
->dev_addr
, wiphy
->perm_addr
, ETH_ALEN
);
2739 SET_NETDEV_DEV(dev
, wiphy_dev(wiphy
));
2741 dev
->flags
|= IFF_BROADCAST
| IFF_MULTICAST
;
2742 dev
->watchdog_timeo
= MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT
;
2743 dev
->hard_header_len
+= MWIFIEX_MIN_DATA_HEADER_LEN
;
2744 dev
->ethtool_ops
= &mwifiex_ethtool_ops
;
2746 mdev_priv
= netdev_priv(dev
);
2747 *((unsigned long *) mdev_priv
) = (unsigned long) priv
;
2749 SET_NETDEV_DEV(dev
, adapter
->dev
);
2751 /* Register network device */
2752 if (register_netdevice(dev
)) {
2753 mwifiex_dbg(adapter
, ERROR
,
2754 "cannot register virtual network device\n");
2756 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2757 priv
->netdev
= NULL
;
2758 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2759 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2760 return ERR_PTR(-EFAULT
);
2763 priv
->dfs_cac_workqueue
= alloc_workqueue("MWIFIEX_DFS_CAC%s",
2766 WQ_UNBOUND
, 1, name
);
2767 if (!priv
->dfs_cac_workqueue
) {
2768 mwifiex_dbg(adapter
, ERROR
,
2769 "cannot register virtual network device\n");
2771 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2772 priv
->netdev
= NULL
;
2773 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2774 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2775 return ERR_PTR(-ENOMEM
);
2778 INIT_DELAYED_WORK(&priv
->dfs_cac_work
, mwifiex_dfs_cac_work_queue
);
2780 priv
->dfs_chan_sw_workqueue
= alloc_workqueue("MWIFIEX_DFS_CHSW%s",
2781 WQ_HIGHPRI
| WQ_UNBOUND
|
2782 WQ_MEM_RECLAIM
, 1, name
);
2783 if (!priv
->dfs_chan_sw_workqueue
) {
2784 mwifiex_dbg(adapter
, ERROR
,
2785 "cannot register virtual network device\n");
2787 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2788 priv
->netdev
= NULL
;
2789 memset(&priv
->wdev
, 0, sizeof(priv
->wdev
));
2790 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2791 return ERR_PTR(-ENOMEM
);
2794 INIT_DELAYED_WORK(&priv
->dfs_chan_sw_work
,
2795 mwifiex_dfs_chan_sw_work_queue
);
2797 sema_init(&priv
->async_sem
, 1);
2799 mwifiex_dbg(adapter
, INFO
,
2800 "info: %s: Marvell 802.11 Adapter\n", dev
->name
);
2802 #ifdef CONFIG_DEBUG_FS
2803 mwifiex_dev_debugfs_init(priv
);
2807 case NL80211_IFTYPE_UNSPECIFIED
:
2808 case NL80211_IFTYPE_STATION
:
2809 case NL80211_IFTYPE_ADHOC
:
2810 adapter
->curr_iface_comb
.sta_intf
++;
2812 case NL80211_IFTYPE_AP
:
2813 adapter
->curr_iface_comb
.uap_intf
++;
2815 case NL80211_IFTYPE_P2P_CLIENT
:
2816 adapter
->curr_iface_comb
.p2p_intf
++;
2819 mwifiex_dbg(adapter
, ERROR
, "type not supported\n");
2820 return ERR_PTR(-EINVAL
);
2825 EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf
);
2828 * del_virtual_intf: remove the virtual interface determined by dev
2830 int mwifiex_del_virtual_intf(struct wiphy
*wiphy
, struct wireless_dev
*wdev
)
2832 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
2833 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2834 struct sk_buff
*skb
, *tmp
;
2836 #ifdef CONFIG_DEBUG_FS
2837 mwifiex_dev_debugfs_remove(priv
);
2840 mwifiex_stop_net_dev_queue(priv
->netdev
, adapter
);
2842 skb_queue_walk_safe(&priv
->bypass_txq
, skb
, tmp
)
2843 mwifiex_write_data_complete(priv
->adapter
, skb
, 0, -1);
2845 if (netif_carrier_ok(priv
->netdev
))
2846 netif_carrier_off(priv
->netdev
);
2848 if (wdev
->netdev
->reg_state
== NETREG_REGISTERED
)
2849 unregister_netdevice(wdev
->netdev
);
2851 if (priv
->dfs_cac_workqueue
) {
2852 flush_workqueue(priv
->dfs_cac_workqueue
);
2853 destroy_workqueue(priv
->dfs_cac_workqueue
);
2854 priv
->dfs_cac_workqueue
= NULL
;
2857 if (priv
->dfs_chan_sw_workqueue
) {
2858 flush_workqueue(priv
->dfs_chan_sw_workqueue
);
2859 destroy_workqueue(priv
->dfs_chan_sw_workqueue
);
2860 priv
->dfs_chan_sw_workqueue
= NULL
;
2862 /* Clear the priv in adapter */
2863 priv
->netdev
->ieee80211_ptr
= NULL
;
2864 priv
->netdev
= NULL
;
2865 priv
->wdev
.iftype
= NL80211_IFTYPE_UNSPECIFIED
;
2867 priv
->media_connected
= false;
2869 switch (priv
->bss_mode
) {
2870 case NL80211_IFTYPE_UNSPECIFIED
:
2871 case NL80211_IFTYPE_STATION
:
2872 case NL80211_IFTYPE_ADHOC
:
2873 adapter
->curr_iface_comb
.sta_intf
--;
2875 case NL80211_IFTYPE_AP
:
2876 adapter
->curr_iface_comb
.uap_intf
--;
2878 case NL80211_IFTYPE_P2P_CLIENT
:
2879 case NL80211_IFTYPE_P2P_GO
:
2880 adapter
->curr_iface_comb
.p2p_intf
--;
2883 mwifiex_dbg(adapter
, ERROR
,
2884 "del_virtual_intf: type not supported\n");
2888 priv
->bss_mode
= NL80211_IFTYPE_UNSPECIFIED
;
2890 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_STA
||
2891 GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
)
2892 kfree(priv
->hist_data
);
2896 EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf
);
2899 mwifiex_is_pattern_supported(struct cfg80211_pkt_pattern
*pat
, s8
*byte_seq
,
2902 int j
, k
, valid_byte_cnt
= 0;
2903 bool dont_care_byte
= false;
2905 for (j
= 0; j
< DIV_ROUND_UP(pat
->pattern_len
, 8); j
++) {
2906 for (k
= 0; k
< 8; k
++) {
2907 if (pat
->mask
[j
] & 1 << k
) {
2908 memcpy(byte_seq
+ valid_byte_cnt
,
2909 &pat
->pattern
[j
* 8 + k
], 1);
2915 dont_care_byte
= true;
2918 if (valid_byte_cnt
> max_byte_seq
)
2923 byte_seq
[max_byte_seq
] = valid_byte_cnt
;
2929 static void mwifiex_set_auto_arp_mef_entry(struct mwifiex_private
*priv
,
2930 struct mwifiex_mef_entry
*mef_entry
)
2932 int i
, filt_num
= 0, num_ipv4
= 0;
2933 struct in_device
*in_dev
;
2934 struct in_ifaddr
*ifa
;
2935 __be32 ips
[MWIFIEX_MAX_SUPPORTED_IPADDR
];
2936 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2938 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2939 mef_entry
->action
= MEF_ACTION_AUTO_ARP
;
2941 /* Enable ARP offload feature */
2942 memset(ips
, 0, sizeof(ips
));
2943 for (i
= 0; i
< MWIFIEX_MAX_BSS_NUM
; i
++) {
2944 if (adapter
->priv
[i
]->netdev
) {
2945 in_dev
= __in_dev_get_rtnl(adapter
->priv
[i
]->netdev
);
2948 ifa
= in_dev
->ifa_list
;
2949 if (!ifa
|| !ifa
->ifa_local
)
2951 ips
[i
] = ifa
->ifa_local
;
2956 for (i
= 0; i
< num_ipv4
; i
++) {
2959 mef_entry
->filter
[filt_num
].repeat
= 1;
2960 memcpy(mef_entry
->filter
[filt_num
].byte_seq
,
2961 (u8
*)&ips
[i
], sizeof(ips
[i
]));
2962 mef_entry
->filter
[filt_num
].
2963 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
2965 mef_entry
->filter
[filt_num
].offset
= 46;
2966 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2968 mef_entry
->filter
[filt_num
].filt_action
=
2974 mef_entry
->filter
[filt_num
].repeat
= 1;
2975 mef_entry
->filter
[filt_num
].byte_seq
[0] = 0x08;
2976 mef_entry
->filter
[filt_num
].byte_seq
[1] = 0x06;
2977 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] = 2;
2978 mef_entry
->filter
[filt_num
].offset
= 20;
2979 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
2980 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
2983 static int mwifiex_set_wowlan_mef_entry(struct mwifiex_private
*priv
,
2984 struct mwifiex_ds_mef_cfg
*mef_cfg
,
2985 struct mwifiex_mef_entry
*mef_entry
,
2986 struct cfg80211_wowlan
*wowlan
)
2988 int i
, filt_num
= 0, ret
= 0;
2989 bool first_pat
= true;
2990 u8 byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
+ 1];
2991 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
2992 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
2994 mef_entry
->mode
= MEF_MODE_HOST_SLEEP
;
2995 mef_entry
->action
= MEF_ACTION_ALLOW_AND_WAKEUP_HOST
;
2997 for (i
= 0; i
< wowlan
->n_patterns
; i
++) {
2998 memset(byte_seq
, 0, sizeof(byte_seq
));
2999 if (!mwifiex_is_pattern_supported(&wowlan
->patterns
[i
],
3001 MWIFIEX_MEF_MAX_BYTESEQ
)) {
3002 mwifiex_dbg(priv
->adapter
, ERROR
,
3003 "Pattern not supported\n");
3007 if (!wowlan
->patterns
[i
].pkt_offset
) {
3008 if (!(byte_seq
[0] & 0x01) &&
3009 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 1)) {
3010 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3012 } else if (is_broadcast_ether_addr(byte_seq
)) {
3013 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_BROADCAST
;
3015 } else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3016 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 2)) ||
3017 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3018 (byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] == 3))) {
3019 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_MULTICAST
;
3023 mef_entry
->filter
[filt_num
].repeat
= 1;
3024 mef_entry
->filter
[filt_num
].offset
=
3025 wowlan
->patterns
[i
].pkt_offset
;
3026 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, byte_seq
,
3028 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3033 mef_entry
->filter
[filt_num
].filt_action
= TYPE_AND
;
3038 if (wowlan
->magic_pkt
) {
3039 mef_cfg
->criteria
|= MWIFIEX_CRITERIA_UNICAST
;
3040 mef_entry
->filter
[filt_num
].repeat
= 16;
3041 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3043 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3045 mef_entry
->filter
[filt_num
].offset
= 28;
3046 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3048 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3051 mef_entry
->filter
[filt_num
].repeat
= 16;
3052 memcpy(mef_entry
->filter
[filt_num
].byte_seq
, priv
->curr_addr
,
3054 mef_entry
->filter
[filt_num
].byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
] =
3056 mef_entry
->filter
[filt_num
].offset
= 56;
3057 mef_entry
->filter
[filt_num
].filt_type
= TYPE_EQ
;
3058 mef_entry
->filter
[filt_num
].filt_action
= TYPE_OR
;
3063 static int mwifiex_set_mef_filter(struct mwifiex_private
*priv
,
3064 struct cfg80211_wowlan
*wowlan
)
3066 int ret
= 0, num_entries
= 1;
3067 struct mwifiex_ds_mef_cfg mef_cfg
;
3068 struct mwifiex_mef_entry
*mef_entry
;
3070 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
)
3073 mef_entry
= kcalloc(num_entries
, sizeof(*mef_entry
), GFP_KERNEL
);
3077 memset(&mef_cfg
, 0, sizeof(mef_cfg
));
3078 mef_cfg
.criteria
|= MWIFIEX_CRITERIA_BROADCAST
|
3079 MWIFIEX_CRITERIA_UNICAST
;
3080 mef_cfg
.num_entries
= num_entries
;
3081 mef_cfg
.mef_entry
= mef_entry
;
3083 mwifiex_set_auto_arp_mef_entry(priv
, &mef_entry
[0]);
3085 if (wowlan
->n_patterns
|| wowlan
->magic_pkt
) {
3086 ret
= mwifiex_set_wowlan_mef_entry(priv
, &mef_cfg
,
3087 &mef_entry
[1], wowlan
);
3092 if (!mef_cfg
.criteria
)
3093 mef_cfg
.criteria
= MWIFIEX_CRITERIA_BROADCAST
|
3094 MWIFIEX_CRITERIA_UNICAST
|
3095 MWIFIEX_CRITERIA_MULTICAST
;
3097 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MEF_CFG
,
3098 HostCmd_ACT_GEN_SET
, 0,
3106 static int mwifiex_cfg80211_suspend(struct wiphy
*wiphy
,
3107 struct cfg80211_wowlan
*wowlan
)
3109 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3110 struct mwifiex_ds_hs_cfg hs_cfg
;
3112 struct mwifiex_private
*priv
;
3114 for (i
= 0; i
< adapter
->priv_num
; i
++) {
3115 priv
= adapter
->priv
[i
];
3116 mwifiex_abort_cac(priv
);
3119 mwifiex_cancel_all_pending_cmd(adapter
);
3122 mwifiex_dbg(adapter
, ERROR
,
3123 "None of the WOWLAN triggers enabled\n");
3127 priv
= mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3129 if (!priv
->media_connected
) {
3130 mwifiex_dbg(adapter
, ERROR
,
3131 "Can not configure WOWLAN in disconnected state\n");
3135 ret
= mwifiex_set_mef_filter(priv
, wowlan
);
3137 mwifiex_dbg(adapter
, ERROR
, "Failed to set MEF filter\n");
3141 if (wowlan
->disconnect
) {
3142 memset(&hs_cfg
, 0, sizeof(hs_cfg
));
3143 hs_cfg
.is_invoke_hostcmd
= false;
3144 hs_cfg
.conditions
= HS_CFG_COND_MAC_EVENT
;
3145 hs_cfg
.gpio
= HS_CFG_GPIO_DEF
;
3146 hs_cfg
.gap
= HS_CFG_GAP_DEF
;
3147 ret
= mwifiex_set_hs_params(priv
, HostCmd_ACT_GEN_SET
,
3148 MWIFIEX_SYNC_CMD
, &hs_cfg
);
3150 mwifiex_dbg(adapter
, ERROR
,
3151 "Failed to set HS params\n");
3159 static int mwifiex_cfg80211_resume(struct wiphy
*wiphy
)
3164 static void mwifiex_cfg80211_set_wakeup(struct wiphy
*wiphy
,
3167 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3169 device_set_wakeup_enable(adapter
->dev
, enabled
);
3173 static int mwifiex_get_coalesce_pkt_type(u8
*byte_seq
)
3175 const u8 ipv4_mc_mac
[] = {0x33, 0x33};
3176 const u8 ipv6_mc_mac
[] = {0x01, 0x00, 0x5e};
3177 const u8 bc_mac
[] = {0xff, 0xff, 0xff, 0xff};
3179 if ((byte_seq
[0] & 0x01) &&
3180 (byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 1))
3181 return PACKET_TYPE_UNICAST
;
3182 else if (!memcmp(byte_seq
, bc_mac
, 4))
3183 return PACKET_TYPE_BROADCAST
;
3184 else if ((!memcmp(byte_seq
, ipv4_mc_mac
, 2) &&
3185 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 2) ||
3186 (!memcmp(byte_seq
, ipv6_mc_mac
, 3) &&
3187 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
] == 3))
3188 return PACKET_TYPE_MULTICAST
;
3194 mwifiex_fill_coalesce_rule_info(struct mwifiex_private
*priv
,
3195 struct cfg80211_coalesce_rules
*crule
,
3196 struct mwifiex_coalesce_rule
*mrule
)
3198 u8 byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
+ 1];
3199 struct filt_field_param
*param
;
3202 mrule
->max_coalescing_delay
= crule
->delay
;
3204 param
= mrule
->params
;
3206 for (i
= 0; i
< crule
->n_patterns
; i
++) {
3207 memset(byte_seq
, 0, sizeof(byte_seq
));
3208 if (!mwifiex_is_pattern_supported(&crule
->patterns
[i
],
3210 MWIFIEX_COALESCE_MAX_BYTESEQ
)) {
3211 mwifiex_dbg(priv
->adapter
, ERROR
,
3212 "Pattern not supported\n");
3216 if (!crule
->patterns
[i
].pkt_offset
) {
3219 pkt_type
= mwifiex_get_coalesce_pkt_type(byte_seq
);
3220 if (pkt_type
&& mrule
->pkt_type
) {
3221 mwifiex_dbg(priv
->adapter
, ERROR
,
3222 "Multiple packet types not allowed\n");
3224 } else if (pkt_type
) {
3225 mrule
->pkt_type
= pkt_type
;
3230 if (crule
->condition
== NL80211_COALESCE_CONDITION_MATCH
)
3231 param
->operation
= RECV_FILTER_MATCH_TYPE_EQ
;
3233 param
->operation
= RECV_FILTER_MATCH_TYPE_NE
;
3235 param
->operand_len
= byte_seq
[MWIFIEX_COALESCE_MAX_BYTESEQ
];
3236 memcpy(param
->operand_byte_stream
, byte_seq
,
3237 param
->operand_len
);
3238 param
->offset
= crule
->patterns
[i
].pkt_offset
;
3241 mrule
->num_of_fields
++;
3244 if (!mrule
->pkt_type
) {
3245 mwifiex_dbg(priv
->adapter
, ERROR
,
3246 "Packet type can not be determined\n");
3253 static int mwifiex_cfg80211_set_coalesce(struct wiphy
*wiphy
,
3254 struct cfg80211_coalesce
*coalesce
)
3256 struct mwifiex_adapter
*adapter
= mwifiex_cfg80211_get_adapter(wiphy
);
3258 struct mwifiex_ds_coalesce_cfg coalesce_cfg
;
3259 struct mwifiex_private
*priv
=
3260 mwifiex_get_priv(adapter
, MWIFIEX_BSS_ROLE_STA
);
3262 memset(&coalesce_cfg
, 0, sizeof(coalesce_cfg
));
3264 mwifiex_dbg(adapter
, WARN
,
3265 "Disable coalesce and reset all previous rules\n");
3266 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3267 HostCmd_ACT_GEN_SET
, 0,
3268 &coalesce_cfg
, true);
3271 coalesce_cfg
.num_of_rules
= coalesce
->n_rules
;
3272 for (i
= 0; i
< coalesce
->n_rules
; i
++) {
3273 ret
= mwifiex_fill_coalesce_rule_info(priv
, &coalesce
->rules
[i
],
3274 &coalesce_cfg
.rule
[i
]);
3276 mwifiex_dbg(adapter
, ERROR
,
3277 "Recheck the patterns provided for rule %d\n",
3283 return mwifiex_send_cmd(priv
, HostCmd_CMD_COALESCE_CFG
,
3284 HostCmd_ACT_GEN_SET
, 0, &coalesce_cfg
, true);
3287 /* cfg80211 ops handler for tdls_mgmt.
3288 * Function prepares TDLS action frame packets and forwards them to FW
3291 mwifiex_cfg80211_tdls_mgmt(struct wiphy
*wiphy
, struct net_device
*dev
,
3292 const u8
*peer
, u8 action_code
, u8 dialog_token
,
3293 u16 status_code
, u32 peer_capability
,
3294 bool initiator
, const u8
*extra_ies
,
3295 size_t extra_ies_len
)
3297 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3300 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
))
3303 /* make sure we are in station mode and connected */
3304 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3307 switch (action_code
) {
3308 case WLAN_TDLS_SETUP_REQUEST
:
3309 mwifiex_dbg(priv
->adapter
, MSG
,
3310 "Send TDLS Setup Request to %pM status_code=%d\n",
3312 mwifiex_add_auto_tdls_peer(priv
, peer
);
3313 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3314 dialog_token
, status_code
,
3315 extra_ies
, extra_ies_len
);
3317 case WLAN_TDLS_SETUP_RESPONSE
:
3318 mwifiex_add_auto_tdls_peer(priv
, peer
);
3319 mwifiex_dbg(priv
->adapter
, MSG
,
3320 "Send TDLS Setup Response to %pM status_code=%d\n",
3322 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3323 dialog_token
, status_code
,
3324 extra_ies
, extra_ies_len
);
3326 case WLAN_TDLS_SETUP_CONFIRM
:
3327 mwifiex_dbg(priv
->adapter
, MSG
,
3328 "Send TDLS Confirm to %pM status_code=%d\n", peer
,
3330 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3331 dialog_token
, status_code
,
3332 extra_ies
, extra_ies_len
);
3334 case WLAN_TDLS_TEARDOWN
:
3335 mwifiex_dbg(priv
->adapter
, MSG
,
3336 "Send TDLS Tear down to %pM\n", peer
);
3337 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3338 dialog_token
, status_code
,
3339 extra_ies
, extra_ies_len
);
3341 case WLAN_TDLS_DISCOVERY_REQUEST
:
3342 mwifiex_dbg(priv
->adapter
, MSG
,
3343 "Send TDLS Discovery Request to %pM\n", peer
);
3344 ret
= mwifiex_send_tdls_data_frame(priv
, peer
, action_code
,
3345 dialog_token
, status_code
,
3346 extra_ies
, extra_ies_len
);
3348 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES
:
3349 mwifiex_dbg(priv
->adapter
, MSG
,
3350 "Send TDLS Discovery Response to %pM\n", peer
);
3351 ret
= mwifiex_send_tdls_action_frame(priv
, peer
, action_code
,
3352 dialog_token
, status_code
,
3353 extra_ies
, extra_ies_len
);
3356 mwifiex_dbg(priv
->adapter
, ERROR
,
3357 "Unknown TDLS mgmt/action frame %pM\n", peer
);
3366 mwifiex_cfg80211_tdls_oper(struct wiphy
*wiphy
, struct net_device
*dev
,
3367 const u8
*peer
, enum nl80211_tdls_operation action
)
3369 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3371 if (!(wiphy
->flags
& WIPHY_FLAG_SUPPORTS_TDLS
) ||
3372 !(wiphy
->flags
& WIPHY_FLAG_TDLS_EXTERNAL_SETUP
))
3375 /* make sure we are in station mode and connected */
3376 if (!(priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
&& priv
->media_connected
))
3379 mwifiex_dbg(priv
->adapter
, MSG
,
3380 "TDLS peer=%pM, oper=%d\n", peer
, action
);
3383 case NL80211_TDLS_ENABLE_LINK
:
3384 action
= MWIFIEX_TDLS_ENABLE_LINK
;
3386 case NL80211_TDLS_DISABLE_LINK
:
3387 action
= MWIFIEX_TDLS_DISABLE_LINK
;
3389 case NL80211_TDLS_TEARDOWN
:
3390 /* shouldn't happen!*/
3391 mwifiex_dbg(priv
->adapter
, ERROR
,
3392 "tdls_oper: teardown from driver not supported\n");
3394 case NL80211_TDLS_SETUP
:
3395 /* shouldn't happen!*/
3396 mwifiex_dbg(priv
->adapter
, ERROR
,
3397 "tdls_oper: setup from driver not supported\n");
3399 case NL80211_TDLS_DISCOVERY_REQ
:
3400 /* shouldn't happen!*/
3401 mwifiex_dbg(priv
->adapter
, ERROR
,
3402 "tdls_oper: discovery from driver not supported\n");
3405 mwifiex_dbg(priv
->adapter
, ERROR
,
3406 "tdls_oper: operation not supported\n");
3410 return mwifiex_tdls_oper(priv
, peer
, action
);
3414 mwifiex_cfg80211_tdls_chan_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3415 const u8
*addr
, u8 oper_class
,
3416 struct cfg80211_chan_def
*chandef
)
3418 struct mwifiex_sta_node
*sta_ptr
;
3419 unsigned long flags
;
3421 u8 second_chan_offset
, band
;
3422 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3424 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3425 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3426 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3429 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3434 if (!(sta_ptr
->tdls_cap
.extcap
.ext_capab
[3] &
3435 WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH
)) {
3436 wiphy_err(wiphy
, "%pM do not support tdls cs\n", addr
);
3440 if (sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3441 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
) {
3442 wiphy_err(wiphy
, "channel switch is running, abort request\n");
3446 chan
= chandef
->chan
->hw_value
;
3447 second_chan_offset
= mwifiex_get_sec_chan_offset(chan
);
3448 band
= chandef
->chan
->band
;
3449 mwifiex_start_tdls_cs(priv
, addr
, chan
, second_chan_offset
, band
);
3455 mwifiex_cfg80211_tdls_cancel_chan_switch(struct wiphy
*wiphy
,
3456 struct net_device
*dev
,
3459 struct mwifiex_sta_node
*sta_ptr
;
3460 unsigned long flags
;
3461 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3463 spin_lock_irqsave(&priv
->sta_list_spinlock
, flags
);
3464 sta_ptr
= mwifiex_get_sta_entry(priv
, addr
);
3465 spin_unlock_irqrestore(&priv
->sta_list_spinlock
, flags
);
3468 wiphy_err(wiphy
, "%s: Invalid TDLS peer %pM\n",
3470 } else if (!(sta_ptr
->tdls_status
== TDLS_CHAN_SWITCHING
||
3471 sta_ptr
->tdls_status
== TDLS_IN_BASE_CHAN
||
3472 sta_ptr
->tdls_status
== TDLS_IN_OFF_CHAN
)) {
3473 wiphy_err(wiphy
, "tdls chan switch not initialize by %pM\n",
3476 mwifiex_stop_tdls_cs(priv
, addr
);
3480 mwifiex_cfg80211_add_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3481 const u8
*mac
, struct station_parameters
*params
)
3483 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3485 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3488 /* make sure we are in station mode and connected */
3489 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3492 return mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CREATE_LINK
);
3496 mwifiex_cfg80211_channel_switch(struct wiphy
*wiphy
, struct net_device
*dev
,
3497 struct cfg80211_csa_settings
*params
)
3499 struct ieee_types_header
*chsw_ie
;
3500 struct ieee80211_channel_sw_ie
*channel_sw
;
3502 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3504 if (priv
->adapter
->scan_processing
) {
3505 mwifiex_dbg(priv
->adapter
, ERROR
,
3506 "radar detection: scan in process...\n");
3510 if (priv
->wdev
.cac_started
)
3513 if (cfg80211_chandef_identical(¶ms
->chandef
,
3514 &priv
->dfs_chandef
))
3517 chsw_ie
= (void *)cfg80211_find_ie(WLAN_EID_CHANNEL_SWITCH
,
3518 params
->beacon_csa
.tail
,
3519 params
->beacon_csa
.tail_len
);
3521 mwifiex_dbg(priv
->adapter
, ERROR
,
3522 "Could not parse channel switch announcement IE\n");
3526 channel_sw
= (void *)(chsw_ie
+ 1);
3527 if (channel_sw
->mode
) {
3528 if (netif_carrier_ok(priv
->netdev
))
3529 netif_carrier_off(priv
->netdev
);
3530 mwifiex_stop_net_dev_queue(priv
->netdev
, priv
->adapter
);
3533 if (mwifiex_del_mgmt_ies(priv
))
3534 mwifiex_dbg(priv
->adapter
, ERROR
,
3535 "Failed to delete mgmt IEs!\n");
3537 if (mwifiex_set_mgmt_ies(priv
, ¶ms
->beacon_csa
)) {
3538 mwifiex_dbg(priv
->adapter
, ERROR
,
3539 "%s: setting mgmt ies failed\n", __func__
);
3543 memcpy(&priv
->dfs_chandef
, ¶ms
->chandef
, sizeof(priv
->dfs_chandef
));
3544 memcpy(&priv
->beacon_after
, ¶ms
->beacon_after
,
3545 sizeof(priv
->beacon_after
));
3547 chsw_msec
= max(channel_sw
->count
* priv
->bss_cfg
.beacon_period
, 100);
3548 queue_delayed_work(priv
->dfs_chan_sw_workqueue
, &priv
->dfs_chan_sw_work
,
3549 msecs_to_jiffies(chsw_msec
));
3553 static int mwifiex_cfg80211_get_channel(struct wiphy
*wiphy
,
3554 struct wireless_dev
*wdev
,
3555 struct cfg80211_chan_def
*chandef
)
3557 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(wdev
->netdev
);
3558 struct mwifiex_bssdescriptor
*curr_bss
;
3559 struct ieee80211_channel
*chan
;
3560 u8 second_chan_offset
;
3561 enum nl80211_channel_type chan_type
;
3562 enum ieee80211_band band
;
3566 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
&&
3567 cfg80211_chandef_valid(&priv
->bss_chandef
)) {
3568 *chandef
= priv
->bss_chandef
;
3570 } else if (priv
->media_connected
) {
3571 curr_bss
= &priv
->curr_bss_params
.bss_descriptor
;
3572 band
= mwifiex_band_to_radio_type(priv
->curr_bss_params
.band
);
3573 freq
= ieee80211_channel_to_frequency(curr_bss
->channel
, band
);
3574 chan
= ieee80211_get_channel(wiphy
, freq
);
3576 if (curr_bss
->bcn_ht_oper
) {
3577 second_chan_offset
= curr_bss
->bcn_ht_oper
->ht_param
&
3578 IEEE80211_HT_PARAM_CHA_SEC_OFFSET
;
3579 chan_type
= mwifiex_sec_chan_offset_to_chan_type
3580 (second_chan_offset
);
3581 cfg80211_chandef_create(chandef
, chan
, chan_type
);
3583 cfg80211_chandef_create(chandef
, chan
,
3584 NL80211_CHAN_NO_HT
);
3593 mwifiex_cfg80211_start_radar_detection(struct wiphy
*wiphy
,
3594 struct net_device
*dev
,
3595 struct cfg80211_chan_def
*chandef
,
3598 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3599 struct mwifiex_radar_params radar_params
;
3601 if (priv
->adapter
->scan_processing
) {
3602 mwifiex_dbg(priv
->adapter
, ERROR
,
3603 "radar detection: scan already in process...\n");
3607 if (!mwifiex_is_11h_active(priv
)) {
3608 mwifiex_dbg(priv
->adapter
, INFO
,
3609 "Enable 11h extensions in FW\n");
3610 if (mwifiex_11h_activate(priv
, true)) {
3611 mwifiex_dbg(priv
->adapter
, ERROR
,
3612 "Failed to activate 11h extensions!!");
3615 priv
->state_11h
.is_11h_active
= true;
3618 memset(&radar_params
, 0, sizeof(struct mwifiex_radar_params
));
3619 radar_params
.chandef
= chandef
;
3620 radar_params
.cac_time_ms
= cac_time_ms
;
3622 memcpy(&priv
->dfs_chandef
, chandef
, sizeof(priv
->dfs_chandef
));
3624 if (mwifiex_send_cmd(priv
, HostCmd_CMD_CHAN_REPORT_REQUEST
,
3625 HostCmd_ACT_GEN_SET
, 0, &radar_params
, true))
3628 queue_delayed_work(priv
->dfs_cac_workqueue
, &priv
->dfs_cac_work
,
3629 msecs_to_jiffies(cac_time_ms
));
3634 mwifiex_cfg80211_change_station(struct wiphy
*wiphy
, struct net_device
*dev
,
3636 struct station_parameters
*params
)
3639 struct mwifiex_private
*priv
= mwifiex_netdev_get_priv(dev
);
3641 /* we support change_station handler only for TDLS peers*/
3642 if (!(params
->sta_flags_set
& BIT(NL80211_STA_FLAG_TDLS_PEER
)))
3645 /* make sure we are in station mode and connected */
3646 if ((priv
->bss_type
!= MWIFIEX_BSS_TYPE_STA
) || !priv
->media_connected
)
3649 priv
->sta_params
= params
;
3651 ret
= mwifiex_tdls_oper(priv
, mac
, MWIFIEX_TDLS_CONFIG_LINK
);
3652 priv
->sta_params
= NULL
;
3657 /* station cfg80211 operations */
3658 static struct cfg80211_ops mwifiex_cfg80211_ops
= {
3659 .add_virtual_intf
= mwifiex_add_virtual_intf
,
3660 .del_virtual_intf
= mwifiex_del_virtual_intf
,
3661 .change_virtual_intf
= mwifiex_cfg80211_change_virtual_intf
,
3662 .scan
= mwifiex_cfg80211_scan
,
3663 .connect
= mwifiex_cfg80211_connect
,
3664 .disconnect
= mwifiex_cfg80211_disconnect
,
3665 .get_station
= mwifiex_cfg80211_get_station
,
3666 .dump_station
= mwifiex_cfg80211_dump_station
,
3667 .dump_survey
= mwifiex_cfg80211_dump_survey
,
3668 .set_wiphy_params
= mwifiex_cfg80211_set_wiphy_params
,
3669 .join_ibss
= mwifiex_cfg80211_join_ibss
,
3670 .leave_ibss
= mwifiex_cfg80211_leave_ibss
,
3671 .add_key
= mwifiex_cfg80211_add_key
,
3672 .del_key
= mwifiex_cfg80211_del_key
,
3673 .mgmt_tx
= mwifiex_cfg80211_mgmt_tx
,
3674 .mgmt_frame_register
= mwifiex_cfg80211_mgmt_frame_register
,
3675 .remain_on_channel
= mwifiex_cfg80211_remain_on_channel
,
3676 .cancel_remain_on_channel
= mwifiex_cfg80211_cancel_remain_on_channel
,
3677 .set_default_key
= mwifiex_cfg80211_set_default_key
,
3678 .set_power_mgmt
= mwifiex_cfg80211_set_power_mgmt
,
3679 .set_tx_power
= mwifiex_cfg80211_set_tx_power
,
3680 .set_bitrate_mask
= mwifiex_cfg80211_set_bitrate_mask
,
3681 .start_ap
= mwifiex_cfg80211_start_ap
,
3682 .stop_ap
= mwifiex_cfg80211_stop_ap
,
3683 .change_beacon
= mwifiex_cfg80211_change_beacon
,
3684 .set_cqm_rssi_config
= mwifiex_cfg80211_set_cqm_rssi_config
,
3685 .set_antenna
= mwifiex_cfg80211_set_antenna
,
3686 .del_station
= mwifiex_cfg80211_del_station
,
3688 .suspend
= mwifiex_cfg80211_suspend
,
3689 .resume
= mwifiex_cfg80211_resume
,
3690 .set_wakeup
= mwifiex_cfg80211_set_wakeup
,
3692 .set_coalesce
= mwifiex_cfg80211_set_coalesce
,
3693 .tdls_mgmt
= mwifiex_cfg80211_tdls_mgmt
,
3694 .tdls_oper
= mwifiex_cfg80211_tdls_oper
,
3695 .tdls_channel_switch
= mwifiex_cfg80211_tdls_chan_switch
,
3696 .tdls_cancel_channel_switch
= mwifiex_cfg80211_tdls_cancel_chan_switch
,
3697 .add_station
= mwifiex_cfg80211_add_station
,
3698 .change_station
= mwifiex_cfg80211_change_station
,
3699 .get_channel
= mwifiex_cfg80211_get_channel
,
3700 .start_radar_detection
= mwifiex_cfg80211_start_radar_detection
,
3701 .channel_switch
= mwifiex_cfg80211_channel_switch
,
3705 static const struct wiphy_wowlan_support mwifiex_wowlan_support
= {
3706 .flags
= WIPHY_WOWLAN_MAGIC_PKT
| WIPHY_WOWLAN_DISCONNECT
,
3707 .n_patterns
= MWIFIEX_MEF_MAX_FILTERS
,
3708 .pattern_min_len
= 1,
3709 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3710 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3714 static bool mwifiex_is_valid_alpha2(const char *alpha2
)
3716 if (!alpha2
|| strlen(alpha2
) != 2)
3719 if (isalpha(alpha2
[0]) && isalpha(alpha2
[1]))
3725 static const struct wiphy_coalesce_support mwifiex_coalesce_support
= {
3726 .n_rules
= MWIFIEX_COALESCE_MAX_RULES
,
3727 .max_delay
= MWIFIEX_MAX_COALESCING_DELAY
,
3728 .n_patterns
= MWIFIEX_COALESCE_MAX_FILTERS
,
3729 .pattern_min_len
= 1,
3730 .pattern_max_len
= MWIFIEX_MAX_PATTERN_LEN
,
3731 .max_pkt_offset
= MWIFIEX_MAX_OFFSET_LEN
,
3734 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter
*adapter
)
3736 u32 n_channels_bg
, n_channels_a
= 0;
3738 n_channels_bg
= mwifiex_band_2ghz
.n_channels
;
3740 if (adapter
->config_bands
& BAND_A
)
3741 n_channels_a
= mwifiex_band_5ghz
.n_channels
;
3743 adapter
->num_in_chan_stats
= n_channels_bg
+ n_channels_a
;
3744 adapter
->chan_stats
= vmalloc(sizeof(*adapter
->chan_stats
) *
3745 adapter
->num_in_chan_stats
);
3747 if (!adapter
->chan_stats
)
3754 * This function registers the device with CFG802.11 subsystem.
3756 * The function creates the wireless device/wiphy, populates it with
3757 * default parameters and handler function pointers, and finally
3758 * registers the device.
3761 int mwifiex_register_cfg80211(struct mwifiex_adapter
*adapter
)
3765 struct wiphy
*wiphy
;
3766 struct mwifiex_private
*priv
= adapter
->priv
[MWIFIEX_BSS_TYPE_STA
];
3770 /* create a new wiphy for use with cfg80211 */
3771 wiphy
= wiphy_new(&mwifiex_cfg80211_ops
,
3772 sizeof(struct mwifiex_adapter
*));
3774 mwifiex_dbg(adapter
, ERROR
,
3775 "%s: creating new wiphy\n", __func__
);
3778 wiphy
->max_scan_ssids
= MWIFIEX_MAX_SSID_LIST_LENGTH
;
3779 wiphy
->max_scan_ie_len
= MWIFIEX_MAX_VSIE_LEN
;
3780 wiphy
->mgmt_stypes
= mwifiex_mgmt_stypes
;
3781 wiphy
->max_remain_on_channel_duration
= 5000;
3782 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
3783 BIT(NL80211_IFTYPE_ADHOC
) |
3784 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
3785 BIT(NL80211_IFTYPE_P2P_GO
) |
3786 BIT(NL80211_IFTYPE_AP
);
3788 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &mwifiex_band_2ghz
;
3789 if (adapter
->config_bands
& BAND_A
)
3790 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = &mwifiex_band_5ghz
;
3792 wiphy
->bands
[IEEE80211_BAND_5GHZ
] = NULL
;
3794 if (adapter
->drcs_enabled
&& ISSUPP_DRCS_ENABLED(adapter
->fw_cap_info
))
3795 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_drcs
;
3796 else if (adapter
->is_hw_11ac_capable
)
3797 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta_vht
;
3799 wiphy
->iface_combinations
= &mwifiex_iface_comb_ap_sta
;
3800 wiphy
->n_iface_combinations
= 1;
3802 /* Initialize cipher suits */
3803 wiphy
->cipher_suites
= mwifiex_cipher_suites
;
3804 wiphy
->n_cipher_suites
= ARRAY_SIZE(mwifiex_cipher_suites
);
3806 ether_addr_copy(wiphy
->perm_addr
, adapter
->perm_addr
);
3807 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
3808 wiphy
->flags
|= WIPHY_FLAG_HAVE_AP_SME
|
3809 WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
|
3810 WIPHY_FLAG_AP_UAPSD
|
3811 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
|
3812 WIPHY_FLAG_HAS_CHANNEL_SWITCH
|
3813 WIPHY_FLAG_PS_ON_BY_DEFAULT
;
3815 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3816 wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_TDLS
|
3817 WIPHY_FLAG_TDLS_EXTERNAL_SETUP
;
3820 wiphy
->wowlan
= &mwifiex_wowlan_support
;
3823 wiphy
->coalesce
= &mwifiex_coalesce_support
;
3825 wiphy
->probe_resp_offload
= NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS
|
3826 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2
|
3827 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P
;
3829 wiphy
->available_antennas_tx
= BIT(adapter
->number_of_antenna
) - 1;
3830 wiphy
->available_antennas_rx
= BIT(adapter
->number_of_antenna
) - 1;
3832 wiphy
->features
|= NL80211_FEATURE_HT_IBSS
|
3833 NL80211_FEATURE_INACTIVITY_TIMER
|
3834 NL80211_FEATURE_NEED_OBSS_SCAN
;
3836 if (ISSUPP_TDLS_ENABLED(adapter
->fw_cap_info
))
3837 wiphy
->features
|= NL80211_FEATURE_TDLS_CHANNEL_SWITCH
;
3839 if (adapter
->fw_api_ver
== MWIFIEX_FW_V15
)
3840 wiphy
->features
|= NL80211_FEATURE_SK_TX_STATUS
;
3842 /* Reserve space for mwifiex specific private data for BSS */
3843 wiphy
->bss_priv_size
= sizeof(struct mwifiex_bss_priv
);
3845 wiphy
->reg_notifier
= mwifiex_reg_notifier
;
3847 /* Set struct mwifiex_adapter pointer in wiphy_priv */
3848 wdev_priv
= wiphy_priv(wiphy
);
3849 *(unsigned long *)wdev_priv
= (unsigned long)adapter
;
3851 set_wiphy_dev(wiphy
, priv
->adapter
->dev
);
3853 ret
= wiphy_register(wiphy
);
3855 mwifiex_dbg(adapter
, ERROR
,
3856 "%s: wiphy_register failed: %d\n", __func__
, ret
);
3861 if (reg_alpha2
&& mwifiex_is_valid_alpha2(reg_alpha2
)) {
3862 mwifiex_dbg(adapter
, INFO
,
3863 "driver hint alpha2: %2.2s\n", reg_alpha2
);
3864 regulatory_hint(wiphy
, reg_alpha2
);
3866 country_code
= mwifiex_11d_code_2_region(adapter
->region_code
);
3868 mwifiex_dbg(adapter
, WARN
,
3869 "ignoring F/W country code %2.2s\n",
3873 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3874 HostCmd_ACT_GEN_GET
, FRAG_THRESH_I
, &thr
, true);
3875 wiphy
->frag_threshold
= thr
;
3876 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3877 HostCmd_ACT_GEN_GET
, RTS_THRESH_I
, &thr
, true);
3878 wiphy
->rts_threshold
= thr
;
3879 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3880 HostCmd_ACT_GEN_GET
, SHORT_RETRY_LIM_I
, &retry
, true);
3881 wiphy
->retry_short
= (u8
) retry
;
3882 mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
3883 HostCmd_ACT_GEN_GET
, LONG_RETRY_LIM_I
, &retry
, true);
3884 wiphy
->retry_long
= (u8
) retry
;
3886 adapter
->wiphy
= wiphy
;