1 /******************************************************************************
3 * Copyright(c) 2009-2010 Realtek Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
26 * Larry Finger <Larry.Finger@lwfinger.net>
28 *****************************************************************************/
31 #include <linux/module.h>
42 *NOTICE!!!: This file will be very big, we should
43 *keep it clear under following roles:
45 *This file include following part, so, if you add new
46 *functions into this file, please check which part it
47 *should includes. or check if you should add new part
50 *1) mac80211 init functions
51 *2) tx information functions
52 *3) functions called by core.c
53 *4) wq & timer callback functions
54 *5) frame process functions
61 /*********************************************************
63 * mac80211 init functions
65 *********************************************************/
66 static struct ieee80211_channel rtl_channeltable_2g
[] = {
67 {.center_freq
= 2412, .hw_value
= 1,},
68 {.center_freq
= 2417, .hw_value
= 2,},
69 {.center_freq
= 2422, .hw_value
= 3,},
70 {.center_freq
= 2427, .hw_value
= 4,},
71 {.center_freq
= 2432, .hw_value
= 5,},
72 {.center_freq
= 2437, .hw_value
= 6,},
73 {.center_freq
= 2442, .hw_value
= 7,},
74 {.center_freq
= 2447, .hw_value
= 8,},
75 {.center_freq
= 2452, .hw_value
= 9,},
76 {.center_freq
= 2457, .hw_value
= 10,},
77 {.center_freq
= 2462, .hw_value
= 11,},
78 {.center_freq
= 2467, .hw_value
= 12,},
79 {.center_freq
= 2472, .hw_value
= 13,},
80 {.center_freq
= 2484, .hw_value
= 14,},
83 static struct ieee80211_channel rtl_channeltable_5g
[] = {
84 {.center_freq
= 5180, .hw_value
= 36,},
85 {.center_freq
= 5200, .hw_value
= 40,},
86 {.center_freq
= 5220, .hw_value
= 44,},
87 {.center_freq
= 5240, .hw_value
= 48,},
88 {.center_freq
= 5260, .hw_value
= 52,},
89 {.center_freq
= 5280, .hw_value
= 56,},
90 {.center_freq
= 5300, .hw_value
= 60,},
91 {.center_freq
= 5320, .hw_value
= 64,},
92 {.center_freq
= 5500, .hw_value
= 100,},
93 {.center_freq
= 5520, .hw_value
= 104,},
94 {.center_freq
= 5540, .hw_value
= 108,},
95 {.center_freq
= 5560, .hw_value
= 112,},
96 {.center_freq
= 5580, .hw_value
= 116,},
97 {.center_freq
= 5600, .hw_value
= 120,},
98 {.center_freq
= 5620, .hw_value
= 124,},
99 {.center_freq
= 5640, .hw_value
= 128,},
100 {.center_freq
= 5660, .hw_value
= 132,},
101 {.center_freq
= 5680, .hw_value
= 136,},
102 {.center_freq
= 5700, .hw_value
= 140,},
103 {.center_freq
= 5745, .hw_value
= 149,},
104 {.center_freq
= 5765, .hw_value
= 153,},
105 {.center_freq
= 5785, .hw_value
= 157,},
106 {.center_freq
= 5805, .hw_value
= 161,},
107 {.center_freq
= 5825, .hw_value
= 165,},
110 static struct ieee80211_rate rtl_ratetable_2g
[] = {
111 {.bitrate
= 10, .hw_value
= 0x00,},
112 {.bitrate
= 20, .hw_value
= 0x01,},
113 {.bitrate
= 55, .hw_value
= 0x02,},
114 {.bitrate
= 110, .hw_value
= 0x03,},
115 {.bitrate
= 60, .hw_value
= 0x04,},
116 {.bitrate
= 90, .hw_value
= 0x05,},
117 {.bitrate
= 120, .hw_value
= 0x06,},
118 {.bitrate
= 180, .hw_value
= 0x07,},
119 {.bitrate
= 240, .hw_value
= 0x08,},
120 {.bitrate
= 360, .hw_value
= 0x09,},
121 {.bitrate
= 480, .hw_value
= 0x0a,},
122 {.bitrate
= 540, .hw_value
= 0x0b,},
125 static struct ieee80211_rate rtl_ratetable_5g
[] = {
126 {.bitrate
= 60, .hw_value
= 0x04,},
127 {.bitrate
= 90, .hw_value
= 0x05,},
128 {.bitrate
= 120, .hw_value
= 0x06,},
129 {.bitrate
= 180, .hw_value
= 0x07,},
130 {.bitrate
= 240, .hw_value
= 0x08,},
131 {.bitrate
= 360, .hw_value
= 0x09,},
132 {.bitrate
= 480, .hw_value
= 0x0a,},
133 {.bitrate
= 540, .hw_value
= 0x0b,},
136 static const struct ieee80211_supported_band rtl_band_2ghz
= {
137 .band
= IEEE80211_BAND_2GHZ
,
139 .channels
= rtl_channeltable_2g
,
140 .n_channels
= ARRAY_SIZE(rtl_channeltable_2g
),
142 .bitrates
= rtl_ratetable_2g
,
143 .n_bitrates
= ARRAY_SIZE(rtl_ratetable_2g
),
148 static struct ieee80211_supported_band rtl_band_5ghz
= {
149 .band
= IEEE80211_BAND_5GHZ
,
151 .channels
= rtl_channeltable_5g
,
152 .n_channels
= ARRAY_SIZE(rtl_channeltable_5g
),
154 .bitrates
= rtl_ratetable_5g
,
155 .n_bitrates
= ARRAY_SIZE(rtl_ratetable_5g
),
160 static const u8 tid_to_ac
[] = {
161 2, /* IEEE80211_AC_BE */
162 3, /* IEEE80211_AC_BK */
163 3, /* IEEE80211_AC_BK */
164 2, /* IEEE80211_AC_BE */
165 1, /* IEEE80211_AC_VI */
166 1, /* IEEE80211_AC_VI */
167 0, /* IEEE80211_AC_VO */
168 0, /* IEEE80211_AC_VO */
171 u8
rtl_tid_to_ac(struct ieee80211_hw
*hw
, u8 tid
)
173 return tid_to_ac
[tid
];
176 static void _rtl_init_hw_ht_capab(struct ieee80211_hw
*hw
,
177 struct ieee80211_sta_ht_cap
*ht_cap
)
179 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
180 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
182 ht_cap
->ht_supported
= true;
183 ht_cap
->cap
= IEEE80211_HT_CAP_SUP_WIDTH_20_40
|
184 IEEE80211_HT_CAP_SGI_40
|
185 IEEE80211_HT_CAP_SGI_20
|
186 IEEE80211_HT_CAP_DSSSCCK40
| IEEE80211_HT_CAP_MAX_AMSDU
;
188 if (rtlpriv
->rtlhal
.disable_amsdu_8k
)
189 ht_cap
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
192 *Maximum length of AMPDU that the STA can receive.
193 *Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
195 ht_cap
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
197 /*Minimum MPDU start spacing , */
198 ht_cap
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_16
;
200 ht_cap
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
203 *hw->wiphy->bands[IEEE80211_BAND_2GHZ]
206 *if rx_ant =1 rx_mask[0]=0xff;==>MCS0-MCS7
207 *if rx_ant =2 rx_mask[1]=0xff;==>MCS8-MCS15
208 *if rx_ant >=3 rx_mask[2]=0xff;
209 *if BW_40 rx_mask[4]=0x01;
210 *highest supported RX rate
212 if (rtlpriv
->dm
.supp_phymode_switch
) {
213 RT_TRACE(COMP_INIT
, DBG_EMERG
, ("Support phy mode switch\n"));
215 ht_cap
->mcs
.rx_mask
[0] = 0xFF;
216 ht_cap
->mcs
.rx_mask
[1] = 0xFF;
217 ht_cap
->mcs
.rx_mask
[4] = 0x01;
219 ht_cap
->mcs
.rx_highest
= MAX_BIT_RATE_40MHZ_MCS15
;
221 if (get_rf_type(rtlphy
) == RF_1T2R
||
222 get_rf_type(rtlphy
) == RF_2T2R
) {
224 RT_TRACE(COMP_INIT
, DBG_DMESG
, ("1T2R or 2T2R\n"));
226 ht_cap
->mcs
.rx_mask
[0] = 0xFF;
227 ht_cap
->mcs
.rx_mask
[1] = 0xFF;
228 ht_cap
->mcs
.rx_mask
[4] = 0x01;
230 ht_cap
->mcs
.rx_highest
= MAX_BIT_RATE_40MHZ_MCS15
;
231 } else if (get_rf_type(rtlphy
) == RF_1T1R
) {
233 RT_TRACE(COMP_INIT
, DBG_DMESG
, ("1T1R\n"));
235 ht_cap
->mcs
.rx_mask
[0] = 0xFF;
236 ht_cap
->mcs
.rx_mask
[1] = 0x00;
237 ht_cap
->mcs
.rx_mask
[4] = 0x01;
239 ht_cap
->mcs
.rx_highest
= MAX_BIT_RATE_40MHZ_MCS7
;
244 static void _rtl_init_mac80211(struct ieee80211_hw
*hw
)
246 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
247 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
248 struct rtl_mac
*rtlmac
= rtl_mac(rtl_priv(hw
));
249 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
250 struct ieee80211_supported_band
*sband
;
253 if (rtlhal
->macphymode
== SINGLEMAC_SINGLEPHY
&&
254 rtlhal
->bandset
== BAND_ON_BOTH
) {
256 /* <1> use mac->bands as mem for hw->wiphy->bands */
257 sband
= &(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]);
259 /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ]
260 * to default value(1T1R) */
261 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]), &rtl_band_2ghz
,
262 sizeof(struct ieee80211_supported_band
));
264 /* <3> init ht cap base on ant_num */
265 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
267 /* <4> set mac->sband to wiphy->sband */
268 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = sband
;
271 /* <1> use mac->bands as mem for hw->wiphy->bands */
272 sband
= &(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]);
274 /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ]
275 * to default value(1T1R) */
276 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]), &rtl_band_5ghz
,
277 sizeof(struct ieee80211_supported_band
));
279 /* <3> init ht cap base on ant_num */
280 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
282 /* <4> set mac->sband to wiphy->sband */
283 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = sband
;
285 if (rtlhal
->current_bandtype
== BAND_ON_2_4G
) {
286 /* <1> use mac->bands as mem for hw->wiphy->bands */
287 sband
= &(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]);
289 /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ]
290 * to default value(1T1R) */
291 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]),
293 sizeof(struct ieee80211_supported_band
));
295 /* <3> init ht cap base on ant_num */
296 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
298 /* <4> set mac->sband to wiphy->sband */
299 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = sband
;
300 } else if (rtlhal
->current_bandtype
== BAND_ON_5G
) {
301 /* <1> use mac->bands as mem for hw->wiphy->bands */
302 sband
= &(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]);
304 /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ]
305 * to default value(1T1R) */
306 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]),
308 sizeof(struct ieee80211_supported_band
));
310 /* <3> init ht cap base on ant_num */
311 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
313 /* <4> set mac->sband to wiphy->sband */
314 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = sband
;
316 RT_TRACE(COMP_INIT
, DBG_EMERG
, ("Err BAND %d\n",
317 rtlhal
->current_bandtype
));
320 /* <5> set hw caps */
321 hw
->flags
= IEEE80211_HW_SIGNAL_DBM
|
322 IEEE80211_HW_RX_INCLUDES_FCS
|
323 IEEE80211_HW_AMPDU_AGGREGATION
|
324 IEEE80211_HW_REPORTS_TX_ACK_STATUS
|
325 IEEE80211_HW_CONNECTION_MONITOR
|
326 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
327 IEEE80211_HW_MFP_CAPABLE
| 0;
329 /* swlps or hwlps has been set in diff chip in init_sw_vars */
330 if (rtlpriv
->psc
.b_swctrl_lps
)
331 hw
->flags
|= IEEE80211_HW_SUPPORTS_PS
|
332 IEEE80211_HW_PS_NULLFUNC_STACK
|
333 /* IEEE80211_HW_SUPPORTS_DYNAMIC_PS | */
335 hw
->wiphy
->interface_modes
=
336 BIT(NL80211_IFTYPE_AP
) |
337 BIT(NL80211_IFTYPE_STATION
) |
338 BIT(NL80211_IFTYPE_ADHOC
) |
339 BIT(NL80211_IFTYPE_MESH_POINT
) |
340 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
341 BIT(NL80211_IFTYPE_P2P_GO
);
343 hw
->wiphy
->flags
|= WIPHY_FLAG_IBSS_RSN
;
345 hw
->wiphy
->flags
|= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
;
347 hw
->wiphy
->rts_threshold
= 2347;
350 hw
->extra_tx_headroom
= RTL_TX_HEADER_SIZE
;
352 /* TODO: Correct this value for our hw */
353 /* TODO: define these hard code value */
354 hw
->max_listen_interval
= 10;
355 hw
->max_rate_tries
= 4;
356 /* hw->max_rates = 1; */
357 hw
->sta_data_size
= sizeof(struct rtl_sta_info
);
359 hw
->vif_data_size
= sizeof(struct rtl_vif_info
);
362 /* <6> mac address */
363 if (is_valid_ether_addr(rtlefuse
->dev_addr
)) {
364 SET_IEEE80211_PERM_ADDR(hw
, rtlefuse
->dev_addr
);
366 u8 rtlmac
[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 };
367 get_random_bytes((rtlmac
+ (ETH_ALEN
- 1)), 1);
368 SET_IEEE80211_PERM_ADDR(hw
, rtlmac
);
373 static int _rtl_init_deferred_work(struct ieee80211_hw
*hw
)
375 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
378 init_timer(&rtlpriv
->works
.watchdog_timer
);
379 setup_timer(&rtlpriv
->works
.watchdog_timer
,
380 rtl_watch_dog_timer_callback
, (unsigned long)hw
);
381 init_timer(&rtlpriv
->works
.dualmac_easyconcurrent_retrytimer
);
382 setup_timer(&rtlpriv
->works
.dualmac_easyconcurrent_retrytimer
,
383 rtl_easy_concurrent_retrytimer_callback
, (unsigned long)hw
);
385 rtlpriv
->works
.hw
= hw
;
386 rtlpriv
->works
.rtl_wq
= alloc_workqueue("%s", 0, 0,
388 if (!rtlpriv
->works
.rtl_wq
)
391 INIT_DELAYED_WORK(&rtlpriv
->works
.watchdog_wq
,
392 (void *)rtl_watchdog_wq_callback
);
393 INIT_DELAYED_WORK(&rtlpriv
->works
.ips_nic_off_wq
,
394 (void *)rtl_ips_nic_off_wq_callback
);
395 INIT_DELAYED_WORK(&rtlpriv
->works
.ps_work
,
396 (void *)rtl_swlps_wq_callback
);
397 INIT_DELAYED_WORK(&rtlpriv
->works
.ps_rfon_wq
,
398 (void *)rtl_swlps_rfon_wq_callback
);
399 INIT_DELAYED_WORK(&rtlpriv
->works
.fwevt_wq
,
400 (void *)rtl_fwevt_wq_callback
);
406 void rtl_deinit_deferred_work(struct ieee80211_hw
*hw
)
408 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
410 del_timer_sync(&rtlpriv
->works
.watchdog_timer
);
412 cancel_delayed_work(&rtlpriv
->works
.watchdog_wq
);
413 cancel_delayed_work(&rtlpriv
->works
.ips_nic_off_wq
);
414 cancel_delayed_work(&rtlpriv
->works
.ps_work
);
415 cancel_delayed_work(&rtlpriv
->works
.ps_rfon_wq
);
416 cancel_delayed_work(&rtlpriv
->works
.fwevt_wq
);
419 void rtl_init_rfkill(struct ieee80211_hw
*hw
)
421 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
427 /*set init state to on */
428 rtlpriv
->rfkill
.rfkill_state
= 1;
429 wiphy_rfkill_set_hw_state(hw
->wiphy
, 0);
431 radio_state
= rtlpriv
->cfg
->ops
->radio_onoff_checking(hw
, &valid
);
434 printk(KERN_INFO
"rtlwifi: wireless switch is %s\n",
435 rtlpriv
->rfkill
.rfkill_state
? "on" : "off");
437 rtlpriv
->rfkill
.rfkill_state
= radio_state
;
439 blocked
= (rtlpriv
->rfkill
.rfkill_state
== 1) ? 0 : 1;
440 wiphy_rfkill_set_hw_state(hw
->wiphy
, blocked
);
443 wiphy_rfkill_start_polling(hw
->wiphy
);
446 void rtl_deinit_rfkill(struct ieee80211_hw
*hw
)
448 wiphy_rfkill_stop_polling(hw
->wiphy
);
452 static void rtl_init_vif(struct ieee80211_hw
*hw
)
454 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
456 INIT_LIST_HEAD(&rtlpriv
->vif_priv
.vif_list
);
458 rtlpriv
->vif_priv
.vifs
= 0;
462 int rtl_init_core(struct ieee80211_hw
*hw
)
464 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
465 struct rtl_mac
*rtlmac
= rtl_mac(rtl_priv(hw
));
467 /* <1> init mac80211 */
468 _rtl_init_mac80211(hw
);
470 rtlmac
->link_state
= MAC80211_NOLINK
;
472 /* <2> rate control register */
473 hw
->rate_control_algorithm
= "rtl_rc";
476 * <3> init CRDA must come after init
477 * mac80211 hw in _rtl_init_mac80211.
479 if (rtl_regd_init(hw
, rtl_reg_notifier
)) {
480 RT_TRACE(COMP_ERR
, DBG_EMERG
, ("REGD init failed\n"));
485 mutex_init(&rtlpriv
->locks
.conf_mutex
);
486 spin_lock_init(&rtlpriv
->locks
.ips_lock
);
487 spin_lock_init(&rtlpriv
->locks
.irq_th_lock
);
488 spin_lock_init(&rtlpriv
->locks
.h2c_lock
);
489 spin_lock_init(&rtlpriv
->locks
.rf_ps_lock
);
490 spin_lock_init(&rtlpriv
->locks
.rf_lock
);
491 spin_lock_init(&rtlpriv
->locks
.lps_lock
);
492 spin_lock_init(&rtlpriv
->locks
.waitq_lock
);
493 spin_lock_init(&rtlpriv
->locks
.entry_list_lock
);
494 spin_lock_init(&rtlpriv
->locks
.cck_and_rw_pagea_lock
);
495 spin_lock_init(&rtlpriv
->locks
.check_sendpkt_lock
);
496 spin_lock_init(&rtlpriv
->locks
.fw_ps_lock
);
497 spin_lock_init(&rtlpriv
->locks
.iqk_lock
);
499 INIT_LIST_HEAD(&rtlpriv
->entry_list
);
501 /* <6> init deferred work */
502 if (_rtl_init_deferred_work(hw
))
513 void rtl_deinit_core(struct ieee80211_hw
*hw
)
517 void rtl_init_rx_config(struct ieee80211_hw
*hw
)
519 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
520 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
522 rtlpriv
->cfg
->ops
->get_hw_reg(hw
, HW_VAR_RCR
, (u8
*) (&mac
->rx_conf
));
525 /*********************************************************
527 * tx information functions
529 *********************************************************/
530 static void _rtl_qurey_shortpreamble_mode(struct ieee80211_hw
*hw
,
531 struct rtl_tcb_desc
*tcb_desc
,
532 struct ieee80211_tx_info
*info
)
534 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
535 u8 rate_flag
= info
->control
.rates
[0].flags
;
537 tcb_desc
->use_shortpreamble
= false;
539 /* 1M can only use Long Preamble. 11B spec */
540 if (tcb_desc
->hw_rate
== rtlpriv
->cfg
->maps
[RTL_RC_CCK_RATE1M
])
542 else if (rate_flag
& IEEE80211_TX_RC_USE_SHORT_PREAMBLE
)
543 tcb_desc
->use_shortpreamble
= true;
548 static void _rtl_query_shortgi(struct ieee80211_hw
*hw
,
549 struct ieee80211_sta
*sta
,
550 struct rtl_tcb_desc
*tcb_desc
,
551 struct ieee80211_tx_info
*info
)
553 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
554 u8 rate_flag
= info
->control
.rates
[0].flags
;
555 u8 sgi_40
= 0, sgi_20
= 0, bw_40
= 0;
556 tcb_desc
->use_shortgi
= false;
561 sgi_40
= sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
;
562 sgi_20
= sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
;
564 if (!(sta
->ht_cap
.ht_supported
))
567 if (!sgi_40
&& !sgi_20
)
570 if (mac
->opmode
== NL80211_IFTYPE_STATION
)
572 else if (mac
->opmode
== NL80211_IFTYPE_AP
||
573 mac
->opmode
== NL80211_IFTYPE_ADHOC
||
574 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
)
575 bw_40
= sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
577 if ((bw_40
== true) && sgi_40
)
578 tcb_desc
->use_shortgi
= true;
579 else if ((bw_40
== false) && sgi_20
)
580 tcb_desc
->use_shortgi
= true;
582 if (!(rate_flag
& IEEE80211_TX_RC_SHORT_GI
))
583 tcb_desc
->use_shortgi
= false;
586 static void _rtl_query_protection_mode(struct ieee80211_hw
*hw
,
587 struct rtl_tcb_desc
*tcb_desc
,
588 struct ieee80211_tx_info
*info
)
590 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
591 u8 rate_flag
= info
->control
.rates
[0].flags
;
593 /* Common Settings */
594 tcb_desc
->b_rts_stbc
= false;
595 tcb_desc
->b_cts_enable
= false;
596 tcb_desc
->rts_sc
= 0;
597 tcb_desc
->b_rts_bw
= false;
598 tcb_desc
->b_rts_use_shortpreamble
= false;
599 tcb_desc
->b_rts_use_shortgi
= false;
601 if (rate_flag
& IEEE80211_TX_RC_USE_CTS_PROTECT
) {
602 /* Use CTS-to-SELF in protection mode. */
603 tcb_desc
->b_rts_enable
= true;
604 tcb_desc
->b_cts_enable
= true;
605 tcb_desc
->rts_rate
= rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE24M
];
606 } else if (rate_flag
& IEEE80211_TX_RC_USE_RTS_CTS
) {
607 /* Use RTS-CTS in protection mode. */
608 tcb_desc
->b_rts_enable
= true;
609 tcb_desc
->rts_rate
= rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE24M
];
613 static void _rtl_txrate_selectmode(struct ieee80211_hw
*hw
,
614 struct ieee80211_sta
*sta
,
615 struct rtl_tcb_desc
*tcb_desc
)
617 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
618 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
619 struct rtl_sta_info
*sta_entry
= NULL
;
623 sta_entry
= (struct rtl_sta_info
*) sta
->drv_priv
;
624 ratr_index
= sta_entry
->ratr_index
;
626 if (!tcb_desc
->disable_ratefallback
|| !tcb_desc
->use_driver_rate
) {
627 if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
628 tcb_desc
->ratr_index
= 0;
629 } else if (mac
->opmode
== NL80211_IFTYPE_ADHOC
||
630 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
631 if (tcb_desc
->b_multicast
|| tcb_desc
->b_broadcast
) {
633 rtlpriv
->cfg
->maps
[RTL_RC_CCK_RATE2M
];
634 tcb_desc
->use_driver_rate
= 1;
635 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_MC
;
637 tcb_desc
->ratr_index
= ratr_index
;
639 } else if (mac
->opmode
== NL80211_IFTYPE_AP
) {
640 tcb_desc
->ratr_index
= ratr_index
;
644 if (rtlpriv
->dm
.b_useramask
) {
645 tcb_desc
->ratr_index
= ratr_index
;
646 /* TODO we will differentiate adhoc and station future */
647 if (mac
->opmode
== NL80211_IFTYPE_STATION
||
648 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
649 tcb_desc
->mac_id
= 0;
650 if (mac
->mode
== WIRELESS_MODE_N_24G
)
651 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_NGB
;
652 else if (mac
->mode
== WIRELESS_MODE_N_5G
)
653 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_NG
;
654 else if (mac
->mode
& WIRELESS_MODE_G
)
655 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_GB
;
656 else if (mac
->mode
& WIRELESS_MODE_B
)
657 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_B
;
658 else if (mac
->mode
& WIRELESS_MODE_A
)
659 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_G
;
660 } else if (mac
->opmode
== NL80211_IFTYPE_AP
||
661 mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
664 tcb_desc
->mac_id
= sta
->aid
+ 1;
666 tcb_desc
->mac_id
= 1;
668 tcb_desc
->mac_id
= 0;
674 static void _rtl_query_bandwidth_mode(struct ieee80211_hw
*hw
,
675 struct ieee80211_sta
*sta
,
676 struct rtl_tcb_desc
*tcb_desc
)
678 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
679 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
681 tcb_desc
->b_packet_bw
= false;
684 if (mac
->opmode
== NL80211_IFTYPE_AP
||
685 mac
->opmode
== NL80211_IFTYPE_ADHOC
||
686 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
687 if (!(sta
->ht_cap
.ht_supported
) ||
688 !(sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
))
690 } else if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
691 if (!mac
->bw_40
|| !(sta
->ht_cap
.ht_supported
))
694 if (tcb_desc
->b_multicast
|| tcb_desc
->b_broadcast
)
697 /*use legency rate, shall use 20MHz */
698 if (tcb_desc
->hw_rate
<= rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE54M
])
701 tcb_desc
->b_packet_bw
= true;
704 static u8
_rtl_get_highest_n_rate(struct ieee80211_hw
*hw
,
705 struct ieee80211_sta
*sta
)
707 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
708 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
711 if ((get_rf_type(rtlphy
) == RF_2T2R
) && (sta
->ht_cap
.mcs
.rx_mask
[1] != 0))
712 hw_rate
= rtlpriv
->cfg
->maps
[RTL_RC_HT_RATEMCS15
];
714 hw_rate
= rtlpriv
->cfg
->maps
[RTL_RC_HT_RATEMCS7
];
719 void rtl_get_tcb_desc(struct ieee80211_hw
*hw
,
720 struct ieee80211_tx_info
*info
,
721 struct ieee80211_sta
*sta
,
722 struct sk_buff
*skb
, struct rtl_tcb_desc
*tcb_desc
)
724 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
725 struct rtl_mac
*rtlmac
= rtl_mac(rtl_priv(hw
));
726 struct ieee80211_hdr
*hdr
= rtl_get_hdr(skb
);
727 struct ieee80211_rate
*txrate
;
728 u16 fc
= rtl_get_fc(skb
);
730 txrate
= ieee80211_get_tx_rate(hw
, info
);
732 tcb_desc
->hw_rate
= txrate
->hw_value
;
734 if (ieee80211_is_data(fc
)) {
736 *we set data rate INX 0
737 *in rtl_rc.c if skb is special data or
738 *mgt which need low data rate.
742 *So tcb_desc->hw_rate is just used for
743 *special data and mgt frames
745 if (info
->control
.rates
[0].idx
== 0 ||
746 ieee80211_is_nullfunc(fc
)) {
747 tcb_desc
->use_driver_rate
= true;
748 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_MC
;
750 tcb_desc
->disable_ratefallback
= 1;
753 *because hw will never use hw_rate
754 *when tcb_desc->use_driver_rate = false
755 *so we never set highest N rate here,
756 *and N rate will all be controlled by FW
757 *when tcb_desc->use_driver_rate = false
759 if (sta
&& (sta
->ht_cap
.ht_supported
)) {
760 tcb_desc
->hw_rate
= _rtl_get_highest_n_rate(hw
, sta
);
762 if (rtlmac
->mode
== WIRELESS_MODE_B
) {
764 rtlpriv
->cfg
->maps
[RTL_RC_CCK_RATE11M
];
767 rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE54M
];
772 if (is_multicast_ether_addr(ieee80211_get_DA(hdr
)))
773 tcb_desc
->b_multicast
= 1;
774 else if (is_broadcast_ether_addr(ieee80211_get_DA(hdr
)))
775 tcb_desc
->b_broadcast
= 1;
777 _rtl_txrate_selectmode(hw
, sta
, tcb_desc
);
778 _rtl_query_bandwidth_mode(hw
, sta
, tcb_desc
);
779 _rtl_qurey_shortpreamble_mode(hw
, tcb_desc
, info
);
780 _rtl_query_shortgi(hw
, sta
, tcb_desc
, info
);
781 _rtl_query_protection_mode(hw
, tcb_desc
, info
);
783 tcb_desc
->use_driver_rate
= true;
784 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_MC
;
785 tcb_desc
->disable_ratefallback
= 1;
786 tcb_desc
->mac_id
= 0;
787 tcb_desc
->b_packet_bw
= false;
790 /* EXPORT_SYMBOL(rtl_get_tcb_desc); */
792 bool rtl_tx_mgmt_proc(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
794 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
795 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
796 u16 fc
= rtl_get_fc(skb
);
798 if (rtlpriv
->dm
.supp_phymode_switch
&&
799 mac
->link_state
< MAC80211_LINKED
&&
800 (ieee80211_is_auth(fc
) || ieee80211_is_probe_req(fc
))) {
801 if (rtlpriv
->cfg
->ops
->check_switch_to_dmdp
)
802 rtlpriv
->cfg
->ops
->check_switch_to_dmdp(hw
);
804 if (ieee80211_is_auth(fc
)) {
805 RT_TRACE(COMP_SEND
, DBG_DMESG
, ("MAC80211_LINKING\n"));
808 mac
->link_state
= MAC80211_LINKING
;
810 rtlpriv
->phy
.b_need_iqk
= true;
817 struct sk_buff
*rtl_make_del_ba(struct ieee80211_hw
*hw
, u8
*sa
,
819 bool rtl_action_proc(struct ieee80211_hw
*hw
, struct sk_buff
*skb
, u8 is_tx
)
821 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
822 struct ieee80211_hdr
*hdr
= rtl_get_hdr(skb
);
823 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
824 u16 fc
= rtl_get_fc(skb
);
825 u8
*act
= (u8
*) (((u8
*) skb
->data
+ MAC80211_3ADDR_LEN
));
828 if (!ieee80211_is_action(fc
))
837 if (mac
->act_scanning
)
840 RT_TRACE((COMP_SEND
| COMP_RECV
), DBG_DMESG
,
841 ("%s ACT_ADDBAREQ From :%pM\n",
842 is_tx
? "Tx" : "Rx", hdr
->addr2
));
843 RT_PRINT_DATA(rtlpriv
, COMP_INIT
, DBG_DMESG
, ("req\n"),
844 skb
->data
, skb
->len
);
846 struct ieee80211_sta
*sta
= NULL
;
847 struct rtl_sta_info
*sta_entry
= NULL
;
848 struct ieee80211_mgmt
*mgmt
= (void *)skb
->data
;
849 u16 capab
= 0, tid
= 0;
850 struct rtl_tid_data
*tid_data
;
851 struct sk_buff
*skb_delba
= NULL
;
852 struct ieee80211_rx_status rx_status
= { 0 };
855 sta
= rtl_find_sta(hw
, hdr
->addr3
);
857 RT_TRACE((COMP_SEND
| COMP_RECV
),
858 DBG_EMERG
, ("sta is NULL\n"));
863 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
868 capab
= le16_to_cpu(mgmt
->u
.action
.u
.addba_req
.capab
);
869 tid
= (capab
& IEEE80211_ADDBA_PARAM_TID_MASK
) >> 2;
870 tid_data
= &sta_entry
->tids
[tid
];
871 if (tid_data
->agg
.rx_agg_state
==
873 skb_delba
= rtl_make_del_ba(hw
,
878 rx_status
.freq
= hw
->conf
.chandef
.chan
->center_freq
;
879 rx_status
.band
= hw
->conf
.chandef
.chan
->band
;
880 rx_status
.flag
|= RX_FLAG_DECRYPTED
;
881 rx_status
.flag
|= RX_FLAG_MACTIME_MPDU
;
882 rx_status
.rate_idx
= 0;
883 rx_status
.signal
= 50 + 10;
884 memcpy(IEEE80211_SKB_RXCB(skb_delba
), &rx_status
,
886 RT_PRINT_DATA(rtlpriv
, COMP_INIT
, DBG_DMESG
,
887 ("fake del\n"), skb_delba
->data
,
889 ieee80211_rx_irqsafe(hw
, skb_delba
);
896 RT_TRACE((COMP_SEND
| COMP_RECV
), DBG_DMESG
,
897 ("%s ACT_ADDBARSP From :%pM\n",
898 is_tx
? "Tx" : "Rx", hdr
->addr2
));
901 RT_TRACE((COMP_SEND
| COMP_RECV
), DBG_DMESG
,
902 ("ACT_ADDBADEL From :%pM\n", hdr
->addr2
));
913 /*should call before software enc*/
914 u8
rtl_is_special_data(struct ieee80211_hw
*hw
, struct sk_buff
*skb
, u8 is_tx
)
916 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
917 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
918 u16 fc
= rtl_get_fc(skb
);
920 u8 mac_hdr_len
= ieee80211_get_hdrlen_from_skb(skb
);
921 const struct iphdr
*ip
;
923 if (!ieee80211_is_data(fc
))
927 ip
= (struct iphdr
*)((u8
*) skb
->data
+ mac_hdr_len
+
928 SNAP_SIZE
+ PROTOC_TYPE_SIZE
);
929 ether_type
= *(u16
*) ((u8
*) skb
->data
+ mac_hdr_len
+ SNAP_SIZE
);
930 ether_type
= ntohs(ether_type
);
932 if (ETH_P_IP
== ether_type
) {
933 if (IPPROTO_UDP
== ip
->protocol
) {
934 struct udphdr
*udp
= (struct udphdr
*)((u8
*) ip
+
936 if (((((u8
*) udp
)[1] == 68) &&
937 (((u8
*) udp
)[3] == 67)) ||
938 ((((u8
*) udp
)[1] == 67) &&
939 (((u8
*) udp
)[3] == 68))) {
941 * 68 : UDP BOOTP client
942 * 67 : UDP BOOTP server
944 RT_TRACE((COMP_SEND
| COMP_RECV
),
945 DBG_DMESG
, ("dhcp %s !!\n",
946 (is_tx
) ? "Tx" : "Rx"));
949 rtlpriv
->ra
.is_special_data
= true;
951 ppsc
->last_delaylps_stamp_jiffies
=
958 } else if (ETH_P_ARP
== ether_type
) {
960 rtlpriv
->ra
.is_special_data
= true;
962 ppsc
->last_delaylps_stamp_jiffies
= jiffies
;
966 } else if (ETH_P_PAE
== ether_type
) {
967 RT_TRACE((COMP_SEND
| COMP_RECV
), DBG_DMESG
,
968 ("802.1X %s EAPOL pkt!!\n", (is_tx
) ? "Tx" : "Rx"));
971 rtlpriv
->ra
.is_special_data
= true;
973 ppsc
->last_delaylps_stamp_jiffies
= jiffies
;
977 } else if (0x86DD == ether_type
) {
982 rtlpriv
->ra
.is_special_data
= false;
986 /*********************************************************
988 * functions called by core.c
990 *********************************************************/
991 int rtl_tx_agg_start(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
992 struct ieee80211_sta
*sta
, u16 tid
, u16
*ssn
)
994 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
995 struct rtl_tid_data
*tid_data
;
996 struct rtl_sta_info
*sta_entry
= NULL
;
1001 if (unlikely(tid
>= MAX_TID_COUNT
))
1004 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1007 tid_data
= &sta_entry
->tids
[tid
];
1009 RT_TRACE(COMP_SEND
, DBG_DMESG
,
1010 ("on ra = %pM tid = %d seq:%d\n", sta
->addr
, tid
,
1011 tid_data
->seq_number
));
1013 *ssn
= tid_data
->seq_number
;
1014 tid_data
->agg
.agg_state
= RTL_AGG_START
;
1016 ieee80211_start_tx_ba_cb_irqsafe(vif
, sta
->addr
, tid
);
1020 int rtl_tx_agg_stop(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
,
1021 struct ieee80211_sta
*sta
, u16 tid
)
1023 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1024 struct rtl_tid_data
*tid_data
;
1025 struct rtl_sta_info
*sta_entry
= NULL
;
1031 RT_TRACE(COMP_ERR
, DBG_EMERG
, ("ra = NULL\n"));
1035 RT_TRACE(COMP_SEND
, DBG_DMESG
,
1036 ("on ra = %pM tid = %d\n", sta
->addr
, tid
));
1038 if (unlikely(tid
>= MAX_TID_COUNT
))
1041 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1042 tid_data
= &sta_entry
->tids
[tid
];
1043 sta_entry
->tids
[tid
].agg
.agg_state
= RTL_AGG_STOP
;
1045 ieee80211_stop_tx_ba_cb_irqsafe(vif
, sta
->addr
, tid
);
1049 int rtl_rx_agg_start(struct ieee80211_hw
*hw
,
1050 struct ieee80211_sta
*sta
, u16 tid
)
1052 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1053 struct rtl_tid_data
*tid_data
;
1054 struct rtl_sta_info
*sta_entry
= NULL
;
1059 if (unlikely(tid
>= MAX_TID_COUNT
))
1062 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1065 tid_data
= &sta_entry
->tids
[tid
];
1067 RT_TRACE(COMP_RECV
, DBG_DMESG
,
1068 ("on ra = %pM tid = %d seq:%d\n", sta
->addr
, tid
,
1069 tid_data
->seq_number
));
1071 tid_data
->agg
.rx_agg_state
= RTL_RX_AGG_START
;
1075 int rtl_rx_agg_stop(struct ieee80211_hw
*hw
,
1076 struct ieee80211_sta
*sta
, u16 tid
)
1078 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1079 struct rtl_tid_data
*tid_data
;
1080 struct rtl_sta_info
*sta_entry
= NULL
;
1086 RT_TRACE(COMP_ERR
, DBG_EMERG
, ("ra = NULL\n"));
1090 RT_TRACE(COMP_SEND
, DBG_DMESG
,
1091 ("on ra = %pM tid = %d\n", sta
->addr
, tid
));
1093 if (unlikely(tid
>= MAX_TID_COUNT
))
1096 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1097 tid_data
= &sta_entry
->tids
[tid
];
1098 sta_entry
->tids
[tid
].agg
.rx_agg_state
= RTL_RX_AGG_STOP
;
1102 int rtl_tx_agg_oper(struct ieee80211_hw
*hw
,
1103 struct ieee80211_sta
*sta
, u16 tid
)
1105 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1106 struct rtl_tid_data
*tid_data
;
1107 struct rtl_sta_info
*sta_entry
= NULL
;
1113 RT_TRACE(COMP_ERR
, DBG_EMERG
, ("ra = NULL\n"));
1117 RT_TRACE(COMP_SEND
, DBG_DMESG
,
1118 ("on ra = %pM tid = %d\n", sta
->addr
, tid
));
1120 if (unlikely(tid
>= MAX_TID_COUNT
))
1123 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1124 tid_data
= &sta_entry
->tids
[tid
];
1125 sta_entry
->tids
[tid
].agg
.agg_state
= RTL_AGG_OPERATIONAL
;
1130 /*********************************************************
1132 * wq & timer callback functions
1134 *********************************************************/
1135 /* this function is used for roaming */
1136 void rtl_beacon_statistic(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
1138 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1139 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
1141 if (rtlpriv
->mac80211
.opmode
!= NL80211_IFTYPE_STATION
)
1144 if (rtlpriv
->mac80211
.link_state
< MAC80211_LINKED
)
1147 /* check if this really is a beacon */
1148 if (!ieee80211_is_beacon(hdr
->frame_control
) &&
1149 !ieee80211_is_probe_resp(hdr
->frame_control
))
1152 /* min. beacon length + FCS_LEN */
1153 if (skb
->len
<= 40 + FCS_LEN
)
1156 /* and only beacons from the associated BSSID, please */
1157 if (ether_addr_equal(hdr
->addr3
, rtlpriv
->mac80211
.bssid
))
1160 rtlpriv
->link_info
.bcn_rx_inperiod
++;
1163 void rtl_watchdog_wq_callback(void *data
)
1165 struct rtl_works
*rtlworks
= container_of_dwork_rtl(data
,
1168 struct ieee80211_hw
*hw
= rtlworks
->hw
;
1169 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1170 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1171 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1172 bool b_busytraffic
= false;
1173 bool b_tx_busy_traffic
= false;
1174 bool b_rx_busy_traffic
= false;
1175 bool b_higher_busytraffic
= false;
1176 bool b_higher_busyrxtraffic
= false;
1178 u32 rx_cnt_inp4eriod
= 0;
1179 u32 tx_cnt_inp4eriod
= 0;
1180 u32 aver_rx_cnt_inperiod
= 0;
1181 u32 aver_tx_cnt_inperiod
= 0;
1182 u32 aver_tidtx_inperiod
[MAX_TID_COUNT
] = {0};
1183 u32 tidtx_inp4eriod
[MAX_TID_COUNT
] = {0};
1184 bool benter_ps
= false;
1186 if (is_hal_stop(rtlhal
))
1189 /* <1> Determine if action frame is allowed */
1190 if (mac
->link_state
> MAC80211_NOLINK
) {
1191 if (mac
->cnt_after_linked
< 20)
1192 mac
->cnt_after_linked
++;
1194 mac
->cnt_after_linked
= 0;
1197 /* <2> to check if traffic busy, if
1198 * busytraffic we don't change channel */
1199 if (mac
->link_state
>= MAC80211_LINKED
) {
1201 /* (1) get aver_rx_cnt_inperiod & aver_tx_cnt_inperiod */
1202 for (idx
= 0; idx
<= 2; idx
++) {
1203 rtlpriv
->link_info
.num_rx_in4period
[idx
] =
1204 rtlpriv
->link_info
.num_rx_in4period
[idx
+ 1];
1205 rtlpriv
->link_info
.num_tx_in4period
[idx
] =
1206 rtlpriv
->link_info
.num_tx_in4period
[idx
+ 1];
1208 rtlpriv
->link_info
.num_rx_in4period
[3] =
1209 rtlpriv
->link_info
.num_rx_inperiod
;
1210 rtlpriv
->link_info
.num_tx_in4period
[3] =
1211 rtlpriv
->link_info
.num_tx_inperiod
;
1212 for (idx
= 0; idx
<= 3; idx
++) {
1214 rtlpriv
->link_info
.num_rx_in4period
[idx
];
1216 rtlpriv
->link_info
.num_tx_in4period
[idx
];
1218 aver_rx_cnt_inperiod
= rx_cnt_inp4eriod
/ 4;
1219 aver_tx_cnt_inperiod
= tx_cnt_inp4eriod
/ 4;
1221 /* (2) check traffic busy */
1222 if (aver_rx_cnt_inperiod
> 100 || aver_tx_cnt_inperiod
> 100) {
1223 b_busytraffic
= true;
1224 if (aver_rx_cnt_inperiod
> aver_tx_cnt_inperiod
)
1225 b_rx_busy_traffic
= true;
1227 b_tx_busy_traffic
= false;
1230 /* Higher Tx/Rx data. */
1231 if (aver_rx_cnt_inperiod
> 4000 ||
1232 aver_tx_cnt_inperiod
> 4000) {
1233 b_higher_busytraffic
= true;
1235 /* Extremely high Rx data. */
1236 if (aver_rx_cnt_inperiod
> 5000)
1237 b_higher_busyrxtraffic
= true;
1240 /* check every tid's tx traffic */
1241 for (tid
= 0; tid
<= 7; tid
++) {
1242 for (idx
= 0; idx
<= 2; idx
++)
1243 rtlpriv
->link_info
.tidtx_in4period
[tid
][idx
] =
1244 rtlpriv
->link_info
.tidtx_in4period
[tid
]
1246 rtlpriv
->link_info
.tidtx_in4period
[tid
][3] =
1247 rtlpriv
->link_info
.tidtx_inperiod
[tid
];
1249 for (idx
= 0; idx
<= 3; idx
++)
1250 tidtx_inp4eriod
[tid
] +=
1251 rtlpriv
->link_info
.tidtx_in4period
[tid
][idx
];
1252 aver_tidtx_inperiod
[tid
] = tidtx_inp4eriod
[tid
] / 4;
1253 if (aver_tidtx_inperiod
[tid
] > 5000)
1254 rtlpriv
->link_info
.higher_busytxtraffic
[tid
] =
1257 rtlpriv
->link_info
.higher_busytxtraffic
[tid
] =
1261 if (((rtlpriv
->link_info
.num_rx_inperiod
+
1262 rtlpriv
->link_info
.num_tx_inperiod
) > 8) ||
1263 (rtlpriv
->link_info
.num_rx_inperiod
> 2))
1268 /* LeisurePS only work in infra mode. */
1275 rtlpriv
->link_info
.num_rx_inperiod
= 0;
1276 rtlpriv
->link_info
.num_tx_inperiod
= 0;
1277 for (tid
= 0; tid
<= 7; tid
++)
1278 rtlpriv
->link_info
.tidtx_inperiod
[tid
] = 0;
1280 rtlpriv
->link_info
.b_busytraffic
= b_busytraffic
;
1281 rtlpriv
->link_info
.b_rx_busy_traffic
= b_rx_busy_traffic
;
1282 rtlpriv
->link_info
.b_tx_busy_traffic
= b_tx_busy_traffic
;
1283 rtlpriv
->link_info
.b_higher_busytraffic
= b_higher_busytraffic
;
1284 rtlpriv
->link_info
.b_higher_busyrxtraffic
= b_higher_busyrxtraffic
;
1287 rtlpriv
->cfg
->ops
->dm_watchdog(hw
);
1290 if (mac
->link_state
== MAC80211_LINKED
&&
1291 mac
->opmode
== NL80211_IFTYPE_STATION
) {
1292 if ((rtlpriv
->link_info
.bcn_rx_inperiod
+
1293 rtlpriv
->link_info
.num_rx_inperiod
) == 0) {
1294 rtlpriv
->link_info
.roam_times
++;
1295 RT_TRACE(COMP_ERR
, DBG_DMESG
, ("AP off for %d s\n",
1296 (rtlpriv
->link_info
.roam_times
* 2)));
1298 /* if we can't recv beacon for 10s,
1299 * we should reconnect this AP */
1300 if (rtlpriv
->link_info
.roam_times
>= 5) {
1301 RT_TRACE(COMP_ERR
, DBG_EMERG
,
1302 ("AP off, try to reconnect now\n"));
1303 rtlpriv
->link_info
.roam_times
= 0;
1304 ieee80211_connection_loss(rtlpriv
->mac80211
.vif
);
1307 rtlpriv
->link_info
.roam_times
= 0;
1310 rtlpriv
->link_info
.bcn_rx_inperiod
= 0;
1313 void rtl_watch_dog_timer_callback(unsigned long data
)
1315 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*)data
;
1316 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1318 queue_delayed_work(rtlpriv
->works
.rtl_wq
,
1319 &rtlpriv
->works
.watchdog_wq
, 0);
1321 mod_timer(&rtlpriv
->works
.watchdog_timer
,
1322 jiffies
+ MSECS(RTL_WATCH_DOG_TIME
));
1324 void rtl_fwevt_wq_callback(void *data
)
1326 struct rtl_works
*rtlworks
=
1327 container_of_dwork_rtl(data
, struct rtl_works
, fwevt_wq
);
1328 struct ieee80211_hw
*hw
= rtlworks
->hw
;
1329 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1331 rtlpriv
->cfg
->ops
->c2h_command_handle(hw
);
1333 void rtl_easy_concurrent_retrytimer_callback(unsigned long data
)
1335 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*)data
;
1336 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1337 struct rtl_priv
*buddy_priv
= rtlpriv
->buddy_priv
;
1339 if (buddy_priv
== NULL
)
1342 rtlpriv
->cfg
->ops
->dualmac_easy_concurrent(hw
);
1344 /*********************************************************
1346 * frame process functions
1348 *********************************************************/
1349 u8
*rtl_find_ie(u8
*data
, unsigned int len
, u8 ie
)
1351 struct ieee80211_mgmt
*mgmt
= (void *)data
;
1354 pos
= (u8
*)mgmt
->u
.beacon
.variable
;
1357 if (pos
+ 2 + pos
[1] > end
)
1368 /* when we use 2 rx ants we send IEEE80211_SMPS_OFF */
1369 /* when we use 1 rx ant we send IEEE80211_SMPS_STATIC */
1370 struct sk_buff
*rtl_make_smps_action(struct ieee80211_hw
*hw
,
1371 enum ieee80211_smps_mode smps
,
1374 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1375 struct sk_buff
*skb
;
1376 struct ieee80211_mgmt_compat
*action_frame
;
1378 /* 27 = header + category + action + smps mode */
1379 skb
= dev_alloc_skb(27 + hw
->extra_tx_headroom
);
1383 skb_reserve(skb
, hw
->extra_tx_headroom
);
1384 action_frame
= (void *)skb_put(skb
, 27);
1385 memset(action_frame
, 0, 27);
1386 memcpy(action_frame
->da
, da
, ETH_ALEN
);
1387 memcpy(action_frame
->sa
, rtlefuse
->dev_addr
, ETH_ALEN
);
1388 memcpy(action_frame
->bssid
, bssid
, ETH_ALEN
);
1389 action_frame
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
1390 IEEE80211_STYPE_ACTION
);
1391 action_frame
->u
.action
.category
= WLAN_CATEGORY_HT
;
1392 action_frame
->u
.action
.u
.ht_smps
.action
= WLAN_HT_ACTION_SMPS
;
1394 case IEEE80211_SMPS_AUTOMATIC
:/* 0 */
1395 case IEEE80211_SMPS_NUM_MODES
:/* 4 */
1397 case IEEE80211_SMPS_OFF
:/* 1 */ /*MIMO_PS_NOLIMIT*/
1398 action_frame
->u
.action
.u
.ht_smps
.smps_control
=
1399 WLAN_HT_SMPS_CONTROL_DISABLED
;/* 0 */
1401 case IEEE80211_SMPS_STATIC
:/* 2 */ /*MIMO_PS_STATIC*/
1402 action_frame
->u
.action
.u
.ht_smps
.smps_control
=
1403 WLAN_HT_SMPS_CONTROL_STATIC
;/* 1 */
1405 case IEEE80211_SMPS_DYNAMIC
:/* 3 */ /*MIMO_PS_DYNAMIC*/
1406 action_frame
->u
.action
.u
.ht_smps
.smps_control
=
1407 WLAN_HT_SMPS_CONTROL_DYNAMIC
;/* 3 */
1414 int rtl_send_smps_action(struct ieee80211_hw
*hw
,
1415 struct ieee80211_sta
*sta
,
1416 enum ieee80211_smps_mode smps
)
1418 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1419 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1420 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1421 struct sk_buff
*skb
= NULL
;
1422 struct rtl_tcb_desc tcb_desc
;
1423 u8 bssid
[ETH_ALEN
] = {0};
1425 memset(&tcb_desc
, 0, sizeof(struct rtl_tcb_desc
));
1427 if (rtlpriv
->mac80211
.act_scanning
)
1433 if (unlikely(is_hal_stop(rtlhal
) || ppsc
->rfpwr_state
!= ERFON
))
1436 if (!test_bit(RTL_STATUS_INTERFACE_START
, &rtlpriv
->status
))
1439 if (rtlpriv
->mac80211
.opmode
== NL80211_IFTYPE_AP
)
1440 memcpy(bssid
, rtlpriv
->efuse
.dev_addr
, ETH_ALEN
);
1442 memcpy(bssid
, rtlpriv
->mac80211
.bssid
, ETH_ALEN
);
1444 skb
= rtl_make_smps_action(hw
, smps
, sta
->addr
, bssid
);
1445 /* this is a type = mgmt * stype = action frame */
1447 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
1448 struct rtl_sta_info
*sta_entry
=
1449 (struct rtl_sta_info
*) sta
->drv_priv
;
1450 sta_entry
->mimo_ps
= smps
;
1451 /* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); */
1453 info
->control
.rates
[0].idx
= 0;
1454 info
->band
= hw
->conf
.chandef
.chan
->band
;
1455 rtlpriv
->intf_ops
->adapter_tx(hw
, sta
, skb
, &tcb_desc
);
1462 /* EXPORT_SYMBOL(rtl_send_smps_action); */
1464 /* because mac80211 have issues when can receive del ba
1465 * so here we just make a fake del_ba if we receive a ba_req
1466 * but rx_agg was opened to let mac80211 release some ba
1467 * related resources, so please this del_ba for tx */
1468 struct sk_buff
*rtl_make_del_ba(struct ieee80211_hw
*hw
,
1469 u8
*sa
, u8
*bssid
, u16 tid
)
1471 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1472 struct sk_buff
*skb
;
1473 struct ieee80211_mgmt
*action_frame
;
1476 /* 27 = header + category + action + smps mode */
1477 skb
= dev_alloc_skb(34 + hw
->extra_tx_headroom
);
1481 skb_reserve(skb
, hw
->extra_tx_headroom
);
1482 action_frame
= (void *)skb_put(skb
, 34);
1483 memset(action_frame
, 0, 34);
1484 memcpy(action_frame
->sa
, sa
, ETH_ALEN
);
1485 memcpy(action_frame
->da
, rtlefuse
->dev_addr
, ETH_ALEN
);
1486 memcpy(action_frame
->bssid
, bssid
, ETH_ALEN
);
1487 action_frame
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
1488 IEEE80211_STYPE_ACTION
);
1489 action_frame
->u
.action
.category
= WLAN_CATEGORY_BACK
;
1490 action_frame
->u
.action
.u
.delba
.action_code
= WLAN_ACTION_DELBA
;
1491 params
= (u16
)(1 << 11); /* bit 11 initiator */
1492 params
|= (u16
)(tid
<< 12); /* bit 15:12 TID number */
1494 action_frame
->u
.action
.u
.delba
.params
= cpu_to_le16(params
);
1495 action_frame
->u
.action
.u
.delba
.reason_code
=
1496 cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT
);
1501 /*********************************************************
1505 *********************************************************/
1506 static bool rtl_chk_vendor_ouisub(struct ieee80211_hw
*hw
,
1507 struct octet_string vendor_ie
)
1509 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1510 bool matched
= false;
1511 static u8 athcap_1
[] = { 0x00, 0x03, 0x7F };
1512 static u8 athcap_2
[] = { 0x00, 0x13, 0x74 };
1513 static u8 broadcap_1
[] = { 0x00, 0x10, 0x18 };
1514 static u8 broadcap_2
[] = { 0x00, 0x0a, 0xf7 };
1515 static u8 broadcap_3
[] = { 0x00, 0x05, 0xb5 };
1516 static u8 racap
[] = { 0x00, 0x0c, 0x43 };
1517 static u8 ciscocap
[] = { 0x00, 0x40, 0x96 };
1518 static u8 marvcap
[] = { 0x00, 0x50, 0x43 };
1520 if (memcmp(vendor_ie
.octet
, athcap_1
, 3) == 0 ||
1521 memcmp(vendor_ie
.octet
, athcap_2
, 3) == 0) {
1522 rtlpriv
->mac80211
.vendor
= PEER_ATH
;
1524 } else if (memcmp(vendor_ie
.octet
, broadcap_1
, 3) == 0 ||
1525 memcmp(vendor_ie
.octet
, broadcap_2
, 3) == 0 ||
1526 memcmp(vendor_ie
.octet
, broadcap_3
, 3) == 0) {
1527 rtlpriv
->mac80211
.vendor
= PEER_BROAD
;
1529 } else if (memcmp(vendor_ie
.octet
, racap
, 3) == 0) {
1530 rtlpriv
->mac80211
.vendor
= PEER_RAL
;
1532 } else if (memcmp(vendor_ie
.octet
, ciscocap
, 3) == 0) {
1533 rtlpriv
->mac80211
.vendor
= PEER_CISCO
;
1535 } else if (memcmp(vendor_ie
.octet
, marvcap
, 3) == 0) {
1536 rtlpriv
->mac80211
.vendor
= PEER_MARV
;
1543 bool rtl_find_221_ie(struct ieee80211_hw
*hw
, u8
*data
,
1546 struct ieee80211_mgmt
*mgmt
= (void *)data
;
1547 struct octet_string vendor_ie
;
1550 pos
= (u8
*)mgmt
->u
.beacon
.variable
;
1553 if (pos
[0] == 221) {
1554 vendor_ie
.length
= pos
[1];
1555 vendor_ie
.octet
= &pos
[2];
1556 if (rtl_chk_vendor_ouisub(hw
, vendor_ie
))
1560 if (pos
+ 2 + pos
[1] > end
)
1568 void rtl_recognize_peer(struct ieee80211_hw
*hw
, u8
*data
, unsigned int len
)
1570 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1571 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1572 struct ieee80211_hdr
*hdr
= (void *)data
;
1573 u32 vendor
= PEER_UNKNOWN
;
1575 static u8 ap3_1
[3] = { 0x00, 0x14, 0xbf };
1576 static u8 ap3_2
[3] = { 0x00, 0x1a, 0x70 };
1577 static u8 ap3_3
[3] = { 0x00, 0x1d, 0x7e };
1578 static u8 ap4_1
[3] = { 0x00, 0x90, 0xcc };
1579 static u8 ap4_2
[3] = { 0x00, 0x0e, 0x2e };
1580 static u8 ap4_3
[3] = { 0x00, 0x18, 0x02 };
1581 static u8 ap4_4
[3] = { 0x00, 0x17, 0x3f };
1582 static u8 ap4_5
[3] = { 0x00, 0x1c, 0xdf };
1583 static u8 ap5_1
[3] = { 0x00, 0x1c, 0xf0 };
1584 static u8 ap5_2
[3] = { 0x00, 0x21, 0x91 };
1585 static u8 ap5_3
[3] = { 0x00, 0x24, 0x01 };
1586 static u8 ap5_4
[3] = { 0x00, 0x15, 0xe9 };
1587 static u8 ap5_5
[3] = { 0x00, 0x17, 0x9A };
1588 static u8 ap5_6
[3] = { 0x00, 0x18, 0xE7 };
1589 static u8 ap6_1
[3] = { 0x00, 0x17, 0x94 };
1590 static u8 ap7_1
[3] = { 0x00, 0x14, 0xa4 };
1592 if (mac
->opmode
!= NL80211_IFTYPE_STATION
)
1595 if (mac
->link_state
== MAC80211_NOLINK
) {
1596 mac
->vendor
= PEER_UNKNOWN
;
1600 if (mac
->cnt_after_linked
> 2)
1603 /* check if this really is a beacon */
1604 if (!ieee80211_is_beacon(hdr
->frame_control
))
1607 /* min. beacon length + FCS_LEN */
1608 if (len
<= 40 + FCS_LEN
)
1611 /* and only beacons from the associated BSSID, please */
1612 if (ether_addr_equal(hdr
->addr3
, rtlpriv
->mac80211
.bssid
))
1615 if (rtl_find_221_ie(hw
, data
, len
))
1616 vendor
= mac
->vendor
;
1618 if ((memcmp(mac
->bssid
, ap5_1
, 3) == 0) ||
1619 (memcmp(mac
->bssid
, ap5_2
, 3) == 0) ||
1620 (memcmp(mac
->bssid
, ap5_3
, 3) == 0) ||
1621 (memcmp(mac
->bssid
, ap5_4
, 3) == 0) ||
1622 (memcmp(mac
->bssid
, ap5_5
, 3) == 0) ||
1623 (memcmp(mac
->bssid
, ap5_6
, 3) == 0) ||
1624 vendor
== PEER_ATH
) {
1626 RT_TRACE(COMP_MAC80211
, DBG_LOUD
, ("=>ath find\n"));
1627 } else if ((memcmp(mac
->bssid
, ap4_4
, 3) == 0) ||
1628 (memcmp(mac
->bssid
, ap4_5
, 3) == 0) ||
1629 (memcmp(mac
->bssid
, ap4_1
, 3) == 0) ||
1630 (memcmp(mac
->bssid
, ap4_2
, 3) == 0) ||
1631 (memcmp(mac
->bssid
, ap4_3
, 3) == 0) ||
1632 vendor
== PEER_RAL
) {
1633 RT_TRACE(COMP_MAC80211
, DBG_LOUD
, ("=>ral find\n"));
1635 } else if (memcmp(mac
->bssid
, ap6_1
, 3) == 0 ||
1636 vendor
== PEER_CISCO
) {
1637 vendor
= PEER_CISCO
;
1638 RT_TRACE(COMP_MAC80211
, DBG_LOUD
, ("=>cisco find\n"));
1639 } else if ((memcmp(mac
->bssid
, ap3_1
, 3) == 0) ||
1640 (memcmp(mac
->bssid
, ap3_2
, 3) == 0) ||
1641 (memcmp(mac
->bssid
, ap3_3
, 3) == 0) ||
1642 vendor
== PEER_BROAD
) {
1643 RT_TRACE(COMP_MAC80211
, DBG_LOUD
, ("=>broad find\n"));
1644 vendor
= PEER_BROAD
;
1645 } else if (memcmp(mac
->bssid
, ap7_1
, 3) == 0 ||
1646 vendor
== PEER_MARV
) {
1648 RT_TRACE(COMP_MAC80211
, DBG_LOUD
, ("=>marv find\n"));
1651 mac
->vendor
= vendor
;
1654 /*********************************************************
1658 *********************************************************/
1659 static ssize_t
rtl_show_debug_level(struct device
*d
,
1660 struct device_attribute
*attr
, char *buf
)
1662 struct ieee80211_hw
*hw
= dev_get_drvdata(d
);
1663 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1665 return sprintf(buf
, "0x%08X\n", rtlpriv
->dbg
.global_debuglevel
);
1668 static ssize_t
rtl_store_debug_level(struct device
*d
,
1669 struct device_attribute
*attr
,
1670 const char *buf
, size_t count
)
1672 struct ieee80211_hw
*hw
= dev_get_drvdata(d
);
1673 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1677 ret
= kstrtoul(buf
, 0, &val
);
1679 printk(KERN_DEBUG
"%s is not in hex or decimal form.\n", buf
);
1681 rtlpriv
->dbg
.global_debuglevel
= val
;
1682 printk(KERN_DEBUG
"debuglevel:%x\n",
1683 rtlpriv
->dbg
.global_debuglevel
);
1686 return strnlen(buf
, count
);
1689 static DEVICE_ATTR(debug_level
, S_IWUSR
| S_IRUGO
,
1690 rtl_show_debug_level
, rtl_store_debug_level
);
1692 static struct attribute
*rtl_sysfs_entries
[] = {
1694 &dev_attr_debug_level
.attr
,
1700 * "name" is folder name witch will be
1701 * put in device directory like :
1702 * sys/devices/pci0000:00/0000:00:1c.4/
1703 * 0000:06:00.0/rtl_sysfs
1705 struct attribute_group rtl_attribute_group
= {
1707 .attrs
= rtl_sysfs_entries
,
1711 /*********************************************************
1715 *********************************************************/
1716 static inline struct ieee80211_vif
*
1717 rtl_get_vif(struct rtl_vif_info
*vif_priv
)
1719 return container_of((void *)vif_priv
, struct ieee80211_vif
, drv_priv
);
1722 /* Protected by ar->mutex or RCU */
1723 struct ieee80211_vif
*rtl_get_main_vif(struct ieee80211_hw
*hw
)
1725 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1726 struct rtl_vif_info
*cvif
;
1728 list_for_each_entry_rcu(cvif
, &rtlpriv
->vif_priv
.vif_list
, list
) {
1730 return rtl_get_vif(cvif
);
1736 static inline bool is_main_vif(struct ieee80211_hw
*hw
,
1737 struct ieee80211_vif
*vif
)
1742 ret
= (rtl_get_main_vif(hw
) == vif
);
1747 bool rtl_set_vif_info(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
1749 struct rtl_vif_info
*vif_info
= (void *) vif
->drv_priv
;
1750 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1753 if (rtlpriv
->vif_priv
.vifs
>= MAX_VIRTUAL_MAC
) {
1754 RT_TRACE(COMP_ERR
, DBG_WARNING
,
1755 ("vif number can not bigger than %d, now vifs is:%d\n",
1756 MAX_VIRTUAL_MAC
, rtlpriv
->vif_priv
.vifs
));
1761 vif_id
= bitmap_find_free_region(&rtlpriv
->vif_priv
.vif_bitmap
,
1762 MAX_VIRTUAL_MAC
, 0);
1763 RT_TRACE(COMP_MAC80211
, DBG_DMESG
,
1764 ("%s vid_id:%d\n", __func__
, vif_id
));
1771 BUG_ON(rtlpriv
->vif_priv
.vif
[vif_id
].id
!= vif_id
);
1772 vif_info
->active
= true;
1773 vif_info
->id
= vif_id
;
1774 vif_info
->enable_beacon
= false;
1775 rtlpriv
->vif_priv
.vifs
++;
1776 if (rtlpriv
->vif_priv
.vifs
> 1) {
1777 rtlpriv
->psc
.b_inactiveps
= false;
1778 rtlpriv
->psc
.b_swctrl_lps
= false;
1779 rtlpriv
->psc
.b_fwctrl_lps
= false;
1782 list_add_tail_rcu(&vif_info
->list
, &rtlpriv
->vif_priv
.vif_list
);
1783 rcu_assign_pointer(rtlpriv
->vif_priv
.vif
[vif_id
].vif
, vif
);
1785 RT_TRACE(COMP_MAC80211
, DBG_DMESG
, ("vifaddress:%p %p %p\n",
1786 rtlpriv
->vif_priv
.vif
[vif_id
].vif
, vif
, rtl_get_main_vif(hw
)));
1796 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
1797 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
1798 MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
1799 MODULE_LICENSE("GPL");
1800 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
1802 struct rtl_global_var global_var
= {};
1804 int rtl_core_module_init(void)
1806 if (rtl_rate_control_register())
1807 printk(KERN_DEBUG
"rtl: Unable to register rtl_rc, use default RC !!\n");
1809 /* add proc for debug */
1810 rtl_proc_add_topdir();
1812 /* init some global vars */
1813 INIT_LIST_HEAD(&global_var
.glb_priv_list
);
1814 spin_lock_init(&global_var
.glb_list_lock
);
1819 void rtl_core_module_exit(void)
1822 rtl_rate_control_unregister();
1824 /* add proc for debug */
1825 rtl_proc_remove_topdir();
1829 module_init(rtl_core_module_init
);
1830 module_exit(rtl_core_module_exit
);