aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/realtek/rtlwifi
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-11-11 08:37:22 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-11 08:37:22 -0500
commit7c5556decd0a629e9ee02e93653f75ba7b7da03c (patch)
treebc56819788e9226efc04a1d1710b99fa6d4512e4 /drivers/net/wireless/realtek/rtlwifi
parent39b175211053c7a6a4d794c42e225994f1c069c2 (diff)
parentfdd0bd88ceaecf729db103ac8836af5805dd2dc1 (diff)
Merge tag 'wireless-drivers-next-for-davem-2017-11-11' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next
Kalle Valo says: ==================== wireless-drivers-next patches for 4.15 Last minute patches before the merge window. Not really anything special standing out, mostly fixes or cleanup and some minor new features. Major changes: iwlwifi * some new PCI IDs ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/realtek/rtlwifi')
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/base.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/core.c12
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.c275
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/pci.h31
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c2
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c10
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h3
-rw-r--r--drivers/net/wireless/realtek/rtlwifi/wifi.h11
21 files changed, 194 insertions, 191 deletions
diff --git a/drivers/net/wireless/realtek/rtlwifi/base.c b/drivers/net/wireless/realtek/rtlwifi/base.c
index 7e3107f9e37f..cad2272ae21b 100644
--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -1630,7 +1630,6 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1630 struct ieee80211_sta *sta, u16 tid) 1630 struct ieee80211_sta *sta, u16 tid)
1631{ 1631{
1632 struct rtl_priv *rtlpriv = rtl_priv(hw); 1632 struct rtl_priv *rtlpriv = rtl_priv(hw);
1633 struct rtl_tid_data *tid_data;
1634 struct rtl_sta_info *sta_entry = NULL; 1633 struct rtl_sta_info *sta_entry = NULL;
1635 1634
1636 if (sta == NULL) 1635 if (sta == NULL)
@@ -1643,7 +1642,6 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1643 return -EINVAL; 1642 return -EINVAL;
1644 1643
1645 sta_entry = (struct rtl_sta_info *)sta->drv_priv; 1644 sta_entry = (struct rtl_sta_info *)sta->drv_priv;
1646 tid_data = &sta_entry->tids[tid];
1647 sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP; 1645 sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP;
1648 1646
1649 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); 1647 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index 1147327e6f52..3cb88825473e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -550,15 +550,13 @@ static int rtl_op_suspend(struct ieee80211_hw *hw,
550 struct rtl_priv *rtlpriv = rtl_priv(hw); 550 struct rtl_priv *rtlpriv = rtl_priv(hw);
551 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 551 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
552 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 552 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
553 struct timeval ts;
554 553
555 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); 554 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
556 if (WARN_ON(!wow)) 555 if (WARN_ON(!wow))
557 return -EINVAL; 556 return -EINVAL;
558 557
559 /* to resolve s4 can not wake up*/ 558 /* to resolve s4 can not wake up*/
560 do_gettimeofday(&ts); 559 rtlhal->last_suspend_sec = ktime_get_real_seconds();
561 rtlhal->last_suspend_sec = ts.tv_sec;
562 560
563 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns) 561 if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns)
564 _rtl_add_wowlan_patterns(hw, wow); 562 _rtl_add_wowlan_patterns(hw, wow);
@@ -577,7 +575,7 @@ static int rtl_op_resume(struct ieee80211_hw *hw)
577 struct rtl_priv *rtlpriv = rtl_priv(hw); 575 struct rtl_priv *rtlpriv = rtl_priv(hw);
578 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 576 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
579 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 577 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
580 struct timeval ts; 578 time64_t now;
581 579
582 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n"); 580 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, "\n");
583 rtlhal->driver_is_goingto_unload = false; 581 rtlhal->driver_is_goingto_unload = false;
@@ -585,8 +583,8 @@ static int rtl_op_resume(struct ieee80211_hw *hw)
585 rtlhal->wake_from_pnp_sleep = true; 583 rtlhal->wake_from_pnp_sleep = true;
586 584
587 /* to resovle s4 can not wake up*/ 585 /* to resovle s4 can not wake up*/
588 do_gettimeofday(&ts); 586 now = ktime_get_real_seconds();
589 if (ts.tv_sec - rtlhal->last_suspend_sec < 5) 587 if (now - rtlhal->last_suspend_sec < 5)
590 return -1; 588 return -1;
591 589
592 rtl_op_start(hw); 590 rtl_op_start(hw);
@@ -1748,7 +1746,7 @@ bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version,
1748 u8 faversion, u8 interface_type, 1746 u8 faversion, u8 interface_type,
1749 struct wlan_pwr_cfg pwrcfgcmd[]) 1747 struct wlan_pwr_cfg pwrcfgcmd[])
1750{ 1748{
1751 struct wlan_pwr_cfg cfg_cmd = {0}; 1749 struct wlan_pwr_cfg cfg_cmd;
1752 bool polling_bit = false; 1750 bool polling_bit = false;
1753 u32 ary_idx = 0; 1751 u32 ary_idx = 0;
1754 u8 value = 0; 1752 u8 value = 0;
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index eb12818b46b3..c2575b0b9440 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -54,8 +54,7 @@ static const u8 ac_to_hwq[] = {
54 BK_QUEUE 54 BK_QUEUE
55}; 55};
56 56
57static u8 _rtl_mac_to_hwqueue(struct ieee80211_hw *hw, 57static u8 _rtl_mac_to_hwqueue(struct ieee80211_hw *hw, struct sk_buff *skb)
58 struct sk_buff *skb)
59{ 58{
60 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 59 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
61 __le16 fc = rtl_get_fc(skb); 60 __le16 fc = rtl_get_fc(skb);
@@ -104,20 +103,18 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
104 break; 103 break;
105 104
106 case 3: 105 case 3:
107 /* 106 /* Always enable ASPM and Clock Req
108 * Always enable ASPM and Clock Req
109 * from initialization to halt. 107 * from initialization to halt.
110 * */ 108 */
111 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM); 109 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM);
112 ppsc->reg_rfps_level |= (RT_RF_PS_LEVEL_ALWAYS_ASPM | 110 ppsc->reg_rfps_level |= (RT_RF_PS_LEVEL_ALWAYS_ASPM |
113 RT_RF_OFF_LEVL_CLK_REQ); 111 RT_RF_OFF_LEVL_CLK_REQ);
114 break; 112 break;
115 113
116 case 4: 114 case 4:
117 /* 115 /* Always enable ASPM without Clock Req
118 * Always enable ASPM without Clock Req
119 * from initialization to halt. 116 * from initialization to halt.
120 * */ 117 */
121 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM | 118 ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM |
122 RT_RF_OFF_LEVL_CLK_REQ); 119 RT_RF_OFF_LEVL_CLK_REQ);
123 ppsc->reg_rfps_level |= RT_RF_PS_LEVEL_ALWAYS_ASPM; 120 ppsc->reg_rfps_level |= RT_RF_PS_LEVEL_ALWAYS_ASPM;
@@ -146,32 +143,19 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
146 143
147 /*Set HW definition to determine if it supports ASPM. */ 144 /*Set HW definition to determine if it supports ASPM. */
148 switch (rtlpci->const_support_pciaspm) { 145 switch (rtlpci->const_support_pciaspm) {
149 case 0:{ 146 case 0:
150 /*Not support ASPM. */ 147 /*Not support ASPM. */
151 bool support_aspm = false; 148 ppsc->support_aspm = false;
152 ppsc->support_aspm = support_aspm; 149 break;
153 break; 150 case 1:
154 } 151 /*Support ASPM. */
155 case 1:{ 152 ppsc->support_aspm = true;
156 /*Support ASPM. */ 153 ppsc->support_backdoor = true;
157 bool support_aspm = true; 154 break;
158 bool support_backdoor = true;
159 ppsc->support_aspm = support_aspm;
160
161 /*if (priv->oem_id == RT_CID_TOSHIBA &&
162 !priv->ndis_adapter.amd_l1_patch)
163 support_backdoor = false; */
164
165 ppsc->support_backdoor = support_backdoor;
166
167 break;
168 }
169 case 2: 155 case 2:
170 /*ASPM value set by chipset. */ 156 /*ASPM value set by chipset. */
171 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) { 157 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL)
172 bool support_aspm = true; 158 ppsc->support_aspm = true;
173 ppsc->support_aspm = support_aspm;
174 }
175 break; 159 break;
176 default: 160 default:
177 pr_err("switch case %#x not processed\n", 161 pr_err("switch case %#x not processed\n",
@@ -180,10 +164,11 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
180 } 164 }
181 165
182 /* toshiba aspm issue, toshiba will set aspm selfly 166 /* toshiba aspm issue, toshiba will set aspm selfly
183 * so we should not set aspm in driver */ 167 * so we should not set aspm in driver
168 */
184 pci_read_config_byte(rtlpci->pdev, 0x80, &init_aspm); 169 pci_read_config_byte(rtlpci->pdev, 0x80, &init_aspm);
185 if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8192SE && 170 if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8192SE &&
186 init_aspm == 0x43) 171 init_aspm == 0x43)
187 ppsc->support_aspm = false; 172 ppsc->support_aspm = false;
188} 173}
189 174
@@ -263,8 +248,7 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw)
263 udelay(50); 248 udelay(50);
264} 249}
265 250
266/* 251/*Enable RTL8192SE ASPM & Enable Pci Bridge ASPM for
267 *Enable RTL8192SE ASPM & Enable Pci Bridge ASPM for
268 *power saving We should follow the sequence to enable 252 *power saving We should follow the sequence to enable
269 *RTL8192SE first then enable Pci Bridge ASPM 253 *RTL8192SE first then enable Pci Bridge ASPM
270 *or the system will show bluescreen. 254 *or the system will show bluescreen.
@@ -334,7 +318,7 @@ static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw)
334 318
335 bool status = false; 319 bool status = false;
336 u8 offset_e0; 320 u8 offset_e0;
337 unsigned offset_e4; 321 unsigned int offset_e4;
338 322
339 pci_write_config_byte(rtlpci->pdev, 0xe0, 0xa0); 323 pci_write_config_byte(rtlpci->pdev, 0xe0, 0xa0);
340 324
@@ -369,12 +353,12 @@ static bool rtl_pci_check_buddy_priv(struct ieee80211_hw *hw,
369 "tpcipriv->ndis_adapter.funcnumber %x\n", 353 "tpcipriv->ndis_adapter.funcnumber %x\n",
370 tpcipriv->ndis_adapter.funcnumber); 354 tpcipriv->ndis_adapter.funcnumber);
371 355
372 if ((pcipriv->ndis_adapter.busnumber == 356 if (pcipriv->ndis_adapter.busnumber ==
373 tpcipriv->ndis_adapter.busnumber) && 357 tpcipriv->ndis_adapter.busnumber &&
374 (pcipriv->ndis_adapter.devnumber == 358 pcipriv->ndis_adapter.devnumber ==
375 tpcipriv->ndis_adapter.devnumber) && 359 tpcipriv->ndis_adapter.devnumber &&
376 (pcipriv->ndis_adapter.funcnumber != 360 pcipriv->ndis_adapter.funcnumber !=
377 tpcipriv->ndis_adapter.funcnumber)) { 361 tpcipriv->ndis_adapter.funcnumber) {
378 find_buddy_priv = true; 362 find_buddy_priv = true;
379 break; 363 break;
380 } 364 }
@@ -407,7 +391,7 @@ static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw)
407} 391}
408 392
409static void rtl_pci_parse_configuration(struct pci_dev *pdev, 393static void rtl_pci_parse_configuration(struct pci_dev *pdev,
410 struct ieee80211_hw *hw) 394 struct ieee80211_hw *hw)
411{ 395{
412 struct rtl_priv *rtlpriv = rtl_priv(hw); 396 struct rtl_priv *rtlpriv = rtl_priv(hw);
413 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 397 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
@@ -441,7 +425,6 @@ static void rtl_pci_init_aspm(struct ieee80211_hw *hw)
441 rtl_pci_enable_aspm(hw); 425 rtl_pci_enable_aspm(hw);
442 RT_SET_PS_LEVEL(ppsc, RT_RF_PS_LEVEL_ALWAYS_ASPM); 426 RT_SET_PS_LEVEL(ppsc, RT_RF_PS_LEVEL_ALWAYS_ASPM);
443 } 427 }
444
445} 428}
446 429
447static void _rtl_pci_io_handler_init(struct device *dev, 430static void _rtl_pci_io_handler_init(struct device *dev,
@@ -458,11 +441,11 @@ static void _rtl_pci_io_handler_init(struct device *dev,
458 rtlpriv->io.read8_sync = pci_read8_sync; 441 rtlpriv->io.read8_sync = pci_read8_sync;
459 rtlpriv->io.read16_sync = pci_read16_sync; 442 rtlpriv->io.read16_sync = pci_read16_sync;
460 rtlpriv->io.read32_sync = pci_read32_sync; 443 rtlpriv->io.read32_sync = pci_read32_sync;
461
462} 444}
463 445
464static bool _rtl_update_earlymode_info(struct ieee80211_hw *hw, 446static bool _rtl_update_earlymode_info(struct ieee80211_hw *hw,
465 struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc, u8 tid) 447 struct sk_buff *skb,
448 struct rtl_tcb_desc *tcb_desc, u8 tid)
466{ 449{
467 struct rtl_priv *rtlpriv = rtl_priv(hw); 450 struct rtl_priv *rtlpriv = rtl_priv(hw);
468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 451 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -520,13 +503,15 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
520 (rtlpriv->buddy_priv && 503 (rtlpriv->buddy_priv &&
521 rtlpriv->buddy_priv->easy_concurrent_ctl.switch_in_process))) 504 rtlpriv->buddy_priv->easy_concurrent_ctl.switch_in_process)))
522 return; 505 return;
523 /* we juse use em for BE/BK/VI/VO */ 506 /* we just use em for BE/BK/VI/VO */
524 for (tid = 7; tid >= 0; tid--) { 507 for (tid = 7; tid >= 0; tid--) {
525 u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(tid)]; 508 u8 hw_queue = ac_to_hwq[rtl_tid_to_ac(tid)];
526 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; 509 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
510
527 while (!mac->act_scanning && 511 while (!mac->act_scanning &&
528 rtlpriv->psc.rfpwr_state == ERFON) { 512 rtlpriv->psc.rfpwr_state == ERFON) {
529 struct rtl_tcb_desc tcb_desc; 513 struct rtl_tcb_desc tcb_desc;
514
530 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 515 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
531 516
532 spin_lock_bh(&rtlpriv->locks.waitq_lock); 517 spin_lock_bh(&rtlpriv->locks.waitq_lock);
@@ -541,7 +526,8 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
541 spin_unlock_bh(&rtlpriv->locks.waitq_lock); 526 spin_unlock_bh(&rtlpriv->locks.waitq_lock);
542 527
543 /* Some macaddr can't do early mode. like 528 /* Some macaddr can't do early mode. like
544 * multicast/broadcast/no_qos data */ 529 * multicast/broadcast/no_qos data
530 */
545 info = IEEE80211_SKB_CB(skb); 531 info = IEEE80211_SKB_CB(skb);
546 if (info->flags & IEEE80211_TX_CTL_AMPDU) 532 if (info->flags & IEEE80211_TX_CTL_AMPDU)
547 _rtl_update_earlymode_info(hw, skb, 533 _rtl_update_earlymode_info(hw, skb,
@@ -552,7 +538,6 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw)
552 } 538 }
553} 539}
554 540
555
556static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) 541static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
557{ 542{
558 struct rtl_priv *rtlpriv = rtl_priv(hw); 543 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -603,7 +588,6 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
603 if (prio == TXCMD_QUEUE) { 588 if (prio == TXCMD_QUEUE) {
604 dev_kfree_skb(skb); 589 dev_kfree_skb(skb);
605 goto tx_status_ok; 590 goto tx_status_ok;
606
607 } 591 }
608 592
609 /* for sw LPS, just after NULL skb send out, we can 593 /* for sw LPS, just after NULL skb send out, we can
@@ -643,15 +627,12 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
643 ieee80211_tx_status_irqsafe(hw, skb); 627 ieee80211_tx_status_irqsafe(hw, skb);
644 628
645 if ((ring->entries - skb_queue_len(&ring->queue)) <= 4) { 629 if ((ring->entries - skb_queue_len(&ring->queue)) <= 4) {
646
647 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG, 630 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
648 "more desc left, wake skb_queue@%d, ring->idx = %d, skb_queue_len = 0x%x\n", 631 "more desc left, wake skb_queue@%d, ring->idx = %d, skb_queue_len = 0x%x\n",
649 prio, ring->idx, 632 prio, ring->idx,
650 skb_queue_len(&ring->queue)); 633 skb_queue_len(&ring->queue));
651 634
652 ieee80211_wake_queue(hw, 635 ieee80211_wake_queue(hw, skb_get_queue_mapping(skb));
653 skb_get_queue_mapping
654 (skb));
655 } 636 }
656tx_status_ok: 637tx_status_ok:
657 skb = NULL; 638 skb = NULL;
@@ -659,7 +640,7 @@ tx_status_ok:
659 640
660 if (((rtlpriv->link_info.num_rx_inperiod + 641 if (((rtlpriv->link_info.num_rx_inperiod +
661 rtlpriv->link_info.num_tx_inperiod) > 8) || 642 rtlpriv->link_info.num_tx_inperiod) > 8) ||
662 (rtlpriv->link_info.num_rx_inperiod > 2)) 643 rtlpriv->link_info.num_rx_inperiod > 2)
663 rtl_lps_leave(hw); 644 rtl_lps_leave(hw);
664} 645}
665 646
@@ -817,7 +798,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
817 new_skb = dev_alloc_skb(rtlpci->rxbuffersize); 798 new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
818 if (unlikely(!new_skb)) 799 if (unlikely(!new_skb))
819 goto no_new; 800 goto no_new;
820 memset(&rx_status , 0 , sizeof(rx_status)); 801 memset(&rx_status, 0, sizeof(rx_status));
821 rtlpriv->cfg->ops->query_rx_desc(hw, &stats, 802 rtlpriv->cfg->ops->query_rx_desc(hw, &stats,
822 &rx_status, (u8 *)pdesc, skb); 803 &rx_status, (u8 *)pdesc, skb);
823 804
@@ -847,12 +828,11 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
847 /* handle command packet here */ 828 /* handle command packet here */
848 if (rtlpriv->cfg->ops->rx_command_packet && 829 if (rtlpriv->cfg->ops->rx_command_packet &&
849 rtlpriv->cfg->ops->rx_command_packet(hw, &stats, skb)) { 830 rtlpriv->cfg->ops->rx_command_packet(hw, &stats, skb)) {
850 dev_kfree_skb_any(skb); 831 dev_kfree_skb_any(skb);
851 goto new_trx_end; 832 goto new_trx_end;
852 } 833 }
853 834
854 /* 835 /* NOTICE This can not be use for mac80211,
855 * NOTICE This can not be use for mac80211,
856 * this is done in mac80211 code, 836 * this is done in mac80211 code,
857 * if done here sec DHCP will fail 837 * if done here sec DHCP will fail
858 * skb_trim(skb, skb->len - 4); 838 * skb_trim(skb, skb->len - 4);
@@ -889,9 +869,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
889 /* for sw lps */ 869 /* for sw lps */
890 rtl_swlps_beacon(hw, (void *)skb->data, skb->len); 870 rtl_swlps_beacon(hw, (void *)skb->data, skb->len);
891 rtl_recognize_peer(hw, (void *)skb->data, skb->len); 871 rtl_recognize_peer(hw, (void *)skb->data, skb->len);
892 if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && 872 if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP &&
893 (rtlpriv->rtlhal.current_bandtype == 873 rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G &&
894 BAND_ON_2_4G) &&
895 (ieee80211_is_beacon(fc) || 874 (ieee80211_is_beacon(fc) ||
896 ieee80211_is_probe_resp(fc))) { 875 ieee80211_is_probe_resp(fc))) {
897 dev_kfree_skb_any(skb); 876 dev_kfree_skb_any(skb);
@@ -913,7 +892,7 @@ new_trx_end:
913 } 892 }
914 if (((rtlpriv->link_info.num_rx_inperiod + 893 if (((rtlpriv->link_info.num_rx_inperiod +
915 rtlpriv->link_info.num_tx_inperiod) > 8) || 894 rtlpriv->link_info.num_tx_inperiod) > 8) ||
916 (rtlpriv->link_info.num_rx_inperiod > 2)) 895 rtlpriv->link_info.num_rx_inperiod > 2)
917 rtl_lps_leave(hw); 896 rtl_lps_leave(hw);
918 skb = new_skb; 897 skb = new_skb;
919no_new: 898no_new:
@@ -947,35 +926,34 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
947 unsigned long flags; 926 unsigned long flags;
948 u32 inta = 0; 927 u32 inta = 0;
949 u32 intb = 0; 928 u32 intb = 0;
929 u32 intc = 0;
930 u32 intd = 0;
950 irqreturn_t ret = IRQ_HANDLED; 931 irqreturn_t ret = IRQ_HANDLED;
951 932
952 if (rtlpci->irq_enabled == 0) 933 if (rtlpci->irq_enabled == 0)
953 return ret; 934 return ret;
954 935
955 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock , flags); 936 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
956 rtlpriv->cfg->ops->disable_interrupt(hw); 937 rtlpriv->cfg->ops->disable_interrupt(hw);
957 938
958 /*read ISR: 4/8bytes */ 939 /*read ISR: 4/8bytes */
959 rtlpriv->cfg->ops->interrupt_recognized(hw, &inta, &intb); 940 rtlpriv->cfg->ops->interrupt_recognized(hw, &inta, &intb, &intc, &intd);
960 941
961 /*Shared IRQ or HW disappared */ 942 /*Shared IRQ or HW disappeared */
962 if (!inta || inta == 0xffff) 943 if (!inta || inta == 0xffff)
963 goto done; 944 goto done;
964 945
965 /*<1> beacon related */ 946 /*<1> beacon related */
966 if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) { 947 if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK])
967 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 948 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
968 "beacon ok interrupt!\n"); 949 "beacon ok interrupt!\n");
969 }
970 950
971 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER])) { 951 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER]))
972 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 952 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
973 "beacon err interrupt!\n"); 953 "beacon err interrupt!\n");
974 }
975 954
976 if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK]) { 955 if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK])
977 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "beacon interrupt!\n"); 956 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "beacon interrupt!\n");
978 }
979 957
980 if (inta & rtlpriv->cfg->maps[RTL_IMR_BCNINT]) { 958 if (inta & rtlpriv->cfg->maps[RTL_IMR_BCNINT]) {
981 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 959 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
@@ -1031,6 +1009,16 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
1031 _rtl_pci_tx_isr(hw, VO_QUEUE); 1009 _rtl_pci_tx_isr(hw, VO_QUEUE);
1032 } 1010 }
1033 1011
1012 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8822BE) {
1013 if (intd & rtlpriv->cfg->maps[RTL_IMR_H2CDOK]) {
1014 rtlpriv->link_info.num_tx_inperiod++;
1015
1016 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
1017 "H2C TX OK interrupt!\n");
1018 _rtl_pci_tx_isr(hw, H2C_QUEUE);
1019 }
1020 }
1021
1034 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) { 1022 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) {
1035 if (inta & rtlpriv->cfg->maps[RTL_IMR_COMDOK]) { 1023 if (inta & rtlpriv->cfg->maps[RTL_IMR_COMDOK]) {
1036 rtlpriv->link_info.num_tx_inperiod++; 1024 rtlpriv->link_info.num_tx_inperiod++;
@@ -1130,7 +1118,7 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1130 1118
1131 /*NB: the beacon data buffer must be 32-bit aligned. */ 1119 /*NB: the beacon data buffer must be 32-bit aligned. */
1132 pskb = ieee80211_beacon_get(hw, mac->vif); 1120 pskb = ieee80211_beacon_get(hw, mac->vif);
1133 if (pskb == NULL) 1121 if (!pskb)
1134 return; 1122 return;
1135 hdr = rtl_get_hdr(pskb); 1123 hdr = rtl_get_hdr(pskb);
1136 info = IEEE80211_SKB_CB(pskb); 1124 info = IEEE80211_SKB_CB(pskb);
@@ -1152,7 +1140,6 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1152 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN, 1140 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
1153 &temp_one); 1141 &temp_one);
1154 } 1142 }
1155 return;
1156} 1143}
1157 1144
1158static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) 1145static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
@@ -1165,14 +1152,15 @@ static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
1165 1152
1166 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) 1153 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE)
1167 desc_num = TX_DESC_NUM_92E; 1154 desc_num = TX_DESC_NUM_92E;
1155 else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8822BE)
1156 desc_num = TX_DESC_NUM_8822B;
1168 else 1157 else
1169 desc_num = RT_TXDESC_NUM; 1158 desc_num = RT_TXDESC_NUM;
1170 1159
1171 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) 1160 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++)
1172 rtlpci->txringcount[i] = desc_num; 1161 rtlpci->txringcount[i] = desc_num;
1173 1162
1174 /* 1163 /*we just alloc 2 desc for beacon queue,
1175 *we just alloc 2 desc for beacon queue,
1176 *because we just need first desc in hw beacon. 1164 *because we just need first desc in hw beacon.
1177 */ 1165 */
1178 rtlpci->txringcount[BEACON_QUEUE] = 2; 1166 rtlpci->txringcount[BEACON_QUEUE] = 2;
@@ -1189,7 +1177,7 @@ static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw)
1189} 1177}
1190 1178
1191static void _rtl_pci_init_struct(struct ieee80211_hw *hw, 1179static void _rtl_pci_init_struct(struct ieee80211_hw *hw,
1192 struct pci_dev *pdev) 1180 struct pci_dev *pdev)
1193{ 1181{
1194 struct rtl_priv *rtlpriv = rtl_priv(hw); 1182 struct rtl_priv *rtlpriv = rtl_priv(hw);
1195 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1183 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -1361,7 +1349,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx)
1361} 1349}
1362 1350
1363static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw, 1351static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1364 unsigned int prio) 1352 unsigned int prio)
1365{ 1353{
1366 struct rtl_priv *rtlpriv = rtl_priv(hw); 1354 struct rtl_priv *rtlpriv = rtl_priv(hw);
1367 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1355 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
@@ -1378,8 +1366,7 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1378 entry = (u8 *)(&ring->desc[ring->idx]); 1366 entry = (u8 *)(&ring->desc[ring->idx]);
1379 1367
1380 pci_unmap_single(rtlpci->pdev, 1368 pci_unmap_single(rtlpci->pdev,
1381 rtlpriv->cfg-> 1369 rtlpriv->cfg->ops->get_desc(hw, (u8 *)entry,
1382 ops->get_desc(hw, (u8 *)entry,
1383 true, 1370 true,
1384 HW_DESC_TXBUFF_ADDR), 1371 HW_DESC_TXBUFF_ADDR),
1385 skb->len, PCI_DMA_TODEVICE); 1372 skb->len, PCI_DMA_TODEVICE);
@@ -1451,8 +1438,7 @@ static int _rtl_pci_init_trx_ring(struct ieee80211_hw *hw)
1451 } 1438 }
1452 1439
1453 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) { 1440 for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) {
1454 ret = _rtl_pci_init_tx_ring(hw, i, 1441 ret = _rtl_pci_init_tx_ring(hw, i, rtlpci->txringcount[i]);
1455 rtlpci->txringcount[i]);
1456 if (ret) 1442 if (ret)
1457 goto err_free_rings; 1443 goto err_free_rings;
1458 } 1444 }
@@ -1500,7 +1486,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1500 /* force the rx_ring[RX_MPDU_QUEUE/ 1486 /* force the rx_ring[RX_MPDU_QUEUE/
1501 * RX_CMD_QUEUE].idx to the first one 1487 * RX_CMD_QUEUE].idx to the first one
1502 *new trx flow, do nothing 1488 *new trx flow, do nothing
1503 */ 1489 */
1504 if (!rtlpriv->use_new_trx_flow && 1490 if (!rtlpriv->use_new_trx_flow &&
1505 rtlpci->rx_ring[rxring_idx].desc) { 1491 rtlpci->rx_ring[rxring_idx].desc) {
1506 struct rtl_rx_desc *entry = NULL; 1492 struct rtl_rx_desc *entry = NULL;
@@ -1510,8 +1496,8 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1510 entry = &rtlpci->rx_ring[rxring_idx].desc[i]; 1496 entry = &rtlpci->rx_ring[rxring_idx].desc[i];
1511 bufferaddress = 1497 bufferaddress =
1512 rtlpriv->cfg->ops->get_desc(hw, (u8 *)entry, 1498 rtlpriv->cfg->ops->get_desc(hw, (u8 *)entry,
1513 false , HW_DESC_RXBUFF_ADDR); 1499 false, HW_DESC_RXBUFF_ADDR);
1514 memset((u8 *)entry , 0 , 1500 memset((u8 *)entry, 0,
1515 sizeof(*rtlpci->rx_ring 1501 sizeof(*rtlpci->rx_ring
1516 [rxring_idx].desc));/*clear one entry*/ 1502 [rxring_idx].desc));/*clear one entry*/
1517 if (rtlpriv->use_new_trx_flow) { 1503 if (rtlpriv->use_new_trx_flow) {
@@ -1540,8 +1526,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1540 rtlpci->rx_ring[rxring_idx].idx = 0; 1526 rtlpci->rx_ring[rxring_idx].idx = 0;
1541 } 1527 }
1542 1528
1543 /* 1529 /*after reset, release previous pending packet,
1544 *after reset, release previous pending packet,
1545 *and force the tx idx to the first one 1530 *and force the tx idx to the first one
1546 */ 1531 */
1547 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); 1532 spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
@@ -1642,7 +1627,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw,
1642 1627
1643 if (rtlpriv->psc.sw_ps_enabled) { 1628 if (rtlpriv->psc.sw_ps_enabled) {
1644 if (ieee80211_is_data(fc) && !ieee80211_is_nullfunc(fc) && 1629 if (ieee80211_is_data(fc) && !ieee80211_is_nullfunc(fc) &&
1645 !ieee80211_has_pm(fc)) 1630 !ieee80211_has_pm(fc))
1646 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); 1631 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
1647 } 1632 }
1648 1633
@@ -1674,7 +1659,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw,
1674 own = (u8)rtlpriv->cfg->ops->get_desc(hw, (u8 *)pdesc, 1659 own = (u8)rtlpriv->cfg->ops->get_desc(hw, (u8 *)pdesc,
1675 true, HW_DESC_OWN); 1660 true, HW_DESC_OWN);
1676 1661
1677 if ((own == 1) && (hw_queue != BEACON_QUEUE)) { 1662 if (own == 1 && hw_queue != BEACON_QUEUE) {
1678 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1663 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1679 "No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%x\n", 1664 "No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%x\n",
1680 hw_queue, ring->idx, idx, 1665 hw_queue, ring->idx, idx,
@@ -1688,11 +1673,10 @@ static int rtl_pci_tx(struct ieee80211_hw *hw,
1688 1673
1689 if (rtlpriv->cfg->ops->get_available_desc && 1674 if (rtlpriv->cfg->ops->get_available_desc &&
1690 rtlpriv->cfg->ops->get_available_desc(hw, hw_queue) == 0) { 1675 rtlpriv->cfg->ops->get_available_desc(hw, hw_queue) == 0) {
1691 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1676 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1692 "get_available_desc fail\n"); 1677 "get_available_desc fail\n");
1693 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, 1678 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1694 flags); 1679 return skb->len;
1695 return skb->len;
1696 } 1680 }
1697 1681
1698 if (ieee80211_is_data(fc)) 1682 if (ieee80211_is_data(fc))
@@ -1751,7 +1735,7 @@ static void rtl_pci_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1751 ring = &pcipriv->dev.tx_ring[queue_id]; 1735 ring = &pcipriv->dev.tx_ring[queue_id];
1752 queue_len = skb_queue_len(&ring->queue); 1736 queue_len = skb_queue_len(&ring->queue);
1753 if (queue_len == 0 || queue_id == BEACON_QUEUE || 1737 if (queue_len == 0 || queue_id == BEACON_QUEUE ||
1754 queue_id == TXCMD_QUEUE) { 1738 queue_id == TXCMD_QUEUE) {
1755 queue_id--; 1739 queue_id--;
1756 continue; 1740 continue;
1757 } else { 1741 } else {
@@ -1761,7 +1745,7 @@ static void rtl_pci_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1761 1745
1762 /* we just wait 1s for all queues */ 1746 /* we just wait 1s for all queues */
1763 if (rtlpriv->psc.rfpwr_state == ERFOFF || 1747 if (rtlpriv->psc.rfpwr_state == ERFOFF ||
1764 is_hal_stop(rtlhal) || i >= 200) 1748 is_hal_stop(rtlhal) || i >= 200)
1765 return; 1749 return;
1766 } 1750 }
1767} 1751}
@@ -1779,7 +1763,6 @@ static void rtl_pci_deinit(struct ieee80211_hw *hw)
1779 1763
1780 flush_workqueue(rtlpriv->works.rtl_wq); 1764 flush_workqueue(rtlpriv->works.rtl_wq);
1781 destroy_workqueue(rtlpriv->works.rtl_wq); 1765 destroy_workqueue(rtlpriv->works.rtl_wq);
1782
1783} 1766}
1784 1767
1785static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) 1768static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev)
@@ -1837,7 +1820,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
1837 1820
1838 rtlpci->up_first_time = false; 1821 rtlpci->up_first_time = false;
1839 1822
1840 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "rtl_pci_start OK\n"); 1823 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%s OK\n", __func__);
1841 return 0; 1824 return 0;
1842} 1825}
1843 1826
@@ -1848,13 +1831,12 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1848 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 1831 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
1849 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1832 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1850 unsigned long flags; 1833 unsigned long flags;
1851 u8 RFInProgressTimeOut = 0; 1834 u8 rf_timeout = 0;
1852 1835
1853 if (rtlpriv->cfg->ops->get_btc_status()) 1836 if (rtlpriv->cfg->ops->get_btc_status())
1854 rtlpriv->btcoexist.btc_ops->btc_halt_notify(); 1837 rtlpriv->btcoexist.btc_ops->btc_halt_notify();
1855 1838
1856 /* 1839 /*should be before disable interrupt&adapter
1857 *should be before disable interrupt&adapter
1858 *and will do it immediately. 1840 *and will do it immediately.
1859 */ 1841 */
1860 set_hal_stop(rtlhal); 1842 set_hal_stop(rtlhal);
@@ -1866,12 +1848,12 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1866 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1848 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
1867 while (ppsc->rfchange_inprogress) { 1849 while (ppsc->rfchange_inprogress) {
1868 spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flags); 1850 spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flags);
1869 if (RFInProgressTimeOut > 100) { 1851 if (rf_timeout > 100) {
1870 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1852 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
1871 break; 1853 break;
1872 } 1854 }
1873 mdelay(1); 1855 mdelay(1);
1874 RFInProgressTimeOut++; 1856 rf_timeout++;
1875 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1857 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
1876 } 1858 }
1877 ppsc->rfchange_inprogress = true; 1859 ppsc->rfchange_inprogress = true;
@@ -1891,7 +1873,7 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1891} 1873}
1892 1874
1893static bool _rtl_pci_find_adapter(struct pci_dev *pdev, 1875static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1894 struct ieee80211_hw *hw) 1876 struct ieee80211_hw *hw)
1895{ 1877{
1896 struct rtl_priv *rtlpriv = rtl_priv(hw); 1878 struct rtl_priv *rtlpriv = rtl_priv(hw);
1897 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 1879 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
@@ -1946,13 +1928,12 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1946 venderid, deviceid); 1928 venderid, deviceid);
1947 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; 1929 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE;
1948 break; 1930 break;
1949
1950 } 1931 }
1951 } else if (deviceid == RTL_PCI_8723AE_DID) { 1932 } else if (deviceid == RTL_PCI_8723AE_DID) {
1952 rtlhal->hw_type = HARDWARE_TYPE_RTL8723AE; 1933 rtlhal->hw_type = HARDWARE_TYPE_RTL8723AE;
1953 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1934 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1954 "8723AE PCI-E is found - " 1935 "8723AE PCI-E is found - vid/did=%x/%x\n",
1955 "vid/did=%x/%x\n", venderid, deviceid); 1936 venderid, deviceid);
1956 } else if (deviceid == RTL_PCI_8192CET_DID || 1937 } else if (deviceid == RTL_PCI_8192CET_DID ||
1957 deviceid == RTL_PCI_8192CE_DID || 1938 deviceid == RTL_PCI_8192CE_DID ||
1958 deviceid == RTL_PCI_8191CE_DID || 1939 deviceid == RTL_PCI_8191CE_DID ||
@@ -1972,21 +1953,26 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1972 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1953 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1973 "Find adapter, Hardware type is 8188EE\n"); 1954 "Find adapter, Hardware type is 8188EE\n");
1974 } else if (deviceid == RTL_PCI_8723BE_DID) { 1955 } else if (deviceid == RTL_PCI_8723BE_DID) {
1975 rtlhal->hw_type = HARDWARE_TYPE_RTL8723BE; 1956 rtlhal->hw_type = HARDWARE_TYPE_RTL8723BE;
1976 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1957 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1977 "Find adapter, Hardware type is 8723BE\n"); 1958 "Find adapter, Hardware type is 8723BE\n");
1978 } else if (deviceid == RTL_PCI_8192EE_DID) { 1959 } else if (deviceid == RTL_PCI_8192EE_DID) {
1979 rtlhal->hw_type = HARDWARE_TYPE_RTL8192EE; 1960 rtlhal->hw_type = HARDWARE_TYPE_RTL8192EE;
1980 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1961 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1981 "Find adapter, Hardware type is 8192EE\n"); 1962 "Find adapter, Hardware type is 8192EE\n");
1982 } else if (deviceid == RTL_PCI_8821AE_DID) { 1963 } else if (deviceid == RTL_PCI_8821AE_DID) {
1983 rtlhal->hw_type = HARDWARE_TYPE_RTL8821AE; 1964 rtlhal->hw_type = HARDWARE_TYPE_RTL8821AE;
1984 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1965 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1985 "Find adapter, Hardware type is 8821AE\n"); 1966 "Find adapter, Hardware type is 8821AE\n");
1986 } else if (deviceid == RTL_PCI_8812AE_DID) { 1967 } else if (deviceid == RTL_PCI_8812AE_DID) {
1987 rtlhal->hw_type = HARDWARE_TYPE_RTL8812AE; 1968 rtlhal->hw_type = HARDWARE_TYPE_RTL8812AE;
1988 RT_TRACE(rtlpriv, COMP_INIT , DBG_LOUD, 1969 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1989 "Find adapter, Hardware type is 8812AE\n"); 1970 "Find adapter, Hardware type is 8812AE\n");
1971 } else if (deviceid == RTL_PCI_8822BE_DID) {
1972 rtlhal->hw_type = HARDWARE_TYPE_RTL8822BE;
1973 rtlhal->bandset = BAND_ON_BOTH;
1974 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1975 "Find adapter, Hardware type is 8822BE\n");
1990 } else { 1976 } else {
1991 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1977 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1992 "Err: Unknown device - vid/did=%x/%x\n", 1978 "Err: Unknown device - vid/did=%x/%x\n",
@@ -2014,11 +2000,17 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
2014 } 2000 }
2015 } 2001 }
2016 2002
2017 /* 92ee use new trx flow */ 2003 switch (rtlhal->hw_type) {
2018 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) 2004 case HARDWARE_TYPE_RTL8192EE:
2005 case HARDWARE_TYPE_RTL8822BE:
2006 /* use new trx flow */
2019 rtlpriv->use_new_trx_flow = true; 2007 rtlpriv->use_new_trx_flow = true;
2020 else 2008 break;
2009
2010 default:
2021 rtlpriv->use_new_trx_flow = false; 2011 rtlpriv->use_new_trx_flow = false;
2012 break;
2013 }
2022 2014
2023 /*find bus info */ 2015 /*find bus info */
2024 pcipriv->ndis_adapter.busnumber = pdev->bus->number; 2016 pcipriv->ndis_adapter.busnumber = pdev->bus->number;
@@ -2109,7 +2101,7 @@ static int rtl_pci_intr_mode_msi(struct ieee80211_hw *hw)
2109 2101
2110 rtlpci->using_msi = true; 2102 rtlpci->using_msi = true;
2111 2103
2112 RT_TRACE(rtlpriv, COMP_INIT|COMP_INTR, DBG_DMESG, 2104 RT_TRACE(rtlpriv, COMP_INIT | COMP_INTR, DBG_DMESG,
2113 "MSI Interrupt Mode!\n"); 2105 "MSI Interrupt Mode!\n");
2114 return 0; 2106 return 0;
2115} 2107}
@@ -2127,7 +2119,7 @@ static int rtl_pci_intr_mode_legacy(struct ieee80211_hw *hw)
2127 return ret; 2119 return ret;
2128 2120
2129 rtlpci->using_msi = false; 2121 rtlpci->using_msi = false;
2130 RT_TRACE(rtlpriv, COMP_INIT|COMP_INTR, DBG_DMESG, 2122 RT_TRACE(rtlpriv, COMP_INIT | COMP_INTR, DBG_DMESG,
2131 "Pin-based Interrupt Mode!\n"); 2123 "Pin-based Interrupt Mode!\n");
2132 return 0; 2124 return 0;
2133} 2125}
@@ -2164,7 +2156,7 @@ static void platform_enable_dma64(struct pci_dev *pdev, bool dma64)
2164} 2156}
2165 2157
2166int rtl_pci_probe(struct pci_dev *pdev, 2158int rtl_pci_probe(struct pci_dev *pdev,
2167 const struct pci_device_id *id) 2159 const struct pci_device_id *id)
2168{ 2160{
2169 struct ieee80211_hw *hw = NULL; 2161 struct ieee80211_hw *hw = NULL;
2170 2162
@@ -2343,7 +2335,6 @@ fail1:
2343 pci_disable_device(pdev); 2335 pci_disable_device(pdev);
2344 2336
2345 return err; 2337 return err;
2346
2347} 2338}
2348EXPORT_SYMBOL(rtl_pci_probe); 2339EXPORT_SYMBOL(rtl_pci_probe);
2349 2340
@@ -2402,20 +2393,20 @@ EXPORT_SYMBOL(rtl_pci_disconnect);
2402 2393
2403#ifdef CONFIG_PM_SLEEP 2394#ifdef CONFIG_PM_SLEEP
2404/*************************************** 2395/***************************************
2405kernel pci power state define: 2396 * kernel pci power state define:
2406PCI_D0 ((pci_power_t __force) 0) 2397 * PCI_D0 ((pci_power_t __force) 0)
2407PCI_D1 ((pci_power_t __force) 1) 2398 * PCI_D1 ((pci_power_t __force) 1)
2408PCI_D2 ((pci_power_t __force) 2) 2399 * PCI_D2 ((pci_power_t __force) 2)
2409PCI_D3hot ((pci_power_t __force) 3) 2400 * PCI_D3hot ((pci_power_t __force) 3)
2410PCI_D3cold ((pci_power_t __force) 4) 2401 * PCI_D3cold ((pci_power_t __force) 4)
2411PCI_UNKNOWN ((pci_power_t __force) 5) 2402 * PCI_UNKNOWN ((pci_power_t __force) 5)
2412 2403
2413This function is called when system 2404 * This function is called when system
2414goes into suspend state mac80211 will 2405 * goes into suspend state mac80211 will
2415call rtl_mac_stop() from the mac80211 2406 * call rtl_mac_stop() from the mac80211
2416suspend function first, So there is 2407 * suspend function first, So there is
2417no need to call hw_disable here. 2408 * no need to call hw_disable here.
2418****************************************/ 2409 ****************************************/
2419int rtl_pci_suspend(struct device *dev) 2410int rtl_pci_suspend(struct device *dev)
2420{ 2411{
2421 struct pci_dev *pdev = to_pci_dev(dev); 2412 struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.h b/drivers/net/wireless/realtek/rtlwifi/pci.h
index 1af92b34979d..e7d070e8da2d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.h
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.h
@@ -27,10 +27,9 @@
27#define __RTL_PCI_H__ 27#define __RTL_PCI_H__
28 28
29#include <linux/pci.h> 29#include <linux/pci.h>
30/* 30/* 1: MSDU packet queue,
311: MSDU packet queue, 31 * 2: Rx Command Queue
322: Rx Command Queue 32 */
33*/
34#define RTL_PCI_RX_MPDU_QUEUE 0 33#define RTL_PCI_RX_MPDU_QUEUE 0
35#define RTL_PCI_RX_CMD_QUEUE 1 34#define RTL_PCI_RX_CMD_QUEUE 1
36#define RTL_PCI_MAX_RX_QUEUE 2 35#define RTL_PCI_MAX_RX_QUEUE 2
@@ -40,6 +39,7 @@
40 39
41#define RT_TXDESC_NUM 128 40#define RT_TXDESC_NUM 128
42#define TX_DESC_NUM_92E 512 41#define TX_DESC_NUM_92E 512
42#define TX_DESC_NUM_8822B 512
43#define RT_TXDESC_NUM_BE_QUEUE 256 43#define RT_TXDESC_NUM_BE_QUEUE 256
44 44
45#define BK_QUEUE 0 45#define BK_QUEUE 0
@@ -51,6 +51,7 @@
51#define MGNT_QUEUE 6 51#define MGNT_QUEUE 6
52#define HIGH_QUEUE 7 52#define HIGH_QUEUE 7
53#define HCCA_QUEUE 8 53#define HCCA_QUEUE 8
54#define H2C_QUEUE TXCMD_QUEUE /* In 8822B */
54 55
55#define RTL_PCI_DEVICE(vend, dev, cfg) \ 56#define RTL_PCI_DEVICE(vend, dev, cfg) \
56 .vendor = (vend), \ 57 .vendor = (vend), \
@@ -108,6 +109,7 @@
108#define RTL_PCI_8192EE_DID 0x818B /*8192ee*/ 109#define RTL_PCI_8192EE_DID 0x818B /*8192ee*/
109#define RTL_PCI_8821AE_DID 0x8821 /*8821ae*/ 110#define RTL_PCI_8821AE_DID 0x8821 /*8821ae*/
110#define RTL_PCI_8812AE_DID 0x8812 /*8812ae*/ 111#define RTL_PCI_8812AE_DID 0x8812 /*8812ae*/
112#define RTL_PCI_8822BE_DID 0xB822 /*8822be*/
111 113
112/*8192 support 16 pages of IO registers*/ 114/*8192 support 16 pages of IO registers*/
113#define RTL_MEM_MAPPED_IO_RANGE_8190PCI 0x1000 115#define RTL_MEM_MAPPED_IO_RANGE_8190PCI 0x1000
@@ -209,7 +211,7 @@ struct rtl_pci {
209 211
210 /*irq */ 212 /*irq */
211 u8 irq_alloc; 213 u8 irq_alloc;
212 u32 irq_mask[2]; 214 u32 irq_mask[4]; /* 0-1: normal, 2: unused, 3: h2c */
213 u32 sys_irq_mask; 215 u32 sys_irq_mask;
214 216
215 /*Bcn control register setting */ 217 /*Bcn control register setting */
@@ -223,8 +225,9 @@ struct rtl_pci {
223 u8 const_hostpci_aspm_setting; 225 u8 const_hostpci_aspm_setting;
224 /*pci-e device */ 226 /*pci-e device */
225 u8 const_devicepci_aspm_setting; 227 u8 const_devicepci_aspm_setting;
226 /*If it supports ASPM, Offset[560h] = 0x40, 228 /* If it supports ASPM, Offset[560h] = 0x40,
227 otherwise Offset[560h] = 0x00. */ 229 * otherwise Offset[560h] = 0x00.
230 */
228 bool support_aspm; 231 bool support_aspm;
229 bool support_backdoor; 232 bool support_backdoor;
230 233
@@ -279,7 +282,7 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw);
279extern const struct rtl_intf_ops rtl_pci_ops; 282extern const struct rtl_intf_ops rtl_pci_ops;
280 283
281int rtl_pci_probe(struct pci_dev *pdev, 284int rtl_pci_probe(struct pci_dev *pdev,
282 const struct pci_device_id *id); 285 const struct pci_device_id *id);
283void rtl_pci_disconnect(struct pci_dev *pdev); 286void rtl_pci_disconnect(struct pci_dev *pdev);
284#ifdef CONFIG_PM_SLEEP 287#ifdef CONFIG_PM_SLEEP
285int rtl_pci_suspend(struct device *dev); 288int rtl_pci_suspend(struct device *dev);
@@ -287,34 +290,34 @@ int rtl_pci_resume(struct device *dev);
287#endif /* CONFIG_PM_SLEEP */ 290#endif /* CONFIG_PM_SLEEP */
288static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr) 291static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
289{ 292{
290 return readb((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 293 return readb((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
291} 294}
292 295
293static inline u16 pci_read16_sync(struct rtl_priv *rtlpriv, u32 addr) 296static inline u16 pci_read16_sync(struct rtl_priv *rtlpriv, u32 addr)
294{ 297{
295 return readw((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 298 return readw((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
296} 299}
297 300
298static inline u32 pci_read32_sync(struct rtl_priv *rtlpriv, u32 addr) 301static inline u32 pci_read32_sync(struct rtl_priv *rtlpriv, u32 addr)
299{ 302{
300 return readl((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 303 return readl((u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
301} 304}
302 305
303static inline void pci_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val) 306static inline void pci_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val)
304{ 307{
305 writeb(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 308 writeb(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
306} 309}
307 310
308static inline void pci_write16_async(struct rtl_priv *rtlpriv, 311static inline void pci_write16_async(struct rtl_priv *rtlpriv,
309 u32 addr, u16 val) 312 u32 addr, u16 val)
310{ 313{
311 writew(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 314 writew(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
312} 315}
313 316
314static inline void pci_write32_async(struct rtl_priv *rtlpriv, 317static inline void pci_write32_async(struct rtl_priv *rtlpriv,
315 u32 addr, u32 val) 318 u32 addr, u32 val)
316{ 319{
317 writel(val, (u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 320 writel(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
318} 321}
319 322
320static inline u16 calc_fifo_space(u16 rp, u16 wp) 323static inline u16 calc_fifo_space(u16 rp, u16 wp)
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
index 2c671364c521..e30a18e64ff5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.c
@@ -1472,7 +1472,8 @@ void rtl88ee_card_disable(struct ieee80211_hw *hw)
1472} 1472}
1473 1473
1474void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw, 1474void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw,
1475 u32 *p_inta, u32 *p_intb) 1475 u32 *p_inta, u32 *p_intb,
1476 u32 *p_intc, u32 *p_intd)
1476{ 1477{
1477 struct rtl_priv *rtlpriv = rtl_priv(hw); 1478 struct rtl_priv *rtlpriv = rtl_priv(hw);
1478 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1479 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
index ab8488da9409..cdf49de1e6ed 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/hw.h
@@ -29,7 +29,8 @@
29void rtl88ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 29void rtl88ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl88ee_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl88ee_read_eeprom_info(struct ieee80211_hw *hw);
31void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw, 31void rtl88ee_interrupt_recognized(struct ieee80211_hw *hw,
32 u32 *p_inta, u32 *p_intb); 32 u32 *p_inta, u32 *p_intb,
33 u32 *p_intc, u32 *p_intd);
33int rtl88ee_hw_init(struct ieee80211_hw *hw); 34int rtl88ee_hw_init(struct ieee80211_hw *hw);
34void rtl88ee_card_disable(struct ieee80211_hw *hw); 35void rtl88ee_card_disable(struct ieee80211_hw *hw);
35void rtl88ee_enable_interrupt(struct ieee80211_hw *hw); 36void rtl88ee_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
index 9310fad69cd9..0f4c86a28716 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
@@ -1375,7 +1375,8 @@ void rtl92ce_card_disable(struct ieee80211_hw *hw)
1375} 1375}
1376 1376
1377void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw, 1377void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw,
1378 u32 *p_inta, u32 *p_intb) 1378 u32 *p_inta, u32 *p_intb,
1379 u32 *p_intc, u32 *p_intd)
1379{ 1380{
1380 struct rtl_priv *rtlpriv = rtl_priv(hw); 1381 struct rtl_priv *rtlpriv = rtl_priv(hw);
1381 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1382 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h
index 7683c5dfe851..b5c8e2fc1ba2 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.h
@@ -42,7 +42,8 @@ static inline u8 rtl92c_get_chnl_group(u8 chnl)
42void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 42void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
43void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw); 43void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw);
44void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw, 44void rtl92ce_interrupt_recognized(struct ieee80211_hw *hw,
45 u32 *p_inta, u32 *p_intb); 45 u32 *p_inta, u32 *p_intb,
46 u32 *p_intc, u32 *p_intd);
46int rtl92ce_hw_init(struct ieee80211_hw *hw); 47int rtl92ce_hw_init(struct ieee80211_hw *hw);
47void rtl92ce_card_disable(struct ieee80211_hw *hw); 48void rtl92ce_card_disable(struct ieee80211_hw *hw);
48void rtl92ce_enable_interrupt(struct ieee80211_hw *hw); 49void rtl92ce_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
index 5a67f85fa165..0da6c0136857 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c
@@ -1356,7 +1356,8 @@ void rtl92de_card_disable(struct ieee80211_hw *hw)
1356} 1356}
1357 1357
1358void rtl92de_interrupt_recognized(struct ieee80211_hw *hw, 1358void rtl92de_interrupt_recognized(struct ieee80211_hw *hw,
1359 u32 *p_inta, u32 *p_intb) 1359 u32 *p_inta, u32 *p_intb,
1360 u32 *p_intc, u32 *p_intd)
1360{ 1361{
1361 struct rtl_priv *rtlpriv = rtl_priv(hw); 1362 struct rtl_priv *rtlpriv = rtl_priv(hw);
1362 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1363 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h
index 85c565b86ae3..9236aa91273d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h
@@ -29,7 +29,8 @@
29void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 29void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl92de_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl92de_read_eeprom_info(struct ieee80211_hw *hw);
31void rtl92de_interrupt_recognized(struct ieee80211_hw *hw, 31void rtl92de_interrupt_recognized(struct ieee80211_hw *hw,
32 u32 *p_inta, u32 *p_intb); 32 u32 *p_inta, u32 *p_intb,
33 u32 *p_intc, u32 *p_intd);
33int rtl92de_hw_init(struct ieee80211_hw *hw); 34int rtl92de_hw_init(struct ieee80211_hw *hw);
34void rtl92de_card_disable(struct ieee80211_hw *hw); 35void rtl92de_card_disable(struct ieee80211_hw *hw);
35void rtl92de_enable_interrupt(struct ieee80211_hw *hw); 36void rtl92de_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
index 6fc3090c4b72..fe5da637e77a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c
@@ -1694,7 +1694,8 @@ void rtl92ee_card_disable(struct ieee80211_hw *hw)
1694} 1694}
1695 1695
1696void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw, 1696void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw,
1697 u32 *p_inta, u32 *p_intb) 1697 u32 *p_inta, u32 *p_intb,
1698 u32 *p_intc, u32 *p_intd)
1698{ 1699{
1699 struct rtl_priv *rtlpriv = rtl_priv(hw); 1700 struct rtl_priv *rtlpriv = rtl_priv(hw);
1700 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1701 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h
index cd6aeb44b996..cd6d3322f033 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.h
@@ -29,7 +29,8 @@
29void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); 29void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl92ee_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl92ee_read_eeprom_info(struct ieee80211_hw *hw);
31void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw, 31void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw,
32 u32 *p_inta, u32 *p_intb); 32 u32 *p_inta, u32 *p_intb,
33 u32 *p_intc, u32 *p_intd);
33int rtl92ee_hw_init(struct ieee80211_hw *hw); 34int rtl92ee_hw_init(struct ieee80211_hw *hw);
34void rtl92ee_card_disable(struct ieee80211_hw *hw); 35void rtl92ee_card_disable(struct ieee80211_hw *hw);
35void rtl92ee_enable_interrupt(struct ieee80211_hw *hw); 36void rtl92ee_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
index 66be79ca4247..76bf089cced4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.c
@@ -1559,7 +1559,7 @@ void rtl92se_card_disable(struct ieee80211_hw *hw)
1559} 1559}
1560 1560
1561void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, u32 *p_inta, 1561void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, u32 *p_inta,
1562 u32 *p_intb) 1562 u32 *p_intb, u32 *p_intc, u32 *p_intd)
1563{ 1563{
1564 struct rtl_priv *rtlpriv = rtl_priv(hw); 1564 struct rtl_priv *rtlpriv = rtl_priv(hw);
1565 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1565 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h
index 3c93d30fcae7..607056010974 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/hw.h
@@ -42,7 +42,8 @@ void rtl92se_get_hw_reg(struct ieee80211_hw *hw,
42 u8 variable, u8 *val); 42 u8 variable, u8 *val);
43void rtl92se_read_eeprom_info(struct ieee80211_hw *hw); 43void rtl92se_read_eeprom_info(struct ieee80211_hw *hw);
44void rtl92se_interrupt_recognized(struct ieee80211_hw *hw, 44void rtl92se_interrupt_recognized(struct ieee80211_hw *hw,
45 u32 *inta, u32 *intb); 45 u32 *p_inta, u32 *p_intb,
46 u32 *p_intc, u32 *p_intd);
46int rtl92se_hw_init(struct ieee80211_hw *hw); 47int rtl92se_hw_init(struct ieee80211_hw *hw);
47void rtl92se_card_disable(struct ieee80211_hw *hw); 48void rtl92se_card_disable(struct ieee80211_hw *hw);
48void rtl92se_enable_interrupt(struct ieee80211_hw *hw); 49void rtl92se_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
index 8cfd4993c90a..c3f98d58124c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
@@ -1340,7 +1340,8 @@ void rtl8723e_card_disable(struct ieee80211_hw *hw)
1340} 1340}
1341 1341
1342void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw, 1342void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw,
1343 u32 *p_inta, u32 *p_intb) 1343 u32 *p_inta, u32 *p_intb,
1344 u32 *p_intc, u32 *p_intd)
1344{ 1345{
1345 struct rtl_priv *rtlpriv = rtl_priv(hw); 1346 struct rtl_priv *rtlpriv = rtl_priv(hw);
1346 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1347 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h
index 1e7063105c96..19e467a37c72 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.h
@@ -34,7 +34,8 @@ void rtl8723e_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
34void rtl8723e_read_eeprom_info(struct ieee80211_hw *hw); 34void rtl8723e_read_eeprom_info(struct ieee80211_hw *hw);
35 35
36void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw, 36void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw,
37 u32 *p_inta, u32 *p_intb); 37 u32 *p_inta, u32 *p_intb,
38 u32 *p_intc, u32 *p_intd);
38int rtl8723e_hw_init(struct ieee80211_hw *hw); 39int rtl8723e_hw_init(struct ieee80211_hw *hw);
39void rtl8723e_card_disable(struct ieee80211_hw *hw); 40void rtl8723e_card_disable(struct ieee80211_hw *hw);
40void rtl8723e_enable_interrupt(struct ieee80211_hw *hw); 41void rtl8723e_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
index 239518bd31f1..7cd1ffa7d4a7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c
@@ -1682,7 +1682,8 @@ void rtl8723be_card_disable(struct ieee80211_hw *hw)
1682} 1682}
1683 1683
1684void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw, 1684void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw,
1685 u32 *p_inta, u32 *p_intb) 1685 u32 *p_inta, u32 *p_intb,
1686 u32 *p_intc, u32 *p_intd)
1686{ 1687{
1687 struct rtl_priv *rtlpriv = rtl_priv(hw); 1688 struct rtl_priv *rtlpriv = rtl_priv(hw);
1688 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1689 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h
index 54d7afa7297e..2215a792f6bf 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.h
@@ -30,7 +30,8 @@ void rtl8723be_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl8723be_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl8723be_read_eeprom_info(struct ieee80211_hw *hw);
31 31
32void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw, 32void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw,
33 u32 *p_inta, u32 *p_intb); 33 u32 *p_inta, u32 *p_intb,
34 u32 *p_intc, u32 *p_intd);
34int rtl8723be_hw_init(struct ieee80211_hw *hw); 35int rtl8723be_hw_init(struct ieee80211_hw *hw);
35void rtl8723be_card_disable(struct ieee80211_hw *hw); 36void rtl8723be_card_disable(struct ieee80211_hw *hw);
36void rtl8723be_enable_interrupt(struct ieee80211_hw *hw); 37void rtl8723be_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 60c82a5b51cd..43e18c4c1e68 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -1364,7 +1364,6 @@ static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw)
1364 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1364 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1365 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); 1365 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
1366 u8 fw_reason = 0; 1366 u8 fw_reason = 0;
1367 struct timeval ts;
1368 1367
1369 fw_reason = rtl_read_byte(rtlpriv, REG_MCUTST_WOWLAN); 1368 fw_reason = rtl_read_byte(rtlpriv, REG_MCUTST_WOWLAN);
1370 1369
@@ -1373,20 +1372,16 @@ static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw)
1373 1372
1374 ppsc->wakeup_reason = 0; 1373 ppsc->wakeup_reason = 0;
1375 1374
1376 rtlhal->last_suspend_sec = ts.tv_sec; 1375 rtlhal->last_suspend_sec = ktime_get_real_seconds();
1377 1376
1378 switch (fw_reason) { 1377 switch (fw_reason) {
1379 case FW_WOW_V2_PTK_UPDATE_EVENT: 1378 case FW_WOW_V2_PTK_UPDATE_EVENT:
1380 ppsc->wakeup_reason = WOL_REASON_PTK_UPDATE; 1379 ppsc->wakeup_reason = WOL_REASON_PTK_UPDATE;
1381 do_gettimeofday(&ts);
1382 ppsc->last_wakeup_time = ts.tv_sec*1000 + ts.tv_usec/1000;
1383 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 1380 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
1384 "It's a WOL PTK Key update event!\n"); 1381 "It's a WOL PTK Key update event!\n");
1385 break; 1382 break;
1386 case FW_WOW_V2_GTK_UPDATE_EVENT: 1383 case FW_WOW_V2_GTK_UPDATE_EVENT:
1387 ppsc->wakeup_reason = WOL_REASON_GTK_UPDATE; 1384 ppsc->wakeup_reason = WOL_REASON_GTK_UPDATE;
1388 do_gettimeofday(&ts);
1389 ppsc->last_wakeup_time = ts.tv_sec*1000 + ts.tv_usec/1000;
1390 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 1385 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
1391 "It's a WOL GTK Key update event!\n"); 1386 "It's a WOL GTK Key update event!\n");
1392 break; 1387 break;
@@ -2488,7 +2483,8 @@ void rtl8821ae_card_disable(struct ieee80211_hw *hw)
2488} 2483}
2489 2484
2490void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw, 2485void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw,
2491 u32 *p_inta, u32 *p_intb) 2486 u32 *p_inta, u32 *p_intb,
2487 u32 *p_intc, u32 *p_intd)
2492{ 2488{
2493 struct rtl_priv *rtlpriv = rtl_priv(hw); 2489 struct rtl_priv *rtlpriv = rtl_priv(hw);
2494 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 2490 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h
index 50fa9c718189..284d259fe557 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.h
@@ -30,7 +30,8 @@ void rtl8821ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
30void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw); 30void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw);
31 31
32void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw, 32void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw,
33 u32 *p_inta, u32 *p_intb); 33 u32 *p_inta, u32 *p_intb,
34 u32 *p_intc, u32 *p_intd);
34int rtl8821ae_hw_init(struct ieee80211_hw *hw); 35int rtl8821ae_hw_init(struct ieee80211_hw *hw);
35void rtl8821ae_card_disable(struct ieee80211_hw *hw); 36void rtl8821ae_card_disable(struct ieee80211_hw *hw);
36void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw); 37void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 22afc14c3da6..92d4859ec906 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -709,6 +709,7 @@ enum rtl_var_map {
709 RTL_IMR_RXFOVW, /*Receive FIFO Overflow */ 709 RTL_IMR_RXFOVW, /*Receive FIFO Overflow */
710 RTL_IMR_RDU, /*Receive Descriptor Unavailable */ 710 RTL_IMR_RDU, /*Receive Descriptor Unavailable */
711 RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */ 711 RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */
712 RTL_IMR_H2CDOK, /*H2C Queue DMA OK Interrupt */
712 RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */ 713 RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */
713 RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */ 714 RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */
714 RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/ 715 RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/
@@ -1599,7 +1600,7 @@ struct rtl_hal {
1599 bool enter_pnp_sleep; 1600 bool enter_pnp_sleep;
1600 bool wake_from_pnp_sleep; 1601 bool wake_from_pnp_sleep;
1601 bool wow_enabled; 1602 bool wow_enabled;
1602 __kernel_time_t last_suspend_sec; 1603 time64_t last_suspend_sec;
1603 u32 wowlan_fwsize; 1604 u32 wowlan_fwsize;
1604 u8 *wowlan_firmware; 1605 u8 *wowlan_firmware;
1605 1606
@@ -1953,8 +1954,6 @@ struct rtl_ps_ctl {
1953 u8 gtk_offload_enable; 1954 u8 gtk_offload_enable;
1954 /* Used for WOL, indicates the reason for waking event.*/ 1955 /* Used for WOL, indicates the reason for waking event.*/
1955 u32 wakeup_reason; 1956 u32 wakeup_reason;
1956 /* Record the last waking time for comparison with setting key. */
1957 u64 last_wakeup_time;
1958}; 1957};
1959 1958
1960struct rtl_stats { 1959struct rtl_stats {
@@ -2100,7 +2099,8 @@ struct rtl_hal_ops {
2100 void (*read_chip_version)(struct ieee80211_hw *hw); 2099 void (*read_chip_version)(struct ieee80211_hw *hw);
2101 void (*read_eeprom_info) (struct ieee80211_hw *hw); 2100 void (*read_eeprom_info) (struct ieee80211_hw *hw);
2102 void (*interrupt_recognized) (struct ieee80211_hw *hw, 2101 void (*interrupt_recognized) (struct ieee80211_hw *hw,
2103 u32 *p_inta, u32 *p_intb); 2102 u32 *p_inta, u32 *p_intb,
2103 u32 *p_intc, u32 *p_intd);
2104 int (*hw_init) (struct ieee80211_hw *hw); 2104 int (*hw_init) (struct ieee80211_hw *hw);
2105 void (*hw_disable) (struct ieee80211_hw *hw); 2105 void (*hw_disable) (struct ieee80211_hw *hw);
2106 void (*hw_suspend) (struct ieee80211_hw *hw); 2106 void (*hw_suspend) (struct ieee80211_hw *hw);
@@ -2144,6 +2144,9 @@ struct rtl_hal_ops {
2144 void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc, 2144 void (*fill_tx_cmddesc) (struct ieee80211_hw *hw, u8 *pdesc,
2145 bool firstseg, bool lastseg, 2145 bool firstseg, bool lastseg,
2146 struct sk_buff *skb); 2146 struct sk_buff *skb);
2147 void (*fill_tx_special_desc)(struct ieee80211_hw *hw,
2148 u8 *pdesc, u8 *pbd_desc,
2149 struct sk_buff *skb, u8 hw_queue);
2147 bool (*query_rx_desc) (struct ieee80211_hw *hw, 2150 bool (*query_rx_desc) (struct ieee80211_hw *hw,
2148 struct rtl_stats *stats, 2151 struct rtl_stats *stats,
2149 struct ieee80211_rx_status *rx_status, 2152 struct ieee80211_rx_status *rx_status,