aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtlwifi/base.c
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2013-03-24 23:06:33 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-04-01 16:17:06 -0400
commit26634c4b1868323f49f8cd24c3493b57819867fd (patch)
tree281409ae1cc5c43951ea74761065a427a5a3ea84 /drivers/net/wireless/rtlwifi/base.c
parentcbafb601cad81de612013fad8daf710ca900015a (diff)
rtlwifi Modify existing bits to match vendor version 2013.02.07
These changes add the new variables for P2P and modify the various struct definitions for other new features. This patch updates files base.{c,h} for the changes in the newest vendor driver. This patch updates files ps.{c,h} for the changes in the newest vendor driver. This patch updates files debug.{c,h}, efuse.c, pci.{c,h}, and wifi.h for the changes in the newest vendor driver. This patch updates files core.c, ps.c, rc.c, and wifi.h for the changes in the newest vendor driver. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Cc: jcheung@suse.com Cc: machen@suse.com Cc: mmarek@suse.cz Cc: zhiyuan_yang@realsil.com.cn Cc: page_he@realsil.com.cn Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rtlwifi/base.c')
-rw-r--r--drivers/net/wireless/rtlwifi/base.c361
1 files changed, 318 insertions, 43 deletions
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 99c5cea3fe21..270b27a06905 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -54,7 +54,8 @@
54 *5) frame process functions 54 *5) frame process functions
55 *6) IOT functions 55 *6) IOT functions
56 *7) sysfs functions 56 *7) sysfs functions
57 *8) ... 57 *8) vif functions
58 *9) ...
58 */ 59 */
59 60
60/********************************************************* 61/*********************************************************
@@ -198,34 +199,46 @@ static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
198 199
199 ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; 200 ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
200 201
201 /* 202 /*hw->wiphy->bands[IEEE80211_BAND_2GHZ]
202 *hw->wiphy->bands[IEEE80211_BAND_2GHZ]
203 *base on ant_num 203 *base on ant_num
204 *rx_mask: RX mask 204 *rx_mask: RX mask
205 *if rx_ant =1 rx_mask[0]=0xff;==>MCS0-MCS7 205 *if rx_ant = 1 rx_mask[0]= 0xff;==>MCS0-MCS7
206 *if rx_ant =2 rx_mask[1]=0xff;==>MCS8-MCS15 206 *if rx_ant = 2 rx_mask[1]= 0xff;==>MCS8-MCS15
207 *if rx_ant >=3 rx_mask[2]=0xff; 207 *if rx_ant >= 3 rx_mask[2]= 0xff;
208 *if BW_40 rx_mask[4]=0x01; 208 *if BW_40 rx_mask[4]= 0x01;
209 *highest supported RX rate 209 *highest supported RX rate
210 */ 210 */
211 if (get_rf_type(rtlphy) == RF_1T2R || get_rf_type(rtlphy) == RF_2T2R) { 211 if (rtlpriv->dm.supp_phymode_switch) {
212 212
213 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T2R or 2T2R\n"); 213 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
214 "Support phy mode switch\n");
214 215
215 ht_cap->mcs.rx_mask[0] = 0xFF; 216 ht_cap->mcs.rx_mask[0] = 0xFF;
216 ht_cap->mcs.rx_mask[1] = 0xFF; 217 ht_cap->mcs.rx_mask[1] = 0xFF;
217 ht_cap->mcs.rx_mask[4] = 0x01; 218 ht_cap->mcs.rx_mask[4] = 0x01;
218 219
219 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); 220 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
220 } else if (get_rf_type(rtlphy) == RF_1T1R) { 221 } else {
221 222 if (get_rf_type(rtlphy) == RF_1T2R ||
222 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T1R\n"); 223 get_rf_type(rtlphy) == RF_2T2R) {
223 224 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
224 ht_cap->mcs.rx_mask[0] = 0xFF; 225 "1T2R or 2T2R\n");
225 ht_cap->mcs.rx_mask[1] = 0x00; 226 ht_cap->mcs.rx_mask[0] = 0xFF;
226 ht_cap->mcs.rx_mask[4] = 0x01; 227 ht_cap->mcs.rx_mask[1] = 0xFF;
227 228 ht_cap->mcs.rx_mask[4] = 0x01;
228 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7); 229
230 ht_cap->mcs.rx_highest =
231 cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
232 } else if (get_rf_type(rtlphy) == RF_1T1R) {
233 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T1R\n");
234
235 ht_cap->mcs.rx_mask[0] = 0xFF;
236 ht_cap->mcs.rx_mask[1] = 0x00;
237 ht_cap->mcs.rx_mask[4] = 0x01;
238
239 ht_cap->mcs.rx_highest =
240 cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7);
241 }
229 } 242 }
230} 243}
231 244
@@ -311,6 +324,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
311 IEEE80211_HW_AMPDU_AGGREGATION | 324 IEEE80211_HW_AMPDU_AGGREGATION |
312 IEEE80211_HW_CONNECTION_MONITOR | 325 IEEE80211_HW_CONNECTION_MONITOR |
313 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */ 326 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
327 IEEE80211_HW_CONNECTION_MONITOR |
328 IEEE80211_HW_MFP_CAPABLE |
314 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 0; 329 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 0;
315 330
316 /* swlps or hwlps has been set in diff chip in init_sw_vars */ 331 /* swlps or hwlps has been set in diff chip in init_sw_vars */
@@ -323,8 +338,12 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
323 hw->wiphy->interface_modes = 338 hw->wiphy->interface_modes =
324 BIT(NL80211_IFTYPE_AP) | 339 BIT(NL80211_IFTYPE_AP) |
325 BIT(NL80211_IFTYPE_STATION) | 340 BIT(NL80211_IFTYPE_STATION) |
326 BIT(NL80211_IFTYPE_ADHOC); 341 BIT(NL80211_IFTYPE_ADHOC) |
342 BIT(NL80211_IFTYPE_MESH_POINT) |
343 BIT(NL80211_IFTYPE_P2P_CLIENT) |
344 BIT(NL80211_IFTYPE_P2P_GO);
327 345
346 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
328 hw->wiphy->rts_threshold = 2347; 347 hw->wiphy->rts_threshold = 2347;
329 348
330 hw->queues = AC_MAX; 349 hw->queues = AC_MAX;
@@ -354,9 +373,10 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
354 struct rtl_priv *rtlpriv = rtl_priv(hw); 373 struct rtl_priv *rtlpriv = rtl_priv(hw);
355 374
356 /* <1> timer */ 375 /* <1> timer */
357 init_timer(&rtlpriv->works.watchdog_timer);
358 setup_timer(&rtlpriv->works.watchdog_timer, 376 setup_timer(&rtlpriv->works.watchdog_timer,
359 rtl_watch_dog_timer_callback, (unsigned long)hw); 377 rtl_watch_dog_timer_callback, (unsigned long)hw);
378 setup_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer,
379 rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw);
360 380
361 /* <2> work queue */ 381 /* <2> work queue */
362 rtlpriv->works.hw = hw; 382 rtlpriv->works.hw = hw;
@@ -369,6 +389,8 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
369 (void *)rtl_swlps_wq_callback); 389 (void *)rtl_swlps_wq_callback);
370 INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq, 390 INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq,
371 (void *)rtl_swlps_rfon_wq_callback); 391 (void *)rtl_swlps_rfon_wq_callback);
392 INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq,
393 (void *)rtl_fwevt_wq_callback);
372 394
373} 395}
374 396
@@ -382,6 +404,7 @@ void rtl_deinit_deferred_work(struct ieee80211_hw *hw)
382 cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq); 404 cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq);
383 cancel_delayed_work(&rtlpriv->works.ps_work); 405 cancel_delayed_work(&rtlpriv->works.ps_work);
384 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); 406 cancel_delayed_work(&rtlpriv->works.ps_rfon_wq);
407 cancel_delayed_work(&rtlpriv->works.fwevt_wq);
385} 408}
386 409
387void rtl_init_rfkill(struct ieee80211_hw *hw) 410void rtl_init_rfkill(struct ieee80211_hw *hw)
@@ -436,12 +459,6 @@ int rtl_init_core(struct ieee80211_hw *hw)
436 if (rtl_regd_init(hw, rtl_reg_notifier)) { 459 if (rtl_regd_init(hw, rtl_reg_notifier)) {
437 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "REGD init failed\n"); 460 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "REGD init failed\n");
438 return 1; 461 return 1;
439 } else {
440 /* CRDA regd hint must after init CRDA */
441 if (regulatory_hint(hw->wiphy, rtlpriv->regd.alpha2)) {
442 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
443 "regulatory_hint fail\n");
444 }
445 } 462 }
446 463
447 /* <4> locks */ 464 /* <4> locks */
@@ -449,15 +466,24 @@ int rtl_init_core(struct ieee80211_hw *hw)
449 mutex_init(&rtlpriv->locks.ps_mutex); 466 mutex_init(&rtlpriv->locks.ps_mutex);
450 spin_lock_init(&rtlpriv->locks.ips_lock); 467 spin_lock_init(&rtlpriv->locks.ips_lock);
451 spin_lock_init(&rtlpriv->locks.irq_th_lock); 468 spin_lock_init(&rtlpriv->locks.irq_th_lock);
469 spin_lock_init(&rtlpriv->locks.irq_pci_lock);
470 spin_lock_init(&rtlpriv->locks.tx_lock);
452 spin_lock_init(&rtlpriv->locks.h2c_lock); 471 spin_lock_init(&rtlpriv->locks.h2c_lock);
453 spin_lock_init(&rtlpriv->locks.rf_ps_lock); 472 spin_lock_init(&rtlpriv->locks.rf_ps_lock);
454 spin_lock_init(&rtlpriv->locks.rf_lock); 473 spin_lock_init(&rtlpriv->locks.rf_lock);
455 spin_lock_init(&rtlpriv->locks.waitq_lock); 474 spin_lock_init(&rtlpriv->locks.waitq_lock);
475 spin_lock_init(&rtlpriv->locks.entry_list_lock);
456 spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock); 476 spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock);
477 spin_lock_init(&rtlpriv->locks.check_sendpkt_lock);
478 spin_lock_init(&rtlpriv->locks.fw_ps_lock);
479 spin_lock_init(&rtlpriv->locks.lps_lock);
480
481 /* <5> init list */
482 INIT_LIST_HEAD(&rtlpriv->entry_list);
457 483
458 rtlmac->link_state = MAC80211_NOLINK; 484 rtlmac->link_state = MAC80211_NOLINK;
459 485
460 /* <5> init deferred work */ 486 /* <6> init deferred work */
461 _rtl_init_deferred_work(hw); 487 _rtl_init_deferred_work(hw);
462 488
463 return 0; 489 return 0;
@@ -523,7 +549,8 @@ static void _rtl_query_shortgi(struct ieee80211_hw *hw,
523 if (mac->opmode == NL80211_IFTYPE_STATION) 549 if (mac->opmode == NL80211_IFTYPE_STATION)
524 bw_40 = mac->bw_40; 550 bw_40 = mac->bw_40;
525 else if (mac->opmode == NL80211_IFTYPE_AP || 551 else if (mac->opmode == NL80211_IFTYPE_AP ||
526 mac->opmode == NL80211_IFTYPE_ADHOC) 552 mac->opmode == NL80211_IFTYPE_ADHOC ||
553 mac->opmode == NL80211_IFTYPE_MESH_POINT)
527 bw_40 = sta->bandwidth >= IEEE80211_STA_RX_BW_40; 554 bw_40 = sta->bandwidth >= IEEE80211_STA_RX_BW_40;
528 555
529 if (bw_40 && sgi_40) 556 if (bw_40 && sgi_40)
@@ -578,23 +605,26 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw,
578 if (!tcb_desc->disable_ratefallback || !tcb_desc->use_driver_rate) { 605 if (!tcb_desc->disable_ratefallback || !tcb_desc->use_driver_rate) {
579 if (mac->opmode == NL80211_IFTYPE_STATION) { 606 if (mac->opmode == NL80211_IFTYPE_STATION) {
580 tcb_desc->ratr_index = 0; 607 tcb_desc->ratr_index = 0;
581 } else if (mac->opmode == NL80211_IFTYPE_ADHOC) { 608 } else if (mac->opmode == NL80211_IFTYPE_ADHOC ||
609 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
582 if (tcb_desc->multicast || tcb_desc->broadcast) { 610 if (tcb_desc->multicast || tcb_desc->broadcast) {
583 tcb_desc->hw_rate = 611 tcb_desc->hw_rate =
584 rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M]; 612 rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M];
585 tcb_desc->use_driver_rate = 1; 613 tcb_desc->use_driver_rate = 1;
614 tcb_desc->ratr_index = RATR_INX_WIRELESS_MC;
586 } else { 615 } else {
587 /* TODO */ 616 tcb_desc->ratr_index = ratr_index;
588 } 617 }
589 tcb_desc->ratr_index = ratr_index;
590 } else if (mac->opmode == NL80211_IFTYPE_AP) { 618 } else if (mac->opmode == NL80211_IFTYPE_AP) {
591 tcb_desc->ratr_index = ratr_index; 619 tcb_desc->ratr_index = ratr_index;
592 } 620 }
593 } 621 }
594 622
595 if (rtlpriv->dm.useramask) { 623 if (rtlpriv->dm.useramask) {
596 /* TODO we will differentiate adhoc and station futrue */ 624 tcb_desc->ratr_index = ratr_index;
597 if (mac->opmode == NL80211_IFTYPE_STATION) { 625 /* TODO we will differentiate adhoc and station future */
626 if (mac->opmode == NL80211_IFTYPE_STATION ||
627 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
598 tcb_desc->mac_id = 0; 628 tcb_desc->mac_id = 0;
599 629
600 if (mac->mode == WIRELESS_MODE_N_24G) 630 if (mac->mode == WIRELESS_MODE_N_24G)
@@ -608,7 +638,7 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw,
608 else if (mac->mode & WIRELESS_MODE_A) 638 else if (mac->mode & WIRELESS_MODE_A)
609 tcb_desc->ratr_index = RATR_INX_WIRELESS_G; 639 tcb_desc->ratr_index = RATR_INX_WIRELESS_G;
610 } else if (mac->opmode == NL80211_IFTYPE_AP || 640 } else if (mac->opmode == NL80211_IFTYPE_AP ||
611 mac->opmode == NL80211_IFTYPE_ADHOC) { 641 mac->opmode == NL80211_IFTYPE_ADHOC) {
612 if (NULL != sta) { 642 if (NULL != sta) {
613 if (sta->aid > 0) 643 if (sta->aid > 0)
614 tcb_desc->mac_id = sta->aid + 1; 644 tcb_desc->mac_id = sta->aid + 1;
@@ -619,7 +649,6 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw,
619 } 649 }
620 } 650 }
621 } 651 }
622
623} 652}
624 653
625static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw, 654static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw,
@@ -633,7 +662,8 @@ static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw,
633 if (!sta) 662 if (!sta)
634 return; 663 return;
635 if (mac->opmode == NL80211_IFTYPE_AP || 664 if (mac->opmode == NL80211_IFTYPE_AP ||
636 mac->opmode == NL80211_IFTYPE_ADHOC) { 665 mac->opmode == NL80211_IFTYPE_ADHOC ||
666 mac->opmode == NL80211_IFTYPE_MESH_POINT) {
637 if (sta->bandwidth == IEEE80211_STA_RX_BW_20) 667 if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
638 return; 668 return;
639 } else if (mac->opmode == NL80211_IFTYPE_STATION) { 669 } else if (mac->opmode == NL80211_IFTYPE_STATION) {
@@ -834,8 +864,8 @@ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb)
834 if (rtlpriv->dm.supp_phymode_switch && 864 if (rtlpriv->dm.supp_phymode_switch &&
835 mac->link_state < MAC80211_LINKED && 865 mac->link_state < MAC80211_LINKED &&
836 (ieee80211_is_auth(fc) || ieee80211_is_probe_req(fc))) { 866 (ieee80211_is_auth(fc) || ieee80211_is_probe_req(fc))) {
837 if (rtlpriv->cfg->ops->check_switch_to_dmdp) 867 if (rtlpriv->cfg->ops->chk_switch_dmdp)
838 rtlpriv->cfg->ops->check_switch_to_dmdp(hw); 868 rtlpriv->cfg->ops->chk_switch_dmdp(hw);
839 } 869 }
840 if (ieee80211_is_auth(fc)) { 870 if (ieee80211_is_auth(fc)) {
841 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n"); 871 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
@@ -924,6 +954,56 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
924} 954}
925EXPORT_SYMBOL(rtl_get_tcb_desc); 955EXPORT_SYMBOL(rtl_get_tcb_desc);
926 956
957static bool addbareq_rx(struct ieee80211_hw *hw, struct sk_buff *skb)
958{
959 struct rtl_priv *rtlpriv = rtl_priv(hw);
960 struct ieee80211_sta *sta = NULL;
961 struct ieee80211_hdr *hdr = rtl_get_hdr(skb);
962 struct rtl_sta_info *sta_entry = NULL;
963 struct ieee80211_mgmt *mgmt = (void *)skb->data;
964 u16 capab = 0, tid = 0;
965 struct rtl_tid_data *tid_data;
966 struct sk_buff *skb_delba = NULL;
967 struct ieee80211_rx_status rx_status = { 0 };
968
969 rcu_read_lock();
970 sta = rtl_find_sta(hw, hdr->addr3);
971 if (sta == NULL) {
972 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_EMERG,
973 "sta is NULL\n");
974 rcu_read_unlock();
975 return true;
976 }
977
978 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
979 if (!sta_entry) {
980 rcu_read_unlock();
981 return true;
982 }
983 capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab);
984 tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
985 tid_data = &sta_entry->tids[tid];
986 if (tid_data->agg.rx_agg_state == RTL_RX_AGG_START) {
987 skb_delba = rtl_make_del_ba(hw, hdr->addr2, hdr->addr3, tid);
988 if (skb_delba) {
989 rx_status.freq = hw->conf.channel->center_freq;
990 rx_status.band = hw->conf.channel->band;
991 rx_status.flag |= RX_FLAG_DECRYPTED;
992 rx_status.flag |= RX_FLAG_MACTIME_END;
993 rx_status.rate_idx = 0;
994 rx_status.signal = 50 + 10;
995 memcpy(IEEE80211_SKB_RXCB(skb_delba), &rx_status,
996 sizeof(rx_status));
997 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG,
998 "fake del\n", skb_delba->data,
999 skb_delba->len);
1000 ieee80211_rx_irqsafe(hw, skb_delba);
1001 }
1002 }
1003 rcu_read_unlock();
1004 return false;
1005}
1006
927bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) 1007bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
928{ 1008{
929 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1009 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -948,6 +1028,11 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
948 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 1028 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
949 "%s ACT_ADDBAREQ From :%pM\n", 1029 "%s ACT_ADDBAREQ From :%pM\n",
950 is_tx ? "Tx" : "Rx", hdr->addr2); 1030 is_tx ? "Tx" : "Rx", hdr->addr2);
1031 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "req\n",
1032 skb->data, skb->len);
1033 if (!is_tx)
1034 if (addbareq_rx(hw, skb))
1035 return true;
951 break; 1036 break;
952 case ACT_ADDBARSP: 1037 case ACT_ADDBARSP:
953 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 1038 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
@@ -1101,6 +1186,58 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw,
1101 return 0; 1186 return 0;
1102} 1187}
1103 1188
1189int rtl_rx_agg_start(struct ieee80211_hw *hw,
1190 struct ieee80211_sta *sta, u16 tid)
1191{
1192 struct rtl_priv *rtlpriv = rtl_priv(hw);
1193 struct rtl_tid_data *tid_data;
1194 struct rtl_sta_info *sta_entry = NULL;
1195
1196 if (sta == NULL)
1197 return -EINVAL;
1198
1199 if (unlikely(tid >= MAX_TID_COUNT))
1200 return -EINVAL;
1201
1202 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1203 if (!sta_entry)
1204 return -ENXIO;
1205 tid_data = &sta_entry->tids[tid];
1206
1207 RT_TRACE(rtlpriv, COMP_RECV, DBG_DMESG,
1208 "on ra = %pM tid = %d seq:%d\n", sta->addr, tid,
1209 tid_data->seq_number);
1210
1211 tid_data->agg.rx_agg_state = RTL_RX_AGG_START;
1212 return 0;
1213}
1214
1215int rtl_rx_agg_stop(struct ieee80211_hw *hw,
1216 struct ieee80211_sta *sta, u16 tid)
1217{
1218 struct rtl_priv *rtlpriv = rtl_priv(hw);
1219 struct rtl_sta_info *sta_entry = NULL;
1220
1221 if (sta == NULL)
1222 return -EINVAL;
1223
1224 if (!sta->addr) {
1225 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "ra = NULL\n");
1226 return -EINVAL;
1227 }
1228
1229 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG,
1230 "on ra = %pM tid = %d\n", sta->addr, tid);
1231
1232 if (unlikely(tid >= MAX_TID_COUNT))
1233 return -EINVAL;
1234
1235 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1236 sta_entry->tids[tid].agg.rx_agg_state = RTL_RX_AGG_STOP;
1237
1238 return 0;
1239}
1240
1104int rtl_tx_agg_oper(struct ieee80211_hw *hw, 1241int rtl_tx_agg_oper(struct ieee80211_hw *hw,
1105 struct ieee80211_sta *sta, u16 tid) 1242 struct ieee80211_sta *sta, u16 tid)
1106{ 1243{
@@ -1132,6 +1269,34 @@ int rtl_tx_agg_oper(struct ieee80211_hw *hw,
1132 * wq & timer callback functions 1269 * wq & timer callback functions
1133 * 1270 *
1134 *********************************************************/ 1271 *********************************************************/
1272/* this function is used for roaming */
1273void rtl_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb)
1274{
1275 struct rtl_priv *rtlpriv = rtl_priv(hw);
1276 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1277
1278 if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
1279 return;
1280
1281 if (rtlpriv->mac80211.link_state < MAC80211_LINKED)
1282 return;
1283
1284 /* check if this really is a beacon */
1285 if (!ieee80211_is_beacon(hdr->frame_control) &&
1286 !ieee80211_is_probe_resp(hdr->frame_control))
1287 return;
1288
1289 /* min. beacon length + FCS_LEN */
1290 if (skb->len <= 40 + FCS_LEN)
1291 return;
1292
1293 /* and only beacons from the associated BSSID, please */
1294 if (compare_ether_addr(hdr->addr3, rtlpriv->mac80211.bssid))
1295 return;
1296
1297 rtlpriv->link_info.bcn_rx_inperiod++;
1298}
1299
1135void rtl_watchdog_wq_callback(void *data) 1300void rtl_watchdog_wq_callback(void *data)
1136{ 1301{
1137 struct rtl_works *rtlworks = container_of_dwork_rtl(data, 1302 struct rtl_works *rtlworks = container_of_dwork_rtl(data,
@@ -1142,6 +1307,8 @@ void rtl_watchdog_wq_callback(void *data)
1142 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1307 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1143 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1308 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1144 bool busytraffic = false; 1309 bool busytraffic = false;
1310 bool tx_busy_traffic = false;
1311 bool rx_busy_traffic = false;
1145 bool higher_busytraffic = false; 1312 bool higher_busytraffic = false;
1146 bool higher_busyrxtraffic = false; 1313 bool higher_busyrxtraffic = false;
1147 u8 idx, tid; 1314 u8 idx, tid;
@@ -1191,8 +1358,13 @@ void rtl_watchdog_wq_callback(void *data)
1191 aver_tx_cnt_inperiod = tx_cnt_inp4eriod / 4; 1358 aver_tx_cnt_inperiod = tx_cnt_inp4eriod / 4;
1192 1359
1193 /* (2) check traffic busy */ 1360 /* (2) check traffic busy */
1194 if (aver_rx_cnt_inperiod > 100 || aver_tx_cnt_inperiod > 100) 1361 if (aver_rx_cnt_inperiod > 100 || aver_tx_cnt_inperiod > 100) {
1195 busytraffic = true; 1362 busytraffic = true;
1363 if (aver_rx_cnt_inperiod > aver_tx_cnt_inperiod)
1364 rx_busy_traffic = true;
1365 else
1366 tx_busy_traffic = false;
1367 }
1196 1368
1197 /* Higher Tx/Rx data. */ 1369 /* Higher Tx/Rx data. */
1198 if (aver_rx_cnt_inperiod > 4000 || 1370 if (aver_rx_cnt_inperiod > 4000 ||
@@ -1236,7 +1408,7 @@ void rtl_watchdog_wq_callback(void *data)
1236 if (enter_ps) 1408 if (enter_ps)
1237 rtl_lps_enter(hw); 1409 rtl_lps_enter(hw);
1238 else 1410 else
1239 rtl_lps_leave(hw); 1411 schedule_work(&rtlpriv->works.lps_leave_work);
1240 } 1412 }
1241 1413
1242 rtlpriv->link_info.num_rx_inperiod = 0; 1414 rtlpriv->link_info.num_rx_inperiod = 0;
@@ -1246,10 +1418,37 @@ void rtl_watchdog_wq_callback(void *data)
1246 1418
1247 rtlpriv->link_info.busytraffic = busytraffic; 1419 rtlpriv->link_info.busytraffic = busytraffic;
1248 rtlpriv->link_info.higher_busytraffic = higher_busytraffic; 1420 rtlpriv->link_info.higher_busytraffic = higher_busytraffic;
1421 rtlpriv->link_info.rx_busy_traffic = rx_busy_traffic;
1422 rtlpriv->link_info.tx_busy_traffic = tx_busy_traffic;
1249 rtlpriv->link_info.higher_busyrxtraffic = higher_busyrxtraffic; 1423 rtlpriv->link_info.higher_busyrxtraffic = higher_busyrxtraffic;
1250 1424
1251 /* <3> DM */ 1425 /* <3> DM */
1252 rtlpriv->cfg->ops->dm_watchdog(hw); 1426 rtlpriv->cfg->ops->dm_watchdog(hw);
1427
1428 /* <4> roaming */
1429 if (mac->link_state == MAC80211_LINKED &&
1430 mac->opmode == NL80211_IFTYPE_STATION) {
1431 if ((rtlpriv->link_info.bcn_rx_inperiod +
1432 rtlpriv->link_info.num_rx_inperiod) == 0) {
1433 rtlpriv->link_info.roam_times++;
1434 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
1435 "AP off for %d s\n",
1436 (rtlpriv->link_info.roam_times * 2));
1437
1438 /* if we can't recv beacon for 6s, we should
1439 * reconnect this AP
1440 */
1441 if (rtlpriv->link_info.roam_times >= 3) {
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);
1446 }
1447 } else {
1448 rtlpriv->link_info.roam_times = 0;
1449 }
1450 }
1451 rtlpriv->link_info.bcn_rx_inperiod = 0;
1253} 1452}
1254 1453
1255void rtl_watch_dog_timer_callback(unsigned long data) 1454void rtl_watch_dog_timer_callback(unsigned long data)
@@ -1264,6 +1463,28 @@ void rtl_watch_dog_timer_callback(unsigned long data)
1264 jiffies + MSECS(RTL_WATCH_DOG_TIME)); 1463 jiffies + MSECS(RTL_WATCH_DOG_TIME));
1265} 1464}
1266 1465
1466void rtl_fwevt_wq_callback(void *data)
1467{
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);
1472
1473 rtlpriv->cfg->ops->c2h_command_handle(hw);
1474}
1475
1476void rtl_easy_concurrent_retrytimer_callback(unsigned long data)
1477{
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;
1481
1482 if (buddy_priv == NULL)
1483 return;
1484
1485 rtlpriv->cfg->ops->dualmac_easy_concurrent(hw);
1486}
1487
1267/********************************************************* 1488/*********************************************************
1268 * 1489 *
1269 * frame process functions 1490 * frame process functions
@@ -1334,14 +1555,16 @@ static struct sk_buff *rtl_make_smps_action(struct ieee80211_hw *hw,
1334} 1555}
1335 1556
1336int rtl_send_smps_action(struct ieee80211_hw *hw, 1557int rtl_send_smps_action(struct ieee80211_hw *hw,
1337 struct ieee80211_sta *sta, u8 *da, u8 *bssid, 1558 struct ieee80211_sta *sta,
1338 enum ieee80211_smps_mode smps) 1559 enum ieee80211_smps_mode smps)
1339{ 1560{
1340 struct rtl_priv *rtlpriv = rtl_priv(hw); 1561 struct rtl_priv *rtlpriv = rtl_priv(hw);
1341 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1562 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1342 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 1563 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1343 struct sk_buff *skb = rtl_make_smps_action(hw, smps, da, bssid); 1564 struct sk_buff *skb = NULL;
1344 struct rtl_tcb_desc tcb_desc; 1565 struct rtl_tcb_desc tcb_desc;
1566 u8 bssid[ETH_ALEN] = {0};
1567
1345 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 1568 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1346 1569
1347 if (rtlpriv->mac80211.act_scanning) 1570 if (rtlpriv->mac80211.act_scanning)
@@ -1356,21 +1579,67 @@ int rtl_send_smps_action(struct ieee80211_hw *hw,
1356 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) 1579 if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status))
1357 goto err_free; 1580 goto err_free;
1358 1581
1582 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP)
1583 memcpy(bssid, rtlpriv->efuse.dev_addr, ETH_ALEN);
1584 else
1585 memcpy(bssid, rtlpriv->mac80211.bssid, ETH_ALEN);
1586
1587 skb = rtl_make_smps_action(hw, smps, sta->addr, bssid);
1359 /* this is a type = mgmt * stype = action frame */ 1588 /* this is a type = mgmt * stype = action frame */
1360 if (skb) { 1589 if (skb) {
1361 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1590 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1362 struct rtl_sta_info *sta_entry = 1591 struct rtl_sta_info *sta_entry =
1363 (struct rtl_sta_info *) sta->drv_priv; 1592 (struct rtl_sta_info *) sta->drv_priv;
1364 sta_entry->mimo_ps = smps; 1593 sta_entry->mimo_ps = smps;
1365 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
1366 1594
1367 info->control.rates[0].idx = 0; 1595 info->control.rates[0].idx = 0;
1368 info->band = hw->conf.channel->band; 1596 info->band = hw->conf.channel->band;
1369 rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc); 1597 rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc);
1370 } 1598 }
1599 return 1;
1600
1371err_free: 1601err_free:
1372 return 0; 1602 return 0;
1373} 1603}
1604EXPORT_SYMBOL(rtl_send_smps_action);
1605
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.
1610 */
1611struct sk_buff *rtl_make_del_ba(struct ieee80211_hw *hw,
1612 u8 *sa, u8 *bssid, u16 tid)
1613{
1614 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1615 struct sk_buff *skb;
1616 struct ieee80211_mgmt *action_frame;
1617 u16 params;
1618
1619 /* 27 = header + category + action + smps mode */
1620 skb = dev_alloc_skb(34 + hw->extra_tx_headroom);
1621 if (!skb)
1622 return NULL;
1623
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 */
1636
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);
1640
1641 return skb;
1642}
1374 1643
1375/********************************************************* 1644/*********************************************************
1376 * 1645 *
@@ -1587,11 +1856,17 @@ MODULE_AUTHOR("Larry Finger <Larry.FInger@lwfinger.net>");
1587MODULE_LICENSE("GPL"); 1856MODULE_LICENSE("GPL");
1588MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core"); 1857MODULE_DESCRIPTION("Realtek 802.11n PCI wireless core");
1589 1858
1859struct rtl_global_var global_var = {};
1860
1590static int __init rtl_core_module_init(void) 1861static int __init rtl_core_module_init(void)
1591{ 1862{
1592 if (rtl_rate_control_register()) 1863 if (rtl_rate_control_register())
1593 pr_err("Unable to register rtl_rc, use default RC !!\n"); 1864 pr_err("Unable to register rtl_rc, use default RC !!\n");
1594 1865
1866 /* init some global vars */
1867 INIT_LIST_HEAD(&global_var.glb_priv_list);
1868 spin_lock_init(&global_var.glb_list_lock);
1869
1595 return 0; 1870 return 0;
1596} 1871}
1597 1872