1 /******************************************************************************
3 * Copyright(c) 2009-2012 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 *****************************************************************************/
39 #include <linux/module.h>
40 #include <linux/udp.h>
43 *NOTICE!!!: This file will be very big, we should
44 *keep it clear under following roles:
46 *This file include following parts, so, if you add new
47 *functions into this file, please check which part it
48 *should includes. or check if you should add new part
51 *1) mac80211 init functions
52 *2) tx information functions
53 *3) functions called by core.c
54 *4) wq & timer callback functions
55 *5) frame process functions
62 /*********************************************************
64 * mac80211 init functions
66 *********************************************************/
67 static struct ieee80211_channel rtl_channeltable_2g
[] = {
68 {.center_freq
= 2412, .hw_value
= 1,},
69 {.center_freq
= 2417, .hw_value
= 2,},
70 {.center_freq
= 2422, .hw_value
= 3,},
71 {.center_freq
= 2427, .hw_value
= 4,},
72 {.center_freq
= 2432, .hw_value
= 5,},
73 {.center_freq
= 2437, .hw_value
= 6,},
74 {.center_freq
= 2442, .hw_value
= 7,},
75 {.center_freq
= 2447, .hw_value
= 8,},
76 {.center_freq
= 2452, .hw_value
= 9,},
77 {.center_freq
= 2457, .hw_value
= 10,},
78 {.center_freq
= 2462, .hw_value
= 11,},
79 {.center_freq
= 2467, .hw_value
= 12,},
80 {.center_freq
= 2472, .hw_value
= 13,},
81 {.center_freq
= 2484, .hw_value
= 14,},
84 static struct ieee80211_channel rtl_channeltable_5g
[] = {
85 {.center_freq
= 5180, .hw_value
= 36,},
86 {.center_freq
= 5200, .hw_value
= 40,},
87 {.center_freq
= 5220, .hw_value
= 44,},
88 {.center_freq
= 5240, .hw_value
= 48,},
89 {.center_freq
= 5260, .hw_value
= 52,},
90 {.center_freq
= 5280, .hw_value
= 56,},
91 {.center_freq
= 5300, .hw_value
= 60,},
92 {.center_freq
= 5320, .hw_value
= 64,},
93 {.center_freq
= 5500, .hw_value
= 100,},
94 {.center_freq
= 5520, .hw_value
= 104,},
95 {.center_freq
= 5540, .hw_value
= 108,},
96 {.center_freq
= 5560, .hw_value
= 112,},
97 {.center_freq
= 5580, .hw_value
= 116,},
98 {.center_freq
= 5600, .hw_value
= 120,},
99 {.center_freq
= 5620, .hw_value
= 124,},
100 {.center_freq
= 5640, .hw_value
= 128,},
101 {.center_freq
= 5660, .hw_value
= 132,},
102 {.center_freq
= 5680, .hw_value
= 136,},
103 {.center_freq
= 5700, .hw_value
= 140,},
104 {.center_freq
= 5745, .hw_value
= 149,},
105 {.center_freq
= 5765, .hw_value
= 153,},
106 {.center_freq
= 5785, .hw_value
= 157,},
107 {.center_freq
= 5805, .hw_value
= 161,},
108 {.center_freq
= 5825, .hw_value
= 165,},
111 static struct ieee80211_rate rtl_ratetable_2g
[] = {
112 {.bitrate
= 10, .hw_value
= 0x00,},
113 {.bitrate
= 20, .hw_value
= 0x01,},
114 {.bitrate
= 55, .hw_value
= 0x02,},
115 {.bitrate
= 110, .hw_value
= 0x03,},
116 {.bitrate
= 60, .hw_value
= 0x04,},
117 {.bitrate
= 90, .hw_value
= 0x05,},
118 {.bitrate
= 120, .hw_value
= 0x06,},
119 {.bitrate
= 180, .hw_value
= 0x07,},
120 {.bitrate
= 240, .hw_value
= 0x08,},
121 {.bitrate
= 360, .hw_value
= 0x09,},
122 {.bitrate
= 480, .hw_value
= 0x0a,},
123 {.bitrate
= 540, .hw_value
= 0x0b,},
126 static struct ieee80211_rate rtl_ratetable_5g
[] = {
127 {.bitrate
= 60, .hw_value
= 0x04,},
128 {.bitrate
= 90, .hw_value
= 0x05,},
129 {.bitrate
= 120, .hw_value
= 0x06,},
130 {.bitrate
= 180, .hw_value
= 0x07,},
131 {.bitrate
= 240, .hw_value
= 0x08,},
132 {.bitrate
= 360, .hw_value
= 0x09,},
133 {.bitrate
= 480, .hw_value
= 0x0a,},
134 {.bitrate
= 540, .hw_value
= 0x0b,},
137 static const struct ieee80211_supported_band rtl_band_2ghz
= {
138 .band
= IEEE80211_BAND_2GHZ
,
140 .channels
= rtl_channeltable_2g
,
141 .n_channels
= ARRAY_SIZE(rtl_channeltable_2g
),
143 .bitrates
= rtl_ratetable_2g
,
144 .n_bitrates
= ARRAY_SIZE(rtl_ratetable_2g
),
149 static struct ieee80211_supported_band rtl_band_5ghz
= {
150 .band
= IEEE80211_BAND_5GHZ
,
152 .channels
= rtl_channeltable_5g
,
153 .n_channels
= ARRAY_SIZE(rtl_channeltable_5g
),
155 .bitrates
= rtl_ratetable_5g
,
156 .n_bitrates
= ARRAY_SIZE(rtl_ratetable_5g
),
161 static const u8 tid_to_ac
[] = {
162 2, /* IEEE80211_AC_BE */
163 3, /* IEEE80211_AC_BK */
164 3, /* IEEE80211_AC_BK */
165 2, /* IEEE80211_AC_BE */
166 1, /* IEEE80211_AC_VI */
167 1, /* IEEE80211_AC_VI */
168 0, /* IEEE80211_AC_VO */
169 0, /* IEEE80211_AC_VO */
172 u8
rtl_tid_to_ac(u8 tid
)
174 return tid_to_ac
[tid
];
176 EXPORT_SYMBOL_GPL(rtl_tid_to_ac
);
178 static void _rtl_init_hw_ht_capab(struct ieee80211_hw
*hw
,
179 struct ieee80211_sta_ht_cap
*ht_cap
)
181 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
182 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
184 ht_cap
->ht_supported
= true;
185 ht_cap
->cap
= IEEE80211_HT_CAP_SUP_WIDTH_20_40
|
186 IEEE80211_HT_CAP_SGI_40
|
187 IEEE80211_HT_CAP_SGI_20
|
188 IEEE80211_HT_CAP_DSSSCCK40
| IEEE80211_HT_CAP_MAX_AMSDU
;
190 if (rtlpriv
->rtlhal
.disable_amsdu_8k
)
191 ht_cap
->cap
&= ~IEEE80211_HT_CAP_MAX_AMSDU
;
194 *Maximum length of AMPDU that the STA can receive.
195 *Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
197 ht_cap
->ampdu_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
199 /*Minimum MPDU start spacing , */
200 ht_cap
->ampdu_density
= IEEE80211_HT_MPDU_DENSITY_16
;
202 ht_cap
->mcs
.tx_params
= IEEE80211_HT_MCS_TX_DEFINED
;
204 /*hw->wiphy->bands[IEEE80211_BAND_2GHZ]
207 *if rx_ant = 1 rx_mask[0]= 0xff;==>MCS0-MCS7
208 *if rx_ant = 2 rx_mask[1]= 0xff;==>MCS8-MCS15
209 *if rx_ant >= 3 rx_mask[2]= 0xff;
210 *if BW_40 rx_mask[4]= 0x01;
211 *highest supported RX rate
213 if (rtlpriv
->dm
.supp_phymode_switch
) {
215 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
,
216 "Support phy mode switch\n");
218 ht_cap
->mcs
.rx_mask
[0] = 0xFF;
219 ht_cap
->mcs
.rx_mask
[1] = 0xFF;
220 ht_cap
->mcs
.rx_mask
[4] = 0x01;
222 ht_cap
->mcs
.rx_highest
= cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15
);
224 if (get_rf_type(rtlphy
) == RF_1T2R
||
225 get_rf_type(rtlphy
) == RF_2T2R
) {
226 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
,
228 ht_cap
->mcs
.rx_mask
[0] = 0xFF;
229 ht_cap
->mcs
.rx_mask
[1] = 0xFF;
230 ht_cap
->mcs
.rx_mask
[4] = 0x01;
232 ht_cap
->mcs
.rx_highest
=
233 cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15
);
234 } else if (get_rf_type(rtlphy
) == RF_1T1R
) {
235 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_DMESG
, "1T1R\n");
237 ht_cap
->mcs
.rx_mask
[0] = 0xFF;
238 ht_cap
->mcs
.rx_mask
[1] = 0x00;
239 ht_cap
->mcs
.rx_mask
[4] = 0x01;
241 ht_cap
->mcs
.rx_highest
=
242 cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7
);
247 static void _rtl_init_mac80211(struct ieee80211_hw
*hw
)
249 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
250 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
251 struct rtl_mac
*rtlmac
= rtl_mac(rtl_priv(hw
));
252 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
253 struct ieee80211_supported_band
*sband
;
256 if (rtlhal
->macphymode
== SINGLEMAC_SINGLEPHY
&& rtlhal
->bandset
==
259 /* <1> use mac->bands as mem for hw->wiphy->bands */
260 sband
= &(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]);
262 /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ]
263 * to default value(1T1R) */
264 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]), &rtl_band_2ghz
,
265 sizeof(struct ieee80211_supported_band
));
267 /* <3> init ht cap base on ant_num */
268 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
270 /* <4> set mac->sband to wiphy->sband */
271 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = sband
;
274 /* <1> use mac->bands as mem for hw->wiphy->bands */
275 sband
= &(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]);
277 /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ]
278 * to default value(1T1R) */
279 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]), &rtl_band_5ghz
,
280 sizeof(struct ieee80211_supported_band
));
282 /* <3> init ht cap base on ant_num */
283 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
285 /* <4> set mac->sband to wiphy->sband */
286 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = sband
;
288 if (rtlhal
->current_bandtype
== BAND_ON_2_4G
) {
289 /* <1> use mac->bands as mem for hw->wiphy->bands */
290 sband
= &(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]);
292 /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ]
293 * to default value(1T1R) */
294 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_2GHZ
]),
296 sizeof(struct ieee80211_supported_band
));
298 /* <3> init ht cap base on ant_num */
299 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
301 /* <4> set mac->sband to wiphy->sband */
302 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] = sband
;
303 } else if (rtlhal
->current_bandtype
== BAND_ON_5G
) {
304 /* <1> use mac->bands as mem for hw->wiphy->bands */
305 sband
= &(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]);
307 /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ]
308 * to default value(1T1R) */
309 memcpy(&(rtlmac
->bands
[IEEE80211_BAND_5GHZ
]),
311 sizeof(struct ieee80211_supported_band
));
313 /* <3> init ht cap base on ant_num */
314 _rtl_init_hw_ht_capab(hw
, &sband
->ht_cap
);
316 /* <4> set mac->sband to wiphy->sband */
317 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] = sband
;
319 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
, "Err BAND %d\n",
320 rtlhal
->current_bandtype
);
323 /* <5> set hw caps */
324 hw
->flags
= IEEE80211_HW_SIGNAL_DBM
|
325 IEEE80211_HW_RX_INCLUDES_FCS
|
326 IEEE80211_HW_AMPDU_AGGREGATION
|
327 IEEE80211_HW_CONNECTION_MONITOR
|
328 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
329 IEEE80211_HW_CONNECTION_MONITOR
|
330 IEEE80211_HW_MFP_CAPABLE
|
331 IEEE80211_HW_REPORTS_TX_ACK_STATUS
| 0;
333 /* swlps or hwlps has been set in diff chip in init_sw_vars */
334 if (rtlpriv
->psc
.swctrl_lps
)
335 hw
->flags
|= IEEE80211_HW_SUPPORTS_PS
|
336 IEEE80211_HW_PS_NULLFUNC_STACK
|
337 /* IEEE80211_HW_SUPPORTS_DYNAMIC_PS | */
340 hw
->wiphy
->interface_modes
=
341 BIT(NL80211_IFTYPE_AP
) |
342 BIT(NL80211_IFTYPE_STATION
) |
343 BIT(NL80211_IFTYPE_ADHOC
) |
344 BIT(NL80211_IFTYPE_MESH_POINT
) |
345 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
346 BIT(NL80211_IFTYPE_P2P_GO
);
348 hw
->wiphy
->flags
|= WIPHY_FLAG_IBSS_RSN
;
349 hw
->wiphy
->rts_threshold
= 2347;
352 hw
->extra_tx_headroom
= RTL_TX_HEADER_SIZE
;
354 /* TODO: Correct this value for our hw */
355 /* TODO: define these hard code value */
356 hw
->channel_change_time
= 100;
357 hw
->max_listen_interval
= 10;
358 hw
->max_rate_tries
= 4;
359 /* hw->max_rates = 1; */
360 hw
->sta_data_size
= sizeof(struct rtl_sta_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 rtlmac1
[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 };
367 get_random_bytes((rtlmac1
+ (ETH_ALEN
- 1)), 1);
368 SET_IEEE80211_PERM_ADDR(hw
, rtlmac1
);
373 static void _rtl_init_deferred_work(struct ieee80211_hw
*hw
)
375 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
378 setup_timer(&rtlpriv
->works
.watchdog_timer
,
379 rtl_watch_dog_timer_callback
, (unsigned long)hw
);
380 setup_timer(&rtlpriv
->works
.dualmac_easyconcurrent_retrytimer
,
381 rtl_easy_concurrent_retrytimer_callback
, (unsigned long)hw
);
384 rtlpriv
->works
.hw
= hw
;
385 rtlpriv
->works
.rtl_wq
= alloc_workqueue("%s", 0, 0, rtlpriv
->cfg
->name
);
386 INIT_DELAYED_WORK(&rtlpriv
->works
.watchdog_wq
,
387 (void *)rtl_watchdog_wq_callback
);
388 INIT_DELAYED_WORK(&rtlpriv
->works
.ips_nic_off_wq
,
389 (void *)rtl_ips_nic_off_wq_callback
);
390 INIT_DELAYED_WORK(&rtlpriv
->works
.ps_work
,
391 (void *)rtl_swlps_wq_callback
);
392 INIT_DELAYED_WORK(&rtlpriv
->works
.ps_rfon_wq
,
393 (void *)rtl_swlps_rfon_wq_callback
);
394 INIT_DELAYED_WORK(&rtlpriv
->works
.fwevt_wq
,
395 (void *)rtl_fwevt_wq_callback
);
399 void rtl_deinit_deferred_work(struct ieee80211_hw
*hw
)
401 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
403 del_timer_sync(&rtlpriv
->works
.watchdog_timer
);
405 cancel_delayed_work(&rtlpriv
->works
.watchdog_wq
);
406 cancel_delayed_work(&rtlpriv
->works
.ips_nic_off_wq
);
407 cancel_delayed_work(&rtlpriv
->works
.ps_work
);
408 cancel_delayed_work(&rtlpriv
->works
.ps_rfon_wq
);
409 cancel_delayed_work(&rtlpriv
->works
.fwevt_wq
);
411 EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work
);
413 void rtl_init_rfkill(struct ieee80211_hw
*hw
)
415 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
421 /*set init state to on */
422 rtlpriv
->rfkill
.rfkill_state
= true;
423 wiphy_rfkill_set_hw_state(hw
->wiphy
, 0);
425 radio_state
= rtlpriv
->cfg
->ops
->radio_onoff_checking(hw
, &valid
);
428 pr_info("wireless switch is %s\n",
429 rtlpriv
->rfkill
.rfkill_state
? "on" : "off");
431 rtlpriv
->rfkill
.rfkill_state
= radio_state
;
433 blocked
= (rtlpriv
->rfkill
.rfkill_state
== 1) ? 0 : 1;
434 wiphy_rfkill_set_hw_state(hw
->wiphy
, blocked
);
437 wiphy_rfkill_start_polling(hw
->wiphy
);
439 EXPORT_SYMBOL(rtl_init_rfkill
);
441 void rtl_deinit_rfkill(struct ieee80211_hw
*hw
)
443 wiphy_rfkill_stop_polling(hw
->wiphy
);
445 EXPORT_SYMBOL_GPL(rtl_deinit_rfkill
);
447 int rtl_init_core(struct ieee80211_hw
*hw
)
449 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
450 struct rtl_mac
*rtlmac
= rtl_mac(rtl_priv(hw
));
452 /* <1> init mac80211 */
453 _rtl_init_mac80211(hw
);
456 /* <2> rate control register */
457 hw
->rate_control_algorithm
= "rtl_rc";
460 * <3> init CRDA must come after init
461 * mac80211 hw in _rtl_init_mac80211.
463 if (rtl_regd_init(hw
, rtl_reg_notifier
)) {
464 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "REGD init failed\n");
469 mutex_init(&rtlpriv
->locks
.conf_mutex
);
470 mutex_init(&rtlpriv
->locks
.ps_mutex
);
471 spin_lock_init(&rtlpriv
->locks
.ips_lock
);
472 spin_lock_init(&rtlpriv
->locks
.irq_th_lock
);
473 spin_lock_init(&rtlpriv
->locks
.irq_pci_lock
);
474 spin_lock_init(&rtlpriv
->locks
.tx_lock
);
475 spin_lock_init(&rtlpriv
->locks
.h2c_lock
);
476 spin_lock_init(&rtlpriv
->locks
.rf_ps_lock
);
477 spin_lock_init(&rtlpriv
->locks
.rf_lock
);
478 spin_lock_init(&rtlpriv
->locks
.waitq_lock
);
479 spin_lock_init(&rtlpriv
->locks
.entry_list_lock
);
480 spin_lock_init(&rtlpriv
->locks
.fw_ps_lock
);
481 spin_lock_init(&rtlpriv
->locks
.cck_and_rw_pagea_lock
);
482 spin_lock_init(&rtlpriv
->locks
.check_sendpkt_lock
);
483 spin_lock_init(&rtlpriv
->locks
.fw_ps_lock
);
484 spin_lock_init(&rtlpriv
->locks
.lps_lock
);
487 INIT_LIST_HEAD(&rtlpriv
->entry_list
);
489 rtlmac
->link_state
= MAC80211_NOLINK
;
491 /* <6> init deferred work */
492 _rtl_init_deferred_work(hw
);
496 EXPORT_SYMBOL_GPL(rtl_init_core
);
498 void rtl_deinit_core(struct ieee80211_hw
*hw
)
501 EXPORT_SYMBOL_GPL(rtl_deinit_core
);
503 void rtl_init_rx_config(struct ieee80211_hw
*hw
)
505 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
506 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
508 rtlpriv
->cfg
->ops
->get_hw_reg(hw
, HW_VAR_RCR
, (u8
*) (&mac
->rx_conf
));
510 EXPORT_SYMBOL_GPL(rtl_init_rx_config
);
512 /*********************************************************
514 * tx information functions
516 *********************************************************/
517 static void _rtl_qurey_shortpreamble_mode(struct ieee80211_hw
*hw
,
518 struct rtl_tcb_desc
*tcb_desc
,
519 struct ieee80211_tx_info
*info
)
521 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
522 u8 rate_flag
= info
->control
.rates
[0].flags
;
524 tcb_desc
->use_shortpreamble
= false;
526 /* 1M can only use Long Preamble. 11B spec */
527 if (tcb_desc
->hw_rate
== rtlpriv
->cfg
->maps
[RTL_RC_CCK_RATE1M
])
529 else if (rate_flag
& IEEE80211_TX_RC_USE_SHORT_PREAMBLE
)
530 tcb_desc
->use_shortpreamble
= true;
535 static void _rtl_query_shortgi(struct ieee80211_hw
*hw
,
536 struct ieee80211_sta
*sta
,
537 struct rtl_tcb_desc
*tcb_desc
,
538 struct ieee80211_tx_info
*info
)
540 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
541 u8 rate_flag
= info
->control
.rates
[0].flags
;
542 u8 sgi_40
= 0, sgi_20
= 0, bw_40
= 0;
543 tcb_desc
->use_shortgi
= false;
548 sgi_40
= sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_40
;
549 sgi_20
= sta
->ht_cap
.cap
& IEEE80211_HT_CAP_SGI_20
;
551 if (!(sta
->ht_cap
.ht_supported
))
554 if (!sgi_40
&& !sgi_20
)
557 if (mac
->opmode
== NL80211_IFTYPE_STATION
)
559 else if (mac
->opmode
== NL80211_IFTYPE_AP
||
560 mac
->opmode
== NL80211_IFTYPE_ADHOC
||
561 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
)
562 bw_40
= sta
->bandwidth
>= IEEE80211_STA_RX_BW_40
;
565 tcb_desc
->use_shortgi
= true;
566 else if ((bw_40
== false) && sgi_20
)
567 tcb_desc
->use_shortgi
= true;
569 if (!(rate_flag
& IEEE80211_TX_RC_SHORT_GI
))
570 tcb_desc
->use_shortgi
= false;
573 static void _rtl_query_protection_mode(struct ieee80211_hw
*hw
,
574 struct rtl_tcb_desc
*tcb_desc
,
575 struct ieee80211_tx_info
*info
)
577 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
578 u8 rate_flag
= info
->control
.rates
[0].flags
;
580 /* Common Settings */
581 tcb_desc
->rts_stbc
= false;
582 tcb_desc
->cts_enable
= false;
583 tcb_desc
->rts_sc
= 0;
584 tcb_desc
->rts_bw
= false;
585 tcb_desc
->rts_use_shortpreamble
= false;
586 tcb_desc
->rts_use_shortgi
= false;
588 if (rate_flag
& IEEE80211_TX_RC_USE_CTS_PROTECT
) {
589 /* Use CTS-to-SELF in protection mode. */
590 tcb_desc
->rts_enable
= true;
591 tcb_desc
->cts_enable
= true;
592 tcb_desc
->rts_rate
= rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE24M
];
593 } else if (rate_flag
& IEEE80211_TX_RC_USE_RTS_CTS
) {
594 /* Use RTS-CTS in protection mode. */
595 tcb_desc
->rts_enable
= true;
596 tcb_desc
->rts_rate
= rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE24M
];
600 static void _rtl_txrate_selectmode(struct ieee80211_hw
*hw
,
601 struct ieee80211_sta
*sta
,
602 struct rtl_tcb_desc
*tcb_desc
)
604 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
605 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
606 struct rtl_sta_info
*sta_entry
= NULL
;
610 sta_entry
= (struct rtl_sta_info
*) sta
->drv_priv
;
611 ratr_index
= sta_entry
->ratr_index
;
613 if (!tcb_desc
->disable_ratefallback
|| !tcb_desc
->use_driver_rate
) {
614 if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
615 tcb_desc
->ratr_index
= 0;
616 } else if (mac
->opmode
== NL80211_IFTYPE_ADHOC
||
617 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
618 if (tcb_desc
->multicast
|| tcb_desc
->broadcast
) {
620 rtlpriv
->cfg
->maps
[RTL_RC_CCK_RATE2M
];
621 tcb_desc
->use_driver_rate
= 1;
622 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_MC
;
624 tcb_desc
->ratr_index
= ratr_index
;
626 } else if (mac
->opmode
== NL80211_IFTYPE_AP
) {
627 tcb_desc
->ratr_index
= ratr_index
;
631 if (rtlpriv
->dm
.useramask
) {
632 tcb_desc
->ratr_index
= ratr_index
;
633 /* TODO we will differentiate adhoc and station future */
634 if (mac
->opmode
== NL80211_IFTYPE_STATION
||
635 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
636 tcb_desc
->mac_id
= 0;
638 if (mac
->mode
== WIRELESS_MODE_N_24G
)
639 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_NGB
;
640 else if (mac
->mode
== WIRELESS_MODE_N_5G
)
641 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_NG
;
642 else if (mac
->mode
& WIRELESS_MODE_G
)
643 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_GB
;
644 else if (mac
->mode
& WIRELESS_MODE_B
)
645 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_B
;
646 else if (mac
->mode
& WIRELESS_MODE_A
)
647 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_G
;
648 } else if (mac
->opmode
== NL80211_IFTYPE_AP
||
649 mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
652 tcb_desc
->mac_id
= sta
->aid
+ 1;
654 tcb_desc
->mac_id
= 1;
656 tcb_desc
->mac_id
= 0;
662 static void _rtl_query_bandwidth_mode(struct ieee80211_hw
*hw
,
663 struct ieee80211_sta
*sta
,
664 struct rtl_tcb_desc
*tcb_desc
)
666 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
667 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
669 tcb_desc
->packet_bw
= false;
672 if (mac
->opmode
== NL80211_IFTYPE_AP
||
673 mac
->opmode
== NL80211_IFTYPE_ADHOC
||
674 mac
->opmode
== NL80211_IFTYPE_MESH_POINT
) {
675 if (sta
->bandwidth
== IEEE80211_STA_RX_BW_20
)
677 } else if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
678 if (!mac
->bw_40
|| !(sta
->ht_cap
.ht_supported
))
681 if (tcb_desc
->multicast
|| tcb_desc
->broadcast
)
684 /*use legency rate, shall use 20MHz */
685 if (tcb_desc
->hw_rate
<= rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE54M
])
688 tcb_desc
->packet_bw
= true;
691 static u8
_rtl_get_highest_n_rate(struct ieee80211_hw
*hw
)
693 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
694 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
697 if (get_rf_type(rtlphy
) == RF_2T2R
)
698 hw_rate
= rtlpriv
->cfg
->maps
[RTL_RC_HT_RATEMCS15
];
700 hw_rate
= rtlpriv
->cfg
->maps
[RTL_RC_HT_RATEMCS7
];
705 /* mac80211's rate_idx is like this:
707 * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
710 * (rx_status->flag & RX_FLAG_HT) = 0,
711 * DESC92_RATE1M-->DESC92_RATE54M ==> idx is 0-->11,
714 * (rx_status->flag & RX_FLAG_HT) = 1,
715 * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
717 * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
719 * (rx_status->flag & RX_FLAG_HT) = 0,
720 * DESC92_RATE6M-->DESC92_RATE54M ==> idx is 0-->7,
723 * (rx_status->flag & RX_FLAG_HT) = 1,
724 * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
726 int rtlwifi_rate_mapping(struct ieee80211_hw
*hw
,
727 bool isht
, u8 desc_rate
, bool first_ampdu
)
732 if (IEEE80211_BAND_2GHZ
== hw
->conf
.chandef
.chan
->band
) {
740 case DESC92_RATE5_5M
:
809 case DESC92_RATEMCS0
:
812 case DESC92_RATEMCS1
:
815 case DESC92_RATEMCS2
:
818 case DESC92_RATEMCS3
:
821 case DESC92_RATEMCS4
:
824 case DESC92_RATEMCS5
:
827 case DESC92_RATEMCS6
:
830 case DESC92_RATEMCS7
:
833 case DESC92_RATEMCS8
:
836 case DESC92_RATEMCS9
:
839 case DESC92_RATEMCS10
:
842 case DESC92_RATEMCS11
:
845 case DESC92_RATEMCS12
:
848 case DESC92_RATEMCS13
:
851 case DESC92_RATEMCS14
:
854 case DESC92_RATEMCS15
:
864 EXPORT_SYMBOL(rtlwifi_rate_mapping
);
866 bool rtl_tx_mgmt_proc(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
868 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
869 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
870 __le16 fc
= rtl_get_fc(skb
);
872 if (rtlpriv
->dm
.supp_phymode_switch
&&
873 mac
->link_state
< MAC80211_LINKED
&&
874 (ieee80211_is_auth(fc
) || ieee80211_is_probe_req(fc
))) {
875 if (rtlpriv
->cfg
->ops
->chk_switch_dmdp
)
876 rtlpriv
->cfg
->ops
->chk_switch_dmdp(hw
);
878 if (ieee80211_is_auth(fc
)) {
879 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_DMESG
, "MAC80211_LINKING\n");
882 mac
->link_state
= MAC80211_LINKING
;
884 rtlpriv
->phy
.need_iqk
= true;
889 EXPORT_SYMBOL_GPL(rtl_tx_mgmt_proc
);
891 void rtl_get_tcb_desc(struct ieee80211_hw
*hw
,
892 struct ieee80211_tx_info
*info
,
893 struct ieee80211_sta
*sta
,
894 struct sk_buff
*skb
, struct rtl_tcb_desc
*tcb_desc
)
896 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
897 struct rtl_mac
*rtlmac
= rtl_mac(rtl_priv(hw
));
898 struct ieee80211_hdr
*hdr
= rtl_get_hdr(skb
);
899 struct ieee80211_rate
*txrate
;
900 __le16 fc
= hdr
->frame_control
;
902 txrate
= ieee80211_get_tx_rate(hw
, info
);
904 tcb_desc
->hw_rate
= txrate
->hw_value
;
906 tcb_desc
->hw_rate
= 0;
908 if (ieee80211_is_data(fc
)) {
910 *we set data rate INX 0
911 *in rtl_rc.c if skb is special data or
912 *mgt which need low data rate.
916 *So tcb_desc->hw_rate is just used for
917 *special data and mgt frames
919 if (info
->control
.rates
[0].idx
== 0 ||
920 ieee80211_is_nullfunc(fc
)) {
921 tcb_desc
->use_driver_rate
= true;
922 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_MC
;
924 tcb_desc
->disable_ratefallback
= 1;
927 *because hw will nerver use hw_rate
928 *when tcb_desc->use_driver_rate = false
929 *so we never set highest N rate here,
930 *and N rate will all be controlled by FW
931 *when tcb_desc->use_driver_rate = false
933 if (sta
&& (sta
->ht_cap
.ht_supported
)) {
934 tcb_desc
->hw_rate
= _rtl_get_highest_n_rate(hw
);
936 if (rtlmac
->mode
== WIRELESS_MODE_B
) {
938 rtlpriv
->cfg
->maps
[RTL_RC_CCK_RATE11M
];
941 rtlpriv
->cfg
->maps
[RTL_RC_OFDM_RATE54M
];
946 if (is_multicast_ether_addr(ieee80211_get_DA(hdr
)))
947 tcb_desc
->multicast
= 1;
948 else if (is_broadcast_ether_addr(ieee80211_get_DA(hdr
)))
949 tcb_desc
->broadcast
= 1;
951 _rtl_txrate_selectmode(hw
, sta
, tcb_desc
);
952 _rtl_query_bandwidth_mode(hw
, sta
, tcb_desc
);
953 _rtl_qurey_shortpreamble_mode(hw
, tcb_desc
, info
);
954 _rtl_query_shortgi(hw
, sta
, tcb_desc
, info
);
955 _rtl_query_protection_mode(hw
, tcb_desc
, info
);
957 tcb_desc
->use_driver_rate
= true;
958 tcb_desc
->ratr_index
= RATR_INX_WIRELESS_MC
;
959 tcb_desc
->disable_ratefallback
= 1;
960 tcb_desc
->mac_id
= 0;
961 tcb_desc
->packet_bw
= false;
964 EXPORT_SYMBOL(rtl_get_tcb_desc
);
966 static bool addbareq_rx(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
968 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
969 struct ieee80211_sta
*sta
= NULL
;
970 struct ieee80211_hdr
*hdr
= rtl_get_hdr(skb
);
971 struct rtl_sta_info
*sta_entry
= NULL
;
972 struct ieee80211_mgmt
*mgmt
= (void *)skb
->data
;
973 u16 capab
= 0, tid
= 0;
974 struct rtl_tid_data
*tid_data
;
975 struct sk_buff
*skb_delba
= NULL
;
976 struct ieee80211_rx_status rx_status
= { 0 };
979 sta
= rtl_find_sta(hw
, hdr
->addr3
);
981 RT_TRACE(rtlpriv
, (COMP_SEND
| COMP_RECV
), DBG_EMERG
,
987 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
992 capab
= le16_to_cpu(mgmt
->u
.action
.u
.addba_req
.capab
);
993 tid
= (capab
& IEEE80211_ADDBA_PARAM_TID_MASK
) >> 2;
994 tid_data
= &sta_entry
->tids
[tid
];
995 if (tid_data
->agg
.rx_agg_state
== RTL_RX_AGG_START
) {
996 skb_delba
= rtl_make_del_ba(hw
, hdr
->addr2
, hdr
->addr3
, tid
);
998 rx_status
.freq
= hw
->conf
.chandef
.chan
->center_freq
;
999 rx_status
.band
= hw
->conf
.chandef
.chan
->band
;
1000 rx_status
.flag
|= RX_FLAG_DECRYPTED
;
1001 rx_status
.flag
|= RX_FLAG_MACTIME_END
;
1002 rx_status
.rate_idx
= 0;
1003 rx_status
.signal
= 50 + 10;
1004 memcpy(IEEE80211_SKB_RXCB(skb_delba
), &rx_status
,
1006 RT_PRINT_DATA(rtlpriv
, COMP_INIT
, DBG_DMESG
,
1007 "fake del\n", skb_delba
->data
,
1009 ieee80211_rx_irqsafe(hw
, skb_delba
);
1016 bool rtl_action_proc(struct ieee80211_hw
*hw
, struct sk_buff
*skb
, u8 is_tx
)
1018 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1019 struct ieee80211_hdr
*hdr
= rtl_get_hdr(skb
);
1020 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1021 __le16 fc
= hdr
->frame_control
;
1022 u8
*act
= (u8
*)skb
->data
+ MAC80211_3ADDR_LEN
;
1025 if (!ieee80211_is_action(fc
))
1034 if (mac
->act_scanning
)
1037 RT_TRACE(rtlpriv
, (COMP_SEND
| COMP_RECV
), DBG_DMESG
,
1038 "%s ACT_ADDBAREQ From :%pM\n",
1039 is_tx
? "Tx" : "Rx", hdr
->addr2
);
1040 RT_PRINT_DATA(rtlpriv
, COMP_INIT
, DBG_DMESG
, "req\n",
1041 skb
->data
, skb
->len
);
1043 if (addbareq_rx(hw
, skb
))
1047 RT_TRACE(rtlpriv
, (COMP_SEND
| COMP_RECV
), DBG_DMESG
,
1048 "%s ACT_ADDBARSP From :%pM\n",
1049 is_tx
? "Tx" : "Rx", hdr
->addr2
);
1052 RT_TRACE(rtlpriv
, (COMP_SEND
| COMP_RECV
), DBG_DMESG
,
1053 "ACT_ADDBADEL From :%pM\n", hdr
->addr2
);
1063 EXPORT_SYMBOL_GPL(rtl_action_proc
);
1065 /*should call before software enc*/
1066 u8
rtl_is_special_data(struct ieee80211_hw
*hw
, struct sk_buff
*skb
, u8 is_tx
)
1068 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1069 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1070 __le16 fc
= rtl_get_fc(skb
);
1072 u8 mac_hdr_len
= ieee80211_get_hdrlen_from_skb(skb
);
1073 const struct iphdr
*ip
;
1075 if (!ieee80211_is_data(fc
))
1078 ip
= (const struct iphdr
*)(skb
->data
+ mac_hdr_len
+
1079 SNAP_SIZE
+ PROTOC_TYPE_SIZE
);
1080 ether_type
= be16_to_cpup((__be16
*)
1081 (skb
->data
+ mac_hdr_len
+ SNAP_SIZE
));
1083 switch (ether_type
) {
1089 if (ip
->protocol
!= IPPROTO_UDP
)
1091 udp
= (struct udphdr
*)((u8
*)ip
+ (ip
->ihl
<< 2));
1092 src
= be16_to_cpu(udp
->source
);
1093 dst
= be16_to_cpu(udp
->dest
);
1095 /* If this case involves port 68 (UDP BOOTP client) connecting
1096 * with port 67 (UDP BOOTP server), then return true so that
1097 * the lowest speed is used.
1099 if (!((src
== 68 && dst
== 67) || (src
== 67 && dst
== 68)))
1102 RT_TRACE(rtlpriv
, (COMP_SEND
| COMP_RECV
), DBG_DMESG
,
1103 "dhcp %s !!\n", is_tx
? "Tx" : "Rx");
1109 RT_TRACE(rtlpriv
, (COMP_SEND
| COMP_RECV
), DBG_DMESG
,
1110 "802.1X %s EAPOL pkt!!\n", is_tx
? "Tx" : "Rx");
1113 /* TODO: Is this right? */
1119 rtlpriv
->enter_ps
= false;
1120 schedule_work(&rtlpriv
->works
.lps_change_work
);
1121 ppsc
->last_delaylps_stamp_jiffies
= jiffies
;
1125 EXPORT_SYMBOL_GPL(rtl_is_special_data
);
1127 /*********************************************************
1129 * functions called by core.c
1131 *********************************************************/
1132 int rtl_tx_agg_start(struct ieee80211_hw
*hw
,
1133 struct ieee80211_sta
*sta
, u16 tid
, u16
*ssn
)
1135 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1136 struct rtl_tid_data
*tid_data
;
1137 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1138 struct rtl_sta_info
*sta_entry
= NULL
;
1143 if (unlikely(tid
>= MAX_TID_COUNT
))
1146 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1149 tid_data
= &sta_entry
->tids
[tid
];
1151 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_DMESG
, "on ra = %pM tid = %d seq:%d\n",
1152 sta
->addr
, tid
, tid_data
->seq_number
);
1154 *ssn
= tid_data
->seq_number
;
1155 tid_data
->agg
.agg_state
= RTL_AGG_START
;
1157 ieee80211_start_tx_ba_cb_irqsafe(mac
->vif
, sta
->addr
, tid
);
1162 int rtl_tx_agg_stop(struct ieee80211_hw
*hw
,
1163 struct ieee80211_sta
*sta
, u16 tid
)
1165 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1166 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1167 struct rtl_sta_info
*sta_entry
= NULL
;
1173 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "ra = NULL\n");
1177 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_DMESG
, "on ra = %pM tid = %d\n",
1180 if (unlikely(tid
>= MAX_TID_COUNT
))
1183 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1184 sta_entry
->tids
[tid
].agg
.agg_state
= RTL_AGG_STOP
;
1186 ieee80211_stop_tx_ba_cb_irqsafe(mac
->vif
, sta
->addr
, tid
);
1191 int rtl_rx_agg_start(struct ieee80211_hw
*hw
,
1192 struct ieee80211_sta
*sta
, u16 tid
)
1194 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1195 struct rtl_tid_data
*tid_data
;
1196 struct rtl_sta_info
*sta_entry
= NULL
;
1201 if (unlikely(tid
>= MAX_TID_COUNT
))
1204 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1207 tid_data
= &sta_entry
->tids
[tid
];
1209 RT_TRACE(rtlpriv
, COMP_RECV
, DBG_DMESG
,
1210 "on ra = %pM tid = %d seq:%d\n", sta
->addr
, tid
,
1211 tid_data
->seq_number
);
1213 tid_data
->agg
.rx_agg_state
= RTL_RX_AGG_START
;
1217 int rtl_rx_agg_stop(struct ieee80211_hw
*hw
,
1218 struct ieee80211_sta
*sta
, u16 tid
)
1220 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1221 struct rtl_sta_info
*sta_entry
= NULL
;
1227 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "ra = NULL\n");
1231 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_DMESG
,
1232 "on ra = %pM tid = %d\n", sta
->addr
, tid
);
1234 if (unlikely(tid
>= MAX_TID_COUNT
))
1237 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1238 sta_entry
->tids
[tid
].agg
.rx_agg_state
= RTL_RX_AGG_STOP
;
1243 int rtl_tx_agg_oper(struct ieee80211_hw
*hw
,
1244 struct ieee80211_sta
*sta
, u16 tid
)
1246 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1247 struct rtl_sta_info
*sta_entry
= NULL
;
1253 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "ra = NULL\n");
1257 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_DMESG
, "on ra = %pM tid = %d\n",
1260 if (unlikely(tid
>= MAX_TID_COUNT
))
1263 sta_entry
= (struct rtl_sta_info
*)sta
->drv_priv
;
1264 sta_entry
->tids
[tid
].agg
.agg_state
= RTL_AGG_OPERATIONAL
;
1269 /*********************************************************
1271 * wq & timer callback functions
1273 *********************************************************/
1274 /* this function is used for roaming */
1275 void rtl_beacon_statistic(struct ieee80211_hw
*hw
, struct sk_buff
*skb
)
1277 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1278 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
1280 if (rtlpriv
->mac80211
.opmode
!= NL80211_IFTYPE_STATION
)
1283 if (rtlpriv
->mac80211
.link_state
< MAC80211_LINKED
)
1286 /* check if this really is a beacon */
1287 if (!ieee80211_is_beacon(hdr
->frame_control
) &&
1288 !ieee80211_is_probe_resp(hdr
->frame_control
))
1291 /* min. beacon length + FCS_LEN */
1292 if (skb
->len
<= 40 + FCS_LEN
)
1295 /* and only beacons from the associated BSSID, please */
1296 if (!ether_addr_equal(hdr
->addr3
, rtlpriv
->mac80211
.bssid
))
1299 rtlpriv
->link_info
.bcn_rx_inperiod
++;
1301 EXPORT_SYMBOL_GPL(rtl_beacon_statistic
);
1303 void rtl_watchdog_wq_callback(void *data
)
1305 struct rtl_works
*rtlworks
= container_of_dwork_rtl(data
,
1308 struct ieee80211_hw
*hw
= rtlworks
->hw
;
1309 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1310 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1311 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1312 bool busytraffic
= false;
1313 bool tx_busy_traffic
= false;
1314 bool rx_busy_traffic
= false;
1315 bool higher_busytraffic
= false;
1316 bool higher_busyrxtraffic
= false;
1318 u32 rx_cnt_inp4eriod
= 0;
1319 u32 tx_cnt_inp4eriod
= 0;
1320 u32 aver_rx_cnt_inperiod
= 0;
1321 u32 aver_tx_cnt_inperiod
= 0;
1322 u32 aver_tidtx_inperiod
[MAX_TID_COUNT
] = {0};
1323 u32 tidtx_inp4eriod
[MAX_TID_COUNT
] = {0};
1325 if (is_hal_stop(rtlhal
))
1328 /* <1> Determine if action frame is allowed */
1329 if (mac
->link_state
> MAC80211_NOLINK
) {
1330 if (mac
->cnt_after_linked
< 20)
1331 mac
->cnt_after_linked
++;
1333 mac
->cnt_after_linked
= 0;
1337 *<2> to check if traffic busy, if
1338 * busytraffic we don't change channel
1340 if (mac
->link_state
>= MAC80211_LINKED
) {
1342 /* (1) get aver_rx_cnt_inperiod & aver_tx_cnt_inperiod */
1343 for (idx
= 0; idx
<= 2; idx
++) {
1344 rtlpriv
->link_info
.num_rx_in4period
[idx
] =
1345 rtlpriv
->link_info
.num_rx_in4period
[idx
+ 1];
1346 rtlpriv
->link_info
.num_tx_in4period
[idx
] =
1347 rtlpriv
->link_info
.num_tx_in4period
[idx
+ 1];
1349 rtlpriv
->link_info
.num_rx_in4period
[3] =
1350 rtlpriv
->link_info
.num_rx_inperiod
;
1351 rtlpriv
->link_info
.num_tx_in4period
[3] =
1352 rtlpriv
->link_info
.num_tx_inperiod
;
1353 for (idx
= 0; idx
<= 3; idx
++) {
1355 rtlpriv
->link_info
.num_rx_in4period
[idx
];
1357 rtlpriv
->link_info
.num_tx_in4period
[idx
];
1359 aver_rx_cnt_inperiod
= rx_cnt_inp4eriod
/ 4;
1360 aver_tx_cnt_inperiod
= tx_cnt_inp4eriod
/ 4;
1362 /* (2) check traffic busy */
1363 if (aver_rx_cnt_inperiod
> 100 || aver_tx_cnt_inperiod
> 100) {
1365 if (aver_rx_cnt_inperiod
> aver_tx_cnt_inperiod
)
1366 rx_busy_traffic
= true;
1368 tx_busy_traffic
= false;
1371 /* Higher Tx/Rx data. */
1372 if (aver_rx_cnt_inperiod
> 4000 ||
1373 aver_tx_cnt_inperiod
> 4000) {
1374 higher_busytraffic
= true;
1376 /* Extremely high Rx data. */
1377 if (aver_rx_cnt_inperiod
> 5000)
1378 higher_busyrxtraffic
= true;
1381 /* check every tid's tx traffic */
1382 for (tid
= 0; tid
<= 7; tid
++) {
1383 for (idx
= 0; idx
<= 2; idx
++)
1384 rtlpriv
->link_info
.tidtx_in4period
[tid
][idx
] =
1385 rtlpriv
->link_info
.tidtx_in4period
[tid
]
1387 rtlpriv
->link_info
.tidtx_in4period
[tid
][3] =
1388 rtlpriv
->link_info
.tidtx_inperiod
[tid
];
1390 for (idx
= 0; idx
<= 3; idx
++)
1391 tidtx_inp4eriod
[tid
] +=
1392 rtlpriv
->link_info
.tidtx_in4period
[tid
][idx
];
1393 aver_tidtx_inperiod
[tid
] = tidtx_inp4eriod
[tid
] / 4;
1394 if (aver_tidtx_inperiod
[tid
] > 5000)
1395 rtlpriv
->link_info
.higher_busytxtraffic
[tid
] =
1398 rtlpriv
->link_info
.higher_busytxtraffic
[tid
] =
1402 if (((rtlpriv
->link_info
.num_rx_inperiod
+
1403 rtlpriv
->link_info
.num_tx_inperiod
) > 8) ||
1404 (rtlpriv
->link_info
.num_rx_inperiod
> 2))
1405 rtlpriv
->enter_ps
= false;
1407 rtlpriv
->enter_ps
= true;
1409 /* LeisurePS only work in infra mode. */
1410 schedule_work(&rtlpriv
->works
.lps_change_work
);
1413 rtlpriv
->link_info
.num_rx_inperiod
= 0;
1414 rtlpriv
->link_info
.num_tx_inperiod
= 0;
1415 for (tid
= 0; tid
<= 7; tid
++)
1416 rtlpriv
->link_info
.tidtx_inperiod
[tid
] = 0;
1418 rtlpriv
->link_info
.busytraffic
= busytraffic
;
1419 rtlpriv
->link_info
.higher_busytraffic
= higher_busytraffic
;
1420 rtlpriv
->link_info
.rx_busy_traffic
= rx_busy_traffic
;
1421 rtlpriv
->link_info
.tx_busy_traffic
= tx_busy_traffic
;
1422 rtlpriv
->link_info
.higher_busyrxtraffic
= higher_busyrxtraffic
;
1425 rtlpriv
->cfg
->ops
->dm_watchdog(hw
);
1428 if (mac
->link_state
== MAC80211_LINKED
&&
1429 mac
->opmode
== NL80211_IFTYPE_STATION
) {
1430 if ((rtlpriv
->link_info
.bcn_rx_inperiod
+
1431 rtlpriv
->link_info
.num_rx_inperiod
) == 0) {
1432 rtlpriv
->link_info
.roam_times
++;
1433 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_DMESG
,
1434 "AP off for %d s\n",
1435 (rtlpriv
->link_info
.roam_times
* 2));
1437 /* if we can't recv beacon for 6s, we should
1440 if ((rtlpriv
->link_info
.roam_times
>= 3) &&
1441 !is_zero_ether_addr(rtlpriv
->mac80211
.bssid
)) {
1442 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
1443 "AP off, try to reconnect now\n");
1444 rtlpriv
->link_info
.roam_times
= 0;
1445 ieee80211_connection_loss(rtlpriv
->mac80211
.vif
);
1448 rtlpriv
->link_info
.roam_times
= 0;
1451 rtlpriv
->link_info
.bcn_rx_inperiod
= 0;
1454 void rtl_watch_dog_timer_callback(unsigned long data
)
1456 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*)data
;
1457 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1459 queue_delayed_work(rtlpriv
->works
.rtl_wq
,
1460 &rtlpriv
->works
.watchdog_wq
, 0);
1462 mod_timer(&rtlpriv
->works
.watchdog_timer
,
1463 jiffies
+ MSECS(RTL_WATCH_DOG_TIME
));
1466 void rtl_fwevt_wq_callback(void *data
)
1468 struct rtl_works
*rtlworks
=
1469 container_of_dwork_rtl(data
, struct rtl_works
, fwevt_wq
);
1470 struct ieee80211_hw
*hw
= rtlworks
->hw
;
1471 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1473 rtlpriv
->cfg
->ops
->c2h_command_handle(hw
);
1476 void rtl_easy_concurrent_retrytimer_callback(unsigned long data
)
1478 struct ieee80211_hw
*hw
= (struct ieee80211_hw
*)data
;
1479 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1480 struct rtl_priv
*buddy_priv
= rtlpriv
->buddy_priv
;
1482 if (buddy_priv
== NULL
)
1485 rtlpriv
->cfg
->ops
->dualmac_easy_concurrent(hw
);
1488 /*********************************************************
1490 * frame process functions
1492 *********************************************************/
1493 u8
*rtl_find_ie(u8
*data
, unsigned int len
, u8 ie
)
1495 struct ieee80211_mgmt
*mgmt
= (void *)data
;
1498 pos
= (u8
*)mgmt
->u
.beacon
.variable
;
1501 if (pos
+ 2 + pos
[1] > end
)
1512 /* when we use 2 rx ants we send IEEE80211_SMPS_OFF */
1513 /* when we use 1 rx ant we send IEEE80211_SMPS_STATIC */
1514 static struct sk_buff
*rtl_make_smps_action(struct ieee80211_hw
*hw
,
1515 enum ieee80211_smps_mode smps
, u8
*da
, u8
*bssid
)
1517 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1518 struct sk_buff
*skb
;
1519 struct ieee80211_mgmt
*action_frame
;
1521 /* 27 = header + category + action + smps mode */
1522 skb
= dev_alloc_skb(27 + hw
->extra_tx_headroom
);
1526 skb_reserve(skb
, hw
->extra_tx_headroom
);
1527 action_frame
= (void *)skb_put(skb
, 27);
1528 memset(action_frame
, 0, 27);
1529 memcpy(action_frame
->da
, da
, ETH_ALEN
);
1530 memcpy(action_frame
->sa
, rtlefuse
->dev_addr
, ETH_ALEN
);
1531 memcpy(action_frame
->bssid
, bssid
, ETH_ALEN
);
1532 action_frame
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
1533 IEEE80211_STYPE_ACTION
);
1534 action_frame
->u
.action
.category
= WLAN_CATEGORY_HT
;
1535 action_frame
->u
.action
.u
.ht_smps
.action
= WLAN_HT_ACTION_SMPS
;
1537 case IEEE80211_SMPS_AUTOMATIC
:/* 0 */
1538 case IEEE80211_SMPS_NUM_MODES
:/* 4 */
1540 case IEEE80211_SMPS_OFF
:/* 1 */ /*MIMO_PS_NOLIMIT*/
1541 action_frame
->u
.action
.u
.ht_smps
.smps_control
=
1542 WLAN_HT_SMPS_CONTROL_DISABLED
;/* 0 */
1544 case IEEE80211_SMPS_STATIC
:/* 2 */ /*MIMO_PS_STATIC*/
1545 action_frame
->u
.action
.u
.ht_smps
.smps_control
=
1546 WLAN_HT_SMPS_CONTROL_STATIC
;/* 1 */
1548 case IEEE80211_SMPS_DYNAMIC
:/* 3 */ /*MIMO_PS_DYNAMIC*/
1549 action_frame
->u
.action
.u
.ht_smps
.smps_control
=
1550 WLAN_HT_SMPS_CONTROL_DYNAMIC
;/* 3 */
1557 int rtl_send_smps_action(struct ieee80211_hw
*hw
,
1558 struct ieee80211_sta
*sta
,
1559 enum ieee80211_smps_mode smps
)
1561 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1562 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1563 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1564 struct sk_buff
*skb
= NULL
;
1565 struct rtl_tcb_desc tcb_desc
;
1566 u8 bssid
[ETH_ALEN
] = {0};
1568 memset(&tcb_desc
, 0, sizeof(struct rtl_tcb_desc
));
1570 if (rtlpriv
->mac80211
.act_scanning
)
1576 if (unlikely(is_hal_stop(rtlhal
) || ppsc
->rfpwr_state
!= ERFON
))
1579 if (!test_bit(RTL_STATUS_INTERFACE_START
, &rtlpriv
->status
))
1582 if (rtlpriv
->mac80211
.opmode
== NL80211_IFTYPE_AP
)
1583 memcpy(bssid
, rtlpriv
->efuse
.dev_addr
, ETH_ALEN
);
1585 memcpy(bssid
, rtlpriv
->mac80211
.bssid
, ETH_ALEN
);
1587 skb
= rtl_make_smps_action(hw
, smps
, sta
->addr
, bssid
);
1588 /* this is a type = mgmt * stype = action frame */
1590 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
1591 struct rtl_sta_info
*sta_entry
=
1592 (struct rtl_sta_info
*) sta
->drv_priv
;
1593 sta_entry
->mimo_ps
= smps
;
1595 info
->control
.rates
[0].idx
= 0;
1596 info
->band
= hw
->conf
.chandef
.chan
->band
;
1597 rtlpriv
->intf_ops
->adapter_tx(hw
, sta
, skb
, &tcb_desc
);
1604 EXPORT_SYMBOL(rtl_send_smps_action
);
1606 /* There seem to be issues in mac80211 regarding when del ba frames can be
1607 * received. As a work around, we make a fake del_ba if we receive a ba_req;
1608 * however, rx_agg was opened to let mac80211 release some ba related
1609 * resources. This del_ba is for tx only.
1611 struct sk_buff
*rtl_make_del_ba(struct ieee80211_hw
*hw
,
1612 u8
*sa
, u8
*bssid
, u16 tid
)
1614 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1615 struct sk_buff
*skb
;
1616 struct ieee80211_mgmt
*action_frame
;
1619 /* 27 = header + category + action + smps mode */
1620 skb
= dev_alloc_skb(34 + hw
->extra_tx_headroom
);
1624 skb_reserve(skb
, hw
->extra_tx_headroom
);
1625 action_frame
= (void *)skb_put(skb
, 34);
1626 memset(action_frame
, 0, 34);
1627 memcpy(action_frame
->sa
, sa
, ETH_ALEN
);
1628 memcpy(action_frame
->da
, rtlefuse
->dev_addr
, ETH_ALEN
);
1629 memcpy(action_frame
->bssid
, bssid
, ETH_ALEN
);
1630 action_frame
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
1631 IEEE80211_STYPE_ACTION
);
1632 action_frame
->u
.action
.category
= WLAN_CATEGORY_BACK
;
1633 action_frame
->u
.action
.u
.delba
.action_code
= WLAN_ACTION_DELBA
;
1634 params
= (u16
)(1 << 11); /* bit 11 initiator */
1635 params
|= (u16
)(tid
<< 12); /* bit 15:12 TID number */
1637 action_frame
->u
.action
.u
.delba
.params
= cpu_to_le16(params
);
1638 action_frame
->u
.action
.u
.delba
.reason_code
=
1639 cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT
);
1644 /*********************************************************
1648 *********************************************************/
1649 static bool rtl_chk_vendor_ouisub(struct ieee80211_hw
*hw
,
1650 struct octet_string vendor_ie
)
1652 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1653 bool matched
= false;
1654 static u8 athcap_1
[] = { 0x00, 0x03, 0x7F };
1655 static u8 athcap_2
[] = { 0x00, 0x13, 0x74 };
1656 static u8 broadcap_1
[] = { 0x00, 0x10, 0x18 };
1657 static u8 broadcap_2
[] = { 0x00, 0x0a, 0xf7 };
1658 static u8 broadcap_3
[] = { 0x00, 0x05, 0xb5 };
1659 static u8 racap
[] = { 0x00, 0x0c, 0x43 };
1660 static u8 ciscocap
[] = { 0x00, 0x40, 0x96 };
1661 static u8 marvcap
[] = { 0x00, 0x50, 0x43 };
1663 if (memcmp(vendor_ie
.octet
, athcap_1
, 3) == 0 ||
1664 memcmp(vendor_ie
.octet
, athcap_2
, 3) == 0) {
1665 rtlpriv
->mac80211
.vendor
= PEER_ATH
;
1667 } else if (memcmp(vendor_ie
.octet
, broadcap_1
, 3) == 0 ||
1668 memcmp(vendor_ie
.octet
, broadcap_2
, 3) == 0 ||
1669 memcmp(vendor_ie
.octet
, broadcap_3
, 3) == 0) {
1670 rtlpriv
->mac80211
.vendor
= PEER_BROAD
;
1672 } else if (memcmp(vendor_ie
.octet
, racap
, 3) == 0) {
1673 rtlpriv
->mac80211
.vendor
= PEER_RAL
;
1675 } else if (memcmp(vendor_ie
.octet
, ciscocap
, 3) == 0) {
1676 rtlpriv
->mac80211
.vendor
= PEER_CISCO
;
1678 } else if (memcmp(vendor_ie
.octet
, marvcap
, 3) == 0) {
1679 rtlpriv
->mac80211
.vendor
= PEER_MARV
;
1686 static bool rtl_find_221_ie(struct ieee80211_hw
*hw
, u8
*data
,
1689 struct ieee80211_mgmt
*mgmt
= (void *)data
;
1690 struct octet_string vendor_ie
;
1693 pos
= (u8
*)mgmt
->u
.beacon
.variable
;
1696 if (pos
[0] == 221) {
1697 vendor_ie
.length
= pos
[1];
1698 vendor_ie
.octet
= &pos
[2];
1699 if (rtl_chk_vendor_ouisub(hw
, vendor_ie
))
1703 if (pos
+ 2 + pos
[1] > end
)
1711 void rtl_recognize_peer(struct ieee80211_hw
*hw
, u8
*data
, unsigned int len
)
1713 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1714 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
1715 struct ieee80211_hdr
*hdr
= (void *)data
;
1716 u32 vendor
= PEER_UNKNOWN
;
1718 static u8 ap3_1
[3] = { 0x00, 0x14, 0xbf };
1719 static u8 ap3_2
[3] = { 0x00, 0x1a, 0x70 };
1720 static u8 ap3_3
[3] = { 0x00, 0x1d, 0x7e };
1721 static u8 ap4_1
[3] = { 0x00, 0x90, 0xcc };
1722 static u8 ap4_2
[3] = { 0x00, 0x0e, 0x2e };
1723 static u8 ap4_3
[3] = { 0x00, 0x18, 0x02 };
1724 static u8 ap4_4
[3] = { 0x00, 0x17, 0x3f };
1725 static u8 ap4_5
[3] = { 0x00, 0x1c, 0xdf };
1726 static u8 ap5_1
[3] = { 0x00, 0x1c, 0xf0 };
1727 static u8 ap5_2
[3] = { 0x00, 0x21, 0x91 };
1728 static u8 ap5_3
[3] = { 0x00, 0x24, 0x01 };
1729 static u8 ap5_4
[3] = { 0x00, 0x15, 0xe9 };
1730 static u8 ap5_5
[3] = { 0x00, 0x17, 0x9A };
1731 static u8 ap5_6
[3] = { 0x00, 0x18, 0xE7 };
1732 static u8 ap6_1
[3] = { 0x00, 0x17, 0x94 };
1733 static u8 ap7_1
[3] = { 0x00, 0x14, 0xa4 };
1735 if (mac
->opmode
!= NL80211_IFTYPE_STATION
)
1738 if (mac
->link_state
== MAC80211_NOLINK
) {
1739 mac
->vendor
= PEER_UNKNOWN
;
1743 if (mac
->cnt_after_linked
> 2)
1746 /* check if this really is a beacon */
1747 if (!ieee80211_is_beacon(hdr
->frame_control
))
1750 /* min. beacon length + FCS_LEN */
1751 if (len
<= 40 + FCS_LEN
)
1754 /* and only beacons from the associated BSSID, please */
1755 if (!ether_addr_equal(hdr
->addr3
, rtlpriv
->mac80211
.bssid
))
1758 if (rtl_find_221_ie(hw
, data
, len
))
1759 vendor
= mac
->vendor
;
1761 if ((memcmp(mac
->bssid
, ap5_1
, 3) == 0) ||
1762 (memcmp(mac
->bssid
, ap5_2
, 3) == 0) ||
1763 (memcmp(mac
->bssid
, ap5_3
, 3) == 0) ||
1764 (memcmp(mac
->bssid
, ap5_4
, 3) == 0) ||
1765 (memcmp(mac
->bssid
, ap5_5
, 3) == 0) ||
1766 (memcmp(mac
->bssid
, ap5_6
, 3) == 0) ||
1767 vendor
== PEER_ATH
) {
1769 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "=>ath find\n");
1770 } else if ((memcmp(mac
->bssid
, ap4_4
, 3) == 0) ||
1771 (memcmp(mac
->bssid
, ap4_5
, 3) == 0) ||
1772 (memcmp(mac
->bssid
, ap4_1
, 3) == 0) ||
1773 (memcmp(mac
->bssid
, ap4_2
, 3) == 0) ||
1774 (memcmp(mac
->bssid
, ap4_3
, 3) == 0) ||
1775 vendor
== PEER_RAL
) {
1776 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "=>ral find\n");
1778 } else if (memcmp(mac
->bssid
, ap6_1
, 3) == 0 ||
1779 vendor
== PEER_CISCO
) {
1780 vendor
= PEER_CISCO
;
1781 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "=>cisco find\n");
1782 } else if ((memcmp(mac
->bssid
, ap3_1
, 3) == 0) ||
1783 (memcmp(mac
->bssid
, ap3_2
, 3) == 0) ||
1784 (memcmp(mac
->bssid
, ap3_3
, 3) == 0) ||
1785 vendor
== PEER_BROAD
) {
1786 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "=>broad find\n");
1787 vendor
= PEER_BROAD
;
1788 } else if (memcmp(mac
->bssid
, ap7_1
, 3) == 0 ||
1789 vendor
== PEER_MARV
) {
1791 RT_TRACE(rtlpriv
, COMP_MAC80211
, DBG_LOUD
, "=>marv find\n");
1794 mac
->vendor
= vendor
;
1796 EXPORT_SYMBOL_GPL(rtl_recognize_peer
);
1798 /*********************************************************
1802 *********************************************************/
1803 static ssize_t
rtl_show_debug_level(struct device
*d
,
1804 struct device_attribute
*attr
, char *buf
)
1806 struct ieee80211_hw
*hw
= dev_get_drvdata(d
);
1807 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1809 return sprintf(buf
, "0x%08X\n", rtlpriv
->dbg
.global_debuglevel
);
1812 static ssize_t
rtl_store_debug_level(struct device
*d
,
1813 struct device_attribute
*attr
,
1814 const char *buf
, size_t count
)
1816 struct ieee80211_hw
*hw
= dev_get_drvdata(d
);
1817 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1821 ret
= kstrtoul(buf
, 0, &val
);
1823 printk(KERN_DEBUG
"%s is not in hex or decimal form.\n", buf
);
1825 rtlpriv
->dbg
.global_debuglevel
= val
;
1826 printk(KERN_DEBUG
"debuglevel:%x\n",
1827 rtlpriv
->dbg
.global_debuglevel
);
1830 return strnlen(buf
, count
);
1833 static DEVICE_ATTR(debug_level
, S_IWUSR
| S_IRUGO
,
1834 rtl_show_debug_level
, rtl_store_debug_level
);
1836 static struct attribute
*rtl_sysfs_entries
[] = {
1838 &dev_attr_debug_level
.attr
,
1844 * "name" is folder name witch will be
1845 * put in device directory like :
1846 * sys/devices/pci0000:00/0000:00:1c.4/
1847 * 0000:06:00.0/rtl_sysfs
1849 struct attribute_group rtl_attribute_group
= {
1851 .attrs
= rtl_sysfs_entries
,
1853 EXPORT_SYMBOL_GPL(rtl_attribute_group
);
1855 MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
1856 MODULE_AUTHOR("Realtek WlanFAE <wlanfae@realtek.com>");
1857 MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
1858 MODULE_LICENSE("GPL");
1859 MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
1861 struct rtl_global_var rtl_global_var
= {};
1862 EXPORT_SYMBOL_GPL(rtl_global_var
);
1864 static int __init
rtl_core_module_init(void)
1866 if (rtl_rate_control_register())
1867 pr_err("Unable to register rtl_rc, use default RC !!\n");
1869 /* init some global vars */
1870 INIT_LIST_HEAD(&rtl_global_var
.glb_priv_list
);
1871 spin_lock_init(&rtl_global_var
.glb_list_lock
);
1876 static void __exit
rtl_core_module_exit(void)
1879 rtl_rate_control_unregister();
1882 module_init(rtl_core_module_init
);
1883 module_exit(rtl_core_module_exit
);