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 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
27 #include <linux/module.h>
38 *NOTICE!!!: This file will be very big, we hsould
39 *keep it clear under follwing roles:
41 *This file include follwing part, so, if you add new
42 *functions into this file, please check which part it
43 *should includes. or check if you should add new part
46 *1) mac80211 init functions
47 *2) tx information functions
48 *3) functions called by core.c
49 *4) wq & timer callback functions
50 *5) frame process functions
57 /*********************************************************
59 * mac80211 init functions
61 *********************************************************/
62 static struct ieee80211_channel rtl_channeltable_2g[] = {
63 {.center_freq = 2412, .hw_value = 1,},
64 {.center_freq = 2417, .hw_value = 2,},
65 {.center_freq = 2422, .hw_value = 3,},
66 {.center_freq = 2427, .hw_value = 4,},
67 {.center_freq = 2432, .hw_value = 5,},
68 {.center_freq = 2437, .hw_value = 6,},
69 {.center_freq = 2442, .hw_value = 7,},
70 {.center_freq = 2447, .hw_value = 8,},
71 {.center_freq = 2452, .hw_value = 9,},
72 {.center_freq = 2457, .hw_value = 10,},
73 {.center_freq = 2462, .hw_value = 11,},
74 {.center_freq = 2467, .hw_value = 12,},
75 {.center_freq = 2472, .hw_value = 13,},
76 {.center_freq = 2484, .hw_value = 14,},
79 static struct ieee80211_channel rtl_channeltable_5g[] = {
80 {.center_freq = 5180, .hw_value = 36,},
81 {.center_freq = 5200, .hw_value = 40,},
82 {.center_freq = 5220, .hw_value = 44,},
83 {.center_freq = 5240, .hw_value = 48,},
84 {.center_freq = 5260, .hw_value = 52,},
85 {.center_freq = 5280, .hw_value = 56,},
86 {.center_freq = 5300, .hw_value = 60,},
87 {.center_freq = 5320, .hw_value = 64,},
88 {.center_freq = 5500, .hw_value = 100,},
89 {.center_freq = 5520, .hw_value = 104,},
90 {.center_freq = 5540, .hw_value = 108,},
91 {.center_freq = 5560, .hw_value = 112,},
92 {.center_freq = 5580, .hw_value = 116,},
93 {.center_freq = 5600, .hw_value = 120,},
94 {.center_freq = 5620, .hw_value = 124,},
95 {.center_freq = 5640, .hw_value = 128,},
96 {.center_freq = 5660, .hw_value = 132,},
97 {.center_freq = 5680, .hw_value = 136,},
98 {.center_freq = 5700, .hw_value = 140,},
99 {.center_freq = 5745, .hw_value = 149,},
100 {.center_freq = 5765, .hw_value = 153,},
101 {.center_freq = 5785, .hw_value = 157,},
102 {.center_freq = 5805, .hw_value = 161,},
103 {.center_freq = 5825, .hw_value = 165,},
106 static struct ieee80211_rate rtl_ratetable_2g[] = {
107 {.bitrate = 10, .hw_value = 0x00,},
108 {.bitrate = 20, .hw_value = 0x01,},
109 {.bitrate = 55, .hw_value = 0x02,},
110 {.bitrate = 110, .hw_value = 0x03,},
111 {.bitrate = 60, .hw_value = 0x04,},
112 {.bitrate = 90, .hw_value = 0x05,},
113 {.bitrate = 120, .hw_value = 0x06,},
114 {.bitrate = 180, .hw_value = 0x07,},
115 {.bitrate = 240, .hw_value = 0x08,},
116 {.bitrate = 360, .hw_value = 0x09,},
117 {.bitrate = 480, .hw_value = 0x0a,},
118 {.bitrate = 540, .hw_value = 0x0b,},
121 static struct ieee80211_rate rtl_ratetable_5g[] = {
122 {.bitrate = 60, .hw_value = 0x04,},
123 {.bitrate = 90, .hw_value = 0x05,},
124 {.bitrate = 120, .hw_value = 0x06,},
125 {.bitrate = 180, .hw_value = 0x07,},
126 {.bitrate = 240, .hw_value = 0x08,},
127 {.bitrate = 360, .hw_value = 0x09,},
128 {.bitrate = 480, .hw_value = 0x0a,},
129 {.bitrate = 540, .hw_value = 0x0b,},
132 static const struct ieee80211_supported_band rtl_band_2ghz = {
133 .band = IEEE80211_BAND_2GHZ,
135 .channels = rtl_channeltable_2g,
136 .n_channels = ARRAY_SIZE(rtl_channeltable_2g),
138 .bitrates = rtl_ratetable_2g,
139 .n_bitrates = ARRAY_SIZE(rtl_ratetable_2g),
144 static struct ieee80211_supported_band rtl_band_5ghz = {
145 .band = IEEE80211_BAND_5GHZ,
147 .channels = rtl_channeltable_5g,
148 .n_channels = ARRAY_SIZE(rtl_channeltable_5g),
150 .bitrates = rtl_ratetable_5g,
151 .n_bitrates = ARRAY_SIZE(rtl_ratetable_5g),
156 static const u8 tid_to_ac[] = {
157 2, /* IEEE80211_AC_BE */
158 3, /* IEEE80211_AC_BK */
159 3, /* IEEE80211_AC_BK */
160 2, /* IEEE80211_AC_BE */
161 1, /* IEEE80211_AC_VI */
162 1, /* IEEE80211_AC_VI */
163 0, /* IEEE80211_AC_VO */
164 0, /* IEEE80211_AC_VO */
167 u8 rtl92e_tid_to_ac(struct ieee80211_hw *hw, u8 tid)
169 return tid_to_ac[tid];
172 static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
173 struct ieee80211_sta_ht_cap *ht_cap)
175 struct rtl_priv *rtlpriv = rtl_priv(hw);
176 struct rtl_phy *rtlphy = &(rtlpriv->phy);
178 ht_cap->ht_supported = true;
179 ht_cap->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
180 IEEE80211_HT_CAP_SGI_40 |
181 IEEE80211_HT_CAP_SGI_20 |
182 IEEE80211_HT_CAP_DSSSCCK40 | IEEE80211_HT_CAP_MAX_AMSDU;
184 if (rtlpriv->rtlhal.disable_amsdu_8k)
185 ht_cap->cap &= ~IEEE80211_HT_CAP_MAX_AMSDU;
188 *Maximum length of AMPDU that the STA can receive.
189 *Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets)
191 ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
193 /*Minimum MPDU start spacing , */
194 ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_16;
196 ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
199 *hw->wiphy->bands[IEEE80211_BAND_2GHZ]
202 *if rx_ant =1 rx_mask[0]=0xff;==>MCS0-MCS7
203 *if rx_ant =2 rx_mask[1]=0xff;==>MCS8-MCS15
204 *if rx_ant >=3 rx_mask[2]=0xff;
205 *if BW_40 rx_mask[4]=0x01;
206 *highest supported RX rate
208 if (rtlpriv->dm.supp_phymode_switch) {
209 RT_TRACE(COMP_INIT, DBG_EMERG, ("Support phy mode switch\n"));
211 ht_cap->mcs.rx_mask[0] = 0xFF;
212 ht_cap->mcs.rx_mask[1] = 0xFF;
213 ht_cap->mcs.rx_mask[4] = 0x01;
215 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
217 if (get_rf_type(rtlphy) == RF_1T2R ||
218 get_rf_type(rtlphy) == RF_2T2R) {
219 RT_TRACE(COMP_INIT, DBG_DMESG, ("1T2R or 2T2R\n"));
221 ht_cap->mcs.rx_mask[0] = 0xFF;
222 ht_cap->mcs.rx_mask[1] = 0xFF;
223 ht_cap->mcs.rx_mask[4] = 0x01;
225 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
226 } else if (get_rf_type(rtlphy) == RF_1T1R) {
227 RT_TRACE(COMP_INIT, DBG_DMESG, ("1T1R\n"));
229 ht_cap->mcs.rx_mask[0] = 0xFF;
230 ht_cap->mcs.rx_mask[1] = 0x00;
231 ht_cap->mcs.rx_mask[4] = 0x01;
233 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7);
238 static void _rtl_init_hw_vht_capab(struct ieee80211_hw *hw,
239 struct ieee80211_sta_vht_cap *vht_cap)
241 struct rtl_priv *rtlpriv = rtl_priv(hw);
242 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
244 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
246 vht_cap->vht_supported = true;
248 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 |
249 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 |
250 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |
251 IEEE80211_VHT_CAP_SHORT_GI_80 |
252 IEEE80211_VHT_CAP_TXSTBC |
253 IEEE80211_VHT_CAP_RXSTBC_1 |
254 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
255 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
256 IEEE80211_VHT_CAP_HTC_VHT |
257 IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
258 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN |
259 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN |
262 mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 |
263 IEEE80211_VHT_MCS_SUPPORT_0_9 << 2 |
264 IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 |
265 IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 |
266 IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 |
267 IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 |
268 IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 |
269 IEEE80211_VHT_MCS_NOT_SUPPORTED << 14;
271 vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
272 vht_cap->vht_mcs.rx_highest =
273 cpu_to_le16(MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9);
274 vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
275 vht_cap->vht_mcs.tx_highest =
276 cpu_to_le16(MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9);
277 } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) {
280 vht_cap->vht_supported = true;
282 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 |
283 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 |
284 IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |
285 IEEE80211_VHT_CAP_SHORT_GI_80 |
286 IEEE80211_VHT_CAP_TXSTBC |
287 IEEE80211_VHT_CAP_RXSTBC_1 |
288 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
289 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
290 IEEE80211_VHT_CAP_HTC_VHT |
291 IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
292 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN |
293 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN |
296 mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 |
297 IEEE80211_VHT_MCS_NOT_SUPPORTED << 2 |
298 IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 |
299 IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 |
300 IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 |
301 IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 |
302 IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 |
303 IEEE80211_VHT_MCS_NOT_SUPPORTED << 14;
305 vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
306 vht_cap->vht_mcs.rx_highest =
307 cpu_to_le16(MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9);
308 vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
309 vht_cap->vht_mcs.tx_highest =
310 cpu_to_le16(MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9);
314 static void _rtl_init_mac80211(struct ieee80211_hw *hw)
316 struct rtl_priv *rtlpriv = rtl_priv(hw);
317 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
318 struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
319 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
320 struct ieee80211_supported_band *sband;
323 if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY &&
324 rtlhal->bandset == BAND_ON_BOTH) {
326 /* <1> use mac->bands as mem for hw->wiphy->bands */
327 sband = &(rtlmac->bands[IEEE80211_BAND_2GHZ]);
329 /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ]
330 * to default value(1T1R) */
331 memcpy(&(rtlmac->bands[IEEE80211_BAND_2GHZ]), &rtl_band_2ghz,
332 sizeof(struct ieee80211_supported_band));
334 /* <3> init ht cap base on ant_num */
335 _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
337 /* <4> set mac->sband to wiphy->sband */
338 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband;
341 /* <1> use mac->bands as mem for hw->wiphy->bands */
342 sband = &(rtlmac->bands[IEEE80211_BAND_5GHZ]);
344 /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ]
345 * to default value(1T1R) */
346 memcpy(&(rtlmac->bands[IEEE80211_BAND_5GHZ]), &rtl_band_5ghz,
347 sizeof(struct ieee80211_supported_band));
349 /* <3> init ht cap base on ant_num */
350 _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
352 _rtl_init_hw_vht_capab(hw, &sband->vht_cap);
354 /* <4> set mac->sband to wiphy->sband */
355 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband;
357 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
358 /* <1> use mac->bands as mem for hw->wiphy->bands */
359 sband = &(rtlmac->bands[IEEE80211_BAND_2GHZ]);
361 /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ]
362 * to default value(1T1R) */
363 memcpy(&(rtlmac->bands[IEEE80211_BAND_2GHZ]),
365 sizeof(struct ieee80211_supported_band));
367 /* <3> init ht cap base on ant_num */
368 _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
370 /* <4> set mac->sband to wiphy->sband */
371 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband;
372 } else if (rtlhal->current_bandtype == BAND_ON_5G) {
373 /* <1> use mac->bands as mem for hw->wiphy->bands */
374 sband = &(rtlmac->bands[IEEE80211_BAND_5GHZ]);
376 /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ]
377 * to default value(1T1R) */
378 memcpy(&(rtlmac->bands[IEEE80211_BAND_5GHZ]),
380 sizeof(struct ieee80211_supported_band));
382 /* <3> init ht cap base on ant_num */
383 _rtl_init_hw_ht_capab(hw, &sband->ht_cap);
385 _rtl_init_hw_vht_capab(hw, &sband->vht_cap);
387 /* <4> set mac->sband to wiphy->sband */
388 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband;
390 RT_TRACE(COMP_INIT, DBG_EMERG,
391 ("Err BAND %d\n", rtlhal->current_bandtype));
394 /* <5> set hw caps */
395 hw->flags = IEEE80211_HW_SIGNAL_DBM |
396 IEEE80211_HW_RX_INCLUDES_FCS |
397 IEEE80211_HW_AMPDU_AGGREGATION |
398 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
399 IEEE80211_HW_CONNECTION_MONITOR |
400 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
401 IEEE80211_HW_MFP_CAPABLE | 0;
403 /* swlps or hwlps has been set in diff chip in init_sw_vars */
404 if (rtlpriv->psc.b_swctrl_lps)
405 hw->flags |= IEEE80211_HW_SUPPORTS_PS |
406 IEEE80211_HW_PS_NULLFUNC_STACK |
407 /* IEEE80211_HW_SUPPORTS_DYNAMIC_PS | */
409 /*<delete in kernel start>*/
410 hw->wiphy->interface_modes =
411 BIT(NL80211_IFTYPE_AP) |
412 BIT(NL80211_IFTYPE_STATION) |
413 BIT(NL80211_IFTYPE_ADHOC) |
414 BIT(NL80211_IFTYPE_MESH_POINT) |
415 BIT(NL80211_IFTYPE_P2P_CLIENT) |
416 BIT(NL80211_IFTYPE_P2P_GO);
417 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
419 hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
421 hw->wiphy->rts_threshold = 2347;
424 hw->extra_tx_headroom = RTL_TX_HEADER_SIZE;
426 /* TODO: Correct this value for our hw */
427 /* TODO: define these hard code value */
428 /* hw->channel_change_time = 100; kernel does not use it*/
429 hw->max_listen_interval = 10;
430 hw->max_rate_tries = 4;
431 /* hw->max_rates = 1; */
432 hw->sta_data_size = sizeof(struct rtl_sta_info);
434 /* wowlan is not supported by kernel if CONFIG_PM is not defined */
436 if (rtlpriv->psc.wo_wlan_mode) {
437 if (rtlpriv->psc.wo_wlan_mode & WAKE_ON_MAGIC_PACKET)
438 rtlpriv->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT;
439 if (rtlpriv->psc.wo_wlan_mode & WAKE_ON_PATTERN_MATCH) {
440 rtlpriv->wowlan.n_patterns =
441 MAX_SUPPORT_WOL_PATTERN_NUM;
442 rtlpriv->wowlan.pattern_min_len = MIN_WOL_PATTERN_SIZE;
443 rtlpriv->wowlan.pattern_max_len = MAX_WOL_PATTERN_SIZE;
445 hw->wiphy->wowlan = &(rtlpriv->wowlan);
449 /* <6> mac address */
450 if (is_valid_ether_addr(rtlefuse->dev_addr)) {
451 SET_IEEE80211_PERM_ADDR(hw, rtlefuse->dev_addr);
453 u8 rtlmac[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 };
454 get_random_bytes((rtlmac + (ETH_ALEN - 1)), 1);
455 SET_IEEE80211_PERM_ADDR(hw, rtlmac);
459 static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
461 struct rtl_priv *rtlpriv = rtl_priv(hw);
464 init_timer(&rtlpriv->works.watchdog_timer);
465 setup_timer(&rtlpriv->works.watchdog_timer,
466 rtl92e_watch_dog_timer_callback, (unsigned long)hw);
467 init_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer);
468 setup_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer,
469 rtl92e_easy_concurrent_retrytimer_callback, (unsigned long)hw);
471 rtlpriv->works.hw = hw;
472 rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
473 INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
474 (void *)rtl92e_watchdog_wq_callback);
475 INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
476 (void *)rtl92e_ips_nic_off_wq_callback);
477 INIT_DELAYED_WORK(&rtlpriv->works.ps_work,
478 (void *)rtl92e_swlps_wq_callback);
479 INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq,
480 (void *)rtl92e_swlps_rfon_wq_callback);
481 INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq,
482 (void *)rtl92e_fwevt_wq_callback);
485 void rtl92e_deinit_deferred_work(struct ieee80211_hw *hw)
487 struct rtl_priv *rtlpriv = rtl_priv(hw);
489 del_timer_sync(&rtlpriv->works.watchdog_timer);
491 cancel_delayed_work(&rtlpriv->works.watchdog_wq);
492 cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq);
493 cancel_delayed_work(&rtlpriv->works.ps_work);
494 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
495 cancel_delayed_work(&rtlpriv->works.fwevt_wq);
498 void rtl92e_init_rfkill(struct ieee80211_hw *hw)
500 struct rtl_priv *rtlpriv = rtl_priv(hw);
506 /*set init state to on */
507 rtlpriv->rfkill.rfkill_state = 1;
508 wiphy_rfkill_set_hw_state(hw->wiphy, 0);
510 radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
513 pr_info("rtlwifi: wireless switch is %s\n",
514 rtlpriv->rfkill.rfkill_state ? "on" : "off");
516 rtlpriv->rfkill.rfkill_state = radio_state;
518 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
519 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
522 wiphy_rfkill_start_polling(hw->wiphy);
525 void rtl92e_deinit_rfkill(struct ieee80211_hw *hw)
527 wiphy_rfkill_stop_polling(hw->wiphy);
531 static void rtl_init_vif(struct ieee80211_hw *hw)
533 struct rtl_priv *rtlpriv = rtl_priv(hw);
535 INIT_LIST_HEAD(&rtlpriv->vif_priv.vif_list);
537 rtlpriv->vif_priv.vifs = 0;
541 int rtl92e_init_core(struct ieee80211_hw *hw)
543 struct rtl_priv *rtlpriv = rtl_priv(hw);
544 struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
546 /* <1> init mac80211 */
547 _rtl_init_mac80211(hw);
549 rtlmac->link_state = MAC80211_NOLINK;
551 /* <2> rate control register */
552 hw->rate_control_algorithm = "rtl_rc";
555 * <3> init CRDA must come after init
556 * mac80211 hw in _rtl_init_mac80211.
558 if (rtl92e_regd_init(hw, rtl92e_reg_notifier)) {
559 RT_TRACE(COMP_ERR, DBG_EMERG, ("REGD init failed\n"));
564 mutex_init(&rtlpriv->locks.conf_mutex);
565 spin_lock_init(&rtlpriv->locks.ips_lock);
566 spin_lock_init(&rtlpriv->locks.irq_th_lock);
567 spin_lock_init(&rtlpriv->locks.h2c_lock);
568 spin_lock_init(&rtlpriv->locks.rf_ps_lock);
569 spin_lock_init(&rtlpriv->locks.rf_lock);
570 spin_lock_init(&rtlpriv->locks.lps_lock);
571 spin_lock_init(&rtlpriv->locks.waitq_lock);
572 spin_lock_init(&rtlpriv->locks.entry_list_lock);
573 spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock);
574 spin_lock_init(&rtlpriv->locks.check_sendpkt_lock);
575 spin_lock_init(&rtlpriv->locks.fw_ps_lock);
576 spin_lock_init(&rtlpriv->locks.iqk_lock);
578 INIT_LIST_HEAD(&rtlpriv->entry_list);
580 /* <6> init deferred work */
581 _rtl_init_deferred_work(hw);
591 void rtl92e_deinit_core(struct ieee80211_hw *hw)
595 void rtl92e_init_rx_config(struct ieee80211_hw *hw)
597 struct rtl_priv *rtlpriv = rtl_priv(hw);
598 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
600 rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)(&mac->rx_conf));
603 /*********************************************************
605 * tx information functions
607 *********************************************************/
608 static void _rtl_qurey_shortpreamble_mode(struct ieee80211_hw *hw,
609 struct rtl_tcb_desc *tcb_desc,
610 struct ieee80211_tx_info *info)
612 struct rtl_priv *rtlpriv = rtl_priv(hw);
613 u8 rate_flag = info->control.rates[0].flags;
615 tcb_desc->use_shortpreamble = false;
617 /* 1M can only use Long Preamble. 11B spec */
618 if (tcb_desc->hw_rate == rtlpriv->cfg->maps[RTL_RC_CCK_RATE1M])
620 else if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
621 tcb_desc->use_shortpreamble = true;
626 static void _rtl_query_shortgi(struct ieee80211_hw *hw,
627 struct ieee80211_sta *sta,
628 struct rtl_tcb_desc *tcb_desc,
629 struct ieee80211_tx_info *info)
631 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
632 u8 rate_flag = info->control.rates[0].flags;
633 u8 sgi_40 = 0, sgi_20 = 0, bw_40 = 0;
634 u8 sgi_80 = 0, bw_80 = 0;
635 tcb_desc->use_shortgi = false;
640 sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
641 sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
642 sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80;
644 if (!(sta->ht_cap.ht_supported) && !(sta->vht_cap.vht_supported))
647 if (!sgi_40 && !sgi_20)
650 if (mac->opmode == NL80211_IFTYPE_STATION) {
653 } else if (mac->opmode == NL80211_IFTYPE_AP ||
654 mac->opmode == NL80211_IFTYPE_ADHOC ||
655 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
656 bw_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
657 bw_80 = sta->vht_cap.vht_supported;
662 tcb_desc->use_shortgi = true;
664 tcb_desc->use_shortgi = false;
667 tcb_desc->use_shortgi = true;
668 else if (!bw_40 && sgi_20)
669 tcb_desc->use_shortgi = true;
672 if (!(rate_flag & IEEE80211_TX_RC_SHORT_GI))
673 tcb_desc->use_shortgi = false;
676 static void _rtl_query_protection_mode(struct ieee80211_hw *hw,
677 struct rtl_tcb_desc *tcb_desc,
678 struct ieee80211_tx_info *info)
680 struct rtl_priv *rtlpriv = rtl_priv(hw);
681 u8 rate_flag = info->control.rates[0].flags;
683 /* Common Settings */
684 tcb_desc->b_rts_stbc = false;
685 tcb_desc->b_cts_enable = false;
686 tcb_desc->rts_sc = 0;
687 tcb_desc->b_rts_bw = false;
688 tcb_desc->b_rts_use_shortpreamble = false;
689 tcb_desc->b_rts_use_shortgi = false;
691 if (rate_flag & IEEE80211_TX_RC_USE_CTS_PROTECT) {
692 /* Use CTS-to-SELF in protection mode. */
693 tcb_desc->b_rts_enable = true;
694 tcb_desc->b_cts_enable = true;
695 tcb_desc->rts_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE24M];
696 } else if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
697 /* Use RTS-CTS in protection mode. */
698 tcb_desc->b_rts_enable = true;
699 tcb_desc->rts_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE24M];
703 static void _rtl_txrate_selectmode(struct ieee80211_hw *hw,
704 struct ieee80211_sta *sta,
705 struct rtl_tcb_desc *tcb_desc)
707 struct rtl_priv *rtlpriv = rtl_priv(hw);
708 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
709 struct rtl_sta_info *sta_entry = NULL;
713 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
714 ratr_index = sta_entry->ratr_index;
716 if (!tcb_desc->disable_ratefallback || !tcb_desc->use_driver_rate) {
717 if (mac->opmode == NL80211_IFTYPE_STATION) {
718 tcb_desc->ratr_index = 0;
719 } else if (mac->opmode == NL80211_IFTYPE_ADHOC ||
720 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
721 if (tcb_desc->b_multicast || tcb_desc->b_broadcast) {
723 rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M];
724 tcb_desc->use_driver_rate = 1;
725 tcb_desc->ratr_index = RATR_INX_WIRELESS_MC;
727 tcb_desc->ratr_index = ratr_index;
729 } else if (mac->opmode == NL80211_IFTYPE_AP) {
730 tcb_desc->ratr_index = ratr_index;
734 if (rtlpriv->dm.b_useramask) {
735 tcb_desc->ratr_index = ratr_index;
736 /* TODO we will differentiate adhoc and station futrue */
737 if (mac->opmode == NL80211_IFTYPE_STATION ||
738 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
739 tcb_desc->mac_id = 0;
741 if (mac->mode == WIRELESS_MODE_AC_5G)
742 tcb_desc->ratr_index =
743 RATR_INX_WIRELESS_AC_5N;
744 else if (mac->mode == WIRELESS_MODE_AC_24G)
745 tcb_desc->ratr_index =
746 RATR_INX_WIRELESS_AC_24N;
747 else if (mac->mode == WIRELESS_MODE_N_24G)
748 tcb_desc->ratr_index = RATR_INX_WIRELESS_NGB;
749 else if (mac->mode == WIRELESS_MODE_N_5G)
750 tcb_desc->ratr_index = RATR_INX_WIRELESS_NG;
751 else if (mac->mode & WIRELESS_MODE_G)
752 tcb_desc->ratr_index = RATR_INX_WIRELESS_GB;
753 else if (mac->mode & WIRELESS_MODE_B)
754 tcb_desc->ratr_index = RATR_INX_WIRELESS_B;
755 else if (mac->mode & WIRELESS_MODE_A)
756 tcb_desc->ratr_index = RATR_INX_WIRELESS_G;
758 } else if (mac->opmode == NL80211_IFTYPE_AP ||
759 mac->opmode == NL80211_IFTYPE_ADHOC) {
762 tcb_desc->mac_id = sta->aid + 1;
764 tcb_desc->mac_id = 1;
766 tcb_desc->mac_id = 0;
772 static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw,
773 struct ieee80211_sta *sta,
774 struct rtl_tcb_desc *tcb_desc)
776 struct rtl_priv *rtlpriv = rtl_priv(hw);
777 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
779 tcb_desc->packet_bw = 0;
782 if (mac->opmode == NL80211_IFTYPE_AP ||
783 mac->opmode == NL80211_IFTYPE_ADHOC ||
784 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
785 if (!(sta->ht_cap.ht_supported) ||
786 !(sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
788 } else if (mac->opmode == NL80211_IFTYPE_STATION) {
789 if (!mac->bw_40 || !(sta->ht_cap.ht_supported))
792 if (tcb_desc->b_multicast || tcb_desc->b_broadcast)
795 /*use legency rate, shall use 20MHz */
796 if (tcb_desc->hw_rate <= rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M])
799 tcb_desc->packet_bw = HT_CHANNEL_WIDTH_20_40;
801 if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE ||
802 rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8821AE) {
803 if (mac->opmode == NL80211_IFTYPE_AP ||
804 mac->opmode == NL80211_IFTYPE_ADHOC ||
805 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
806 if (!(sta->vht_cap.vht_supported)) {
808 } else if (mac->opmode == NL80211_IFTYPE_STATION) {
810 !(sta->vht_cap.vht_supported))
814 if (tcb_desc->hw_rate <=
815 rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15])
817 tcb_desc->packet_bw = HT_CHANNEL_WIDTH_80;
821 static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw,
822 struct ieee80211_sta *sta)
824 struct rtl_priv *rtlpriv = rtl_priv(hw);
825 struct rtl_phy *rtlphy = &(rtlpriv->phy);
827 u16 map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map);
829 if (get_rf_type(rtlphy) == RF_2T2R) {
830 if ((map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_7)
832 rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS7];
833 else if ((map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_8)
834 hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
836 hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9];
838 if ((map & 0x0003) == IEEE80211_VHT_MCS_SUPPORT_0_7)
839 hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS7];
840 else if ((map & 0x0003) == IEEE80211_VHT_MCS_SUPPORT_0_8)
841 hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
843 hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9];
849 static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
850 struct ieee80211_sta *sta)
852 struct rtl_priv *rtlpriv = rtl_priv(hw);
853 struct rtl_phy *rtlphy = &(rtlpriv->phy);
856 if ((get_rf_type(rtlphy) == RF_2T2R) &&
857 (sta->ht_cap.mcs.rx_mask[1] != 0))
858 hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15];
860 hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS7];
865 void stg_rtl_get_tcb_desc(struct ieee80211_hw *hw,
866 struct ieee80211_tx_info *info,
867 struct ieee80211_sta *sta,
868 struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc)
870 struct rtl_priv *rtlpriv = rtl_priv(hw);
871 struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
872 struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
873 struct ieee80211_rate *txrate;
874 __le16 fc = rtl_get_fc(skb);
876 txrate = ieee80211_get_tx_rate(hw, info);
878 tcb_desc->hw_rate = txrate->hw_value;
880 if (ieee80211_is_data(fc)) {
882 *we set data rate INX 0
883 *in rtl_rc.c if skb is special data or
884 *mgt which need low data rate.
888 *So tcb_desc->hw_rate is just used for
889 *special data and mgt frames
891 if (info->control.rates[0].idx == 0 ||
892 ieee80211_is_nullfunc(fc)) {
893 tcb_desc->use_driver_rate = true;
894 tcb_desc->ratr_index = RATR_INX_WIRELESS_MC;
896 tcb_desc->disable_ratefallback = 1;
899 *because hw will nerver use hw_rate
900 *when tcb_desc->use_driver_rate = false
901 *so we never set highest N rate here,
902 *and N rate will all be controled by FW
903 *when tcb_desc->use_driver_rate = false
905 if (sta && sta->vht_cap.vht_supported) {
907 _rtl_get_vht_highest_n_rate(hw, sta);
908 } else if (sta && (sta->ht_cap.ht_supported)) {
910 _rtl_get_highest_n_rate(hw, sta);
912 if (rtlmac->mode == WIRELESS_MODE_B) {
914 rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M];
917 rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M];
922 if (is_multicast_ether_addr(ieee80211_get_DA(hdr)))
923 tcb_desc->b_multicast = 1;
924 else if (is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
925 tcb_desc->b_broadcast = 1;
927 _rtl_txrate_selectmode(hw, sta, tcb_desc);
928 _rtl_query_bandwidth_mode(hw, sta, tcb_desc);
929 _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info);
930 _rtl_query_shortgi(hw, sta, tcb_desc, info);
931 _rtl_query_protection_mode(hw, tcb_desc, info);
933 tcb_desc->use_driver_rate = true;
934 tcb_desc->ratr_index = RATR_INX_WIRELESS_MC;
935 tcb_desc->disable_ratefallback = 1;
936 tcb_desc->mac_id = 0;
937 tcb_desc->packet_bw = 0;
940 EXPORT_SYMBOL(stg_rtl_get_tcb_desc);
942 bool rtl92e_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb)
944 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
945 struct rtl_priv *rtlpriv = rtl_priv(hw);
946 __le16 fc = rtl_get_fc(skb);
948 if (rtlpriv->dm.supp_phymode_switch &&
949 mac->link_state < MAC80211_LINKED &&
950 (ieee80211_is_auth(fc) || ieee80211_is_probe_req(fc))) {
951 if (rtlpriv->cfg->ops->check_switch_to_dmdp)
952 rtlpriv->cfg->ops->check_switch_to_dmdp(hw);
954 if (ieee80211_is_auth(fc)) {
955 RT_TRACE(COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n"));
956 rtl92e_ips_nic_on(hw);
958 mac->link_state = MAC80211_LINKING;
960 rtlpriv->phy.b_need_iqk = true;
965 struct sk_buff *rtl92e_make_del_ba(struct ieee80211_hw *hw, u8 *sa,
968 bool rtl92e_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
970 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
971 struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
972 struct rtl_priv *rtlpriv = rtl_priv(hw);
973 __le16 fc = rtl_get_fc(skb);
974 u8 *act = (u8 *)(((u8 *)skb->data + MAC80211_3ADDR_LEN));
977 if (!ieee80211_is_action(fc))
986 if (mac->act_scanning)
989 RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG,
990 ("%s ACT_ADDBAREQ From:%pM\n",
991 is_tx ? "Tx" : "Rx", hdr->addr2));
992 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "req\n",
993 skb->data, skb->len);
995 struct ieee80211_sta *sta = NULL;
996 struct rtl_sta_info *sta_entry = NULL;
997 struct ieee80211_mgmt *mgmt = (void *)skb->data;
998 u16 capab = 0, tid = 0;
999 struct rtl_tid_data *tid_data;
1000 struct sk_buff *skb_delba = NULL;
1001 struct ieee80211_rx_status rx_status = { 0 };
1004 sta = rtl_find_sta(hw, hdr->addr3);
1006 RT_TRACE((COMP_SEND | COMP_RECV),
1007 DBG_TRACE, ("sta is NULL\n"));
1013 (struct rtl_sta_info *)sta->drv_priv;
1018 capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab);
1020 IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
1021 tid_data = &sta_entry->tids[tid];
1022 if (tid_data->agg.rx_agg_state ==
1024 skb_delba = rtl92e_make_del_ba(hw,
1030 hw->conf.chandef.chan->center_freq;
1032 hw->conf.chandef.chan->band;
1033 rx_status.flag |= RX_FLAG_DECRYPTED;
1034 rx_status.flag |= RX_FLAG_MACTIME_MPDU;
1035 rx_status.rate_idx = 0;
1036 rx_status.signal = 50 + 10;
1037 memcpy(IEEE80211_SKB_RXCB(skb_delba),
1038 &rx_status, sizeof(rx_status));
1039 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG,
1041 skb_delba->data, skb_delba->len);
1042 ieee80211_rx_irqsafe(hw, skb_delba);
1049 RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG,
1050 ("%s ACT_ADDBARSP From :%pM\n",
1051 is_tx ? "Tx" : "Rx", hdr->addr2));
1054 RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG,
1055 ("ACT_ADDBADEL From :%pM\n", hdr->addr2));
1066 /*should call before software enc*/
1067 u8 rtl92e_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb,
1070 struct rtl_priv *rtlpriv = rtl_priv(hw);
1071 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1072 __le16 fc = rtl_get_fc(skb);
1074 u8 mac_hdr_len = ieee80211_get_hdrlen_from_skb(skb);
1075 const struct iphdr *ip;
1077 if (!ieee80211_is_data(fc))
1080 ip = (struct iphdr *)((u8 *)skb->data + mac_hdr_len +
1081 SNAP_SIZE + PROTOC_TYPE_SIZE);
1082 ether_type = be16_to_cpup((__be16 *)
1083 (skb->data + mac_hdr_len + SNAP_SIZE));
1085 if (ETH_P_IP == ether_type) {
1086 if (IPPROTO_UDP == ip->protocol) {
1087 struct udphdr *udp = (struct udphdr *)((u8 *)ip +
1089 if (((((u8 *)udp)[1] == 68) &&
1090 (((u8 *)udp)[3] == 67)) ||
1091 ((((u8 *)udp)[1] == 67) &&
1092 (((u8 *)udp)[3] == 68))) {
1094 * 68 : UDP BOOTP client
1095 * 67 : UDP BOOTP server
1097 RT_TRACE((COMP_SEND | COMP_RECV),
1098 DBG_DMESG, ("dhcp %s !!\n",
1099 (is_tx) ? "Tx" : "Rx"));
1102 rtlpriv->ra.is_special_data = true;
1103 if (rtlpriv->cfg->ops->get_btc_status())
1104 rtlpriv->btcoexist.btc_ops->btc_special_packet_notify(
1106 rtl92e_lps_leave(hw);
1107 ppsc->last_delaylps_stamp_jiffies =
1114 } else if (ETH_P_ARP == ether_type) {
1116 rtlpriv->ra.is_special_data = true;
1117 if (rtlpriv->cfg->ops->get_btc_status())
1118 rtlpriv->btcoexist.btc_ops->btc_special_packet_notify(
1120 rtl92e_lps_leave(hw);
1121 ppsc->last_delaylps_stamp_jiffies = jiffies;
1125 } else if (ETH_P_PAE == ether_type) {
1126 RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG,
1127 ("802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx"));
1130 rtlpriv->ra.is_special_data = true;
1131 rtl92e_lps_leave(hw);
1132 ppsc->last_delaylps_stamp_jiffies = jiffies;
1136 } else if (0x86DD == ether_type) {
1141 rtlpriv->ra.is_special_data = false;
1145 /*********************************************************
1147 * functions called by core.c
1149 *********************************************************/
1150 int rtl92e_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1151 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
1153 struct rtl_priv *rtlpriv = rtl_priv(hw);
1154 struct rtl_tid_data *tid_data;
1155 struct rtl_sta_info *sta_entry = NULL;
1160 if (unlikely(tid >= MAX_TID_COUNT))
1163 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1166 tid_data = &sta_entry->tids[tid];
1168 RT_TRACE(COMP_SEND, DBG_DMESG,
1169 ("on ra = %pM tid = %d seq:%d\n", sta->addr, tid,
1170 tid_data->seq_number));
1172 *ssn = tid_data->seq_number;
1173 tid_data->agg.agg_state = RTL_AGG_START;
1175 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1179 int rtl92e_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1180 struct ieee80211_sta *sta, u16 tid)
1182 struct rtl_priv *rtlpriv = rtl_priv(hw);
1183 struct rtl_tid_data *tid_data;
1184 struct rtl_sta_info *sta_entry = NULL;
1189 /* Comparing an array to null is not useful */
1191 RT_TRACE(COMP_ERR, DBG_EMERG, ("ra = NULL\n"));
1195 RT_TRACE(COMP_SEND, DBG_DMESG,
1196 ("on ra = %pM tid = %d\n", sta->addr, tid));
1198 if (unlikely(tid >= MAX_TID_COUNT))
1201 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1202 tid_data = &sta_entry->tids[tid];
1203 sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP;
1205 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1209 int rtl92e_rx_agg_start(struct ieee80211_hw *hw,
1210 struct ieee80211_sta *sta, u16 tid)
1212 struct rtl_priv *rtlpriv = rtl_priv(hw);
1213 struct rtl_tid_data *tid_data;
1214 struct rtl_sta_info *sta_entry = NULL;
1219 if (unlikely(tid >= MAX_TID_COUNT))
1222 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1225 tid_data = &sta_entry->tids[tid];
1227 RT_TRACE(COMP_RECV, DBG_DMESG,
1228 ("on ra = %pM tid = %d seq:%d\n", sta->addr, tid,
1229 tid_data->seq_number));
1231 tid_data->agg.rx_agg_state = RTL_RX_AGG_START;
1235 int rtl92e_rx_agg_stop(struct ieee80211_hw *hw,
1236 struct ieee80211_sta *sta, u16 tid)
1238 struct rtl_priv *rtlpriv = rtl_priv(hw);
1239 struct rtl_tid_data *tid_data;
1240 struct rtl_sta_info *sta_entry = NULL;
1245 /* Comparing an array to null is not useful */
1247 RT_TRACE(COMP_ERR, DBG_EMERG, ("ra = NULL\n"));
1251 RT_TRACE(COMP_SEND, DBG_DMESG,
1252 ("on ra = %pM tid = %d\n", sta->addr, tid));
1254 if (unlikely(tid >= MAX_TID_COUNT))
1257 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1258 tid_data = &sta_entry->tids[tid];
1259 sta_entry->tids[tid].agg.rx_agg_state = RTL_RX_AGG_STOP;
1264 int rtl92e_tx_agg_oper(struct ieee80211_hw *hw,
1265 struct ieee80211_sta *sta, u16 tid)
1267 struct rtl_priv *rtlpriv = rtl_priv(hw);
1268 struct rtl_tid_data *tid_data;
1269 struct rtl_sta_info *sta_entry = NULL;
1274 /* Comparing an array to null is not useful */
1276 RT_TRACE(COMP_ERR, DBG_EMERG, ("ra = NULL\n"));
1280 RT_TRACE(COMP_SEND, DBG_DMESG,
1281 ("on ra = %pM tid = %d\n", sta->addr, tid));
1283 if (unlikely(tid >= MAX_TID_COUNT))
1286 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1287 tid_data = &sta_entry->tids[tid];
1288 sta_entry->tids[tid].agg.agg_state = RTL_AGG_OPERATIONAL;
1293 /*********************************************************
1295 * wq & timer callback functions
1297 *********************************************************/
1298 /* this function is used for roaming */
1299 void rtl92e_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb)
1301 struct rtl_priv *rtlpriv = rtl_priv(hw);
1302 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1304 if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
1307 if (rtlpriv->mac80211.link_state < MAC80211_LINKED)
1310 /* check if this really is a beacon */
1311 if (!ieee80211_is_beacon(hdr->frame_control) &&
1312 !ieee80211_is_probe_resp(hdr->frame_control))
1315 /* min. beacon length + FCS_LEN */
1316 if (skb->len <= 40 + FCS_LEN)
1319 /* and only beacons from the associated BSSID, please */
1320 if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
1323 rtlpriv->link_info.bcn_rx_inperiod++;
1326 void rtl92e_watchdog_wq_callback(void *data)
1328 struct rtl_works *rtlworks = container_of_dwork_rtl(data,
1331 struct ieee80211_hw *hw = rtlworks->hw;
1332 struct rtl_priv *rtlpriv = rtl_priv(hw);
1333 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1334 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1335 bool b_busytraffic = false;
1336 bool b_tx_busy_traffic = false;
1337 bool b_rx_busy_traffic = false;
1338 bool b_higher_busytraffic = false;
1339 bool b_higher_busyrxtraffic = false;
1341 u32 rx_cnt_inp4eriod = 0;
1342 u32 tx_cnt_inp4eriod = 0;
1343 u32 aver_rx_cnt_inperiod = 0;
1344 u32 aver_tx_cnt_inperiod = 0;
1345 u32 aver_tidtx_inperiod[MAX_TID_COUNT] = {0};
1346 u32 tidtx_inp4eriod[MAX_TID_COUNT] = {0};
1347 bool benter_ps = false;
1349 if (is_hal_stop(rtlhal))
1352 /* <1> Determine if action frame is allowed */
1353 if (mac->link_state > MAC80211_NOLINK) {
1354 if (mac->cnt_after_linked < 20)
1355 mac->cnt_after_linked++;
1357 mac->cnt_after_linked = 0;
1360 /* <2> to check if traffic busy, if
1361 * busytraffic we don't change channel */
1362 if (mac->link_state >= MAC80211_LINKED) {
1363 /* (1) get aver_rx_cnt_inperiod & aver_tx_cnt_inperiod */
1364 for (idx = 0; idx <= 2; idx++) {
1365 rtlpriv->link_info.num_rx_in4period[idx] =
1366 rtlpriv->link_info.num_rx_in4period[idx + 1];
1367 rtlpriv->link_info.num_tx_in4period[idx] =
1368 rtlpriv->link_info.num_tx_in4period[idx + 1];
1370 rtlpriv->link_info.num_rx_in4period[3] =
1371 rtlpriv->link_info.num_rx_inperiod;
1372 rtlpriv->link_info.num_tx_in4period[3] =
1373 rtlpriv->link_info.num_tx_inperiod;
1374 for (idx = 0; idx <= 3; idx++) {
1376 rtlpriv->link_info.num_rx_in4period[idx];
1378 rtlpriv->link_info.num_tx_in4period[idx];
1380 aver_rx_cnt_inperiod = rx_cnt_inp4eriod / 4;
1381 aver_tx_cnt_inperiod = tx_cnt_inp4eriod / 4;
1383 /* (2) check traffic busy */
1384 if (aver_rx_cnt_inperiod > 100 || aver_tx_cnt_inperiod > 100) {
1385 b_busytraffic = true;
1386 if (aver_rx_cnt_inperiod > aver_tx_cnt_inperiod)
1387 b_rx_busy_traffic = true;
1389 b_tx_busy_traffic = false;
1392 /* Higher Tx/Rx data. */
1393 if (aver_rx_cnt_inperiod > 4000 ||
1394 aver_tx_cnt_inperiod > 4000) {
1395 b_higher_busytraffic = true;
1397 /* Extremely high Rx data. */
1398 if (aver_rx_cnt_inperiod > 5000)
1399 b_higher_busyrxtraffic = true;
1402 /* check every tid's tx traffic */
1403 for (tid = 0; tid <= 7; tid++) {
1404 for (idx = 0; idx <= 2; idx++)
1405 rtlpriv->link_info.tidtx_in4period[tid][idx] =
1406 rtlpriv->link_info.tidtx_in4period[tid]
1408 rtlpriv->link_info.tidtx_in4period[tid][3] =
1409 rtlpriv->link_info.tidtx_inperiod[tid];
1411 for (idx = 0; idx <= 3; idx++)
1412 tidtx_inp4eriod[tid] +=
1413 rtlpriv->link_info.tidtx_in4period[tid][idx];
1414 aver_tidtx_inperiod[tid] = tidtx_inp4eriod[tid] / 4;
1415 if (aver_tidtx_inperiod[tid] > 5000)
1416 rtlpriv->link_info.higher_busytxtraffic[tid] =
1419 rtlpriv->link_info.higher_busytxtraffic[tid] =
1423 if (((rtlpriv->link_info.num_rx_inperiod +
1424 rtlpriv->link_info.num_tx_inperiod) > 8) ||
1425 (rtlpriv->link_info.num_rx_inperiod > 2))
1430 /* LeisurePS only work in infra mode. */
1432 rtl92e_lps_enter(hw);
1434 rtl92e_lps_leave(hw);
1437 rtlpriv->link_info.num_rx_inperiod = 0;
1438 rtlpriv->link_info.num_tx_inperiod = 0;
1439 for (tid = 0; tid <= 7; tid++)
1440 rtlpriv->link_info.tidtx_inperiod[tid] = 0;
1442 rtlpriv->link_info.b_busytraffic = b_busytraffic;
1443 rtlpriv->link_info.b_rx_busy_traffic = b_rx_busy_traffic;
1444 rtlpriv->link_info.b_tx_busy_traffic = b_tx_busy_traffic;
1445 rtlpriv->link_info.b_higher_busytraffic = b_higher_busytraffic;
1446 rtlpriv->link_info.b_higher_busyrxtraffic = b_higher_busyrxtraffic;
1449 rtlpriv->cfg->ops->dm_watchdog(hw);
1452 if (mac->link_state == MAC80211_LINKED &&
1453 mac->opmode == NL80211_IFTYPE_STATION) {
1454 if ((rtlpriv->link_info.bcn_rx_inperiod +
1455 rtlpriv->link_info.num_rx_inperiod) == 0) {
1456 rtlpriv->link_info.roam_times++;
1457 RT_TRACE(COMP_ERR, DBG_DMESG,
1458 ("AP off for %d s\n",
1459 (rtlpriv->link_info.roam_times * 2)));
1461 /* if we can't recv beacon for 10s,
1462 * we should reconnect this AP */
1463 if (rtlpriv->link_info.roam_times >= 5) {
1464 RT_TRACE(COMP_ERR, DBG_EMERG,
1465 ("AP off, try to reconnect now\n"));
1466 rtlpriv->link_info.roam_times = 0;
1467 ieee80211_connection_loss(
1468 rtlpriv->mac80211.vif);
1471 rtlpriv->link_info.roam_times = 0;
1475 if (rtlpriv->cfg->ops->get_btc_status())
1476 rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv);
1478 rtlpriv->link_info.bcn_rx_inperiod = 0;
1481 void rtl92e_watch_dog_timer_callback(unsigned long data)
1483 struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
1484 struct rtl_priv *rtlpriv = rtl_priv(hw);
1486 queue_delayed_work(rtlpriv->works.rtl_wq,
1487 &rtlpriv->works.watchdog_wq, 0);
1489 mod_timer(&rtlpriv->works.watchdog_timer,
1490 jiffies + MSECS(RTL_WATCH_DOG_TIME));
1492 void rtl92e_fwevt_wq_callback(void *data)
1494 struct rtl_works *rtlworks =
1495 container_of_dwork_rtl(data, struct rtl_works, fwevt_wq);
1496 struct ieee80211_hw *hw = rtlworks->hw;
1497 struct rtl_priv *rtlpriv = rtl_priv(hw);
1499 rtlpriv->cfg->ops->c2h_command_handle(hw);
1501 void rtl92e_easy_concurrent_retrytimer_callback(unsigned long data)
1503 struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
1504 struct rtl_priv *rtlpriv = rtl_priv(hw);
1505 struct rtl_priv *buddy_priv = rtlpriv->buddy_priv;
1507 if (buddy_priv == NULL)
1510 rtlpriv->cfg->ops->dualmac_easy_concurrent(hw);
1512 /*********************************************************
1514 * frame process functions
1516 *********************************************************/
1517 u8 *rtl92e_find_ie(u8 *data, unsigned int len, u8 ie)
1519 struct ieee80211_mgmt *mgmt = (void *)data;
1522 pos = (u8 *)mgmt->u.beacon.variable;
1525 if (pos + 2 + pos[1] > end)
1536 /* when we use 2 rx ants we send IEEE80211_SMPS_OFF */
1537 /* when we use 1 rx ant we send IEEE80211_SMPS_STATIC */
1538 static struct sk_buff *rtl_make_smps_action(struct ieee80211_hw *hw,
1539 enum ieee80211_smps_mode smps,
1542 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1543 struct sk_buff *skb;
1544 struct ieee80211_mgmt_compat *action_frame;
1546 /* 27 = header + category + action + smps mode */
1547 skb = dev_alloc_skb(27 + hw->extra_tx_headroom);
1551 skb_reserve(skb, hw->extra_tx_headroom);
1552 action_frame = (void *)skb_put(skb, 27);
1553 memset(action_frame, 0, 27);
1554 ether_addr_copy(action_frame->da, da);
1555 ether_addr_copy(action_frame->sa, rtlefuse->dev_addr);
1556 ether_addr_copy(action_frame->bssid, bssid);
1557 action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1558 IEEE80211_STYPE_ACTION);
1559 action_frame->u.action.category = WLAN_CATEGORY_HT;
1560 action_frame->u.action.u.ht_smps.action = WLAN_HT_ACTION_SMPS;
1562 case IEEE80211_SMPS_AUTOMATIC:/* 0 */
1563 case IEEE80211_SMPS_NUM_MODES:/* 4 */
1565 /* Here will get a 'MISSING_BREAK' in Coverity Test, just ignore it.
1566 * According to Kernel Code, here is right.
1568 case IEEE80211_SMPS_OFF:/* 1 */ /*MIMO_PS_NOLIMIT*/
1569 action_frame->u.action.u.ht_smps.smps_control =
1570 WLAN_HT_SMPS_CONTROL_DISABLED;/* 0 */
1572 case IEEE80211_SMPS_STATIC:/* 2 */ /*MIMO_PS_STATIC*/
1573 action_frame->u.action.u.ht_smps.smps_control =
1574 WLAN_HT_SMPS_CONTROL_STATIC;/* 1 */
1576 case IEEE80211_SMPS_DYNAMIC:/* 3 */ /*MIMO_PS_DYNAMIC*/
1577 action_frame->u.action.u.ht_smps.smps_control =
1578 WLAN_HT_SMPS_CONTROL_DYNAMIC;/* 3 */
1585 int stg_rtl_send_smps_action(struct ieee80211_hw *hw,
1586 struct ieee80211_sta *sta,
1587 enum ieee80211_smps_mode smps)
1589 struct rtl_priv *rtlpriv = rtl_priv(hw);
1590 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1591 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1592 struct sk_buff *skb = NULL;
1593 struct rtl_tcb_desc tcb_desc;
1594 u8 bssid[ETH_ALEN] = {0};
1596 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1598 if (rtlpriv->mac80211.act_scanning)
1604 if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON))
1607 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1610 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP)
1611 ether_addr_copy(bssid, rtlpriv->efuse.dev_addr);
1613 ether_addr_copy(bssid, rtlpriv->mac80211.bssid);
1615 skb = rtl_make_smps_action(hw, smps, sta->addr, bssid);
1616 /* this is a type = mgmt * stype = action frame */
1618 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1619 struct rtl_sta_info *sta_entry =
1620 (struct rtl_sta_info *)sta->drv_priv;
1621 sta_entry->mimo_ps = smps;
1622 /* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); */
1624 info->control.rates[0].idx = 0;
1625 info->band = hw->conf.chandef.chan->band;
1626 rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc);
1633 EXPORT_SYMBOL(stg_rtl_send_smps_action);
1635 /* because mac80211 have issues when can receive del ba
1636 * so here we just make a fake del_ba if we receive a ba_req
1637 * but rx_agg was opened to let mac80211 release some ba
1638 * related resources, so please this del_ba for tx */
1639 struct sk_buff *rtl92e_make_del_ba(struct ieee80211_hw *hw,
1640 u8 *sa, u8 *bssid, u16 tid)
1642 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1643 struct sk_buff *skb;
1644 struct ieee80211_mgmt *action_frame;
1647 /* 27 = header + category + action + smps mode */
1648 skb = dev_alloc_skb(34 + hw->extra_tx_headroom);
1652 skb_reserve(skb, hw->extra_tx_headroom);
1653 action_frame = (void *)skb_put(skb, 34);
1654 memset(action_frame, 0, 34);
1655 ether_addr_copy(action_frame->sa, sa);
1656 ether_addr_copy(action_frame->da, rtlefuse->dev_addr);
1657 ether_addr_copy(action_frame->bssid, bssid);
1658 action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1659 IEEE80211_STYPE_ACTION);
1660 action_frame->u.action.category = WLAN_CATEGORY_BACK;
1661 action_frame->u.action.u.delba.action_code = WLAN_ACTION_DELBA;
1662 params = (u16)(1 << 11); /* bit 11 initiator */
1663 params |= (u16)(tid << 12); /* bit 15:12 TID number */
1665 action_frame->u.action.u.delba.params = cpu_to_le16(params);
1666 action_frame->u.action.u.delba.reason_code =
1667 cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT);
1672 /*********************************************************
1676 *********************************************************/
1677 static bool rtl_chk_vendor_ouisub(struct ieee80211_hw *hw,
1678 struct octet_string vendor_ie)
1680 struct rtl_priv *rtlpriv = rtl_priv(hw);
1681 bool matched = false;
1682 static u8 athcap_1[] = { 0x00, 0x03, 0x7F };
1683 static u8 athcap_2[] = { 0x00, 0x13, 0x74 };
1684 static u8 broadcap_1[] = { 0x00, 0x10, 0x18 };
1685 static u8 broadcap_2[] = { 0x00, 0x0a, 0xf7 };
1686 static u8 broadcap_3[] = { 0x00, 0x05, 0xb5 };
1687 static u8 racap[] = { 0x00, 0x0c, 0x43 };
1688 static u8 ciscocap[] = { 0x00, 0x40, 0x96 };
1689 static u8 marvcap[] = { 0x00, 0x50, 0x43 };
1691 if (memcmp(vendor_ie.octet, athcap_1, 3) == 0 ||
1692 memcmp(vendor_ie.octet, athcap_2, 3) == 0) {
1693 rtlpriv->mac80211.vendor = PEER_ATH;
1695 } else if (memcmp(vendor_ie.octet, broadcap_1, 3) == 0 ||
1696 memcmp(vendor_ie.octet, broadcap_2, 3) == 0 ||
1697 memcmp(vendor_ie.octet, broadcap_3, 3) == 0) {
1698 rtlpriv->mac80211.vendor = PEER_BROAD;
1700 } else if (memcmp(vendor_ie.octet, racap, 3) == 0) {
1701 rtlpriv->mac80211.vendor = PEER_RAL;
1703 } else if (memcmp(vendor_ie.octet, ciscocap, 3) == 0) {
1704 rtlpriv->mac80211.vendor = PEER_CISCO;
1706 } else if (memcmp(vendor_ie.octet, marvcap, 3) == 0) {
1707 rtlpriv->mac80211.vendor = PEER_MARV;
1714 static bool rtl_find_221_ie(struct ieee80211_hw *hw, u8 *data, unsigned int len)
1716 struct ieee80211_mgmt *mgmt = (void *)data;
1717 struct octet_string vendor_ie;
1720 pos = (u8 *)mgmt->u.beacon.variable;
1723 if (pos[0] == 221) {
1724 vendor_ie.length = pos[1];
1725 vendor_ie.octet = &pos[2];
1726 if (rtl_chk_vendor_ouisub(hw, vendor_ie))
1730 if (pos + 2 + pos[1] > end)
1738 void rtl92e_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len)
1740 struct rtl_priv *rtlpriv = rtl_priv(hw);
1741 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1742 struct ieee80211_hdr *hdr = (void *)data;
1743 u32 vendor = PEER_UNKNOWN;
1745 static u8 ap3_1[3] = { 0x00, 0x14, 0xbf };
1746 static u8 ap3_2[3] = { 0x00, 0x1a, 0x70 };
1747 static u8 ap3_3[3] = { 0x00, 0x1d, 0x7e };
1748 static u8 ap4_1[3] = { 0x00, 0x90, 0xcc };
1749 static u8 ap4_2[3] = { 0x00, 0x0e, 0x2e };
1750 static u8 ap4_3[3] = { 0x00, 0x18, 0x02 };
1751 static u8 ap4_4[3] = { 0x00, 0x17, 0x3f };
1752 static u8 ap4_5[3] = { 0x00, 0x1c, 0xdf };
1753 static u8 ap5_1[3] = { 0x00, 0x1c, 0xf0 };
1754 static u8 ap5_2[3] = { 0x00, 0x21, 0x91 };
1755 static u8 ap5_3[3] = { 0x00, 0x24, 0x01 };
1756 static u8 ap5_4[3] = { 0x00, 0x15, 0xe9 };
1757 static u8 ap5_5[3] = { 0x00, 0x17, 0x9A };
1758 static u8 ap5_6[3] = { 0x00, 0x18, 0xE7 };
1759 static u8 ap6_1[3] = { 0x00, 0x17, 0x94 };
1760 static u8 ap7_1[3] = { 0x00, 0x14, 0xa4 };
1762 if (mac->opmode != NL80211_IFTYPE_STATION)
1765 if (mac->link_state == MAC80211_NOLINK) {
1766 mac->vendor = PEER_UNKNOWN;
1770 if (mac->cnt_after_linked > 2)
1773 /* check if this really is a beacon */
1774 if (!ieee80211_is_beacon(hdr->frame_control))
1777 /* min. beacon length + FCS_LEN */
1778 if (len <= 40 + FCS_LEN)
1781 /* and only beacons from the associated BSSID, please */
1782 if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid))
1785 if (rtl_find_221_ie(hw, data, len))
1786 vendor = mac->vendor;
1788 if ((memcmp(mac->bssid, ap5_1, 3) == 0) ||
1789 (memcmp(mac->bssid, ap5_2, 3) == 0) ||
1790 (memcmp(mac->bssid, ap5_3, 3) == 0) ||
1791 (memcmp(mac->bssid, ap5_4, 3) == 0) ||
1792 (memcmp(mac->bssid, ap5_5, 3) == 0) ||
1793 (memcmp(mac->bssid, ap5_6, 3) == 0) ||
1794 vendor == PEER_ATH) {
1796 RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>ath find\n"));
1797 } else if ((memcmp(mac->bssid, ap4_4, 3) == 0) ||
1798 (memcmp(mac->bssid, ap4_5, 3) == 0) ||
1799 (memcmp(mac->bssid, ap4_1, 3) == 0) ||
1800 (memcmp(mac->bssid, ap4_2, 3) == 0) ||
1801 (memcmp(mac->bssid, ap4_3, 3) == 0) ||
1802 vendor == PEER_RAL) {
1803 RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>ral findn\n"));
1805 } else if (memcmp(mac->bssid, ap6_1, 3) == 0 ||
1806 vendor == PEER_CISCO) {
1807 vendor = PEER_CISCO;
1808 RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>cisco find\n"));
1809 } else if ((memcmp(mac->bssid, ap3_1, 3) == 0) ||
1810 (memcmp(mac->bssid, ap3_2, 3) == 0) ||
1811 (memcmp(mac->bssid, ap3_3, 3) == 0) ||
1812 vendor == PEER_BROAD) {
1813 RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>broad find\n"));
1814 vendor = PEER_BROAD;
1815 } else if (memcmp(mac->bssid, ap7_1, 3) == 0 ||
1816 vendor == PEER_MARV) {
1818 RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>marv find\n"));
1821 mac->vendor = vendor;
1824 /*********************************************************
1828 *********************************************************/
1829 struct rtl_global_var global_var = {};
1831 int rtl_core_module_init(void)
1833 static int here_once;
1838 if (rtl92e_rate_control_register())
1839 pr_debug("rtl: Unable to register rtl_rc, use default RC !!\n");
1841 /* init some global vars */
1842 INIT_LIST_HEAD(&global_var.glb_priv_list);
1843 spin_lock_init(&global_var.glb_list_lock);
1847 void rtl_core_module_exit(void)
1850 rtl92e_rate_control_unregister();