2 * Copyright (c) 2014 Redpine Signals Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/etherdevice.h>
18 #include "rsi_debugfs.h"
21 #include "rsi_common.h"
24 static const struct ieee80211_channel rsi_2ghz_channels
[] = {
25 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2412,
26 .hw_value
= 1 }, /* Channel 1 */
27 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2417,
28 .hw_value
= 2 }, /* Channel 2 */
29 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2422,
30 .hw_value
= 3 }, /* Channel 3 */
31 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2427,
32 .hw_value
= 4 }, /* Channel 4 */
33 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2432,
34 .hw_value
= 5 }, /* Channel 5 */
35 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2437,
36 .hw_value
= 6 }, /* Channel 6 */
37 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2442,
38 .hw_value
= 7 }, /* Channel 7 */
39 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2447,
40 .hw_value
= 8 }, /* Channel 8 */
41 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2452,
42 .hw_value
= 9 }, /* Channel 9 */
43 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2457,
44 .hw_value
= 10 }, /* Channel 10 */
45 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2462,
46 .hw_value
= 11 }, /* Channel 11 */
47 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2467,
48 .hw_value
= 12 }, /* Channel 12 */
49 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2472,
50 .hw_value
= 13 }, /* Channel 13 */
51 { .band
= NL80211_BAND_2GHZ
, .center_freq
= 2484,
52 .hw_value
= 14 }, /* Channel 14 */
55 static const struct ieee80211_channel rsi_5ghz_channels
[] = {
56 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5180,
57 .hw_value
= 36, }, /* Channel 36 */
58 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5200,
59 .hw_value
= 40, }, /* Channel 40 */
60 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5220,
61 .hw_value
= 44, }, /* Channel 44 */
62 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5240,
63 .hw_value
= 48, }, /* Channel 48 */
64 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5260,
65 .hw_value
= 52, }, /* Channel 52 */
66 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5280,
67 .hw_value
= 56, }, /* Channel 56 */
68 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5300,
69 .hw_value
= 60, }, /* Channel 60 */
70 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5320,
71 .hw_value
= 64, }, /* Channel 64 */
72 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5500,
73 .hw_value
= 100, }, /* Channel 100 */
74 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5520,
75 .hw_value
= 104, }, /* Channel 104 */
76 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5540,
77 .hw_value
= 108, }, /* Channel 108 */
78 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5560,
79 .hw_value
= 112, }, /* Channel 112 */
80 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5580,
81 .hw_value
= 116, }, /* Channel 116 */
82 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5600,
83 .hw_value
= 120, }, /* Channel 120 */
84 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5620,
85 .hw_value
= 124, }, /* Channel 124 */
86 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5640,
87 .hw_value
= 128, }, /* Channel 128 */
88 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5660,
89 .hw_value
= 132, }, /* Channel 132 */
90 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5680,
91 .hw_value
= 136, }, /* Channel 136 */
92 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5700,
93 .hw_value
= 140, }, /* Channel 140 */
94 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5745,
95 .hw_value
= 149, }, /* Channel 149 */
96 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5765,
97 .hw_value
= 153, }, /* Channel 153 */
98 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5785,
99 .hw_value
= 157, }, /* Channel 157 */
100 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5805,
101 .hw_value
= 161, }, /* Channel 161 */
102 { .band
= NL80211_BAND_5GHZ
, .center_freq
= 5825,
103 .hw_value
= 165, }, /* Channel 165 */
106 struct ieee80211_rate rsi_rates
[12] = {
107 { .bitrate
= STD_RATE_01
* 5, .hw_value
= RSI_RATE_1
},
108 { .bitrate
= STD_RATE_02
* 5, .hw_value
= RSI_RATE_2
},
109 { .bitrate
= STD_RATE_5_5
* 5, .hw_value
= RSI_RATE_5_5
},
110 { .bitrate
= STD_RATE_11
* 5, .hw_value
= RSI_RATE_11
},
111 { .bitrate
= STD_RATE_06
* 5, .hw_value
= RSI_RATE_6
},
112 { .bitrate
= STD_RATE_09
* 5, .hw_value
= RSI_RATE_9
},
113 { .bitrate
= STD_RATE_12
* 5, .hw_value
= RSI_RATE_12
},
114 { .bitrate
= STD_RATE_18
* 5, .hw_value
= RSI_RATE_18
},
115 { .bitrate
= STD_RATE_24
* 5, .hw_value
= RSI_RATE_24
},
116 { .bitrate
= STD_RATE_36
* 5, .hw_value
= RSI_RATE_36
},
117 { .bitrate
= STD_RATE_48
* 5, .hw_value
= RSI_RATE_48
},
118 { .bitrate
= STD_RATE_54
* 5, .hw_value
= RSI_RATE_54
},
121 const u16 rsi_mcsrates
[8] = {
122 RSI_RATE_MCS0
, RSI_RATE_MCS1
, RSI_RATE_MCS2
, RSI_RATE_MCS3
,
123 RSI_RATE_MCS4
, RSI_RATE_MCS5
, RSI_RATE_MCS6
, RSI_RATE_MCS7
126 static const u32 rsi_max_ap_stas
[16] = {
127 32, /* 1 - Wi-Fi alone */
130 0, /* 4 - BT EDR alone */
131 4, /* 5 - STA + BT EDR */
132 32, /* 6 - AP + BT EDR */
134 0, /* 8 - BT LE alone */
135 4, /* 9 - STA + BE LE */
139 1, /* 13 - STA + BT Dual */
140 4, /* 14 - AP + BT Dual */
143 static const struct ieee80211_iface_limit rsi_iface_limits
[] = {
146 .types
= BIT(NL80211_IFTYPE_STATION
),
150 .types
= BIT(NL80211_IFTYPE_AP
) |
151 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
152 BIT(NL80211_IFTYPE_P2P_GO
),
156 .types
= BIT(NL80211_IFTYPE_P2P_DEVICE
),
160 static const struct ieee80211_iface_combination rsi_iface_combinations
[] = {
162 .num_different_channels
= 1,
164 .limits
= rsi_iface_limits
,
165 .n_limits
= ARRAY_SIZE(rsi_iface_limits
),
170 * rsi_is_cipher_wep() - This function determines if the cipher is WEP or not.
171 * @common: Pointer to the driver private structure.
173 * Return: If cipher type is WEP, a value of 1 is returned, else 0.
176 bool rsi_is_cipher_wep(struct rsi_common
*common
)
178 if (((common
->secinfo
.gtk_cipher
== WLAN_CIPHER_SUITE_WEP104
) ||
179 (common
->secinfo
.gtk_cipher
== WLAN_CIPHER_SUITE_WEP40
)) &&
180 (!common
->secinfo
.ptk_cipher
))
187 * rsi_register_rates_channels() - This function registers channels and rates.
188 * @adapter: Pointer to the adapter structure.
189 * @band: Operating band to be set.
191 * Return: int - 0 on success, negative error on failure.
193 static int rsi_register_rates_channels(struct rsi_hw
*adapter
, int band
)
195 struct ieee80211_supported_band
*sbands
= &adapter
->sbands
[band
];
196 void *channels
= NULL
;
198 if (band
== NL80211_BAND_2GHZ
) {
199 channels
= kmemdup(rsi_2ghz_channels
, sizeof(rsi_2ghz_channels
),
203 sbands
->band
= NL80211_BAND_2GHZ
;
204 sbands
->n_channels
= ARRAY_SIZE(rsi_2ghz_channels
);
205 sbands
->bitrates
= rsi_rates
;
206 sbands
->n_bitrates
= ARRAY_SIZE(rsi_rates
);
208 channels
= kmemdup(rsi_5ghz_channels
, sizeof(rsi_5ghz_channels
),
212 sbands
->band
= NL80211_BAND_5GHZ
;
213 sbands
->n_channels
= ARRAY_SIZE(rsi_5ghz_channels
);
214 sbands
->bitrates
= &rsi_rates
[4];
215 sbands
->n_bitrates
= ARRAY_SIZE(rsi_rates
) - 4;
218 sbands
->channels
= channels
;
220 memset(&sbands
->ht_cap
, 0, sizeof(struct ieee80211_sta_ht_cap
));
221 sbands
->ht_cap
.ht_supported
= true;
222 sbands
->ht_cap
.cap
= (IEEE80211_HT_CAP_SUP_WIDTH_20_40
|
223 IEEE80211_HT_CAP_SGI_20
|
224 IEEE80211_HT_CAP_SGI_40
);
225 sbands
->ht_cap
.ampdu_factor
= IEEE80211_HT_MAX_AMPDU_16K
;
226 sbands
->ht_cap
.ampdu_density
= IEEE80211_HT_MPDU_DENSITY_NONE
;
227 sbands
->ht_cap
.mcs
.rx_mask
[0] = 0xff;
228 sbands
->ht_cap
.mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
229 /* sbands->ht_cap.mcs.rx_highest = 0x82; */
233 static int rsi_mac80211_hw_scan_start(struct ieee80211_hw
*hw
,
234 struct ieee80211_vif
*vif
,
235 struct ieee80211_scan_request
*hw_req
)
237 struct cfg80211_scan_request
*scan_req
= &hw_req
->req
;
238 struct rsi_hw
*adapter
= hw
->priv
;
239 struct rsi_common
*common
= adapter
->priv
;
240 struct ieee80211_bss_conf
*bss
= &vif
->bss_conf
;
242 rsi_dbg(INFO_ZONE
, "***** Hardware scan start *****\n");
243 common
->mac_ops_resumed
= false;
245 if (common
->fsm_state
!= FSM_MAC_INIT_DONE
)
248 if ((common
->wow_flags
& RSI_WOW_ENABLED
) ||
249 scan_req
->n_channels
== 0)
252 /* Scan already in progress. So return */
253 if (common
->bgscan_en
)
256 /* If STA is not connected, return with special value 1, in order
257 * to start sw_scan in mac80211
262 mutex_lock(&common
->mutex
);
263 common
->hwscan
= scan_req
;
264 if (!rsi_send_bgscan_params(common
, RSI_START_BGSCAN
)) {
265 if (!rsi_send_bgscan_probe_req(common
, vif
)) {
266 rsi_dbg(INFO_ZONE
, "Background scan started...\n");
267 common
->bgscan_en
= true;
270 mutex_unlock(&common
->mutex
);
275 static void rsi_mac80211_cancel_hw_scan(struct ieee80211_hw
*hw
,
276 struct ieee80211_vif
*vif
)
278 struct rsi_hw
*adapter
= hw
->priv
;
279 struct rsi_common
*common
= adapter
->priv
;
280 struct cfg80211_scan_info info
;
282 rsi_dbg(INFO_ZONE
, "***** Hardware scan stop *****\n");
283 mutex_lock(&common
->mutex
);
285 if (common
->bgscan_en
) {
286 if (!rsi_send_bgscan_params(common
, RSI_STOP_BGSCAN
))
287 common
->bgscan_en
= false;
288 info
.aborted
= false;
289 ieee80211_scan_completed(adapter
->hw
, &info
);
290 rsi_dbg(INFO_ZONE
, "Back ground scan cancelled\n");
292 common
->hwscan
= NULL
;
293 mutex_unlock(&common
->mutex
);
297 * rsi_mac80211_detach() - This function is used to de-initialize the
299 * @adapter: Pointer to the adapter structure.
303 void rsi_mac80211_detach(struct rsi_hw
*adapter
)
305 struct ieee80211_hw
*hw
= adapter
->hw
;
306 enum nl80211_band band
;
309 ieee80211_stop_queues(hw
);
310 ieee80211_unregister_hw(hw
);
311 ieee80211_free_hw(hw
);
315 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
316 struct ieee80211_supported_band
*sband
=
317 &adapter
->sbands
[band
];
319 kfree(sband
->channels
);
322 #ifdef CONFIG_RSI_DEBUGFS
323 rsi_remove_dbgfs(adapter
);
324 kfree(adapter
->dfsentry
);
327 EXPORT_SYMBOL_GPL(rsi_mac80211_detach
);
330 * rsi_indicate_tx_status() - This function indicates the transmit status.
331 * @adapter: Pointer to the adapter structure.
332 * @skb: Pointer to the socket buffer structure.
337 void rsi_indicate_tx_status(struct rsi_hw
*adapter
,
341 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
342 struct skb_info
*tx_params
;
345 rsi_dbg(ERR_ZONE
, "##### No MAC #####\n");
350 info
->flags
|= IEEE80211_TX_STAT_ACK
;
352 tx_params
= (struct skb_info
*)info
->driver_data
;
353 skb_pull(skb
, tx_params
->internal_hdr_size
);
354 memset(info
->driver_data
, 0, IEEE80211_TX_INFO_DRIVER_DATA_SIZE
);
356 ieee80211_tx_status_irqsafe(adapter
->hw
, skb
);
360 * rsi_mac80211_tx() - This is the handler that 802.11 module calls for each
361 * transmitted frame.SKB contains the buffer starting
362 * from the IEEE 802.11 header.
363 * @hw: Pointer to the ieee80211_hw structure.
364 * @control: Pointer to the ieee80211_tx_control structure
365 * @skb: Pointer to the socket buffer structure.
369 static void rsi_mac80211_tx(struct ieee80211_hw
*hw
,
370 struct ieee80211_tx_control
*control
,
373 struct rsi_hw
*adapter
= hw
->priv
;
374 struct rsi_common
*common
= adapter
->priv
;
375 struct ieee80211_hdr
*wlh
= (struct ieee80211_hdr
*)skb
->data
;
377 if (ieee80211_is_auth(wlh
->frame_control
))
378 common
->mac_ops_resumed
= false;
380 rsi_core_xmit(common
, skb
);
384 * rsi_mac80211_start() - This is first handler that 802.11 module calls, since
385 * the driver init is complete by then, just
387 * @hw: Pointer to the ieee80211_hw structure.
389 * Return: 0 as success.
391 static int rsi_mac80211_start(struct ieee80211_hw
*hw
)
393 struct rsi_hw
*adapter
= hw
->priv
;
394 struct rsi_common
*common
= adapter
->priv
;
396 rsi_dbg(ERR_ZONE
, "===> Interface UP <===\n");
397 mutex_lock(&common
->mutex
);
398 if (common
->hibernate_resume
) {
399 common
->reinit_hw
= true;
400 adapter
->host_intf_ops
->reinit_device(adapter
);
401 wait_for_completion(&adapter
->priv
->wlan_init_completion
);
403 common
->iface_down
= false;
404 wiphy_rfkill_start_polling(hw
->wiphy
);
405 rsi_send_rx_filter_frame(common
, 0);
406 mutex_unlock(&common
->mutex
);
412 * rsi_mac80211_stop() - This is the last handler that 802.11 module calls.
413 * @hw: Pointer to the ieee80211_hw structure.
417 static void rsi_mac80211_stop(struct ieee80211_hw
*hw
)
419 struct rsi_hw
*adapter
= hw
->priv
;
420 struct rsi_common
*common
= adapter
->priv
;
422 rsi_dbg(ERR_ZONE
, "===> Interface DOWN <===\n");
423 mutex_lock(&common
->mutex
);
424 common
->iface_down
= true;
425 wiphy_rfkill_stop_polling(hw
->wiphy
);
427 /* Block all rx frames */
428 rsi_send_rx_filter_frame(common
, 0xffff);
430 mutex_unlock(&common
->mutex
);
433 static int rsi_map_intf_mode(enum nl80211_iftype vif_type
)
436 case NL80211_IFTYPE_STATION
:
437 return RSI_OPMODE_STA
;
438 case NL80211_IFTYPE_AP
:
439 return RSI_OPMODE_AP
;
440 case NL80211_IFTYPE_P2P_DEVICE
:
441 return RSI_OPMODE_P2P_CLIENT
;
442 case NL80211_IFTYPE_P2P_CLIENT
:
443 return RSI_OPMODE_P2P_CLIENT
;
444 case NL80211_IFTYPE_P2P_GO
:
445 return RSI_OPMODE_P2P_GO
;
447 return RSI_OPMODE_UNSUPPORTED
;
452 * rsi_mac80211_add_interface() - This function is called when a netdevice
453 * attached to the hardware is enabled.
454 * @hw: Pointer to the ieee80211_hw structure.
455 * @vif: Pointer to the ieee80211_vif structure.
457 * Return: ret: 0 on success, negative error code on failure.
459 static int rsi_mac80211_add_interface(struct ieee80211_hw
*hw
,
460 struct ieee80211_vif
*vif
)
462 struct rsi_hw
*adapter
= hw
->priv
;
463 struct rsi_common
*common
= adapter
->priv
;
464 struct vif_priv
*vif_info
= (struct vif_priv
*)vif
->drv_priv
;
465 enum opmode intf_mode
;
466 enum vap_status vap_status
;
469 vif
->driver_flags
|= IEEE80211_VIF_SUPPORTS_UAPSD
;
470 mutex_lock(&common
->mutex
);
472 intf_mode
= rsi_map_intf_mode(vif
->type
);
473 if (intf_mode
== RSI_OPMODE_UNSUPPORTED
) {
475 "%s: Interface type %d not supported\n", __func__
,
477 mutex_unlock(&common
->mutex
);
480 if ((vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) ||
481 (vif
->type
== NL80211_IFTYPE_P2P_CLIENT
) ||
482 (vif
->type
== NL80211_IFTYPE_P2P_GO
))
483 common
->p2p_enabled
= true;
485 /* Get free vap index */
486 for (i
= 0; i
< RSI_MAX_VIFS
; i
++) {
487 if (!adapter
->vifs
[i
] ||
488 !memcmp(vif
->addr
, adapter
->vifs
[i
]->addr
, ETH_ALEN
)) {
494 rsi_dbg(ERR_ZONE
, "Reject: Max VAPs reached\n");
495 mutex_unlock(&common
->mutex
);
498 vif_info
->vap_id
= vap_idx
;
499 adapter
->vifs
[vap_idx
] = vif
;
501 vap_status
= VAP_ADD
;
503 if (rsi_set_vap_capabilities(common
, intf_mode
, vif
->addr
,
504 vif_info
->vap_id
, vap_status
)) {
505 rsi_dbg(ERR_ZONE
, "Failed to set VAP capabilities\n");
506 mutex_unlock(&common
->mutex
);
510 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
511 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
512 rsi_send_rx_filter_frame(common
, DISALLOW_BEACONS
);
513 common
->min_rate
= RSI_RATE_AUTO
;
514 for (i
= 0; i
< common
->max_stations
; i
++)
515 common
->stations
[i
].sta
= NULL
;
518 mutex_unlock(&common
->mutex
);
524 * rsi_mac80211_remove_interface() - This function notifies driver that an
525 * interface is going down.
526 * @hw: Pointer to the ieee80211_hw structure.
527 * @vif: Pointer to the ieee80211_vif structure.
531 static void rsi_mac80211_remove_interface(struct ieee80211_hw
*hw
,
532 struct ieee80211_vif
*vif
)
534 struct rsi_hw
*adapter
= hw
->priv
;
535 struct rsi_common
*common
= adapter
->priv
;
539 rsi_dbg(INFO_ZONE
, "Remove Interface Called\n");
541 mutex_lock(&common
->mutex
);
543 if (adapter
->sc_nvifs
<= 0) {
544 mutex_unlock(&common
->mutex
);
548 opmode
= rsi_map_intf_mode(vif
->type
);
549 if (opmode
== RSI_OPMODE_UNSUPPORTED
) {
550 rsi_dbg(ERR_ZONE
, "Opmode error : %d\n", opmode
);
551 mutex_unlock(&common
->mutex
);
554 for (i
= 0; i
< RSI_MAX_VIFS
; i
++) {
555 if (!adapter
->vifs
[i
])
557 if (vif
== adapter
->vifs
[i
]) {
558 rsi_set_vap_capabilities(common
, opmode
, vif
->addr
,
561 adapter
->vifs
[i
] = NULL
;
564 mutex_unlock(&common
->mutex
);
568 * rsi_channel_change() - This function is a performs the checks
569 * required for changing a channel and sets
570 * the channel accordingly.
571 * @hw: Pointer to the ieee80211_hw structure.
573 * Return: 0 on success, negative error code on failure.
575 static int rsi_channel_change(struct ieee80211_hw
*hw
)
577 struct rsi_hw
*adapter
= hw
->priv
;
578 struct rsi_common
*common
= adapter
->priv
;
579 int status
= -EOPNOTSUPP
;
580 struct ieee80211_channel
*curchan
= hw
->conf
.chandef
.chan
;
581 u16 channel
= curchan
->hw_value
;
582 struct ieee80211_vif
*vif
;
583 struct ieee80211_bss_conf
*bss
;
588 "%s: Set channel: %d MHz type: %d channel_no %d\n",
589 __func__
, curchan
->center_freq
,
590 curchan
->flags
, channel
);
592 for (i
= 0; i
< RSI_MAX_VIFS
; i
++) {
593 vif
= adapter
->vifs
[i
];
596 if (vif
->type
== NL80211_IFTYPE_STATION
) {
597 bss
= &vif
->bss_conf
;
605 if (!common
->hw_data_qs_blocked
&&
606 (rsi_get_connected_channel(vif
) != channel
)) {
607 rsi_dbg(INFO_ZONE
, "blk data q %d\n", channel
);
608 if (!rsi_send_block_unblock_frame(common
, true))
609 common
->hw_data_qs_blocked
= true;
613 status
= rsi_band_check(common
, curchan
);
615 status
= rsi_set_channel(adapter
->priv
, curchan
);
618 if (common
->hw_data_qs_blocked
&&
619 (rsi_get_connected_channel(vif
) == channel
)) {
620 rsi_dbg(INFO_ZONE
, "unblk data q %d\n", channel
);
621 if (!rsi_send_block_unblock_frame(common
, false))
622 common
->hw_data_qs_blocked
= false;
630 * rsi_config_power() - This function configures tx power to device
631 * @hw: Pointer to the ieee80211_hw structure.
633 * Return: 0 on success, negative error code on failure.
635 static int rsi_config_power(struct ieee80211_hw
*hw
)
637 struct rsi_hw
*adapter
= hw
->priv
;
638 struct rsi_common
*common
= adapter
->priv
;
639 struct ieee80211_conf
*conf
= &hw
->conf
;
641 if (adapter
->sc_nvifs
<= 0) {
642 rsi_dbg(ERR_ZONE
, "%s: No virtual interface found\n", __func__
);
647 "%s: Set tx power: %d dBM\n", __func__
, conf
->power_level
);
649 if (conf
->power_level
== common
->tx_power
)
652 common
->tx_power
= conf
->power_level
;
654 return rsi_send_radio_params_update(common
);
658 * rsi_mac80211_config() - This function is a handler for configuration
659 * requests. The stack calls this function to
660 * change hardware configuration, e.g., channel.
661 * @hw: Pointer to the ieee80211_hw structure.
662 * @changed: Changed flags set.
664 * Return: 0 on success, negative error code on failure.
666 static int rsi_mac80211_config(struct ieee80211_hw
*hw
,
669 struct rsi_hw
*adapter
= hw
->priv
;
670 struct rsi_common
*common
= adapter
->priv
;
671 struct ieee80211_conf
*conf
= &hw
->conf
;
672 int status
= -EOPNOTSUPP
;
674 mutex_lock(&common
->mutex
);
676 if (changed
& IEEE80211_CONF_CHANGE_CHANNEL
)
677 status
= rsi_channel_change(hw
);
680 if (changed
& IEEE80211_CONF_CHANGE_POWER
) {
681 rsi_dbg(INFO_ZONE
, "%s: Configuring Power\n", __func__
);
682 status
= rsi_config_power(hw
);
685 /* Power save parameters */
686 if ((changed
& IEEE80211_CONF_CHANGE_PS
) &&
687 !common
->mac_ops_resumed
) {
688 struct ieee80211_vif
*vif
, *sta_vif
= NULL
;
692 for (i
= 0; i
< RSI_MAX_VIFS
; i
++) {
693 vif
= adapter
->vifs
[i
];
696 /* Don't go to power save if AP vap exists */
697 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
698 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
702 if ((vif
->type
== NL80211_IFTYPE_STATION
||
703 vif
->type
== NL80211_IFTYPE_P2P_CLIENT
) &&
704 (!sta_vif
|| vif
->bss_conf
.assoc
))
707 if (set_ps
&& sta_vif
) {
708 spin_lock_irqsave(&adapter
->ps_lock
, flags
);
709 if (conf
->flags
& IEEE80211_CONF_PS
)
710 rsi_enable_ps(adapter
, sta_vif
);
712 rsi_disable_ps(adapter
, sta_vif
);
713 spin_unlock_irqrestore(&adapter
->ps_lock
, flags
);
718 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
719 rsi_dbg(INFO_ZONE
, "RTS threshold\n");
720 if ((common
->rts_threshold
) <= IEEE80211_MAX_RTS_THRESHOLD
) {
722 "%s: Sending vap updates....\n", __func__
);
723 status
= rsi_send_vap_dynamic_update(common
);
726 mutex_unlock(&common
->mutex
);
732 * rsi_get_connected_channel() - This function is used to get the current
733 * connected channel number.
734 * @vif: Pointer to the ieee80211_vif structure.
736 * Return: Current connected AP's channel number is returned.
738 u16
rsi_get_connected_channel(struct ieee80211_vif
*vif
)
740 struct ieee80211_bss_conf
*bss
;
741 struct ieee80211_channel
*channel
;
746 bss
= &vif
->bss_conf
;
747 channel
= bss
->chandef
.chan
;
752 return channel
->hw_value
;
755 static void rsi_switch_channel(struct rsi_hw
*adapter
,
756 struct ieee80211_vif
*vif
)
758 struct rsi_common
*common
= adapter
->priv
;
759 struct ieee80211_channel
*channel
;
761 if (common
->iface_down
)
766 channel
= vif
->bss_conf
.chandef
.chan
;
771 rsi_band_check(common
, channel
);
772 rsi_set_channel(common
, channel
);
773 rsi_dbg(INFO_ZONE
, "Switched to channel - %d\n", channel
->hw_value
);
777 * rsi_mac80211_bss_info_changed() - This function is a handler for config
778 * requests related to BSS parameters that
779 * may vary during BSS's lifespan.
780 * @hw: Pointer to the ieee80211_hw structure.
781 * @vif: Pointer to the ieee80211_vif structure.
782 * @bss_conf: Pointer to the ieee80211_bss_conf structure.
783 * @changed: Changed flags set.
787 static void rsi_mac80211_bss_info_changed(struct ieee80211_hw
*hw
,
788 struct ieee80211_vif
*vif
,
789 struct ieee80211_bss_conf
*bss_conf
,
792 struct rsi_hw
*adapter
= hw
->priv
;
793 struct rsi_common
*common
= adapter
->priv
;
794 struct ieee80211_bss_conf
*bss
= &vif
->bss_conf
;
795 struct ieee80211_conf
*conf
= &hw
->conf
;
796 u16 rx_filter_word
= 0;
798 mutex_lock(&common
->mutex
);
799 if (changed
& BSS_CHANGED_ASSOC
) {
800 rsi_dbg(INFO_ZONE
, "%s: Changed Association status: %d\n",
801 __func__
, bss_conf
->assoc
);
802 if (bss_conf
->assoc
) {
803 /* Send the RX filter frame */
804 rx_filter_word
= (ALLOW_DATA_ASSOC_PEER
|
805 ALLOW_CTRL_ASSOC_PEER
|
806 ALLOW_MGMT_ASSOC_PEER
);
807 rsi_send_rx_filter_frame(common
, rx_filter_word
);
809 rsi_inform_bss_status(common
,
816 bss_conf
->assoc_capability
, vif
);
817 adapter
->ps_info
.dtim_interval_duration
= bss
->dtim_period
;
818 adapter
->ps_info
.listen_interval
= conf
->listen_interval
;
820 /* If U-APSD is updated, send ps parameters to firmware */
822 if (common
->uapsd_bitmap
) {
823 rsi_dbg(INFO_ZONE
, "Configuring UAPSD\n");
824 rsi_conf_uapsd(adapter
, vif
);
827 common
->uapsd_bitmap
= 0;
831 if (changed
& BSS_CHANGED_CQM
) {
832 common
->cqm_info
.last_cqm_event_rssi
= 0;
833 common
->cqm_info
.rssi_thold
= bss_conf
->cqm_rssi_thold
;
834 common
->cqm_info
.rssi_hyst
= bss_conf
->cqm_rssi_hyst
;
835 rsi_dbg(INFO_ZONE
, "RSSI threshold & hysteresis are: %d %d\n",
836 common
->cqm_info
.rssi_thold
,
837 common
->cqm_info
.rssi_hyst
);
840 if ((changed
& BSS_CHANGED_BEACON_ENABLED
) &&
841 ((vif
->type
== NL80211_IFTYPE_AP
) ||
842 (vif
->type
== NL80211_IFTYPE_P2P_GO
))) {
843 if (bss
->enable_beacon
) {
844 rsi_dbg(INFO_ZONE
, "===> BEACON ENABLED <===\n");
845 common
->beacon_enabled
= 1;
847 rsi_dbg(INFO_ZONE
, "===> BEACON DISABLED <===\n");
848 common
->beacon_enabled
= 0;
852 mutex_unlock(&common
->mutex
);
856 * rsi_mac80211_conf_filter() - This function configure the device's RX filter.
857 * @hw: Pointer to the ieee80211_hw structure.
858 * @changed_flags: Changed flags set.
859 * @total_flags: Total initial flags set.
860 * @multicast: Multicast.
864 static void rsi_mac80211_conf_filter(struct ieee80211_hw
*hw
,
869 /* Not doing much here as of now */
870 *total_flags
&= RSI_SUPP_FILTERS
;
874 * rsi_mac80211_conf_tx() - This function configures TX queue parameters
875 * (EDCF (aifs, cw_min, cw_max), bursting)
876 * for a hardware TX queue.
877 * @hw: Pointer to the ieee80211_hw structure
878 * @vif: Pointer to the ieee80211_vif structure.
879 * @queue: Queue number.
880 * @params: Pointer to ieee80211_tx_queue_params structure.
882 * Return: 0 on success, negative error code on failure.
884 static int rsi_mac80211_conf_tx(struct ieee80211_hw
*hw
,
885 struct ieee80211_vif
*vif
, u16 queue
,
886 const struct ieee80211_tx_queue_params
*params
)
888 struct rsi_hw
*adapter
= hw
->priv
;
889 struct rsi_common
*common
= adapter
->priv
;
892 if (queue
>= IEEE80211_NUM_ACS
)
896 "%s: Conf queue %d, aifs: %d, cwmin: %d cwmax: %d, txop: %d\n",
897 __func__
, queue
, params
->aifs
,
898 params
->cw_min
, params
->cw_max
, params
->txop
);
900 mutex_lock(&common
->mutex
);
901 /* Map into the way the f/w expects */
903 case IEEE80211_AC_VO
:
906 case IEEE80211_AC_VI
:
909 case IEEE80211_AC_BE
:
912 case IEEE80211_AC_BK
:
920 memcpy(&common
->edca_params
[idx
],
922 sizeof(struct ieee80211_tx_queue_params
));
925 common
->uapsd_bitmap
|= idx
;
927 common
->uapsd_bitmap
&= (~idx
);
929 mutex_unlock(&common
->mutex
);
935 * rsi_hal_key_config() - This function loads the keys into the firmware.
936 * @hw: Pointer to the ieee80211_hw structure.
937 * @vif: Pointer to the ieee80211_vif structure.
938 * @key: Pointer to the ieee80211_key_conf structure.
939 * @sta: Pointer to the ieee80211_sta structure.
941 * Return: status: 0 on success, negative error codes on failure.
943 static int rsi_hal_key_config(struct ieee80211_hw
*hw
,
944 struct ieee80211_vif
*vif
,
945 struct ieee80211_key_conf
*key
,
946 struct ieee80211_sta
*sta
)
948 struct rsi_hw
*adapter
= hw
->priv
;
949 struct rsi_sta
*rsta
= NULL
;
954 if (key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
)
955 key_type
= RSI_PAIRWISE_KEY
;
957 key_type
= RSI_GROUP_KEY
;
959 rsi_dbg(ERR_ZONE
, "%s: Cipher 0x%x key_type: %d key_len: %d\n",
960 __func__
, key
->cipher
, key_type
, key
->keylen
);
962 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
963 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
965 rsta
= rsi_find_sta(adapter
->priv
, sta
->addr
);
967 sta_id
= rsta
->sta_id
;
969 adapter
->priv
->key
= key
;
971 if ((key
->cipher
== WLAN_CIPHER_SUITE_WEP104
) ||
972 (key
->cipher
== WLAN_CIPHER_SUITE_WEP40
)) {
973 status
= rsi_hal_load_key(adapter
->priv
,
986 status
= rsi_hal_load_key(adapter
->priv
,
997 if (vif
->type
== NL80211_IFTYPE_STATION
&&
998 (key
->cipher
== WLAN_CIPHER_SUITE_WEP104
||
999 key
->cipher
== WLAN_CIPHER_SUITE_WEP40
)) {
1000 if (!rsi_send_block_unblock_frame(adapter
->priv
, false))
1001 adapter
->priv
->hw_data_qs_blocked
= false;
1008 * rsi_mac80211_set_key() - This function sets type of key to be loaded.
1009 * @hw: Pointer to the ieee80211_hw structure.
1010 * @cmd: enum set_key_cmd.
1011 * @vif: Pointer to the ieee80211_vif structure.
1012 * @sta: Pointer to the ieee80211_sta structure.
1013 * @key: Pointer to the ieee80211_key_conf structure.
1015 * Return: status: 0 on success, negative error code on failure.
1017 static int rsi_mac80211_set_key(struct ieee80211_hw
*hw
,
1018 enum set_key_cmd cmd
,
1019 struct ieee80211_vif
*vif
,
1020 struct ieee80211_sta
*sta
,
1021 struct ieee80211_key_conf
*key
)
1023 struct rsi_hw
*adapter
= hw
->priv
;
1024 struct rsi_common
*common
= adapter
->priv
;
1025 struct security_info
*secinfo
= &common
->secinfo
;
1028 mutex_lock(&common
->mutex
);
1031 secinfo
->security_enable
= true;
1032 status
= rsi_hal_key_config(hw
, vif
, key
, sta
);
1034 mutex_unlock(&common
->mutex
);
1038 if (key
->flags
& IEEE80211_KEY_FLAG_PAIRWISE
)
1039 secinfo
->ptk_cipher
= key
->cipher
;
1041 secinfo
->gtk_cipher
= key
->cipher
;
1043 key
->hw_key_idx
= key
->keyidx
;
1044 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
1046 rsi_dbg(ERR_ZONE
, "%s: RSI set_key\n", __func__
);
1050 if (vif
->type
== NL80211_IFTYPE_STATION
)
1051 secinfo
->security_enable
= false;
1052 rsi_dbg(ERR_ZONE
, "%s: RSI del key\n", __func__
);
1053 memset(key
, 0, sizeof(struct ieee80211_key_conf
));
1054 status
= rsi_hal_key_config(hw
, vif
, key
, sta
);
1058 status
= -EOPNOTSUPP
;
1062 mutex_unlock(&common
->mutex
);
1067 * rsi_mac80211_ampdu_action() - This function selects the AMPDU action for
1068 * the corresponding mlme_action flag and
1069 * informs the f/w regarding this.
1070 * @hw: Pointer to the ieee80211_hw structure.
1071 * @vif: Pointer to the ieee80211_vif structure.
1072 * @params: Pointer to A-MPDU action parameters
1074 * Return: status: 0 on success, negative error code on failure.
1076 static int rsi_mac80211_ampdu_action(struct ieee80211_hw
*hw
,
1077 struct ieee80211_vif
*vif
,
1078 struct ieee80211_ampdu_params
*params
)
1080 int status
= -EOPNOTSUPP
;
1081 struct rsi_hw
*adapter
= hw
->priv
;
1082 struct rsi_common
*common
= adapter
->priv
;
1083 struct rsi_sta
*rsta
= NULL
;
1084 u16 seq_no
= 0, seq_start
= 0;
1086 struct ieee80211_sta
*sta
= params
->sta
;
1088 enum ieee80211_ampdu_mlme_action action
= params
->action
;
1089 u16 tid
= params
->tid
;
1090 u16
*ssn
= ¶ms
->ssn
;
1091 u8 buf_size
= params
->buf_size
;
1093 for (ii
= 0; ii
< RSI_MAX_VIFS
; ii
++) {
1094 if (vif
== adapter
->vifs
[ii
])
1098 mutex_lock(&common
->mutex
);
1103 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
1104 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
1105 rsta
= rsi_find_sta(common
, sta
->addr
);
1107 rsi_dbg(ERR_ZONE
, "No station mapped\n");
1111 sta_id
= rsta
->sta_id
;
1115 "%s: AMPDU action tid=%d ssn=0x%x, buf_size=%d sta_id=%d\n",
1116 __func__
, tid
, seq_no
, buf_size
, sta_id
);
1119 case IEEE80211_AMPDU_RX_START
:
1120 status
= rsi_send_aggregation_params_frame(common
,
1128 case IEEE80211_AMPDU_RX_STOP
:
1129 status
= rsi_send_aggregation_params_frame(common
,
1137 case IEEE80211_AMPDU_TX_START
:
1138 if ((vif
->type
== NL80211_IFTYPE_STATION
) ||
1139 (vif
->type
== NL80211_IFTYPE_P2P_CLIENT
))
1140 common
->vif_info
[ii
].seq_start
= seq_no
;
1141 else if ((vif
->type
== NL80211_IFTYPE_AP
) ||
1142 (vif
->type
== NL80211_IFTYPE_P2P_GO
))
1143 rsta
->seq_start
[tid
] = seq_no
;
1144 status
= IEEE80211_AMPDU_TX_START_IMMEDIATE
;
1147 case IEEE80211_AMPDU_TX_STOP_CONT
:
1148 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
1149 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
1150 status
= rsi_send_aggregation_params_frame(common
,
1157 ieee80211_stop_tx_ba_cb_irqsafe(vif
, sta
->addr
, tid
);
1160 case IEEE80211_AMPDU_TX_OPERATIONAL
:
1161 if ((vif
->type
== NL80211_IFTYPE_STATION
) ||
1162 (vif
->type
== NL80211_IFTYPE_P2P_CLIENT
))
1163 seq_start
= common
->vif_info
[ii
].seq_start
;
1164 else if ((vif
->type
== NL80211_IFTYPE_AP
) ||
1165 (vif
->type
== NL80211_IFTYPE_P2P_GO
))
1166 seq_start
= rsta
->seq_start
[tid
];
1167 status
= rsi_send_aggregation_params_frame(common
,
1176 rsi_dbg(ERR_ZONE
, "%s: Unknown AMPDU action\n", __func__
);
1181 mutex_unlock(&common
->mutex
);
1186 * rsi_mac80211_set_rts_threshold() - This function sets rts threshold value.
1187 * @hw: Pointer to the ieee80211_hw structure.
1188 * @value: Rts threshold value.
1190 * Return: 0 on success.
1192 static int rsi_mac80211_set_rts_threshold(struct ieee80211_hw
*hw
,
1195 struct rsi_hw
*adapter
= hw
->priv
;
1196 struct rsi_common
*common
= adapter
->priv
;
1198 mutex_lock(&common
->mutex
);
1199 common
->rts_threshold
= value
;
1200 mutex_unlock(&common
->mutex
);
1206 * rsi_mac80211_set_rate_mask() - This function sets bitrate_mask to be used.
1207 * @hw: Pointer to the ieee80211_hw structure
1208 * @vif: Pointer to the ieee80211_vif structure.
1209 * @mask: Pointer to the cfg80211_bitrate_mask structure.
1211 * Return: 0 on success.
1213 static int rsi_mac80211_set_rate_mask(struct ieee80211_hw
*hw
,
1214 struct ieee80211_vif
*vif
,
1215 const struct cfg80211_bitrate_mask
*mask
)
1217 struct rsi_hw
*adapter
= hw
->priv
;
1218 struct rsi_common
*common
= adapter
->priv
;
1219 enum nl80211_band band
= hw
->conf
.chandef
.chan
->band
;
1221 mutex_lock(&common
->mutex
);
1222 common
->fixedrate_mask
[band
] = 0;
1224 if (mask
->control
[band
].legacy
== 0xfff) {
1225 common
->fixedrate_mask
[band
] =
1226 (mask
->control
[band
].ht_mcs
[0] << 12);
1228 common
->fixedrate_mask
[band
] =
1229 mask
->control
[band
].legacy
;
1231 mutex_unlock(&common
->mutex
);
1237 * rsi_perform_cqm() - This function performs cqm.
1238 * @common: Pointer to the driver private structure.
1239 * @bssid: pointer to the bssid.
1240 * @rssi: RSSI value.
1241 * @vif: Pointer to the ieee80211_vif structure.
1243 static void rsi_perform_cqm(struct rsi_common
*common
,
1246 struct ieee80211_vif
*vif
)
1248 s8 last_event
= common
->cqm_info
.last_cqm_event_rssi
;
1249 int thold
= common
->cqm_info
.rssi_thold
;
1250 u32 hyst
= common
->cqm_info
.rssi_hyst
;
1251 enum nl80211_cqm_rssi_threshold_event event
;
1253 if (rssi
< thold
&& (last_event
== 0 || rssi
< (last_event
- hyst
)))
1254 event
= NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW
;
1255 else if (rssi
> thold
&&
1256 (last_event
== 0 || rssi
> (last_event
+ hyst
)))
1257 event
= NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH
;
1261 common
->cqm_info
.last_cqm_event_rssi
= rssi
;
1262 rsi_dbg(INFO_ZONE
, "CQM: Notifying event: %d\n", event
);
1263 ieee80211_cqm_rssi_notify(vif
, event
, rssi
, GFP_KERNEL
);
1269 * rsi_fill_rx_status() - This function fills rx status in
1270 * ieee80211_rx_status structure.
1271 * @hw: Pointer to the ieee80211_hw structure.
1272 * @skb: Pointer to the socket buffer structure.
1273 * @common: Pointer to the driver private structure.
1274 * @rxs: Pointer to the ieee80211_rx_status structure.
1278 static void rsi_fill_rx_status(struct ieee80211_hw
*hw
,
1279 struct sk_buff
*skb
,
1280 struct rsi_common
*common
,
1281 struct ieee80211_rx_status
*rxs
)
1283 struct rsi_hw
*adapter
= common
->priv
;
1284 struct ieee80211_vif
*vif
;
1285 struct ieee80211_bss_conf
*bss
= NULL
;
1286 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
1287 struct skb_info
*rx_params
= (struct skb_info
*)info
->driver_data
;
1288 struct ieee80211_hdr
*hdr
;
1289 char rssi
= rx_params
->rssi
;
1291 u8 channel
= rx_params
->channel
;
1295 hdr
= ((struct ieee80211_hdr
*)(skb
->data
));
1296 hdrlen
= ieee80211_hdrlen(hdr
->frame_control
);
1298 memset(info
, 0, sizeof(struct ieee80211_tx_info
));
1300 rxs
->signal
= -(rssi
);
1302 rxs
->band
= common
->band
;
1304 freq
= ieee80211_channel_to_frequency(channel
, rxs
->band
);
1309 if (ieee80211_has_protected(hdr
->frame_control
)) {
1310 if (rsi_is_cipher_wep(common
)) {
1311 memmove(skb
->data
+ 4, skb
->data
, hdrlen
);
1314 memmove(skb
->data
+ 8, skb
->data
, hdrlen
);
1316 rxs
->flag
|= RX_FLAG_MMIC_STRIPPED
;
1318 rxs
->flag
|= RX_FLAG_DECRYPTED
;
1319 rxs
->flag
|= RX_FLAG_IV_STRIPPED
;
1322 for (i
= 0; i
< RSI_MAX_VIFS
; i
++) {
1323 vif
= adapter
->vifs
[i
];
1326 if (vif
->type
== NL80211_IFTYPE_STATION
) {
1327 bss
= &vif
->bss_conf
;
1333 /* CQM only for connected AP beacons, the RSSI is a weighted avg */
1334 if (bss
->assoc
&& !(memcmp(bss
->bssid
, hdr
->addr2
, ETH_ALEN
))) {
1335 if (ieee80211_is_beacon(hdr
->frame_control
))
1336 rsi_perform_cqm(common
, hdr
->addr2
, rxs
->signal
, vif
);
1343 * rsi_indicate_pkt_to_os() - This function sends received packet to mac80211.
1344 * @common: Pointer to the driver private structure.
1345 * @skb: Pointer to the socket buffer structure.
1349 void rsi_indicate_pkt_to_os(struct rsi_common
*common
,
1350 struct sk_buff
*skb
)
1352 struct rsi_hw
*adapter
= common
->priv
;
1353 struct ieee80211_hw
*hw
= adapter
->hw
;
1354 struct ieee80211_rx_status
*rx_status
= IEEE80211_SKB_RXCB(skb
);
1356 if ((common
->iface_down
) || (!adapter
->sc_nvifs
)) {
1361 /* filling in the ieee80211_rx_status flags */
1362 rsi_fill_rx_status(hw
, skb
, common
, rx_status
);
1364 ieee80211_rx_irqsafe(hw
, skb
);
1367 static void rsi_set_min_rate(struct ieee80211_hw
*hw
,
1368 struct ieee80211_sta
*sta
,
1369 struct rsi_common
*common
)
1371 u8 band
= hw
->conf
.chandef
.chan
->band
;
1374 bool matched
= false;
1376 common
->bitrate_mask
[band
] = sta
->supp_rates
[band
];
1378 rate_bitmap
= (common
->fixedrate_mask
[band
] & sta
->supp_rates
[band
]);
1380 if (rate_bitmap
& 0xfff) {
1381 /* Find out the min rate */
1382 for (ii
= 0; ii
< ARRAY_SIZE(rsi_rates
); ii
++) {
1383 if (rate_bitmap
& BIT(ii
)) {
1384 common
->min_rate
= rsi_rates
[ii
].hw_value
;
1391 common
->vif_info
[0].is_ht
= sta
->ht_cap
.ht_supported
;
1393 if ((common
->vif_info
[0].is_ht
) && (rate_bitmap
>> 12)) {
1394 for (ii
= 0; ii
< ARRAY_SIZE(rsi_mcsrates
); ii
++) {
1395 if ((rate_bitmap
>> 12) & BIT(ii
)) {
1396 common
->min_rate
= rsi_mcsrates
[ii
];
1404 common
->min_rate
= 0xffff;
1408 * rsi_mac80211_sta_add() - This function notifies driver about a peer getting
1410 * @hw: pointer to the ieee80211_hw structure.
1411 * @vif: Pointer to the ieee80211_vif structure.
1412 * @sta: Pointer to the ieee80211_sta structure.
1414 * Return: 0 on success, negative error codes on failure.
1416 static int rsi_mac80211_sta_add(struct ieee80211_hw
*hw
,
1417 struct ieee80211_vif
*vif
,
1418 struct ieee80211_sta
*sta
)
1420 struct rsi_hw
*adapter
= hw
->priv
;
1421 struct rsi_common
*common
= adapter
->priv
;
1422 bool sta_exist
= false;
1423 struct rsi_sta
*rsta
;
1426 rsi_dbg(INFO_ZONE
, "Station Add: %pM\n", sta
->addr
);
1428 mutex_lock(&common
->mutex
);
1430 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
1431 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
1434 int free_index
= -1;
1436 /* Check if max stations reached */
1437 if (common
->num_stations
>= common
->max_stations
) {
1438 rsi_dbg(ERR_ZONE
, "Reject: Max Stations exists\n");
1439 status
= -EOPNOTSUPP
;
1442 for (cnt
= 0; cnt
< common
->max_stations
; cnt
++) {
1443 rsta
= &common
->stations
[cnt
];
1450 if (!memcmp(rsta
->sta
->addr
, sta
->addr
, ETH_ALEN
)) {
1451 rsi_dbg(INFO_ZONE
, "Station exists\n");
1458 if (free_index
>= 0)
1459 sta_idx
= free_index
;
1463 "%s: Some problem reaching here...\n",
1468 rsta
= &common
->stations
[sta_idx
];
1470 rsta
->sta_id
= sta_idx
;
1471 for (cnt
= 0; cnt
< IEEE80211_NUM_TIDS
; cnt
++)
1472 rsta
->start_tx_aggr
[cnt
] = false;
1473 for (cnt
= 0; cnt
< IEEE80211_NUM_TIDS
; cnt
++)
1474 rsta
->seq_start
[cnt
] = 0;
1476 rsi_dbg(INFO_ZONE
, "New Station\n");
1478 /* Send peer notify to device */
1479 rsi_dbg(INFO_ZONE
, "Indicate bss status to device\n");
1480 rsi_inform_bss_status(common
, RSI_OPMODE_AP
, 1,
1481 sta
->addr
, sta
->wme
, sta
->aid
,
1482 sta
, sta_idx
, 0, vif
);
1485 struct ieee80211_key_conf
*key
= common
->key
;
1487 if ((key
->cipher
== WLAN_CIPHER_SUITE_WEP104
) ||
1488 (key
->cipher
== WLAN_CIPHER_SUITE_WEP40
))
1489 rsi_hal_load_key(adapter
->priv
,
1499 common
->num_stations
++;
1503 if ((vif
->type
== NL80211_IFTYPE_STATION
) ||
1504 (vif
->type
== NL80211_IFTYPE_P2P_CLIENT
)) {
1505 rsi_set_min_rate(hw
, sta
, common
);
1506 if (sta
->ht_cap
.ht_supported
) {
1507 common
->vif_info
[0].is_ht
= true;
1508 common
->bitrate_mask
[NL80211_BAND_2GHZ
] =
1509 sta
->supp_rates
[NL80211_BAND_2GHZ
];
1510 if ((sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
) ||
1511 (sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
))
1512 common
->vif_info
[0].sgi
= true;
1513 ieee80211_start_tx_ba_session(sta
, 0, 0);
1518 mutex_unlock(&common
->mutex
);
1524 * rsi_mac80211_sta_remove() - This function notifies driver about a peer
1525 * getting disconnected.
1526 * @hw: Pointer to the ieee80211_hw structure.
1527 * @vif: Pointer to the ieee80211_vif structure.
1528 * @sta: Pointer to the ieee80211_sta structure.
1530 * Return: 0 on success, negative error codes on failure.
1532 static int rsi_mac80211_sta_remove(struct ieee80211_hw
*hw
,
1533 struct ieee80211_vif
*vif
,
1534 struct ieee80211_sta
*sta
)
1536 struct rsi_hw
*adapter
= hw
->priv
;
1537 struct rsi_common
*common
= adapter
->priv
;
1538 struct ieee80211_bss_conf
*bss
= &vif
->bss_conf
;
1539 struct rsi_sta
*rsta
;
1541 rsi_dbg(INFO_ZONE
, "Station Remove: %pM\n", sta
->addr
);
1543 mutex_lock(&common
->mutex
);
1545 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
1546 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
1549 /* Send peer notify to device */
1550 rsi_dbg(INFO_ZONE
, "Indicate bss status to device\n");
1551 for (sta_idx
= 0; sta_idx
< common
->max_stations
; sta_idx
++) {
1552 rsta
= &common
->stations
[sta_idx
];
1556 if (!memcmp(rsta
->sta
->addr
, sta
->addr
, ETH_ALEN
)) {
1557 rsi_inform_bss_status(common
, RSI_OPMODE_AP
, 0,
1558 sta
->addr
, sta
->wme
,
1559 sta
->aid
, sta
, sta_idx
,
1563 for (cnt
= 0; cnt
< IEEE80211_NUM_TIDS
; cnt
++)
1564 rsta
->start_tx_aggr
[cnt
] = false;
1565 if (common
->num_stations
> 0)
1566 common
->num_stations
--;
1570 if (sta_idx
>= common
->max_stations
)
1571 rsi_dbg(ERR_ZONE
, "%s: No station found\n", __func__
);
1574 if ((vif
->type
== NL80211_IFTYPE_STATION
) ||
1575 (vif
->type
== NL80211_IFTYPE_P2P_CLIENT
)) {
1576 /* Resetting all the fields to default values */
1577 memcpy((u8
*)bss
->bssid
, (u8
*)sta
->addr
, ETH_ALEN
);
1578 bss
->qos
= sta
->wme
;
1579 common
->bitrate_mask
[NL80211_BAND_2GHZ
] = 0;
1580 common
->bitrate_mask
[NL80211_BAND_5GHZ
] = 0;
1581 common
->min_rate
= 0xffff;
1582 common
->vif_info
[0].is_ht
= false;
1583 common
->vif_info
[0].sgi
= false;
1584 common
->vif_info
[0].seq_start
= 0;
1585 common
->secinfo
.ptk_cipher
= 0;
1586 common
->secinfo
.gtk_cipher
= 0;
1587 if (!common
->iface_down
)
1588 rsi_send_rx_filter_frame(common
, 0);
1590 mutex_unlock(&common
->mutex
);
1596 * rsi_mac80211_set_antenna() - This function is used to configure
1597 * tx and rx antennas.
1598 * @hw: Pointer to the ieee80211_hw structure.
1599 * @tx_ant: Bitmap for tx antenna
1600 * @rx_ant: Bitmap for rx antenna
1602 * Return: 0 on success, Negative error code on failure.
1604 static int rsi_mac80211_set_antenna(struct ieee80211_hw
*hw
,
1605 u32 tx_ant
, u32 rx_ant
)
1607 struct rsi_hw
*adapter
= hw
->priv
;
1608 struct rsi_common
*common
= adapter
->priv
;
1611 if (tx_ant
> 1 || rx_ant
> 1) {
1613 "Invalid antenna selection (tx: %d, rx:%d)\n",
1616 "Use 0 for int_ant, 1 for ext_ant\n");
1620 rsi_dbg(INFO_ZONE
, "%s: Antenna map Tx %x Rx %d\n",
1621 __func__
, tx_ant
, rx_ant
);
1623 mutex_lock(&common
->mutex
);
1625 antenna
= tx_ant
? ANTENNA_SEL_UFL
: ANTENNA_SEL_INT
;
1626 if (common
->ant_in_use
!= antenna
)
1627 if (rsi_set_antenna(common
, antenna
))
1628 goto fail_set_antenna
;
1630 rsi_dbg(INFO_ZONE
, "(%s) Antenna path configured successfully\n",
1631 tx_ant
? "UFL" : "INT");
1633 common
->ant_in_use
= antenna
;
1635 mutex_unlock(&common
->mutex
);
1640 rsi_dbg(ERR_ZONE
, "%s: Failed.\n", __func__
);
1641 mutex_unlock(&common
->mutex
);
1646 * rsi_mac80211_get_antenna() - This function is used to configure
1647 * tx and rx antennas.
1649 * @hw: Pointer to the ieee80211_hw structure.
1650 * @tx_ant: Bitmap for tx antenna
1651 * @rx_ant: Bitmap for rx antenna
1653 * Return: 0 on success, negative error codes on failure.
1655 static int rsi_mac80211_get_antenna(struct ieee80211_hw
*hw
,
1656 u32
*tx_ant
, u32
*rx_ant
)
1658 struct rsi_hw
*adapter
= hw
->priv
;
1659 struct rsi_common
*common
= adapter
->priv
;
1661 mutex_lock(&common
->mutex
);
1663 *tx_ant
= (common
->ant_in_use
== ANTENNA_SEL_UFL
) ? 1 : 0;
1666 mutex_unlock(&common
->mutex
);
1671 static int rsi_map_region_code(enum nl80211_dfs_regions region_code
)
1673 switch (region_code
) {
1674 case NL80211_DFS_FCC
:
1675 return RSI_REGION_FCC
;
1676 case NL80211_DFS_ETSI
:
1677 return RSI_REGION_ETSI
;
1678 case NL80211_DFS_JP
:
1679 return RSI_REGION_TELEC
;
1680 case NL80211_DFS_UNSET
:
1681 return RSI_REGION_WORLD
;
1683 return RSI_REGION_WORLD
;
1686 static void rsi_reg_notify(struct wiphy
*wiphy
,
1687 struct regulatory_request
*request
)
1689 struct ieee80211_supported_band
*sband
;
1690 struct ieee80211_channel
*ch
;
1691 struct ieee80211_hw
*hw
= wiphy_to_ieee80211_hw(wiphy
);
1692 struct rsi_hw
* adapter
= hw
->priv
;
1693 struct rsi_common
*common
= adapter
->priv
;
1696 mutex_lock(&common
->mutex
);
1698 rsi_dbg(INFO_ZONE
, "country = %s dfs_region = %d\n",
1699 request
->alpha2
, request
->dfs_region
);
1701 if (common
->num_supp_bands
> 1) {
1702 sband
= wiphy
->bands
[NL80211_BAND_5GHZ
];
1704 for (i
= 0; i
< sband
->n_channels
; i
++) {
1705 ch
= &sband
->channels
[i
];
1706 if (ch
->flags
& IEEE80211_CHAN_DISABLED
)
1709 if (ch
->flags
& IEEE80211_CHAN_RADAR
)
1710 ch
->flags
|= IEEE80211_CHAN_NO_IR
;
1713 adapter
->dfs_region
= rsi_map_region_code(request
->dfs_region
);
1714 rsi_dbg(INFO_ZONE
, "RSI region code = %d\n", adapter
->dfs_region
);
1716 adapter
->country
[0] = request
->alpha2
[0];
1717 adapter
->country
[1] = request
->alpha2
[1];
1719 mutex_unlock(&common
->mutex
);
1722 static void rsi_mac80211_rfkill_poll(struct ieee80211_hw
*hw
)
1724 struct rsi_hw
*adapter
= hw
->priv
;
1725 struct rsi_common
*common
= adapter
->priv
;
1727 mutex_lock(&common
->mutex
);
1728 if (common
->fsm_state
!= FSM_MAC_INIT_DONE
)
1729 wiphy_rfkill_set_hw_state(hw
->wiphy
, true);
1731 wiphy_rfkill_set_hw_state(hw
->wiphy
, false);
1732 mutex_unlock(&common
->mutex
);
1735 static void rsi_resume_conn_channel(struct rsi_common
*common
)
1737 struct rsi_hw
*adapter
= common
->priv
;
1738 struct ieee80211_vif
*vif
;
1741 for (cnt
= 0; cnt
< RSI_MAX_VIFS
; cnt
++) {
1742 vif
= adapter
->vifs
[cnt
];
1746 if ((vif
->type
== NL80211_IFTYPE_AP
) ||
1747 (vif
->type
== NL80211_IFTYPE_P2P_GO
)) {
1748 rsi_switch_channel(adapter
, vif
);
1751 if (((vif
->type
== NL80211_IFTYPE_STATION
) ||
1752 (vif
->type
== NL80211_IFTYPE_P2P_CLIENT
)) &&
1753 vif
->bss_conf
.assoc
) {
1754 rsi_switch_channel(adapter
, vif
);
1760 void rsi_roc_timeout(struct timer_list
*t
)
1762 struct rsi_common
*common
= from_timer(common
, t
, roc_timer
);
1764 rsi_dbg(INFO_ZONE
, "Remain on channel expired\n");
1766 mutex_lock(&common
->mutex
);
1767 ieee80211_remain_on_channel_expired(common
->priv
->hw
);
1769 if (timer_pending(&common
->roc_timer
))
1770 del_timer(&common
->roc_timer
);
1772 rsi_resume_conn_channel(common
);
1773 mutex_unlock(&common
->mutex
);
1776 static int rsi_mac80211_roc(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
1777 struct ieee80211_channel
*chan
, int duration
,
1778 enum ieee80211_roc_type type
)
1780 struct rsi_hw
*adapter
= (struct rsi_hw
*)hw
->priv
;
1781 struct rsi_common
*common
= (struct rsi_common
*)adapter
->priv
;
1784 rsi_dbg(INFO_ZONE
, "***** Remain on channel *****\n");
1786 mutex_lock(&common
->mutex
);
1787 rsi_dbg(INFO_ZONE
, "%s: channel: %d duration: %dms\n",
1788 __func__
, chan
->hw_value
, duration
);
1790 if (timer_pending(&common
->roc_timer
)) {
1791 rsi_dbg(INFO_ZONE
, "Stop on-going ROC\n");
1792 del_timer(&common
->roc_timer
);
1794 common
->roc_timer
.expires
= msecs_to_jiffies(duration
) + jiffies
;
1795 add_timer(&common
->roc_timer
);
1797 /* Configure band */
1798 if (rsi_band_check(common
, chan
)) {
1799 rsi_dbg(ERR_ZONE
, "Failed to set band\n");
1804 /* Configure channel */
1805 if (rsi_set_channel(common
, chan
)) {
1806 rsi_dbg(ERR_ZONE
, "Failed to set the channel\n");
1811 common
->roc_vif
= vif
;
1812 ieee80211_ready_on_channel(hw
);
1813 rsi_dbg(INFO_ZONE
, "%s: Ready on channel :%d\n",
1814 __func__
, chan
->hw_value
);
1817 mutex_unlock(&common
->mutex
);
1822 static int rsi_mac80211_cancel_roc(struct ieee80211_hw
*hw
,
1823 struct ieee80211_vif
*vif
)
1825 struct rsi_hw
*adapter
= hw
->priv
;
1826 struct rsi_common
*common
= adapter
->priv
;
1828 rsi_dbg(INFO_ZONE
, "Cancel remain on channel\n");
1830 mutex_lock(&common
->mutex
);
1831 if (!timer_pending(&common
->roc_timer
)) {
1832 mutex_unlock(&common
->mutex
);
1836 del_timer(&common
->roc_timer
);
1838 rsi_resume_conn_channel(common
);
1839 mutex_unlock(&common
->mutex
);
1845 static const struct wiphy_wowlan_support rsi_wowlan_support
= {
1846 .flags
= WIPHY_WOWLAN_ANY
|
1847 WIPHY_WOWLAN_MAGIC_PKT
|
1848 WIPHY_WOWLAN_DISCONNECT
|
1849 WIPHY_WOWLAN_GTK_REKEY_FAILURE
|
1850 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
1851 WIPHY_WOWLAN_EAP_IDENTITY_REQ
|
1852 WIPHY_WOWLAN_4WAY_HANDSHAKE
,
1855 static u16
rsi_wow_map_triggers(struct rsi_common
*common
,
1856 struct cfg80211_wowlan
*wowlan
)
1858 u16 wow_triggers
= 0;
1860 rsi_dbg(INFO_ZONE
, "Mapping wowlan triggers\n");
1863 wow_triggers
|= RSI_WOW_ANY
;
1864 if (wowlan
->magic_pkt
)
1865 wow_triggers
|= RSI_WOW_MAGIC_PKT
;
1866 if (wowlan
->disconnect
)
1867 wow_triggers
|= RSI_WOW_DISCONNECT
;
1868 if (wowlan
->gtk_rekey_failure
|| wowlan
->eap_identity_req
||
1869 wowlan
->four_way_handshake
)
1870 wow_triggers
|= RSI_WOW_GTK_REKEY
;
1872 return wow_triggers
;
1875 int rsi_config_wowlan(struct rsi_hw
*adapter
, struct cfg80211_wowlan
*wowlan
)
1877 struct rsi_common
*common
= adapter
->priv
;
1879 u16 rx_filter_word
= 0;
1880 struct ieee80211_bss_conf
*bss
= NULL
;
1882 rsi_dbg(INFO_ZONE
, "Config WoWLAN to device\n");
1884 if (!adapter
->vifs
[0])
1887 bss
= &adapter
->vifs
[0]->bss_conf
;
1889 if (WARN_ON(!wowlan
)) {
1890 rsi_dbg(ERR_ZONE
, "WoW triggers not enabled\n");
1894 common
->wow_flags
|= RSI_WOW_ENABLED
;
1895 triggers
= rsi_wow_map_triggers(common
, wowlan
);
1897 rsi_dbg(ERR_ZONE
, "%s:No valid WoW triggers\n", __func__
);
1902 "Cannot configure WoWLAN (Station not connected)\n");
1903 common
->wow_flags
|= RSI_WOW_NO_CONNECTION
;
1906 rsi_dbg(INFO_ZONE
, "TRIGGERS %x\n", triggers
);
1908 if (common
->coex_mode
> 1)
1909 rsi_disable_ps(adapter
, adapter
->vifs
[0]);
1911 rsi_send_wowlan_request(common
, triggers
, 1);
1914 * Increase the beacon_miss threshold & keep-alive timers in
1917 rsi_send_vap_dynamic_update(common
);
1919 rx_filter_word
= (ALLOW_DATA_ASSOC_PEER
| DISALLOW_BEACONS
);
1920 rsi_send_rx_filter_frame(common
, rx_filter_word
);
1924 EXPORT_SYMBOL(rsi_config_wowlan
);
1926 static int rsi_mac80211_suspend(struct ieee80211_hw
*hw
,
1927 struct cfg80211_wowlan
*wowlan
)
1929 struct rsi_hw
*adapter
= hw
->priv
;
1930 struct rsi_common
*common
= adapter
->priv
;
1932 rsi_dbg(INFO_ZONE
, "%s: mac80211 suspend\n", __func__
);
1933 mutex_lock(&common
->mutex
);
1934 if (rsi_config_wowlan(adapter
, wowlan
)) {
1935 rsi_dbg(ERR_ZONE
, "Failed to configure WoWLAN\n");
1936 mutex_unlock(&common
->mutex
);
1939 mutex_unlock(&common
->mutex
);
1944 static int rsi_mac80211_resume(struct ieee80211_hw
*hw
)
1946 u16 rx_filter_word
= 0;
1947 struct rsi_hw
*adapter
= hw
->priv
;
1948 struct rsi_common
*common
= adapter
->priv
;
1950 common
->wow_flags
= 0;
1952 rsi_dbg(INFO_ZONE
, "%s: mac80211 resume\n", __func__
);
1954 if (common
->hibernate_resume
) {
1955 common
->mac_ops_resumed
= true;
1956 /* Device need a complete restart of all MAC operations.
1957 * returning 1 will serve this purpose.
1962 mutex_lock(&common
->mutex
);
1963 rsi_send_wowlan_request(common
, 0, 0);
1965 rx_filter_word
= (ALLOW_DATA_ASSOC_PEER
| ALLOW_CTRL_ASSOC_PEER
|
1966 ALLOW_MGMT_ASSOC_PEER
);
1967 rsi_send_rx_filter_frame(common
, rx_filter_word
);
1968 mutex_unlock(&common
->mutex
);
1975 static const struct ieee80211_ops mac80211_ops
= {
1976 .tx
= rsi_mac80211_tx
,
1977 .start
= rsi_mac80211_start
,
1978 .stop
= rsi_mac80211_stop
,
1979 .add_interface
= rsi_mac80211_add_interface
,
1980 .remove_interface
= rsi_mac80211_remove_interface
,
1981 .config
= rsi_mac80211_config
,
1982 .bss_info_changed
= rsi_mac80211_bss_info_changed
,
1983 .conf_tx
= rsi_mac80211_conf_tx
,
1984 .configure_filter
= rsi_mac80211_conf_filter
,
1985 .set_key
= rsi_mac80211_set_key
,
1986 .set_rts_threshold
= rsi_mac80211_set_rts_threshold
,
1987 .set_bitrate_mask
= rsi_mac80211_set_rate_mask
,
1988 .ampdu_action
= rsi_mac80211_ampdu_action
,
1989 .sta_add
= rsi_mac80211_sta_add
,
1990 .sta_remove
= rsi_mac80211_sta_remove
,
1991 .set_antenna
= rsi_mac80211_set_antenna
,
1992 .get_antenna
= rsi_mac80211_get_antenna
,
1993 .rfkill_poll
= rsi_mac80211_rfkill_poll
,
1994 .remain_on_channel
= rsi_mac80211_roc
,
1995 .cancel_remain_on_channel
= rsi_mac80211_cancel_roc
,
1997 .suspend
= rsi_mac80211_suspend
,
1998 .resume
= rsi_mac80211_resume
,
2000 .hw_scan
= rsi_mac80211_hw_scan_start
,
2001 .cancel_hw_scan
= rsi_mac80211_cancel_hw_scan
,
2005 * rsi_mac80211_attach() - This function is used to initialize Mac80211 stack.
2006 * @common: Pointer to the driver private structure.
2008 * Return: 0 on success, negative error codes on failure.
2010 int rsi_mac80211_attach(struct rsi_common
*common
)
2013 struct ieee80211_hw
*hw
= NULL
;
2014 struct wiphy
*wiphy
= NULL
;
2015 struct rsi_hw
*adapter
= common
->priv
;
2016 u8 addr_mask
[ETH_ALEN
] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x3};
2018 rsi_dbg(INIT_ZONE
, "%s: Performing mac80211 attach\n", __func__
);
2020 hw
= ieee80211_alloc_hw(sizeof(struct rsi_hw
), &mac80211_ops
);
2022 rsi_dbg(ERR_ZONE
, "%s: ieee80211 hw alloc failed\n", __func__
);
2028 SET_IEEE80211_DEV(hw
, adapter
->device
);
2033 ieee80211_hw_set(hw
, SIGNAL_DBM
);
2034 ieee80211_hw_set(hw
, HAS_RATE_CONTROL
);
2035 ieee80211_hw_set(hw
, AMPDU_AGGREGATION
);
2036 ieee80211_hw_set(hw
, SUPPORTS_PS
);
2037 ieee80211_hw_set(hw
, SUPPORTS_DYNAMIC_PS
);
2039 hw
->queues
= MAX_HW_QUEUES
;
2040 hw
->extra_tx_headroom
= RSI_NEEDED_HEADROOM
;
2043 hw
->max_rate_tries
= MAX_RETRIES
;
2044 hw
->uapsd_queues
= RSI_IEEE80211_UAPSD_QUEUES
;
2045 hw
->uapsd_max_sp_len
= IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL
;
2047 hw
->max_tx_aggregation_subframes
= RSI_MAX_TX_AGGR_FRMS
;
2048 hw
->max_rx_aggregation_subframes
= RSI_MAX_RX_AGGR_FRMS
;
2049 hw
->rate_control_algorithm
= "AARF";
2051 SET_IEEE80211_PERM_ADDR(hw
, common
->mac_addr
);
2052 ether_addr_copy(hw
->wiphy
->addr_mask
, addr_mask
);
2054 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
2055 BIT(NL80211_IFTYPE_AP
) |
2056 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
2057 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
2058 BIT(NL80211_IFTYPE_P2P_GO
);
2060 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
2061 wiphy
->retry_short
= RETRY_SHORT
;
2062 wiphy
->retry_long
= RETRY_LONG
;
2063 wiphy
->frag_threshold
= IEEE80211_MAX_FRAG_THRESHOLD
;
2064 wiphy
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
2067 wiphy
->available_antennas_rx
= 1;
2068 wiphy
->available_antennas_tx
= 1;
2070 status
= rsi_register_rates_channels(adapter
, NL80211_BAND_2GHZ
);
2073 wiphy
->bands
[NL80211_BAND_2GHZ
] =
2074 &adapter
->sbands
[NL80211_BAND_2GHZ
];
2075 if (common
->num_supp_bands
> 1) {
2076 status
= rsi_register_rates_channels(adapter
,
2080 wiphy
->bands
[NL80211_BAND_5GHZ
] =
2081 &adapter
->sbands
[NL80211_BAND_5GHZ
];
2085 wiphy
->max_ap_assoc_sta
= rsi_max_ap_stas
[common
->oper_mode
- 1];
2086 common
->max_stations
= wiphy
->max_ap_assoc_sta
;
2087 rsi_dbg(ERR_ZONE
, "Max Stations Allowed = %d\n", common
->max_stations
);
2088 hw
->sta_data_size
= sizeof(struct rsi_sta
);
2090 wiphy
->max_scan_ssids
= RSI_MAX_SCAN_SSIDS
;
2091 wiphy
->max_scan_ie_len
= RSI_MAX_SCAN_IE_LEN
;
2092 wiphy
->flags
= WIPHY_FLAG_REPORTS_OBSS
;
2093 wiphy
->flags
|= WIPHY_FLAG_AP_UAPSD
;
2094 wiphy
->features
|= NL80211_FEATURE_INACTIVITY_TIMER
;
2095 wiphy
->reg_notifier
= rsi_reg_notify
;
2098 wiphy
->wowlan
= &rsi_wowlan_support
;
2101 wiphy_ext_feature_set(wiphy
, NL80211_EXT_FEATURE_CQM_RSSI_LIST
);
2103 /* Wi-Fi direct parameters */
2104 wiphy
->flags
|= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
;
2105 wiphy
->flags
|= WIPHY_FLAG_OFFCHAN_TX
;
2106 wiphy
->max_remain_on_channel_duration
= 10000;
2107 hw
->max_listen_interval
= 10;
2108 wiphy
->iface_combinations
= rsi_iface_combinations
;
2109 wiphy
->n_iface_combinations
= ARRAY_SIZE(rsi_iface_combinations
);
2111 if (common
->coex_mode
> 1)
2112 wiphy
->flags
|= WIPHY_FLAG_PS_ON_BY_DEFAULT
;
2114 status
= ieee80211_register_hw(hw
);
2118 return rsi_init_dbgfs(adapter
);