History

Merge tag 'wireless-drivers-next-2020-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next

Kalle Valo says: ==================== wireless-drivers-next patches for v5.9 Second set of patches for v5.9. mt76 has most of patches this time. Otherwise it's just smaller fixes and cleanups to other drivers. There was a major conflict in mt76 driver between wireless-drivers and wireless-drivers-next. I solved that by merging the former to the latter. Major changes: rtw88 * add support for ieee80211_ops::change_interface * add support for enabling and disabling beacon * add debugfs file for testing h2c mt76 * ARP filter offload for 7663 * runtime power management for 7663 * testmode support for mfg calibration * support for more channels ====================

David S. Miller committed 6 years ago

Commit cabf06e2 parents 93f4ddd 2cfd71f124 files · +5595 −1277Browse files

Unified · Split

124 files
  1. Documentation/networking/device_drivers/wifi/intel/ipw2100.rst +1 −1
  2. drivers/bcma/driver_gpio.c +11 −12
  3. drivers/bcma/scan.c +3 −5
  4. drivers/net/wireless/broadcom/b43/main.c +7 −7
  5. drivers/net/wireless/broadcom/b43/phy_common.c +1 −1
  6. drivers/net/wireless/broadcom/b43/phy_g.c +6 −6
  7. drivers/net/wireless/broadcom/b43/phy_ht.c +1 −1
  8. drivers/net/wireless/broadcom/b43/phy_lp.c +1 −1
  9. drivers/net/wireless/broadcom/b43/phy_n.c +75 −75
  10. drivers/net/wireless/broadcom/b43/radio_2056.c +1 −1
  11. drivers/net/wireless/broadcom/b43/tables_nphy.c +2 −2
  12. drivers/net/wireless/broadcom/b43legacy/main.c +4 −4
  13. drivers/net/wireless/broadcom/b43legacy/phy.c +4 −4
  14. drivers/net/wireless/broadcom/b43legacy/radio.c +4 −4
  15. drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +8 −0
  16. drivers/net/wireless/cisco/airo.c +19 −20
  17. drivers/net/wireless/intel/ipw2x00/Kconfig +2 −2
  18. drivers/net/wireless/intel/ipw2x00/ipw2100.c +60 −63
  19. drivers/net/wireless/intel/ipw2x00/ipw2200.c +29 −27
  20. drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +1 −1
  21. drivers/net/wireless/intersil/Kconfig +1 −1
  22. drivers/net/wireless/intersil/hostap/hostap_hw.c +3 −3
  23. drivers/net/wireless/intersil/hostap/hostap_pci.c +10 −24
  24. drivers/net/wireless/intersil/orinoco/Kconfig +2 −2
  25. drivers/net/wireless/intersil/p54/Kconfig +3 −3
  26. drivers/net/wireless/intersil/p54/fwio.c +1 −1
  27. drivers/net/wireless/intersil/p54/p54pci.c +35 −30
  28. drivers/net/wireless/intersil/p54/p54usb.c +1 −1
  29. drivers/net/wireless/intersil/prism54/isl_oid.h +1 −1
  30. drivers/net/wireless/intersil/prism54/islpci_dev.c +14 −16
  31. drivers/net/wireless/intersil/prism54/islpci_eth.c +10 −14
  32. drivers/net/wireless/intersil/prism54/islpci_hotplug.c +14 −25
  33. drivers/net/wireless/intersil/prism54/islpci_mgt.c +11 −10
  34. drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +1 −1
  35. drivers/net/wireless/mediatek/mt76/Kconfig +4 −0
  36. drivers/net/wireless/mediatek/mt76/Makefile +3 −0
  37. drivers/net/wireless/mediatek/mt76/debugfs.c +2 −5
  38. drivers/net/wireless/mediatek/mt76/dma.c +6 −0
  39. drivers/net/wireless/mediatek/mt76/eeprom.c +5 −0
  40. drivers/net/wireless/mediatek/mt76/mac80211.c +32 −5
  41. drivers/net/wireless/mediatek/mt76/mt76.h +112 −3
  42. drivers/net/wireless/mediatek/mt76/mt7603/main.c +3 −3
  43. drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +0 −2
  44. drivers/net/wireless/mediatek/mt76/mt7615/Kconfig +17 −2
  45. drivers/net/wireless/mediatek/mt76/mt7615/Makefile +6 −1
  46. drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +101 −1
  47. drivers/net/wireless/mediatek/mt76/mt7615/dma.c +0 −4
  48. drivers/net/wireless/mediatek/mt76/mt7615/init.c +14 −3
  49. drivers/net/wireless/mediatek/mt76/mt7615/mac.c +282 −30
  50. drivers/net/wireless/mediatek/mt76/mt7615/mac.h +5 −0
  51. drivers/net/wireless/mediatek/mt76/mt7615/main.c +269 −63
  52. drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +313 −58
  53. drivers/net/wireless/mediatek/mt76/mt7615/mcu.h +51 −3
  54. drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +47 −2
  55. drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +91 −4
  56. drivers/net/wireless/mediatek/mt76/mt7615/pci.c +4 −0
  57. drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c +4 −0
  58. drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +0 −1
  59. drivers/net/wireless/mediatek/mt76/mt7615/regs.h +31 −2
  60. drivers/net/wireless/mediatek/mt76/mt7615/sdio.c +478 −0
  61. drivers/net/wireless/mediatek/mt76/mt7615/sdio.h +115 −0
  62. drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c +162 −0
  63. drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c +268 −0
  64. drivers/net/wireless/mediatek/mt76/mt7615/testmode.c +363 −0
  65. drivers/net/wireless/mediatek/mt76/mt7615/usb.c +17 −229
  66. drivers/net/wireless/mediatek/mt76/mt7615/usb_init.c +0 −145
  67. drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c +5 −2
  68. drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c +394 −0
  69. drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +2 −4
  70. drivers/net/wireless/mediatek/mt76/mt76x02.h +0 −1
  71. drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c +1 −1
  72. drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +2 −1
  73. drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c +5 −2
  74. drivers/net/wireless/mediatek/mt76/mt76x02_util.c +4 −4
  75. drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +1 −0
  76. drivers/net/wireless/mediatek/mt76/mt76x2/pci.c +63 −7
  77. drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +17 −0
  78. drivers/net/wireless/mediatek/mt76/mt76x2/usb.c +3 −5
  79. drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +10 −1
  80. drivers/net/wireless/mediatek/mt76/mt7915/dma.c +11 −10
  81. drivers/net/wireless/mediatek/mt76/mt7915/init.c +26 −18
  82. drivers/net/wireless/mediatek/mt76/mt7915/mac.c +45 −48
  83. drivers/net/wireless/mediatek/mt76/mt7915/mac.h +0 −17
  84. drivers/net/wireless/mediatek/mt76/mt7915/main.c +6 −7
  85. drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +96 −21
  86. drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +3 −3
  87. drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +27 −8
  88. drivers/net/wireless/mediatek/mt76/mt7915/pci.c +1 −1
  89. drivers/net/wireless/mediatek/mt76/mt7915/regs.h +5 −0
  90. drivers/net/wireless/mediatek/mt76/pci.c +1 −0
  91. drivers/net/wireless/mediatek/mt76/sdio.c +368 −0
  92. drivers/net/wireless/mediatek/mt76/testmode.c +497 −0
  93. drivers/net/wireless/mediatek/mt76/testmode.h +156 −0
  94. drivers/net/wireless/mediatek/mt76/tx.c +47 −0
  95. drivers/net/wireless/mediatek/mt76/usb.c +16 −74
  96. drivers/net/wireless/mediatek/mt76/util.c +2 −2
  97. drivers/net/wireless/mediatek/mt7601u/mcu.c +3 −1
  98. drivers/net/wireless/microchip/wilc1000/sdio.c +2 −4
  99. drivers/net/wireless/quantenna/qtnfmac/core.c +4 −1
  100. drivers/net/wireless/ralink/rt2x00/rt2400pci.c +1 −2
  101. drivers/net/wireless/ralink/rt2x00/rt2500pci.c +1 −2
  102. drivers/net/wireless/ralink/rt2x00/rt2800pci.c +1 −2
  103. drivers/net/wireless/ralink/rt2x00/rt2x00.h +2 −3
  104. drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +1 −3
  105. drivers/net/wireless/ralink/rt2x00/rt2x00pci.c +8 −23
  106. drivers/net/wireless/ralink/rt2x00/rt2x00pci.h +2 −7
  107. drivers/net/wireless/ralink/rt2x00/rt2x00soc.c +1 −1
  108. drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +1 −1
  109. drivers/net/wireless/ralink/rt2x00/rt61pci.c +1 −2
  110. drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c +3 −5
  111. drivers/net/wireless/realtek/rtw88/coex.c +2 −1
  112. drivers/net/wireless/realtek/rtw88/debug.c +30 −0
  113. drivers/net/wireless/realtek/rtw88/fw.c +11 −6
  114. drivers/net/wireless/realtek/rtw88/fw.h +2 −0
  115. drivers/net/wireless/realtek/rtw88/mac80211.c +27 −0
  116. drivers/net/wireless/realtek/rtw88/main.c +6 −5
  117. drivers/net/wireless/realtek/rtw88/main.h +2 −0
  118. drivers/net/wireless/realtek/rtw88/reg.h +1 −0
  119. drivers/net/wireless/realtek/rtw88/rtw8821c.c +404 −1
  120. drivers/net/wireless/realtek/rtw88/rtw8821c.h +26 −0
  121. drivers/net/wireless/realtek/rtw88/tx.c +73 −31
  122. drivers/net/wireless/realtek/rtw88/tx.h +10 −3
  123. drivers/net/wireless/ti/wl1251/event.c +1 −1
  124. include/linux/mmc/sdio_ids.h +3 −0
Documentation/networking/device_drivers/wifi/intel/ipw2100.rst+1−1
@@ -78,7 +78,7 @@ such, if you are interested in deploying or shipping a driver as part of · 77 unmodified lines
7878 solution intended to be used for purposes other than development, please
7979 obtain a tested driver from Intel Customer Support at:
8080
81−http://www.intel.com/support/wireless/sb/CS-006408.htm
81+https://www.intel.com/support/wireless/sb/CS-006408.htm
8282
8383 1. Introduction
8484 ===============
drivers/bcma/driver_gpio.c+11−12
@@ -122,6 +122,7 @@ static irqreturn_t bcma_gpio_irq_handler(int irq, void *dev_id) · 121 unmodified lines
122122 static int bcma_gpio_irq_init(struct bcma_drv_cc *cc)
123123 {
124124 struct gpio_chip *chip = &cc->gpio;
125+ struct gpio_irq_chip *girq = &chip->irq;
125126 int hwirq, err;
126127
127128 if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC)
@@ -136,15 +137,13 @@ static int bcma_gpio_irq_init(struct bcma_drv_cc *cc) · 8 unmodified lines
136137 bcma_chipco_gpio_intmask(cc, ~0, 0);
137138 bcma_cc_set32(cc, BCMA_CC_IRQMASK, BCMA_CC_IRQ_GPIO);
138139
139− err = gpiochip_irqchip_add(chip,
140− &bcma_gpio_irq_chip,
141− 0,
142− handle_simple_irq,
143− IRQ_TYPE_NONE);
144− if (err) {
145− free_irq(hwirq, cc);
146− return err;
147− }
140+ girq->chip = &bcma_gpio_irq_chip;
141+ /* This will let us handle the parent IRQ in the driver */
142+ girq->parent_handler = NULL;
143+ girq->num_parents = 0;
144+ girq->parents = NULL;
145+ girq->default_type = IRQ_TYPE_NONE;
146+ girq->handler = handle_simple_irq;
148147
149148 return 0;
150149 }
@@ -212,13 +211,13 @@ int bcma_gpio_init(struct bcma_drv_cc *cc) · 61 unmodified lines
212211 else
213212 chip->base = -1;
214213
215− err = gpiochip_add_data(chip, cc);
214+ err = bcma_gpio_irq_init(cc);
216215 if (err)
217216 return err;
218217
219− err = bcma_gpio_irq_init(cc);
218+ err = gpiochip_add_data(chip, cc);
220219 if (err) {
221− gpiochip_remove(chip);
220+ bcma_gpio_irq_exit(cc);
222221 return err;
223222 }
224223
drivers/bcma/scan.c+3−5
@@ -219,7 +219,7 @@ static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr) · 218 unmodified lines
219219 static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
220220 u32 type, u8 port)
221221 {
222− u32 addrl, addrh, sizeh = 0;
222+ u32 addrl;
223223 u32 size;
224224
225225 u32 ent = bcma_erom_get_ent(bus, eromptr);
@@ -233,14 +233,12 @@ static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr, · 7 unmodified lines
233233
234234 addrl = ent & SCAN_ADDR_ADDR;
235235 if (ent & SCAN_ADDR_AG32)
236− addrh = bcma_erom_get_ent(bus, eromptr);
237− else
238− addrh = 0;
236+ bcma_erom_get_ent(bus, eromptr);
239237
240238 if ((ent & SCAN_ADDR_SZ) == SCAN_ADDR_SZ_SZD) {
241239 size = bcma_erom_get_ent(bus, eromptr);
242240 if (size & SCAN_SIZE_SG32)
243− sizeh = bcma_erom_get_ent(bus, eromptr);
241+ bcma_erom_get_ent(bus, eromptr);
244242 }
245243
246244 return addrl;
drivers/net/wireless/broadcom/b43/main.c+7−7
@@ -734,7 +734,7 @@ static void b43_short_slot_timing_disable(struct b43_wldev *dev) · 733 unmodified lines
734734 }
735735
736736 /* DummyTransmission function, as documented on
737− * http://bcm-v4.sipsolutions.net/802.11/DummyTransmission
737+ * https://bcm-v4.sipsolutions.net/802.11/DummyTransmission
738738 */
739739 void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
740740 {
@@ -1198,7 +1198,7 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags) · 457 unmodified lines
11981198 }
11991199 }
12001200
1201−/* http://bcm-v4.sipsolutions.net/802.11/PHY/BmacCorePllReset */
1201+/* https://bcm-v4.sipsolutions.net/802.11/PHY/BmacCorePllReset */
12021202 void b43_wireless_core_phy_pll_reset(struct b43_wldev *dev)
12031203 {
12041204 struct bcma_drv_cc *bcma_cc __maybe_unused;
@@ -2290,7 +2290,7 @@ err_format: · 1085 unmodified lines
22902290 return -EPROTO;
22912291 }
22922292
2293−/* http://bcm-v4.sipsolutions.net/802.11/Init/Firmware */
2293+/* https://bcm-v4.sipsolutions.net/802.11/Init/Firmware */
22942294 static int b43_try_request_fw(struct b43_request_fw_context *ctx)
22952295 {
22962296 struct b43_wldev *dev = ctx->dev;
@@ -2843,7 +2843,7 @@ static int b43_upload_initvals_band(struct b43_wldev *dev) · 546 unmodified lines
28432843 }
28442844
28452845 /* Initialize the GPIOs
2846− * http://bcm-specs.sipsolutions.net/GPIO
2846+ * https://bcm-specs.sipsolutions.net/GPIO
28472847 */
28482848
28492849 #ifdef CONFIG_B43_SSB
@@ -2971,7 +2971,7 @@ void b43_mac_enable(struct b43_wldev *dev) · 121 unmodified lines
29712971 }
29722972 }
29732973
2974−/* http://bcm-specs.sipsolutions.net/SuspendMAC */
2974+/* https://bcm-specs.sipsolutions.net/SuspendMAC */
29752975 void b43_mac_suspend(struct b43_wldev *dev)
29762976 {
29772977 int i;
@@ -3004,7 +3004,7 @@ out: · 26 unmodified lines
30043004 dev->mac_suspended++;
30053005 }
30063006
3007−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */
3007+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */
30083008 void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on)
30093009 {
30103010 u32 tmp;
@@ -3231,7 +3231,7 @@ static void b43_chip_exit(struct b43_wldev *dev) · 220 unmodified lines
32313231 }
32323232
32333233 /* Initialize the chip
3234− * http://bcm-specs.sipsolutions.net/ChipInit
3234+ * https://bcm-specs.sipsolutions.net/ChipInit
32353235 */
32363236 static int b43_chip_init(struct b43_wldev *dev)
32373237 {
drivers/net/wireless/broadcom/b43/phy_common.c+1−1
@@ -559,7 +559,7 @@ bool b43_is_40mhz(struct b43_wldev *dev) · 558 unmodified lines
559559 return dev->phy.chandef->width == NL80211_CHAN_WIDTH_40;
560560 }
561561
562−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */
562+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */
563563 void b43_phy_force_clock(struct b43_wldev *dev, bool force)
564564 {
565565 u32 tmp;
drivers/net/wireless/broadcom/b43/phy_g.c+6−6
@@ -357,14 +357,14 @@ static void b43_set_original_gains(struct b43_wldev *dev) · 356 unmodified lines
357357 b43_dummy_transmission(dev, false, true);
358358 }
359359
360−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
360+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
361361 static void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val)
362362 {
363363 b43_phy_write(dev, B43_PHY_NRSSILT_CTRL, offset);
364364 b43_phy_write(dev, B43_PHY_NRSSILT_DATA, (u16) val);
365365 }
366366
367−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
367+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
368368 static s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset)
369369 {
370370 u16 val;
@@ -375,7 +375,7 @@ static s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset) · 4 unmodified lines
375375 return (s16) val;
376376 }
377377
378−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
378+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
379379 static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)
380380 {
381381 u16 i;
@@ -389,7 +389,7 @@ static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val) · 7 unmodified lines
389389 }
390390 }
391391
392−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
392+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
393393 static void b43_nrssi_mem_update(struct b43_wldev *dev)
394394 {
395395 struct b43_phy_g *gphy = dev->phy.g;
@@ -1575,7 +1575,7 @@ static void b43_phy_initb5(struct b43_wldev *dev) · 1179 unmodified lines
15751575 b43_write16(dev, 0x03E4, (b43_read16(dev, 0x03E4) & 0xFFC0) | 0x0004);
15761576 }
15771577
1578−/* http://bcm-v4.sipsolutions.net/802.11/PHY/Init/B6 */
1578+/* https://bcm-v4.sipsolutions.net/802.11/PHY/Init/B6 */
15791579 static void b43_phy_initb6(struct b43_wldev *dev)
15801580 {
15811581 struct b43_phy *phy = &dev->phy;
@@ -2746,7 +2746,7 @@ static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev, · 1164 unmodified lines
27462746 return 0;
27472747 }
27482748
2749−/* http://bcm-specs.sipsolutions.net/EstimatePowerOut
2749+/* https://bcm-specs.sipsolutions.net/EstimatePowerOut
27502750 * This function converts a TSSI value to dBm in Q5.2
27512751 */
27522752 static s8 b43_gphy_estimate_power_out(struct b43_wldev *dev, s8 tssi)
drivers/net/wireless/broadcom/b43/phy_ht.c+1−1
@@ -1018,7 +1018,7 @@ static void b43_phy_ht_op_free(struct b43_wldev *dev) · 1017 unmodified lines
10181018 phy->ht = NULL;
10191019 }
10201020
1021−/* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
1021+/* https://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
10221022 static void b43_phy_ht_op_software_rfkill(struct b43_wldev *dev,
10231023 bool blocked)
10241024 {
drivers/net/wireless/broadcom/b43/phy_lp.c+1−1
@@ -70,7 +70,7 @@ static void b43_lpphy_op_free(struct b43_wldev *dev) · 69 unmodified lines
7070 dev->phy.lp = NULL;
7171 }
7272
73−/* http://bcm-v4.sipsolutions.net/802.11/PHY/LP/ReadBandSrom */
73+/* https://bcm-v4.sipsolutions.net/802.11/PHY/LP/ReadBandSrom */
7474 static void lpphy_read_band_sprom(struct b43_wldev *dev)
7575 {
7676 struct ssb_sprom *sprom = dev->dev->bus_sprom;
drivers/net/wireless/broadcom/b43/phy_n.c+75−75
@@ -98,7 +98,7 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev) · 97 unmodified lines
9898 (dev->phy.n->ipa5g_on && band == NL80211_BAND_5GHZ));
9999 }
100100
101−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */
101+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */
102102 static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev)
103103 {
104104 return (b43_phy_read(dev, B43_NPHY_RFSEQCA) & B43_NPHY_RFSEQCA_RXEN) >>
@@ -109,7 +109,7 @@ static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev) · 4 unmodified lines
109109 * RF (just without b43_nphy_rf_ctl_intc_override)
110110 **************************************************/
111111
112−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ForceRFSeq */
112+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ForceRFSeq */
113113 static void b43_nphy_force_rf_sequence(struct b43_wldev *dev,
114114 enum b43_nphy_rf_sequence seq)
115115 {
@@ -146,7 +146,7 @@ static void b43_nphy_rf_ctl_override_rev19(struct b43_wldev *dev, u16 field, · 30 unmodified lines
146146 /* TODO */
147147 }
148148
149−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverrideRev7 */
149+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverrideRev7 */
150150 static void b43_nphy_rf_ctl_override_rev7(struct b43_wldev *dev, u16 field,
151151 u16 value, u8 core, bool off,
152152 u8 override)
@@ -193,7 +193,7 @@ static void b43_nphy_rf_ctl_override_rev7(struct b43_wldev *dev, u16 field, · 40 unmodified lines
193193 }
194194 }
195195
196−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverideOneToMany */
196+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverideOneToMany */
197197 static void b43_nphy_rf_ctl_override_one_to_many(struct b43_wldev *dev,
198198 enum n_rf_ctl_over_cmd cmd,
199199 u16 value, u8 core, bool off)
@@ -237,7 +237,7 @@ static void b43_nphy_rf_ctl_override_one_to_many(struct b43_wldev *dev, · 37 unmodified lines
237237 }
238238 }
239239
240−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverride */
240+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverride */
241241 static void b43_nphy_rf_ctl_override(struct b43_wldev *dev, u16 field,
242242 u16 value, u8 core, bool off)
243243 {
@@ -382,7 +382,7 @@ static void b43_nphy_rf_ctl_intc_override_rev7(struct b43_wldev *dev, · 138 unmodified lines
382382 }
383383 }
384384
385−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlIntcOverride */
385+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlIntcOverride */
386386 static void b43_nphy_rf_ctl_intc_override(struct b43_wldev *dev,
387387 enum n_intc_override intc_override,
388388 u16 value, u8 core)
@@ -490,7 +490,7 @@ static void b43_nphy_rf_ctl_intc_override(struct b43_wldev *dev, · 101 unmodified lines
490490 * Various PHY ops
491491 **************************************************/
492492
493−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */
493+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */
494494 static void b43_nphy_write_clip_detection(struct b43_wldev *dev,
495495 const u16 *clip_st)
496496 {
@@ -498,14 +498,14 @@ static void b43_nphy_write_clip_detection(struct b43_wldev *dev, · 1 unmodified line
498498 b43_phy_write(dev, B43_NPHY_C2_CLIP1THRES, clip_st[1]);
499499 }
500500
501−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */
501+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */
502502 static void b43_nphy_read_clip_detection(struct b43_wldev *dev, u16 *clip_st)
503503 {
504504 clip_st[0] = b43_phy_read(dev, B43_NPHY_C1_CLIP1THRES);
505505 clip_st[1] = b43_phy_read(dev, B43_NPHY_C2_CLIP1THRES);
506506 }
507507
508−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */
508+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */
509509 static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val)
510510 {
511511 u16 tmp;
@@ -526,7 +526,7 @@ static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val) · 14 unmodified lines
526526 return tmp;
527527 }
528528
529−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */
529+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */
530530 static void b43_nphy_reset_cca(struct b43_wldev *dev)
531531 {
532532 u16 bbcfg;
@@ -540,7 +540,7 @@ static void b43_nphy_reset_cca(struct b43_wldev *dev) · 7 unmodified lines
540540 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
541541 }
542542
543−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/carriersearch */
543+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/carriersearch */
544544 static void b43_nphy_stay_in_carrier_search(struct b43_wldev *dev, bool enable)
545545 {
546546 struct b43_phy *phy = &dev->phy;
@@ -564,7 +564,7 @@ static void b43_nphy_stay_in_carrier_search(struct b43_wldev *dev, bool enable) · 17 unmodified lines
564564 }
565565 }
566566
567−/* http://bcm-v4.sipsolutions.net/PHY/N/Read_Lpf_Bw_Ctl */
567+/* https://bcm-v4.sipsolutions.net/PHY/N/Read_Lpf_Bw_Ctl */
568568 static u16 b43_nphy_read_lpf_ctl(struct b43_wldev *dev, u16 offset)
569569 {
570570 if (!offset)
@@ -572,7 +572,7 @@ static u16 b43_nphy_read_lpf_ctl(struct b43_wldev *dev, u16 offset) · 1 unmodified line
572572 return b43_ntab_read(dev, B43_NTAB16(7, offset)) & 0x7;
573573 }
574574
575−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/AdjustLnaGainTbl */
575+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/AdjustLnaGainTbl */
576576 static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)
577577 {
578578 struct b43_phy_n *nphy = dev->phy.n;
@@ -628,7 +628,7 @@ static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev) · 49 unmodified lines
628628 b43_nphy_stay_in_carrier_search(dev, 0);
629629 }
630630
631−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRfSeq */
631+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRfSeq */
632632 static void b43_nphy_set_rf_sequence(struct b43_wldev *dev, u8 cmd,
633633 u8 *events, u8 *delays, u8 length)
634634 {
@@ -805,7 +805,7 @@ static void b43_radio_2057_setup(struct b43_wldev *dev, · 170 unmodified lines
805805 }
806806
807807 /* Calibrate resistors in LPF of PLL?
808− * http://bcm-v4.sipsolutions.net/PHY/radio205x_rcal
808+ * https://bcm-v4.sipsolutions.net/PHY/radio205x_rcal
809809 */
810810 static u8 b43_radio_2057_rcal(struct b43_wldev *dev)
811811 {
@@ -919,7 +919,7 @@ static u8 b43_radio_2057_rcal(struct b43_wldev *dev) · 107 unmodified lines
919919 }
920920
921921 /* Calibrate the internal RC oscillator?
922− * http://bcm-v4.sipsolutions.net/PHY/radio2057_rccal
922+ * https://bcm-v4.sipsolutions.net/PHY/radio2057_rccal
923923 */
924924 static u16 b43_radio_2057_rccal(struct b43_wldev *dev)
925925 {
@@ -1030,7 +1030,7 @@ static void b43_radio_2057_init_post(struct b43_wldev *dev) · 104 unmodified lines
10301030 b43_radio_mask(dev, R2057_RFPLL_MASTER, ~0x8);
10311031 }
10321032
1033−/* http://bcm-v4.sipsolutions.net/802.11/Radio/2057/Init */
1033+/* https://bcm-v4.sipsolutions.net/802.11/Radio/2057/Init */
10341034 static void b43_radio_2057_init(struct b43_wldev *dev)
10351035 {
10361036 b43_radio_2057_init_pre(dev);
@@ -1117,7 +1117,7 @@ static void b43_chantab_radio_2056_upload(struct b43_wldev *dev, · 80 unmodified lines
11171117 e->radio_tx1_mixg_boost_tune);
11181118 }
11191119
1120−/* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2056Setup */
1120+/* https://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2056Setup */
11211121 static void b43_radio_2056_setup(struct b43_wldev *dev,
11221122 const struct b43_nphy_channeltab_entry_rev3 *e)
11231123 {
@@ -1356,7 +1356,7 @@ static void b43_radio_init2056_post(struct b43_wldev *dev) · 232 unmodified lines
13561356
13571357 /*
13581358 * Initialize a Broadcom 2056 N-radio
1359− * http://bcm-v4.sipsolutions.net/802.11/Radio/2056/Init
1359+ * https://bcm-v4.sipsolutions.net/802.11/Radio/2056/Init
13601360 */
13611361 static void b43_radio_init2056(struct b43_wldev *dev)
13621362 {
@@ -1406,7 +1406,7 @@ static void b43_chantab_radio_upload(struct b43_wldev *dev, · 43 unmodified lines
14061406 b43_radio_write(dev, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim);
14071407 }
14081408
1409−/* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2055Setup */
1409+/* https://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2055Setup */
14101410 static void b43_radio_2055_setup(struct b43_wldev *dev,
14111411 const struct b43_nphy_channeltab_entry_rev2 *e)
14121412 {
@@ -1480,7 +1480,7 @@ static void b43_radio_init2055_post(struct b43_wldev *dev) · 67 unmodified lines
14801480
14811481 /*
14821482 * Initialize a Broadcom 2055 N-radio
1483− * http://bcm-v4.sipsolutions.net/802.11/Radio/2055/Init
1483+ * https://bcm-v4.sipsolutions.net/802.11/Radio/2055/Init
14841484 */
14851485 static void b43_radio_init2055(struct b43_wldev *dev)
14861486 {
@@ -1499,7 +1499,7 @@ static void b43_radio_init2055(struct b43_wldev *dev) · 12 unmodified lines
14991499 * Samples
15001500 **************************************************/
15011501
1502−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/LoadSampleTable */
1502+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/LoadSampleTable */
15031503 static int b43_nphy_load_samples(struct b43_wldev *dev,
15041504 struct cordic_iq *samples, u16 len) {
15051505 struct b43_phy_n *nphy = dev->phy.n;
@@ -1526,7 +1526,7 @@ static int b43_nphy_load_samples(struct b43_wldev *dev, · 20 unmodified lines
15261526 return 0;
15271527 }
15281528
1529−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GenLoadSamples */
1529+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/GenLoadSamples */
15301530 static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max,
15311531 bool test)
15321532 {
@@ -1569,7 +1569,7 @@ static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max, · 36 unmodified lines
15691569 return (i < 0) ? 0 : len;
15701570 }
15711571
1572−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RunSamples */
1572+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RunSamples */
15731573 static void b43_nphy_run_samples(struct b43_wldev *dev, u16 samps, u16 loops,
15741574 u16 wait, bool iqmode, bool dac_test,
15751575 bool modify_bbmult)
@@ -1650,7 +1650,7 @@ static void b43_nphy_run_samples(struct b43_wldev *dev, u16 samps, u16 loops, · 74 unmodified lines
16501650 * RSSI
16511651 **************************************************/
16521652
1653−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ScaleOffsetRssi */
1653+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ScaleOffsetRssi */
16541654 static void b43_nphy_scale_offset_rssi(struct b43_wldev *dev, u16 scale,
16551655 s8 offset, u8 core,
16561656 enum n_rail_type rail,
@@ -1895,7 +1895,7 @@ static void b43_nphy_rev2_rssi_select(struct b43_wldev *dev, u8 code, · 238 unmodified lines
18951895 }
18961896 }
18971897
1898−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSISel */
1898+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSISel */
18991899 static void b43_nphy_rssi_select(struct b43_wldev *dev, u8 code,
19001900 enum n_rssi_type type)
19011901 {
@@ -1907,7 +1907,7 @@ static void b43_nphy_rssi_select(struct b43_wldev *dev, u8 code, · 5 unmodified lines
19071907 b43_nphy_rev2_rssi_select(dev, code, type);
19081908 }
19091909
1910−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRssi2055Vcm */
1910+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRssi2055Vcm */
19111911 static void b43_nphy_set_rssi_2055_vcm(struct b43_wldev *dev,
19121912 enum n_rssi_type rssi_type, u8 *buf)
19131913 {
@@ -1936,7 +1936,7 @@ static void b43_nphy_set_rssi_2055_vcm(struct b43_wldev *dev, · 22 unmodified lines
19361936 }
19371937 }
19381938
1939−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/PollRssi */
1939+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/PollRssi */
19401940 static int b43_nphy_poll_rssi(struct b43_wldev *dev, enum n_rssi_type rssi_type,
19411941 s32 *buf, u8 nsamp)
19421942 {
@@ -2025,7 +2025,7 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, enum n_rssi_type rssi_type, · 82 unmodified lines
20252025 return out;
20262026 }
20272027
2028−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
2028+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
20292029 static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
20302030 {
20312031 struct b43_phy *phy = &dev->phy;
@@ -2287,7 +2287,7 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev) · 255 unmodified lines
22872287 b43_nphy_write_clip_detection(dev, clip_state);
22882288 }
22892289
2290−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */
2290+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */
22912291 static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, enum n_rssi_type type)
22922292 {
22932293 int i, j, vcm;
@@ -2453,7 +2453,7 @@ static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, enum n_rssi_type type) · 159 unmodified lines
24532453
24542454 /*
24552455 * RSSI Calibration
2456− * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal
2456+ * https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal
24572457 */
24582458 static void b43_nphy_rssi_cal(struct b43_wldev *dev)
24592459 {
@@ -2680,7 +2680,7 @@ static void b43_nphy_gain_ctl_workarounds_rev1_2(struct b43_wldev *dev) · 220 unmodified lines
26802680 b43_phy_maskset(dev, B43_PHY_N(0xC5D), 0xFF80, 4);
26812681 }
26822682
2683−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */
2683+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */
26842684 static void b43_nphy_gain_ctl_workarounds(struct b43_wldev *dev)
26852685 {
26862686 if (dev->phy.rev >= 19)
@@ -3433,7 +3433,7 @@ static void b43_nphy_workarounds_rev1_2(struct b43_wldev *dev) · 746 unmodified lines
34333433 B43_NPHY_FINERX2_CGC_DECGC);
34343434 }
34353435
3436−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */
3436+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */
34373437 static void b43_nphy_workarounds(struct b43_wldev *dev)
34383438 {
34393439 struct b43_phy *phy = &dev->phy;
@@ -3468,7 +3468,7 @@ static void b43_nphy_workarounds(struct b43_wldev *dev) · 28 unmodified lines
34683468
34693469 /*
34703470 * Transmits a known value for LO calibration
3471− * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone
3471+ * https://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone
34723472 */
34733473 static int b43_nphy_tx_tone(struct b43_wldev *dev, u32 freq, u16 max_val,
34743474 bool iqmode, bool dac_test, bool modify_bbmult)
@@ -3481,7 +3481,7 @@ static int b43_nphy_tx_tone(struct b43_wldev *dev, u32 freq, u16 max_val, · 6 unmodified lines
34813481 return 0;
34823482 }
34833483
3484−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */
3484+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */
34853485 static void b43_nphy_update_txrx_chain(struct b43_wldev *dev)
34863486 {
34873487 struct b43_phy_n *nphy = dev->phy.n;
@@ -3509,7 +3509,7 @@ static void b43_nphy_update_txrx_chain(struct b43_wldev *dev) · 21 unmodified lines
35093509 ~B43_NPHY_RFSEQMODE_CAOVER);
35103510 }
35113511
3512−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */
3512+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */
35133513 static void b43_nphy_stop_playback(struct b43_wldev *dev)
35143514 {
35153515 struct b43_phy *phy = &dev->phy;
@@ -3546,7 +3546,7 @@ static void b43_nphy_stop_playback(struct b43_wldev *dev) · 30 unmodified lines
35463546 b43_nphy_stay_in_carrier_search(dev, 0);
35473547 }
35483548
3549−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */
3549+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */
35503550 static void b43_nphy_iq_cal_gain_params(struct b43_wldev *dev, u16 core,
35513551 struct nphy_txgains target,
35523552 struct nphy_iqcal_params *params)
@@ -3595,7 +3595,7 @@ static void b43_nphy_iq_cal_gain_params(struct b43_wldev *dev, u16 core, · 42 unmodified lines
35953595 * Tx and Rx
35963596 **************************************************/
35973597
3598−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlEnable */
3598+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlEnable */
35993599 static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable)
36003600 {
36013601 struct b43_phy *phy = &dev->phy;
@@ -3732,7 +3732,7 @@ static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable) · 130 unmodified lines
37323732 b43_nphy_stay_in_carrier_search(dev, 0);
37333733 }
37343734
3735−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrFix */
3735+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrFix */
37363736 static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
37373737 {
37383738 struct b43_phy *phy = &dev->phy;
@@ -3926,7 +3926,7 @@ static void b43_nphy_ipa_internal_tssi_setup(struct b43_wldev *dev) · 187 unmodified lines
39263926 /*
39273927 * Stop radio and transmit known signal. Then check received signal strength to
39283928 * get TSSI (Transmit Signal Strength Indicator).
3929− * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlIdleTssi
3929+ * https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlIdleTssi
39303930 */
39313931 static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev)
39323932 {
@@ -3978,7 +3978,7 @@ static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev) · 45 unmodified lines
39783978 nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF;
39793979 }
39803980
3981−/* http://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */
3981+/* https://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */
39823982 static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev)
39833983 {
39843984 struct b43_phy_n *nphy = dev->phy.n;
@@ -4039,7 +4039,7 @@ static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev) · 54 unmodified lines
40394039 }
40404040 }
40414041
4042−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */
4042+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */
40434043 static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)
40444044 {
40454045 struct b43_phy *phy = &dev->phy;
@@ -4272,7 +4272,7 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev) · 226 unmodified lines
42724272 }
42734273 }
42744274
4275−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/PA%20override */
4275+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/PA%20override */
42764276 static void b43_nphy_pa_override(struct b43_wldev *dev, bool enable)
42774277 {
42784278 struct b43_phy_n *nphy = dev->phy.n;
@@ -4310,7 +4310,7 @@ static void b43_nphy_pa_override(struct b43_wldev *dev, bool enable) · 31 unmodified lines
43104310
43114311 /*
43124312 * TX low-pass filter bandwidth setup
4313− * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxLpFbw
4313+ * https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxLpFbw
43144314 */
43154315 static void b43_nphy_tx_lpf_bw(struct b43_wldev *dev)
43164316 {
@@ -4333,7 +4333,7 @@ static void b43_nphy_tx_lpf_bw(struct b43_wldev *dev) · 16 unmodified lines
43334333 }
43344334 }
43354335
4336−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */
4336+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */
43374337 static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est,
43384338 u16 samps, u8 time, bool wait)
43394339 {
@@ -4372,7 +4372,7 @@ static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est, · 32 unmodified lines
43724372 memset(est, 0, sizeof(*est));
43734373 }
43744374
4375−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqCoeffs */
4375+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqCoeffs */
43764376 static void b43_nphy_rx_iq_coeffs(struct b43_wldev *dev, bool write,
43774377 struct b43_phy_n_iq_comp *pcomp)
43784378 {
@@ -4391,7 +4391,7 @@ static void b43_nphy_rx_iq_coeffs(struct b43_wldev *dev, bool write, · 12 unmodified lines
43914391
43924392 #if 0
43934393 /* Ready but not used anywhere */
4394−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhyCleanup */
4394+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhyCleanup */
43954395 static void b43_nphy_rx_cal_phy_cleanup(struct b43_wldev *dev, u8 core)
43964396 {
43974397 u16 *regs = dev->phy.n->tx_rx_cal_phy_saveregs;
@@ -4414,7 +4414,7 @@ static void b43_nphy_rx_cal_phy_cleanup(struct b43_wldev *dev, u8 core) · 16 unmodified lines
44144414 b43_phy_write(dev, B43_NPHY_PAPD_EN1, regs[10]);
44154415 }
44164416
4417−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhySetup */
4417+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhySetup */
44184418 static void b43_nphy_rx_cal_phy_setup(struct b43_wldev *dev, u8 core)
44194419 {
44204420 u8 rxval, txval;
@@ -4476,7 +4476,7 @@ static void b43_nphy_rx_cal_phy_setup(struct b43_wldev *dev, u8 core) · 55 unmodified lines
44764476 }
44774477 #endif
44784478
4479−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalcRxIqComp */
4479+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalcRxIqComp */
44804480 static void b43_nphy_calc_rx_iq_comp(struct b43_wldev *dev, u8 mask)
44814481 {
44824482 int i;
@@ -4574,7 +4574,7 @@ static void b43_nphy_calc_rx_iq_comp(struct b43_wldev *dev, u8 mask) · 91 unmodified lines
45744574 b43_nphy_rx_iq_coeffs(dev, true, &new);
45754575 }
45764576
4577−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxIqWar */
4577+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxIqWar */
45784578 static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev)
45794579 {
45804580 u16 array[4];
@@ -4586,7 +4586,7 @@ static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev) · 5 unmodified lines
45864586 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_NPHY_TXIQW3, array[3]);
45874587 }
45884588
4589−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */
4589+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */
45904590 static void b43_nphy_spur_workaround(struct b43_wldev *dev)
45914591 {
45924592 struct b43_phy_n *nphy = dev->phy.n;
@@ -4645,7 +4645,7 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev) · 52 unmodified lines
46454645 b43_nphy_stay_in_carrier_search(dev, 0);
46464646 }
46474647
4648−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */
4648+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */
46494649 static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev)
46504650 {
46514651 struct b43_phy_n *nphy = dev->phy.n;
@@ -4713,7 +4713,7 @@ static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev) · 61 unmodified lines
47134713
47144714 /*
47154715 * Restore RSSI Calibration
4716− * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreRssiCal
4716+ * https://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreRssiCal
47174717 */
47184718 static void b43_nphy_restore_rssi_cal(struct b43_wldev *dev)
47194719 {
@@ -4822,7 +4822,7 @@ static void b43_nphy_tx_cal_radio_setup_rev7(struct b43_wldev *dev) · 102 unmodified lines
48224822 }
48234823 }
48244824
4825−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalRadioSetup */
4825+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalRadioSetup */
48264826 static void b43_nphy_tx_cal_radio_setup(struct b43_wldev *dev)
48274827 {
48284828 struct b43_phy *phy = &dev->phy;
@@ -4921,7 +4921,7 @@ static void b43_nphy_tx_cal_radio_setup(struct b43_wldev *dev) · 92 unmodified lines
49214921 }
49224922 }
49234923
4924−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */
4924+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */
49254925 static void b43_nphy_update_tx_cal_ladder(struct b43_wldev *dev, u16 core)
49264926 {
49274927 struct b43_phy_n *nphy = dev->phy.n;
@@ -4955,14 +4955,14 @@ static void b43_nphy_pa_set_tx_dig_filter(struct b43_wldev *dev, u16 offset, · 27 unmodified lines
49554955 b43_phy_write(dev, offset, filter[i]);
49564956 }
49574957
4958−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ExtPaSetTxDigiFilts */
4958+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ExtPaSetTxDigiFilts */
49594959 static void b43_nphy_ext_pa_set_tx_dig_filters(struct b43_wldev *dev)
49604960 {
49614961 b43_nphy_pa_set_tx_dig_filter(dev, 0x2C5,
49624962 tbl_tx_filter_coef_rev4[2]);
49634963 }
49644964
4965−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IpaSetTxDigiFilts */
4965+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/IpaSetTxDigiFilts */
49664966 static void b43_nphy_int_pa_set_tx_dig_filters(struct b43_wldev *dev)
49674967 {
49684968 /* B43_NPHY_TXF_20CO_S0A1, B43_NPHY_TXF_40CO_S0A1, unknown */
@@ -5002,7 +5002,7 @@ static void b43_nphy_int_pa_set_tx_dig_filters(struct b43_wldev *dev) · 33 unmodified lines
50025002 }
50035003 }
50045004
5005−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetTxGain */
5005+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/GetTxGain */
50065006 static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev)
50075007 {
50085008 struct b43_phy_n *nphy = dev->phy.n;
@@ -5077,7 +5077,7 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev) · 68 unmodified lines
50775077 return target;
50785078 }
50795079
5080−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */
5080+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */
50815081 static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev *dev)
50825082 {
50835083 u16 *regs = dev->phy.n->tx_rx_cal_phy_saveregs;
@@ -5106,7 +5106,7 @@ static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev *dev) · 22 unmodified lines
51065106 }
51075107 }
51085108
5109−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */
5109+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */
51105110 static void b43_nphy_tx_cal_phy_setup(struct b43_wldev *dev)
51115111 {
51125112 struct b43_phy *phy = &dev->phy;
@@ -5207,7 +5207,7 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev *dev) · 94 unmodified lines
52075207 }
52085208 }
52095209
5210−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SaveCal */
5210+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SaveCal */
52115211 static void b43_nphy_save_cal(struct b43_wldev *dev)
52125212 {
52135213 struct b43_phy *phy = &dev->phy;
@@ -5278,7 +5278,7 @@ static void b43_nphy_save_cal(struct b43_wldev *dev) · 64 unmodified lines
52785278 b43_nphy_stay_in_carrier_search(dev, 0);
52795279 }
52805280
5281−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */
5281+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */
52825282 static void b43_nphy_restore_cal(struct b43_wldev *dev)
52835283 {
52845284 struct b43_phy *phy = &dev->phy;
@@ -5366,7 +5366,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev) · 81 unmodified lines
53665366 b43_nphy_rx_iq_coeffs(dev, true, rxcal_coeffs);
53675367 }
53685368
5369−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalTxIqlo */
5369+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalTxIqlo */
53705370 static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
53715371 struct nphy_txgains target,
53725372 bool full, bool mphase)
@@ -5599,7 +5599,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev, · 226 unmodified lines
55995599 return error;
56005600 }
56015601
5602−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ReapplyTxCalCoeffs */
5602+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ReapplyTxCalCoeffs */
56035603 static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
56045604 {
56055605 struct b43_phy_n *nphy = dev->phy.n;
@@ -5634,7 +5634,7 @@ static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev) · 28 unmodified lines
56345634 }
56355635 }
56365636
5637−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIqRev2 */
5637+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIqRev2 */
56385638 static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
56395639 struct nphy_txgains target, u8 type, bool debug)
56405640 {
@@ -5821,7 +5821,7 @@ static int b43_nphy_rev3_cal_rx_iq(struct b43_wldev *dev, · 180 unmodified lines
58215821 return -1;
58225822 }
58235823
5824−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIq */
5824+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIq */
58255825 static int b43_nphy_cal_rx_iq(struct b43_wldev *dev,
58265826 struct nphy_txgains target, u8 type, bool debug)
58275827 {
@@ -5834,7 +5834,7 @@ static int b43_nphy_cal_rx_iq(struct b43_wldev *dev, · 6 unmodified lines
58345834 return b43_nphy_rev2_cal_rx_iq(dev, target, type, debug);
58355835 }
58365836
5837−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreSetState */
5837+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreSetState */
58385838 static void b43_nphy_set_rx_core_state(struct b43_wldev *dev, u8 mask)
58395839 {
58405840 struct b43_phy *phy = &dev->phy;
@@ -5939,7 +5939,7 @@ static enum b43_txpwr_result b43_nphy_op_recalc_txpower(struct b43_wldev *dev, · 98 unmodified lines
59395939 * N-PHY init
59405940 **************************************************/
59415941
5942−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */
5942+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */
59435943 static void b43_nphy_update_mimo_config(struct b43_wldev *dev, s32 preamble)
59445944 {
59455945 u16 mimocfg = b43_phy_read(dev, B43_NPHY_MIMOCFG);
@@ -5953,7 +5953,7 @@ static void b43_nphy_update_mimo_config(struct b43_wldev *dev, s32 preamble) · 7 unmodified lines
59535953 b43_phy_write(dev, B43_NPHY_MIMOCFG, mimocfg);
59545954 }
59555955
5956−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BPHYInit */
5956+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/BPHYInit */
59575957 static void b43_nphy_bphy_init(struct b43_wldev *dev)
59585958 {
59595959 unsigned int i;
@@ -5972,7 +5972,7 @@ static void b43_nphy_bphy_init(struct b43_wldev *dev) · 12 unmodified lines
59725972 b43_phy_write(dev, B43_PHY_N_BMODE(0x38), 0x668);
59735973 }
59745974
5975−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SuperSwitchInit */
5975+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SuperSwitchInit */
59765976 static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)
59775977 {
59785978 if (dev->phy.rev >= 7)
@@ -6246,7 +6246,7 @@ static void b43_chantab_phy_upload(struct b43_wldev *dev, · 267 unmodified lines
62466246 b43_phy_write(dev, B43_NPHY_BW6, e->phy_bw6);
62476247 }
62486248
6249−/* http://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */
6249+/* https://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */
62506250 static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid)
62516251 {
62526252 switch (dev->dev->bus_type) {
@@ -6265,7 +6265,7 @@ static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid) · 12 unmodified lines
62656265 }
62666266 }
62676267
6268−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */
6268+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */
62696269 static void b43_nphy_channel_setup(struct b43_wldev *dev,
62706270 const struct b43_phy_n_sfo_cfg *e,
62716271 struct ieee80211_channel *new_channel)
@@ -6372,7 +6372,7 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev, · 100 unmodified lines
63726372 b43_nphy_spur_workaround(dev);
63736373 }
63746374
6375−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetChanspec */
6375+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SetChanspec */
63766376 static int b43_nphy_set_channel(struct b43_wldev *dev,
63776377 struct ieee80211_channel *channel,
63786378 enum nl80211_channel_type channel_type)
@@ -6589,7 +6589,7 @@ static void b43_nphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value) · 210 unmodified lines
65896589 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
65906590 }
65916591
6592−/* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
6592+/* https://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
65936593 static void b43_nphy_op_software_rfkill(struct b43_wldev *dev,
65946594 bool blocked)
65956595 {
@@ -6643,7 +6643,7 @@ static void b43_nphy_op_software_rfkill(struct b43_wldev *dev, · 47 unmodified lines
66436643 }
66446644 }
66456645
6646−/* http://bcm-v4.sipsolutions.net/802.11/PHY/Anacore */
6646+/* https://bcm-v4.sipsolutions.net/802.11/PHY/Anacore */
66476647 static void b43_nphy_op_switch_analog(struct b43_wldev *dev, bool on)
66486648 {
66496649 struct b43_phy *phy = &dev->phy;
drivers/net/wireless/broadcom/b43/radio_2056.c+1−1
@@ -3072,7 +3072,7 @@ INITTABSPTS(b2056_inittab_radio_rev11); · 3071 unmodified lines
30723072 .phy_regs.phy_bw5 = r4, \
30733073 .phy_regs.phy_bw6 = r5
30743074
3075−/* http://bcm-v4.sipsolutions.net/802.11/Radio/2056/ChannelTable */
3075+/* https://bcm-v4.sipsolutions.net/802.11/Radio/2056/ChannelTable */
30763076 static const struct b43_nphy_channeltab_entry_rev3 b43_nphy_channeltab_phy_rev3[] = {
30773077 { .freq = 4920,
30783078 RADIOREGS3(0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04,
drivers/net/wireless/broadcom/b43/tables_nphy.c+2−2
@@ -3620,7 +3620,7 @@ static void b43_nphy_tables_init_rev0(struct b43_wldev *dev) · 3619 unmodified lines
36203620 ntab_upload(dev, B43_NTAB_C1_LOFEEDTH, b43_ntab_loftlt1);
36213621 }
36223622
3623−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables */
3623+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables */
36243624 void b43_nphy_tables_init(struct b43_wldev *dev)
36253625 {
36263626 if (dev->phy.rev >= 16)
@@ -3633,7 +3633,7 @@ void b43_nphy_tables_init(struct b43_wldev *dev) · 6 unmodified lines
36333633 b43_nphy_tables_init_rev0(dev);
36343634 }
36353635
3636−/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
3636+/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
36373637 static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
36383638 {
36393639 struct b43_phy *phy = &dev->phy;
drivers/net/wireless/broadcom/b43legacy/main.c+4−4
@@ -591,7 +591,7 @@ static void b43legacy_synchronize_irq(struct b43legacy_wldev *dev) · 590 unmodified lines
591591 }
592592
593593 /* DummyTransmission function, as documented on
594− * http://bcm-specs.sipsolutions.net/DummyTransmission
594+ * https://bcm-specs.sipsolutions.net/DummyTransmission
595595 */
596596 void b43legacy_dummy_transmission(struct b43legacy_wldev *dev)
597597 {
@@ -1870,7 +1870,7 @@ out: · 1272 unmodified lines
18701870 }
18711871
18721872 /* Initialize the GPIOs
1873− * http://bcm-specs.sipsolutions.net/GPIO
1873+ * https://bcm-specs.sipsolutions.net/GPIO
18741874 */
18751875 static int b43legacy_gpio_init(struct b43legacy_wldev *dev)
18761876 {
@@ -1960,7 +1960,7 @@ void b43legacy_mac_enable(struct b43legacy_wldev *dev) · 83 unmodified lines
19601960 }
19611961 }
19621962
1963−/* http://bcm-specs.sipsolutions.net/SuspendMAC */
1963+/* https://bcm-specs.sipsolutions.net/SuspendMAC */
19641964 void b43legacy_mac_suspend(struct b43legacy_wldev *dev)
19651965 {
19661966 int i;
@@ -2141,7 +2141,7 @@ static void b43legacy_chip_exit(struct b43legacy_wldev *dev) · 174 unmodified lines
21412141 }
21422142
21432143 /* Initialize the chip
2144− * http://bcm-specs.sipsolutions.net/ChipInit
2144+ * https://bcm-specs.sipsolutions.net/ChipInit
21452145 */
21462146 static int b43legacy_chip_init(struct b43legacy_wldev *dev)
21472147 {
drivers/net/wireless/broadcom/b43legacy/phy.c+4−4
@@ -129,7 +129,7 @@ void b43legacy_phy_calibrate(struct b43legacy_wldev *dev) · 128 unmodified lines
129129 }
130130
131131 /* initialize B PHY power control
132− * as described in http://bcm-specs.sipsolutions.net/InitPowerControl
132+ * as described in https://bcm-specs.sipsolutions.net/InitPowerControl
133133 */
134134 static void b43legacy_phy_init_pctl(struct b43legacy_wldev *dev)
135135 {
@@ -1461,7 +1461,7 @@ void b43legacy_phy_set_baseband_attenuation(struct b43legacy_wldev *dev, · 1325 unmodified lines
14611461 b43legacy_phy_write(dev, 0x0060, value);
14621462 }
14631463
1464−/* http://bcm-specs.sipsolutions.net/LocalOscillator/Measure */
1464+/* https://bcm-specs.sipsolutions.net/LocalOscillator/Measure */
14651465 void b43legacy_phy_lo_g_measure(struct b43legacy_wldev *dev)
14661466 {
14671467 static const u8 pairorder[10] = { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8 };
@@ -1721,7 +1721,7 @@ void b43legacy_phy_lo_mark_all_unused(struct b43legacy_wldev *dev) · 253 unmodified lines
17211721 }
17221722 }
17231723
1724−/* http://bcm-specs.sipsolutions.net/EstimatePowerOut
1724+/* https://bcm-specs.sipsolutions.net/EstimatePowerOut
17251725 * This function converts a TSSI value to dBm in Q5.2
17261726 */
17271727 static s8 b43legacy_phy_estimate_power_out(struct b43legacy_wldev *dev, s8 tssi)
@@ -1747,7 +1747,7 @@ static s8 b43legacy_phy_estimate_power_out(struct b43legacy_wldev *dev, s8 tssi) · 19 unmodified lines
17471747 return dbm;
17481748 }
17491749
1750−/* http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */
1750+/* https://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */
17511751 void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
17521752 {
17531753 struct b43legacy_phy *phy = &dev->phy;
drivers/net/wireless/broadcom/b43legacy/radio.c+4−4
@@ -313,14 +313,14 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev) · 312 unmodified lines
313313 return ret[channel - 1];
314314 }
315315
316−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
316+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
317317 void b43legacy_nrssi_hw_write(struct b43legacy_wldev *dev, u16 offset, s16 val)
318318 {
319319 b43legacy_phy_write(dev, B43legacy_PHY_NRSSILT_CTRL, offset);
320320 b43legacy_phy_write(dev, B43legacy_PHY_NRSSILT_DATA, (u16)val);
321321 }
322322
323−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
323+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
324324 s16 b43legacy_nrssi_hw_read(struct b43legacy_wldev *dev, u16 offset)
325325 {
326326 u16 val;
@@ -331,7 +331,7 @@ s16 b43legacy_nrssi_hw_read(struct b43legacy_wldev *dev, u16 offset) · 4 unmodified lines
331331 return (s16)val;
332332 }
333333
334−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
334+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
335335 void b43legacy_nrssi_hw_update(struct b43legacy_wldev *dev, u16 val)
336336 {
337337 u16 i;
@@ -345,7 +345,7 @@ void b43legacy_nrssi_hw_update(struct b43legacy_wldev *dev, u16 val) · 7 unmodified lines
345345 }
346346 }
347347
348−/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
348+/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
349349 void b43legacy_nrssi_mem_update(struct b43legacy_wldev *dev)
350350 {
351351 struct b43legacy_phy *phy = &dev->phy;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c+8−0
@@ -84,6 +84,8 @@ · 83 unmodified lines
8484
8585 #define BRCMF_ND_INFO_TIMEOUT msecs_to_jiffies(2000)
8686
87+#define BRCMF_PS_MAX_TIMEOUT_MS 2000
88+
8789 #define BRCMF_ASSOC_PARAMS_FIXED_SIZE \
8890 (sizeof(struct brcmf_assoc_params_le) - sizeof(u16))
8991
@@ -2942,6 +2944,12 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, · 2852 unmodified lines
29422944 else
29432945 bphy_err(drvr, "error (%d)\n", err);
29442946 }
2947+
2948+ err = brcmf_fil_iovar_int_set(ifp, "pm2_sleep_ret",
2949+ min_t(u32, timeout, BRCMF_PS_MAX_TIMEOUT_MS));
2950+ if (err)
2951+ bphy_err(drvr, "Unable to set pm timeout, (%d)\n", err);
2952+
29452953 done:
29462954 brcmf_dbg(TRACE, "Exit\n");
29472955 return err;
drivers/net/wireless/cisco/airo.c+19−20
@@ -74,16 +74,19 @@ MODULE_DEVICE_TABLE(pci, card_ids); · 73 unmodified lines
7474
7575 static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *);
7676 static void airo_pci_remove(struct pci_dev *);
77−static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state);
78−static int airo_pci_resume(struct pci_dev *pdev);
77+static int __maybe_unused airo_pci_suspend(struct device *dev);
78+static int __maybe_unused airo_pci_resume(struct device *dev);
79+
80+static SIMPLE_DEV_PM_OPS(airo_pci_pm_ops,
81+ airo_pci_suspend,
82+ airo_pci_resume);
7983
8084 static struct pci_driver airo_driver = {
81− .name = DRV_NAME,
82− .id_table = card_ids,
83− .probe = airo_pci_probe,
84− .remove = airo_pci_remove,
85− .suspend = airo_pci_suspend,
86− .resume = airo_pci_resume,
85+ .name = DRV_NAME,
86+ .id_table = card_ids,
87+ .probe = airo_pci_probe,
88+ .remove = airo_pci_remove,
89+ .driver.pm = &airo_pci_pm_ops,
8790 };
8891 #endif /* CONFIG_PCI */
8992
@@ -5573,9 +5576,9 @@ static void airo_pci_remove(struct pci_dev *pdev) · 5483 unmodified lines
55735576 pci_disable_device(pdev);
55745577 }
55755578
5576−static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5579+static int __maybe_unused airo_pci_suspend(struct device *dev_d)
55775580 {
5578− struct net_device *dev = pci_get_drvdata(pdev);
5581+ struct net_device *dev = dev_get_drvdata(dev_d);
55795582 struct airo_info *ai = dev->ml_priv;
55805583 Cmd cmd;
55815584 Resp rsp;
@@ -5591,25 +5594,21 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) · 9 unmodified lines
55915594 return -EAGAIN;
55925595 disable_MAC(ai, 0);
55935596 netif_device_detach(dev);
5594− ai->power = state;
5597+ ai->power = PMSG_SUSPEND;
55955598 cmd.cmd = HOSTSLEEP;
55965599 issuecommand(ai, &cmd, &rsp);
55975600
5598− pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
5599− pci_save_state(pdev);
5600− pci_set_power_state(pdev, pci_choose_state(pdev, state));
5601+ device_wakeup_enable(dev_d);
56015602 return 0;
56025603 }
56035604
5604−static int airo_pci_resume(struct pci_dev *pdev)
5605+static int __maybe_unused airo_pci_resume(struct device *dev_d)
56055606 {
5606− struct net_device *dev = pci_get_drvdata(pdev);
5607+ struct net_device *dev = dev_get_drvdata(dev_d);
56075608 struct airo_info *ai = dev->ml_priv;
5608− pci_power_t prev_state = pdev->current_state;
5609+ pci_power_t prev_state = to_pci_dev(dev_d)->current_state;
56095610
5610− pci_set_power_state(pdev, PCI_D0);
5611− pci_restore_state(pdev);
5612− pci_enable_wake(pdev, PCI_D0, 0);
5611+ device_wakeup_disable(dev_d);
56135612
56145613 if (prev_state != PCI_D1) {
56155614 reset_card(dev, 0);
drivers/net/wireless/intel/ipw2x00/Kconfig+2−2
@@ -28,7 +28,7 @@ config IPW2100 · 27 unmodified lines
2828 You will also very likely need the Wireless Tools in order to
2929 configure your card:
3030
31− <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
31+ <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
3232
3333 It is recommended that you compile this driver as a module (M)
3434 rather than built-in (Y). This driver requires firmware at device
@@ -90,7 +90,7 @@ config IPW2200 · 55 unmodified lines
9090 You will also very likely need the Wireless Tools in order to
9191 configure your card:
9292
93− <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
93+ <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
9494
9595 It is recommended that you compile this driver as a module (M)
9696 rather than built-in (Y). This driver requires firmware at device
drivers/net/wireless/intel/ipw2x00/ipw2100.c+60−63
@@ -2295,10 +2295,11 @@ static int ipw2100_alloc_skb(struct ipw2100_priv *priv, · 2294 unmodified lines
22952295 return -ENOMEM;
22962296
22972297 packet->rxp = (struct ipw2100_rx *)packet->skb->data;
2298− packet->dma_addr = pci_map_single(priv->pci_dev, packet->skb->data,
2298+ packet->dma_addr = dma_map_single(&priv->pci_dev->dev,
2299+ packet->skb->data,
22992300 sizeof(struct ipw2100_rx),
2300− PCI_DMA_FROMDEVICE);
2301− if (pci_dma_mapping_error(priv->pci_dev, packet->dma_addr)) {
2301+ DMA_FROM_DEVICE);
2302+ if (dma_mapping_error(&priv->pci_dev->dev, packet->dma_addr)) {
23022303 dev_kfree_skb(packet->skb);
23032304 return -ENOMEM;
23042305 }
@@ -2479,9 +2480,8 @@ static void isr_rx(struct ipw2100_priv *priv, int i, · 174 unmodified lines
24792480 return;
24802481 }
24812482
2482− pci_unmap_single(priv->pci_dev,
2483− packet->dma_addr,
2484− sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE);
2483+ dma_unmap_single(&priv->pci_dev->dev, packet->dma_addr,
2484+ sizeof(struct ipw2100_rx), DMA_FROM_DEVICE);
24852485
24862486 skb_put(packet->skb, status->frame_size);
24872487
@@ -2563,8 +2563,8 @@ static void isr_rx_monitor(struct ipw2100_priv *priv, int i, · 75 unmodified lines
25632563 return;
25642564 }
25652565
2566− pci_unmap_single(priv->pci_dev, packet->dma_addr,
2567− sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE);
2566+ dma_unmap_single(&priv->pci_dev->dev, packet->dma_addr,
2567+ sizeof(struct ipw2100_rx), DMA_FROM_DEVICE);
25682568 memmove(packet->skb->data + sizeof(struct ipw_rt_hdr),
25692569 packet->skb->data, status->frame_size);
25702570
@@ -2689,9 +2689,9 @@ static void __ipw2100_rx_process(struct ipw2100_priv *priv) · 118 unmodified lines
26892689
26902690 /* Sync the DMA for the RX buffer so CPU is sure to get
26912691 * the correct values */
2692− pci_dma_sync_single_for_cpu(priv->pci_dev, packet->dma_addr,
2693− sizeof(struct ipw2100_rx),
2694− PCI_DMA_FROMDEVICE);
2692+ dma_sync_single_for_cpu(&priv->pci_dev->dev, packet->dma_addr,
2693+ sizeof(struct ipw2100_rx),
2694+ DMA_FROM_DEVICE);
26952695
26962696 if (unlikely(ipw2100_corruption_check(priv, i))) {
26972697 ipw2100_corruption_detected(priv, i);
@@ -2923,9 +2923,8 @@ static int __ipw2100_tx_process(struct ipw2100_priv *priv) · 225 unmodified lines
29232923 (packet->index + 1 + i) % txq->entries,
29242924 tbd->host_addr, tbd->buf_length);
29252925
2926− pci_unmap_single(priv->pci_dev,
2927− tbd->host_addr,
2928− tbd->buf_length, PCI_DMA_TODEVICE);
2926+ dma_unmap_single(&priv->pci_dev->dev, tbd->host_addr,
2927+ tbd->buf_length, DMA_TO_DEVICE);
29292928 }
29302929
29312930 libipw_txb_free(packet->info.d_struct.txb);
@@ -3165,15 +3164,13 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) · 233 unmodified lines
31653164 tbd->buf_length = packet->info.d_struct.txb->
31663165 fragments[i]->len - LIBIPW_3ADDR_LEN;
31673166
3168− tbd->host_addr = pci_map_single(priv->pci_dev,
3167+ tbd->host_addr = dma_map_single(&priv->pci_dev->dev,
31693168 packet->info.d_struct.
3170− txb->fragments[i]->
3171− data +
3169+ txb->fragments[i]->data +
31723170 LIBIPW_3ADDR_LEN,
31733171 tbd->buf_length,
3174− PCI_DMA_TODEVICE);
3175− if (pci_dma_mapping_error(priv->pci_dev,
3176− tbd->host_addr)) {
3172+ DMA_TO_DEVICE);
3173+ if (dma_mapping_error(&priv->pci_dev->dev, tbd->host_addr)) {
31773174 IPW_DEBUG_TX("dma mapping error\n");
31783175 break;
31793176 }
@@ -3182,10 +3179,10 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) · 2 unmodified lines
31823179 txq->next, tbd->host_addr,
31833180 tbd->buf_length);
31843181
3185− pci_dma_sync_single_for_device(priv->pci_dev,
3186− tbd->host_addr,
3187− tbd->buf_length,
3188− PCI_DMA_TODEVICE);
3182+ dma_sync_single_for_device(&priv->pci_dev->dev,
3183+ tbd->host_addr,
3184+ tbd->buf_length,
3185+ DMA_TO_DEVICE);
31893186
31903187 txq->next++;
31913188 txq->next %= txq->entries;
@@ -3440,9 +3437,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) · 248 unmodified lines
34403437 return -ENOMEM;
34413438
34423439 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3443− v = pci_zalloc_consistent(priv->pci_dev,
3444− sizeof(struct ipw2100_cmd_header),
3445− &p);
3440+ v = dma_alloc_coherent(&priv->pci_dev->dev,
3441+ sizeof(struct ipw2100_cmd_header), &p,
3442+ GFP_KERNEL);
34463443 if (!v) {
34473444 printk(KERN_ERR DRV_NAME ": "
34483445 "%s: PCI alloc failed for msg "
@@ -3461,11 +3458,10 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) · 12 unmodified lines
34613458 return 0;
34623459
34633460 for (j = 0; j < i; j++) {
3464− pci_free_consistent(priv->pci_dev,
3465− sizeof(struct ipw2100_cmd_header),
3466− priv->msg_buffers[j].info.c_struct.cmd,
3467− priv->msg_buffers[j].info.c_struct.
3468− cmd_phys);
3461+ dma_free_coherent(&priv->pci_dev->dev,
3462+ sizeof(struct ipw2100_cmd_header),
3463+ priv->msg_buffers[j].info.c_struct.cmd,
3464+ priv->msg_buffers[j].info.c_struct.cmd_phys);
34693465 }
34703466
34713467 kfree(priv->msg_buffers);
@@ -3496,11 +3492,10 @@ static void ipw2100_msg_free(struct ipw2100_priv *priv) · 24 unmodified lines
34963492 return;
34973493
34983494 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3499− pci_free_consistent(priv->pci_dev,
3500− sizeof(struct ipw2100_cmd_header),
3501− priv->msg_buffers[i].info.c_struct.cmd,
3502− priv->msg_buffers[i].info.c_struct.
3503− cmd_phys);
3495+ dma_free_coherent(&priv->pci_dev->dev,
3496+ sizeof(struct ipw2100_cmd_header),
3497+ priv->msg_buffers[i].info.c_struct.cmd,
3498+ priv->msg_buffers[i].info.c_struct.cmd_phys);
35043499 }
35053500
35063501 kfree(priv->msg_buffers);
@@ -4323,7 +4318,8 @@ static int status_queue_allocate(struct ipw2100_priv *priv, int entries) · 816 unmodified lines
43234318 IPW_DEBUG_INFO("enter\n");
43244319
43254320 q->size = entries * sizeof(struct ipw2100_status);
4326− q->drv = pci_zalloc_consistent(priv->pci_dev, q->size, &q->nic);
4321+ q->drv = dma_alloc_coherent(&priv->pci_dev->dev, q->size, &q->nic,
4322+ GFP_KERNEL);
43274323 if (!q->drv) {
43284324 IPW_DEBUG_WARNING("Can not allocate status queue.\n");
43294325 return -ENOMEM;
@@ -4339,9 +4335,10 @@ static void status_queue_free(struct ipw2100_priv *priv) · 9 unmodified lines
43394335 IPW_DEBUG_INFO("enter\n");
43404336
43414337 if (priv->status_queue.drv) {
4342− pci_free_consistent(priv->pci_dev, priv->status_queue.size,
4343− priv->status_queue.drv,
4344− priv->status_queue.nic);
4338+ dma_free_coherent(&priv->pci_dev->dev,
4339+ priv->status_queue.size,
4340+ priv->status_queue.drv,
4341+ priv->status_queue.nic);
43454342 priv->status_queue.drv = NULL;
43464343 }
43474344
@@ -4357,7 +4354,8 @@ static int bd_queue_allocate(struct ipw2100_priv *priv, · 9 unmodified lines
43574354
43584355 q->entries = entries;
43594356 q->size = entries * sizeof(struct ipw2100_bd);
4360− q->drv = pci_zalloc_consistent(priv->pci_dev, q->size, &q->nic);
4357+ q->drv = dma_alloc_coherent(&priv->pci_dev->dev, q->size, &q->nic,
4358+ GFP_KERNEL);
43614359 if (!q->drv) {
43624360 IPW_DEBUG_INFO
43634361 ("can't allocate shared memory for buffer descriptors\n");
@@ -4377,7 +4375,8 @@ static void bd_queue_free(struct ipw2100_priv *priv, struct ipw2100_bd_queue *q) · 13 unmodified lines
43774375 return;
43784376
43794377 if (q->drv) {
4380− pci_free_consistent(priv->pci_dev, q->size, q->drv, q->nic);
4378+ dma_free_coherent(&priv->pci_dev->dev, q->size, q->drv,
4379+ q->nic);
43814380 q->drv = NULL;
43824381 }
43834382
@@ -4430,16 +4429,16 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv) · 46 unmodified lines
44304429
44314430 priv->tx_buffers = kmalloc_array(TX_PENDED_QUEUE_LENGTH,
44324431 sizeof(struct ipw2100_tx_packet),
4433− GFP_ATOMIC);
4432+ GFP_KERNEL);
44344433 if (!priv->tx_buffers) {
44354434 bd_queue_free(priv, &priv->tx_queue);
44364435 return -ENOMEM;
44374436 }
44384437
44394438 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4440− v = pci_alloc_consistent(priv->pci_dev,
4441− sizeof(struct ipw2100_data_header),
4442− &p);
4439+ v = dma_alloc_coherent(&priv->pci_dev->dev,
4440+ sizeof(struct ipw2100_data_header), &p,
4441+ GFP_KERNEL);
44434442 if (!v) {
44444443 printk(KERN_ERR DRV_NAME
44454444 ": %s: PCI alloc failed for tx " "buffers.\n",
@@ -4459,11 +4458,10 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv) · 13 unmodified lines
44594458 return 0;
44604459
44614460 for (j = 0; j < i; j++) {
4462− pci_free_consistent(priv->pci_dev,
4463− sizeof(struct ipw2100_data_header),
4464− priv->tx_buffers[j].info.d_struct.data,
4465− priv->tx_buffers[j].info.d_struct.
4466− data_phys);
4461+ dma_free_coherent(&priv->pci_dev->dev,
4462+ sizeof(struct ipw2100_data_header),
4463+ priv->tx_buffers[j].info.d_struct.data,
4464+ priv->tx_buffers[j].info.d_struct.data_phys);
44674465 }
44684466
44694467 kfree(priv->tx_buffers);
@@ -4540,12 +4538,10 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv) · 70 unmodified lines
45404538 priv->tx_buffers[i].info.d_struct.txb = NULL;
45414539 }
45424540 if (priv->tx_buffers[i].info.d_struct.data)
4543− pci_free_consistent(priv->pci_dev,
4544− sizeof(struct ipw2100_data_header),
4545− priv->tx_buffers[i].info.d_struct.
4546− data,
4547− priv->tx_buffers[i].info.d_struct.
4548− data_phys);
4541+ dma_free_coherent(&priv->pci_dev->dev,
4542+ sizeof(struct ipw2100_data_header),
4543+ priv->tx_buffers[i].info.d_struct.data,
4544+ priv->tx_buffers[i].info.d_struct.data_phys);
45494545 }
45504546
45514547 kfree(priv->tx_buffers);
@@ -4608,9 +4604,10 @@ static int ipw2100_rx_allocate(struct ipw2100_priv *priv) · 56 unmodified lines
46084604 return 0;
46094605
46104606 for (j = 0; j < i; j++) {
4611− pci_unmap_single(priv->pci_dev, priv->rx_buffers[j].dma_addr,
4607+ dma_unmap_single(&priv->pci_dev->dev,
4608+ priv->rx_buffers[j].dma_addr,
46124609 sizeof(struct ipw2100_rx_packet),
4613− PCI_DMA_FROMDEVICE);
4610+ DMA_FROM_DEVICE);
46144611 dev_kfree_skb(priv->rx_buffers[j].skb);
46154612 }
46164613
@@ -4662,10 +4659,10 @@ static void ipw2100_rx_free(struct ipw2100_priv *priv) · 45 unmodified lines
46624659
46634660 for (i = 0; i < RX_QUEUE_LENGTH; i++) {
46644661 if (priv->rx_buffers[i].rxp) {
4665− pci_unmap_single(priv->pci_dev,
4662+ dma_unmap_single(&priv->pci_dev->dev,
46664663 priv->rx_buffers[i].dma_addr,
46674664 sizeof(struct ipw2100_rx),
4668− PCI_DMA_FROMDEVICE);
4665+ DMA_FROM_DEVICE);
46694666 dev_kfree_skb(priv->rx_buffers[i].skb);
46704667 }
46714668 }
@@ -6196,7 +6193,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, · 1524 unmodified lines
61966193 pci_set_master(pci_dev);
61976194 pci_set_drvdata(pci_dev, priv);
61986195
6199− err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
6196+ err = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32));
62006197 if (err) {
62016198 printk(KERN_WARNING DRV_NAME
62026199 "Error calling pci_set_dma_mask.\n");
drivers/net/wireless/intel/ipw2x00/ipw2200.c+29−27
@@ -3442,8 +3442,9 @@ static void ipw_rx_queue_reset(struct ipw_priv *priv, · 3441 unmodified lines
34423442 /* In the reset function, these buffers may have been allocated
34433443 * to an SKB, so we need to unmap and free potential storage */
34443444 if (rxq->pool[i].skb != NULL) {
3445− pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,
3446− IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
3445+ dma_unmap_single(&priv->pci_dev->dev,
3446+ rxq->pool[i].dma_addr,
3447+ IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
34473448 dev_kfree_skb(rxq->pool[i].skb);
34483449 rxq->pool[i].skb = NULL;
34493450 }
@@ -3774,7 +3775,8 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, · 324 unmodified lines
37743775 return -ENOMEM;
37753776
37763777 q->bd =
3777− pci_alloc_consistent(dev, sizeof(q->bd[0]) * count, &q->q.dma_addr);
3778+ dma_alloc_coherent(&dev->dev, sizeof(q->bd[0]) * count,
3779+ &q->q.dma_addr, GFP_KERNEL);
37783780 if (!q->bd) {
37793781 IPW_ERROR("pci_alloc_consistent(%zd) failed\n",
37803782 sizeof(q->bd[0]) * count);
@@ -3816,9 +3818,10 @@ static void ipw_queue_tx_free_tfd(struct ipw_priv *priv, · 35 unmodified lines
38163818
38173819 /* unmap chunks if any */
38183820 for (i = 0; i < le32_to_cpu(bd->u.data.num_chunks); i++) {
3819− pci_unmap_single(dev, le32_to_cpu(bd->u.data.chunk_ptr[i]),
3821+ dma_unmap_single(&dev->dev,
3822+ le32_to_cpu(bd->u.data.chunk_ptr[i]),
38203823 le16_to_cpu(bd->u.data.chunk_len[i]),
3821− PCI_DMA_TODEVICE);
3824+ DMA_TO_DEVICE);
38223825 if (txq->txb[txq->q.last_used]) {
38233826 libipw_txb_free(txq->txb[txq->q.last_used]);
38243827 txq->txb[txq->q.last_used] = NULL;
@@ -3850,8 +3853,8 @@ static void ipw_queue_tx_free(struct ipw_priv *priv, struct clx2_tx_queue *txq) · 25 unmodified lines
38503853 }
38513854
38523855 /* free buffers belonging to queue itself */
3853− pci_free_consistent(dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd,
3854− q->dma_addr);
3856+ dma_free_coherent(&dev->dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd,
3857+ q->dma_addr);
38553858 kfree(txq->txb);
38563859
38573860 /* 0 fill whole structure */
@@ -5196,8 +5199,8 @@ static void ipw_rx_queue_replenish(void *data) · 1338 unmodified lines
51965199 list_del(element);
51975200
51985201 rxb->dma_addr =
5199− pci_map_single(priv->pci_dev, rxb->skb->data,
5200− IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
5202+ dma_map_single(&priv->pci_dev->dev, rxb->skb->data,
5203+ IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
52015204
52025205 list_add_tail(&rxb->list, &rxq->rx_free);
52035206 rxq->free_count++;
@@ -5230,8 +5233,9 @@ static void ipw_rx_queue_free(struct ipw_priv *priv, struct ipw_rx_queue *rxq) · 26 unmodified lines
52305233
52315234 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
52325235 if (rxq->pool[i].skb != NULL) {
5233− pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,
5234− IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
5236+ dma_unmap_single(&priv->pci_dev->dev,
5237+ rxq->pool[i].dma_addr,
5238+ IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
52355239 dev_kfree_skb(rxq->pool[i].skb);
52365240 }
52375241 }
@@ -8263,9 +8267,8 @@ static void ipw_rx(struct ipw_priv *priv) · 3025 unmodified lines
82638267 }
82648268 priv->rxq->queue[i] = NULL;
82658269
8266− pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr,
8267− IPW_RX_BUF_SIZE,
8268− PCI_DMA_FROMDEVICE);
8270+ dma_sync_single_for_cpu(&priv->pci_dev->dev, rxb->dma_addr,
8271+ IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
82698272
82708273 pkt = (struct ipw_rx_packet *)rxb->skb->data;
82718274 IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n",
@@ -8417,8 +8420,8 @@ static void ipw_rx(struct ipw_priv *priv) · 145 unmodified lines
84178420 rxb->skb = NULL;
84188421 }
84198422
8420− pci_unmap_single(priv->pci_dev, rxb->dma_addr,
8421− IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);
8423+ dma_unmap_single(&priv->pci_dev->dev, rxb->dma_addr,
8424+ IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
84228425 list_add_tail(&rxb->list, &priv->rxq->rx_used);
84238426
84248427 i = (i + 1) % RX_QUEUE_SIZE;
@@ -10217,11 +10220,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct libipw_txb *txb, · 1792 unmodified lines
1021710220 txb->fragments[i]->len - hdr_len);
1021810221
1021910222 tfd->u.data.chunk_ptr[i] =
10220− cpu_to_le32(pci_map_single
10221− (priv->pci_dev,
10222− txb->fragments[i]->data + hdr_len,
10223− txb->fragments[i]->len - hdr_len,
10224− PCI_DMA_TODEVICE));
10223+ cpu_to_le32(dma_map_single(&priv->pci_dev->dev,
10224+ txb->fragments[i]->data + hdr_len,
10225+ txb->fragments[i]->len - hdr_len,
10226+ DMA_TO_DEVICE));
1022510227 tfd->u.data.chunk_len[i] =
1022610228 cpu_to_le16(txb->fragments[i]->len - hdr_len);
1022710229 }
@@ -10251,10 +10253,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct libipw_txb *txb, · 23 unmodified lines
1025110253 dev_kfree_skb_any(txb->fragments[i]);
1025210254 txb->fragments[i] = skb;
1025310255 tfd->u.data.chunk_ptr[i] =
10254− cpu_to_le32(pci_map_single
10255− (priv->pci_dev, skb->data,
10256− remaining_bytes,
10257− PCI_DMA_TODEVICE));
10256+ cpu_to_le32(dma_map_single(&priv->pci_dev->dev,
10257+ skb->data,
10258+ remaining_bytes,
10259+ DMA_TO_DEVICE));
1025810260
1025910261 le32_add_cpu(&tfd->u.data.num_chunks, 1);
1026010262 }
@@ -11620,9 +11622,9 @@ static int ipw_pci_probe(struct pci_dev *pdev, · 1359 unmodified lines
1162011622
1162111623 pci_set_master(pdev);
1162211624
11623− err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
11625+ err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
1162411626 if (!err)
11625− err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
11627+ err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
1162611628 if (err) {
1162711629 printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n");
1162811630 goto out_pci_disable_device;
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c+1−1
@@ -480,7 +480,7 @@ void iwl_dbg_tlv_load_bin(struct device *dev, struct iwl_trans *trans) · 479 unmodified lines
480480 if (!iwlwifi_mod_params.enable_ini)
481481 return;
482482
483− res = request_firmware(&fw, "iwl-debug-yoyo.bin", dev);
483+ res = firmware_request_nowarn(&fw, "iwl-debug-yoyo.bin", dev);
484484 if (res)
485485 return;
486486
drivers/net/wireless/intersil/Kconfig+1−1
@@ -30,7 +30,7 @@ config PRISM54 · 29 unmodified lines
3030
3131 For more information refer to the p54 wiki:
3232
33− http://wireless.kernel.org/en/users/Drivers/p54
33+ http://wireless.wiki.kernel.org/en/users/Drivers/p54
3434
3535 Note: You need a motherboard with DMA support to use any of these cards
3636
drivers/net/wireless/intersil/hostap/hostap_hw.c+3−3
@@ -3366,8 +3366,8 @@ static void prism2_free_local_data(struct net_device *dev) · 3365 unmodified lines
33663366 }
33673367
33683368
3369−#if (defined(PRISM2_PCI) && defined(CONFIG_PM)) || defined(PRISM2_PCCARD)
3370−static void prism2_suspend(struct net_device *dev)
3369+#if defined(PRISM2_PCI) || defined(PRISM2_PCCARD)
3370+static void __maybe_unused prism2_suspend(struct net_device *dev)
33713371 {
33723372 struct hostap_interface *iface;
33733373 struct local_info *local;
@@ -3385,7 +3385,7 @@ static void prism2_suspend(struct net_device *dev) · 11 unmodified lines
33853385 /* Disable hardware and firmware */
33863386 prism2_hw_shutdown(dev, 0);
33873387 }
3388−#endif /* (PRISM2_PCI && CONFIG_PM) || PRISM2_PCCARD */
3388+#endif /* PRISM2_PCI || PRISM2_PCCARD */
33893389
33903390
33913391 /* These might at some point be compiled separately and used as separate
drivers/net/wireless/intersil/hostap/hostap_pci.c+10−24
@@ -403,36 +403,23 @@ static void prism2_pci_remove(struct pci_dev *pdev) · 402 unmodified lines
403403 pci_disable_device(pdev);
404404 }
405405
406−
407−#ifdef CONFIG_PM
408−static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state)
406+static int __maybe_unused prism2_pci_suspend(struct device *dev_d)
409407 {
410− struct net_device *dev = pci_get_drvdata(pdev);
408+ struct net_device *dev = dev_get_drvdata(dev_d);
411409
412410 if (netif_running(dev)) {
413411 netif_stop_queue(dev);
414412 netif_device_detach(dev);
415413 }
416414 prism2_suspend(dev);
417− pci_save_state(pdev);
418− pci_disable_device(pdev);
419− pci_set_power_state(pdev, PCI_D3hot);
420415
421416 return 0;
422417 }
423418
424−static int prism2_pci_resume(struct pci_dev *pdev)
419+static int __maybe_unused prism2_pci_resume(struct device *dev_d)
425420 {
426− struct net_device *dev = pci_get_drvdata(pdev);
427− int err;
428−
429− err = pci_enable_device(pdev);
430− if (err) {
431− printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
432− dev->name);
433− return err;
434− }
435− pci_restore_state(pdev);
421+ struct net_device *dev = dev_get_drvdata(dev_d);
422+
436423 prism2_hw_config(dev, 0);
437424 if (netif_running(dev)) {
438425 netif_device_attach(dev);
@@ -441,20 +428,19 @@ static int prism2_pci_resume(struct pci_dev *pdev) · 2 unmodified lines
441428
442429 return 0;
443430 }
444−#endif /* CONFIG_PM */
445−
446431
447432 MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
448433
434+static SIMPLE_DEV_PM_OPS(prism2_pci_pm_ops,
435+ prism2_pci_suspend,
436+ prism2_pci_resume);
437+
449438 static struct pci_driver prism2_pci_driver = {
450439 .name = "hostap_pci",
451440 .id_table = prism2_pci_id_table,
452441 .probe = prism2_pci_probe,
453442 .remove = prism2_pci_remove,
454−#ifdef CONFIG_PM
455− .suspend = prism2_pci_suspend,
456− .resume = prism2_pci_resume,
457−#endif /* CONFIG_PM */
443+ .driver.pm = &prism2_pci_pm_ops,
458444 };
459445
460446 module_pci_driver(prism2_pci_driver);
drivers/net/wireless/intersil/orinoco/Kconfig+2−2
@@ -27,7 +27,7 @@ config HERMES · 26 unmodified lines
2727
2828 You will also very likely also need the Wireless Tools in order to
2929 configure your card and that /etc/pcmcia/wireless.opts works :
30− <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>
30+ <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>
3131
3232 config HERMES_PRISM
3333 bool "Support Prism 2/2.5 chipset"
@@ -120,7 +120,7 @@ config PCMCIA_HERMES · 86 unmodified lines
120120
121121 You will very likely need the Wireless Tools in order to
122122 configure your card and that /etc/pcmcia/wireless.opts works:
123− <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
123+ <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
124124
125125 config PCMCIA_SPECTRUM
126126 tristate "Symbol Spectrum24 Trilogy PCMCIA card support"
drivers/net/wireless/intersil/p54/Kconfig+3−3
@@ -10,7 +10,7 @@ config P54_COMMON · 9 unmodified lines
1010 also need to be enabled in order to support any devices.
1111
1212 These devices require softmac firmware which can be found at
13− <http://wireless.kernel.org/en/users/Drivers/p54>
13+ <http://wireless.wiki.kernel.org/en/users/Drivers/p54>
1414
1515 If you choose to build a module, it'll be called p54common.
1616
@@ -22,7 +22,7 @@ config P54_USB · 5 unmodified lines
2222 This driver is for USB isl38xx based wireless cards.
2323
2424 These devices require softmac firmware which can be found at
25− <http://wireless.kernel.org/en/users/Drivers/p54>
25+ <http://wireless.wiki.kernel.org/en/users/Drivers/p54>
2626
2727 If you choose to build a module, it'll be called p54usb.
2828
@@ -36,7 +36,7 @@ config P54_PCI · 7 unmodified lines
3636 supported by the fullmac driver/firmware.
3737
3838 This driver requires softmac firmware which can be found at
39− <http://wireless.kernel.org/en/users/Drivers/p54>
39+ <http://wireless.wiki.kernel.org/en/users/Drivers/p54>
4040
4141 If you choose to build a module, it'll be called p54pci.
4242
drivers/net/wireless/intersil/p54/fwio.c+1−1
@@ -132,7 +132,7 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) · 131 unmodified lines
132132 if (priv->fw_var < 0x500)
133133 wiphy_info(priv->hw->wiphy,
134134 "you are using an obsolete firmware. "
135− "visit http://wireless.kernel.org/en/users/Drivers/p54 "
135+ "visit http://wireless.wiki.kernel.org/en/users/Drivers/p54 "
136136 "and grab one for \"kernel >= 2.6.28\"!\n");
137137
138138 if (priv->fw_var >= 0x300) {
drivers/net/wireless/intersil/p54/p54pci.c+35−30
@@ -153,12 +153,12 @@ static void p54p_refill_rx_ring(struct ieee80211_hw *dev, · 152 unmodified lines
153153 if (!skb)
154154 break;
155155
156− mapping = pci_map_single(priv->pdev,
156+ mapping = dma_map_single(&priv->pdev->dev,
157157 skb_tail_pointer(skb),
158158 priv->common.rx_mtu + 32,
159− PCI_DMA_FROMDEVICE);
159+ DMA_FROM_DEVICE);
160160
161− if (pci_dma_mapping_error(priv->pdev, mapping)) {
161+ if (dma_mapping_error(&priv->pdev->dev, mapping)) {
162162 dev_kfree_skb_any(skb);
163163 dev_err(&priv->pdev->dev,
164164 "RX DMA Mapping error\n");
@@ -215,19 +215,22 @@ static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index, · 50 unmodified lines
215215 len = priv->common.rx_mtu;
216216 }
217217 dma_addr = le32_to_cpu(desc->host_addr);
218− pci_dma_sync_single_for_cpu(priv->pdev, dma_addr,
219− priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
218+ dma_sync_single_for_cpu(&priv->pdev->dev, dma_addr,
219+ priv->common.rx_mtu + 32,
220+ DMA_FROM_DEVICE);
220221 skb_put(skb, len);
221222
222223 if (p54_rx(dev, skb)) {
223− pci_unmap_single(priv->pdev, dma_addr,
224− priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
224+ dma_unmap_single(&priv->pdev->dev, dma_addr,
225+ priv->common.rx_mtu + 32,
226+ DMA_FROM_DEVICE);
225227 rx_buf[i] = NULL;
226228 desc->host_addr = cpu_to_le32(0);
227229 } else {
228230 skb_trim(skb, 0);
229− pci_dma_sync_single_for_device(priv->pdev, dma_addr,
230− priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);
231+ dma_sync_single_for_device(&priv->pdev->dev, dma_addr,
232+ priv->common.rx_mtu + 32,
233+ DMA_FROM_DEVICE);
231234 desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
232235 }
233236
@@ -258,8 +261,9 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index, · 24 unmodified lines
258261 skb = tx_buf[i];
259262 tx_buf[i] = NULL;
260263
261− pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
262− le16_to_cpu(desc->len), PCI_DMA_TODEVICE);
264+ dma_unmap_single(&priv->pdev->dev,
265+ le32_to_cpu(desc->host_addr),
266+ le16_to_cpu(desc->len), DMA_TO_DEVICE);
263267
264268 desc->host_addr = 0;
265269 desc->device_addr = 0;
@@ -334,9 +338,9 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb) · 68 unmodified lines
334338 idx = le32_to_cpu(ring_control->host_idx[1]);
335339 i = idx % ARRAY_SIZE(ring_control->tx_data);
336340
337− mapping = pci_map_single(priv->pdev, skb->data, skb->len,
338− PCI_DMA_TODEVICE);
339− if (pci_dma_mapping_error(priv->pdev, mapping)) {
341+ mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len,
342+ DMA_TO_DEVICE);
343+ if (dma_mapping_error(&priv->pdev->dev, mapping)) {
340344 spin_unlock_irqrestore(&priv->lock, flags);
341345 p54_free_skb(dev, skb);
342346 dev_err(&priv->pdev->dev, "TX DMA mapping error\n");
@@ -378,10 +382,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 35 unmodified lines
378382 for (i = 0; i < ARRAY_SIZE(priv->rx_buf_data); i++) {
379383 desc = &ring_control->rx_data[i];
380384 if (desc->host_addr)
381− pci_unmap_single(priv->pdev,
385+ dma_unmap_single(&priv->pdev->dev,
382386 le32_to_cpu(desc->host_addr),
383387 priv->common.rx_mtu + 32,
384− PCI_DMA_FROMDEVICE);
388+ DMA_FROM_DEVICE);
385389 kfree_skb(priv->rx_buf_data[i]);
386390 priv->rx_buf_data[i] = NULL;
387391 }
@@ -389,10 +393,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 1 unmodified line
389393 for (i = 0; i < ARRAY_SIZE(priv->rx_buf_mgmt); i++) {
390394 desc = &ring_control->rx_mgmt[i];
391395 if (desc->host_addr)
392− pci_unmap_single(priv->pdev,
396+ dma_unmap_single(&priv->pdev->dev,
393397 le32_to_cpu(desc->host_addr),
394398 priv->common.rx_mtu + 32,
395− PCI_DMA_FROMDEVICE);
399+ DMA_FROM_DEVICE);
396400 kfree_skb(priv->rx_buf_mgmt[i]);
397401 priv->rx_buf_mgmt[i] = NULL;
398402 }
@@ -400,10 +404,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 1 unmodified line
400404 for (i = 0; i < ARRAY_SIZE(priv->tx_buf_data); i++) {
401405 desc = &ring_control->tx_data[i];
402406 if (desc->host_addr)
403− pci_unmap_single(priv->pdev,
407+ dma_unmap_single(&priv->pdev->dev,
404408 le32_to_cpu(desc->host_addr),
405409 le16_to_cpu(desc->len),
406− PCI_DMA_TODEVICE);
410+ DMA_TO_DEVICE);
407411
408412 p54_free_skb(dev, priv->tx_buf_data[i]);
409413 priv->tx_buf_data[i] = NULL;
@@ -412,10 +416,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 2 unmodified lines
412416 for (i = 0; i < ARRAY_SIZE(priv->tx_buf_mgmt); i++) {
413417 desc = &ring_control->tx_mgmt[i];
414418 if (desc->host_addr)
415− pci_unmap_single(priv->pdev,
419+ dma_unmap_single(&priv->pdev->dev,
416420 le32_to_cpu(desc->host_addr),
417421 le16_to_cpu(desc->len),
418− PCI_DMA_TODEVICE);
422+ DMA_TO_DEVICE);
419423
420424 p54_free_skb(dev, priv->tx_buf_mgmt[i]);
421425 priv->tx_buf_mgmt[i] = NULL;
@@ -568,9 +572,9 @@ static int p54p_probe(struct pci_dev *pdev, · 146 unmodified lines
568572 goto err_disable_dev;
569573 }
570574
571− err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
575+ err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
572576 if (!err)
573− err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
577+ err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
574578 if (err) {
575579 dev_err(&pdev->dev, "No suitable DMA available\n");
576580 goto err_free_reg;
@@ -603,8 +607,9 @@ static int p54p_probe(struct pci_dev *pdev, · 26 unmodified lines
603607 goto err_free_dev;
604608 }
605609
606− priv->ring_control = pci_alloc_consistent(pdev, sizeof(*priv->ring_control),
607− &priv->ring_control_dma);
610+ priv->ring_control = dma_alloc_coherent(&pdev->dev,
611+ sizeof(*priv->ring_control),
612+ &priv->ring_control_dma, GFP_KERNEL);
608613 if (!priv->ring_control) {
609614 dev_err(&pdev->dev, "Cannot allocate rings\n");
610615 err = -ENOMEM;
@@ -623,8 +628,8 @@ static int p54p_probe(struct pci_dev *pdev, · 12 unmodified lines
623628 if (!err)
624629 return 0;
625630
626− pci_free_consistent(pdev, sizeof(*priv->ring_control),
627− priv->ring_control, priv->ring_control_dma);
631+ dma_free_coherent(&pdev->dev, sizeof(*priv->ring_control),
632+ priv->ring_control, priv->ring_control_dma);
628633
629634 err_iounmap:
630635 iounmap(priv->map);
@@ -653,8 +658,8 @@ static void p54p_remove(struct pci_dev *pdev) · 22 unmodified lines
653658 wait_for_completion(&priv->fw_loaded);
654659 p54_unregister_common(dev);
655660 release_firmware(priv->firmware);
656− pci_free_consistent(pdev, sizeof(*priv->ring_control),
657− priv->ring_control, priv->ring_control_dma);
661+ dma_free_coherent(&pdev->dev, sizeof(*priv->ring_control),
662+ priv->ring_control, priv->ring_control_dma);
658663 iounmap(priv->map);
659664 pci_release_regions(pdev);
660665 pci_disable_device(pdev);
drivers/net/wireless/intersil/p54/p54usb.c+1−1
@@ -36,7 +36,7 @@ static struct usb_driver p54u_driver; · 35 unmodified lines
3636 * Note:
3737 *
3838 * Always update our wiki's device list (located at:
39− * http://wireless.kernel.org/en/users/Drivers/p54/devices ),
39+ * http://wireless.wiki.kernel.org/en/users/Drivers/p54/devices ),
4040 * whenever you add a new device.
4141 */
4242
drivers/net/wireless/intersil/prism54/isl_oid.h+1−1
@@ -143,7 +143,7 @@ enum dot11_priv_t { · 142 unmodified lines
143143 * together with a CSMA contention. Without this all frames are
144144 * sent with a CSMA contention.
145145 * Bibliography:
146− * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html
146+ * https://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html
147147 */
148148 enum dot11_maxframeburst_t {
149149 /* Values for DOT11_OID_MAXFRAMEBURST */
drivers/net/wireless/intersil/prism54/islpci_dev.c+14−16
@@ -636,10 +636,10 @@ islpci_alloc_memory(islpci_private *priv) · 635 unmodified lines
636636 */
637637
638638 /* perform the allocation */
639− priv->driver_mem_address = pci_alloc_consistent(priv->pdev,
640− HOST_MEM_BLOCK,
641− &priv->
642− device_host_address);
639+ priv->driver_mem_address = dma_alloc_coherent(&priv->pdev->dev,
640+ HOST_MEM_BLOCK,
641+ &priv->device_host_address,
642+ GFP_KERNEL);
643643
644644 if (!priv->driver_mem_address) {
645645 /* error allocating the block of PCI memory */
@@ -692,11 +692,9 @@ islpci_alloc_memory(islpci_private *priv) · 46 unmodified lines
692692
693693 /* map the allocated skb data area to pci */
694694 priv->pci_map_rx_address[counter] =
695− pci_map_single(priv->pdev, (void *) skb->data,
696− MAX_FRAGMENT_SIZE_RX + 2,
697− PCI_DMA_FROMDEVICE);
698− if (pci_dma_mapping_error(priv->pdev,
699− priv->pci_map_rx_address[counter])) {
695+ dma_map_single(&priv->pdev->dev, (void *)skb->data,
696+ MAX_FRAGMENT_SIZE_RX + 2, DMA_FROM_DEVICE);
697+ if (dma_mapping_error(&priv->pdev->dev, priv->pci_map_rx_address[counter])) {
700698 priv->pci_map_rx_address[counter] = 0;
701699 /* error mapping the buffer to device
702700 accessible memory address */
@@ -727,9 +725,9 @@ islpci_free_memory(islpci_private *priv) · 24 unmodified lines
727725
728726 /* free consistent DMA area... */
729727 if (priv->driver_mem_address)
730− pci_free_consistent(priv->pdev, HOST_MEM_BLOCK,
731− priv->driver_mem_address,
732− priv->device_host_address);
728+ dma_free_coherent(&priv->pdev->dev, HOST_MEM_BLOCK,
729+ priv->driver_mem_address,
730+ priv->device_host_address);
733731
734732 /* clear some dangling pointers */
735733 priv->driver_mem_address = NULL;
@@ -741,8 +739,8 @@ islpci_free_memory(islpci_private *priv) · 5 unmodified lines
741739 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {
742740 struct islpci_membuf *buf = &priv->mgmt_rx[counter];
743741 if (buf->pci_addr)
744− pci_unmap_single(priv->pdev, buf->pci_addr,
745− buf->size, PCI_DMA_FROMDEVICE);
742+ dma_unmap_single(&priv->pdev->dev, buf->pci_addr,
743+ buf->size, DMA_FROM_DEVICE);
746744 buf->pci_addr = 0;
747745 kfree(buf->mem);
748746 buf->size = 0;
@@ -752,10 +750,10 @@ islpci_free_memory(islpci_private *priv) · 3 unmodified lines
752750 /* clean up data rx buffers */
753751 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
754752 if (priv->pci_map_rx_address[counter])
755− pci_unmap_single(priv->pdev,
753+ dma_unmap_single(&priv->pdev->dev,
756754 priv->pci_map_rx_address[counter],
757755 MAX_FRAGMENT_SIZE_RX + 2,
758− PCI_DMA_FROMDEVICE);
756+ DMA_FROM_DEVICE);
759757 priv->pci_map_rx_address[counter] = 0;
760758
761759 if (priv->data_low_rx[counter])
drivers/net/wireless/intersil/prism54/islpci_eth.c+10−14
@@ -50,9 +50,9 @@ islpci_eth_cleanup_transmit(islpci_private *priv, · 49 unmodified lines
5050 skb, skb->data, skb->len, skb->truesize);
5151 #endif
5252
53− pci_unmap_single(priv->pdev,
53+ dma_unmap_single(&priv->pdev->dev,
5454 priv->pci_map_tx_address[index],
55− skb->len, PCI_DMA_TODEVICE);
55+ skb->len, DMA_TO_DEVICE);
5656 dev_kfree_skb_irq(skb);
5757 skb = NULL;
5858 }
@@ -176,10 +176,9 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev) · 117 unmodified lines
176176 #endif
177177
178178 /* map the skb buffer to pci memory for DMA operation */
179− pci_map_address = pci_map_single(priv->pdev,
180− (void *) skb->data, skb->len,
181− PCI_DMA_TODEVICE);
182− if (pci_dma_mapping_error(priv->pdev, pci_map_address)) {
179+ pci_map_address = dma_map_single(&priv->pdev->dev, (void *)skb->data,
180+ skb->len, DMA_TO_DEVICE);
181+ if (dma_mapping_error(&priv->pdev->dev, pci_map_address)) {
183182 printk(KERN_WARNING "%s: cannot map buffer to PCI\n",
184183 ndev->name);
185184 goto drop_free;
@@ -323,9 +322,8 @@ islpci_eth_receive(islpci_private *priv) · 137 unmodified lines
323322 #endif
324323
325324 /* delete the streaming DMA mapping before processing the skb */
326− pci_unmap_single(priv->pdev,
327− priv->pci_map_rx_address[index],
328− MAX_FRAGMENT_SIZE_RX + 2, PCI_DMA_FROMDEVICE);
325+ dma_unmap_single(&priv->pdev->dev, priv->pci_map_rx_address[index],
326+ MAX_FRAGMENT_SIZE_RX + 2, DMA_FROM_DEVICE);
329327
330328 /* update the skb structure and align the buffer */
331329 skb_put(skb, size);
@@ -431,11 +429,9 @@ islpci_eth_receive(islpci_private *priv) · 99 unmodified lines
431429
432430 /* set the streaming DMA mapping for proper PCI bus operation */
433431 priv->pci_map_rx_address[index] =
434− pci_map_single(priv->pdev, (void *) skb->data,
435− MAX_FRAGMENT_SIZE_RX + 2,
436− PCI_DMA_FROMDEVICE);
437− if (pci_dma_mapping_error(priv->pdev,
438− priv->pci_map_rx_address[index])) {
432+ dma_map_single(&priv->pdev->dev, (void *)skb->data,
433+ MAX_FRAGMENT_SIZE_RX + 2, DMA_FROM_DEVICE);
434+ if (dma_mapping_error(&priv->pdev->dev, priv->pci_map_rx_address[index])) {
439435 /* error mapping the buffer to device accessible memory address */
440436 DEBUG(SHOW_ERROR_MESSAGES,
441437 "Error mapping DMA address\n");
drivers/net/wireless/intersil/prism54/islpci_hotplug.c+14−25
@@ -26,7 +26,8 @@ module_param(init_pcitm, int, 0); · 25 unmodified lines
2626 /* In this order: vendor, device, subvendor, subdevice, class, class_mask,
2727 * driver_data
2828 * If you have an update for this please contact prism54-devel@prism54.org
29− * The latest list can be found at http://wireless.kernel.org/en/users/Drivers/p54 */
29+ * The latest list can be found at http://wireless.wiki.kernel.org/en/users/Drivers/p54
30+ */
3031 static const struct pci_device_id prism54_id_tbl[] = {
3132 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
3233 {
@@ -63,16 +64,17 @@ MODULE_DEVICE_TABLE(pci, prism54_id_tbl); · 30 unmodified lines
6364
6465 static int prism54_probe(struct pci_dev *, const struct pci_device_id *);
6566 static void prism54_remove(struct pci_dev *);
66−static int prism54_suspend(struct pci_dev *, pm_message_t state);
67−static int prism54_resume(struct pci_dev *);
67+static int __maybe_unused prism54_suspend(struct device *);
68+static int __maybe_unused prism54_resume(struct device *);
69+
70+static SIMPLE_DEV_PM_OPS(prism54_pm_ops, prism54_suspend, prism54_resume);
6871
6972 static struct pci_driver prism54_driver = {
7073 .name = DRV_NAME,
7174 .id_table = prism54_id_tbl,
7275 .probe = prism54_probe,
7376 .remove = prism54_remove,
74− .suspend = prism54_suspend,
75− .resume = prism54_resume,
77+ .driver.pm = &prism54_pm_ops,
7678 };
7779
7880 /******************************************************************************
@@ -106,7 +108,7 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 27 unmodified lines
106108 }
107109
108110 /* enable PCI DMA */
109− if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
111+ if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
110112 printk(KERN_ERR "%s: 32-bit PCI DMA not supported", DRV_NAME);
111113 goto do_pci_disable_device;
112114 }
@@ -243,16 +245,13 @@ prism54_remove(struct pci_dev *pdev) · 130 unmodified lines
243245 pci_disable_device(pdev);
244246 }
245247
246−static int
247−prism54_suspend(struct pci_dev *pdev, pm_message_t state)
248+static int __maybe_unused
249+prism54_suspend(struct device *dev)
248250 {
249− struct net_device *ndev = pci_get_drvdata(pdev);
251+ struct net_device *ndev = dev_get_drvdata(dev);
250252 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
251253 BUG_ON(!priv);
252254
253−
254− pci_save_state(pdev);
255−
256255 /* tell the device not to trigger interrupts for now... */
257256 isl38xx_disable_interrupts(priv->device_base);
258257
@@ -266,26 +265,16 @@ prism54_suspend(struct pci_dev *pdev, pm_message_t state) · 7 unmodified lines
266265 return 0;
267266 }
268267
269−static int
270−prism54_resume(struct pci_dev *pdev)
268+static int __maybe_unused
269+prism54_resume(struct device *dev)
271270 {
272− struct net_device *ndev = pci_get_drvdata(pdev);
271+ struct net_device *ndev = dev_get_drvdata(dev);
273272 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
274− int err;
275273
276274 BUG_ON(!priv);
277275
278276 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
279277
280− err = pci_enable_device(pdev);
281− if (err) {
282− printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
283− ndev->name);
284− return err;
285− }
286−
287− pci_restore_state(pdev);
288−
289278 /* alright let's go into the PREBOOT state */
290279 islpci_reset(priv, 1);
291280
drivers/net/wireless/intersil/prism54/islpci_mgt.c+11−10
@@ -115,10 +115,11 @@ islpci_mgmt_rx_fill(struct net_device *ndev) · 114 unmodified lines
115115 buf->size = MGMT_FRAME_SIZE;
116116 }
117117 if (buf->pci_addr == 0) {
118− buf->pci_addr = pci_map_single(priv->pdev, buf->mem,
118+ buf->pci_addr = dma_map_single(&priv->pdev->dev,
119+ buf->mem,
119120 MGMT_FRAME_SIZE,
120− PCI_DMA_FROMDEVICE);
121− if (pci_dma_mapping_error(priv->pdev, buf->pci_addr)) {
121+ DMA_FROM_DEVICE);
122+ if (dma_mapping_error(&priv->pdev->dev, buf->pci_addr)) {
122123 printk(KERN_WARNING
123124 "Failed to make memory DMA'able.\n");
124125 return -ENOMEM;
@@ -203,9 +204,9 @@ islpci_mgt_transmit(struct net_device *ndev, int operation, unsigned long oid, · 78 unmodified lines
203204 #endif
204205
205206 err = -ENOMEM;
206− buf.pci_addr = pci_map_single(priv->pdev, buf.mem, frag_len,
207− PCI_DMA_TODEVICE);
208− if (pci_dma_mapping_error(priv->pdev, buf.pci_addr)) {
207+ buf.pci_addr = dma_map_single(&priv->pdev->dev, buf.mem, frag_len,
208+ DMA_TO_DEVICE);
209+ if (dma_mapping_error(&priv->pdev->dev, buf.pci_addr)) {
209210 printk(KERN_WARNING "%s: cannot map PCI memory for mgmt\n",
210211 ndev->name);
211212 goto error_free;
@@ -302,8 +303,8 @@ islpci_mgt_receive(struct net_device *ndev) · 90 unmodified lines
302303 }
303304
304305 /* Ensure the results of device DMA are visible to the CPU. */
305− pci_dma_sync_single_for_cpu(priv->pdev, buf->pci_addr,
306− buf->size, PCI_DMA_FROMDEVICE);
306+ dma_sync_single_for_cpu(&priv->pdev->dev, buf->pci_addr,
307+ buf->size, DMA_FROM_DEVICE);
307308
308309 /* Perform endianess conversion for PIMFOR header in-place. */
309310 header = pimfor_decode_header(buf->mem, frag_len);
@@ -414,8 +415,8 @@ islpci_mgt_cleanup_transmit(struct net_device *ndev) · 104 unmodified lines
414415 for (; priv->index_mgmt_tx < curr_frag; priv->index_mgmt_tx++) {
415416 int index = priv->index_mgmt_tx % ISL38XX_CB_MGMT_QSIZE;
416417 struct islpci_membuf *buf = &priv->mgmt_tx[index];
417− pci_unmap_single(priv->pdev, buf->pci_addr, buf->size,
418− PCI_DMA_TODEVICE);
418+ dma_unmap_single(&priv->pdev->dev, buf->pci_addr, buf->size,
419+ DMA_TO_DEVICE);
419420 buf->pci_addr = 0;
420421 kfree(buf->mem);
421422 buf->mem = NULL;
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c+1−1
@@ -398,7 +398,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, · 397 unmodified lines
398398 new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),
399399 GFP_KERNEL);
400400 if (!new_node->rx_reorder_ptr) {
401− kfree((u8 *) new_node);
401+ kfree(new_node);
402402 mwifiex_dbg(priv->adapter, ERROR,
403403 "%s: failed to alloc reorder_ptr\n", __func__);
404404 return;
drivers/net/wireless/mediatek/mt76/Kconfig+4−0
@@ -12,6 +12,10 @@ config MT76_USB · 11 unmodified lines
1212 tristate
1313 depends on MT76_CORE
1414
15+config MT76_SDIO
16+ tristate
17+ depends on MT76_CORE
18+
1519 config MT76x02_LIB
1620 tristate
1721 select MT76_CORE
drivers/net/wireless/mediatek/mt76/Makefile+3−0
@@ -1,6 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0-only
22 obj-$(CONFIG_MT76_CORE) += mt76.o
33 obj-$(CONFIG_MT76_USB) += mt76-usb.o
4+obj-$(CONFIG_MT76_SDIO) += mt76-sdio.o
45 obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
56 obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o
67
@@ -9,8 +10,10 @@ mt76-y := \ · 2 unmodified lines
910 tx.o agg-rx.o mcu.o
1011
1112 mt76-$(CONFIG_PCI) += pci.o
13+mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o
1214
1315 mt76-usb-y := usb.o usb_trace.o
16+mt76-sdio-y := sdio.o
1417
1518 CFLAGS_trace.o := -I$(src)
1619 CFLAGS_usb_trace.o := -I$(src)
drivers/net/wireless/mediatek/mt76/debugfs.c+2−5
@@ -9,7 +9,7 @@ mt76_reg_set(void *data, u64 val) · 8 unmodified lines
99 {
1010 struct mt76_dev *dev = data;
1111
12− dev->bus->wr(dev, dev->debugfs_reg, val);
12+ __mt76_wr(dev, dev->debugfs_reg, val);
1313 return 0;
1414 }
1515
@@ -18,7 +18,7 @@ mt76_reg_get(void *data, u64 *val) · 2 unmodified lines
1818 {
1919 struct mt76_dev *dev = data;
2020
21− *val = dev->bus->rr(dev, dev->debugfs_reg);
21+ *val = __mt76_rr(dev, dev->debugfs_reg);
2222 return 0;
2323 }
2424
@@ -54,9 +54,6 @@ static int mt76_rx_queues_read(struct seq_file *s, void *data) · 29 unmodified lines
5454 mt76_for_each_q_rx(dev, i) {
5555 struct mt76_queue *q = &dev->q_rx[i];
5656
57− if (!q->ndesc)
58− continue;
59−
6057 queued = mt76_is_usb(dev) ? q->ndesc - q->queued : q->queued;
6158 seq_printf(s, "%d: queued=%d head=%d tail=%d\n",
6259 i, queued, q->head, q->tail);
drivers/net/wireless/mediatek/mt76/dma.c+6−0
@@ -370,6 +370,12 @@ unmap: · 369 unmodified lines
370370 tx_info.buf[n].len, DMA_TO_DEVICE);
371371
372372 free:
373+#ifdef CONFIG_NL80211_TESTMODE
374+ /* fix tx_done accounting on queue overflow */
375+ if (tx_info.skb == dev->test.tx_skb)
376+ dev->test.tx_done--;
377+#endif
378+
373379 e.skb = tx_info.skb;
374380 e.txwi = t;
375381 dev->drv->tx_complete_skb(dev, qid, &e);
drivers/net/wireless/mediatek/mt76/eeprom.c+5−0
@@ -74,6 +74,11 @@ mt76_get_of_eeprom(struct mt76_dev *dev, int len) · 73 unmodified lines
7474 &data[i]);
7575 }
7676
77+#ifdef CONFIG_NL80211_TESTMODE
78+ dev->test.mtd_name = devm_kstrdup(dev->dev, part, GFP_KERNEL);
79+ dev->test.mtd_offset = offset;
80+#endif
81+
7782 out_put_node:
7883 of_node_put(np);
7984 return ret;
drivers/net/wireless/mediatek/mt76/mac80211.c+32−5
@@ -58,12 +58,15 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = { · 57 unmodified lines
5858 CHAN5G(132, 5660),
5959 CHAN5G(136, 5680),
6060 CHAN5G(140, 5700),
61+ CHAN5G(144, 5720),
6162
6263 CHAN5G(149, 5745),
6364 CHAN5G(153, 5765),
6465 CHAN5G(157, 5785),
6566 CHAN5G(161, 5805),
6667 CHAN5G(165, 5825),
68+ CHAN5G(169, 5845),
69+ CHAN5G(173, 5865),
6770 };
6871
6972 static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {
@@ -279,7 +282,8 @@ mt76_phy_init(struct mt76_dev *dev, struct ieee80211_hw *hw) · 209 unmodified lines
279282
280283 wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
281284 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH |
282− WIPHY_FLAG_SUPPORTS_TDLS;
285+ WIPHY_FLAG_SUPPORTS_TDLS |
286+ WIPHY_FLAG_AP_UAPSD;
283287
284288 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
285289 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_AIRTIME_FAIRNESS);
@@ -289,6 +293,7 @@ mt76_phy_init(struct mt76_dev *dev, struct ieee80211_hw *hw) · 3 unmodified lines
289293 wiphy->available_antennas_rx = dev->phy.antenna_mask;
290294
291295 hw->txq_data_size = sizeof(struct mt76_txq);
296+ hw->uapsd_max_sp_len = IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL;
292297
293298 if (!hw->max_tx_fragments)
294299 hw->max_tx_fragments = 16;
@@ -300,7 +305,11 @@ mt76_phy_init(struct mt76_dev *dev, struct ieee80211_hw *hw) · 5 unmodified lines
300305 ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);
301306 ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
302307 ieee80211_hw_set(hw, TX_AMSDU);
303− ieee80211_hw_set(hw, TX_FRAG_LIST);
308+
309+ /* TODO: avoid linearization for SDIO */
310+ if (!mt76_is_sdio(dev))
311+ ieee80211_hw_set(hw, TX_FRAG_LIST);
312+
304313 ieee80211_hw_set(hw, MFP_CAPABLE);
305314 ieee80211_hw_set(hw, AP_LINK_PS);
306315 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
@@ -432,6 +441,12 @@ mt76_alloc_device(struct device *pdev, unsigned int size, · 125 unmodified lines
432441
433442 tasklet_init(&dev->tx_tasklet, mt76_tx_tasklet, (unsigned long)dev);
434443
444+ dev->wq = alloc_ordered_workqueue("mt76", 0);
445+ if (!dev->wq) {
446+ ieee80211_free_hw(hw);
447+ return NULL;
448+ }
449+
435450 return dev;
436451 }
437452 EXPORT_SYMBOL_GPL(mt76_alloc_device);
@@ -485,7 +500,12 @@ EXPORT_SYMBOL_GPL(mt76_unregister_device); · 47 unmodified lines
485500
486501 void mt76_free_device(struct mt76_dev *dev)
487502 {
488− mt76_tx_free(dev);
503+ if (dev->wq) {
504+ destroy_workqueue(dev->wq);
505+ dev->wq = NULL;
506+ }
507+ if (mt76_is_mmio(dev))
508+ mt76_tx_free(dev);
489509 ieee80211_free_hw(dev->hw);
490510 }
491511 EXPORT_SYMBOL_GPL(mt76_free_device);
@@ -500,6 +520,13 @@ void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb) · 8 unmodified lines
500520 return;
501521 }
502522
523+#ifdef CONFIG_NL80211_TESTMODE
524+ if (dev->test.state == MT76_TM_STATE_RX_FRAMES) {
525+ dev->test.rx_stats.packets[q]++;
526+ if (status->flag & RX_FLAG_FAILED_FCS_CRC)
527+ dev->test.rx_stats.fcs_error[q]++;
528+ }
529+#endif
503530 __skb_queue_tail(&dev->rx_skb[q], skb);
504531 }
505532 EXPORT_SYMBOL_GPL(mt76_rx);
@@ -537,8 +564,7 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c) · 31 unmodified lines
537564 return &msband->chan[idx];
538565 }
539566
540−static void
541−mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
567+void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
542568 {
543569 struct mt76_channel_state *state = phy->chan_state;
544570
@@ -546,6 +572,7 @@ mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time) · 1 unmodified line
546572 phy->survey_time));
547573 phy->survey_time = time;
548574 }
575+EXPORT_SYMBOL_GPL(mt76_update_survey_active_time);
549576
550577 void mt76_update_survey(struct mt76_dev *dev)
551578 {
drivers/net/wireless/mediatek/mt76/mt76.h+112−3
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/average.h>
1616 #include <net/mac80211.h>
1717 #include "util.h"
18+#include "testmode.h"
1819
1920 #define MT_TX_RING_SIZE 256
2021 #define MT_MCU_RING_SIZE 32
@@ -33,6 +34,7 @@ struct mt76_reg_pair { · 12 unmodified lines
3334 enum mt76_bus_type {
3435 MT76_BUS_MMIO,
3536 MT76_BUS_USB,
37+ MT76_BUS_SDIO,
3638 };
3739
3840 struct mt76_bus_ops {
@@ -52,6 +54,7 @@ struct mt76_bus_ops { · 13 unmodified lines
5254
5355 #define mt76_is_usb(dev) ((dev)->bus->type == MT76_BUS_USB)
5456 #define mt76_is_mmio(dev) ((dev)->bus->type == MT76_BUS_MMIO)
57+#define mt76_is_sdio(dev) ((dev)->bus->type == MT76_BUS_SDIO)
5558
5659 enum mt76_txq_id {
5760 MT_TXQ_VO = IEEE80211_AC_VO,
@@ -94,6 +97,7 @@ struct mt76_queue_entry { · 36 unmodified lines
9497 union {
9598 struct mt76_txwi_cache *txwi;
9699 struct urb *urb;
100+ int buf_sz;
97101 };
98102 enum mt76_txq_id qid;
99103 bool skip_buf0:1;
@@ -146,6 +150,8 @@ struct mt76_mcu_ops { · 46 unmodified lines
146150 int len, bool wait_resp);
147151 int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
148152 int cmd, bool wait_resp);
153+ u32 (*mcu_rr)(struct mt76_dev *dev, u32 offset);
154+ void (*mcu_wr)(struct mt76_dev *dev, u32 offset, u32 val);
149155 int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,
150156 const struct mt76_reg_pair *rp, int len);
151157 int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base,
@@ -290,6 +296,7 @@ enum { · 138 unmodified lines
290296 MT76_STATE_POWER_OFF,
291297 MT76_STATE_SUSPEND,
292298 MT76_STATE_ROC,
299+ MT76_STATE_PM,
293300 };
294301
295302 struct mt76_hw_cap {
@@ -422,7 +429,6 @@ struct mt76_usb { · 126 unmodified lines
422429 u16 data_len;
423430
424431 struct tasklet_struct rx_tasklet;
425− struct workqueue_struct *wq;
426432 struct work_struct stat_work;
427433
428434 u8 out_ep[__MT_EP_OUT_MAX];
@@ -439,6 +445,24 @@ struct mt76_usb { · 10 unmodified lines
439445 } mcu;
440446 };
441447
448+struct mt76_sdio {
449+ struct task_struct *tx_kthread;
450+ struct task_struct *kthread;
451+ struct work_struct stat_work;
452+
453+ unsigned long state;
454+
455+ struct sdio_func *func;
456+
457+ struct {
458+ struct mutex lock;
459+ int pse_data_quota;
460+ int ple_data_quota;
461+ int pse_mcu_quota;
462+ int deficit;
463+ } sched;
464+};
465+
442466 struct mt76_mmio {
443467 void __iomem *regs;
444468 spinlock_t irq_lock;
@@ -475,6 +499,47 @@ struct mt76_rx_status { · 30 unmodified lines
475499 s8 chain_signal[IEEE80211_MAX_CHAINS];
476500 };
477501
502+struct mt76_testmode_ops {
503+ int (*set_state)(struct mt76_dev *dev, enum mt76_testmode_state state);
504+ int (*set_params)(struct mt76_dev *dev, struct nlattr **tb,
505+ enum mt76_testmode_state new_state);
506+ int (*dump_stats)(struct mt76_dev *dev, struct sk_buff *msg);
507+};
508+
509+struct mt76_testmode_data {
510+ enum mt76_testmode_state state;
511+
512+ u32 param_set[DIV_ROUND_UP(NUM_MT76_TM_ATTRS, 32)];
513+ struct sk_buff *tx_skb;
514+
515+ u32 tx_count;
516+ u16 tx_msdu_len;
517+
518+ u8 tx_rate_mode;
519+ u8 tx_rate_idx;
520+ u8 tx_rate_nss;
521+ u8 tx_rate_sgi;
522+ u8 tx_rate_ldpc;
523+
524+ u8 tx_antenna_mask;
525+
526+ u32 freq_offset;
527+
528+ u8 tx_power[4];
529+ u8 tx_power_control;
530+
531+ const char *mtd_name;
532+ u32 mtd_offset;
533+
534+ u32 tx_pending;
535+ u32 tx_queued;
536+ u32 tx_done;
537+ struct {
538+ u64 packets[__MT_RXQ_MAX];
539+ u64 fcs_error[__MT_RXQ_MAX];
540+ } rx_stats;
541+};
542+
478543 struct mt76_phy {
479544 struct ieee80211_hw *hw;
480545 struct mt76_dev *dev;
@@ -491,6 +556,8 @@ struct mt76_phy { · 10 unmodified lines
491556 struct mt76_sband sband_2g;
492557 struct mt76_sband sband_5g;
493558
559+ u32 vif_mask;
560+
494561 int txpower_cur;
495562 u8 antenna_mask;
496563 };
@@ -572,9 +639,17 @@ struct mt76_dev { · 75 unmodified lines
572639
573640 u32 rxfilter;
574641
642+#ifdef CONFIG_NL80211_TESTMODE
643+ const struct mt76_testmode_ops *test_ops;
644+ struct mt76_testmode_data test;
645+#endif
646+
647+ struct workqueue_struct *wq;
648+
575649 union {
576650 struct mt76_mmio mmio;
577651 struct mt76_usb usb;
652+ struct mt76_sdio sdio;
578653 };
579654 };
580655
@@ -805,6 +880,15 @@ static inline u8 mt76_tx_power_nss_delta(u8 nss) · 224 unmodified lines
805880 return nss_delta[nss - 1];
806881 }
807882
883+static inline bool mt76_testmode_enabled(struct mt76_dev *dev)
884+{
885+#ifdef CONFIG_NL80211_TESTMODE
886+ return dev->test.state != MT76_TM_STATE_OFF;
887+#else
888+ return false;
889+#endif
890+}
891+
808892 void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
809893 void mt76_tx(struct mt76_phy *dev, struct ieee80211_sta *sta,
810894 struct mt76_wcid *wcid, struct sk_buff *skb);
@@ -824,6 +908,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw, · 13 unmodified lines
824908 bool mt76_has_tx_pending(struct mt76_phy *phy);
825909 void mt76_set_channel(struct mt76_phy *phy);
826910 void mt76_update_survey(struct mt76_dev *dev);
911+void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
827912 int mt76_get_survey(struct ieee80211_hw *hw, int idx,
828913 struct survey_info *survey);
829914 void mt76_set_stream_caps(struct mt76_phy *phy, bool vht);
@@ -877,6 +962,24 @@ void mt76_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 47 unmodified lines
877962 const u8 *mac);
878963 void mt76_sw_scan_complete(struct ieee80211_hw *hw,
879964 struct ieee80211_vif *vif);
965+int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
966+ void *data, int len);
967+int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
968+ struct netlink_callback *cb, void *data, int len);
969+int mt76_testmode_set_state(struct mt76_dev *dev, enum mt76_testmode_state state);
970+
971+static inline void mt76_testmode_reset(struct mt76_dev *dev, bool disable)
972+{
973+#ifdef CONFIG_NL80211_TESTMODE
974+ enum mt76_testmode_state state = MT76_TM_STATE_IDLE;
975+
976+ if (disable || dev->test.state == MT76_TM_STATE_OFF)
977+ state = MT76_TM_STATE_OFF;
978+
979+ mt76_testmode_set_state(dev, state);
980+#endif
981+}
982+
880983
881984 /* internal */
882985 static inline struct ieee80211_hw *
@@ -901,6 +1004,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames, · 18 unmodified lines
9011004 void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
9021005 struct napi_struct *napi);
9031006 void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);
1007+void mt76_testmode_tx_pending(struct mt76_dev *dev);
9041008
9051009 /* usb */
9061010 static inline bool mt76u_urb_error(struct urb *urb)
@@ -935,13 +1039,12 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len, · 28 unmodified lines
9351039 return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout);
9361040 }
9371041
938−int mt76u_skb_dma_info(struct sk_buff *skb, u32 info);
1042+int mt76_skb_adjust_pad(struct sk_buff *skb);
9391043 int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
9401044 u8 req_type, u16 val, u16 offset,
9411045 void *buf, size_t len);
9421046 void mt76u_single_wr(struct mt76_dev *dev, const u8 req,
9431047 const u16 offset, const u32 val);
944−void mt76u_deinit(struct mt76_dev *dev);
9451048 int mt76u_init(struct mt76_dev *dev, struct usb_interface *intf,
9461049 bool ext);
9471050 int mt76u_alloc_mcu_queue(struct mt76_dev *dev);
@@ -951,6 +1054,12 @@ void mt76u_stop_rx(struct mt76_dev *dev); · 3 unmodified lines
9511054 int mt76u_resume_rx(struct mt76_dev *dev);
9521055 void mt76u_queues_deinit(struct mt76_dev *dev);
9531056
1057+int mt76s_init(struct mt76_dev *dev, struct sdio_func *func,
1058+ const struct mt76_bus_ops *bus_ops);
1059+int mt76s_alloc_queues(struct mt76_dev *dev);
1060+void mt76s_stop_txrx(struct mt76_dev *dev);
1061+void mt76s_deinit(struct mt76_dev *dev);
1062+
9541063 struct sk_buff *
9551064 mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
9561065 int data_len);
drivers/net/wireless/mediatek/mt76/mt7603/main.c+3−3
@@ -44,7 +44,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 43 unmodified lines
4444
4545 mutex_lock(&dev->mt76.mutex);
4646
47− mvif->idx = ffs(~dev->vif_mask) - 1;
47+ mvif->idx = ffs(~dev->mphy.vif_mask) - 1;
4848 if (mvif->idx >= MT7603_MAX_INTERFACES) {
4949 ret = -ENOSPC;
5050 goto out;
@@ -65,7 +65,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 14 unmodified lines
6565 }
6666
6767 idx = MT7603_WTBL_RESERVED - 1 - mvif->idx;
68− dev->vif_mask |= BIT(mvif->idx);
68+ dev->mphy.vif_mask |= BIT(mvif->idx);
6969 INIT_LIST_HEAD(&mvif->sta.poll_list);
7070 mvif->sta.wcid.idx = idx;
7171 mvif->sta.wcid.hw_key_idx = -1;
@@ -107,7 +107,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 35 unmodified lines
107107 spin_unlock_bh(&dev->sta_poll_lock);
108108
109109 mutex_lock(&dev->mt76.mutex);
110− dev->vif_mask &= ~BIT(mvif->idx);
110+ dev->mphy.vif_mask &= ~BIT(mvif->idx);
111111 mutex_unlock(&dev->mt76.mutex);
112112 }
113113
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h+0−2
@@ -108,8 +108,6 @@ struct mt7603_dev { · 107 unmodified lines
108108
109109 u32 rxfilter;
110110
111− u8 vif_mask;
112−
113111 struct list_head sta_poll_list;
114112 spinlock_t sta_poll_lock;
115113
drivers/net/wireless/mediatek/mt76/mt7615/Kconfig+17−2
@@ -28,13 +28,28 @@ config MT7622_WMAC · 27 unmodified lines
2828 which has the same feature set as a MT7615, but limited to
2929 2.4 GHz only.
3030
31+config MT7663_USB_SDIO_COMMON
32+ tristate
33+ select MT7615_COMMON
34+
3135 config MT7663U
3236 tristate "MediaTek MT7663U (USB) support"
3337 select MT76_USB
34− select MT7615_COMMON
38+ select MT7663_USB_SDIO_COMMON
3539 depends on MAC80211
3640 depends on USB
3741 help
38− This adds support for MT7663U 802.11ax 2x2:2 wireless devices.
42+ This adds support for MT7663U 802.11ac 2x2:2 wireless devices.
43+
44+ To compile this driver as a module, choose M here.
45+
46+config MT7663S
47+ tristate "MediaTek MT7663S (SDIO) support"
48+ select MT76_SDIO
49+ select MT7663_USB_SDIO_COMMON
50+ depends on MAC80211
51+ depends on MMC
52+ help
53+ This adds support for MT7663S 802.11ac 2x2:2 wireless devices.
3954
4055 To compile this driver as a module, choose M here.
drivers/net/wireless/mediatek/mt76/mt7615/Makefile+6−1
@@ -2,14 +2,19 @@ · 1 unmodified line
22
33 obj-$(CONFIG_MT7615_COMMON) += mt7615-common.o
44 obj-$(CONFIG_MT7615E) += mt7615e.o
5+obj-$(CONFIG_MT7663_USB_SDIO_COMMON) += mt7663-usb-sdio-common.o
56 obj-$(CONFIG_MT7663U) += mt7663u.o
7+obj-$(CONFIG_MT7663S) += mt7663s.o
68
79 CFLAGS_trace.o := -I$(src)
810
911 mt7615-common-y := main.o init.o mcu.o eeprom.o mac.o \
1012 debugfs.o trace.o
13+mt7615-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
1114
1215 mt7615e-y := pci.o pci_init.o dma.o pci_mac.o mmio.o
1316 mt7615e-$(CONFIG_MT7622_WMAC) += soc.o
1417
15−mt7663u-y := usb.o usb_mcu.o usb_init.o
18+mt7663-usb-sdio-common-y := usb_sdio.o
19+mt7663u-y := usb.o usb_mcu.o
20+mt7663s-y := sdio.o sdio_mcu.o sdio_txrx.o
drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c+101−1
@@ -6,11 +6,16 @@ static int · 5 unmodified lines
66 mt7615_radar_pattern_set(void *data, u64 val)
77 {
88 struct mt7615_dev *dev = data;
9+ int err;
910
1011 if (!mt7615_wait_for_mcu_init(dev))
1112 return 0;
1213
13− return mt7615_mcu_rdd_send_pattern(dev);
14+ mt7615_mutex_acquire(dev);
15+ err = mt7615_mcu_rdd_send_pattern(dev);
16+ mt7615_mutex_release(dev);
17+
18+ return err;
1419 }
1520
1621 DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_pattern, NULL,
@@ -46,6 +51,52 @@ mt7615_scs_get(void *data, u64 *val) · 29 unmodified lines
4651 DEFINE_DEBUGFS_ATTRIBUTE(fops_scs, mt7615_scs_get,
4752 mt7615_scs_set, "%lld\n");
4853
54+static int
55+mt7615_pm_set(void *data, u64 val)
56+{
57+ struct mt7615_dev *dev = data;
58+
59+ if (!mt7615_wait_for_mcu_init(dev))
60+ return 0;
61+
62+ return mt7615_pm_set_enable(dev, val);
63+}
64+
65+static int
66+mt7615_pm_get(void *data, u64 *val)
67+{
68+ struct mt7615_dev *dev = data;
69+
70+ *val = dev->pm.enable;
71+
72+ return 0;
73+}
74+
75+DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7615_pm_get, mt7615_pm_set, "%lld\n");
76+
77+static int
78+mt7615_pm_idle_timeout_set(void *data, u64 val)
79+{
80+ struct mt7615_dev *dev = data;
81+
82+ dev->pm.idle_timeout = msecs_to_jiffies(val);
83+
84+ return 0;
85+}
86+
87+static int
88+mt7615_pm_idle_timeout_get(void *data, u64 *val)
89+{
90+ struct mt7615_dev *dev = data;
91+
92+ *val = jiffies_to_msecs(dev->pm.idle_timeout);
93+
94+ return 0;
95+}
96+
97+DEFINE_DEBUGFS_ATTRIBUTE(fops_pm_idle_timeout, mt7615_pm_idle_timeout_get,
98+ mt7615_pm_idle_timeout_set, "%lld\n");
99+
49100 static int
50101 mt7615_dbdc_set(void *data, u64 val)
51102 {
@@ -84,7 +135,10 @@ mt7615_fw_debug_set(void *data, u64 val) · 32 unmodified lines
84135 return 0;
85136
86137 dev->fw_debug = val;
138+
139+ mt7615_mutex_acquire(dev);
87140 mt7615_mcu_fw_log_2_host(dev, dev->fw_debug ? 2 : 0);
141+ mt7615_mutex_release(dev);
88142
89143 return 0;
90144 }
@@ -111,6 +165,8 @@ mt7615_reset_test_set(void *data, u64 val) · 20 unmodified lines
111165 if (!mt7615_wait_for_mcu_init(dev))
112166 return 0;
113167
168+ mt7615_mutex_acquire(dev);
169+
114170 skb = alloc_skb(1, GFP_KERNEL);
115171 if (!skb)
116172 return -ENOMEM;
@@ -118,6 +174,8 @@ mt7615_reset_test_set(void *data, u64 val) · 1 unmodified line
118174 skb_put(skb, 1);
119175 mt76_tx_queue_skb_raw(dev, 0, skb, 0);
120176
177+ mt7615_mutex_release(dev);
178+
121179 return 0;
122180 }
123181
@@ -167,9 +225,13 @@ mt7615_ampdu_stat_read(struct seq_file *file, void *data) · 43 unmodified lines
167225 {
168226 struct mt7615_dev *dev = file->private;
169227
228+ mt7615_mutex_acquire(dev);
229+
170230 mt7615_ampdu_stat_read_phy(&dev->phy, file);
171231 mt7615_ampdu_stat_read_phy(mt7615_ext_phy(dev), file);
172232
233+ mt7615_mutex_release(dev);
234+
173235 return 0;
174236 }
175237
@@ -221,7 +283,10 @@ static int mt7615_read_temperature(struct seq_file *s, void *data) · 45 unmodified lines
221283 return 0;
222284
223285 /* cpu */
286+ mt7615_mutex_acquire(dev);
224287 temp = mt7615_mcu_get_temperature(dev, 0);
288+ mt7615_mutex_release(dev);
289+
225290 seq_printf(s, "Temperature: %d\n", temp);
226291
227292 return 0;
@@ -233,6 +298,8 @@ mt7615_queues_acq(struct seq_file *s, void *data) · 5 unmodified lines
233298 struct mt7615_dev *dev = dev_get_drvdata(s->private);
234299 int i;
235300
301+ mt7615_mutex_acquire(dev);
302+
236303 for (i = 0; i < 16; i++) {
237304 int j, wmm_idx = i % MT7615_MAX_WMM_SETS;
238305 int acs = i / MT7615_MAX_WMM_SETS;
@@ -253,6 +320,8 @@ mt7615_queues_acq(struct seq_file *s, void *data) · 14 unmodified lines
253320 seq_printf(s, "AC%d%d: queued=%d\n", wmm_idx, acs, qlen);
254321 }
255322
323+ mt7615_mutex_release(dev);
324+
256325 return 0;
257326 }
258327
@@ -285,6 +354,29 @@ mt7615_queues_read(struct seq_file *s, void *data) · 26 unmodified lines
285354 return 0;
286355 }
287356
357+static int
358+mt7615_rf_reg_set(void *data, u64 val)
359+{
360+ struct mt7615_dev *dev = data;
361+
362+ mt7615_rf_wr(dev, dev->debugfs_rf_wf, dev->debugfs_rf_reg, val);
363+
364+ return 0;
365+}
366+
367+static int
368+mt7615_rf_reg_get(void *data, u64 *val)
369+{
370+ struct mt7615_dev *dev = data;
371+
372+ *val = mt7615_rf_rr(dev, dev->debugfs_rf_wf, dev->debugfs_rf_reg);
373+
374+ return 0;
375+}
376+
377+DEFINE_DEBUGFS_ATTRIBUTE(fops_rf_reg, mt7615_rf_reg_get, mt7615_rf_reg_set,
378+ "0x%08llx\n");
379+
288380 int mt7615_init_debugfs(struct mt7615_dev *dev)
289381 {
290382 struct dentry *dir;
@@ -305,6 +397,9 @@ int mt7615_init_debugfs(struct mt7615_dev *dev) · 14 unmodified lines
305397 debugfs_create_file("scs", 0600, dir, dev, &fops_scs);
306398 debugfs_create_file("dbdc", 0600, dir, dev, &fops_dbdc);
307399 debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug);
400+ debugfs_create_file("runtime-pm", 0600, dir, dev, &fops_pm);
401+ debugfs_create_file("idle-timeout", 0600, dir, dev,
402+ &fops_pm_idle_timeout);
308403 debugfs_create_devm_seqfile(dev->mt76.dev, "radio", dir,
309404 mt7615_radio_read);
310405 debugfs_create_u32("dfs_hw_pattern", 0400, dir, &dev->hw_pattern);
@@ -324,6 +419,11 @@ int mt7615_init_debugfs(struct mt7615_dev *dev) · 13 unmodified lines
324419 debugfs_create_devm_seqfile(dev->mt76.dev, "temperature", dir,
325420 mt7615_read_temperature);
326421
422+ debugfs_create_u32("rf_wfidx", 0600, dir, &dev->debugfs_rf_wf);
423+ debugfs_create_u32("rf_regidx", 0600, dir, &dev->debugfs_rf_reg);
424+ debugfs_create_file_unsafe("rf_regval", 0600, dir, dev,
425+ &fops_rf_reg);
426+
327427 return 0;
328428 }
329429 EXPORT_SYMBOL_GPL(mt7615_init_debugfs);
drivers/net/wireless/mediatek/mt76/mt7615/dma.c+0−4
@@ -122,10 +122,6 @@ static int mt7615_poll_tx(struct napi_struct *napi, int budget) · 121 unmodified lines
122122
123123 mt7615_tx_cleanup(dev);
124124
125− rcu_read_lock();
126− mt7615_mac_sta_poll(dev);
127− rcu_read_unlock();
128−
129125 tasklet_schedule(&dev->mt76.tx_tasklet);
130126
131127 return 0;
drivers/net/wireless/mediatek/mt76/mt7615/init.c+14−3
@@ -285,7 +285,9 @@ mt7615_regd_notifier(struct wiphy *wiphy, · 284 unmodified lines
285285 if (!(chandef->chan->flags & IEEE80211_CHAN_RADAR))
286286 return;
287287
288+ mt7615_mutex_acquire(dev);
288289 mt7615_dfs_init_radar_detector(phy);
290+ mt7615_mutex_release(dev);
289291 }
290292
291293 static void
@@ -321,6 +323,7 @@ mt7615_init_wiphy(struct ieee80211_hw *hw) · 29 unmodified lines
321323
322324 ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
323325 ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN);
326+ ieee80211_hw_set(hw, WANT_MONITOR_VIF);
324327
325328 if (is_mt7615(&phy->dev->mt76))
326329 hw->max_tx_fragments = MT_TXP_MAX_BUF_NUM;
@@ -405,9 +408,6 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev) · 78 unmodified lines
405408 mphy->sband_2g.sband.n_channels = 0;
406409 mphy->hw->wiphy->bands[NL80211_BAND_2GHZ] = NULL;
407410
408− /* The second interface does not get any packets unless it has a vif */
409− ieee80211_hw_set(mphy->hw, WANT_MONITOR_VIF);
410−
411411 ret = mt76_register_phy(mphy);
412412 if (ret)
413413 ieee80211_free_hw(mphy->hw);
@@ -437,6 +437,12 @@ void mt7615_init_device(struct mt7615_dev *dev) · 23 unmodified lines
437437 dev->phy.dev = dev;
438438 dev->phy.mt76 = &dev->mt76.phy;
439439 dev->mt76.phy.priv = &dev->phy;
440+
441+ INIT_DELAYED_WORK(&dev->pm.ps_work, mt7615_pm_power_save_work);
442+ INIT_WORK(&dev->pm.wake_work, mt7615_pm_wake_work);
443+ init_completion(&dev->pm.wake_cmpl);
444+ spin_lock_init(&dev->pm.txq_lock);
445+ set_bit(MT76_STATE_PM, &dev->mphy.state);
440446 INIT_DELAYED_WORK(&dev->phy.mac_work, mt7615_mac_work);
441447 INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
442448 skb_queue_head_init(&dev->phy.scan_event_list);
@@ -450,6 +456,7 @@ void mt7615_init_device(struct mt7615_dev *dev) · 7 unmodified lines
450456 timer_setup(&dev->phy.roc_timer, mt7615_roc_timer, 0);
451457
452458 mt7615_init_wiphy(hw);
459+ dev->pm.idle_timeout = MT7615_PM_TIMEOUT;
453460 dev->mphy.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
454461 dev->mphy.sband_5g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
455462 dev->mphy.sband_5g.sband.vht_cap.cap |=
@@ -457,5 +464,9 @@ void mt7615_init_device(struct mt7615_dev *dev) · 1 unmodified line
457464 IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK;
458465 mt7615_cap_dbdc_disable(dev);
459466 dev->phy.dfs_state = -1;
467+
468+#ifdef CONFIG_NL80211_TESTMODE
469+ dev->mt76.test_ops = &mt7615_testmode_ops;
470+#endif
460471 }
461472 EXPORT_SYMBOL_GPL(mt7615_init_device);
drivers/net/wireless/mediatek/mt76/mt7615/mac.c+282−30
@@ -186,6 +186,40 @@ mt7615_get_status_freq_info(struct mt7615_dev *dev, struct mt76_phy *mphy, · 185 unmodified lines
186186 status->freq = ieee80211_channel_to_frequency(chfreq, status->band);
187187 }
188188
189+static void mt7615_mac_fill_tm_rx(struct mt7615_dev *dev, __le32 *rxv)
190+{
191+#ifdef CONFIG_NL80211_TESTMODE
192+ u32 rxv1 = le32_to_cpu(rxv[0]);
193+ u32 rxv3 = le32_to_cpu(rxv[2]);
194+ u32 rxv4 = le32_to_cpu(rxv[3]);
195+ u32 rxv5 = le32_to_cpu(rxv[4]);
196+ u8 cbw = FIELD_GET(MT_RXV1_FRAME_MODE, rxv1);
197+ u8 mode = FIELD_GET(MT_RXV1_TX_MODE, rxv1);
198+ s16 foe = FIELD_GET(MT_RXV5_FOE, rxv5);
199+ u32 foe_const = (BIT(cbw + 1) & 0xf) * 10000;
200+
201+ if (!mode) {
202+ /* CCK */
203+ foe &= ~BIT(11);
204+ foe *= 1000;
205+ foe >>= 11;
206+ } else {
207+ if (foe > 2048)
208+ foe -= 4096;
209+
210+ foe = (foe * foe_const) >> 15;
211+ }
212+
213+ dev->test.last_freq_offset = foe;
214+ dev->test.last_rcpi[0] = FIELD_GET(MT_RXV4_RCPI0, rxv4);
215+ dev->test.last_rcpi[1] = FIELD_GET(MT_RXV4_RCPI1, rxv4);
216+ dev->test.last_rcpi[2] = FIELD_GET(MT_RXV4_RCPI2, rxv4);
217+ dev->test.last_rcpi[3] = FIELD_GET(MT_RXV4_RCPI3, rxv4);
218+ dev->test.last_ib_rssi = FIELD_GET(MT_RXV3_IB_RSSI, rxv3);
219+ dev->test.last_wb_rssi = FIELD_GET(MT_RXV3_WB_RSSI, rxv3);
220+#endif
221+}
222+
189223 static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
190224 {
191225 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
@@ -401,6 +435,8 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) · 209 unmodified lines
401435 status->chain_signal[i]);
402436 }
403437
438+ mt7615_mac_fill_tm_rx(dev, rxd);
439+
404440 rxd += 6;
405441 if ((u8 *)rxd - skb->data >= skb->len)
406442 return -EINVAL;
@@ -493,18 +529,18 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 86 unmodified lines
493529 struct ieee80211_sta *sta, int pid,
494530 struct ieee80211_key_conf *key, bool beacon)
495531 {
532+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
533+ u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
496534 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
497535 struct ieee80211_tx_rate *rate = &info->control.rates[0];
498− struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
536+ bool ext_phy = info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY;
499537 bool multicast = is_multicast_ether_addr(hdr->addr1);
500538 struct ieee80211_vif *vif = info->control.vif;
539+ bool is_mmio = mt76_is_mmio(&dev->mt76);
540+ u32 val, sz_txd = is_mmio ? MT_TXD_SIZE : MT_USB_TXD_SIZE;
501541 struct mt76_phy *mphy = &dev->mphy;
502− bool ext_phy = info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY;
503− bool is_usb = mt76_is_usb(&dev->mt76);
504− int tx_count = 8;
505− u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
506542 __le16 fc = hdr->frame_control;
507− u32 val, sz_txd = is_usb ? MT_USB_TXD_SIZE : MT_TXD_SIZE;
543+ int tx_count = 8;
508544 u16 seqno = 0;
509545
510546 if (vif) {
@@ -530,10 +566,10 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 19 unmodified lines
530566 p_fmt = MT_TX_TYPE_FW;
531567 q_idx = ext_phy ? MT_LMAC_BCN1 : MT_LMAC_BCN0;
532568 } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {
533− p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
569+ p_fmt = is_mmio ? MT_TX_TYPE_CT : MT_TX_TYPE_SF;
534570 q_idx = ext_phy ? MT_LMAC_ALTX1 : MT_LMAC_ALTX0;
535571 } else {
536− p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
572+ p_fmt = is_mmio ? MT_TX_TYPE_CT : MT_TX_TYPE_SF;
537573 q_idx = wmm_idx * MT7615_MAX_WMM_SETS +
538574 mt7615_lmac_mapping(dev, skb_get_queue_mapping(skb));
539575 }
@@ -617,16 +653,19 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 77 unmodified lines
617653 }
618654
619655 val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count);
620− if (ieee80211_is_data_qos(hdr->frame_control)) {
621− seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
622− val |= MT_TXD3_SN_VALID;
623− } else if (ieee80211_is_back_req(hdr->frame_control)) {
624− struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data;
656+ if (info->flags & IEEE80211_TX_CTL_INJECTED) {
657+ seqno = le16_to_cpu(hdr->seq_ctrl);
658+
659+ if (ieee80211_is_back_req(hdr->frame_control)) {
660+ struct ieee80211_bar *bar;
625661
626− seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(bar->start_seq_num));
627− val |= MT_TXD3_SN_VALID;
662+ bar = (struct ieee80211_bar *)skb->data;
663+ seqno = le16_to_cpu(bar->start_seq_num);
664+ }
665+
666+ val |= MT_TXD3_SN_VALID |
667+ FIELD_PREP(MT_TXD3_SEQ, IEEE80211_SEQ_TO_SN(seqno));
628668 }
629− val |= FIELD_PREP(MT_TXD3_SEQ, seqno);
630669
631670 txwi[3] |= cpu_to_le32(val);
632671
@@ -636,7 +675,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 3 unmodified lines
636675 txwi[7] = FIELD_PREP(MT_TXD7_TYPE, fc_type) |
637676 FIELD_PREP(MT_TXD7_SUB_TYPE, fc_stype) |
638677 FIELD_PREP(MT_TXD7_SPE_IDX, 0x18);
639− if (is_usb)
678+ if (!is_mmio)
640679 txwi[8] = FIELD_PREP(MT_TXD8_L_TYPE, fc_type) |
641680 FIELD_PREP(MT_TXD8_L_SUB_TYPE, fc_stype);
642681
@@ -878,6 +917,9 @@ mt7615_mac_queue_rate_update(struct mt7615_phy *phy, struct mt7615_sta *sta, · 235 unmodified lines
878917 struct mt7615_dev *dev = phy->dev;
879918 struct mt7615_wtbl_desc *wd;
880919
920+ if (work_pending(&dev->wtbl_work))
921+ return -EBUSY;
922+
881923 wd = kzalloc(sizeof(*wd), GFP_ATOMIC);
882924 if (!wd)
883925 return -ENOMEM;
@@ -888,11 +930,34 @@ mt7615_mac_queue_rate_update(struct mt7615_phy *phy, struct mt7615_sta *sta, · 4 unmodified lines
888930 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates,
889931 &wd->rate);
890932 list_add_tail(&wd->node, &dev->wd_head);
891− queue_work(dev->mt76.usb.wq, &dev->wtbl_work);
933+ queue_work(dev->mt76.wq, &dev->wtbl_work);
892934
893935 return 0;
894936 }
895937
938+u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid)
939+{
940+ u32 addr, val, val2;
941+ u8 offset;
942+
943+ addr = mt7615_mac_wtbl_addr(dev, wcid) + 11 * 4;
944+
945+ offset = tid * 12;
946+ addr += 4 * (offset / 32);
947+ offset %= 32;
948+
949+ val = mt76_rr(dev, addr);
950+ val >>= (tid % 32);
951+
952+ if (offset > 20) {
953+ addr += 4;
954+ val2 = mt76_rr(dev, addr);
955+ val |= val2 << (32 - offset);
956+ }
957+
958+ return val & GENMASK(11, 0);
959+}
960+
896961 void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
897962 struct ieee80211_tx_rate *probe_rate,
898963 struct ieee80211_tx_rate *rates)
@@ -902,7 +967,7 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, · 3 unmodified lines
902967 struct mt7615_rate_desc rd;
903968 u32 w5, w27, addr;
904969
905− if (mt76_is_usb(&dev->mt76)) {
970+ if (!mt76_is_mmio(&dev->mt76)) {
906971 mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates);
907972 return;
908973 }
@@ -961,6 +1026,7 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, · 52 unmodified lines
9611026
9621027 sta->rate_count = 2 * MT7615_RATE_RETRY * n_rates;
9631028 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
1029+ sta->rate_probe = !!probe_rate;
9641030 }
9651031 EXPORT_SYMBOL_GPL(mt7615_mac_set_rates);
9661032
@@ -1169,7 +1235,6 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, · 202 unmodified lines
11691235 phy = dev->mt76.phy2->priv;
11701236
11711237 mt7615_mac_set_rates(phy, sta, NULL, sta->rates);
1172− sta->rate_probe = false;
11731238 }
11741239 spin_unlock_bh(&dev->mt76.lock);
11751240 } else {
@@ -1373,6 +1438,12 @@ static void mt7615_mac_tx_free(struct mt7615_dev *dev, struct sk_buff *skb) · 197 unmodified lines
13731438 }
13741439
13751440 dev_kfree_skb(skb);
1441+
1442+ rcu_read_lock();
1443+ mt7615_mac_sta_poll(dev);
1444+ rcu_read_unlock();
1445+
1446+ tasklet_schedule(&dev->mt76.tx_tasklet);
13761447 }
13771448
13781449 void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
@@ -1462,7 +1533,7 @@ void mt7615_mac_set_scs(struct mt7615_phy *phy, bool enable) · 83 unmodified lines
14621533 bool ext_phy = phy != &dev->phy;
14631534 u32 reg, mask;
14641535
1465− mutex_lock(&dev->mt76.mutex);
1536+ mt7615_mutex_acquire(dev);
14661537
14671538 if (phy->scs_en == enable)
14681539 goto out;
@@ -1489,7 +1560,7 @@ void mt7615_mac_set_scs(struct mt7615_phy *phy, bool enable) · 20 unmodified lines
14891560 phy->scs_en = enable;
14901561
14911562 out:
1492− mutex_unlock(&dev->mt76.mutex);
1563+ mt7615_mutex_release(dev);
14931564 }
14941565
14951566 void mt7615_mac_enable_nf(struct mt7615_dev *dev, bool ext_phy)
@@ -1679,9 +1750,9 @@ mt7615_phy_update_channel(struct mt76_phy *mphy, int idx) · 183 unmodified lines
16791750 state->noise = -(phy->noise >> 4);
16801751 }
16811752
1682−void mt7615_update_channel(struct mt76_dev *mdev)
1753+static void __mt7615_update_channel(struct mt7615_dev *dev)
16831754 {
1684− struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
1755+ struct mt76_dev *mdev = &dev->mt76;
16851756
16861757 mt7615_phy_update_channel(&mdev->phy, 0);
16871758 if (mdev->phy2)
@@ -1690,8 +1761,32 @@ void mt7615_update_channel(struct mt76_dev *mdev) · 2 unmodified lines
16901761 /* reset obss airtime */
16911762 mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
16921763 }
1764+
1765+void mt7615_update_channel(struct mt76_dev *mdev)
1766+{
1767+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
1768+
1769+ if (mt7615_pm_wake(dev))
1770+ return;
1771+
1772+ __mt7615_update_channel(dev);
1773+ mt7615_pm_power_save_sched(dev);
1774+}
16931775 EXPORT_SYMBOL_GPL(mt7615_update_channel);
16941776
1777+static void mt7615_update_survey(struct mt7615_dev *dev)
1778+{
1779+ struct mt76_dev *mdev = &dev->mt76;
1780+ ktime_t cur_time;
1781+
1782+ __mt7615_update_channel(dev);
1783+ cur_time = ktime_get_boottime();
1784+
1785+ mt76_update_survey_active_time(&mdev->phy, cur_time);
1786+ if (mdev->phy2)
1787+ mt76_update_survey_active_time(mdev->phy2, cur_time);
1788+}
1789+
16951790 static void
16961791 mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
16971792 {
@@ -1740,6 +1835,163 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy) · 42 unmodified lines
17401835 }
17411836 }
17421837
1838+void mt7615_pm_wake_work(struct work_struct *work)
1839+{
1840+ struct mt7615_dev *dev;
1841+ struct mt76_phy *mphy;
1842+ int i;
1843+
1844+ dev = (struct mt7615_dev *)container_of(work, struct mt7615_dev,
1845+ pm.wake_work);
1846+ mphy = dev->phy.mt76;
1847+
1848+ if (mt7615_driver_own(dev)) {
1849+ dev_err(mphy->dev->dev, "failed to wake device\n");
1850+ goto out;
1851+ }
1852+
1853+ spin_lock_bh(&dev->pm.txq_lock);
1854+ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
1855+ struct mt7615_sta *msta = dev->pm.tx_q[i].msta;
1856+ struct mt76_wcid *wcid = msta ? &msta->wcid : NULL;
1857+ struct ieee80211_sta *sta = NULL;
1858+
1859+ if (!dev->pm.tx_q[i].skb)
1860+ continue;
1861+
1862+ if (msta && wcid->sta)
1863+ sta = container_of((void *)msta, struct ieee80211_sta,
1864+ drv_priv);
1865+
1866+ mt76_tx(mphy, sta, wcid, dev->pm.tx_q[i].skb);
1867+ dev->pm.tx_q[i].skb = NULL;
1868+ }
1869+ spin_unlock_bh(&dev->pm.txq_lock);
1870+
1871+ tasklet_schedule(&dev->mt76.tx_tasklet);
1872+
1873+out:
1874+ ieee80211_wake_queues(mphy->hw);
1875+ complete_all(&dev->pm.wake_cmpl);
1876+}
1877+
1878+int mt7615_pm_wake(struct mt7615_dev *dev)
1879+{
1880+ struct mt76_phy *mphy = dev->phy.mt76;
1881+
1882+ if (!mt7615_firmware_offload(dev))
1883+ return 0;
1884+
1885+ if (!mt76_is_mmio(mphy->dev))
1886+ return 0;
1887+
1888+ if (!test_bit(MT76_STATE_PM, &mphy->state))
1889+ return 0;
1890+
1891+ if (test_bit(MT76_HW_SCANNING, &mphy->state) ||
1892+ test_bit(MT76_HW_SCHED_SCANNING, &mphy->state))
1893+ return 0;
1894+
1895+ if (queue_work(dev->mt76.wq, &dev->pm.wake_work))
1896+ reinit_completion(&dev->pm.wake_cmpl);
1897+
1898+ if (!wait_for_completion_timeout(&dev->pm.wake_cmpl, 3 * HZ)) {
1899+ ieee80211_wake_queues(mphy->hw);
1900+ return -ETIMEDOUT;
1901+ }
1902+
1903+ return 0;
1904+}
1905+EXPORT_SYMBOL_GPL(mt7615_pm_wake);
1906+
1907+void mt7615_pm_power_save_sched(struct mt7615_dev *dev)
1908+{
1909+ struct mt76_phy *mphy = dev->phy.mt76;
1910+
1911+ if (!mt7615_firmware_offload(dev))
1912+ return;
1913+
1914+ if (!mt76_is_mmio(mphy->dev))
1915+ return;
1916+
1917+ if (!dev->pm.enable || !test_bit(MT76_STATE_RUNNING, &mphy->state))
1918+ return;
1919+
1920+ dev->pm.last_activity = jiffies;
1921+
1922+ if (test_bit(MT76_HW_SCANNING, &mphy->state) ||
1923+ test_bit(MT76_HW_SCHED_SCANNING, &mphy->state))
1924+ return;
1925+
1926+ if (!test_bit(MT76_STATE_PM, &mphy->state))
1927+ queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work,
1928+ dev->pm.idle_timeout);
1929+}
1930+EXPORT_SYMBOL_GPL(mt7615_pm_power_save_sched);
1931+
1932+void mt7615_pm_power_save_work(struct work_struct *work)
1933+{
1934+ struct mt7615_dev *dev;
1935+ unsigned long delta;
1936+
1937+ dev = (struct mt7615_dev *)container_of(work, struct mt7615_dev,
1938+ pm.ps_work.work);
1939+
1940+ delta = dev->pm.idle_timeout;
1941+ if (time_is_after_jiffies(dev->pm.last_activity + delta)) {
1942+ delta = dev->pm.last_activity + delta - jiffies;
1943+ goto out;
1944+ }
1945+
1946+ if (!mt7615_firmware_own(dev))
1947+ return;
1948+out:
1949+ queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta);
1950+}
1951+
1952+static void
1953+mt7615_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif)
1954+{
1955+ struct mt7615_phy *phy = priv;
1956+ struct mt7615_dev *dev = phy->dev;
1957+ bool ext_phy = phy != &dev->phy;
1958+
1959+ if (mt7615_mcu_set_bss_pm(dev, vif, dev->pm.enable))
1960+ return;
1961+
1962+ if (dev->pm.enable) {
1963+ vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
1964+ mt76_set(dev, MT_WF_RFCR(ext_phy),
1965+ MT_WF_RFCR_DROP_OTHER_BEACON);
1966+ } else {
1967+ vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
1968+ mt76_clear(dev, MT_WF_RFCR(ext_phy),
1969+ MT_WF_RFCR_DROP_OTHER_BEACON);
1970+ }
1971+}
1972+
1973+int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable)
1974+{
1975+ struct mt76_phy *mphy = dev->phy.mt76;
1976+
1977+ if (!mt7615_firmware_offload(dev) || !mt76_is_mmio(&dev->mt76))
1978+ return -EOPNOTSUPP;
1979+
1980+ mt7615_mutex_acquire(dev);
1981+
1982+ if (dev->pm.enable == enable)
1983+ goto out;
1984+
1985+ dev->pm.enable = enable;
1986+ ieee80211_iterate_active_interfaces(mphy->hw,
1987+ IEEE80211_IFACE_ITER_RESUME_ALL,
1988+ mt7615_pm_interface_iter, mphy->priv);
1989+out:
1990+ mt7615_mutex_release(dev);
1991+
1992+ return 0;
1993+}
1994+
17431995 void mt7615_mac_work(struct work_struct *work)
17441996 {
17451997 struct mt7615_phy *phy;
@@ -1749,9 +2001,9 @@ void mt7615_mac_work(struct work_struct *work) · 3 unmodified lines
17492001 mac_work.work);
17502002 mdev = &phy->dev->mt76;
17512003
1752− mutex_lock(&mdev->mutex);
2004+ mt7615_mutex_acquire(phy->dev);
17532005
1754− mt76_update_survey(mdev);
2006+ mt7615_update_survey(phy->dev);
17552007 if (++phy->mac_work_count == 5) {
17562008 phy->mac_work_count = 0;
17572009
@@ -1759,7 +2011,7 @@ void mt7615_mac_work(struct work_struct *work) · 1 unmodified line
17592011 mt7615_mac_scs_check(phy);
17602012 }
17612013
1762− mutex_unlock(&mdev->mutex);
2014+ mt7615_mutex_release(phy->dev);
17632015
17642016 mt76_tx_status_check(mdev, NULL, false);
17652017 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mac_work,
@@ -1863,7 +2115,7 @@ void mt7615_mac_reset_work(struct work_struct *work) · 97 unmodified lines
18632115 napi_disable(&dev->mt76.napi[1]);
18642116 napi_disable(&dev->mt76.tx_napi);
18652117
1866− mutex_lock(&dev->mt76.mutex);
2118+ mt7615_mutex_acquire(dev);
18672119
18682120 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_PDMA_STOPPED);
18692121
@@ -1896,10 +2148,10 @@ void mt7615_mac_reset_work(struct work_struct *work) · 26 unmodified lines
18962148 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_RESET_DONE);
18972149 mt7615_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE);
18982150
1899− mutex_unlock(&dev->mt76.mutex);
1900−
19012151 mt7615_update_beacons(dev);
19022152
2153+ mt7615_mutex_release(dev);
2154+
19032155 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->phy.mac_work,
19042156 MT7615_WATCHDOG_TIME);
19052157 if (phy2)
drivers/net/wireless/mediatek/mt76/mt7615/mac.h+5−0
@@ -100,11 +100,16 @@ enum rx_pkt_type { · 99 unmodified lines
100100 #define MT_RXV2_GROUP_ID GENMASK(26, 21)
101101 #define MT_RXV2_LENGTH GENMASK(20, 0)
102102
103+#define MT_RXV3_WB_RSSI GENMASK(31, 24)
104+#define MT_RXV3_IB_RSSI GENMASK(23, 16)
105+
103106 #define MT_RXV4_RCPI3 GENMASK(31, 24)
104107 #define MT_RXV4_RCPI2 GENMASK(23, 16)
105108 #define MT_RXV4_RCPI1 GENMASK(15, 8)
106109 #define MT_RXV4_RCPI0 GENMASK(7, 0)
107110
111+#define MT_RXV5_FOE GENMASK(11, 0)
112+
108113 #define MT_RXV6_NF3 GENMASK(31, 24)
109114 #define MT_RXV6_NF2 GENMASK(23, 16)
110115 #define MT_RXV6_NF1 GENMASK(15, 8)
drivers/net/wireless/mediatek/mt76/mt7615/main.c+269−63
@@ -24,6 +24,22 @@ static bool mt7615_dev_running(struct mt7615_dev *dev) · 23 unmodified lines
2424 return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state);
2525 }
2626
27+static void mt7615_free_pending_tx_skbs(struct mt7615_dev *dev,
28+ struct mt7615_sta *msta)
29+{
30+ int i;
31+
32+ spin_lock_bh(&dev->pm.txq_lock);
33+ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
34+ if (msta && dev->pm.tx_q[i].msta != msta)
35+ continue;
36+
37+ dev_kfree_skb(dev->pm.tx_q[i].skb);
38+ dev->pm.tx_q[i].skb = NULL;
39+ }
40+ spin_unlock_bh(&dev->pm.txq_lock);
41+}
42+
2743 static int mt7615_start(struct ieee80211_hw *hw)
2844 {
2945 struct mt7615_dev *dev = mt7615_hw_dev(hw);
@@ -33,7 +49,7 @@ static int mt7615_start(struct ieee80211_hw *hw) · 3 unmodified lines
3349 if (!mt7615_wait_for_mcu_init(dev))
3450 return -EIO;
3551
36− mutex_lock(&dev->mt76.mutex);
52+ mt7615_mutex_acquire(dev);
3753
3854 running = mt7615_dev_running(dev);
3955
@@ -60,7 +76,7 @@ static int mt7615_start(struct ieee80211_hw *hw) · 20 unmodified lines
6076 if (!running)
6177 mt7615_mac_reset_counters(dev);
6278
63− mutex_unlock(&dev->mt76.mutex);
79+ mt7615_mutex_release(dev);
6480
6581 return 0;
6682 }
@@ -74,7 +90,14 @@ static void mt7615_stop(struct ieee80211_hw *hw) · 7 unmodified lines
7490 del_timer_sync(&phy->roc_timer);
7591 cancel_work_sync(&phy->roc_work);
7692
77− mutex_lock(&dev->mt76.mutex);
93+ cancel_delayed_work_sync(&dev->pm.ps_work);
94+ cancel_work_sync(&dev->pm.wake_work);
95+
96+ mt7615_free_pending_tx_skbs(dev, NULL);
97+
98+ mt7615_mutex_acquire(dev);
99+
100+ mt76_testmode_reset(&dev->mt76, true);
78101
79102 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
80103 cancel_delayed_work_sync(&phy->scan_work);
@@ -89,7 +112,7 @@ static void mt7615_stop(struct ieee80211_hw *hw) · 8 unmodified lines
89112 mt7615_mcu_set_mac_enable(dev, 0, false);
90113 }
91114
92− mutex_unlock(&dev->mt76.mutex);
115+ mt7615_mutex_release(dev);
93116 }
94117
95118 static int get_omac_idx(enum nl80211_iftype type, u32 mask)
@@ -135,9 +158,15 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, · 39 unmodified lines
135158 bool ext_phy = phy != &dev->phy;
136159 int idx, ret = 0;
137160
138− mutex_lock(&dev->mt76.mutex);
161+ mt7615_mutex_acquire(dev);
162+
163+ mt76_testmode_reset(&dev->mt76, true);
139164
140− mvif->idx = ffs(~dev->vif_mask) - 1;
165+ if (vif->type == NL80211_IFTYPE_MONITOR &&
166+ is_zero_ether_addr(vif->addr))
167+ phy->monitor_vif = vif;
168+
169+ mvif->idx = ffs(~dev->mphy.vif_mask) - 1;
141170 if (mvif->idx >= MT7615_MAX_INTERFACES) {
142171 ret = -ENOSPC;
143172 goto out;
@@ -157,7 +186,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, · 13 unmodified lines
157186 else
158187 mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
159188
160− dev->vif_mask |= BIT(mvif->idx);
189+ dev->mphy.vif_mask |= BIT(mvif->idx);
161190 dev->omac_mask |= BIT(mvif->omac_idx);
162191 phy->omac_mask |= BIT(mvif->omac_idx);
163192
@@ -180,8 +209,20 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, · 16 unmodified lines
180209 }
181210
182211 ret = mt7615_mcu_add_dev_info(dev, vif, true);
212+ if (ret)
213+ goto out;
214+
215+ if (dev->pm.enable) {
216+ ret = mt7615_mcu_set_bss_pm(dev, vif, true);
217+ if (ret)
218+ goto out;
219+
220+ vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
221+ mt76_set(dev, MT_WF_RFCR(ext_phy),
222+ MT_WF_RFCR_DROP_OTHER_BEACON);
223+ }
183224 out:
184− mutex_unlock(&dev->mt76.mutex);
225+ mt7615_mutex_release(dev);
185226
186227 return ret;
187228 }
@@ -197,17 +238,32 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw, · 9 unmodified lines
197238
198239 /* TODO: disable beacon for the bss */
199240
241+ mt7615_mutex_acquire(dev);
242+
243+ mt76_testmode_reset(&dev->mt76, true);
244+ if (vif == phy->monitor_vif)
245+ phy->monitor_vif = NULL;
246+
247+ mt7615_free_pending_tx_skbs(dev, msta);
248+
249+ if (dev->pm.enable) {
250+ bool ext_phy = phy != &dev->phy;
251+
252+ mt7615_mcu_set_bss_pm(dev, vif, false);
253+ mt76_clear(dev, MT_WF_RFCR(ext_phy),
254+ MT_WF_RFCR_DROP_OTHER_BEACON);
255+ }
200256 mt7615_mcu_add_dev_info(dev, vif, false);
201257
202258 rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
203259 if (vif->txq)
204260 mt76_txq_remove(&dev->mt76, vif->txq);
205261
206− mutex_lock(&dev->mt76.mutex);
207− dev->vif_mask &= ~BIT(mvif->idx);
262+ dev->mphy.vif_mask &= ~BIT(mvif->idx);
208263 dev->omac_mask &= ~BIT(mvif->omac_idx);
209264 phy->omac_mask &= ~BIT(mvif->omac_idx);
210− mutex_unlock(&dev->mt76.mutex);
265+
266+ mt7615_mutex_release(dev);
211267
212268 spin_lock_bh(&dev->sta_poll_lock);
213269 if (!list_empty(&msta->poll_list))
@@ -234,7 +290,7 @@ static void mt7615_init_dfs_state(struct mt7615_phy *phy) · 20 unmodified lines
234290 phy->dfs_state = -1;
235291 }
236292
237−static int mt7615_set_channel(struct mt7615_phy *phy)
293+int mt7615_set_channel(struct mt7615_phy *phy)
238294 {
239295 struct mt7615_dev *dev = phy->dev;
240296 bool ext_phy = phy != &dev->phy;
@@ -242,7 +298,8 @@ static int mt7615_set_channel(struct mt7615_phy *phy) · 1 unmodified line
242298
243299 cancel_delayed_work_sync(&phy->mac_work);
244300
245− mutex_lock(&dev->mt76.mutex);
301+ mt7615_mutex_acquire(dev);
302+
246303 set_bit(MT76_RESET, &phy->mt76->state);
247304
248305 mt7615_init_dfs_state(phy);
@@ -260,7 +317,7 @@ static int mt7615_set_channel(struct mt7615_phy *phy) · 11 unmodified lines
260317 mt7615_mac_set_timing(phy);
261318 ret = mt7615_dfs_init_radar_detector(phy);
262319 mt7615_mac_cca_stats_reset(phy);
263− mt7615_mcu_set_sku_en(phy, true);
320+ mt7615_mcu_set_sku_en(phy, !mt76_testmode_enabled(&dev->mt76));
264321
265322 mt7615_mac_reset_counters(dev);
266323 phy->noise = 0;
@@ -268,11 +325,15 @@ static int mt7615_set_channel(struct mt7615_phy *phy) · 1 unmodified line
268325
269326 out:
270327 clear_bit(MT76_RESET, &phy->mt76->state);
271− mutex_unlock(&dev->mt76.mutex);
328+
329+ mt7615_mutex_release(dev);
272330
273331 mt76_txq_schedule_all(phy->mt76);
274− ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mac_work,
275− MT7615_WATCHDOG_TIME);
332+
333+ if (!mt76_testmode_enabled(&dev->mt76))
334+ ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mac_work,
335+ MT7615_WATCHDOG_TIME);
336+
276337 return ret;
277338 }
278339
@@ -301,7 +362,7 @@ mt7615_queue_key_update(struct mt7615_dev *dev, enum set_key_cmd cmd, · 22 unmodified lines
301362 wd->key.cmd = cmd;
302363
303364 list_add_tail(&wd->node, &dev->wd_head);
304− queue_work(dev->mt76.usb.wq, &dev->wtbl_work);
365+ queue_work(dev->mt76.wq, &dev->wtbl_work);
305366
306367 return 0;
307368 }
@@ -315,7 +376,7 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, · 7 unmodified lines
315376 struct mt7615_sta *msta = sta ? (struct mt7615_sta *)sta->drv_priv :
316377 &mvif->sta;
317378 struct mt76_wcid *wcid = &msta->wcid;
318− int idx = key->keyidx;
379+ int idx = key->keyidx, err;
319380
320381 /* The hardware does not support per-STA RX GTK, fallback
321382 * to software mode for these.
@@ -345,6 +406,8 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, · 23 unmodified lines
345406 return -EOPNOTSUPP;
346407 }
347408
409+ mt7615_mutex_acquire(dev);
410+
348411 if (cmd == SET_KEY) {
349412 key->hw_key_idx = wcid->idx;
350413 wcid->hw_key_idx = idx;
@@ -354,10 +417,14 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, · 3 unmodified lines
354417 mt76_wcid_key_setup(&dev->mt76, wcid,
355418 cmd == SET_KEY ? key : NULL);
356419
357− if (mt76_is_usb(&dev->mt76))
358− return mt7615_queue_key_update(dev, cmd, msta, key);
420+ if (mt76_is_mmio(&dev->mt76))
421+ err = mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
422+ else
423+ err = mt7615_queue_key_update(dev, cmd, msta, key);
424+
425+ mt7615_mutex_release(dev);
359426
360− return mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
427+ return err;
361428 }
362429
363430 static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
@@ -369,14 +436,23 @@ static int mt7615_config(struct ieee80211_hw *hw, u32 changed) · 5 unmodified lines
369436
370437 if (changed & (IEEE80211_CONF_CHANGE_CHANNEL |
371438 IEEE80211_CONF_CHANGE_POWER)) {
439+#ifdef CONFIG_NL80211_TESTMODE
440+ if (dev->mt76.test.state != MT76_TM_STATE_OFF) {
441+ mt7615_mutex_acquire(dev);
442+ mt76_testmode_reset(&dev->mt76, false);
443+ mt7615_mutex_release(dev);
444+ }
445+#endif
372446 ieee80211_stop_queues(hw);
373447 ret = mt7615_set_channel(phy);
374448 ieee80211_wake_queues(hw);
375449 }
376450
377− mutex_lock(&dev->mt76.mutex);
451+ mt7615_mutex_acquire(dev);
378452
379453 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
454+ mt76_testmode_reset(&dev->mt76, true);
455+
380456 if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
381457 phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
382458 else
@@ -385,7 +461,7 @@ static int mt7615_config(struct ieee80211_hw *hw, u32 changed) · 2 unmodified lines
385461 mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
386462 }
387463
388− mutex_unlock(&dev->mt76.mutex);
464+ mt7615_mutex_release(dev);
389465
390466 return ret;
391467 }
@@ -396,11 +472,17 @@ mt7615_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, · 4 unmodified lines
396472 {
397473 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
398474 struct mt7615_dev *dev = mt7615_hw_dev(hw);
475+ int err;
476+
477+ mt7615_mutex_acquire(dev);
399478
400479 queue = mt7615_lmac_mapping(dev, queue);
401480 queue += mvif->wmm_idx * MT7615_MAX_WMM_SETS;
481+ err = mt7615_mcu_set_wmm(dev, queue, params);
402482
403− return mt7615_mcu_set_wmm(dev, queue, params);
483+ mt7615_mutex_release(dev);
484+
485+ return err;
404486 }
405487
406488 static void mt7615_configure_filter(struct ieee80211_hw *hw,
@@ -419,10 +501,13 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw, · 12 unmodified lines
419501 MT_WF_RFCR1_DROP_CFACK;
420502 u32 flags = 0;
421503
504+ mt7615_mutex_acquire(dev);
505+
422506 #define MT76_FILTER(_flag, _hw) do { \
423507 flags |= *total_flags & FIF_##_flag; \
424508 phy->rxfilter &= ~(_hw); \
425− phy->rxfilter |= !(flags & FIF_##_flag) * (_hw); \
509+ if (!mt76_testmode_enabled(&dev->mt76)) \
510+ phy->rxfilter |= !(flags & FIF_##_flag) * (_hw);\
426511 } while (0)
427512
428513 phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS |
@@ -455,6 +540,8 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw, · 26 unmodified lines
455540 mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags);
456541 else
457542 mt76_set(dev, MT_WF_RFCR1(band), ctl_flags);
543+
544+ mt7615_mutex_release(dev);
458545 }
459546
460547 static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
@@ -465,7 +552,7 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw, · 4 unmodified lines
465552 struct mt7615_dev *dev = mt7615_hw_dev(hw);
466553 struct mt7615_phy *phy = mt7615_hw_phy(hw);
467554
468− mutex_lock(&dev->mt76.mutex);
555+ mt7615_mutex_acquire(dev);
469556
470557 if (changed & BSS_CHANGED_ERP_SLOT) {
471558 int slottime = info->use_short_slot ? 9 : 20;
@@ -491,7 +578,10 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw, · 19 unmodified lines
491578 if (changed & BSS_CHANGED_PS)
492579 mt7615_mcu_set_vif_ps(dev, vif);
493580
494− mutex_unlock(&dev->mt76.mutex);
581+ if (changed & BSS_CHANGED_ARP_FILTER)
582+ mt7615_mcu_update_arp_filter(hw, vif, info);
583+
584+ mt7615_mutex_release(dev);
495585 }
496586
497587 static void
@@ -501,9 +591,9 @@ mt7615_channel_switch_beacon(struct ieee80211_hw *hw, · 3 unmodified lines
501591 {
502592 struct mt7615_dev *dev = mt7615_hw_dev(hw);
503593
504− mutex_lock(&dev->mt76.mutex);
594+ mt7615_mutex_acquire(dev);
505595 mt7615_mcu_add_beacon(dev, hw, vif, true);
506− mutex_unlock(&dev->mt76.mutex);
596+ mt7615_mutex_release(dev);
507597 }
508598
509599 int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
@@ -512,7 +602,7 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 2 unmodified lines
512602 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
513603 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
514604 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
515− int idx;
605+ int idx, err;
516606
517607 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7615_WTBL_STA - 1);
518608 if (idx < 0)
@@ -524,6 +614,10 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 5 unmodified lines
524614 msta->wcid.idx = idx;
525615 msta->wcid.ext_phy = mvif->band_idx;
526616
617+ err = mt7615_pm_wake(dev);
618+ if (err)
619+ return err;
620+
527621 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
528622 struct mt7615_phy *phy;
529623
@@ -534,6 +628,8 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 4 unmodified lines
534628 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
535629 mt7615_mcu_sta_add(dev, vif, sta, true);
536630
631+ mt7615_pm_power_save_sched(dev);
632+
537633 return 0;
538634 }
539635 EXPORT_SYMBOL_GPL(mt7615_mac_sta_add);
@@ -544,6 +640,9 @@ void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 4 unmodified lines
544640 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
545641 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
546642
643+ mt7615_free_pending_tx_skbs(dev, msta);
644+ mt7615_pm_wake(dev);
645+
547646 mt7615_mcu_sta_add(dev, vif, sta, false);
548647 mt7615_mac_wtbl_update(dev, msta->wcid.idx,
549648 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
@@ -559,6 +658,8 @@ void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 9 unmodified lines
559658 if (!list_empty(&msta->poll_list))
560659 list_del_init(&msta->poll_list);
561660 spin_unlock_bh(&dev->sta_poll_lock);
661+
662+ mt7615_pm_power_save_sched(dev);
562663 }
563664 EXPORT_SYMBOL_GPL(mt7615_mac_sta_remove);
564665
@@ -582,11 +683,29 @@ static void mt7615_sta_rate_tbl_update(struct ieee80211_hw *hw, · 17 unmodified lines
582683 break;
583684 }
584685 msta->n_rates = i;
585− mt7615_mac_set_rates(phy, msta, NULL, msta->rates);
586− msta->rate_probe = false;
686+ if (!test_bit(MT76_STATE_PM, &phy->mt76->state))
687+ mt7615_mac_set_rates(phy, msta, NULL, msta->rates);
587688 spin_unlock_bh(&dev->mt76.lock);
588689 }
589690
691+static void
692+mt7615_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
693+{
694+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
695+ struct mt7615_phy *phy = mt7615_hw_phy(hw);
696+ struct mt76_phy *mphy = phy->mt76;
697+
698+ if (!test_bit(MT76_STATE_RUNNING, &mphy->state))
699+ return;
700+
701+ if (test_bit(MT76_STATE_PM, &mphy->state)) {
702+ queue_work(dev->mt76.wq, &dev->pm.wake_work);
703+ return;
704+ }
705+
706+ tasklet_schedule(&dev->mt76.tx_tasklet);
707+}
708+
590709 static void mt7615_tx(struct ieee80211_hw *hw,
591710 struct ieee80211_tx_control *control,
592711 struct sk_buff *skb)
@@ -596,22 +715,43 @@ static void mt7615_tx(struct ieee80211_hw *hw, · 3 unmodified lines
596715 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
597716 struct ieee80211_vif *vif = info->control.vif;
598717 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
718+ struct mt7615_sta *msta = NULL;
719+ int qid;
599720
600721 if (control->sta) {
601− struct mt7615_sta *sta;
602−
603− sta = (struct mt7615_sta *)control->sta->drv_priv;
604− wcid = &sta->wcid;
722+ msta = (struct mt7615_sta *)control->sta->drv_priv;
723+ wcid = &msta->wcid;
605724 }
606725
607726 if (vif && !control->sta) {
608727 struct mt7615_vif *mvif;
609728
610729 mvif = (struct mt7615_vif *)vif->drv_priv;
611− wcid = &mvif->sta.wcid;
730+ msta = &mvif->sta;
731+ wcid = &msta->wcid;
732+ }
733+
734+ if (!test_bit(MT76_STATE_PM, &mphy->state)) {
735+ mt76_tx(mphy, control->sta, wcid, skb);
736+ return;
737+ }
738+
739+ qid = skb_get_queue_mapping(skb);
740+ if (qid >= MT_TXQ_PSD) {
741+ qid = IEEE80211_AC_BE;
742+ skb_set_queue_mapping(skb, qid);
612743 }
613744
614− mt76_tx(mphy, control->sta, wcid, skb);
745+ spin_lock_bh(&dev->pm.txq_lock);
746+ if (!dev->pm.tx_q[qid].skb) {
747+ ieee80211_stop_queues(hw);
748+ dev->pm.tx_q[qid].msta = msta;
749+ dev->pm.tx_q[qid].skb = skb;
750+ queue_work(dev->mt76.wq, &dev->pm.wake_work);
751+ } else {
752+ dev_kfree_skb(skb);
753+ }
754+ spin_unlock_bh(&dev->pm.txq_lock);
615755 }
616756
617757 static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
@@ -619,9 +759,9 @@ static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val) · 1 unmodified line
619759 struct mt7615_dev *dev = mt7615_hw_dev(hw);
620760 struct mt7615_phy *phy = mt7615_hw_phy(hw);
621761
622− mutex_lock(&dev->mt76.mutex);
762+ mt7615_mutex_acquire(dev);
623763 mt7615_mcu_set_rts_thresh(phy, val);
624− mutex_unlock(&dev->mt76.mutex);
764+ mt7615_mutex_release(dev);
625765
626766 return 0;
627767 }
@@ -645,7 +785,8 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 17 unmodified lines
645785
646786 mtxq = (struct mt76_txq *)txq->drv_priv;
647787
648− mutex_lock(&dev->mt76.mutex);
788+ mt7615_mutex_acquire(dev);
789+
649790 switch (action) {
650791 case IEEE80211_AMPDU_RX_START:
651792 mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
@@ -660,6 +801,9 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 8 unmodified lines
660801 mtxq->aggr = true;
661802 mtxq->send_bar = false;
662803 mt7615_mcu_add_tx_ba(dev, params, true);
804+ ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
805+ ieee80211_send_bar(vif, sta->addr, tid,
806+ IEEE80211_SN_TO_SEQ(ssn));
663807 break;
664808 case IEEE80211_AMPDU_TX_STOP_FLUSH:
665809 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
@@ -667,6 +811,8 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 1 unmodified line
667811 mt7615_mcu_add_tx_ba(dev, params, false);
668812 break;
669813 case IEEE80211_AMPDU_TX_START:
814+ ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
815+ params->ssn = ssn;
670816 mtxq->agg_ssn = IEEE80211_SN_TO_SEQ(ssn);
671817 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
672818 break;
@@ -676,7 +822,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 3 unmodified lines
676822 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
677823 break;
678824 }
679− mutex_unlock(&dev->mt76.mutex);
825+ mt7615_mutex_release(dev);
680826
681827 return ret;
682828 }
@@ -721,27 +867,47 @@ mt7615_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 38 unmodified lines
721867 u32 t32[2];
722868 } tsf;
723869
724− mutex_lock(&dev->mt76.mutex);
870+ mt7615_mutex_acquire(dev);
725871
726872 mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */
727873 tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0);
728874 tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1);
729875
730− mutex_unlock(&dev->mt76.mutex);
876+ mt7615_mutex_release(dev);
731877
732878 return tsf.t64;
733879 }
734880
881+static void
882+mt7615_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
883+ u64 timestamp)
884+{
885+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
886+ union {
887+ u64 t64;
888+ u32 t32[2];
889+ } tsf = { .t64 = timestamp, };
890+
891+ mt7615_mutex_acquire(dev);
892+
893+ mt76_wr(dev, MT_LPON_UTTR0, tsf.t32[0]);
894+ mt76_wr(dev, MT_LPON_UTTR1, tsf.t32[1]);
895+ /* TSF software overwrite */
896+ mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_WRITE);
897+
898+ mt7615_mutex_release(dev);
899+}
900+
735901 static void
736902 mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
737903 {
738904 struct mt7615_phy *phy = mt7615_hw_phy(hw);
739905 struct mt7615_dev *dev = phy->dev;
740906
741− mutex_lock(&dev->mt76.mutex);
907+ mt7615_mutex_acquire(dev);
742908 phy->coverage_class = max_t(s16, coverage_class, 0);
743909 mt7615_mac_set_timing(phy);
744− mutex_unlock(&dev->mt76.mutex);
910+ mt7615_mutex_release(dev);
745911 }
746912
747913 static int
@@ -758,7 +924,7 @@ mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) · 10 unmodified lines
758924 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
759925 tx_ant = BIT(ffs(tx_ant) - 1) - 1;
760926
761− mutex_lock(&dev->mt76.mutex);
927+ mt7615_mutex_acquire(dev);
762928
763929 phy->mt76->antenna_mask = tx_ant;
764930 if (ext_phy) {
@@ -771,7 +937,7 @@ mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) · 6 unmodified lines
771937
772938 mt76_set_stream_caps(phy->mt76, true);
773939
774− mutex_unlock(&dev->mt76.mutex);
940+ mt7615_mutex_release(dev);
775941
776942 return 0;
777943 }
@@ -794,9 +960,11 @@ void mt7615_roc_work(struct work_struct *work) · 16 unmodified lines
794960 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
795961 return;
796962
963+ mt7615_mutex_acquire(phy->dev);
797964 ieee80211_iterate_active_interfaces(phy->mt76->hw,
798965 IEEE80211_IFACE_ITER_RESUME_ALL,
799966 mt7615_roc_iter, phy);
967+ mt7615_mutex_release(phy->dev);
800968 ieee80211_remain_on_channel_expired(phy->mt76->hw);
801969 }
802970
@@ -844,17 +1012,26 @@ static int · 41 unmodified lines
8441012 mt7615_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
8451013 struct ieee80211_scan_request *req)
8461014 {
1015+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
8471016 struct mt76_phy *mphy = hw->priv;
1017+ int err;
1018+
1019+ mt7615_mutex_acquire(dev);
1020+ err = mt7615_mcu_hw_scan(mphy->priv, vif, req);
1021+ mt7615_mutex_release(dev);
8481022
849− return mt7615_mcu_hw_scan(mphy->priv, vif, req);
1023+ return err;
8501024 }
8511025
8521026 static void
8531027 mt7615_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
8541028 {
1029+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
8551030 struct mt76_phy *mphy = hw->priv;
8561031
1032+ mt7615_mutex_acquire(dev);
8571033 mt7615_mcu_cancel_hw_scan(mphy->priv, vif);
1034+ mt7615_mutex_release(dev);
8581035 }
8591036
8601037 static int
@@ -862,22 +1039,35 @@ mt7615_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 1 unmodified line
8621039 struct cfg80211_sched_scan_request *req,
8631040 struct ieee80211_scan_ies *ies)
8641041 {
1042+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
8651043 struct mt76_phy *mphy = hw->priv;
8661044 int err;
8671045
1046+ mt7615_mutex_acquire(dev);
1047+
8681048 err = mt7615_mcu_sched_scan_req(mphy->priv, vif, req);
8691049 if (err < 0)
870− return err;
1050+ goto out;
1051+
1052+ err = mt7615_mcu_sched_scan_enable(mphy->priv, vif, true);
1053+out:
1054+ mt7615_mutex_release(dev);
8711055
872− return mt7615_mcu_sched_scan_enable(mphy->priv, vif, true);
1056+ return err;
8731057 }
8741058
8751059 static int
8761060 mt7615_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
8771061 {
1062+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
8781063 struct mt76_phy *mphy = hw->priv;
1064+ int err;
8791065
880− return mt7615_mcu_sched_scan_enable(mphy->priv, vif, false);
1066+ mt7615_mutex_acquire(dev);
1067+ err = mt7615_mcu_sched_scan_enable(mphy->priv, vif, false);
1068+ mt7615_mutex_release(dev);
1069+
1070+ return err;
8811071 }
8821072
8831073 static int mt7615_remain_on_channel(struct ieee80211_hw *hw,
@@ -892,20 +1082,24 @@ static int mt7615_remain_on_channel(struct ieee80211_hw *hw, · 8 unmodified lines
8921082 if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))
8931083 return 0;
8941084
1085+ mt7615_mutex_acquire(phy->dev);
1086+
8951087 err = mt7615_mcu_set_roc(phy, vif, chan, duration);
8961088 if (err < 0) {
8971089 clear_bit(MT76_STATE_ROC, &phy->mt76->state);
898− return err;
1090+ goto out;
8991091 }
9001092
9011093 if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, HZ)) {
9021094 mt7615_mcu_set_roc(phy, vif, NULL, 0);
9031095 clear_bit(MT76_STATE_ROC, &phy->mt76->state);
904−
905− return -ETIMEDOUT;
1096+ err = -ETIMEDOUT;
9061097 }
9071098
908− return 0;
1099+out:
1100+ mt7615_mutex_release(phy->dev);
1101+
1102+ return err;
9091103 }
9101104
9111105 static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw,
@@ -919,7 +1113,9 @@ static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw, · 7 unmodified lines
9191113 del_timer_sync(&phy->roc_timer);
9201114 cancel_work_sync(&phy->roc_work);
9211115
1116+ mt7615_mutex_acquire(phy->dev);
9221117 mt7615_mcu_set_roc(phy, vif, NULL, 0);
1118+ mt7615_mutex_release(phy->dev);
9231119
9241120 return 0;
9251121 }
@@ -933,7 +1129,10 @@ static int mt7615_suspend(struct ieee80211_hw *hw, · 7 unmodified lines
9331129 bool ext_phy = phy != &dev->phy;
9341130 int err = 0;
9351131
936− mutex_lock(&dev->mt76.mutex);
1132+ cancel_delayed_work_sync(&dev->pm.ps_work);
1133+ mt7615_free_pending_tx_skbs(dev, NULL);
1134+
1135+ mt7615_mutex_acquire(dev);
9371136
9381137 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
9391138 cancel_delayed_work_sync(&phy->scan_work);
@@ -949,7 +1148,7 @@ static int mt7615_suspend(struct ieee80211_hw *hw, · 9 unmodified lines
9491148 if (!mt7615_dev_running(dev))
9501149 err = mt7615_mcu_set_hif_suspend(dev, true);
9511150
952− mutex_unlock(&dev->mt76.mutex);
1151+ mt7615_mutex_release(dev);
9531152
9541153 return err;
9551154 }
@@ -960,7 +1159,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) · 4 unmodified lines
9601159 struct mt7615_phy *phy = mt7615_hw_phy(hw);
9611160 bool running, ext_phy = phy != &dev->phy;
9621161
963− mutex_lock(&dev->mt76.mutex);
1162+ mt7615_mutex_acquire(dev);
9641163
9651164 running = mt7615_dev_running(dev);
9661165 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
@@ -970,7 +1169,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) · 3 unmodified lines
9701169
9711170 err = mt7615_mcu_set_hif_suspend(dev, false);
9721171 if (err < 0) {
973− mutex_unlock(&dev->mt76.mutex);
1172+ mt7615_mutex_release(dev);
9741173 return err;
9751174 }
9761175 }
@@ -984,7 +1183,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) · 7 unmodified lines
9841183 MT7615_WATCHDOG_TIME);
9851184 mt76_clear(dev, MT_WF_RFCR(ext_phy), MT_WF_RFCR_DROP_OTHER_BEACON);
9861185
987− mutex_unlock(&dev->mt76.mutex);
1186+ mt7615_mutex_release(dev);
9881187
9891188 return 0;
9901189 }
@@ -1001,7 +1200,11 @@ static void mt7615_set_rekey_data(struct ieee80211_hw *hw, · 10 unmodified lines
10011200 struct ieee80211_vif *vif,
10021201 struct cfg80211_gtk_rekey_data *data)
10031202 {
1203+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
1204+
1205+ mt7615_mutex_acquire(dev);
10041206 mt7615_mcu_update_gtk_rekey(hw, vif, data);
1207+ mt7615_mutex_release(dev);
10051208 }
10061209 #endif /* CONFIG_PM */
10071210
@@ -1021,7 +1224,7 @@ const struct ieee80211_ops mt7615_ops = { · 13 unmodified lines
10211224 .set_key = mt7615_set_key,
10221225 .ampdu_action = mt7615_ampdu_action,
10231226 .set_rts_threshold = mt7615_set_rts_threshold,
1024− .wake_tx_queue = mt76_wake_tx_queue,
1227+ .wake_tx_queue = mt7615_wake_tx_queue,
10251228 .sta_rate_tbl_update = mt7615_sta_rate_tbl_update,
10261229 .sw_scan_start = mt76_sw_scan,
10271230 .sw_scan_complete = mt76_sw_scan_complete,
@@ -1030,6 +1233,7 @@ const struct ieee80211_ops mt7615_ops = { · 2 unmodified lines
10301233 .channel_switch_beacon = mt7615_channel_switch_beacon,
10311234 .get_stats = mt7615_get_stats,
10321235 .get_tsf = mt7615_get_tsf,
1236+ .set_tsf = mt7615_set_tsf,
10331237 .get_survey = mt76_get_survey,
10341238 .get_antenna = mt76_get_antenna,
10351239 .set_antenna = mt7615_set_antenna,
@@ -1040,6 +1244,8 @@ const struct ieee80211_ops mt7615_ops = { · 4 unmodified lines
10401244 .sched_scan_stop = mt7615_stop_sched_scan,
10411245 .remain_on_channel = mt7615_remain_on_channel,
10421246 .cancel_remain_on_channel = mt7615_cancel_remain_on_channel,
1247+ CFG80211_TESTMODE_CMD(mt76_testmode_cmd)
1248+ CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
10431249 #ifdef CONFIG_PM
10441250 .suspend = mt7615_suspend,
10451251 .resume = mt7615_resume,
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c+313−58
@@ -146,13 +146,19 @@ void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb, · 145 unmodified lines
146146 mcu_txd->cid = mcu_cmd;
147147 break;
148148 case MCU_CE_PREFIX:
149− mcu_txd->set_query = MCU_Q_SET;
149+ if (cmd & MCU_QUERY_MASK)
150+ mcu_txd->set_query = MCU_Q_QUERY;
151+ else
152+ mcu_txd->set_query = MCU_Q_SET;
150153 mcu_txd->cid = mcu_cmd;
151154 break;
152155 default:
153156 mcu_txd->cid = MCU_CMD_EXT_CID;
154− mcu_txd->set_query = MCU_Q_SET;
155− mcu_txd->ext_cid = cmd;
157+ if (cmd & MCU_QUERY_PREFIX)
158+ mcu_txd->set_query = MCU_Q_QUERY;
159+ else
160+ mcu_txd->set_query = MCU_Q_SET;
161+ mcu_txd->ext_cid = mcu_cmd;
156162 mcu_txd->ext_cid_ack = 1;
157163 break;
158164 }
@@ -180,8 +186,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, · 21 unmodified lines
180186 struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;
181187 int ret = 0;
182188
183− if (seq != rxd->seq)
184− return -EAGAIN;
189+ if (seq != rxd->seq) {
190+ ret = -EAGAIN;
191+ goto out;
192+ }
185193
186194 switch (cmd) {
187195 case MCU_CMD_PATCH_SEM_CONTROL:
@@ -192,6 +200,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, · 4 unmodified lines
192200 skb_pull(skb, sizeof(*rxd));
193201 ret = le32_to_cpu(*(__le32 *)skb->data);
194202 break;
203+ case MCU_EXT_CMD_RF_REG_ACCESS | MCU_QUERY_PREFIX:
204+ skb_pull(skb, sizeof(*rxd));
205+ ret = le32_to_cpu(*(__le32 *)&skb->data[8]);
206+ break;
195207 case MCU_UNI_CMD_DEV_INFO_UPDATE:
196208 case MCU_UNI_CMD_BSS_INFO_UPDATE:
197209 case MCU_UNI_CMD_STA_REC_UPDATE:
@@ -205,9 +217,18 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, · 7 unmodified lines
205217 ret = le32_to_cpu(event->status);
206218 break;
207219 }
220+ case MCU_CMD_REG_READ: {
221+ struct mt7615_mcu_reg_event *event;
222+
223+ skb_pull(skb, sizeof(*rxd));
224+ event = (struct mt7615_mcu_reg_event *)skb->data;
225+ ret = (int)le32_to_cpu(event->val);
226+ break;
227+ }
208228 default:
209229 break;
210230 }
231+out:
211232 dev_kfree_skb(skb);
212233
213234 return ret;
@@ -271,6 +292,38 @@ int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, · 57 unmodified lines
271292 }
272293 EXPORT_SYMBOL_GPL(mt7615_mcu_msg_send);
273294
295+u32 mt7615_rf_rr(struct mt7615_dev *dev, u32 wf, u32 reg)
296+{
297+ struct {
298+ __le32 wifi_stream;
299+ __le32 address;
300+ __le32 data;
301+ } req = {
302+ .wifi_stream = cpu_to_le32(wf),
303+ .address = cpu_to_le32(reg),
304+ };
305+
306+ return __mt76_mcu_send_msg(&dev->mt76,
307+ MCU_EXT_CMD_RF_REG_ACCESS | MCU_QUERY_PREFIX,
308+ &req, sizeof(req), true);
309+}
310+
311+int mt7615_rf_wr(struct mt7615_dev *dev, u32 wf, u32 reg, u32 val)
312+{
313+ struct {
314+ __le32 wifi_stream;
315+ __le32 address;
316+ __le32 data;
317+ } req = {
318+ .wifi_stream = cpu_to_le32(wf),
319+ .address = cpu_to_le32(reg),
320+ .data = cpu_to_le32(val),
321+ };
322+
323+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_RF_REG_ACCESS, &req,
324+ sizeof(req), false);
325+}
326+
274327 static void
275328 mt7615_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
276329 {
@@ -926,6 +979,38 @@ mt7615_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) · 649 unmodified lines
926979 }
927980 }
928981
982+static void
983+mt7615_mcu_sta_uapsd(struct sk_buff *skb, struct ieee80211_vif *vif,
984+ struct ieee80211_sta *sta)
985+{
986+ struct sta_rec_uapsd *uapsd;
987+ struct tlv *tlv;
988+
989+ if (vif->type != NL80211_IFTYPE_AP || !sta->wme)
990+ return;
991+
992+ tlv = mt7615_mcu_add_tlv(skb, STA_REC_APPS, sizeof(*uapsd));
993+ uapsd = (struct sta_rec_uapsd *)tlv;
994+
995+ if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) {
996+ uapsd->dac_map |= BIT(3);
997+ uapsd->tac_map |= BIT(3);
998+ }
999+ if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) {
1000+ uapsd->dac_map |= BIT(2);
1001+ uapsd->tac_map |= BIT(2);
1002+ }
1003+ if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) {
1004+ uapsd->dac_map |= BIT(1);
1005+ uapsd->tac_map |= BIT(1);
1006+ }
1007+ if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) {
1008+ uapsd->dac_map |= BIT(0);
1009+ uapsd->tac_map |= BIT(0);
1010+ }
1011+ uapsd->max_sp = sta->max_sp;
1012+}
1013+
9291014 static void
9301015 mt7615_mcu_wtbl_ba_tlv(struct sk_buff *skb,
9311016 struct ieee80211_ampdu_params *params,
@@ -1188,8 +1273,10 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 256 unmodified lines
11881273 return PTR_ERR(sskb);
11891274
11901275 mt7615_mcu_sta_basic_tlv(sskb, vif, sta, enable);
1191− if (enable && sta)
1276+ if (enable && sta) {
11921277 mt7615_mcu_sta_ht_tlv(sskb, sta);
1278+ mt7615_mcu_sta_uapsd(sskb, vif, sta);
1279+ }
11931280
11941281 wtbl_hdr = mt7615_mcu_alloc_wtbl_req(dev, msta, WTBL_RESET_AND_SET,
11951282 NULL, &wskb);
@@ -1206,8 +1293,12 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 10 unmodified lines
12061293 skb = enable ? wskb : sskb;
12071294
12081295 err = __mt76_mcu_skb_send_msg(&dev->mt76, skb, cmd, true);
1209− if (err < 0)
1296+ if (err < 0) {
1297+ skb = enable ? sskb : wskb;
1298+ dev_kfree_skb(skb);
1299+
12101300 return err;
1301+ }
12111302
12121303 cmd = enable ? MCU_EXT_CMD_STA_REC_UPDATE : MCU_EXT_CMD_WTBL_UPDATE;
12131304 skb = enable ? sskb : wskb;
@@ -1285,8 +1376,10 @@ mt7615_mcu_add_sta_cmd(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 71 unmodified lines
12851376 return PTR_ERR(skb);
12861377
12871378 mt7615_mcu_sta_basic_tlv(skb, vif, sta, enable);
1288− if (enable && sta)
1379+ if (enable && sta) {
12891380 mt7615_mcu_sta_ht_tlv(skb, sta);
1381+ mt7615_mcu_sta_uapsd(skb, vif, sta);
1382+ }
12901383
12911384 sta_wtbl = mt7615_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv));
12921385
@@ -1429,6 +1522,7 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif, · 136 unmodified lines
14291522 u8 pad[3];
14301523 } __packed hdr;
14311524 struct mt7615_bss_basic_tlv basic;
1525+ struct mt7615_bss_qos_tlv qos;
14321526 } basic_req = {
14331527 .hdr = {
14341528 .bss_idx = mvif->idx,
@@ -1444,6 +1538,11 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif, · 9 unmodified lines
14441538 .active = true, /* keep bss deactivated */
14451539 .phymode = 0x38,
14461540 },
1541+ .qos = {
1542+ .tag = cpu_to_le16(UNI_BSS_INFO_QBSS),
1543+ .len = cpu_to_le16(sizeof(struct mt7615_bss_qos_tlv)),
1544+ .qos = vif->bss_conf.qos,
1545+ },
14471546 };
14481547 struct {
14491548 struct {
@@ -1808,44 +1907,66 @@ static void mt7622_trigger_hif_int(struct mt7615_dev *dev, bool en) · 358 unmodified lines
18081907
18091908 int mt7615_driver_own(struct mt7615_dev *dev)
18101909 {
1910+ struct mt76_phy *mphy = &dev->mt76.phy;
18111911 struct mt76_dev *mdev = &dev->mt76;
1812− u32 addr;
1912+ int i;
18131913
1814− addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST;
1815− mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN);
1914+ if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
1915+ goto out;
18161916
18171917 mt7622_trigger_hif_int(dev, true);
18181918
1819− addr = is_mt7663(mdev) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
1820− if (!mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN, 0, 3000)) {
1821− dev_err(dev->mt76.dev, "Timeout for driver own\n");
1822− return -EIO;
1919+ for (i = 0; i < MT7615_DRV_OWN_RETRY_COUNT; i++) {
1920+ u32 addr;
1921+
1922+ addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST;
1923+ mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN);
1924+
1925+ addr = is_mt7663(mdev) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
1926+ if (mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN, 0, 50))
1927+ break;
18231928 }
18241929
18251930 mt7622_trigger_hif_int(dev, false);
18261931
1932+ if (i == MT7615_DRV_OWN_RETRY_COUNT) {
1933+ dev_err(mdev->dev, "driver own failed\n");
1934+ set_bit(MT76_STATE_PM, &mphy->state);
1935+ return -EIO;
1936+ }
1937+
1938+out:
1939+ dev->pm.last_activity = jiffies;
1940+
18271941 return 0;
18281942 }
18291943 EXPORT_SYMBOL_GPL(mt7615_driver_own);
18301944
18311945 int mt7615_firmware_own(struct mt7615_dev *dev)
18321946 {
1947+ struct mt76_phy *mphy = &dev->mt76.phy;
1948+ int err = 0;
18331949 u32 addr;
18341950
1835− addr = is_mt7663(&dev->mt76) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
1951+ if (test_and_set_bit(MT76_STATE_PM, &mphy->state))
1952+ return 0;
1953+
18361954 mt7622_trigger_hif_int(dev, true);
18371955
1956+ addr = is_mt7663(&dev->mt76) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
18381957 mt76_wr(dev, addr, MT_CFG_LPCR_HOST_FW_OWN);
18391958
1840− if (!is_mt7615(&dev->mt76) &&
1959+ if (is_mt7622(&dev->mt76) &&
18411960 !mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN,
1842− MT_CFG_LPCR_HOST_FW_OWN, 3000)) {
1961+ MT_CFG_LPCR_HOST_FW_OWN, 300)) {
18431962 dev_err(dev->mt76.dev, "Timeout for firmware own\n");
1844− return -EIO;
1963+ clear_bit(MT76_STATE_PM, &mphy->state);
1964+ err = -EIO;
18451965 }
1966+
18461967 mt7622_trigger_hif_int(dev, false);
18471968
1848− return 0;
1969+ return err;
18491970 }
18501971 EXPORT_SYMBOL_GPL(mt7615_firmware_own);
18511972
@@ -2725,6 +2846,14 @@ int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd) · 873 unmodified lines
27252846 .center_chan2 = ieee80211_frequency_to_channel(freq2),
27262847 };
27272848
2849+#ifdef CONFIG_NL80211_TESTMODE
2850+ if (dev->mt76.test.state == MT76_TM_STATE_TX_FRAMES &&
2851+ dev->mt76.test.tx_antenna_mask) {
2852+ req.tx_streams = hweight8(dev->mt76.test.tx_antenna_mask);
2853+ req.rx_streams_mask = dev->mt76.test.tx_antenna_mask;
2854+ }
2855+#endif
2856+
27282857 if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
27292858 req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
27302859 else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) &&
@@ -2736,7 +2865,10 @@ int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd) · 5 unmodified lines
27362865 req.band_idx = phy != &dev->phy;
27372866 req.bw = mt7615_mcu_chan_bw(chandef);
27382867
2739− mt7615_mcu_set_txpower_sku(phy, req.txpower_sku);
2868+ if (mt76_testmode_enabled(&dev->mt76))
2869+ memset(req.txpower_sku, 0x3f, 49);
2870+ else
2871+ mt7615_mcu_set_txpower_sku(phy, req.txpower_sku);
27402872
27412873 return __mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true);
27422874 }
@@ -2754,6 +2886,27 @@ int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index) · 11 unmodified lines
27542886 sizeof(req), true);
27552887 }
27562888
2889+int mt7615_mcu_set_test_param(struct mt7615_dev *dev, u8 param, bool test_mode,
2890+ u32 val)
2891+{
2892+ struct {
2893+ u8 test_mode_en;
2894+ u8 param_idx;
2895+ u8 _rsv[2];
2896+
2897+ __le32 value;
2898+
2899+ u8 pad[8];
2900+ } req = {
2901+ .test_mode_en = test_mode,
2902+ .param_idx = param,
2903+ .value = cpu_to_le32(val),
2904+ };
2905+
2906+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_ATE_CTRL, &req,
2907+ sizeof(req), false);
2908+}
2909+
27572910 int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable)
27582911 {
27592912 struct mt7615_dev *dev = phy->dev;
@@ -3332,43 +3485,8 @@ out: · 572 unmodified lines
33323485 return ret;
33333486 }
33343487
3335−#ifdef CONFIG_PM
3336−int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend)
3337−{
3338− struct {
3339− struct {
3340− u8 hif_type; /* 0x0: HIF_SDIO
3341− * 0x1: HIF_USB
3342− * 0x2: HIF_PCIE
3343− */
3344− u8 pad[3];
3345− } __packed hdr;
3346− struct hif_suspend_tlv {
3347− __le16 tag;
3348− __le16 len;
3349− u8 suspend;
3350− } __packed hif_suspend;
3351− } req = {
3352− .hif_suspend = {
3353− .tag = cpu_to_le16(0), /* 0: UNI_HIF_CTRL_BASIC */
3354− .len = cpu_to_le16(sizeof(struct hif_suspend_tlv)),
3355− .suspend = suspend,
3356− },
3357− };
3358−
3359− if (mt76_is_mmio(&dev->mt76))
3360− req.hdr.hif_type = 2;
3361− else if (mt76_is_usb(&dev->mt76))
3362− req.hdr.hif_type = 1;
3363−
3364− return __mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_HIF_CTRL,
3365− &req, sizeof(req), true);
3366−}
3367−EXPORT_SYMBOL_GPL(mt7615_mcu_set_hif_suspend);
3368−
3369−static int
3370−mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
3371− bool enable)
3488+int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
3489+ bool enable)
33723490 {
33733491 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
33743492 struct {
@@ -3408,6 +3526,40 @@ mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 33 unmodified lines
34083526 &req, sizeof(req), false);
34093527 }
34103528
3529+#ifdef CONFIG_PM
3530+int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend)
3531+{
3532+ struct {
3533+ struct {
3534+ u8 hif_type; /* 0x0: HIF_SDIO
3535+ * 0x1: HIF_USB
3536+ * 0x2: HIF_PCIE
3537+ */
3538+ u8 pad[3];
3539+ } __packed hdr;
3540+ struct hif_suspend_tlv {
3541+ __le16 tag;
3542+ __le16 len;
3543+ u8 suspend;
3544+ } __packed hif_suspend;
3545+ } req = {
3546+ .hif_suspend = {
3547+ .tag = cpu_to_le16(0), /* 0: UNI_HIF_CTRL_BASIC */
3548+ .len = cpu_to_le16(sizeof(struct hif_suspend_tlv)),
3549+ .suspend = suspend,
3550+ },
3551+ };
3552+
3553+ if (mt76_is_mmio(&dev->mt76))
3554+ req.hdr.hif_type = 2;
3555+ else if (mt76_is_usb(&dev->mt76))
3556+ req.hdr.hif_type = 1;
3557+
3558+ return __mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_HIF_CTRL,
3559+ &req, sizeof(req), true);
3560+}
3561+EXPORT_SYMBOL_GPL(mt7615_mcu_set_hif_suspend);
3562+
34113563 static int
34123564 mt7615_mcu_set_wow_ctrl(struct mt7615_phy *phy, struct ieee80211_vif *vif,
34133565 bool suspend, struct cfg80211_wowlan *wowlan)
@@ -3542,6 +3694,32 @@ mt7615_mcu_set_gtk_rekey(struct mt7615_dev *dev, · 128 unmodified lines
35423694 &req, sizeof(req), true);
35433695 }
35443696
3697+static int
3698+mt7615_mcu_set_arp_filter(struct mt7615_dev *dev, struct ieee80211_vif *vif,
3699+ bool suspend)
3700+{
3701+ struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
3702+ struct {
3703+ struct {
3704+ u8 bss_idx;
3705+ u8 pad[3];
3706+ } __packed hdr;
3707+ struct mt7615_arpns_tlv arpns;
3708+ } req = {
3709+ .hdr = {
3710+ .bss_idx = mvif->idx,
3711+ },
3712+ .arpns = {
3713+ .tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ARP),
3714+ .len = cpu_to_le16(sizeof(struct mt7615_arpns_tlv)),
3715+ .mode = suspend,
3716+ },
3717+ };
3718+
3719+ return __mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_OFFLOAD,
3720+ &req, sizeof(req), true);
3721+}
3722+
35453723 void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
35463724 struct ieee80211_vif *vif)
35473725 {
@@ -3554,6 +3732,7 @@ void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac, · 6 unmodified lines
35543732 mt7615_mcu_set_bss_pm(phy->dev, vif, suspend);
35553733
35563734 mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend);
3735+ mt7615_mcu_set_arp_filter(phy->dev, vif, suspend);
35573736
35583737 mt7615_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true);
35593738
@@ -3653,6 +3832,53 @@ int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif, · 93 unmodified lines
36533832 sizeof(req), false);
36543833 }
36553834
3835+int mt7615_mcu_update_arp_filter(struct ieee80211_hw *hw,
3836+ struct ieee80211_vif *vif,
3837+ struct ieee80211_bss_conf *info)
3838+{
3839+ struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
3840+ struct mt7615_dev *dev = mt7615_hw_dev(hw);
3841+ struct sk_buff *skb;
3842+ int i, len = min_t(int, info->arp_addr_cnt,
3843+ IEEE80211_BSS_ARP_ADDR_LIST_LEN);
3844+ struct {
3845+ struct {
3846+ u8 bss_idx;
3847+ u8 pad[3];
3848+ } __packed hdr;
3849+ struct mt7615_arpns_tlv arp;
3850+ } req_hdr = {
3851+ .hdr = {
3852+ .bss_idx = mvif->idx,
3853+ },
3854+ .arp = {
3855+ .tag = cpu_to_le16(UNI_OFFLOAD_OFFLOAD_ARP),
3856+ .len = cpu_to_le16(sizeof(struct mt7615_arpns_tlv)),
3857+ .ips_num = len,
3858+ .mode = 2, /* update */
3859+ .option = 1,
3860+ },
3861+ };
3862+
3863+ if (!mt7615_firmware_offload(dev))
3864+ return 0;
3865+
3866+ skb = mt76_mcu_msg_alloc(&dev->mt76, NULL,
3867+ sizeof(req_hdr) + len * sizeof(__be32));
3868+ if (!skb)
3869+ return -ENOMEM;
3870+
3871+ skb_put_data(skb, &req_hdr, sizeof(req_hdr));
3872+ for (i = 0; i < len; i++) {
3873+ u8 *addr = (u8 *)skb_put(skb, sizeof(__be32));
3874+
3875+ memcpy(addr, &info->arp_addr_list[i], sizeof(__be32));
3876+ }
3877+
3878+ return __mt76_mcu_skb_send_msg(&dev->mt76, skb,
3879+ MCU_UNI_CMD_OFFLOAD, true);
3880+}
3881+
36563882 int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw,
36573883 struct ieee80211_vif *vif)
36583884 {
@@ -3674,3 +3900,32 @@ int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw, · 15 unmodified lines
36743900 return __mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_P2P_OPPPS,
36753901 &req, sizeof(req), false);
36763902 }
3903+
3904+u32 mt7615_mcu_reg_rr(struct mt76_dev *dev, u32 offset)
3905+{
3906+ struct {
3907+ __le32 addr;
3908+ __le32 val;
3909+ } __packed req = {
3910+ .addr = cpu_to_le32(offset),
3911+ };
3912+
3913+ return __mt76_mcu_send_msg(dev, MCU_CMD_REG_READ,
3914+ &req, sizeof(req), true);
3915+}
3916+EXPORT_SYMBOL_GPL(mt7615_mcu_reg_rr);
3917+
3918+void mt7615_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val)
3919+{
3920+ struct {
3921+ __le32 addr;
3922+ __le32 val;
3923+ } __packed req = {
3924+ .addr = cpu_to_le32(offset),
3925+ .val = cpu_to_le32(val),
3926+ };
3927+
3928+ __mt76_mcu_send_msg(dev, MCU_CMD_REG_WRITE,
3929+ &req, sizeof(req), false);
3930+}
3931+EXPORT_SYMBOL_GPL(mt7615_mcu_reg_wr);
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h+51−3
@@ -81,6 +81,7 @@ enum { · 80 unmodified lines
8181 MCU_EVENT_GENERIC = 0x01,
8282 MCU_EVENT_ACCESS_REG = 0x02,
8383 MCU_EVENT_MT_PATCH_SEM = 0x04,
84+ MCU_EVENT_REG_ACCESS = 0x05,
8485 MCU_EVENT_SCAN_DONE = 0x0d,
8586 MCU_EVENT_ROC = 0x10,
8687 MCU_EVENT_BSS_ABSENCE = 0x11,
@@ -238,8 +239,11 @@ enum { · 151 unmodified lines
238239 #define MCU_FW_PREFIX BIT(31)
239240 #define MCU_UNI_PREFIX BIT(30)
240241 #define MCU_CE_PREFIX BIT(29)
242+#define MCU_QUERY_PREFIX BIT(28)
241243 #define MCU_CMD_MASK ~(MCU_FW_PREFIX | MCU_UNI_PREFIX | \
242− MCU_CE_PREFIX)
244+ MCU_CE_PREFIX | MCU_QUERY_PREFIX)
245+
246+#define MCU_QUERY_MASK BIT(16)
243247
244248 enum {
245249 MCU_CMD_TARGET_ADDRESS_LEN_REQ = MCU_FW_PREFIX | 0x01,
@@ -254,6 +258,7 @@ enum { · 8 unmodified lines
254258 };
255259
256260 enum {
261+ MCU_EXT_CMD_RF_REG_ACCESS = 0x02,
257262 MCU_EXT_CMD_PM_STATE_CTRL = 0x07,
258263 MCU_EXT_CMD_CHANNEL_SWITCH = 0x08,
259264 MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11,
@@ -266,6 +271,7 @@ enum { · 6 unmodified lines
266271 MCU_EXT_CMD_GET_TEMP = 0x2c,
267272 MCU_EXT_CMD_WTBL_UPDATE = 0x32,
268273 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
274+ MCU_EXT_CMD_ATE_CTRL = 0x3d,
269275 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
270276 MCU_EXT_CMD_DBDC_CTRL = 0x45,
271277 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
@@ -287,6 +293,11 @@ enum { · 15 unmodified lines
287293 MCU_UNI_CMD_HIF_CTRL = MCU_UNI_PREFIX | 0x07,
288294 };
289295
296+enum {
297+ MCU_ATE_SET_FREQ_OFFSET = 0xa,
298+ MCU_ATE_SET_TX_POWER_CONTROL = 0x15,
299+};
300+
290301 struct mt7615_mcu_uni_event {
291302 u8 cid;
292303 u8 pad[3];
@@ -421,6 +432,11 @@ struct nt7615_sched_scan_done { · 128 unmodified lines
421432 __le16 pad;
422433 } __packed;
423434
435+struct mt7615_mcu_reg_event {
436+ __le32 reg;
437+ __le32 val;
438+} __packed;
439+
424440 struct mt7615_mcu_bss_event {
425441 u8 bss_idx;
426442 u8 is_absent;
@@ -454,6 +470,13 @@ struct mt7615_bss_basic_tlv { · 27 unmodified lines
454470 u8 pad[3];
455471 } __packed;
456472
473+struct mt7615_bss_qos_tlv {
474+ __le16 tag;
475+ __le16 len;
476+ u8 qos;
477+ u8 pad[3];
478+} __packed;
479+
457480 struct mt7615_wow_ctrl_tlv {
458481 __le16 tag;
459482 __le16 len;
@@ -545,6 +568,15 @@ struct mt7615_roc_tlv { · 85 unmodified lines
545568 u8 rsv1[8];
546569 } __packed;
547570
571+struct mt7615_arpns_tlv {
572+ __le16 tag;
573+ __le16 len;
574+ u8 mode;
575+ u8 ips_num;
576+ u8 option;
577+ u8 pad[1];
578+} __packed;
579+
548580 /* offload mcu commands */
549581 enum {
550582 MCU_CMD_START_HW_SCAN = MCU_CE_PREFIX | 0x03,
@@ -557,6 +589,8 @@ enum { · 6 unmodified lines
557589 MCU_CMD_SET_P2P_OPPPS = MCU_CE_PREFIX | 0x33,
558590 MCU_CMD_SCHED_SCAN_ENABLE = MCU_CE_PREFIX | 0x61,
559591 MCU_CMD_SCHED_SCAN_REQ = MCU_CE_PREFIX | 0x62,
592+ MCU_CMD_REG_WRITE = MCU_CE_PREFIX | 0xc0,
593+ MCU_CMD_REG_READ = MCU_CE_PREFIX | MCU_QUERY_MASK | 0xc0,
560594 };
561595
562596 #define MCU_CMD_ACK BIT(0)
@@ -569,6 +603,8 @@ enum { · 6 unmodified lines
569603 UNI_BSS_INFO_BASIC = 0,
570604 UNI_BSS_INFO_RLM = 2,
571605 UNI_BSS_INFO_BCN_CONTENT = 7,
606+ UNI_BSS_INFO_QBSS = 15,
607+ UNI_BSS_INFO_UAPSD = 19,
572608 };
573609
574610 enum {
@@ -580,8 +616,8 @@ enum { · 5 unmodified lines
580616 };
581617
582618 enum {
583− UNI_OFFLOAD_OFFLOAD_ARPNS_IPV4,
584− UNI_OFFLOAD_OFFLOAD_ARPNS_IPV6,
619+ UNI_OFFLOAD_OFFLOAD_ARP,
620+ UNI_OFFLOAD_OFFLOAD_ND,
585621 UNI_OFFLOAD_OFFLOAD_GTK_REKEY,
586622 UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT,
587623 };
@@ -882,6 +918,7 @@ struct wtbl_raw { · 294 unmodified lines
882918 sizeof(struct sta_rec_basic) + \
883919 sizeof(struct sta_rec_ht) + \
884920 sizeof(struct sta_rec_vht) + \
921+ sizeof(struct sta_rec_uapsd) + \
885922 sizeof(struct tlv) + \
886923 MT7615_WTBL_UPDATE_MAX_SIZE)
887924
@@ -971,6 +1008,17 @@ struct sta_rec_ba { · 83 unmodified lines
9711008 __le16 winsize;
9721009 } __packed;
9731010
1011+struct sta_rec_uapsd {
1012+ __le16 tag;
1013+ __le16 len;
1014+ u8 dac_map;
1015+ u8 tac_map;
1016+ u8 max_sp;
1017+ u8 rsv0;
1018+ __le16 listen_interval;
1019+ u8 rsv1[2];
1020+} __packed;
1021+
9741022 enum {
9751023 STA_REC_BASIC,
9761024 STA_REC_RA,
drivers/net/wireless/mediatek/mt76/mt7615/mmio.c+47−2
@@ -17,7 +17,6 @@ const u32 mt7615e_reg_map[] = { · 16 unmodified lines
1717 [MT_CSR_BASE] = 0x07000,
1818 [MT_PLE_BASE] = 0x08000,
1919 [MT_PSE_BASE] = 0x0c000,
20− [MT_PHY_BASE] = 0x10000,
2120 [MT_CFG_BASE] = 0x20200,
2221 [MT_AGG_BASE] = 0x20a00,
2322 [MT_TMAC_BASE] = 0x21000,
@@ -44,7 +43,7 @@ const u32 mt7663e_reg_map[] = { · 20 unmodified lines
4443 [MT_CSR_BASE] = 0x07000,
4544 [MT_PLE_BASE] = 0x08000,
4645 [MT_PSE_BASE] = 0x0c000,
47− [MT_PHY_BASE] = 0x10000,
46+ [MT_PP_BASE] = 0x0e000,
4847 [MT_CFG_BASE] = 0x20000,
4948 [MT_AGG_BASE] = 0x22000,
5049 [MT_TMAC_BASE] = 0x24000,
@@ -140,6 +139,38 @@ static void mt7615_irq_tasklet(unsigned long data) · 89 unmodified lines
140139 mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0);
141140 }
142141
142+static u32 __mt7615_reg_addr(struct mt7615_dev *dev, u32 addr)
143+{
144+ if (addr < 0x100000)
145+ return addr;
146+
147+ return mt7615_reg_map(dev, addr);
148+}
149+
150+static u32 mt7615_rr(struct mt76_dev *mdev, u32 offset)
151+{
152+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
153+ u32 addr = __mt7615_reg_addr(dev, offset);
154+
155+ return dev->bus_ops->rr(mdev, addr);
156+}
157+
158+static void mt7615_wr(struct mt76_dev *mdev, u32 offset, u32 val)
159+{
160+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
161+ u32 addr = __mt7615_reg_addr(dev, offset);
162+
163+ dev->bus_ops->wr(mdev, addr, val);
164+}
165+
166+static u32 mt7615_rmw(struct mt76_dev *mdev, u32 offset, u32 mask, u32 val)
167+{
168+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
169+ u32 addr = __mt7615_reg_addr(dev, offset);
170+
171+ return dev->bus_ops->rmw(mdev, addr, mask, val);
172+}
173+
143174 int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
144175 int irq, const u32 *map)
145176 {
@@ -159,6 +190,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, · 13 unmodified lines
159190 .sta_remove = mt7615_mac_sta_remove,
160191 .update_survey = mt7615_update_channel,
161192 };
193+ struct mt76_bus_ops *bus_ops;
162194 struct ieee80211_ops *ops;
163195 struct mt7615_dev *dev;
164196 struct mt76_dev *mdev;
@@ -182,6 +214,19 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, · 17 unmodified lines
182214 (mt76_rr(dev, MT_HW_REV) & 0xff);
183215 dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
184216
217+ dev->bus_ops = dev->mt76.bus;
218+ bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops),
219+ GFP_KERNEL);
220+ if (!bus_ops) {
221+ ret = -ENOMEM;
222+ goto error;
223+ }
224+
225+ bus_ops->rr = mt7615_rr;
226+ bus_ops->wr = mt7615_wr;
227+ bus_ops->rmw = mt7615_rmw;
228+ dev->mt76.bus = bus_ops;
229+
185230 ret = devm_request_irq(mdev->dev, irq, mt7615_irq_handler,
186231 IRQF_SHARED, KBUILD_MODNAME, dev);
187232 if (ret)
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h+91−4
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 #ifndef __MT7615_H
55 #define __MT7615_H
66
7+#include <linux/completion.h>
78 #include <linux/interrupt.h>
89 #include <linux/ktime.h>
910 #include <linux/regmap.h>
@@ -18,6 +19,7 @@ · 8 unmodified lines
1819 #define MT7615_WTBL_STA (MT7615_WTBL_RESERVED - \
1920 MT7615_MAX_INTERFACES)
2021
22+#define MT7615_PM_TIMEOUT (HZ / 12)
2123 #define MT7615_WATCHDOG_TIME (HZ / 10)
2224 #define MT7615_HW_SCAN_TIMEOUT (HZ / 10)
2325 #define MT7615_RESET_TIMEOUT (30 * HZ)
@@ -31,6 +33,8 @@ · 7 unmodified lines
3133 #define MT7615_RX_RING_SIZE 1024
3234 #define MT7615_RX_MCU_RING_SIZE 512
3335
36+#define MT7615_DRV_OWN_RETRY_COUNT 10
37+
3438 #define MT7615_FIRMWARE_CR4 "mediatek/mt7615_cr4.bin"
3539 #define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin"
3640 #define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin"
@@ -169,6 +173,8 @@ struct mt7615_phy { · 132 unmodified lines
169173 struct mt76_phy *mt76;
170174 struct mt7615_dev *dev;
171175
176+ struct ieee80211_vif *monitor_vif;
177+
172178 u32 rxfilter;
173179 u32 omac_mask;
174180
@@ -240,10 +246,10 @@ struct mt7615_dev { · 65 unmodified lines
240246 struct mt76_phy mphy;
241247 };
242248
249+ const struct mt76_bus_ops *bus_ops;
243250 struct tasklet_struct irq_tasklet;
244251
245252 struct mt7615_phy phy;
246− u32 vif_mask;
247253 u32 omac_mask;
248254
249255 u16 chainmask;
@@ -280,6 +286,37 @@ struct mt7615_dev { · 30 unmodified lines
280286
281287 struct work_struct wtbl_work;
282288 struct list_head wd_head;
289+
290+ u32 debugfs_rf_wf;
291+ u32 debugfs_rf_reg;
292+
293+#ifdef CONFIG_NL80211_TESTMODE
294+ struct {
295+ u32 *reg_backup;
296+
297+ s16 last_freq_offset;
298+ u8 last_rcpi[4];
299+ s8 last_ib_rssi;
300+ s8 last_wb_rssi;
301+ } test;
302+#endif
303+
304+ struct {
305+ bool enable;
306+
307+ spinlock_t txq_lock;
308+ struct {
309+ struct mt7615_sta *msta;
310+ struct sk_buff *skb;
311+ } tx_q[IEEE80211_NUM_ACS];
312+
313+ struct work_struct wake_work;
314+ struct completion wake_cmpl;
315+
316+ struct delayed_work ps_work;
317+ unsigned long last_activity;
318+ unsigned long idle_timeout;
319+ } pm;
283320 };
284321
285322 enum tx_pkt_queue_idx {
@@ -372,8 +409,10 @@ extern struct ieee80211_rate mt7615_rates[12]; · 86 unmodified lines
372409 extern const struct ieee80211_ops mt7615_ops;
373410 extern const u32 mt7615e_reg_map[__MT_BASE_MAX];
374411 extern const u32 mt7663e_reg_map[__MT_BASE_MAX];
412+extern const u32 mt7663_usb_sdio_reg_map[__MT_BASE_MAX];
375413 extern struct pci_driver mt7615_pci_driver;
376414 extern struct platform_driver mt7622_wmac_driver;
415+extern const struct mt76_testmode_ops mt7615_testmode_ops;
377416
378417 #ifdef CONFIG_MT7622_WMAC
379418 int mt7622_wmac_init(struct mt7615_dev *dev);
@@ -408,6 +447,11 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev); · 28 unmodified lines
408447 void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
409448 struct ieee80211_tx_rate *probe_rate,
410449 struct ieee80211_tx_rate *rates);
450+int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable);
451+void mt7615_pm_wake_work(struct work_struct *work);
452+int mt7615_pm_wake(struct mt7615_dev *dev);
453+void mt7615_pm_power_save_sched(struct mt7615_dev *dev);
454+void mt7615_pm_power_save_work(struct work_struct *work);
411455 int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
412456 int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);
413457 int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
@@ -462,6 +506,20 @@ static inline u16 mt7615_wtbl_size(struct mt7615_dev *dev) · 48 unmodified lines
462506 return MT7615_WTBL_SIZE;
463507 }
464508
509+static inline void mt7615_mutex_acquire(struct mt7615_dev *dev)
510+ __acquires(&dev->mt76.mutex)
511+{
512+ mutex_lock(&dev->mt76.mutex);
513+ mt7615_pm_wake(dev);
514+}
515+
516+static inline void mt7615_mutex_release(struct mt7615_dev *dev)
517+ __releases(&dev->mt76.mutex)
518+{
519+ mt7615_pm_power_save_sched(dev);
520+ mutex_unlock(&dev->mt76.mutex);
521+}
522+
465523 static inline u8 mt7615_lmac_mapping(struct mt7615_dev *dev, u8 ac)
466524 {
467525 static const u8 lmac_queue_map[] = {
@@ -485,6 +543,7 @@ void mt7615_init_txpower(struct mt7615_dev *dev, · 17 unmodified lines
485543 struct ieee80211_supported_band *sband);
486544 void mt7615_phy_init(struct mt7615_dev *dev);
487545 void mt7615_mac_init(struct mt7615_dev *dev);
546+int mt7615_set_channel(struct mt7615_phy *phy);
488547
489548 int mt7615_mcu_restart(struct mt76_dev *dev);
490549 void mt7615_update_channel(struct mt76_dev *mdev);
@@ -516,15 +575,19 @@ int mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, · 25 unmodified lines
516575 enum mt7615_cipher_type cipher,
517576 enum set_key_cmd cmd);
518577 void mt7615_mac_reset_work(struct work_struct *work);
578+u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid);
519579
520580 int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
521581 int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
522582 int len, bool wait_resp);
583+u32 mt7615_rf_rr(struct mt7615_dev *dev, u32 wf, u32 reg);
584+int mt7615_rf_wr(struct mt7615_dev *dev, u32 wf, u32 reg, u32 val);
523585 int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);
524586 int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
525587 int mt7615_mcu_set_mac_enable(struct mt7615_dev *dev, int band, bool enable);
526588 int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val);
527589 int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index);
590+int mt7615_mcu_set_tx_power(struct mt7615_phy *phy);
528591 void mt7615_mcu_exit(struct mt7615_dev *dev);
529592 void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
530593 int cmd, int *wait_seq);
@@ -563,6 +626,8 @@ int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev, · 32 unmodified lines
563626 const struct mt7615_dfs_pulse *pulse);
564627 int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,
565628 const struct mt7615_dfs_pattern *pattern);
629+int mt7615_mcu_set_test_param(struct mt7615_dev *dev, u8 param, bool test_mode,
630+ u32 val);
566631 int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);
567632 int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);
568633 int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
@@ -579,18 +644,40 @@ int mt7615_driver_own(struct mt7615_dev *dev); · 10 unmodified lines
579644 int mt7615_init_debugfs(struct mt7615_dev *dev);
580645 int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
581646
647+int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
648+ bool enable);
582649 int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend);
583650 void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
584651 struct ieee80211_vif *vif);
585652 int mt7615_mcu_update_gtk_rekey(struct ieee80211_hw *hw,
586653 struct ieee80211_vif *vif,
587654 struct cfg80211_gtk_rekey_data *key);
588−
655+int mt7615_mcu_update_arp_filter(struct ieee80211_hw *hw,
656+ struct ieee80211_vif *vif,
657+ struct ieee80211_bss_conf *info);
589658 int __mt7663_load_firmware(struct mt7615_dev *dev);
659+u32 mt7615_mcu_reg_rr(struct mt76_dev *dev, u32 offset);
660+void mt7615_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val);
590661
591662 /* usb */
592−void mt7663u_wtbl_work(struct work_struct *work);
663+int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
664+ enum mt76_txq_id qid, struct mt76_wcid *wcid,
665+ struct ieee80211_sta *sta,
666+ struct mt76_tx_info *tx_info);
667+bool mt7663_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update);
668+void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
669+ enum mt76_txq_id qid,
670+ struct mt76_queue_entry *e);
671+void mt7663_usb_sdio_wtbl_work(struct work_struct *work);
672+int mt7663_usb_sdio_register_device(struct mt7615_dev *dev);
593673 int mt7663u_mcu_init(struct mt7615_dev *dev);
594−int mt7663u_register_device(struct mt7615_dev *dev);
674+
675+/* sdio */
676+u32 mt7663s_read_pcr(struct mt7615_dev *dev);
677+int mt7663s_mcu_init(struct mt7615_dev *dev);
678+int mt7663s_driver_own(struct mt7615_dev *dev);
679+int mt7663s_firmware_own(struct mt7615_dev *dev);
680+int mt7663s_kthread_run(void *data);
681+void mt7663s_sdio_irq(struct sdio_func *func);
595682
596683 #endif
drivers/net/wireless/mediatek/mt76/mt7615/pci.c+4−0
@@ -75,6 +75,10 @@ static int mt7615_pci_suspend(struct pci_dev *pdev, pm_message_t state) · 74 unmodified lines
7575 bool hif_suspend;
7676 int i, err;
7777
78+ err = mt7615_pm_wake(dev);
79+ if (err < 0)
80+ return err;
81+
7882 hif_suspend = !test_bit(MT76_STATE_SUSPEND, &dev->mphy.state) &&
7983 mt7615_firmware_offload(dev);
8084 if (hif_suspend) {
drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c+4−0
@@ -70,6 +70,10 @@ mt7615_led_set_config(struct led_classdev *led_cdev, · 69 unmodified lines
7070
7171 mt76 = container_of(led_cdev, struct mt76_dev, led_cdev);
7272 dev = container_of(mt76, struct mt7615_dev, mt76);
73+
74+ if (test_bit(MT76_STATE_PM, &mt76->phy.state))
75+ return;
76+
7377 val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xffff) |
7478 FIELD_PREP(MT_LED_STATUS_OFF, delay_off) |
7579 FIELD_PREP(MT_LED_STATUS_ON, delay_on);
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c+0−1
@@ -155,7 +155,6 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, · 154 unmodified lines
155155 spin_lock_bh(&dev->mt76.lock);
156156 mt7615_mac_set_rates(phy, msta, &info->control.rates[0],
157157 msta->rates);
158− msta->rate_probe = true;
159158 spin_unlock_bh(&dev->mt76.lock);
160159 }
161160
drivers/net/wireless/mediatek/mt76/mt7615/regs.h+31−2
@@ -14,7 +14,6 @@ enum mt7615_reg_base { · 13 unmodified lines
1414 MT_CSR_BASE,
1515 MT_PLE_BASE,
1616 MT_PSE_BASE,
17− MT_PHY_BASE,
1817 MT_CFG_BASE,
1918 MT_AGG_BASE,
2019 MT_TMAC_BASE,
@@ -29,6 +28,7 @@ enum mt7615_reg_base { · 8 unmodified lines
2928 MT_PCIE_REMAP_BASE2,
3029 MT_TOP_MISC_BASE,
3130 MT_EFUSE_ADDR_BASE,
31+ MT_PP_BASE,
3232 __MT_BASE_MAX,
3333 };
3434
@@ -153,6 +153,8 @@ enum mt7615_reg_base { · 118 unmodified lines
153153
154154 #define MT_PLE(ofs) ((dev)->reg_map[MT_PLE_BASE] + (ofs))
155155
156+#define MT_PLE_PG_HIF0_GROUP MT_PLE(0x110)
157+#define MT_HIF0_MIN_QUOTA GENMASK(11, 0)
156158 #define MT_PLE_FL_Q0_CTRL MT_PLE(0x1b0)
157159 #define MT_PLE_FL_Q1_CTRL MT_PLE(0x1b4)
158160 #define MT_PLE_FL_Q2_CTRL MT_PLE(0x1b8)
@@ -162,6 +164,10 @@ enum mt7615_reg_base { · 3 unmodified lines
162164 ((n) << 2))
163165
164166 #define MT_PSE(ofs) ((dev)->reg_map[MT_PSE_BASE] + (ofs))
167+#define MT_PSE_PG_HIF0_GROUP MT_PSE(0x110)
168+#define MT_HIF0_MIN_QUOTA GENMASK(11, 0)
169+#define MT_PSE_PG_HIF1_GROUP MT_PSE(0x118)
170+#define MT_HIF1_MIN_QUOTA GENMASK(11, 0)
165171 #define MT_PSE_QUEUE_EMPTY MT_PSE(0x0b4)
166172 #define MT_HIF_0_EMPTY_MASK BIT(16)
167173 #define MT_HIF_1_EMPTY_MASK BIT(17)
@@ -169,7 +175,12 @@ enum mt7615_reg_base { · 1 unmodified line
169175 #define MT_PSE_PG_INFO MT_PSE(0x194)
170176 #define MT_PSE_SRC_CNT GENMASK(27, 16)
171177
172−#define MT_WF_PHY_BASE ((dev)->reg_map[MT_PHY_BASE])
178+#define MT_PP(ofs) ((dev)->reg_map[MT_PP_BASE] + (ofs))
179+#define MT_PP_TXDWCNT MT_PP(0x0)
180+#define MT_PP_TXDWCNT_TX0_ADD_DW_CNT GENMASK(7, 0)
181+#define MT_PP_TXDWCNT_TX1_ADD_DW_CNT GENMASK(15, 8)
182+
183+#define MT_WF_PHY_BASE 0x82070000
173184 #define MT_WF_PHY(ofs) (MT_WF_PHY_BASE + (ofs))
174185
175186 #define MT_WF_PHY_WF2_RFCTRL0(n) MT_WF_PHY(0x1900 + (n) * 0x400)
@@ -213,6 +224,9 @@ enum mt7615_reg_base { · 37 unmodified lines
213224 #define MT_WF_PHY_RXTD2_BASE MT_WF_PHY(0x2a00)
214225 #define MT_WF_PHY_RXTD2(_n) (MT_WF_PHY_RXTD2_BASE + ((_n) << 2))
215226
227+#define MT_WF_PHY_RFINTF3_0(_n) MT_WF_PHY(0x1100 + (_n) * 0x400)
228+#define MT_WF_PHY_RFINTF3_0_ANT GENMASK(7, 4)
229+
216230 #define MT_WF_CFG_BASE ((dev)->reg_map[MT_CFG_BASE])
217231 #define MT_WF_CFG(ofs) (MT_WF_CFG_BASE + (ofs))
218232
@@ -256,6 +270,13 @@ enum mt7615_reg_base { · 37 unmodified lines
256270 #define MT_WF_ARB_BASE ((dev)->reg_map[MT_ARB_BASE])
257271 #define MT_WF_ARB(ofs) (MT_WF_ARB_BASE + (ofs))
258272
273+#define MT_ARB_RQCR MT_WF_ARB(0x070)
274+#define MT_ARB_RQCR_RX_START BIT(0)
275+#define MT_ARB_RQCR_RXV_START BIT(4)
276+#define MT_ARB_RQCR_RXV_R_EN BIT(7)
277+#define MT_ARB_RQCR_RXV_T_EN BIT(8)
278+#define MT_ARB_RQCR_BAND_SHIFT 16
279+
259280 #define MT_ARB_SCR MT_WF_ARB(0x080)
260281 #define MT_ARB_SCR_TX0_DISABLE BIT(8)
261282 #define MT_ARB_SCR_RX0_DISABLE BIT(9)
@@ -417,6 +438,7 @@ enum mt7615_reg_base { · 155 unmodified lines
417438
418439 #define MT_LPON_T0CR MT_LPON(0x010)
419440 #define MT_LPON_T0CR_MODE GENMASK(1, 0)
441+#define MT_LPON_T0CR_WRITE BIT(0)
420442
421443 #define MT_LPON_UTTR0 MT_LPON(0x018)
422444 #define MT_LPON_UTTR1 MT_LPON(0x01c)
@@ -550,4 +572,11 @@ enum mt7615_reg_base { · 127 unmodified lines
550572 #define MT_WL_RX_BUSY BIT(30)
551573 #define MT_WL_TX_BUSY BIT(31)
552574
575+#define MT_MCU_PTA_BASE 0x81060000
576+#define MT_MCU_PTA(_n) (MT_MCU_PTA_BASE + (_n))
577+
578+#define MT_ANT_SWITCH_CON(n) MT_MCU_PTA(0x0c8)
579+#define MT_ANT_SWITCH_CON_MODE(_n) (GENMASK(4, 0) << (_n * 8))
580+#define MT_ANT_SWITCH_CON_MODE1(_n) (GENMASK(3, 0) << (_n * 8))
581+
553582 #endif
drivers/net/wireless/mediatek/mt76/mt7615/sdio.c+478−0
@@ -0,0 +1,478 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 MediaTek Inc.
3+ *
4+ * Author: Felix Fietkau <nbd@nbd.name>
5+ * Lorenzo Bianconi <lorenzo@kernel.org>
6+ * Sean Wang <sean.wang@mediatek.com>
7+ */
8+
9+#include <linux/kernel.h>
10+#include <linux/iopoll.h>
11+#include <linux/module.h>
12+
13+#include <linux/mmc/host.h>
14+#include <linux/mmc/sdio_ids.h>
15+#include <linux/mmc/sdio_func.h>
16+
17+#include "mt7615.h"
18+#include "sdio.h"
19+#include "mac.h"
20+
21+static const struct sdio_device_id mt7663s_table[] = {
22+ { SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, 0x7603) },
23+ { } /* Terminating entry */
24+};
25+
26+static u32 mt7663s_read_whisr(struct mt76_dev *dev)
27+{
28+ return sdio_readl(dev->sdio.func, MCR_WHISR, NULL);
29+}
30+
31+u32 mt7663s_read_pcr(struct mt7615_dev *dev)
32+{
33+ struct mt76_sdio *sdio = &dev->mt76.sdio;
34+
35+ return sdio_readl(sdio->func, MCR_WHLPCR, NULL);
36+}
37+
38+static u32 mt7663s_read_mailbox(struct mt76_dev *dev, u32 offset)
39+{
40+ struct sdio_func *func = dev->sdio.func;
41+ u32 val = ~0, status;
42+ int err;
43+
44+ sdio_claim_host(func);
45+
46+ sdio_writel(func, offset, MCR_H2DSM0R, &err);
47+ if (err < 0) {
48+ dev_err(dev->dev, "failed setting address [err=%d]\n", err);
49+ goto out;
50+ }
51+
52+ sdio_writel(func, H2D_SW_INT_READ, MCR_WSICR, &err);
53+ if (err < 0) {
54+ dev_err(dev->dev, "failed setting read mode [err=%d]\n", err);
55+ goto out;
56+ }
57+
58+ err = readx_poll_timeout(mt7663s_read_whisr, dev, status,
59+ status & H2D_SW_INT_READ, 0, 1000000);
60+ if (err < 0) {
61+ dev_err(dev->dev, "query whisr timeout\n");
62+ goto out;
63+ }
64+
65+ sdio_writel(func, H2D_SW_INT_READ, MCR_WHISR, &err);
66+ if (err < 0) {
67+ dev_err(dev->dev, "failed setting read mode [err=%d]\n", err);
68+ goto out;
69+ }
70+
71+ val = sdio_readl(func, MCR_H2DSM0R, &err);
72+ if (err < 0) {
73+ dev_err(dev->dev, "failed reading h2dsm0r [err=%d]\n", err);
74+ goto out;
75+ }
76+
77+ if (val != offset) {
78+ dev_err(dev->dev, "register mismatch\n");
79+ val = ~0;
80+ goto out;
81+ }
82+
83+ val = sdio_readl(func, MCR_D2HRM1R, &err);
84+ if (err < 0)
85+ dev_err(dev->dev, "failed reading d2hrm1r [err=%d]\n", err);
86+
87+out:
88+ sdio_release_host(func);
89+
90+ return val;
91+}
92+
93+static void mt7663s_write_mailbox(struct mt76_dev *dev, u32 offset, u32 val)
94+{
95+ struct sdio_func *func = dev->sdio.func;
96+ u32 status;
97+ int err;
98+
99+ sdio_claim_host(func);
100+
101+ sdio_writel(func, offset, MCR_H2DSM0R, &err);
102+ if (err < 0) {
103+ dev_err(dev->dev, "failed setting address [err=%d]\n", err);
104+ goto out;
105+ }
106+
107+ sdio_writel(func, val, MCR_H2DSM1R, &err);
108+ if (err < 0) {
109+ dev_err(dev->dev,
110+ "failed setting write value [err=%d]\n", err);
111+ goto out;
112+ }
113+
114+ sdio_writel(func, H2D_SW_INT_WRITE, MCR_WSICR, &err);
115+ if (err < 0) {
116+ dev_err(dev->dev, "failed setting write mode [err=%d]\n", err);
117+ goto out;
118+ }
119+
120+ err = readx_poll_timeout(mt7663s_read_whisr, dev, status,
121+ status & H2D_SW_INT_WRITE, 0, 1000000);
122+ if (err < 0) {
123+ dev_err(dev->dev, "query whisr timeout\n");
124+ goto out;
125+ }
126+
127+ sdio_writel(func, H2D_SW_INT_WRITE, MCR_WHISR, &err);
128+ if (err < 0) {
129+ dev_err(dev->dev, "failed setting write mode [err=%d]\n", err);
130+ goto out;
131+ }
132+
133+ val = sdio_readl(func, MCR_H2DSM0R, &err);
134+ if (err < 0) {
135+ dev_err(dev->dev, "failed reading h2dsm0r [err=%d]\n", err);
136+ goto out;
137+ }
138+
139+ if (val != offset)
140+ dev_err(dev->dev, "register mismatch\n");
141+
142+out:
143+ sdio_release_host(func);
144+}
145+
146+static u32 mt7663s_rr(struct mt76_dev *dev, u32 offset)
147+{
148+ if (test_bit(MT76_STATE_MCU_RUNNING, &dev->phy.state))
149+ return dev->mcu_ops->mcu_rr(dev, offset);
150+ else
151+ return mt7663s_read_mailbox(dev, offset);
152+}
153+
154+static void mt7663s_wr(struct mt76_dev *dev, u32 offset, u32 val)
155+{
156+ if (test_bit(MT76_STATE_MCU_RUNNING, &dev->phy.state))
157+ dev->mcu_ops->mcu_wr(dev, offset, val);
158+ else
159+ mt7663s_write_mailbox(dev, offset, val);
160+}
161+
162+static u32 mt7663s_rmw(struct mt76_dev *dev, u32 offset, u32 mask, u32 val)
163+{
164+ val |= mt7663s_rr(dev, offset) & ~mask;
165+ mt7663s_wr(dev, offset, val);
166+
167+ return val;
168+}
169+
170+static void mt7663s_write_copy(struct mt76_dev *dev, u32 offset,
171+ const void *data, int len)
172+{
173+ const u32 *val = data;
174+ int i;
175+
176+ for (i = 0; i < len / sizeof(u32); i++) {
177+ mt7663s_wr(dev, offset, val[i]);
178+ offset += sizeof(u32);
179+ }
180+}
181+
182+static void mt7663s_read_copy(struct mt76_dev *dev, u32 offset,
183+ void *data, int len)
184+{
185+ u32 *val = data;
186+ int i;
187+
188+ for (i = 0; i < len / sizeof(u32); i++) {
189+ val[i] = mt7663s_rr(dev, offset);
190+ offset += sizeof(u32);
191+ }
192+}
193+
194+static int mt7663s_wr_rp(struct mt76_dev *dev, u32 base,
195+ const struct mt76_reg_pair *data,
196+ int len)
197+{
198+ int i;
199+
200+ for (i = 0; i < len; i++) {
201+ mt7663s_wr(dev, data->reg, data->value);
202+ data++;
203+ }
204+
205+ return 0;
206+}
207+
208+static int mt7663s_rd_rp(struct mt76_dev *dev, u32 base,
209+ struct mt76_reg_pair *data,
210+ int len)
211+{
212+ int i;
213+
214+ for (i = 0; i < len; i++) {
215+ data->value = mt7663s_rr(dev, data->reg);
216+ data++;
217+ }
218+
219+ return 0;
220+}
221+
222+static void mt7663s_init_work(struct work_struct *work)
223+{
224+ struct mt7615_dev *dev;
225+
226+ dev = container_of(work, struct mt7615_dev, mcu_work);
227+ if (mt7663s_mcu_init(dev))
228+ return;
229+
230+ mt7615_mcu_set_eeprom(dev);
231+ mt7615_mac_init(dev);
232+ mt7615_phy_init(dev);
233+ mt7615_mcu_del_wtbl_all(dev);
234+ mt7615_check_offload_capability(dev);
235+}
236+
237+static int mt7663s_hw_init(struct mt7615_dev *dev, struct sdio_func *func)
238+{
239+ u32 status, ctrl;
240+ int ret;
241+
242+ sdio_claim_host(func);
243+
244+ ret = sdio_enable_func(func);
245+ if (ret < 0)
246+ goto release;
247+
248+ /* Get ownership from the device */
249+ sdio_writel(func, WHLPCR_INT_EN_CLR | WHLPCR_FW_OWN_REQ_CLR,
250+ MCR_WHLPCR, &ret);
251+ if (ret < 0)
252+ goto disable_func;
253+
254+ ret = readx_poll_timeout(mt7663s_read_pcr, dev, status,
255+ status & WHLPCR_IS_DRIVER_OWN, 2000, 1000000);
256+ if (ret < 0) {
257+ dev_err(dev->mt76.dev, "Cannot get ownership from device");
258+ goto disable_func;
259+ }
260+
261+ ret = sdio_set_block_size(func, 512);
262+ if (ret < 0)
263+ goto disable_func;
264+
265+ /* Enable interrupt */
266+ sdio_writel(func, WHLPCR_INT_EN_SET, MCR_WHLPCR, &ret);
267+ if (ret < 0)
268+ goto disable_func;
269+
270+ ctrl = WHIER_RX0_DONE_INT_EN | WHIER_TX_DONE_INT_EN;
271+ sdio_writel(func, ctrl, MCR_WHIER, &ret);
272+ if (ret < 0)
273+ goto disable_func;
274+
275+ /* set WHISR as read clear and Rx aggregation number as 16 */
276+ ctrl = FIELD_PREP(MAX_HIF_RX_LEN_NUM, 16);
277+ sdio_writel(func, ctrl, MCR_WHCR, &ret);
278+ if (ret < 0)
279+ goto disable_func;
280+
281+ ret = sdio_claim_irq(func, mt7663s_sdio_irq);
282+ if (ret < 0)
283+ goto disable_func;
284+
285+ sdio_release_host(func);
286+
287+ return 0;
288+
289+disable_func:
290+ sdio_disable_func(func);
291+release:
292+ sdio_release_host(func);
293+
294+ return ret;
295+}
296+
297+static int mt7663s_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
298+ struct ieee80211_sta *sta)
299+{
300+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
301+ struct mt76_sdio *sdio = &mdev->sdio;
302+ u32 pse, ple;
303+ int err;
304+
305+ err = mt7615_mac_sta_add(mdev, vif, sta);
306+ if (err < 0)
307+ return err;
308+
309+ /* init sched data quota */
310+ pse = mt76_get_field(dev, MT_PSE_PG_HIF0_GROUP, MT_HIF0_MIN_QUOTA);
311+ ple = mt76_get_field(dev, MT_PLE_PG_HIF0_GROUP, MT_HIF0_MIN_QUOTA);
312+
313+ mutex_lock(&sdio->sched.lock);
314+ sdio->sched.pse_data_quota = pse;
315+ sdio->sched.ple_data_quota = ple;
316+ mutex_unlock(&sdio->sched.lock);
317+
318+ return 0;
319+}
320+
321+static int mt7663s_probe(struct sdio_func *func,
322+ const struct sdio_device_id *id)
323+{
324+ static const struct mt76_driver_ops drv_ops = {
325+ .txwi_size = MT_USB_TXD_SIZE,
326+ .drv_flags = MT_DRV_RX_DMA_HDR | MT_DRV_HW_MGMT_TXQ,
327+ .tx_prepare_skb = mt7663_usb_sdio_tx_prepare_skb,
328+ .tx_complete_skb = mt7663_usb_sdio_tx_complete_skb,
329+ .tx_status_data = mt7663_usb_sdio_tx_status_data,
330+ .rx_skb = mt7615_queue_rx_skb,
331+ .sta_ps = mt7615_sta_ps,
332+ .sta_add = mt7663s_sta_add,
333+ .sta_remove = mt7615_mac_sta_remove,
334+ .update_survey = mt7615_update_channel,
335+ };
336+ static const struct mt76_bus_ops mt7663s_ops = {
337+ .rr = mt7663s_rr,
338+ .rmw = mt7663s_rmw,
339+ .wr = mt7663s_wr,
340+ .write_copy = mt7663s_write_copy,
341+ .read_copy = mt7663s_read_copy,
342+ .wr_rp = mt7663s_wr_rp,
343+ .rd_rp = mt7663s_rd_rp,
344+ .type = MT76_BUS_SDIO,
345+ };
346+ struct ieee80211_ops *ops;
347+ struct mt7615_dev *dev;
348+ struct mt76_dev *mdev;
349+ int ret;
350+
351+ ops = devm_kmemdup(&func->dev, &mt7615_ops, sizeof(mt7615_ops),
352+ GFP_KERNEL);
353+ if (!ops)
354+ return -ENOMEM;
355+
356+ mdev = mt76_alloc_device(&func->dev, sizeof(*dev), ops, &drv_ops);
357+ if (!mdev)
358+ return -ENOMEM;
359+
360+ dev = container_of(mdev, struct mt7615_dev, mt76);
361+
362+ INIT_WORK(&dev->mcu_work, mt7663s_init_work);
363+ dev->reg_map = mt7663_usb_sdio_reg_map;
364+ dev->ops = ops;
365+ sdio_set_drvdata(func, dev);
366+
367+ mdev->sdio.tx_kthread = kthread_create(mt7663s_kthread_run, dev,
368+ "mt7663s_tx");
369+ if (IS_ERR(mdev->sdio.tx_kthread))
370+ return PTR_ERR(mdev->sdio.tx_kthread);
371+
372+ ret = mt76s_init(mdev, func, &mt7663s_ops);
373+ if (ret < 0)
374+ goto err_free;
375+
376+ ret = mt7663s_hw_init(dev, func);
377+ if (ret)
378+ goto err_free;
379+
380+ mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
381+ (mt76_rr(dev, MT_HW_REV) & 0xff);
382+ dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
383+
384+ ret = mt76s_alloc_queues(&dev->mt76);
385+ if (ret)
386+ goto err_deinit;
387+
388+ ret = mt7663_usb_sdio_register_device(dev);
389+ if (ret)
390+ goto err_deinit;
391+
392+ return 0;
393+
394+err_deinit:
395+ mt76s_deinit(&dev->mt76);
396+err_free:
397+ mt76_free_device(&dev->mt76);
398+
399+ return ret;
400+}
401+
402+static void mt7663s_remove(struct sdio_func *func)
403+{
404+ struct mt7615_dev *dev = sdio_get_drvdata(func);
405+
406+ if (!test_and_clear_bit(MT76_STATE_INITIALIZED, &dev->mphy.state))
407+ return;
408+
409+ ieee80211_unregister_hw(dev->mt76.hw);
410+ mt76s_deinit(&dev->mt76);
411+ mt76_free_device(&dev->mt76);
412+}
413+
414+#ifdef CONFIG_PM
415+static int mt7663s_suspend(struct device *dev)
416+{
417+ struct sdio_func *func = dev_to_sdio_func(dev);
418+ struct mt7615_dev *mdev = sdio_get_drvdata(func);
419+
420+ if (!test_bit(MT76_STATE_SUSPEND, &mdev->mphy.state) &&
421+ mt7615_firmware_offload(mdev)) {
422+ int err;
423+
424+ err = mt7615_mcu_set_hif_suspend(mdev, true);
425+ if (err < 0)
426+ return err;
427+ }
428+
429+ mt76s_stop_txrx(&mdev->mt76);
430+
431+ return mt7663s_firmware_own(mdev);
432+}
433+
434+static int mt7663s_resume(struct device *dev)
435+{
436+ struct sdio_func *func = dev_to_sdio_func(dev);
437+ struct mt7615_dev *mdev = sdio_get_drvdata(func);
438+ int err;
439+
440+ err = mt7663s_driver_own(mdev);
441+ if (err)
442+ return err;
443+
444+ if (!test_bit(MT76_STATE_SUSPEND, &mdev->mphy.state) &&
445+ mt7615_firmware_offload(mdev))
446+ err = mt7615_mcu_set_hif_suspend(mdev, false);
447+
448+ return err;
449+}
450+
451+static const struct dev_pm_ops mt7663s_pm_ops = {
452+ .suspend = mt7663s_suspend,
453+ .resume = mt7663s_resume,
454+};
455+#endif
456+
457+MODULE_DEVICE_TABLE(sdio, mt7663s_table);
458+MODULE_FIRMWARE(MT7663_OFFLOAD_FIRMWARE_N9);
459+MODULE_FIRMWARE(MT7663_OFFLOAD_ROM_PATCH);
460+MODULE_FIRMWARE(MT7663_FIRMWARE_N9);
461+MODULE_FIRMWARE(MT7663_ROM_PATCH);
462+
463+static struct sdio_driver mt7663s_driver = {
464+ .name = KBUILD_MODNAME,
465+ .probe = mt7663s_probe,
466+ .remove = mt7663s_remove,
467+ .id_table = mt7663s_table,
468+#ifdef CONFIG_PM
469+ .drv = {
470+ .pm = &mt7663s_pm_ops,
471+ }
472+#endif
473+};
474+module_sdio_driver(mt7663s_driver);
475+
476+MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
477+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
478+MODULE_LICENSE("Dual BSD/GPL");
drivers/net/wireless/mediatek/mt76/mt7615/sdio.h+115−0
@@ -0,0 +1,115 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 MediaTek Inc.
3+ *
4+ * Author: Sean Wang <sean.wang@mediatek.com>
5+ */
6+
7+#ifndef __MT76S_H
8+#define __MT76S_H
9+
10+#define MT_PSE_PAGE_SZ 128
11+
12+#define MCR_WCIR 0x0000
13+#define MCR_WHLPCR 0x0004
14+#define WHLPCR_FW_OWN_REQ_CLR BIT(9)
15+#define WHLPCR_FW_OWN_REQ_SET BIT(8)
16+#define WHLPCR_IS_DRIVER_OWN BIT(8)
17+#define WHLPCR_INT_EN_CLR BIT(1)
18+#define WHLPCR_INT_EN_SET BIT(0)
19+
20+#define MCR_WSDIOCSR 0x0008
21+#define MCR_WHCR 0x000C
22+#define W_INT_CLR_CTRL BIT(1)
23+#define RECV_MAILBOX_RD_CLR_EN BIT(2)
24+#define MAX_HIF_RX_LEN_NUM GENMASK(13, 8)
25+#define RX_ENHANCE_MODE BIT(16)
26+
27+#define MCR_WHISR 0x0010
28+#define MCR_WHIER 0x0014
29+#define WHIER_D2H_SW_INT GENMASK(31, 8)
30+#define WHIER_FW_OWN_BACK_INT_EN BIT(7)
31+#define WHIER_ABNORMAL_INT_EN BIT(6)
32+#define WHIER_RX1_DONE_INT_EN BIT(2)
33+#define WHIER_RX0_DONE_INT_EN BIT(1)
34+#define WHIER_TX_DONE_INT_EN BIT(0)
35+#define WHIER_DEFAULT (WHIER_RX0_DONE_INT_EN | \
36+ WHIER_RX1_DONE_INT_EN | \
37+ WHIER_TX_DONE_INT_EN | \
38+ WHIER_ABNORMAL_INT_EN | \
39+ WHIER_D2H_SW_INT)
40+
41+#define MCR_WASR 0x0020
42+#define MCR_WSICR 0x0024
43+#define MCR_WTSR0 0x0028
44+#define TQ0_CNT GENMASK(7, 0)
45+#define TQ1_CNT GENMASK(15, 8)
46+#define TQ2_CNT GENMASK(23, 16)
47+#define TQ3_CNT GENMASK(31, 24)
48+
49+#define MCR_WTSR1 0x002c
50+#define TQ4_CNT GENMASK(7, 0)
51+#define TQ5_CNT GENMASK(15, 8)
52+#define TQ6_CNT GENMASK(23, 16)
53+#define TQ7_CNT GENMASK(31, 24)
54+
55+#define MCR_WTDR1 0x0034
56+#define MCR_WRDR0 0x0050
57+#define MCR_WRDR1 0x0054
58+#define MCR_WRDR(p) (0x0050 + 4 * (p))
59+#define MCR_H2DSM0R 0x0070
60+#define H2D_SW_INT_READ BIT(16)
61+#define H2D_SW_INT_WRITE BIT(17)
62+
63+#define MCR_H2DSM1R 0x0074
64+#define MCR_D2HRM0R 0x0078
65+#define MCR_D2HRM1R 0x007c
66+#define MCR_D2HRM2R 0x0080
67+#define MCR_WRPLR 0x0090
68+#define RX0_PACKET_LENGTH GENMASK(15, 0)
69+#define RX1_PACKET_LENGTH GENMASK(31, 16)
70+
71+#define MCR_WTMDR 0x00b0
72+#define MCR_WTMCR 0x00b4
73+#define MCR_WTMDPCR0 0x00b8
74+#define MCR_WTMDPCR1 0x00bc
75+#define MCR_WPLRCR 0x00d4
76+#define MCR_WSR 0x00D8
77+#define MCR_CLKIOCR 0x0100
78+#define MCR_CMDIOCR 0x0104
79+#define MCR_DAT0IOCR 0x0108
80+#define MCR_DAT1IOCR 0x010C
81+#define MCR_DAT2IOCR 0x0110
82+#define MCR_DAT3IOCR 0x0114
83+#define MCR_CLKDLYCR 0x0118
84+#define MCR_CMDDLYCR 0x011C
85+#define MCR_ODATDLYCR 0x0120
86+#define MCR_IDATDLYCR1 0x0124
87+#define MCR_IDATDLYCR2 0x0128
88+#define MCR_ILCHCR 0x012C
89+#define MCR_WTQCR0 0x0130
90+#define MCR_WTQCR1 0x0134
91+#define MCR_WTQCR2 0x0138
92+#define MCR_WTQCR3 0x013C
93+#define MCR_WTQCR4 0x0140
94+#define MCR_WTQCR5 0x0144
95+#define MCR_WTQCR6 0x0148
96+#define MCR_WTQCR7 0x014C
97+#define MCR_WTQCR(x) (0x130 + 4 * (x))
98+#define TXQ_CNT_L GENMASK(15, 0)
99+#define TXQ_CNT_H GENMASK(31, 16)
100+
101+#define MCR_SWPCDBGR 0x0154
102+
103+struct mt76s_intr {
104+ u32 isr;
105+ struct {
106+ u32 wtqcr[8];
107+ } tx;
108+ struct {
109+ u16 num[2];
110+ u16 len[2][16];
111+ } rx;
112+ u32 rec_mb[2];
113+} __packed;
114+
115+#endif
drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c+162−0
@@ -0,0 +1,162 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/* Copyright (C) 2020 MediaTek Inc.
3+ *
4+ * Author: Felix Fietkau <nbd@nbd.name>
5+ * Lorenzo Bianconi <lorenzo@kernel.org>
6+ * Sean Wang <sean.wang@mediatek.com>
7+ */
8+#include <linux/kernel.h>
9+#include <linux/mmc/sdio_func.h>
10+#include <linux/module.h>
11+#include <linux/iopoll.h>
12+
13+#include "mt7615.h"
14+#include "mac.h"
15+#include "mcu.h"
16+#include "regs.h"
17+#include "sdio.h"
18+
19+static int mt7663s_mcu_init_sched(struct mt7615_dev *dev)
20+{
21+ struct mt76_sdio *sdio = &dev->mt76.sdio;
22+ u32 pse0, ple, pse1, txdwcnt;
23+
24+ pse0 = mt76_get_field(dev, MT_PSE_PG_HIF0_GROUP, MT_HIF0_MIN_QUOTA);
25+ pse1 = mt76_get_field(dev, MT_PSE_PG_HIF1_GROUP, MT_HIF1_MIN_QUOTA);
26+ ple = mt76_get_field(dev, MT_PLE_PG_HIF0_GROUP, MT_HIF0_MIN_QUOTA);
27+ txdwcnt = mt76_get_field(dev, MT_PP_TXDWCNT,
28+ MT_PP_TXDWCNT_TX1_ADD_DW_CNT);
29+
30+ mutex_lock(&sdio->sched.lock);
31+
32+ sdio->sched.pse_data_quota = pse0;
33+ sdio->sched.ple_data_quota = ple;
34+ sdio->sched.pse_mcu_quota = pse1;
35+ sdio->sched.deficit = txdwcnt << 2;
36+
37+ mutex_unlock(&sdio->sched.lock);
38+
39+ return 0;
40+}
41+
42+static int
43+mt7663s_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
44+ int cmd, bool wait_resp)
45+{
46+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
47+ int ret, seq;
48+
49+ mutex_lock(&mdev->mcu.mutex);
50+
51+ mt7615_mcu_fill_msg(dev, skb, cmd, &seq);
52+ ret = mt76_tx_queue_skb_raw(dev, MT_TXQ_MCU, skb, 0);
53+ if (ret)
54+ goto out;
55+
56+ mt76_queue_kick(dev, mdev->q_tx[MT_TXQ_MCU].q);
57+ if (wait_resp)
58+ ret = mt7615_mcu_wait_response(dev, cmd, seq);
59+
60+out:
61+ mutex_unlock(&mdev->mcu.mutex);
62+
63+ return ret;
64+}
65+
66+int mt7663s_driver_own(struct mt7615_dev *dev)
67+{
68+ struct sdio_func *func = dev->mt76.sdio.func;
69+ struct mt76_phy *mphy = &dev->mt76.phy;
70+ u32 status;
71+ int ret;
72+
73+ if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
74+ goto out;
75+
76+ sdio_claim_host(func);
77+
78+ sdio_writel(func, WHLPCR_FW_OWN_REQ_CLR, MCR_WHLPCR, 0);
79+
80+ ret = readx_poll_timeout(mt7663s_read_pcr, dev, status,
81+ status & WHLPCR_IS_DRIVER_OWN, 2000, 1000000);
82+ if (ret < 0) {
83+ dev_err(dev->mt76.dev, "Cannot get ownership from device");
84+ set_bit(MT76_STATE_PM, &mphy->state);
85+ sdio_release_host(func);
86+
87+ return ret;
88+ }
89+
90+ sdio_release_host(func);
91+
92+out:
93+ dev->pm.last_activity = jiffies;
94+
95+ return 0;
96+}
97+
98+int mt7663s_firmware_own(struct mt7615_dev *dev)
99+{
100+ struct sdio_func *func = dev->mt76.sdio.func;
101+ struct mt76_phy *mphy = &dev->mt76.phy;
102+ u32 status;
103+ int ret;
104+
105+ if (test_and_set_bit(MT76_STATE_PM, &mphy->state))
106+ return 0;
107+
108+ sdio_claim_host(func);
109+
110+ sdio_writel(func, WHLPCR_FW_OWN_REQ_SET, MCR_WHLPCR, 0);
111+
112+ ret = readx_poll_timeout(mt7663s_read_pcr, dev, status,
113+ !(status & WHLPCR_IS_DRIVER_OWN), 2000, 1000000);
114+ if (ret < 0) {
115+ dev_err(dev->mt76.dev, "Cannot set ownership to device");
116+ clear_bit(MT76_STATE_PM, &mphy->state);
117+ }
118+
119+ sdio_release_host(func);
120+
121+ return ret;
122+}
123+
124+int mt7663s_mcu_init(struct mt7615_dev *dev)
125+{
126+ static const struct mt76_mcu_ops mt7663s_mcu_ops = {
127+ .headroom = sizeof(struct mt7615_mcu_txd),
128+ .tailroom = MT_USB_TAIL_SIZE,
129+ .mcu_skb_send_msg = mt7663s_mcu_send_message,
130+ .mcu_send_msg = mt7615_mcu_msg_send,
131+ .mcu_restart = mt7615_mcu_restart,
132+ .mcu_rr = mt7615_mcu_reg_rr,
133+ .mcu_wr = mt7615_mcu_reg_wr,
134+ };
135+ int ret;
136+
137+ ret = mt7663s_driver_own(dev);
138+ if (ret)
139+ return ret;
140+
141+ dev->mt76.mcu_ops = &mt7663s_mcu_ops,
142+
143+ ret = mt76_get_field(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_N9_RDY);
144+ if (ret) {
145+ mt7615_mcu_restart(&dev->mt76);
146+ if (!mt76_poll_msec(dev, MT_CONN_ON_MISC,
147+ MT_TOP_MISC2_FW_N9_RDY, 0, 500))
148+ return -EIO;
149+ }
150+
151+ ret = __mt7663_load_firmware(dev);
152+ if (ret)
153+ return ret;
154+
155+ ret = mt7663s_mcu_init_sched(dev);
156+ if (ret)
157+ return ret;
158+
159+ set_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state);
160+
161+ return 0;
162+}
drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c+268−0
@@ -0,0 +1,268 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 MediaTek Inc.
3+ *
4+ * Author: Felix Fietkau <nbd@nbd.name>
5+ * Lorenzo Bianconi <lorenzo@kernel.org>
6+ * Sean Wang <sean.wang@mediatek.com>
7+ */
8+
9+#include <linux/kernel.h>
10+#include <linux/iopoll.h>
11+#include <linux/module.h>
12+
13+#include <linux/mmc/host.h>
14+#include <linux/mmc/sdio_ids.h>
15+#include <linux/mmc/sdio_func.h>
16+
17+#include "../trace.h"
18+#include "mt7615.h"
19+#include "sdio.h"
20+#include "mac.h"
21+
22+static void mt7663s_refill_sched_quota(struct mt7615_dev *dev, u32 *data)
23+{
24+ struct mt76_sdio *sdio = &dev->mt76.sdio;
25+
26+ mutex_lock(&sdio->sched.lock);
27+ sdio->sched.pse_data_quota += FIELD_GET(TXQ_CNT_L, data[0]) + /* BK */
28+ FIELD_GET(TXQ_CNT_H, data[0]) + /* BE */
29+ FIELD_GET(TXQ_CNT_L, data[1]) + /* VI */
30+ FIELD_GET(TXQ_CNT_H, data[1]); /* VO */
31+ sdio->sched.ple_data_quota += FIELD_GET(TXQ_CNT_H, data[2]) + /* BK */
32+ FIELD_GET(TXQ_CNT_L, data[3]) + /* BE */
33+ FIELD_GET(TXQ_CNT_H, data[3]) + /* VI */
34+ FIELD_GET(TXQ_CNT_L, data[4]); /* VO */
35+ sdio->sched.pse_mcu_quota += FIELD_GET(TXQ_CNT_L, data[2]);
36+ mutex_unlock(&sdio->sched.lock);
37+}
38+
39+static struct sk_buff *mt7663s_build_rx_skb(void *data, int data_len,
40+ int buf_len)
41+{
42+ int len = min_t(int, data_len, MT_SKB_HEAD_LEN);
43+ struct sk_buff *skb;
44+
45+ skb = alloc_skb(len, GFP_KERNEL);
46+ if (!skb)
47+ return NULL;
48+
49+ skb_put_data(skb, data, len);
50+ if (data_len > len) {
51+ struct page *page;
52+
53+ data += len;
54+ page = virt_to_head_page(data);
55+ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
56+ page, data - page_address(page),
57+ data_len - len, buf_len);
58+ get_page(page);
59+ }
60+
61+ return skb;
62+}
63+
64+static int mt7663s_rx_run_queue(struct mt7615_dev *dev, enum mt76_rxq_id qid,
65+ struct mt76s_intr *intr)
66+{
67+ struct mt76_queue *q = &dev->mt76.q_rx[qid];
68+ struct mt76_sdio *sdio = &dev->mt76.sdio;
69+ int len = 0, err, i, order;
70+ struct page *page;
71+ u8 *buf;
72+
73+ for (i = 0; i < intr->rx.num[qid]; i++)
74+ len += round_up(intr->rx.len[qid][i] + 4, 4);
75+
76+ if (!len)
77+ return 0;
78+
79+ if (len > sdio->func->cur_blksize)
80+ len = roundup(len, sdio->func->cur_blksize);
81+
82+ order = get_order(len);
83+ page = __dev_alloc_pages(GFP_KERNEL, order);
84+ if (!page)
85+ return -ENOMEM;
86+
87+ buf = page_address(page);
88+
89+ err = sdio_readsb(sdio->func, buf, MCR_WRDR(qid), len);
90+ if (err < 0) {
91+ dev_err(dev->mt76.dev, "sdio read data failed:%d\n", err);
92+ __free_pages(page, order);
93+ return err;
94+ }
95+
96+ for (i = 0; i < intr->rx.num[qid]; i++) {
97+ int index = (q->tail + i) % q->ndesc;
98+ struct mt76_queue_entry *e = &q->entry[index];
99+
100+ len = intr->rx.len[qid][i];
101+ e->skb = mt7663s_build_rx_skb(buf, len, round_up(len + 4, 4));
102+ if (!e->skb)
103+ break;
104+
105+ buf += round_up(len + 4, 4);
106+ if (q->queued + i + 1 == q->ndesc)
107+ break;
108+ }
109+ __free_pages(page, order);
110+
111+ spin_lock_bh(&q->lock);
112+ q->tail = (q->tail + i) % q->ndesc;
113+ q->queued += i;
114+ spin_unlock_bh(&q->lock);
115+
116+ return err;
117+}
118+
119+static int mt7663s_tx_update_sched(struct mt7615_dev *dev,
120+ struct mt76_queue_entry *e,
121+ bool mcu)
122+{
123+ struct mt76_sdio *sdio = &dev->mt76.sdio;
124+ struct mt76_phy *mphy = &dev->mt76.phy;
125+ struct ieee80211_hdr *hdr;
126+ int size, ret = -EBUSY;
127+
128+ size = DIV_ROUND_UP(e->buf_sz + sdio->sched.deficit, MT_PSE_PAGE_SZ);
129+
130+ if (mcu) {
131+ if (!test_bit(MT76_STATE_MCU_RUNNING, &mphy->state))
132+ return 0;
133+
134+ mutex_lock(&sdio->sched.lock);
135+ if (sdio->sched.pse_mcu_quota > size) {
136+ sdio->sched.pse_mcu_quota -= size;
137+ ret = 0;
138+ }
139+ mutex_unlock(&sdio->sched.lock);
140+
141+ return ret;
142+ }
143+
144+ hdr = (struct ieee80211_hdr *)(e->skb->data + MT_USB_TXD_SIZE);
145+ if (ieee80211_is_ctl(hdr->frame_control))
146+ return 0;
147+
148+ mutex_lock(&sdio->sched.lock);
149+ if (sdio->sched.pse_data_quota > size &&
150+ sdio->sched.ple_data_quota > 0) {
151+ sdio->sched.pse_data_quota -= size;
152+ sdio->sched.ple_data_quota--;
153+ ret = 0;
154+ }
155+ mutex_unlock(&sdio->sched.lock);
156+
157+ return ret;
158+}
159+
160+static int mt7663s_tx_run_queue(struct mt7615_dev *dev, struct mt76_queue *q)
161+{
162+ bool mcu = q == dev->mt76.q_tx[MT_TXQ_MCU].q;
163+ struct mt76_sdio *sdio = &dev->mt76.sdio;
164+ int nframes = 0;
165+
166+ while (q->first != q->tail) {
167+ struct mt76_queue_entry *e = &q->entry[q->first];
168+ int err, len = e->skb->len;
169+
170+ if (mt7663s_tx_update_sched(dev, e, mcu))
171+ break;
172+
173+ if (len > sdio->func->cur_blksize)
174+ len = roundup(len, sdio->func->cur_blksize);
175+
176+ /* TODO: skb_walk_frags and then write to SDIO port */
177+ err = sdio_writesb(sdio->func, MCR_WTDR1, e->skb->data, len);
178+ if (err) {
179+ dev_err(dev->mt76.dev, "sdio write failed: %d\n", err);
180+ return -EIO;
181+ }
182+
183+ e->done = true;
184+ q->first = (q->first + 1) % q->ndesc;
185+ nframes++;
186+ }
187+
188+ return nframes;
189+}
190+
191+static int mt7663s_tx_run_queues(struct mt7615_dev *dev)
192+{
193+ int i, nframes = 0;
194+
195+ for (i = 0; i < MT_TXQ_MCU_WA; i++) {
196+ int ret;
197+
198+ ret = mt7663s_tx_run_queue(dev, dev->mt76.q_tx[i].q);
199+ if (ret < 0)
200+ return ret;
201+
202+ nframes += ret;
203+ }
204+
205+ return nframes;
206+}
207+
208+int mt7663s_kthread_run(void *data)
209+{
210+ struct mt7615_dev *dev = data;
211+ struct mt76_phy *mphy = &dev->mt76.phy;
212+
213+ while (!kthread_should_stop()) {
214+ int ret;
215+
216+ cond_resched();
217+
218+ sdio_claim_host(dev->mt76.sdio.func);
219+ ret = mt7663s_tx_run_queues(dev);
220+ sdio_release_host(dev->mt76.sdio.func);
221+
222+ if (ret <= 0 || !test_bit(MT76_STATE_RUNNING, &mphy->state)) {
223+ set_current_state(TASK_INTERRUPTIBLE);
224+ schedule();
225+ } else {
226+ wake_up_process(dev->mt76.sdio.kthread);
227+ }
228+ }
229+
230+ return 0;
231+}
232+
233+void mt7663s_sdio_irq(struct sdio_func *func)
234+{
235+ struct mt7615_dev *dev = sdio_get_drvdata(func);
236+ struct mt76_sdio *sdio = &dev->mt76.sdio;
237+ struct mt76s_intr intr;
238+
239+ /* disable interrupt */
240+ sdio_writel(func, WHLPCR_INT_EN_CLR, MCR_WHLPCR, 0);
241+
242+ do {
243+ sdio_readsb(func, &intr, MCR_WHISR, sizeof(struct mt76s_intr));
244+ trace_dev_irq(&dev->mt76, intr.isr, 0);
245+
246+ if (!test_bit(MT76_STATE_INITIALIZED, &dev->mt76.phy.state))
247+ goto out;
248+
249+ if (intr.isr & WHIER_RX0_DONE_INT_EN) {
250+ mt7663s_rx_run_queue(dev, 0, &intr);
251+ wake_up_process(sdio->kthread);
252+ }
253+
254+ if (intr.isr & WHIER_RX1_DONE_INT_EN) {
255+ mt7663s_rx_run_queue(dev, 1, &intr);
256+ wake_up_process(sdio->kthread);
257+ }
258+
259+ if (intr.isr & WHIER_TX_DONE_INT_EN) {
260+ mt7663s_refill_sched_quota(dev, intr.tx.wtqcr);
261+ mt7663s_tx_run_queues(dev);
262+ wake_up_process(sdio->kthread);
263+ }
264+ } while (intr.isr);
265+out:
266+ /* enable interrupt */
267+ sdio_writel(func, WHLPCR_INT_EN_SET, MCR_WHLPCR, 0);
268+}
drivers/net/wireless/mediatek/mt76/mt7615/testmode.c+363−0
@@ -0,0 +1,363 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */
3+
4+#include "mt7615.h"
5+#include "eeprom.h"
6+#include "mcu.h"
7+
8+enum {
9+ TM_CHANGED_TXPOWER_CTRL,
10+ TM_CHANGED_TXPOWER,
11+ TM_CHANGED_FREQ_OFFSET,
12+
13+ /* must be last */
14+ NUM_TM_CHANGED
15+};
16+
17+
18+static const u8 tm_change_map[] = {
19+ [TM_CHANGED_TXPOWER_CTRL] = MT76_TM_ATTR_TX_POWER_CONTROL,
20+ [TM_CHANGED_TXPOWER] = MT76_TM_ATTR_TX_POWER,
21+ [TM_CHANGED_FREQ_OFFSET] = MT76_TM_ATTR_FREQ_OFFSET,
22+};
23+
24+static const u32 reg_backup_list[] = {
25+ MT_WF_PHY_RFINTF3_0(0),
26+ MT_WF_PHY_RFINTF3_0(1),
27+ MT_WF_PHY_RFINTF3_0(2),
28+ MT_WF_PHY_RFINTF3_0(3),
29+ MT_ANT_SWITCH_CON(2),
30+ MT_ANT_SWITCH_CON(3),
31+ MT_ANT_SWITCH_CON(4),
32+ MT_ANT_SWITCH_CON(6),
33+ MT_ANT_SWITCH_CON(7),
34+ MT_ANT_SWITCH_CON(8),
35+};
36+
37+static const struct {
38+ u16 wf;
39+ u16 reg;
40+} rf_backup_list[] = {
41+ { 0, 0x48 },
42+ { 1, 0x48 },
43+ { 2, 0x48 },
44+ { 3, 0x48 },
45+};
46+
47+static int
48+mt7615_tm_set_tx_power(struct mt7615_phy *phy)
49+{
50+ struct mt7615_dev *dev = phy->dev;
51+ struct mt76_phy *mphy = phy->mt76;
52+ int i, ret, n_chains = hweight8(mphy->antenna_mask);
53+ struct cfg80211_chan_def *chandef = &mphy->chandef;
54+ int freq = chandef->center_freq1, len, target_chains;
55+ u8 *data, *eep = (u8 *)dev->mt76.eeprom.data;
56+ enum nl80211_band band = chandef->chan->band;
57+ struct sk_buff *skb;
58+ struct {
59+ u8 center_chan;
60+ u8 dbdc_idx;
61+ u8 band;
62+ u8 rsv;
63+ } __packed req_hdr = {
64+ .center_chan = ieee80211_frequency_to_channel(freq),
65+ .band = band,
66+ .dbdc_idx = phy != &dev->phy,
67+ };
68+ u8 *tx_power = NULL;
69+
70+ if (dev->mt76.test.state != MT76_TM_STATE_OFF)
71+ tx_power = dev->mt76.test.tx_power;
72+
73+ len = sizeof(req_hdr) + MT7615_EE_MAX - MT_EE_NIC_CONF_0;
74+ skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req_hdr) + len);
75+ if (!skb)
76+ return -ENOMEM;
77+
78+ skb_put_data(skb, &req_hdr, sizeof(req_hdr));
79+ data = skb_put_data(skb, eep + MT_EE_NIC_CONF_0, len);
80+
81+ target_chains = mt7615_ext_pa_enabled(dev, band) ? 1 : n_chains;
82+ for (i = 0; i < target_chains; i++) {
83+ int index;
84+
85+ ret = mt7615_eeprom_get_target_power_index(dev, chandef->chan, i);
86+ if (ret < 0)
87+ return -EINVAL;
88+
89+ index = ret - MT_EE_NIC_CONF_0;
90+ if (tx_power && tx_power[i])
91+ data[ret - MT_EE_NIC_CONF_0] = tx_power[i];
92+ }
93+
94+ return __mt76_mcu_skb_send_msg(&dev->mt76, skb,
95+ MCU_EXT_CMD_SET_TX_POWER_CTRL, false);
96+}
97+
98+static void
99+mt7615_tm_reg_backup_restore(struct mt7615_dev *dev)
100+{
101+ u32 *b = dev->test.reg_backup;
102+ int n_regs = ARRAY_SIZE(reg_backup_list);
103+ int n_rf_regs = ARRAY_SIZE(rf_backup_list);
104+ int i;
105+
106+ if (dev->mt76.test.state == MT76_TM_STATE_OFF) {
107+ for (i = 0; i < n_regs; i++)
108+ mt76_wr(dev, reg_backup_list[i], b[i]);
109+
110+ for (i = 0; i < n_rf_regs; i++)
111+ mt7615_rf_wr(dev, rf_backup_list[i].wf,
112+ rf_backup_list[i].reg, b[n_regs + i]);
113+ return;
114+ }
115+
116+ if (b)
117+ return;
118+
119+ b = devm_kzalloc(dev->mt76.dev, 4 * (n_regs + n_rf_regs),
120+ GFP_KERNEL);
121+ if (!b)
122+ return;
123+
124+ dev->test.reg_backup = b;
125+ for (i = 0; i < n_regs; i++)
126+ b[i] = mt76_rr(dev, reg_backup_list[i]);
127+ for (i = 0; i < n_rf_regs; i++)
128+ b[n_regs + i] = mt7615_rf_rr(dev, rf_backup_list[i].wf,
129+ rf_backup_list[i].reg);
130+}
131+
132+
133+static void
134+mt7615_tm_init_phy(struct mt7615_dev *dev, struct mt7615_phy *phy)
135+{
136+ unsigned int total_flags = ~0;
137+
138+ if (!test_bit(MT76_STATE_RUNNING, &phy->mt76->state))
139+ return;
140+
141+ mutex_unlock(&dev->mt76.mutex);
142+ mt7615_set_channel(phy);
143+ mt7615_ops.configure_filter(phy->mt76->hw, 0, &total_flags, 0);
144+ mutex_lock(&dev->mt76.mutex);
145+
146+ mt7615_tm_reg_backup_restore(dev);
147+}
148+
149+static void
150+mt7615_tm_init(struct mt7615_dev *dev)
151+{
152+ mt7615_tm_init_phy(dev, &dev->phy);
153+
154+ if (dev->mt76.phy2)
155+ mt7615_tm_init_phy(dev, dev->mt76.phy2->priv);
156+}
157+
158+static void
159+mt7615_tm_set_rx_enable(struct mt7615_dev *dev, bool en)
160+{
161+ u32 rqcr_mask = (MT_ARB_RQCR_RX_START |
162+ MT_ARB_RQCR_RXV_START |
163+ MT_ARB_RQCR_RXV_R_EN |
164+ MT_ARB_RQCR_RXV_T_EN) *
165+ (BIT(0) | BIT(MT_ARB_RQCR_BAND_SHIFT));
166+
167+ if (en) {
168+ mt76_clear(dev, MT_ARB_SCR,
169+ MT_ARB_SCR_RX0_DISABLE | MT_ARB_SCR_RX1_DISABLE);
170+ mt76_set(dev, MT_ARB_RQCR, rqcr_mask);
171+ } else {
172+ mt76_set(dev, MT_ARB_SCR,
173+ MT_ARB_SCR_RX0_DISABLE | MT_ARB_SCR_RX1_DISABLE);
174+ mt76_clear(dev, MT_ARB_RQCR, rqcr_mask);
175+ }
176+}
177+
178+static void
179+mt7615_tm_set_tx_antenna(struct mt7615_dev *dev, bool en)
180+{
181+ struct mt76_testmode_data *td = &dev->mt76.test;
182+ u8 mask = td->tx_antenna_mask;
183+ int i;
184+
185+ if (!mask)
186+ return;
187+
188+ if (!en)
189+ mask = dev->phy.chainmask;
190+
191+ for (i = 0; i < 4; i++) {
192+ mt76_rmw_field(dev, MT_WF_PHY_RFINTF3_0(i),
193+ MT_WF_PHY_RFINTF3_0_ANT,
194+ td->tx_antenna_mask & BIT(i) ? 0 : 0xa);
195+
196+ }
197+
198+ /* 2.4 GHz band */
199+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(3), MT_ANT_SWITCH_CON_MODE(0),
200+ (td->tx_antenna_mask & BIT(0)) ? 0x8 : 0x1b);
201+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(4), MT_ANT_SWITCH_CON_MODE(2),
202+ (td->tx_antenna_mask & BIT(1)) ? 0xe : 0x1b);
203+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(6), MT_ANT_SWITCH_CON_MODE1(0),
204+ (td->tx_antenna_mask & BIT(2)) ? 0x0 : 0xf);
205+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(7), MT_ANT_SWITCH_CON_MODE1(2),
206+ (td->tx_antenna_mask & BIT(3)) ? 0x6 : 0xf);
207+
208+ /* 5 GHz band */
209+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(4), MT_ANT_SWITCH_CON_MODE(1),
210+ (td->tx_antenna_mask & BIT(0)) ? 0xd : 0x1b);
211+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(2), MT_ANT_SWITCH_CON_MODE(3),
212+ (td->tx_antenna_mask & BIT(1)) ? 0x13 : 0x1b);
213+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(7), MT_ANT_SWITCH_CON_MODE1(1),
214+ (td->tx_antenna_mask & BIT(2)) ? 0x5 : 0xf);
215+ mt76_rmw_field(dev, MT_ANT_SWITCH_CON(8), MT_ANT_SWITCH_CON_MODE1(3),
216+ (td->tx_antenna_mask & BIT(3)) ? 0xb : 0xf);
217+
218+ for (i = 0; i < 4; i++) {
219+ u32 val;
220+
221+ val = mt7615_rf_rr(dev, i, 0x48);
222+ val &= ~(0x3ff << 20);
223+ if (td->tx_antenna_mask & BIT(i))
224+ val |= 3 << 20;
225+ else
226+ val |= (2 << 28) | (2 << 26) | (8 << 20);
227+ mt7615_rf_wr(dev, i, 0x48, val);
228+ }
229+}
230+
231+static void
232+mt7615_tm_set_tx_frames(struct mt7615_dev *dev, bool en)
233+{
234+ struct ieee80211_tx_info *info;
235+ struct sk_buff *skb = dev->mt76.test.tx_skb;
236+
237+ mt7615_mcu_set_chan_info(&dev->phy, MCU_EXT_CMD_SET_RX_PATH);
238+ mt7615_tm_set_tx_antenna(dev, en);
239+ mt7615_tm_set_rx_enable(dev, !en);
240+ if (!en || !skb)
241+ return;
242+
243+ info = IEEE80211_SKB_CB(skb);
244+ info->control.vif = dev->phy.monitor_vif;
245+}
246+
247+static void
248+mt7615_tm_update_params(struct mt7615_dev *dev, u32 changed)
249+{
250+ struct mt76_testmode_data *td = &dev->mt76.test;
251+ bool en = dev->mt76.test.state != MT76_TM_STATE_OFF;
252+
253+ if (changed & BIT(TM_CHANGED_TXPOWER_CTRL))
254+ mt7615_mcu_set_test_param(dev, MCU_ATE_SET_TX_POWER_CONTROL,
255+ en, en && td->tx_power_control);
256+ if (changed & BIT(TM_CHANGED_FREQ_OFFSET))
257+ mt7615_mcu_set_test_param(dev, MCU_ATE_SET_FREQ_OFFSET,
258+ en, en ? td->freq_offset : 0);
259+ if (changed & BIT(TM_CHANGED_TXPOWER))
260+ mt7615_tm_set_tx_power(&dev->phy);
261+}
262+
263+static int
264+mt7615_tm_set_state(struct mt76_dev *mdev, enum mt76_testmode_state state)
265+{
266+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
267+ struct mt76_testmode_data *td = &mdev->test;
268+ enum mt76_testmode_state prev_state = td->state;
269+
270+ mdev->test.state = state;
271+
272+ if (prev_state == MT76_TM_STATE_TX_FRAMES)
273+ mt7615_tm_set_tx_frames(dev, false);
274+ else if (state == MT76_TM_STATE_TX_FRAMES)
275+ mt7615_tm_set_tx_frames(dev, true);
276+
277+ if (state <= MT76_TM_STATE_IDLE)
278+ mt7615_tm_init(dev);
279+
280+ if ((state == MT76_TM_STATE_IDLE &&
281+ prev_state == MT76_TM_STATE_OFF) ||
282+ (state == MT76_TM_STATE_OFF &&
283+ prev_state == MT76_TM_STATE_IDLE)) {
284+ u32 changed = 0;
285+ int i;
286+
287+ for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
288+ u16 cur = tm_change_map[i];
289+
290+ if (td->param_set[cur / 32] & BIT(cur % 32))
291+ changed |= BIT(i);
292+ }
293+
294+ mt7615_tm_update_params(dev, changed);
295+ }
296+
297+ return 0;
298+}
299+
300+static int
301+mt7615_tm_set_params(struct mt76_dev *mdev, struct nlattr **tb,
302+ enum mt76_testmode_state new_state)
303+{
304+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
305+ struct mt76_testmode_data *td = &dev->mt76.test;
306+ u32 changed = 0;
307+ int i;
308+
309+ BUILD_BUG_ON(NUM_TM_CHANGED >= 32);
310+
311+ if (new_state == MT76_TM_STATE_OFF ||
312+ td->state == MT76_TM_STATE_OFF)
313+ return 0;
314+
315+ if (td->tx_antenna_mask & ~dev->phy.chainmask)
316+ return -EINVAL;
317+
318+ for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
319+ if (tb[tm_change_map[i]])
320+ changed |= BIT(i);
321+ }
322+
323+ mt7615_tm_update_params(dev, changed);
324+
325+ return 0;
326+}
327+
328+static int
329+mt7615_tm_dump_stats(struct mt76_dev *mdev, struct sk_buff *msg)
330+{
331+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
332+ void *rx, *rssi;
333+ int i;
334+
335+ rx = nla_nest_start(msg, MT76_TM_STATS_ATTR_LAST_RX);
336+ if (!rx)
337+ return -ENOMEM;
338+
339+ if (nla_put_s32(msg, MT76_TM_RX_ATTR_FREQ_OFFSET, dev->test.last_freq_offset) ||
340+ nla_put_s32(msg, MT76_TM_RX_ATTR_IB_RSSI, dev->test.last_ib_rssi) ||
341+ nla_put_s32(msg, MT76_TM_RX_ATTR_WB_RSSI, dev->test.last_wb_rssi))
342+ return -ENOMEM;
343+
344+ rssi = nla_nest_start(msg, MT76_TM_RX_ATTR_RCPI);
345+ if (!rssi)
346+ return -ENOMEM;
347+
348+ for (i = 0; i < ARRAY_SIZE(dev->test.last_rcpi); i++)
349+ if (nla_put_u8(msg, i, dev->test.last_rcpi[i]))
350+ return -ENOMEM;
351+
352+ nla_nest_end(msg, rssi);
353+
354+ nla_nest_end(msg, rx);
355+
356+ return 0;
357+}
358+
359+const struct mt76_testmode_ops mt7615_testmode_ops = {
360+ .set_state = mt7615_tm_set_state,
361+ .set_params = mt7615_tm_set_params,
362+ .dump_stats = mt7615_tm_dump_stats,
363+};
drivers/net/wireless/mediatek/mt76/mt7615/usb.c+17−229
@@ -15,31 +15,6 @@ · 14 unmodified lines
1515 #include "mcu.h"
1616 #include "regs.h"
1717
18−static const u32 mt7663u_reg_map[] = {
19− [MT_TOP_CFG_BASE] = 0x80020000,
20− [MT_HW_BASE] = 0x80000000,
21− [MT_DMA_SHDL_BASE] = 0x5000a000,
22− [MT_HIF_BASE] = 0x50000000,
23− [MT_CSR_BASE] = 0x40000000,
24− [MT_EFUSE_ADDR_BASE] = 0x78011000,
25− [MT_TOP_MISC_BASE] = 0x81020000,
26− [MT_PLE_BASE] = 0x82060000,
27− [MT_PSE_BASE] = 0x82068000,
28− [MT_PHY_BASE] = 0x82070000,
29− [MT_WTBL_BASE_ADDR] = 0x820e0000,
30− [MT_CFG_BASE] = 0x820f0000,
31− [MT_AGG_BASE] = 0x820f2000,
32− [MT_ARB_BASE] = 0x820f3000,
33− [MT_TMAC_BASE] = 0x820f4000,
34− [MT_RMAC_BASE] = 0x820f5000,
35− [MT_DMA_BASE] = 0x820f7000,
36− [MT_PF_BASE] = 0x820f8000,
37− [MT_WTBL_BASE_ON] = 0x820f9000,
38− [MT_WTBL_BASE_OFF] = 0x820f9800,
39− [MT_LPON_BASE] = 0x820fb000,
40− [MT_MIB_BASE] = 0x820fd000,
41−};
42−
4318 static const struct usb_device_id mt7615_device_table[] = {
4419 { USB_DEVICE_AND_INTERFACE_INFO(0x0e8d, 0x7663, 0xff, 0xff, 0xff) },
4520 { },
@@ -64,205 +39,19 @@ static void mt7663u_cleanup(struct mt7615_dev *dev) · 18 unmodified lines
6439 mt76u_queues_deinit(&dev->mt76);
6540 }
6641
67−static void
68−mt7663u_mac_write_txwi(struct mt7615_dev *dev, struct mt76_wcid *wcid,
69− enum mt76_txq_id qid, struct ieee80211_sta *sta,
70− struct sk_buff *skb)
71−{
72− struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
73− struct ieee80211_key_conf *key = info->control.hw_key;
74− __le32 *txwi;
75− int pid;
76−
77− if (!wcid)
78− wcid = &dev->mt76.global_wcid;
79−
80− pid = mt76_tx_status_skb_add(&dev->mt76, wcid, skb);
81−
82− txwi = (__le32 *)(skb->data - MT_USB_TXD_SIZE);
83− memset(txwi, 0, MT_USB_TXD_SIZE);
84− mt7615_mac_write_txwi(dev, txwi, skb, wcid, sta, pid, key, false);
85− skb_push(skb, MT_USB_TXD_SIZE);
86−}
87−
88−static int
89−__mt7663u_mac_set_rates(struct mt7615_dev *dev,
90− struct mt7615_wtbl_desc *wd)
91−{
92− struct mt7615_rate_desc *rate = &wd->rate;
93− struct mt7615_sta *sta = wd->sta;
94− u32 w5, w27, addr, val;
95−
96− lockdep_assert_held(&dev->mt76.mutex);
97−
98− if (!sta)
99− return -EINVAL;
100−
101− if (!mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000))
102− return -ETIMEDOUT;
103−
104− addr = mt7615_mac_wtbl_addr(dev, sta->wcid.idx);
105−
106− w27 = mt76_rr(dev, addr + 27 * 4);
107− w27 &= ~MT_WTBL_W27_CC_BW_SEL;
108− w27 |= FIELD_PREP(MT_WTBL_W27_CC_BW_SEL, rate->bw);
109−
110− w5 = mt76_rr(dev, addr + 5 * 4);
111− w5 &= ~(MT_WTBL_W5_BW_CAP | MT_WTBL_W5_CHANGE_BW_RATE |
112− MT_WTBL_W5_MPDU_OK_COUNT |
113− MT_WTBL_W5_MPDU_FAIL_COUNT |
114− MT_WTBL_W5_RATE_IDX);
115− w5 |= FIELD_PREP(MT_WTBL_W5_BW_CAP, rate->bw) |
116− FIELD_PREP(MT_WTBL_W5_CHANGE_BW_RATE,
117− rate->bw_idx ? rate->bw_idx - 1 : 7);
118−
119− mt76_wr(dev, MT_WTBL_RIUCR0, w5);
120−
121− mt76_wr(dev, MT_WTBL_RIUCR1,
122− FIELD_PREP(MT_WTBL_RIUCR1_RATE0, rate->probe_val) |
123− FIELD_PREP(MT_WTBL_RIUCR1_RATE1, rate->val[0]) |
124− FIELD_PREP(MT_WTBL_RIUCR1_RATE2_LO, rate->val[1]));
125−
126− mt76_wr(dev, MT_WTBL_RIUCR2,
127− FIELD_PREP(MT_WTBL_RIUCR2_RATE2_HI, rate->val[1] >> 8) |
128− FIELD_PREP(MT_WTBL_RIUCR2_RATE3, rate->val[1]) |
129− FIELD_PREP(MT_WTBL_RIUCR2_RATE4, rate->val[2]) |
130− FIELD_PREP(MT_WTBL_RIUCR2_RATE5_LO, rate->val[2]));
131−
132− mt76_wr(dev, MT_WTBL_RIUCR3,
133− FIELD_PREP(MT_WTBL_RIUCR3_RATE5_HI, rate->val[2] >> 4) |
134− FIELD_PREP(MT_WTBL_RIUCR3_RATE6, rate->val[3]) |
135− FIELD_PREP(MT_WTBL_RIUCR3_RATE7, rate->val[3]));
136−
137− mt76_wr(dev, MT_WTBL_UPDATE,
138− FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, sta->wcid.idx) |
139− MT_WTBL_UPDATE_RATE_UPDATE |
140− MT_WTBL_UPDATE_TX_COUNT_CLEAR);
141−
142− mt76_wr(dev, addr + 27 * 4, w27);
143−
144− mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */
145− val = mt76_rr(dev, MT_LPON_UTTR0);
146− sta->rate_set_tsf = (val & ~BIT(0)) | rate->rateset;
147−
148− if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET))
149− mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000);
150−
151− sta->rate_count = 2 * MT7615_RATE_RETRY * sta->n_rates;
152− sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
153−
154− return 0;
155−}
156−
157−static int
158−__mt7663u_mac_set_key(struct mt7615_dev *dev,
159− struct mt7615_wtbl_desc *wd)
160−{
161− struct mt7615_key_desc *key = &wd->key;
162− struct mt7615_sta *sta = wd->sta;
163− enum mt7615_cipher_type cipher;
164− struct mt76_wcid *wcid;
165− int err;
166−
167− lockdep_assert_held(&dev->mt76.mutex);
168−
169− if (!sta)
170− return -EINVAL;
171−
172− cipher = mt7615_mac_get_cipher(key->cipher);
173− if (cipher == MT_CIPHER_NONE)
174− return -EOPNOTSUPP;
175−
176− wcid = &wd->sta->wcid;
177−
178− mt7615_mac_wtbl_update_cipher(dev, wcid, cipher, key->cmd);
179− err = mt7615_mac_wtbl_update_key(dev, wcid, key->key, key->keylen,
180− cipher, key->cmd);
181− if (err < 0)
182− return err;
183−
184− err = mt7615_mac_wtbl_update_pk(dev, wcid, cipher, key->keyidx,
185− key->cmd);
186− if (err < 0)
187− return err;
188−
189− if (key->cmd == SET_KEY)
190− wcid->cipher |= BIT(cipher);
191− else
192− wcid->cipher &= ~BIT(cipher);
193−
194− return 0;
195−}
196−
197−void mt7663u_wtbl_work(struct work_struct *work)
42+static void mt7663u_init_work(struct work_struct *work)
19843 {
199− struct mt7615_wtbl_desc *wd, *wd_next;
20044 struct mt7615_dev *dev;
20145
202− dev = (struct mt7615_dev *)container_of(work, struct mt7615_dev,
203− wtbl_work);
204−
205− list_for_each_entry_safe(wd, wd_next, &dev->wd_head, node) {
206− spin_lock_bh(&dev->mt76.lock);
207− list_del(&wd->node);
208− spin_unlock_bh(&dev->mt76.lock);
209−
210− mutex_lock(&dev->mt76.mutex);
211− switch (wd->type) {
212− case MT7615_WTBL_RATE_DESC:
213− __mt7663u_mac_set_rates(dev, wd);
214− break;
215− case MT7615_WTBL_KEY_DESC:
216− __mt7663u_mac_set_key(dev, wd);
217− break;
218− }
219− mutex_unlock(&dev->mt76.mutex);
220−
221− kfree(wd);
222− }
223−}
224−
225−static void
226−mt7663u_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
227− struct mt76_queue_entry *e)
228−{
229− skb_pull(e->skb, MT_USB_HDR_SIZE + MT_USB_TXD_SIZE);
230− mt76_tx_complete_skb(mdev, e->skb);
231−}
232−
233−static int
234−mt7663u_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
235− enum mt76_txq_id qid, struct mt76_wcid *wcid,
236− struct ieee80211_sta *sta,
237− struct mt76_tx_info *tx_info)
238−{
239− struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
240− struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx_info->skb);
241−
242− if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) {
243− struct mt7615_sta *msta;
244−
245− msta = container_of(wcid, struct mt7615_sta, wcid);
246− spin_lock_bh(&dev->mt76.lock);
247− mt7615_mac_set_rates(&dev->phy, msta, &info->control.rates[0],
248− msta->rates);
249− msta->rate_probe = true;
250− spin_unlock_bh(&dev->mt76.lock);
251− }
252− mt7663u_mac_write_txwi(dev, wcid, qid, sta, tx_info->skb);
253−
254− return mt76u_skb_dma_info(tx_info->skb, tx_info->skb->len);
255−}
256−
257−static bool mt7663u_tx_status_data(struct mt76_dev *mdev, u8 *update)
258−{
259− struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
260−
261− mutex_lock(&dev->mt76.mutex);
262− mt7615_mac_sta_poll(dev);
263− mutex_unlock(&dev->mt76.mutex);
46+ dev = container_of(work, struct mt7615_dev, mcu_work);
47+ if (mt7663u_mcu_init(dev))
48+ return;
26449
265− return 0;
50+ mt7615_mcu_set_eeprom(dev);
51+ mt7615_mac_init(dev);
52+ mt7615_phy_init(dev);
53+ mt7615_mcu_del_wtbl_all(dev);
54+ mt7615_check_offload_capability(dev);
26655 }
26756
26857 static int mt7663u_probe(struct usb_interface *usb_intf,
@@ -271,9 +60,9 @@ static int mt7663u_probe(struct usb_interface *usb_intf, · 2 unmodified lines
27160 static const struct mt76_driver_ops drv_ops = {
27261 .txwi_size = MT_USB_TXD_SIZE,
27362 .drv_flags = MT_DRV_RX_DMA_HDR | MT_DRV_HW_MGMT_TXQ,
274− .tx_prepare_skb = mt7663u_tx_prepare_skb,
275− .tx_complete_skb = mt7663u_tx_complete_skb,
276− .tx_status_data = mt7663u_tx_status_data,
63+ .tx_prepare_skb = mt7663_usb_sdio_tx_prepare_skb,
64+ .tx_complete_skb = mt7663_usb_sdio_tx_complete_skb,
65+ .tx_status_data = mt7663_usb_sdio_tx_status_data,
27766 .rx_skb = mt7615_queue_rx_skb,
27867 .sta_ps = mt7615_sta_ps,
27968 .sta_add = mt7615_mac_sta_add,
@@ -303,7 +92,8 @@ static int mt7663u_probe(struct usb_interface *usb_intf, · 23 unmodified lines
30392
30493 usb_set_intfdata(usb_intf, dev);
30594
306− dev->reg_map = mt7663u_reg_map;
95+ INIT_WORK(&dev->mcu_work, mt7663u_init_work);
96+ dev->reg_map = mt7663_usb_sdio_reg_map;
30797 dev->ops = ops;
30898 ret = mt76u_init(mdev, usb_intf, true);
30999 if (ret < 0)
@@ -342,7 +132,7 @@ alloc_queues: · 32 unmodified lines
342132 if (ret)
343133 goto error_free_q;
344134
345− ret = mt7663u_register_device(dev);
135+ ret = mt7663_usb_sdio_register_device(dev);
346136 if (ret)
347137 goto error_free_q;
348138
@@ -351,11 +141,10 @@ alloc_queues: · 2 unmodified lines
351141 error_free_q:
352142 mt76u_queues_deinit(&dev->mt76);
353143 error:
354− mt76u_deinit(&dev->mt76);
355144 usb_set_intfdata(usb_intf, NULL);
356145 usb_put_dev(interface_to_usbdev(usb_intf));
357146
358− ieee80211_free_hw(mdev->hw);
147+ mt76_free_device(&dev->mt76);
359148
360149 return ret;
361150 }
@@ -373,8 +162,7 @@ static void mt7663u_disconnect(struct usb_interface *usb_intf) · 11 unmodified lines
373162 usb_set_intfdata(usb_intf, NULL);
374163 usb_put_dev(interface_to_usbdev(usb_intf));
375164
376− mt76u_deinit(&dev->mt76);
377− ieee80211_free_hw(dev->mt76.hw);
165+ mt76_free_device(&dev->mt76);
378166 }
379167
380168 #ifdef CONFIG_PM
drivers/net/wireless/mediatek/mt76/mt7615/usb_init.c+0−145
@@ -1,145 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/* Copyright (C) 2019 MediaTek Inc.
3− *
4− * Author: Felix Fietkau <nbd@nbd.name>
5− * Lorenzo Bianconi <lorenzo@kernel.org>
6− * Sean Wang <sean.wang@mediatek.com>
7− */
8−
9−#include <linux/kernel.h>
10−#include <linux/module.h>
11−
12−#include "mt7615.h"
13−#include "mac.h"
14−#include "regs.h"
15−
16−static int mt7663u_dma_sched_init(struct mt7615_dev *dev)
17−{
18− int i;
19−
20− mt76_rmw(dev, MT_DMA_SHDL(MT_DMASHDL_PKT_MAX_SIZE),
21− MT_DMASHDL_PKT_MAX_SIZE_PLE | MT_DMASHDL_PKT_MAX_SIZE_PSE,
22− FIELD_PREP(MT_DMASHDL_PKT_MAX_SIZE_PLE, 1) |
23− FIELD_PREP(MT_DMASHDL_PKT_MAX_SIZE_PSE, 8));
24−
25− /* disable refill group 5 - group 15 and raise group 2
26− * and 3 as high priority.
27− */
28− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_REFILL), 0xffe00006);
29− mt76_clear(dev, MT_DMA_SHDL(MT_DMASHDL_PAGE), BIT(16));
30−
31− for (i = 0; i < 5; i++)
32− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_GROUP_QUOTA(i)),
33− FIELD_PREP(MT_DMASHDL_GROUP_QUOTA_MIN, 0x3) |
34− FIELD_PREP(MT_DMASHDL_GROUP_QUOTA_MAX, 0x1ff));
35−
36− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_Q_MAP(0)), 0x42104210);
37− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_Q_MAP(1)), 0x42104210);
38−
39− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_Q_MAP(2)), 0x4444);
40−
41− /* group pririority from high to low:
42− * 15 (cmd groups) > 4 > 3 > 2 > 1 > 0.
43− */
44− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_SCHED_SET0), 0x6501234f);
45− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_SCHED_SET1), 0xedcba987);
46− mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_OPTIONAL), 0x7004801c);
47−
48− mt76_wr(dev, MT_UDMA_WLCFG_1,
49− FIELD_PREP(MT_WL_TX_TMOUT_LMT, 80000) |
50− FIELD_PREP(MT_WL_RX_AGG_PKT_LMT, 1));
51−
52− /* setup UDMA Rx Flush */
53− mt76_clear(dev, MT_UDMA_WLCFG_0, MT_WL_RX_FLUSH);
54− /* hif reset */
55− mt76_set(dev, MT_HIF_RST, MT_HIF_LOGIC_RST_N);
56−
57− mt76_set(dev, MT_UDMA_WLCFG_0,
58− MT_WL_RX_AGG_EN | MT_WL_RX_EN | MT_WL_TX_EN |
59− MT_WL_RX_MPSZ_PAD0 | MT_TICK_1US_EN |
60− MT_WL_TX_TMOUT_FUNC_EN);
61− mt76_rmw(dev, MT_UDMA_WLCFG_0, MT_WL_RX_AGG_LMT | MT_WL_RX_AGG_TO,
62− FIELD_PREP(MT_WL_RX_AGG_LMT, 32) |
63− FIELD_PREP(MT_WL_RX_AGG_TO, 100));
64−
65− return 0;
66−}
67−
68−static int mt7663u_init_hardware(struct mt7615_dev *dev)
69−{
70− int ret, idx;
71−
72− ret = mt7615_eeprom_init(dev, MT_EFUSE_BASE);
73− if (ret < 0)
74− return ret;
75−
76− ret = mt7663u_dma_sched_init(dev);
77− if (ret)
78− return ret;
79−
80− set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
81−
82− /* Beacon and mgmt frames should occupy wcid 0 */
83− idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7615_WTBL_STA - 1);
84− if (idx)
85− return -ENOSPC;
86−
87− dev->mt76.global_wcid.idx = idx;
88− dev->mt76.global_wcid.hw_key_idx = -1;
89− rcu_assign_pointer(dev->mt76.wcid[idx], &dev->mt76.global_wcid);
90−
91− return 0;
92−}
93−
94−static void mt7663u_init_work(struct work_struct *work)
95−{
96− struct mt7615_dev *dev;
97−
98− dev = container_of(work, struct mt7615_dev, mcu_work);
99− if (mt7663u_mcu_init(dev))
100− return;
101−
102− mt7615_mcu_set_eeprom(dev);
103− mt7615_mac_init(dev);
104− mt7615_phy_init(dev);
105− mt7615_mcu_del_wtbl_all(dev);
106− mt7615_check_offload_capability(dev);
107−}
108−
109−int mt7663u_register_device(struct mt7615_dev *dev)
110−{
111− struct ieee80211_hw *hw = mt76_hw(dev);
112− int err;
113−
114− INIT_WORK(&dev->wtbl_work, mt7663u_wtbl_work);
115− INIT_WORK(&dev->mcu_work, mt7663u_init_work);
116− INIT_LIST_HEAD(&dev->wd_head);
117− mt7615_init_device(dev);
118−
119− err = mt7663u_init_hardware(dev);
120− if (err)
121− return err;
122−
123− hw->extra_tx_headroom += MT_USB_HDR_SIZE + MT_USB_TXD_SIZE;
124− /* check hw sg support in order to enable AMSDU */
125− hw->max_tx_fragments = dev->mt76.usb.sg_en ? MT_HW_TXP_MAX_BUF_NUM : 1;
126−
127− err = mt76_register_device(&dev->mt76, true, mt7615_rates,
128− ARRAY_SIZE(mt7615_rates));
129− if (err < 0)
130− return err;
131−
132− if (!dev->mt76.usb.sg_en) {
133− struct ieee80211_sta_vht_cap *vht_cap;
134−
135− /* decrease max A-MSDU size if SG is not supported */
136− vht_cap = &dev->mphy.sband_5g.sband.vht_cap;
137− vht_cap->cap &= ~IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454;
138− }
139−
140− ieee80211_queue_work(hw, &dev->mcu_work);
141− mt7615_init_txpower(dev, &dev->mphy.sband_2g.sband);
142− mt7615_init_txpower(dev, &dev->mphy.sband_5g.sband);
143−
144− return mt7615_init_debugfs(dev);
145−}
drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c+5−2
@@ -28,13 +28,13 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, · 27 unmodified lines
2828 else
2929 ep = MT_EP_OUT_AC_BE;
3030
31− ret = mt76u_skb_dma_info(skb, skb->len);
31+ put_unaligned_le32(skb->len, skb_push(skb, sizeof(skb->len)));
32+ ret = mt76_skb_adjust_pad(skb);
3233 if (ret < 0)
3334 goto out;
3435
3536 ret = mt76u_bulk_msg(&dev->mt76, skb->data, skb->len, NULL,
3637 1000, ep);
37− dev_kfree_skb(skb);
3838 if (ret < 0)
3939 goto out;
4040
@@ -43,6 +43,7 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, · 2 unmodified lines
4343
4444 out:
4545 mutex_unlock(&mdev->mcu.mutex);
46+ dev_kfree_skb(skb);
4647
4748 return ret;
4849 }
@@ -60,6 +61,8 @@ int mt7663u_mcu_init(struct mt7615_dev *dev) · 11 unmodified lines
6061
6162 dev->mt76.mcu_ops = &mt7663u_mcu_ops,
6263
64+ /* usb does not support runtime-pm */
65+ clear_bit(MT76_STATE_PM, &dev->mphy.state);
6366 mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);
6467
6568 if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) {
drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c+394−0
@@ -0,0 +1,394 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 MediaTek Inc.
3+ *
4+ * Author: Lorenzo Bianconi <lorenzo@kernel.org>
5+ * Sean Wang <sean.wang@mediatek.com>
6+ */
7+
8+#include <linux/kernel.h>
9+#include <linux/module.h>
10+#include <linux/usb.h>
11+
12+#include "mt7615.h"
13+#include "mac.h"
14+#include "mcu.h"
15+#include "regs.h"
16+
17+const u32 mt7663_usb_sdio_reg_map[] = {
18+ [MT_TOP_CFG_BASE] = 0x80020000,
19+ [MT_HW_BASE] = 0x80000000,
20+ [MT_DMA_SHDL_BASE] = 0x5000a000,
21+ [MT_HIF_BASE] = 0x50000000,
22+ [MT_CSR_BASE] = 0x40000000,
23+ [MT_EFUSE_ADDR_BASE] = 0x78011000,
24+ [MT_TOP_MISC_BASE] = 0x81020000,
25+ [MT_PLE_BASE] = 0x82060000,
26+ [MT_PSE_BASE] = 0x82068000,
27+ [MT_PP_BASE] = 0x8206c000,
28+ [MT_WTBL_BASE_ADDR] = 0x820e0000,
29+ [MT_CFG_BASE] = 0x820f0000,
30+ [MT_AGG_BASE] = 0x820f2000,
31+ [MT_ARB_BASE] = 0x820f3000,
32+ [MT_TMAC_BASE] = 0x820f4000,
33+ [MT_RMAC_BASE] = 0x820f5000,
34+ [MT_DMA_BASE] = 0x820f7000,
35+ [MT_PF_BASE] = 0x820f8000,
36+ [MT_WTBL_BASE_ON] = 0x820f9000,
37+ [MT_WTBL_BASE_OFF] = 0x820f9800,
38+ [MT_LPON_BASE] = 0x820fb000,
39+ [MT_MIB_BASE] = 0x820fd000,
40+};
41+EXPORT_SYMBOL_GPL(mt7663_usb_sdio_reg_map);
42+
43+static void
44+mt7663_usb_sdio_write_txwi(struct mt7615_dev *dev, struct mt76_wcid *wcid,
45+ enum mt76_txq_id qid, struct ieee80211_sta *sta,
46+ struct sk_buff *skb)
47+{
48+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
49+ struct ieee80211_key_conf *key = info->control.hw_key;
50+ __le32 *txwi;
51+ int pid;
52+
53+ if (!wcid)
54+ wcid = &dev->mt76.global_wcid;
55+
56+ pid = mt76_tx_status_skb_add(&dev->mt76, wcid, skb);
57+
58+ txwi = (__le32 *)(skb->data - MT_USB_TXD_SIZE);
59+ memset(txwi, 0, MT_USB_TXD_SIZE);
60+ mt7615_mac_write_txwi(dev, txwi, skb, wcid, sta, pid, key, false);
61+ skb_push(skb, MT_USB_TXD_SIZE);
62+}
63+
64+static int
65+mt7663_usb_sdio_set_rates(struct mt7615_dev *dev,
66+ struct mt7615_wtbl_desc *wd)
67+{
68+ struct mt7615_rate_desc *rate = &wd->rate;
69+ struct mt7615_sta *sta = wd->sta;
70+ u32 w5, w27, addr, val;
71+
72+ lockdep_assert_held(&dev->mt76.mutex);
73+
74+ if (!sta)
75+ return -EINVAL;
76+
77+ if (!mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000))
78+ return -ETIMEDOUT;
79+
80+ addr = mt7615_mac_wtbl_addr(dev, sta->wcid.idx);
81+
82+ w27 = mt76_rr(dev, addr + 27 * 4);
83+ w27 &= ~MT_WTBL_W27_CC_BW_SEL;
84+ w27 |= FIELD_PREP(MT_WTBL_W27_CC_BW_SEL, rate->bw);
85+
86+ w5 = mt76_rr(dev, addr + 5 * 4);
87+ w5 &= ~(MT_WTBL_W5_BW_CAP | MT_WTBL_W5_CHANGE_BW_RATE |
88+ MT_WTBL_W5_MPDU_OK_COUNT |
89+ MT_WTBL_W5_MPDU_FAIL_COUNT |
90+ MT_WTBL_W5_RATE_IDX);
91+ w5 |= FIELD_PREP(MT_WTBL_W5_BW_CAP, rate->bw) |
92+ FIELD_PREP(MT_WTBL_W5_CHANGE_BW_RATE,
93+ rate->bw_idx ? rate->bw_idx - 1 : 7);
94+
95+ mt76_wr(dev, MT_WTBL_RIUCR0, w5);
96+
97+ mt76_wr(dev, MT_WTBL_RIUCR1,
98+ FIELD_PREP(MT_WTBL_RIUCR1_RATE0, rate->probe_val) |
99+ FIELD_PREP(MT_WTBL_RIUCR1_RATE1, rate->val[0]) |
100+ FIELD_PREP(MT_WTBL_RIUCR1_RATE2_LO, rate->val[1]));
101+
102+ mt76_wr(dev, MT_WTBL_RIUCR2,
103+ FIELD_PREP(MT_WTBL_RIUCR2_RATE2_HI, rate->val[1] >> 8) |
104+ FIELD_PREP(MT_WTBL_RIUCR2_RATE3, rate->val[1]) |
105+ FIELD_PREP(MT_WTBL_RIUCR2_RATE4, rate->val[2]) |
106+ FIELD_PREP(MT_WTBL_RIUCR2_RATE5_LO, rate->val[2]));
107+
108+ mt76_wr(dev, MT_WTBL_RIUCR3,
109+ FIELD_PREP(MT_WTBL_RIUCR3_RATE5_HI, rate->val[2] >> 4) |
110+ FIELD_PREP(MT_WTBL_RIUCR3_RATE6, rate->val[3]) |
111+ FIELD_PREP(MT_WTBL_RIUCR3_RATE7, rate->val[3]));
112+
113+ mt76_wr(dev, MT_WTBL_UPDATE,
114+ FIELD_PREP(MT_WTBL_UPDATE_WLAN_IDX, sta->wcid.idx) |
115+ MT_WTBL_UPDATE_RATE_UPDATE |
116+ MT_WTBL_UPDATE_TX_COUNT_CLEAR);
117+
118+ mt76_wr(dev, addr + 27 * 4, w27);
119+
120+ sta->rate_probe = sta->rateset[rate->rateset].probe_rate.idx != -1;
121+
122+ mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */
123+ val = mt76_rr(dev, MT_LPON_UTTR0);
124+ sta->rate_set_tsf = (val & ~BIT(0)) | rate->rateset;
125+
126+ if (!(sta->wcid.tx_info & MT_WCID_TX_INFO_SET))
127+ mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000);
128+
129+ sta->rate_count = 2 * MT7615_RATE_RETRY * sta->n_rates;
130+ sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
131+
132+ return 0;
133+}
134+
135+static int
136+mt7663_usb_sdio_set_key(struct mt7615_dev *dev,
137+ struct mt7615_wtbl_desc *wd)
138+{
139+ struct mt7615_key_desc *key = &wd->key;
140+ struct mt7615_sta *sta = wd->sta;
141+ enum mt7615_cipher_type cipher;
142+ struct mt76_wcid *wcid;
143+ int err;
144+
145+ lockdep_assert_held(&dev->mt76.mutex);
146+
147+ if (!sta) {
148+ err = -EINVAL;
149+ goto out;
150+ }
151+
152+ cipher = mt7615_mac_get_cipher(key->cipher);
153+ if (cipher == MT_CIPHER_NONE) {
154+ err = -EOPNOTSUPP;
155+ goto out;
156+ }
157+
158+ wcid = &wd->sta->wcid;
159+
160+ mt7615_mac_wtbl_update_cipher(dev, wcid, cipher, key->cmd);
161+ err = mt7615_mac_wtbl_update_key(dev, wcid, key->key, key->keylen,
162+ cipher, key->cmd);
163+ if (err < 0)
164+ goto out;
165+
166+ err = mt7615_mac_wtbl_update_pk(dev, wcid, cipher, key->keyidx,
167+ key->cmd);
168+ if (err < 0)
169+ goto out;
170+
171+ if (key->cmd == SET_KEY)
172+ wcid->cipher |= BIT(cipher);
173+ else
174+ wcid->cipher &= ~BIT(cipher);
175+out:
176+ kfree(key->key);
177+
178+ return err;
179+}
180+
181+void mt7663_usb_sdio_wtbl_work(struct work_struct *work)
182+{
183+ struct mt7615_wtbl_desc *wd, *wd_next;
184+ struct list_head wd_list;
185+ struct mt7615_dev *dev;
186+
187+ dev = (struct mt7615_dev *)container_of(work, struct mt7615_dev,
188+ wtbl_work);
189+
190+ INIT_LIST_HEAD(&wd_list);
191+ spin_lock_bh(&dev->mt76.lock);
192+ list_splice_init(&dev->wd_head, &wd_list);
193+ spin_unlock_bh(&dev->mt76.lock);
194+
195+ list_for_each_entry_safe(wd, wd_next, &wd_list, node) {
196+ list_del(&wd->node);
197+
198+ mt7615_mutex_acquire(dev);
199+
200+ switch (wd->type) {
201+ case MT7615_WTBL_RATE_DESC:
202+ mt7663_usb_sdio_set_rates(dev, wd);
203+ break;
204+ case MT7615_WTBL_KEY_DESC:
205+ mt7663_usb_sdio_set_key(dev, wd);
206+ break;
207+ }
208+
209+ mt7615_mutex_release(dev);
210+
211+ kfree(wd);
212+ }
213+}
214+EXPORT_SYMBOL_GPL(mt7663_usb_sdio_wtbl_work);
215+
216+bool mt7663_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update)
217+{
218+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
219+
220+ mt7615_mutex_acquire(dev);
221+ mt7615_mac_sta_poll(dev);
222+ mt7615_mutex_release(dev);
223+
224+ return 0;
225+}
226+EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_status_data);
227+
228+void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
229+ enum mt76_txq_id qid,
230+ struct mt76_queue_entry *e)
231+{
232+ unsigned int headroom = MT_USB_TXD_SIZE;
233+
234+ if (mt76_is_usb(mdev))
235+ headroom += MT_USB_HDR_SIZE;
236+ skb_pull(e->skb, headroom);
237+
238+ mt76_tx_complete_skb(mdev, e->skb);
239+}
240+EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_complete_skb);
241+
242+int mt7663_usb_sdio_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
243+ enum mt76_txq_id qid, struct mt76_wcid *wcid,
244+ struct ieee80211_sta *sta,
245+ struct mt76_tx_info *tx_info)
246+{
247+ struct mt7615_sta *msta = container_of(wcid, struct mt7615_sta, wcid);
248+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
249+ struct sk_buff *skb = tx_info->skb;
250+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
251+
252+ if ((info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) &&
253+ !msta->rate_probe) {
254+ /* request to configure sampling rate */
255+ spin_lock_bh(&dev->mt76.lock);
256+ mt7615_mac_set_rates(&dev->phy, msta, &info->control.rates[0],
257+ msta->rates);
258+ spin_unlock_bh(&dev->mt76.lock);
259+ }
260+
261+ mt7663_usb_sdio_write_txwi(dev, wcid, qid, sta, skb);
262+ if (mt76_is_usb(mdev))
263+ put_unaligned_le32(skb->len, skb_push(skb, sizeof(skb->len)));
264+
265+ return mt76_skb_adjust_pad(skb);
266+}
267+EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_prepare_skb);
268+
269+static int mt7663u_dma_sched_init(struct mt7615_dev *dev)
270+{
271+ int i;
272+
273+ mt76_rmw(dev, MT_DMA_SHDL(MT_DMASHDL_PKT_MAX_SIZE),
274+ MT_DMASHDL_PKT_MAX_SIZE_PLE | MT_DMASHDL_PKT_MAX_SIZE_PSE,
275+ FIELD_PREP(MT_DMASHDL_PKT_MAX_SIZE_PLE, 1) |
276+ FIELD_PREP(MT_DMASHDL_PKT_MAX_SIZE_PSE, 8));
277+
278+ /* disable refill group 5 - group 15 and raise group 2
279+ * and 3 as high priority.
280+ */
281+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_REFILL), 0xffe00006);
282+ mt76_clear(dev, MT_DMA_SHDL(MT_DMASHDL_PAGE), BIT(16));
283+
284+ for (i = 0; i < 5; i++)
285+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_GROUP_QUOTA(i)),
286+ FIELD_PREP(MT_DMASHDL_GROUP_QUOTA_MIN, 0x3) |
287+ FIELD_PREP(MT_DMASHDL_GROUP_QUOTA_MAX, 0x1ff));
288+
289+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_Q_MAP(0)), 0x42104210);
290+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_Q_MAP(1)), 0x42104210);
291+
292+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_Q_MAP(2)), 0x4444);
293+
294+ /* group pririority from high to low:
295+ * 15 (cmd groups) > 4 > 3 > 2 > 1 > 0.
296+ */
297+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_SCHED_SET0), 0x6501234f);
298+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_SCHED_SET1), 0xedcba987);
299+ mt76_wr(dev, MT_DMA_SHDL(MT_DMASHDL_OPTIONAL), 0x7004801c);
300+
301+ mt76_wr(dev, MT_UDMA_WLCFG_1,
302+ FIELD_PREP(MT_WL_TX_TMOUT_LMT, 80000) |
303+ FIELD_PREP(MT_WL_RX_AGG_PKT_LMT, 1));
304+
305+ /* setup UDMA Rx Flush */
306+ mt76_clear(dev, MT_UDMA_WLCFG_0, MT_WL_RX_FLUSH);
307+ /* hif reset */
308+ mt76_set(dev, MT_HIF_RST, MT_HIF_LOGIC_RST_N);
309+
310+ mt76_set(dev, MT_UDMA_WLCFG_0,
311+ MT_WL_RX_AGG_EN | MT_WL_RX_EN | MT_WL_TX_EN |
312+ MT_WL_RX_MPSZ_PAD0 | MT_TICK_1US_EN |
313+ MT_WL_TX_TMOUT_FUNC_EN);
314+ mt76_rmw(dev, MT_UDMA_WLCFG_0, MT_WL_RX_AGG_LMT | MT_WL_RX_AGG_TO,
315+ FIELD_PREP(MT_WL_RX_AGG_LMT, 32) |
316+ FIELD_PREP(MT_WL_RX_AGG_TO, 100));
317+
318+ return 0;
319+}
320+
321+static int mt7663_usb_sdio_init_hardware(struct mt7615_dev *dev)
322+{
323+ int ret, idx;
324+
325+ ret = mt7615_eeprom_init(dev, MT_EFUSE_BASE);
326+ if (ret < 0)
327+ return ret;
328+
329+ if (mt76_is_usb(&dev->mt76)) {
330+ ret = mt7663u_dma_sched_init(dev);
331+ if (ret)
332+ return ret;
333+ }
334+
335+ set_bit(MT76_STATE_INITIALIZED, &dev->mphy.state);
336+
337+ /* Beacon and mgmt frames should occupy wcid 0 */
338+ idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7615_WTBL_STA - 1);
339+ if (idx)
340+ return -ENOSPC;
341+
342+ dev->mt76.global_wcid.idx = idx;
343+ dev->mt76.global_wcid.hw_key_idx = -1;
344+ rcu_assign_pointer(dev->mt76.wcid[idx], &dev->mt76.global_wcid);
345+
346+ return 0;
347+}
348+
349+int mt7663_usb_sdio_register_device(struct mt7615_dev *dev)
350+{
351+ struct ieee80211_hw *hw = mt76_hw(dev);
352+ int err;
353+
354+ INIT_WORK(&dev->wtbl_work, mt7663_usb_sdio_wtbl_work);
355+ INIT_LIST_HEAD(&dev->wd_head);
356+ mt7615_init_device(dev);
357+
358+ err = mt7663_usb_sdio_init_hardware(dev);
359+ if (err)
360+ return err;
361+
362+ /* check hw sg support in order to enable AMSDU */
363+ if (dev->mt76.usb.sg_en || mt76_is_sdio(&dev->mt76))
364+ hw->max_tx_fragments = MT_HW_TXP_MAX_BUF_NUM;
365+ else
366+ hw->max_tx_fragments = 1;
367+ hw->extra_tx_headroom += MT_USB_TXD_SIZE;
368+ if (mt76_is_usb(&dev->mt76))
369+ hw->extra_tx_headroom += MT_USB_HDR_SIZE;
370+
371+ err = mt76_register_device(&dev->mt76, true, mt7615_rates,
372+ ARRAY_SIZE(mt7615_rates));
373+ if (err < 0)
374+ return err;
375+
376+ if (!dev->mt76.usb.sg_en) {
377+ struct ieee80211_sta_vht_cap *vht_cap;
378+
379+ /* decrease max A-MSDU size if SG is not supported */
380+ vht_cap = &dev->mphy.sband_5g.sband.vht_cap;
381+ vht_cap->cap &= ~IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454;
382+ }
383+
384+ ieee80211_queue_work(hw, &dev->mcu_work);
385+ mt7615_init_txpower(dev, &dev->mphy.sband_2g.sband);
386+ mt7615_init_txpower(dev, &dev->mphy.sband_5g.sband);
387+
388+ return mt7615_init_debugfs(dev);
389+}
390+EXPORT_SYMBOL_GPL(mt7663_usb_sdio_register_device);
391+
392+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
393+MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
394+MODULE_LICENSE("Dual BSD/GPL");
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c+2−4
@@ -277,9 +277,8 @@ static int mt76x0u_probe(struct usb_interface *usb_intf, · 276 unmodified lines
277277 err:
278278 usb_set_intfdata(usb_intf, NULL);
279279 usb_put_dev(interface_to_usbdev(usb_intf));
280− mt76u_deinit(&dev->mt76);
280+ mt76_free_device(&dev->mt76);
281281
282− ieee80211_free_hw(mdev->hw);
283282 return ret;
284283 }
285284
@@ -297,8 +296,7 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf) · 11 unmodified lines
297296 usb_set_intfdata(usb_intf, NULL);
298297 usb_put_dev(interface_to_usbdev(usb_intf));
299298
300− mt76u_deinit(&dev->mt76);
301− ieee80211_free_hw(dev->mt76.hw);
299+ mt76_free_device(&dev->mt76);
302300 }
303301
304302 static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,
drivers/net/wireless/mediatek/mt76/mt76x02.h+0−1
@@ -80,7 +80,6 @@ struct mt76x02_dev { · 79 unmodified lines
8080
8181 struct mutex phy_mutex;
8282
83− u16 vif_mask;
8483 u16 chainmask;
8584
8685 u8 txdone_seq;
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c+1−1
@@ -439,7 +439,7 @@ static void mt76x02_reset_state(struct mt76x02_dev *dev) · 438 unmodified lines
439439 memset(msta, 0, sizeof(*msta));
440440 }
441441
442− dev->vif_mask = 0;
442+ dev->mphy.vif_mask = 0;
443443 dev->mt76.beacon_mask = 0;
444444 }
445445
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c+2−1
@@ -56,8 +56,9 @@ int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags) · 55 unmodified lines
5656 */
5757 info = FIELD_PREP(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |
5858 FIELD_PREP(MT_TXD_INFO_DPORT, port) | flags;
59+ put_unaligned_le32(info, skb_push(skb, sizeof(info)));
5960
60− return mt76u_skb_dma_info(skb, info);
61+ return mt76_skb_adjust_pad(skb);
6162 }
6263
6364 int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c+5−2
@@ -87,8 +87,10 @@ __mt76x02u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, · 86 unmodified lines
8787 u32 info;
8888 int ret;
8989
90− if (test_bit(MT76_REMOVED, &dev->phy.state))
91− return 0;
90+ if (test_bit(MT76_REMOVED, &dev->phy.state)) {
91+ ret = 0;
92+ goto out;
93+ }
9294
9395 if (wait_resp) {
9496 seq = ++dev->mcu.msg_seq & 0xf;
@@ -111,6 +113,7 @@ __mt76x02u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, · 16 unmodified lines
111113 if (wait_resp)
112114 ret = mt76x02u_mcu_wait_resp(dev, seq);
113115
116+out:
114117 consume_skb(skb);
115118
116119 return ret;
drivers/net/wireless/mediatek/mt76/mt76x02_util.c+4−4
@@ -305,7 +305,7 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 304 unmodified lines
305305 unsigned int idx = 0;
306306
307307 /* Allow to change address in HW if we create first interface. */
308− if (!dev->vif_mask &&
308+ if (!dev->mphy.vif_mask &&
309309 (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) ||
310310 memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1)))
311311 mt76x02_mac_setaddr(dev, vif->addr);
@@ -330,11 +330,11 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 18 unmodified lines
330330 idx += 8;
331331
332332 /* vif is already set or idx is 8 for AP/Mesh/... */
333− if (dev->vif_mask & BIT(idx) ||
333+ if (dev->mphy.vif_mask & BIT(idx) ||
334334 (vif->type != NL80211_IFTYPE_STATION && idx > 7))
335335 return -EBUSY;
336336
337− dev->vif_mask |= BIT(idx);
337+ dev->mphy.vif_mask |= BIT(idx);
338338
339339 mt76x02_vif_init(dev, vif, idx);
340340 return 0;
@@ -348,7 +348,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw, · 7 unmodified lines
348348 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
349349
350350 mt76_txq_remove(&dev->mt76, vif->txq);
351− dev->vif_mask &= ~BIT(mvif->idx);
351+ dev->mphy.vif_mask &= ~BIT(mvif->idx);
352352 }
353353 EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
354354
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h+1−0
@@ -39,6 +39,7 @@ static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev) · 38 unmodified lines
3939 extern const struct ieee80211_ops mt76x2_ops;
4040
4141 int mt76x2_register_device(struct mt76x02_dev *dev);
42+int mt76x2_resume_device(struct mt76x02_dev *dev);
4243
4344 void mt76x2_phy_power_on(struct mt76x02_dev *dev);
4445 void mt76x2_stop_hardware(struct mt76x02_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2/pci.c+63−7
@@ -9,7 +9,7 @@ · 8 unmodified lines
99
1010 #include "mt76x2.h"
1111
12−static const struct pci_device_id mt76pci_device_table[] = {
12+static const struct pci_device_id mt76x2e_device_table[] = {
1313 { PCI_DEVICE(0x14c3, 0x7662) },
1414 { PCI_DEVICE(0x14c3, 0x7612) },
1515 { PCI_DEVICE(0x14c3, 0x7602) },
@@ -17,7 +17,7 @@ static const struct pci_device_id mt76pci_device_table[] = { · 1 unmodified line
1717 };
1818
1919 static int
20−mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
20+mt76x2e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2121 {
2222 static const struct mt76_driver_ops drv_ops = {
2323 .txwi_size = sizeof(struct mt76x02_txwi),
@@ -93,7 +93,7 @@ error: · 69 unmodified lines
9393 }
9494
9595 static void
96−mt76pci_remove(struct pci_dev *pdev)
96+mt76x2e_remove(struct pci_dev *pdev)
9797 {
9898 struct mt76_dev *mdev = pci_get_drvdata(pdev);
9999 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
@@ -103,16 +103,72 @@ mt76pci_remove(struct pci_dev *pdev) · 3 unmodified lines
103103 mt76_free_device(mdev);
104104 }
105105
106−MODULE_DEVICE_TABLE(pci, mt76pci_device_table);
106+static int __maybe_unused
107+mt76x2e_suspend(struct pci_dev *pdev, pm_message_t state)
108+{
109+ struct mt76_dev *mdev = pci_get_drvdata(pdev);
110+ int i, err;
111+
112+ napi_disable(&mdev->tx_napi);
113+ tasklet_kill(&mdev->pre_tbtt_tasklet);
114+ tasklet_kill(&mdev->tx_tasklet);
115+
116+ mt76_for_each_q_rx(mdev, i)
117+ napi_disable(&mdev->napi[i]);
118+
119+ pci_enable_wake(pdev, pci_choose_state(pdev, state), true);
120+ pci_save_state(pdev);
121+ err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
122+ if (err)
123+ goto restore;
124+
125+ return 0;
126+
127+restore:
128+ mt76_for_each_q_rx(mdev, i)
129+ napi_enable(&mdev->napi[i]);
130+ napi_enable(&mdev->tx_napi);
131+
132+ return err;
133+}
134+
135+static int __maybe_unused
136+mt76x2e_resume(struct pci_dev *pdev)
137+{
138+ struct mt76_dev *mdev = pci_get_drvdata(pdev);
139+ struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
140+ int i, err;
141+
142+ err = pci_set_power_state(pdev, PCI_D0);
143+ if (err)
144+ return err;
145+
146+ pci_restore_state(pdev);
147+
148+ mt76_for_each_q_rx(mdev, i) {
149+ napi_enable(&mdev->napi[i]);
150+ napi_schedule(&mdev->napi[i]);
151+ }
152+ napi_enable(&mdev->tx_napi);
153+ napi_schedule(&mdev->tx_napi);
154+
155+ return mt76x2_resume_device(dev);
156+}
157+
158+MODULE_DEVICE_TABLE(pci, mt76x2e_device_table);
107159 MODULE_FIRMWARE(MT7662_FIRMWARE);
108160 MODULE_FIRMWARE(MT7662_ROM_PATCH);
109161 MODULE_LICENSE("Dual BSD/GPL");
110162
111163 static struct pci_driver mt76pci_driver = {
112164 .name = KBUILD_MODNAME,
113− .id_table = mt76pci_device_table,
114− .probe = mt76pci_probe,
115− .remove = mt76pci_remove,
165+ .id_table = mt76x2e_device_table,
166+ .probe = mt76x2e_probe,
167+ .remove = mt76x2e_remove,
168+#ifdef CONFIG_PM
169+ .suspend = mt76x2e_suspend,
170+ .resume = mt76x2e_resume,
171+#endif /* CONFIG_PM */
116172 };
117173
118174 module_pci_driver(mt76pci_driver);
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c+17−0
@@ -217,6 +217,23 @@ mt76x2_power_on(struct mt76x02_dev *dev) · 216 unmodified lines
217217 mt76x2_power_on_rf(dev, 1);
218218 }
219219
220+int mt76x2_resume_device(struct mt76x02_dev *dev)
221+{
222+ int err;
223+
224+ mt76x02_dma_disable(dev);
225+ mt76x2_reset_wlan(dev, true);
226+ mt76x2_power_on(dev);
227+
228+ err = mt76x2_mac_reset(dev, true);
229+ if (err)
230+ return err;
231+
232+ mt76x02_mac_start(dev);
233+
234+ return mt76x2_mcu_init(dev);
235+}
236+
220237 static int mt76x2_init_hardware(struct mt76x02_dev *dev)
221238 {
222239 int ret;
drivers/net/wireless/mediatek/mt76/mt76x2/usb.c+3−5
@@ -16,6 +16,7 @@ static const struct usb_device_id mt76x2u_device_table[] = { · 15 unmodified lines
1616 { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USBAC1200 - Alfa AWUS036ACM */
1717 { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */
1818 { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */
19+ { USB_DEVICE(0x0e8d, 0x7632) }, /* HC-M7662BU1 */
1920 { USB_DEVICE(0x2c4e, 0x0103) }, /* Mercury UD13 */
2021 { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */
2122 { USB_DEVICE(0x045e, 0x02e6) }, /* XBox One Wireless Adapter */
@@ -74,8 +75,7 @@ static int mt76x2u_probe(struct usb_interface *intf, · 52 unmodified lines
7475 return 0;
7576
7677 err:
77− ieee80211_free_hw(mt76_hw(dev));
78− mt76u_deinit(&dev->mt76);
78+ mt76_free_device(&dev->mt76);
7979 usb_set_intfdata(intf, NULL);
8080 usb_put_dev(udev);
8181
@@ -91,9 +91,7 @@ static void mt76x2u_disconnect(struct usb_interface *intf) · 9 unmodified lines
9191 set_bit(MT76_REMOVED, &dev->mphy.state);
9292 ieee80211_unregister_hw(hw);
9393 mt76x2u_cleanup(dev);
94− mt76u_deinit(&dev->mt76);
95−
96− ieee80211_free_hw(hw);
94+ mt76_free_device(&dev->mt76);
9795 usb_set_intfdata(intf, NULL);
9896 usb_put_dev(udev);
9997 }
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c+10−1
@@ -178,7 +178,14 @@ mt7915_txbf_stat_read_phy(struct mt7915_phy *phy, struct seq_file *s) · 177 unmodified lines
178178 seq_printf(s, "Tx Beamformee feedback triggered counts: %ld\n",
179179 FIELD_GET(MT_ETBF_TX_FB_TRI, cnt));
180180
181− /* Tx SU counters */
181+ /* Tx SU & MU counters */
182+ cnt = mt76_rr(dev, MT_MIB_SDR34(ext_phy));
183+ seq_printf(s, "Tx multi-user Beamforming counts: %ld\n",
184+ FIELD_GET(MT_MIB_MU_BF_TX_CNT, cnt));
185+ cnt = mt76_rr(dev, MT_MIB_DR8(ext_phy));
186+ seq_printf(s, "Tx multi-user MPDU counts: %d\n", cnt);
187+ cnt = mt76_rr(dev, MT_MIB_DR9(ext_phy));
188+ seq_printf(s, "Tx multi-user successful MPDU counts: %d\n", cnt);
182189 cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy));
183190 seq_printf(s, "Tx single-user successful MPDU counts: %d\n", cnt);
184191
@@ -384,6 +391,7 @@ int mt7915_init_debugfs(struct mt7915_dev *dev) · 199 unmodified lines
384391 return 0;
385392 }
386393
394+#ifdef CONFIG_MAC80211_DEBUGFS
387395 /** per-station debugfs **/
388396
389397 /* usage: <tx mode> <ldpc> <stbc> <bw> <gi> <nss> <mcs> */
@@ -461,3 +469,4 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 71 unmodified lines
461469 debugfs_create_file("fixed_rate", 0600, dir, sta, &fops_fixed_rate);
462470 debugfs_create_file("stats", 0400, dir, sta, &fops_sta_stats);
463471 }
472+#endif
drivers/net/wireless/mediatek/mt76/mt7915/dma.c+11−10
@@ -79,26 +79,27 @@ void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, · 78 unmodified lines
7979 }
8080 }
8181
82+static void
83+mt7915_tx_cleanup(struct mt7915_dev *dev)
84+{
85+ mt76_queue_tx_cleanup(dev, MT_TXQ_MCU, false);
86+ mt76_queue_tx_cleanup(dev, MT_TXQ_MCU_WA, false);
87+ mt76_queue_tx_cleanup(dev, MT_TXQ_PSD, false);
88+ mt76_queue_tx_cleanup(dev, MT_TXQ_BE, false);
89+}
90+
8291 static int mt7915_poll_tx(struct napi_struct *napi, int budget)
8392 {
84− static const u8 queue_map[] = {
85− MT_TXQ_MCU,
86− MT_TXQ_MCU_WA,
87− MT_TXQ_BE
88− };
8993 struct mt7915_dev *dev;
90− int i;
9194
9295 dev = container_of(napi, struct mt7915_dev, mt76.tx_napi);
9396
94− for (i = 0; i < ARRAY_SIZE(queue_map); i++)
95− mt76_queue_tx_cleanup(dev, queue_map[i], false);
97+ mt7915_tx_cleanup(dev);
9698
9799 if (napi_complete_done(napi, 0))
98100 mt7915_irq_enable(dev, MT_INT_TX_DONE_ALL);
99101
100− for (i = 0; i < ARRAY_SIZE(queue_map); i++)
101− mt76_queue_tx_cleanup(dev, queue_map[i], false);
102+ mt7915_tx_cleanup(dev);
102103
103104 mt7915_mac_sta_poll(dev);
104105
drivers/net/wireless/mediatek/mt76/mt7915/init.c+26−18
@@ -417,11 +417,6 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band, · 416 unmodified lines
417417
418418 he_cap_elem->mac_cap_info[0] =
419419 IEEE80211_HE_MAC_CAP0_HTC_HE;
420− he_cap_elem->mac_cap_info[1] =
421− IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_0US |
422− IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_1;
423− he_cap_elem->mac_cap_info[2] =
424− IEEE80211_HE_MAC_CAP2_BSR;
425420 he_cap_elem->mac_cap_info[3] =
426421 IEEE80211_HE_MAC_CAP3_OMI_CONTROL |
427422 IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_RESERVED;
@@ -443,27 +438,27 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band, · 15 unmodified lines
443438 IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ |
444439 IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ;
445440
446− /* TODO: OFDMA */
447−
448441 switch (i) {
449442 case NL80211_IFTYPE_AP:
450443 he_cap_elem->mac_cap_info[0] |=
451444 IEEE80211_HE_MAC_CAP0_TWT_RES;
445+ he_cap_elem->mac_cap_info[2] |=
446+ IEEE80211_HE_MAC_CAP2_BSR;
452447 he_cap_elem->mac_cap_info[4] |=
453448 IEEE80211_HE_MAC_CAP4_BQR;
449+ he_cap_elem->mac_cap_info[5] |=
450+ IEEE80211_HE_MAC_CAP5_OM_CTRL_UL_MU_DATA_DIS_RX;
454451 he_cap_elem->phy_cap_info[3] |=
455452 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK |
456453 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK;
457454 he_cap_elem->phy_cap_info[6] |=
458455 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT;
459− he_cap_elem->phy_cap_info[9] |=
460− IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU;
461456 break;
462457 case NL80211_IFTYPE_STATION:
463458 he_cap_elem->mac_cap_info[0] |=
464459 IEEE80211_HE_MAC_CAP0_TWT_REQ;
465− he_cap_elem->mac_cap_info[3] |=
466− IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED;
460+ he_cap_elem->mac_cap_info[1] |=
461+ IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US;
467462
468463 if (band == NL80211_BAND_2GHZ)
469464 he_cap_elem->phy_cap_info[0] |=
@@ -473,18 +468,31 @@ mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band, · 3 unmodified lines
473468 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G;
474469
475470 he_cap_elem->phy_cap_info[1] |=
476− IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A;
471+ IEEE80211_HE_PHY_CAP1_DEVICE_CLASS_A |
472+ IEEE80211_HE_PHY_CAP1_HE_LTF_AND_GI_FOR_HE_PPDUS_0_8US;
473+ he_cap_elem->phy_cap_info[3] |=
474+ IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK |
475+ IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK;
476+ he_cap_elem->phy_cap_info[6] |=
477+ IEEE80211_HE_PHY_CAP6_TRIG_CQI_FB |
478+ IEEE80211_HE_PHY_CAP6_PARTIAL_BW_EXT_RANGE |
479+ IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT;
480+ he_cap_elem->phy_cap_info[7] |=
481+ IEEE80211_HE_PHY_CAP7_POWER_BOOST_FACTOR_AR |
482+ IEEE80211_HE_PHY_CAP7_HE_SU_MU_PPDU_4XLTF_AND_08_US_GI;
477483 he_cap_elem->phy_cap_info[8] |=
478484 IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G |
479485 IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU |
480− IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU;
486+ IEEE80211_HE_PHY_CAP8_80MHZ_IN_160MHZ_HE_PPDU |
487+ IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484;
481488 he_cap_elem->phy_cap_info[9] |=
482− IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU;
489+ IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM |
490+ IEEE80211_HE_PHY_CAP9_NON_TRIGGERED_CQI_FEEDBACK |
491+ IEEE80211_HE_PHY_CAP9_TX_1024_QAM_LESS_THAN_242_TONE_RU |
492+ IEEE80211_HE_PHY_CAP9_RX_1024_QAM_LESS_THAN_242_TONE_RU |
493+ IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_COMP_SIGB |
494+ IEEE80211_HE_PHY_CAP9_RX_FULL_BW_SU_USING_MU_WITH_NON_COMP_SIGB;
483495 break;
484−#ifdef CONFIG_MAC80211_MESH
485− case NL80211_IFTYPE_MESH_POINT:
486− break;
487−#endif
488496 }
489497
490498 he_mcs->rx_mcs_80 = cpu_to_le16(mcs_map);
drivers/net/wireless/mediatek/mt76/mt7915/mac.c+45−48
@@ -178,14 +178,14 @@ void mt7915_mac_sta_poll(struct mt7915_dev *dev) · 177 unmodified lines
178178
179179 static void
180180 mt7915_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
181− struct mt7915_rxv *rxv,
182− struct ieee80211_radiotap_he *he)
181+ struct ieee80211_radiotap_he *he,
182+ __le32 *rxv)
183183 {
184184 u32 ru_h, ru_l;
185185 u8 ru, offs = 0;
186186
187− ru_l = FIELD_GET(MT_PRXV_HE_RU_ALLOC_L, le32_to_cpu(rxv->v[0]));
188− ru_h = FIELD_GET(MT_PRXV_HE_RU_ALLOC_H, le32_to_cpu(rxv->v[1]));
187+ ru_l = FIELD_GET(MT_PRXV_HE_RU_ALLOC_L, le32_to_cpu(rxv[0]));
188+ ru_h = FIELD_GET(MT_PRXV_HE_RU_ALLOC_H, le32_to_cpu(rxv[1]));
189189 ru = (u8)(ru_l | ru_h << 4);
190190
191191 status->bw = RATE_INFO_BW_HE_RU;
@@ -228,7 +228,7 @@ mt7915_mac_decode_he_radiotap_ru(struct mt76_rx_status *status, · 36 unmodified lines
228228 static void
229229 mt7915_mac_decode_he_radiotap(struct sk_buff *skb,
230230 struct mt76_rx_status *status,
231− struct mt7915_rxv *rxv)
231+ __le32 *rxv, u32 phy)
232232 {
233233 /* TODO: struct ieee80211_radiotap_he_mu */
234234 static const struct ieee80211_radiotap_he known = {
@@ -245,48 +245,45 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, · 10 unmodified lines
245245 HE_BITS(DATA2_TXOP_KNOWN),
246246 };
247247 struct ieee80211_radiotap_he *he = NULL;
248− __le32 v2 = rxv->v[2];
249− __le32 v11 = rxv->v[11];
250− __le32 v14 = rxv->v[14];
251− u32 ltf_size = le32_get_bits(v2, MT_CRXV_HE_LTF_SIZE) + 1;
248+ u32 ltf_size = le32_get_bits(rxv[2], MT_CRXV_HE_LTF_SIZE) + 1;
252249
253250 he = skb_push(skb, sizeof(known));
254251 memcpy(he, &known, sizeof(known));
255252
256− he->data3 = HE_PREP(DATA3_BSS_COLOR, BSS_COLOR, v14) |
257− HE_PREP(DATA3_LDPC_XSYMSEG, LDPC_EXT_SYM, v2);
258− he->data5 = HE_PREP(DATA5_PE_DISAMBIG, PE_DISAMBIG, v2) |
253+ he->data3 = HE_PREP(DATA3_BSS_COLOR, BSS_COLOR, rxv[14]) |
254+ HE_PREP(DATA3_LDPC_XSYMSEG, LDPC_EXT_SYM, rxv[2]);
255+ he->data5 = HE_PREP(DATA5_PE_DISAMBIG, PE_DISAMBIG, rxv[2]) |
259256 le16_encode_bits(ltf_size,
260257 IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE);
261− he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, v14) |
262− HE_PREP(DATA6_DOPPLER, DOPPLER, v14);
258+ he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) |
259+ HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]);
263260
264− switch (rxv->phy) {
261+ switch (phy) {
265262 case MT_PHY_TYPE_HE_SU:
266263 he->data1 |= HE_BITS(DATA1_FORMAT_SU) |
267264 HE_BITS(DATA1_UL_DL_KNOWN) |
268265 HE_BITS(DATA1_BEAM_CHANGE_KNOWN) |
269266 HE_BITS(DATA1_SPTL_REUSE_KNOWN);
270267
271− he->data3 |= HE_PREP(DATA3_BEAM_CHANGE, BEAM_CHNG, v14) |
272− HE_PREP(DATA3_UL_DL, UPLINK, v2);
273− he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, v11);
268+ he->data3 |= HE_PREP(DATA3_BEAM_CHANGE, BEAM_CHNG, rxv[14]) |
269+ HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
270+ he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, rxv[11]);
274271 break;
275272 case MT_PHY_TYPE_HE_EXT_SU:
276273 he->data1 |= HE_BITS(DATA1_FORMAT_EXT_SU) |
277274 HE_BITS(DATA1_UL_DL_KNOWN);
278275
279− he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, v2);
276+ he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
280277 break;
281278 case MT_PHY_TYPE_HE_MU:
282279 he->data1 |= HE_BITS(DATA1_FORMAT_MU) |
283280 HE_BITS(DATA1_UL_DL_KNOWN) |
284281 HE_BITS(DATA1_SPTL_REUSE_KNOWN);
285282
286− he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, v2);
287− he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, v11);
283+ he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
284+ he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, rxv[11]);
288285
289− mt7915_mac_decode_he_radiotap_ru(status, rxv, he);
286+ mt7915_mac_decode_he_radiotap_ru(status, he, rxv);
290287 break;
291288 case MT_PHY_TYPE_HE_TB:
292289 he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) |
@@ -295,12 +292,12 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, · 2 unmodified lines
295292 HE_BITS(DATA1_SPTL_REUSE3_KNOWN) |
296293 HE_BITS(DATA1_SPTL_REUSE4_KNOWN);
297294
298− he->data4 |= HE_PREP(DATA4_TB_SPTL_REUSE1, SR_MASK, v11) |
299− HE_PREP(DATA4_TB_SPTL_REUSE2, SR1_MASK, v11) |
300− HE_PREP(DATA4_TB_SPTL_REUSE3, SR2_MASK, v11) |
301− HE_PREP(DATA4_TB_SPTL_REUSE4, SR3_MASK, v11);
295+ he->data4 |= HE_PREP(DATA4_TB_SPTL_REUSE1, SR_MASK, rxv[11]) |
296+ HE_PREP(DATA4_TB_SPTL_REUSE2, SR1_MASK, rxv[11]) |
297+ HE_PREP(DATA4_TB_SPTL_REUSE3, SR2_MASK, rxv[11]) |
298+ HE_PREP(DATA4_TB_SPTL_REUSE4, SR3_MASK, rxv[11]);
302299
303− mt7915_mac_decode_he_radiotap_ru(status, rxv, he);
300+ mt7915_mac_decode_he_radiotap_ru(status, he, rxv);
304301 break;
305302 default:
306303 break;
@@ -314,8 +311,9 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 7 unmodified lines
314311 struct mt7915_phy *phy = &dev->phy;
315312 struct ieee80211_supported_band *sband;
316313 struct ieee80211_hdr *hdr;
317− struct mt7915_rxv rxv = {};
318314 __le32 *rxd = (__le32 *)skb->data;
315+ __le32 *rxv = NULL;
316+ u32 mode = 0;
319317 u32 rxd1 = le32_to_cpu(rxd[1]);
320318 u32 rxd2 = le32_to_cpu(rxd[2]);
321319 u32 rxd3 = le32_to_cpu(rxd[3]);
@@ -427,15 +425,14 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 105 unmodified lines
427425 if (rxd1 & MT_RXD1_NORMAL_GROUP_3) {
428426 u32 v0, v1, v2;
429427
430− memcpy(rxv.v, rxd, sizeof(rxv.v));
431−
428+ rxv = rxd;
432429 rxd += 2;
433430 if ((u8 *)rxd - skb->data >= skb->len)
434431 return -EINVAL;
435432
436− v0 = le32_to_cpu(rxv.v[0]);
437− v1 = le32_to_cpu(rxv.v[1]);
438− v2 = le32_to_cpu(rxv.v[2]);
433+ v0 = le32_to_cpu(rxv[0]);
434+ v1 = le32_to_cpu(rxv[1]);
435+ v2 = le32_to_cpu(rxv[2]);
439436
440437 if (v0 & MT_PRXV_HT_AD_CODE)
441438 status->enc_flags |= RX_ENC_FLAG_LDPC;
@@ -466,9 +463,9 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 24 unmodified lines
466463 return -EINVAL;
467464
468465 idx = i = FIELD_GET(MT_PRXV_TX_RATE, v0);
469− rxv.phy = FIELD_GET(MT_CRXV_TX_MODE, v2);
466+ mode = FIELD_GET(MT_CRXV_TX_MODE, v2);
470467
471− switch (rxv.phy) {
468+ switch (mode) {
472469 case MT_PHY_TYPE_CCK:
473470 cck = true;
474471 /* fall through */
@@ -503,8 +500,7 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 28 unmodified lines
503500 if (gi <= NL80211_RATE_INFO_HE_GI_3_2)
504501 status->he_gi = gi;
505502
506− if (idx & MT_PRXV_TX_DCM)
507− status->he_dcm = true;
503+ status->he_dcm = !!(idx & MT_PRXV_TX_DCM);
508504 break;
509505 default:
510506 return -EINVAL;
@@ -515,7 +511,7 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 4 unmodified lines
515511 case IEEE80211_STA_RX_BW_20:
516512 break;
517513 case IEEE80211_STA_RX_BW_40:
518− if (rxv.phy & MT_PHY_TYPE_HE_EXT_SU &&
514+ if (mode & MT_PHY_TYPE_HE_EXT_SU &&
519515 (idx & MT_PRXV_TX_ER_SU_106T)) {
520516 status->bw = RATE_INFO_BW_HE_RU;
521517 status->he_ru =
@@ -535,7 +531,7 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 13 unmodified lines
535531 }
536532
537533 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc;
538− if (rxv.phy < MT_PHY_TYPE_HE_SU && gi)
534+ if (mode < MT_PHY_TYPE_HE_SU && gi)
539535 status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
540536 }
541537 }
@@ -548,8 +544,8 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 6 unmodified lines
548544 mt76_insert_ccmp_hdr(skb, key_id);
549545 }
550546
551− if (status->flag & RX_FLAG_RADIOTAP_HE)
552− mt7915_mac_decode_he_radiotap(skb, status, &rxv);
547+ if (rxv && status->flag & RX_FLAG_RADIOTAP_HE)
548+ mt7915_mac_decode_he_radiotap(skb, status, rxv, mode);
553549
554550 hdr = mt76_skb_get_hdr(skb);
555551 if (!status->wcid || !ieee80211_is_data_qos(hdr->frame_control))
@@ -591,16 +587,16 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, · 35 unmodified lines
591587 fc_type = (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) >> 2;
592588 fc_stype = (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) >> 4;
593589
594− if (ieee80211_is_data(fc) || ieee80211_is_bufferable_mmpdu(fc)) {
595− q_idx = wmm_idx * MT7915_MAX_WMM_SETS +
596− skb_get_queue_mapping(skb);
597− p_fmt = MT_TX_TYPE_CT;
598− } else if (beacon) {
599− q_idx = MT_LMAC_BCN0;
590+ if (beacon) {
600591 p_fmt = MT_TX_TYPE_FW;
601− } else {
592+ q_idx = MT_LMAC_BCN0;
593+ } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {
594+ p_fmt = MT_TX_TYPE_CT;
602595 q_idx = MT_LMAC_ALTX0;
596+ } else {
603597 p_fmt = MT_TX_TYPE_CT;
598+ q_idx = wmm_idx * MT7915_MAX_WMM_SETS +
599+ mt7915_lmac_mapping(dev, skb_get_queue_mapping(skb));
604600 }
605601
606602 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + MT_TXD_SIZE) |
@@ -616,6 +612,7 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, · 9 unmodified lines
616612 FIELD_PREP(MT_TXD1_TID,
617613 skb->priority & IEEE80211_QOS_CTL_TID_MASK) |
618614 FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
615+
619616 if (ext_phy && q_idx >= MT_LMAC_ALTX0 && q_idx <= MT_LMAC_BCN0)
620617 val |= MT_TXD1_TGID;
621618
drivers/net/wireless/mediatek/mt76/mt7915/mac.h+0−17
@@ -128,13 +128,6 @@ enum rx_pkt_type { · 127 unmodified lines
128128 #define MT_CRXV_HE_BEAM_CHNG BIT(13)
129129 #define MT_CRXV_HE_DOPPLER BIT(16)
130130
131−struct mt7915_rxv {
132− u32 phy;
133−
134− /* P-RXV: bit 0~1, C-RXV: bit 2~19 */
135− __le32 v[20];
136−};
137−
138131 enum tx_header_format {
139132 MT_HDR_FORMAT_802_3,
140133 MT_HDR_FORMAT_CMD,
@@ -149,16 +142,6 @@ enum tx_pkt_type { · 8 unmodified lines
149142 MT_TX_TYPE_FW,
150143 };
151144
152−enum tx_pkt_queue_idx {
153− MT_LMAC_AC00,
154− MT_LMAC_AC01,
155− MT_LMAC_AC02,
156− MT_LMAC_AC03,
157− MT_LMAC_ALTX0 = 0x10,
158− MT_LMAC_BMC0 = 0x10,
159− MT_LMAC_BCN0 = 0x12,
160−};
161−
162145 enum tx_port_idx {
163146 MT_TX_PORT_IDX_LMAC,
164147 MT_TX_PORT_IDX_MCU
drivers/net/wireless/mediatek/mt76/mt7915/main.c+6−7
@@ -125,7 +125,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, · 124 unmodified lines
125125
126126 mutex_lock(&dev->mt76.mutex);
127127
128− mvif->idx = ffs(~phy->vif_mask) - 1;
128+ mvif->idx = ffs(~phy->mt76->vif_mask) - 1;
129129 if (mvif->idx >= MT7915_MAX_INTERFACES) {
130130 ret = -ENOSPC;
131131 goto out;
@@ -150,7 +150,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, · 18 unmodified lines
150150 if (ret)
151151 goto out;
152152
153− phy->vif_mask |= BIT(mvif->idx);
153+ phy->mt76->vif_mask |= BIT(mvif->idx);
154154 phy->omac_mask |= BIT(mvif->omac_idx);
155155
156156 idx = MT7915_WTBL_RESERVED - mvif->idx;
@@ -194,7 +194,7 @@ static void mt7915_remove_interface(struct ieee80211_hw *hw, · 37 unmodified lines
194194 mt76_txq_remove(&dev->mt76, vif->txq);
195195
196196 mutex_lock(&dev->mt76.mutex);
197− phy->vif_mask &= ~BIT(mvif->idx);
197+ phy->mt76->vif_mask &= ~BIT(mvif->idx);
198198 phy->omac_mask &= ~BIT(mvif->omac_idx);
199199 mutex_unlock(&dev->mt76.mutex);
200200
@@ -350,13 +350,12 @@ static int · 149 unmodified lines
350350 mt7915_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
351351 const struct ieee80211_tx_queue_params *params)
352352 {
353+ struct mt7915_dev *dev = mt7915_hw_dev(hw);
353354 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
354355
355356 /* no need to update right away, we'll get BSS_CHANGED_QOS */
356− mvif->wmm[queue].cw_min = params->cw_min;
357− mvif->wmm[queue].cw_max = params->cw_max;
358− mvif->wmm[queue].aifs = params->aifs;
359− mvif->wmm[queue].txop = params->txop;
357+ queue = mt7915_lmac_mapping(dev, queue);
358+ mvif->queue_params[queue] = *params;
360359
361360 return 0;
362361 }
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c+96−21
@@ -312,8 +312,10 @@ mt7915_mcu_parse_response(struct mt7915_dev *dev, int cmd, · 311 unmodified lines
312312 struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data;
313313 int ret = 0;
314314
315− if (seq != rxd->seq)
316− return -EAGAIN;
315+ if (seq != rxd->seq) {
316+ ret = -EAGAIN;
317+ goto out;
318+ }
317319
318320 switch (cmd) {
319321 case -MCU_CMD_PATCH_SEM_CONTROL:
@@ -330,6 +332,7 @@ mt7915_mcu_parse_response(struct mt7915_dev *dev, int cmd, · 10 unmodified lines
330332 default:
331333 break;
332334 }
335+out:
333336 dev_kfree_skb(skb);
334337
335338 return ret;
@@ -505,15 +508,22 @@ static void · 169 unmodified lines
505508 mt7915_mcu_tx_rate_report(struct mt7915_dev *dev, struct sk_buff *skb)
506509 {
507510 struct mt7915_mcu_ra_info *ra = (struct mt7915_mcu_ra_info *)skb->data;
508− u16 wcidx = le16_to_cpu(ra->wlan_idx);
509− struct mt76_wcid *wcid = rcu_dereference(dev->mt76.wcid[wcidx]);
510− struct mt7915_sta *msta = container_of(wcid, struct mt7915_sta, wcid);
511− struct mt7915_sta_stats *stats = &msta->stats;
512− struct mt76_phy *mphy = &dev->mphy;
513511 struct rate_info rate = {}, prob_rate = {};
512+ u16 probe = le16_to_cpu(ra->prob_up_rate);
514513 u16 attempts = le16_to_cpu(ra->attempts);
515514 u16 curr = le16_to_cpu(ra->curr_rate);
516− u16 probe = le16_to_cpu(ra->prob_up_rate);
515+ u16 wcidx = le16_to_cpu(ra->wlan_idx);
516+ struct mt76_phy *mphy = &dev->mphy;
517+ struct mt7915_sta_stats *stats;
518+ struct mt7915_sta *msta;
519+ struct mt76_wcid *wcid;
520+
521+ if (wcidx >= MT76_N_WCIDS)
522+ return;
523+
524+ wcid = rcu_dereference(dev->mt76.wcid[wcidx]);
525+ msta = container_of(wcid, struct mt7915_sta, wcid);
526+ stats = &msta->stats;
517527
518528 if (msta->wcid.ext_phy && dev->mt76.phy2)
519529 mphy = dev->mt76.phy2;
@@ -1166,19 +1176,31 @@ mt7915_mcu_sta_ba(struct mt7915_dev *dev, · 646 unmodified lines
11661176 struct wtbl_req_hdr *wtbl_hdr;
11671177 struct tlv *sta_wtbl;
11681178 struct sk_buff *skb;
1179+ int ret;
11691180
11701181 skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta,
11711182 MT7915_STA_UPDATE_MAX_SIZE);
11721183 if (IS_ERR(skb))
11731184 return PTR_ERR(skb);
11741185
1175− mt7915_mcu_sta_ba_tlv(skb, params, enable, tx);
11761186 sta_wtbl = mt7915_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv));
11771187
11781188 wtbl_hdr = mt7915_mcu_alloc_wtbl_req(dev, msta, WTBL_SET, sta_wtbl,
11791189 &skb);
11801190 mt7915_mcu_wtbl_ba_tlv(skb, params, enable, tx, sta_wtbl, wtbl_hdr);
11811191
1192+ ret = __mt76_mcu_skb_send_msg(&dev->mt76, skb,
1193+ MCU_EXT_CMD_STA_REC_UPDATE, true);
1194+ if (ret)
1195+ return ret;
1196+
1197+ skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta,
1198+ MT7915_STA_UPDATE_MAX_SIZE);
1199+ if (IS_ERR(skb))
1200+ return PTR_ERR(skb);
1201+
1202+ mt7915_mcu_sta_ba_tlv(skb, params, enable, tx);
1203+
11821204 return __mt76_mcu_skb_send_msg(&dev->mt76, skb,
11831205 MCU_EXT_CMD_STA_REC_UPDATE, true);
11841206 }
@@ -1466,16 +1488,39 @@ mt7915_mcu_sta_muru_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) · 281 unmodified lines
14661488 HE_PHY(CAP2_UL_MU_PARTIAL_MU_MIMO, elem->phy_cap_info[2]);
14671489 }
14681490
1491+static int
1492+mt7915_mcu_add_mu(struct mt7915_dev *dev, struct ieee80211_vif *vif,
1493+ struct ieee80211_sta *sta)
1494+{
1495+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
1496+ struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
1497+ struct sk_buff *skb;
1498+ int len = sizeof(struct sta_req_hdr) + sizeof(struct sta_rec_muru);
1499+
1500+ if (!sta->vht_cap.vht_supported && !sta->he_cap.has_he)
1501+ return 0;
1502+
1503+ skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, len);
1504+ if (IS_ERR(skb))
1505+ return PTR_ERR(skb);
1506+
1507+ /* starec muru */
1508+ mt7915_mcu_sta_muru_tlv(skb, sta);
1509+
1510+ return __mt76_mcu_skb_send_msg(&dev->mt76, skb,
1511+ MCU_EXT_CMD_STA_REC_UPDATE, true);
1512+}
1513+
14691514 static void
14701515 mt7915_mcu_sta_tlv(struct mt7915_dev *dev, struct sk_buff *skb,
14711516 struct ieee80211_sta *sta)
14721517 {
14731518 struct tlv *tlv;
14741519
1520+ /* starec ht */
14751521 if (sta->ht_cap.ht_supported) {
14761522 struct sta_rec_ht *ht;
14771523
1478− /* starec ht */
14791524 tlv = mt7915_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));
14801525 ht = (struct sta_rec_ht *)tlv;
14811526 ht->ht_cap = cpu_to_le16(sta->ht_cap.cap);
@@ -1495,10 +1540,6 @@ mt7915_mcu_sta_tlv(struct mt7915_dev *dev, struct sk_buff *skb, · 13 unmodified lines
14951540 /* starec he */
14961541 if (sta->he_cap.has_he)
14971542 mt7915_mcu_sta_he_tlv(skb, sta);
1498−
1499− /* starec muru */
1500− if (sta->he_cap.has_he || sta->vht_cap.vht_supported)
1501− mt7915_mcu_sta_muru_tlv(skb, sta);
15021543 }
15031544
15041545 static void
@@ -2064,6 +2105,32 @@ int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif, · 559 unmodified lines
20642105 MCU_EXT_CMD_STA_REC_UPDATE, true);
20652106 }
20662107
2108+static int
2109+mt7915_mcu_add_group(struct mt7915_dev *dev, struct ieee80211_vif *vif,
2110+ struct ieee80211_sta *sta)
2111+{
2112+#define MT_STA_BSS_GROUP 1
2113+ struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
2114+ struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
2115+ struct {
2116+ __le32 action;
2117+ u8 wlan_idx_lo;
2118+ u8 status;
2119+ u8 wlan_idx_hi;
2120+ u8 rsv0[5];
2121+ __le32 val;
2122+ u8 rsv1[8];
2123+ } __packed req = {
2124+ .action = cpu_to_le32(MT_STA_BSS_GROUP),
2125+ .wlan_idx_lo = to_wcid_lo(msta->wcid.idx),
2126+ .wlan_idx_hi = to_wcid_hi(msta->wcid.idx),
2127+ .val = cpu_to_le32(mvif->idx),
2128+ };
2129+
2130+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_SET_DRR_CTRL,
2131+ &req, sizeof(req), true);
2132+}
2133+
20672134 int mt7915_mcu_add_sta_adv(struct mt7915_dev *dev, struct ieee80211_vif *vif,
20682135 struct ieee80211_sta *sta, bool enable)
20692136 {
@@ -2073,10 +2140,18 @@ int mt7915_mcu_add_sta_adv(struct mt7915_dev *dev, struct ieee80211_vif *vif, · 3 unmodified lines
20732140 return 0;
20742141
20752142 /* must keep the order */
2143+ ret = mt7915_mcu_add_group(dev, vif, sta);
2144+ if (ret)
2145+ return ret;
2146+
20762147 ret = mt7915_mcu_add_txbf(dev, vif, sta, enable);
20772148 if (ret)
20782149 return ret;
20792150
2151+ ret = mt7915_mcu_add_mu(dev, vif, sta);
2152+ if (ret)
2153+ return ret;
2154+
20802155 if (enable)
20812156 return mt7915_mcu_add_rate_ctrl(dev, vif, sta);
20822157
@@ -2823,23 +2898,23 @@ int mt7915_mcu_set_tx(struct mt7915_dev *dev, struct ieee80211_vif *vif) · 740 unmodified lines
28232898 int ac;
28242899
28252900 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
2901+ struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac];
28262902 struct edca *e = &req.edca[ac];
28272903
28282904 e->queue = ac + mvif->wmm_idx * MT7915_MAX_WMM_SETS;
2829− e->aifs = mvif->wmm[ac].aifs;
2830− e->txop = cpu_to_le16(mvif->wmm[ac].txop);
2905+ e->aifs = q->aifs;
2906+ e->txop = cpu_to_le16(q->txop);
28312907
2832− if (mvif->wmm[ac].cw_min)
2833− e->cw_min = fls(mvif->wmm[ac].cw_max);
2908+ if (q->cw_min)
2909+ e->cw_min = fls(q->cw_min);
28342910 else
28352911 e->cw_min = 5;
28362912
2837− if (mvif->wmm[ac].cw_max)
2838− e->cw_max = cpu_to_le16(fls(mvif->wmm[ac].cw_max));
2913+ if (q->cw_max)
2914+ e->cw_max = cpu_to_le16(fls(q->cw_max));
28392915 else
28402916 e->cw_max = cpu_to_le16(10);
28412917 }
2842−
28432918 return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
28442919 &req, sizeof(req), true);
28452920 }
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h+3−3
@@ -201,6 +201,7 @@ enum { · 200 unmodified lines
201201 MCU_EXT_CMD_EDCA_UPDATE = 0x27,
202202 MCU_EXT_CMD_DEV_INFO_UPDATE = 0x2A,
203203 MCU_EXT_CMD_THERMAL_CTRL = 0x2c,
204+ MCU_EXT_CMD_SET_DRR_CTRL = 0x36,
204205 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
205206 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
206207 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
@@ -653,7 +654,7 @@ struct sta_rec_muru { · 446 unmodified lines
653654 bool ofdma_ul_en;
654655 bool mimo_dl_en;
655656 bool mimo_ul_en;
656− bool rsv[4];
657+ u8 rsv[4];
657658 } cfg;
658659
659660 struct {
@@ -664,7 +665,7 @@ struct sta_rec_muru { · 4 unmodified lines
664665 bool lt16_sigb;
665666 bool rx_su_comp_sigb;
666667 bool rx_su_non_comp_sigb;
667− bool rsv;
668+ u8 rsv;
668669 } ofdma_dl;
669670
670671 struct {
@@ -951,7 +952,6 @@ enum { · 280 unmodified lines
951952 sizeof(struct sta_rec_ba) + \
952953 sizeof(struct sta_rec_vht) + \
953954 sizeof(struct tlv) + \
954− sizeof(struct sta_rec_muru) + \
955955 MT7915_WTBL_UPDATE_MAX_SIZE)
956956
957957 #define MT7915_WTBL_UPDATE_BA_SIZE (sizeof(struct wtbl_req_hdr) + \
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h+27−8
@@ -99,15 +99,10 @@ struct mt7915_vif { · 98 unmodified lines
9999 u8 band_idx;
100100 u8 wmm_idx;
101101
102− struct {
103− u16 cw_min;
104− u16 cw_max;
105− u16 txop;
106− u8 aifs;
107− } wmm[IEEE80211_NUM_ACS];
108−
109102 struct mt7915_sta sta;
110103 struct mt7915_dev *dev;
104+
105+ struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
111106 };
112107
113108 struct mib_stats {
@@ -125,7 +120,6 @@ struct mt7915_phy { · 11 unmodified lines
125120 struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES];
126121
127122 u32 rxfilter;
128− u32 vif_mask;
129123 u32 omac_mask;
130124
131125 u16 noise;
@@ -199,6 +193,16 @@ enum { · 67 unmodified lines
199193 EXT_BSSID_END
200194 };
201195
196+enum {
197+ MT_LMAC_AC00,
198+ MT_LMAC_AC01,
199+ MT_LMAC_AC02,
200+ MT_LMAC_AC03,
201+ MT_LMAC_ALTX0 = 0x10,
202+ MT_LMAC_BMC0,
203+ MT_LMAC_BCN0,
204+};
205+
202206 enum {
203207 MT_RX_SEL0,
204208 MT_RX_SEL1,
@@ -254,6 +258,21 @@ mt7915_ext_phy(struct mt7915_dev *dev) · 49 unmodified lines
254258 return phy->priv;
255259 }
256260
261+static inline u8 mt7915_lmac_mapping(struct mt7915_dev *dev, u8 ac)
262+{
263+ static const u8 lmac_queue_map[] = {
264+ [IEEE80211_AC_BK] = MT_LMAC_AC00,
265+ [IEEE80211_AC_BE] = MT_LMAC_AC01,
266+ [IEEE80211_AC_VI] = MT_LMAC_AC02,
267+ [IEEE80211_AC_VO] = MT_LMAC_AC03,
268+ };
269+
270+ if (WARN_ON_ONCE(ac >= ARRAY_SIZE(lmac_queue_map)))
271+ return MT_LMAC_AC01; /* BE */
272+
273+ return lmac_queue_map[ac];
274+}
275+
257276 static inline void
258277 mt7915_set_aggr_state(struct mt7915_sta *msta, u8 tid,
259278 enum mt7915_ampdu_state state)
drivers/net/wireless/mediatek/mt76/mt7915/pci.c+1−1
@@ -103,7 +103,7 @@ static int mt7915_pci_probe(struct pci_dev *pdev, · 102 unmodified lines
103103 static const struct mt76_driver_ops drv_ops = {
104104 /* txwi_size = txd size + txp size */
105105 .txwi_size = MT_TXD_SIZE + sizeof(struct mt7915_txp),
106− .drv_flags = MT_DRV_TXWI_NO_FREE,
106+ .drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ,
107107 .survey_flags = SURVEY_INFO_TIME_TX |
108108 SURVEY_INFO_TIME_RX |
109109 SURVEY_INFO_TIME_BSS_RX,
drivers/net/wireless/mediatek/mt76/mt7915/regs.h+5−0
@@ -117,11 +117,16 @@ · 116 unmodified lines
117117 #define MT_MIB_SDR16(_band) MT_WF_MIB(_band, 0x048)
118118 #define MT_MIB_SDR16_BUSY_MASK GENMASK(23, 0)
119119
120+#define MT_MIB_SDR34(_band) MT_WF_MIB(_band, 0x090)
121+#define MT_MIB_MU_BF_TX_CNT GENMASK(15, 0)
122+
120123 #define MT_MIB_SDR36(_band) MT_WF_MIB(_band, 0x098)
121124 #define MT_MIB_SDR36_TXTIME_MASK GENMASK(23, 0)
122125 #define MT_MIB_SDR37(_band) MT_WF_MIB(_band, 0x09c)
123126 #define MT_MIB_SDR37_RXTIME_MASK GENMASK(23, 0)
124127
128+#define MT_MIB_DR8(_band) MT_WF_MIB(_band, 0x0c0)
129+#define MT_MIB_DR9(_band) MT_WF_MIB(_band, 0x0c4)
125130 #define MT_MIB_DR11(_band) MT_WF_MIB(_band, 0x0cc)
126131
127132 #define MT_MIB_MB_SDR0(_band, n) MT_WF_MIB(_band, 0x100 + ((n) << 4))
drivers/net/wireless/mediatek/mt76/pci.c+1−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 * Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org>
44 */
55
6+#include "mt76.h"
67 #include <linux/pci.h>
78
89 void mt76_pci_disable_aspm(struct pci_dev *pdev)
drivers/net/wireless/mediatek/mt76/sdio.c+368−0
@@ -0,0 +1,368 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 MediaTek Inc.
3+ *
4+ * This file is written based on mt76/usb.c.
5+ *
6+ * Author: Felix Fietkau <nbd@nbd.name>
7+ * Lorenzo Bianconi <lorenzo@kernel.org>
8+ * Sean Wang <sean.wang@mediatek.com>
9+ */
10+
11+#include <linux/iopoll.h>
12+#include <linux/kernel.h>
13+#include <linux/module.h>
14+#include <linux/mmc/sdio_func.h>
15+#include <linux/sched.h>
16+#include <linux/kthread.h>
17+
18+#include "mt76.h"
19+
20+static int
21+mt76s_alloc_rx_queue(struct mt76_dev *dev, enum mt76_rxq_id qid)
22+{
23+ struct mt76_queue *q = &dev->q_rx[qid];
24+
25+ spin_lock_init(&q->lock);
26+ q->entry = devm_kcalloc(dev->dev,
27+ MT_NUM_RX_ENTRIES, sizeof(*q->entry),
28+ GFP_KERNEL);
29+ if (!q->entry)
30+ return -ENOMEM;
31+
32+ q->ndesc = MT_NUM_RX_ENTRIES;
33+ q->head = q->tail = 0;
34+ q->queued = 0;
35+
36+ return 0;
37+}
38+
39+static int mt76s_alloc_tx(struct mt76_dev *dev)
40+{
41+ struct mt76_queue *q;
42+ int i;
43+
44+ for (i = 0; i < MT_TXQ_MCU_WA; i++) {
45+ INIT_LIST_HEAD(&dev->q_tx[i].swq);
46+
47+ q = devm_kzalloc(dev->dev, sizeof(*q), GFP_KERNEL);
48+ if (!q)
49+ return -ENOMEM;
50+
51+ spin_lock_init(&q->lock);
52+ q->hw_idx = i;
53+ dev->q_tx[i].q = q;
54+
55+ q->entry = devm_kcalloc(dev->dev,
56+ MT_NUM_TX_ENTRIES, sizeof(*q->entry),
57+ GFP_KERNEL);
58+ if (!q->entry)
59+ return -ENOMEM;
60+
61+ q->ndesc = MT_NUM_TX_ENTRIES;
62+ }
63+
64+ return 0;
65+}
66+
67+void mt76s_stop_txrx(struct mt76_dev *dev)
68+{
69+ struct mt76_sdio *sdio = &dev->sdio;
70+
71+ cancel_work_sync(&sdio->stat_work);
72+ clear_bit(MT76_READING_STATS, &dev->phy.state);
73+
74+ mt76_tx_status_check(dev, NULL, true);
75+}
76+EXPORT_SYMBOL_GPL(mt76s_stop_txrx);
77+
78+int mt76s_alloc_queues(struct mt76_dev *dev)
79+{
80+ int err;
81+
82+ err = mt76s_alloc_rx_queue(dev, MT_RXQ_MAIN);
83+ if (err < 0)
84+ return err;
85+
86+ return mt76s_alloc_tx(dev);
87+}
88+EXPORT_SYMBOL_GPL(mt76s_alloc_queues);
89+
90+static struct mt76_queue_entry *
91+mt76s_get_next_rx_entry(struct mt76_queue *q)
92+{
93+ struct mt76_queue_entry *e = NULL;
94+
95+ spin_lock_bh(&q->lock);
96+ if (q->queued > 0) {
97+ e = &q->entry[q->head];
98+ q->head = (q->head + 1) % q->ndesc;
99+ q->queued--;
100+ }
101+ spin_unlock_bh(&q->lock);
102+
103+ return e;
104+}
105+
106+static int
107+mt76s_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q)
108+{
109+ int qid = q - &dev->q_rx[MT_RXQ_MAIN];
110+ int nframes = 0;
111+
112+ while (true) {
113+ struct mt76_queue_entry *e;
114+
115+ if (!test_bit(MT76_STATE_INITIALIZED, &dev->phy.state))
116+ break;
117+
118+ e = mt76s_get_next_rx_entry(q);
119+ if (!e || !e->skb)
120+ break;
121+
122+ dev->drv->rx_skb(dev, MT_RXQ_MAIN, e->skb);
123+ e->skb = NULL;
124+ nframes++;
125+ }
126+ if (qid == MT_RXQ_MAIN)
127+ mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL);
128+
129+ return nframes;
130+}
131+
132+static int mt76s_process_tx_queue(struct mt76_dev *dev, enum mt76_txq_id qid)
133+{
134+ struct mt76_sw_queue *sq = &dev->q_tx[qid];
135+ u32 n_dequeued = 0, n_sw_dequeued = 0;
136+ struct mt76_queue_entry entry;
137+ struct mt76_queue *q = sq->q;
138+ bool wake;
139+
140+ while (q->queued > n_dequeued) {
141+ if (!q->entry[q->head].done)
142+ break;
143+
144+ if (q->entry[q->head].schedule) {
145+ q->entry[q->head].schedule = false;
146+ n_sw_dequeued++;
147+ }
148+
149+ entry = q->entry[q->head];
150+ q->entry[q->head].done = false;
151+ q->head = (q->head + 1) % q->ndesc;
152+ n_dequeued++;
153+
154+ if (qid == MT_TXQ_MCU)
155+ dev_kfree_skb(entry.skb);
156+ else
157+ dev->drv->tx_complete_skb(dev, qid, &entry);
158+ }
159+
160+ spin_lock_bh(&q->lock);
161+
162+ sq->swq_queued -= n_sw_dequeued;
163+ q->queued -= n_dequeued;
164+
165+ wake = q->stopped && q->queued < q->ndesc - 8;
166+ if (wake)
167+ q->stopped = false;
168+
169+ if (!q->queued)
170+ wake_up(&dev->tx_wait);
171+
172+ spin_unlock_bh(&q->lock);
173+
174+ if (qid == MT_TXQ_MCU)
175+ goto out;
176+
177+ mt76_txq_schedule(&dev->phy, qid);
178+
179+ if (wake)
180+ ieee80211_wake_queue(dev->hw, qid);
181+
182+ wake_up_process(dev->sdio.tx_kthread);
183+out:
184+ return n_dequeued;
185+}
186+
187+static void mt76s_tx_status_data(struct work_struct *work)
188+{
189+ struct mt76_sdio *sdio;
190+ struct mt76_dev *dev;
191+ u8 update = 1;
192+ u16 count = 0;
193+
194+ sdio = container_of(work, struct mt76_sdio, stat_work);
195+ dev = container_of(sdio, struct mt76_dev, sdio);
196+
197+ while (true) {
198+ if (test_bit(MT76_REMOVED, &dev->phy.state))
199+ break;
200+
201+ if (!dev->drv->tx_status_data(dev, &update))
202+ break;
203+ count++;
204+ }
205+
206+ if (count && test_bit(MT76_STATE_RUNNING, &dev->phy.state))
207+ queue_work(dev->wq, &sdio->stat_work);
208+ else
209+ clear_bit(MT76_READING_STATS, &dev->phy.state);
210+}
211+
212+static int
213+mt76s_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
214+ struct sk_buff *skb, struct mt76_wcid *wcid,
215+ struct ieee80211_sta *sta)
216+{
217+ struct mt76_queue *q = dev->q_tx[qid].q;
218+ struct mt76_tx_info tx_info = {
219+ .skb = skb,
220+ };
221+ int err, len = skb->len;
222+ u16 idx = q->tail;
223+
224+ if (q->queued == q->ndesc)
225+ return -ENOSPC;
226+
227+ skb->prev = skb->next = NULL;
228+ err = dev->drv->tx_prepare_skb(dev, NULL, qid, wcid, sta, &tx_info);
229+ if (err < 0)
230+ return err;
231+
232+ q->entry[q->tail].skb = tx_info.skb;
233+ q->entry[q->tail].buf_sz = len;
234+ q->tail = (q->tail + 1) % q->ndesc;
235+ q->queued++;
236+
237+ return idx;
238+}
239+
240+static int
241+mt76s_tx_queue_skb_raw(struct mt76_dev *dev, enum mt76_txq_id qid,
242+ struct sk_buff *skb, u32 tx_info)
243+{
244+ struct mt76_queue *q = dev->q_tx[qid].q;
245+ int ret = -ENOSPC, len = skb->len;
246+
247+ spin_lock_bh(&q->lock);
248+ if (q->queued == q->ndesc)
249+ goto out;
250+
251+ ret = mt76_skb_adjust_pad(skb);
252+ if (ret)
253+ goto out;
254+
255+ q->entry[q->tail].buf_sz = len;
256+ q->entry[q->tail].skb = skb;
257+ q->tail = (q->tail + 1) % q->ndesc;
258+ q->queued++;
259+
260+out:
261+ spin_unlock_bh(&q->lock);
262+
263+ return ret;
264+}
265+
266+static void mt76s_tx_kick(struct mt76_dev *dev, struct mt76_queue *q)
267+{
268+ struct mt76_sdio *sdio = &dev->sdio;
269+
270+ wake_up_process(sdio->tx_kthread);
271+}
272+
273+static const struct mt76_queue_ops sdio_queue_ops = {
274+ .tx_queue_skb = mt76s_tx_queue_skb,
275+ .kick = mt76s_tx_kick,
276+ .tx_queue_skb_raw = mt76s_tx_queue_skb_raw,
277+};
278+
279+static int mt76s_kthread_run(void *data)
280+{
281+ struct mt76_dev *dev = data;
282+ struct mt76_phy *mphy = &dev->phy;
283+
284+ while (!kthread_should_stop()) {
285+ int i, nframes = 0;
286+
287+ cond_resched();
288+
289+ /* rx processing */
290+ local_bh_disable();
291+ rcu_read_lock();
292+
293+ mt76_for_each_q_rx(dev, i)
294+ nframes += mt76s_process_rx_queue(dev, &dev->q_rx[i]);
295+
296+ rcu_read_unlock();
297+ local_bh_enable();
298+
299+ /* tx processing */
300+ for (i = 0; i < MT_TXQ_MCU_WA; i++)
301+ nframes += mt76s_process_tx_queue(dev, i);
302+
303+ if (dev->drv->tx_status_data &&
304+ !test_and_set_bit(MT76_READING_STATS, &mphy->state))
305+ queue_work(dev->wq, &dev->sdio.stat_work);
306+
307+ if (!nframes || !test_bit(MT76_STATE_RUNNING, &mphy->state)) {
308+ set_current_state(TASK_INTERRUPTIBLE);
309+ schedule();
310+ }
311+ }
312+
313+ return 0;
314+}
315+
316+void mt76s_deinit(struct mt76_dev *dev)
317+{
318+ struct mt76_sdio *sdio = &dev->sdio;
319+ int i;
320+
321+ kthread_stop(sdio->kthread);
322+ kthread_stop(sdio->tx_kthread);
323+ mt76s_stop_txrx(dev);
324+
325+ sdio_claim_host(sdio->func);
326+ sdio_release_irq(sdio->func);
327+ sdio_release_host(sdio->func);
328+
329+ mt76_for_each_q_rx(dev, i) {
330+ struct mt76_queue *q = &dev->q_rx[i];
331+ int j;
332+
333+ for (j = 0; j < q->ndesc; j++) {
334+ struct mt76_queue_entry *e = &q->entry[j];
335+
336+ if (!e->skb)
337+ continue;
338+
339+ dev_kfree_skb(e->skb);
340+ e->skb = NULL;
341+ }
342+ }
343+}
344+EXPORT_SYMBOL_GPL(mt76s_deinit);
345+
346+int mt76s_init(struct mt76_dev *dev, struct sdio_func *func,
347+ const struct mt76_bus_ops *bus_ops)
348+{
349+ struct mt76_sdio *sdio = &dev->sdio;
350+
351+ sdio->kthread = kthread_create(mt76s_kthread_run, dev, "mt76s");
352+ if (IS_ERR(sdio->kthread))
353+ return PTR_ERR(sdio->kthread);
354+
355+ INIT_WORK(&sdio->stat_work, mt76s_tx_status_data);
356+
357+ mutex_init(&sdio->sched.lock);
358+ dev->queue_ops = &sdio_queue_ops;
359+ dev->bus = bus_ops;
360+ dev->sdio.func = func;
361+
362+ return 0;
363+}
364+EXPORT_SYMBOL_GPL(mt76s_init);
365+
366+MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
367+MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
368+MODULE_LICENSE("Dual BSD/GPL");
drivers/net/wireless/mediatek/mt76/testmode.c+497−0
@@ -0,0 +1,497 @@
1+// SPDX-License-Identifier: ISC
2+/* Copyright (C) 2020 Felix Fietkau <nbd@nbd.name> */
3+#include "mt76.h"
4+
5+static const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = {
6+ [MT76_TM_ATTR_RESET] = { .type = NLA_FLAG },
7+ [MT76_TM_ATTR_STATE] = { .type = NLA_U8 },
8+ [MT76_TM_ATTR_TX_COUNT] = { .type = NLA_U32 },
9+ [MT76_TM_ATTR_TX_RATE_MODE] = { .type = NLA_U8 },
10+ [MT76_TM_ATTR_TX_RATE_NSS] = { .type = NLA_U8 },
11+ [MT76_TM_ATTR_TX_RATE_IDX] = { .type = NLA_U8 },
12+ [MT76_TM_ATTR_TX_RATE_SGI] = { .type = NLA_U8 },
13+ [MT76_TM_ATTR_TX_RATE_LDPC] = { .type = NLA_U8 },
14+ [MT76_TM_ATTR_TX_ANTENNA] = { .type = NLA_U8 },
15+ [MT76_TM_ATTR_TX_POWER_CONTROL] = { .type = NLA_U8 },
16+ [MT76_TM_ATTR_TX_POWER] = { .type = NLA_NESTED },
17+ [MT76_TM_ATTR_FREQ_OFFSET] = { .type = NLA_U32 },
18+};
19+
20+void mt76_testmode_tx_pending(struct mt76_dev *dev)
21+{
22+ struct mt76_testmode_data *td = &dev->test;
23+ struct mt76_wcid *wcid = &dev->global_wcid;
24+ struct sk_buff *skb = td->tx_skb;
25+ struct mt76_queue *q;
26+ int qid;
27+
28+ if (!skb || !td->tx_pending)
29+ return;
30+
31+ qid = skb_get_queue_mapping(skb);
32+ q = dev->q_tx[qid].q;
33+
34+ spin_lock_bh(&q->lock);
35+
36+ while (td->tx_pending > 0 && q->queued < q->ndesc / 2) {
37+ int ret;
38+
39+ ret = dev->queue_ops->tx_queue_skb(dev, qid, skb_get(skb), wcid, NULL);
40+ if (ret < 0)
41+ break;
42+
43+ td->tx_pending--;
44+ td->tx_queued++;
45+ }
46+
47+ dev->queue_ops->kick(dev, q);
48+
49+ spin_unlock_bh(&q->lock);
50+}
51+
52+
53+static int
54+mt76_testmode_tx_init(struct mt76_dev *dev)
55+{
56+ struct mt76_testmode_data *td = &dev->test;
57+ struct ieee80211_tx_info *info;
58+ struct ieee80211_hdr *hdr;
59+ struct sk_buff *skb;
60+ u16 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
61+ IEEE80211_FCTL_FROMDS;
62+ struct ieee80211_tx_rate *rate;
63+ u8 max_nss = hweight8(dev->phy.antenna_mask);
64+
65+ if (td->tx_antenna_mask)
66+ max_nss = min_t(u8, max_nss, hweight8(td->tx_antenna_mask));
67+
68+ skb = alloc_skb(td->tx_msdu_len, GFP_KERNEL);
69+ if (!skb)
70+ return -ENOMEM;
71+
72+ dev_kfree_skb(td->tx_skb);
73+ td->tx_skb = skb;
74+ hdr = __skb_put_zero(skb, td->tx_msdu_len);
75+ hdr->frame_control = cpu_to_le16(fc);
76+ memcpy(hdr->addr1, dev->macaddr, sizeof(dev->macaddr));
77+ memcpy(hdr->addr2, dev->macaddr, sizeof(dev->macaddr));
78+ memcpy(hdr->addr3, dev->macaddr, sizeof(dev->macaddr));
79+
80+ info = IEEE80211_SKB_CB(skb);
81+ info->flags = IEEE80211_TX_CTL_INJECTED |
82+ IEEE80211_TX_CTL_NO_ACK |
83+ IEEE80211_TX_CTL_NO_PS_BUFFER;
84+ rate = &info->control.rates[0];
85+ rate->count = 1;
86+ rate->idx = td->tx_rate_idx;
87+
88+ switch (td->tx_rate_mode) {
89+ case MT76_TM_TX_MODE_CCK:
90+ if (dev->phy.chandef.chan->band != NL80211_BAND_2GHZ)
91+ return -EINVAL;
92+
93+ if (rate->idx > 4)
94+ return -EINVAL;
95+ break;
96+ case MT76_TM_TX_MODE_OFDM:
97+ if (dev->phy.chandef.chan->band != NL80211_BAND_2GHZ)
98+ break;
99+
100+ if (rate->idx > 8)
101+ return -EINVAL;
102+
103+ rate->idx += 4;
104+ break;
105+ case MT76_TM_TX_MODE_HT:
106+ if (rate->idx > 8 * max_nss &&
107+ !(rate->idx == 32 &&
108+ dev->phy.chandef.width >= NL80211_CHAN_WIDTH_40))
109+ return -EINVAL;
110+
111+ rate->flags |= IEEE80211_TX_RC_MCS;
112+ break;
113+ case MT76_TM_TX_MODE_VHT:
114+ if (rate->idx > 9)
115+ return -EINVAL;
116+
117+ if (td->tx_rate_nss > max_nss)
118+ return -EINVAL;
119+
120+ ieee80211_rate_set_vht(rate, td->tx_rate_idx, td->tx_rate_nss);
121+ rate->flags |= IEEE80211_TX_RC_VHT_MCS;
122+ break;
123+ default:
124+ break;
125+ }
126+
127+ if (td->tx_rate_sgi)
128+ rate->flags |= IEEE80211_TX_RC_SHORT_GI;
129+
130+ if (td->tx_rate_ldpc)
131+ info->flags |= IEEE80211_TX_CTL_LDPC;
132+
133+ if (td->tx_rate_mode >= MT76_TM_TX_MODE_HT) {
134+ switch (dev->phy.chandef.width) {
135+ case NL80211_CHAN_WIDTH_40:
136+ rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
137+ break;
138+ case NL80211_CHAN_WIDTH_80:
139+ rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;
140+ break;
141+ case NL80211_CHAN_WIDTH_80P80:
142+ case NL80211_CHAN_WIDTH_160:
143+ rate->flags |= IEEE80211_TX_RC_160_MHZ_WIDTH;
144+ break;
145+ default:
146+ break;
147+ }
148+ }
149+
150+ skb_set_queue_mapping(skb, IEEE80211_AC_BE);
151+
152+ return 0;
153+}
154+
155+static void
156+mt76_testmode_tx_start(struct mt76_dev *dev)
157+{
158+ struct mt76_testmode_data *td = &dev->test;
159+
160+ td->tx_queued = 0;
161+ td->tx_done = 0;
162+ td->tx_pending = td->tx_count;
163+ tasklet_schedule(&dev->tx_tasklet);
164+}
165+
166+static void
167+mt76_testmode_tx_stop(struct mt76_dev *dev)
168+{
169+ struct mt76_testmode_data *td = &dev->test;
170+
171+ tasklet_disable(&dev->tx_tasklet);
172+
173+ td->tx_pending = 0;
174+
175+ tasklet_enable(&dev->tx_tasklet);
176+
177+ wait_event_timeout(dev->tx_wait, td->tx_done == td->tx_queued, 10 * HZ);
178+
179+ dev_kfree_skb(td->tx_skb);
180+ td->tx_skb = NULL;
181+}
182+
183+static inline void
184+mt76_testmode_param_set(struct mt76_testmode_data *td, u16 idx)
185+{
186+ td->param_set[idx / 32] |= BIT(idx % 32);
187+}
188+
189+static inline bool
190+mt76_testmode_param_present(struct mt76_testmode_data *td, u16 idx)
191+{
192+ return td->param_set[idx / 32] & BIT(idx % 32);
193+}
194+
195+static void
196+mt76_testmode_init_defaults(struct mt76_dev *dev)
197+{
198+ struct mt76_testmode_data *td = &dev->test;
199+
200+ if (td->tx_msdu_len > 0)
201+ return;
202+
203+ td->tx_msdu_len = 1024;
204+ td->tx_count = 1;
205+ td->tx_rate_mode = MT76_TM_TX_MODE_OFDM;
206+ td->tx_rate_nss = 1;
207+}
208+
209+static int
210+__mt76_testmode_set_state(struct mt76_dev *dev, enum mt76_testmode_state state)
211+{
212+ enum mt76_testmode_state prev_state = dev->test.state;
213+ int err;
214+
215+ if (prev_state == MT76_TM_STATE_TX_FRAMES)
216+ mt76_testmode_tx_stop(dev);
217+
218+ if (state == MT76_TM_STATE_TX_FRAMES) {
219+ err = mt76_testmode_tx_init(dev);
220+ if (err)
221+ return err;
222+ }
223+
224+ err = dev->test_ops->set_state(dev, state);
225+ if (err) {
226+ if (state == MT76_TM_STATE_TX_FRAMES)
227+ mt76_testmode_tx_stop(dev);
228+
229+ return err;
230+ }
231+
232+ if (state == MT76_TM_STATE_TX_FRAMES)
233+ mt76_testmode_tx_start(dev);
234+ else if (state == MT76_TM_STATE_RX_FRAMES) {
235+ memset(&dev->test.rx_stats, 0, sizeof(dev->test.rx_stats));
236+ }
237+
238+ dev->test.state = state;
239+
240+ return 0;
241+}
242+
243+int mt76_testmode_set_state(struct mt76_dev *dev, enum mt76_testmode_state state)
244+{
245+ struct mt76_testmode_data *td = &dev->test;
246+ struct ieee80211_hw *hw = dev->phy.hw;
247+
248+ if (state == td->state && state == MT76_TM_STATE_OFF)
249+ return 0;
250+
251+ if (state > MT76_TM_STATE_OFF &&
252+ (!test_bit(MT76_STATE_RUNNING, &dev->phy.state) ||
253+ !(hw->conf.flags & IEEE80211_CONF_MONITOR)))
254+ return -ENOTCONN;
255+
256+ if (state != MT76_TM_STATE_IDLE &&
257+ td->state != MT76_TM_STATE_IDLE) {
258+ int ret;
259+
260+ ret = __mt76_testmode_set_state(dev, MT76_TM_STATE_IDLE);
261+ if (ret)
262+ return ret;
263+ }
264+
265+ return __mt76_testmode_set_state(dev, state);
266+
267+}
268+EXPORT_SYMBOL(mt76_testmode_set_state);
269+
270+static int
271+mt76_tm_get_u8(struct nlattr *attr, u8 *dest, u8 min, u8 max)
272+{
273+ u8 val;
274+
275+ if (!attr)
276+ return 0;
277+
278+ val = nla_get_u8(attr);
279+ if (val < min || val > max)
280+ return -EINVAL;
281+
282+ *dest = val;
283+ return 0;
284+}
285+
286+int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
287+ void *data, int len)
288+{
289+ struct mt76_phy *phy = hw->priv;
290+ struct mt76_dev *dev = phy->dev;
291+ struct mt76_testmode_data *td = &dev->test;
292+ struct nlattr *tb[NUM_MT76_TM_ATTRS];
293+ u32 state;
294+ int err;
295+ int i;
296+
297+ if (!dev->test_ops)
298+ return -EOPNOTSUPP;
299+
300+ err = nla_parse_deprecated(tb, MT76_TM_ATTR_MAX, data, len,
301+ mt76_tm_policy, NULL);
302+ if (err)
303+ return err;
304+
305+ err = -EINVAL;
306+
307+ mutex_lock(&dev->mutex);
308+
309+ if (tb[MT76_TM_ATTR_RESET]) {
310+ mt76_testmode_set_state(dev, MT76_TM_STATE_OFF);
311+ memset(td, 0, sizeof(*td));
312+ }
313+
314+ mt76_testmode_init_defaults(dev);
315+
316+ if (tb[MT76_TM_ATTR_TX_COUNT])
317+ td->tx_count = nla_get_u32(tb[MT76_TM_ATTR_TX_COUNT]);
318+
319+ if (tb[MT76_TM_ATTR_TX_LENGTH]) {
320+ u32 val = nla_get_u32(tb[MT76_TM_ATTR_TX_LENGTH]);
321+
322+ if (val > IEEE80211_MAX_FRAME_LEN ||
323+ val < sizeof(struct ieee80211_hdr))
324+ goto out;
325+
326+ td->tx_msdu_len = val;
327+ }
328+
329+ if (tb[MT76_TM_ATTR_TX_RATE_IDX])
330+ td->tx_rate_idx = nla_get_u8(tb[MT76_TM_ATTR_TX_RATE_IDX]);
331+
332+ if (mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_RATE_MODE], &td->tx_rate_mode,
333+ 0, MT76_TM_TX_MODE_MAX) ||
334+ mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_RATE_NSS], &td->tx_rate_nss,
335+ 1, hweight8(phy->antenna_mask)) ||
336+ mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_RATE_SGI], &td->tx_rate_sgi, 0, 1) ||
337+ mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_RATE_LDPC], &td->tx_rate_ldpc, 0, 1) ||
338+ mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_ANTENNA], &td->tx_antenna_mask, 1,
339+ phy->antenna_mask) ||
340+ mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_POWER_CONTROL],
341+ &td->tx_power_control, 0, 1))
342+ goto out;
343+
344+ if (tb[MT76_TM_ATTR_FREQ_OFFSET])
345+ td->freq_offset = nla_get_u32(tb[MT76_TM_ATTR_FREQ_OFFSET]);
346+
347+ if (tb[MT76_TM_ATTR_STATE]) {
348+ state = nla_get_u32(tb[MT76_TM_ATTR_STATE]);
349+ if (state > MT76_TM_STATE_MAX)
350+ goto out;
351+ } else {
352+ state = td->state;
353+ }
354+
355+ if (tb[MT76_TM_ATTR_TX_POWER]) {
356+ struct nlattr *cur;
357+ int idx = 0;
358+ int rem;
359+
360+ nla_for_each_nested(cur, tb[MT76_TM_ATTR_TX_POWER], rem) {
361+ if (nla_len(cur) != 1 ||
362+ idx >= ARRAY_SIZE(td->tx_power))
363+ goto out;
364+
365+ td->tx_power[idx++] = nla_get_u8(cur);
366+ }
367+ }
368+
369+ if (dev->test_ops->set_params) {
370+ err = dev->test_ops->set_params(dev, tb, state);
371+ if (err)
372+ goto out;
373+ }
374+
375+ for (i = MT76_TM_ATTR_STATE; i < ARRAY_SIZE(tb); i++)
376+ if (tb[i])
377+ mt76_testmode_param_set(td, i);
378+
379+ err = 0;
380+ if (tb[MT76_TM_ATTR_STATE])
381+ err = mt76_testmode_set_state(dev, state);
382+
383+out:
384+ mutex_unlock(&dev->mutex);
385+
386+ return err;
387+}
388+EXPORT_SYMBOL(mt76_testmode_cmd);
389+
390+static int
391+mt76_testmode_dump_stats(struct mt76_dev *dev, struct sk_buff *msg)
392+{
393+ struct mt76_testmode_data *td = &dev->test;
394+ u64 rx_packets = 0;
395+ u64 rx_fcs_error = 0;
396+ int i;
397+
398+ for (i = 0; i < ARRAY_SIZE(td->rx_stats.packets); i++) {
399+ rx_packets += td->rx_stats.packets[i];
400+ rx_fcs_error += td->rx_stats.fcs_error[i];
401+ }
402+
403+ if (nla_put_u32(msg, MT76_TM_STATS_ATTR_TX_PENDING, td->tx_pending) ||
404+ nla_put_u32(msg, MT76_TM_STATS_ATTR_TX_QUEUED, td->tx_queued) ||
405+ nla_put_u32(msg, MT76_TM_STATS_ATTR_TX_DONE, td->tx_done) ||
406+ nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_PACKETS, rx_packets,
407+ MT76_TM_STATS_ATTR_PAD) ||
408+ nla_put_u64_64bit(msg, MT76_TM_STATS_ATTR_RX_FCS_ERROR, rx_fcs_error,
409+ MT76_TM_STATS_ATTR_PAD))
410+ return -EMSGSIZE;
411+
412+ if (dev->test_ops->dump_stats)
413+ return dev->test_ops->dump_stats(dev, msg);
414+
415+ return 0;
416+}
417+
418+int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
419+ struct netlink_callback *cb, void *data, int len)
420+{
421+ struct mt76_phy *phy = hw->priv;
422+ struct mt76_dev *dev = phy->dev;
423+ struct mt76_testmode_data *td = &dev->test;
424+ struct nlattr *tb[NUM_MT76_TM_ATTRS] = {};
425+ int err = 0;
426+ void *a;
427+ int i;
428+
429+ if (!dev->test_ops)
430+ return -EOPNOTSUPP;
431+
432+ if (cb->args[2]++ > 0)
433+ return -ENOENT;
434+
435+ if (data) {
436+ err = nla_parse_deprecated(tb, MT76_TM_ATTR_MAX, data, len,
437+ mt76_tm_policy, NULL);
438+ if (err)
439+ return err;
440+ }
441+
442+ mutex_lock(&dev->mutex);
443+
444+ if (tb[MT76_TM_ATTR_STATS]) {
445+ a = nla_nest_start(msg, MT76_TM_ATTR_STATS);
446+ err = mt76_testmode_dump_stats(dev, msg);
447+ nla_nest_end(msg, a);
448+
449+ goto out;
450+ }
451+
452+ mt76_testmode_init_defaults(dev);
453+
454+ err = -EMSGSIZE;
455+ if (nla_put_u32(msg, MT76_TM_ATTR_STATE, td->state))
456+ goto out;
457+
458+ if (td->mtd_name &&
459+ (nla_put_string(msg, MT76_TM_ATTR_MTD_PART, td->mtd_name) ||
460+ nla_put_u32(msg, MT76_TM_ATTR_MTD_OFFSET, td->mtd_offset)))
461+ goto out;
462+
463+ if (nla_put_u32(msg, MT76_TM_ATTR_TX_COUNT, td->tx_count) ||
464+ nla_put_u32(msg, MT76_TM_ATTR_TX_LENGTH, td->tx_msdu_len) ||
465+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_MODE, td->tx_rate_mode) ||
466+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_NSS, td->tx_rate_nss) ||
467+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_IDX, td->tx_rate_idx) ||
468+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_SGI, td->tx_rate_sgi) ||
469+ nla_put_u8(msg, MT76_TM_ATTR_TX_RATE_LDPC, td->tx_rate_ldpc) ||
470+ (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_ANTENNA) &&
471+ nla_put_u8(msg, MT76_TM_ATTR_TX_ANTENNA, td->tx_antenna_mask)) ||
472+ (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_POWER_CONTROL) &&
473+ nla_put_u8(msg, MT76_TM_ATTR_TX_POWER_CONTROL, td->tx_power_control)) ||
474+ (mt76_testmode_param_present(td, MT76_TM_ATTR_FREQ_OFFSET) &&
475+ nla_put_u8(msg, MT76_TM_ATTR_FREQ_OFFSET, td->freq_offset)))
476+ goto out;
477+
478+ if (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_POWER)) {
479+ a = nla_nest_start(msg, MT76_TM_ATTR_TX_POWER);
480+ if (!a)
481+ goto out;
482+
483+ for (i = 0; i < ARRAY_SIZE(td->tx_power); i++)
484+ if (nla_put_u8(msg, i, td->tx_power[i]))
485+ goto out;
486+
487+ nla_nest_end(msg, a);
488+ }
489+
490+ err = 0;
491+
492+out:
493+ mutex_unlock(&dev->mutex);
494+
495+ return err;
496+}
497+EXPORT_SYMBOL(mt76_testmode_dump);
drivers/net/wireless/mediatek/mt76/testmode.h+156−0
@@ -0,0 +1,156 @@
1+/* SPDX-License-Identifier: ISC */
2+/*
3+ * Copyright (C) 2020 Felix Fietkau <nbd@nbd.name>
4+ */
5+#ifndef __MT76_TESTMODE_H
6+#define __MT76_TESTMODE_H
7+
8+/**
9+ * enum mt76_testmode_attr - testmode attributes inside NL80211_ATTR_TESTDATA
10+ *
11+ * @MT76_TM_ATTR_UNSPEC: (invalid attribute)
12+ *
13+ * @MT76_TM_ATTR_RESET: reset parameters to default (flag)
14+ * @MT76_TM_ATTR_STATE: test state (u32), see &enum mt76_testmode_state
15+ *
16+ * @MT76_TM_ATTR_MTD_PART: mtd partition used for eeprom data (string)
17+ * @MT76_TM_ATTR_MTD_OFFSET: offset of eeprom data within the partition (u32)
18+ *
19+ * @MT76_TM_ATTR_TX_COUNT: configured number of frames to send when setting
20+ * state to MT76_TM_STATE_TX_FRAMES (u32)
21+ * @MT76_TM_ATTR_TX_PENDING: pending frames during MT76_TM_STATE_TX_FRAMES (u32)
22+ * @MT76_TM_ATTR_TX_LENGTH: packet tx msdu length (u32)
23+ * @MT76_TM_ATTR_TX_RATE_MODE: packet tx mode (u8, see &enum mt76_testmode_tx_mode)
24+ * @MT76_TM_ATTR_TX_RATE_NSS: packet tx number of spatial streams (u8)
25+ * @MT76_TM_ATTR_TX_RATE_IDX: packet tx rate/MCS index (u8)
26+ * @MT76_TM_ATTR_TX_RATE_SGI: packet tx use short guard interval (u8)
27+ * @MT76_TM_ATTR_TX_RATE_LDPC: packet tx enable LDPC (u8)
28+ *
29+ * @MT76_TM_ATTR_TX_ANTENNA: tx antenna mask (u8)
30+ * @MT76_TM_ATTR_TX_POWER_CONTROL: enable tx power control (u8)
31+ * @MT76_TM_ATTR_TX_POWER: per-antenna tx power array (nested, u8 attrs)
32+ *
33+ * @MT76_TM_ATTR_FREQ_OFFSET: RF frequency offset (u32)
34+ *
35+ * @MT76_TM_ATTR_STATS: statistics (nested, see &enum mt76_testmode_stats_attr)
36+ */
37+enum mt76_testmode_attr {
38+ MT76_TM_ATTR_UNSPEC,
39+
40+ MT76_TM_ATTR_RESET,
41+ MT76_TM_ATTR_STATE,
42+
43+ MT76_TM_ATTR_MTD_PART,
44+ MT76_TM_ATTR_MTD_OFFSET,
45+
46+ MT76_TM_ATTR_TX_COUNT,
47+ MT76_TM_ATTR_TX_LENGTH,
48+ MT76_TM_ATTR_TX_RATE_MODE,
49+ MT76_TM_ATTR_TX_RATE_NSS,
50+ MT76_TM_ATTR_TX_RATE_IDX,
51+ MT76_TM_ATTR_TX_RATE_SGI,
52+ MT76_TM_ATTR_TX_RATE_LDPC,
53+
54+ MT76_TM_ATTR_TX_ANTENNA,
55+ MT76_TM_ATTR_TX_POWER_CONTROL,
56+ MT76_TM_ATTR_TX_POWER,
57+
58+ MT76_TM_ATTR_FREQ_OFFSET,
59+
60+ MT76_TM_ATTR_STATS,
61+
62+ /* keep last */
63+ NUM_MT76_TM_ATTRS,
64+ MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1,
65+};
66+
67+/**
68+ * enum mt76_testmode_state - statistics attributes
69+ *
70+ * @MT76_TM_STATS_ATTR_TX_PENDING: pending tx frames (u32)
71+ * @MT76_TM_STATS_ATTR_TX_QUEUED: queued tx frames (u32)
72+ * @MT76_TM_STATS_ATTR_TX_QUEUED: completed tx frames (u32)
73+ *
74+ * @MT76_TM_STATS_ATTR_RX_PACKETS: number of rx packets (u64)
75+ * @MT76_TM_STATS_ATTR_RX_FCS_ERROR: number of rx packets with FCS error (u64)
76+ * @MT76_TM_STATS_ATTR_LAST_RX: information about the last received packet
77+ * see &enum mt76_testmode_rx_attr
78+ */
79+enum mt76_testmode_stats_attr {
80+ MT76_TM_STATS_ATTR_UNSPEC,
81+ MT76_TM_STATS_ATTR_PAD,
82+
83+ MT76_TM_STATS_ATTR_TX_PENDING,
84+ MT76_TM_STATS_ATTR_TX_QUEUED,
85+ MT76_TM_STATS_ATTR_TX_DONE,
86+
87+ MT76_TM_STATS_ATTR_RX_PACKETS,
88+ MT76_TM_STATS_ATTR_RX_FCS_ERROR,
89+ MT76_TM_STATS_ATTR_LAST_RX,
90+
91+ /* keep last */
92+ NUM_MT76_TM_STATS_ATTRS,
93+ MT76_TM_STATS_ATTR_MAX = NUM_MT76_TM_STATS_ATTRS - 1,
94+};
95+
96+
97+/**
98+ * enum mt76_testmode_rx_attr - packet rx information
99+ *
100+ * @MT76_TM_RX_ATTR_FREQ_OFFSET: frequency offset (s32)
101+ * @MT76_TM_RX_ATTR_RCPI: received channel power indicator (array, u8)
102+ * @MT76_TM_RX_ATTR_IB_RSSI: internal inband RSSI (s8)
103+ * @MT76_TM_RX_ATTR_WB_RSSI: internal wideband RSSI (s8)
104+ */
105+enum mt76_testmode_rx_attr {
106+ MT76_TM_RX_ATTR_UNSPEC,
107+
108+ MT76_TM_RX_ATTR_FREQ_OFFSET,
109+ MT76_TM_RX_ATTR_RCPI,
110+ MT76_TM_RX_ATTR_IB_RSSI,
111+ MT76_TM_RX_ATTR_WB_RSSI,
112+
113+ /* keep last */
114+ NUM_MT76_TM_RX_ATTRS,
115+ MT76_TM_RX_ATTR_MAX = NUM_MT76_TM_RX_ATTRS - 1,
116+};
117+
118+/**
119+ * enum mt76_testmode_state - phy test state
120+ *
121+ * @MT76_TM_STATE_OFF: test mode disabled (normal operation)
122+ * @MT76_TM_STATE_IDLE: test mode enabled, but idle
123+ * @MT76_TM_STATE_TX_FRAMES: send a fixed number of test frames
124+ * @MT76_TM_STATE_RX_FRAMES: receive packets and keep statistics
125+ */
126+enum mt76_testmode_state {
127+ MT76_TM_STATE_OFF,
128+ MT76_TM_STATE_IDLE,
129+ MT76_TM_STATE_TX_FRAMES,
130+ MT76_TM_STATE_RX_FRAMES,
131+
132+ /* keep last */
133+ NUM_MT76_TM_STATES,
134+ MT76_TM_STATE_MAX = NUM_MT76_TM_STATES - 1,
135+};
136+
137+/**
138+ * enum mt76_testmode_tx_mode - packet tx phy mode
139+ *
140+ * @MT76_TM_TX_MODE_CCK: legacy CCK mode
141+ * @MT76_TM_TX_MODE_OFDM: legacy OFDM mode
142+ * @MT76_TM_TX_MODE_HT: 802.11n MCS
143+ * @MT76_TM_TX_MODE_VHT: 802.11ac MCS
144+ */
145+enum mt76_testmode_tx_mode {
146+ MT76_TM_TX_MODE_CCK,
147+ MT76_TM_TX_MODE_OFDM,
148+ MT76_TM_TX_MODE_HT,
149+ MT76_TM_TX_MODE_VHT,
150+
151+ /* keep last */
152+ NUM_MT76_TM_TX_MODES,
153+ MT76_TM_TX_MODE_MAX = NUM_MT76_TM_TX_MODES - 1,
154+};
155+
156+#endif
drivers/net/wireless/mediatek/mt76/tx.c+47−0
@@ -236,6 +236,14 @@ void mt76_tx_complete_skb(struct mt76_dev *dev, struct sk_buff *skb) · 235 unmodified lines
236236 struct ieee80211_hw *hw;
237237 struct sk_buff_head list;
238238
239+#ifdef CONFIG_NL80211_TESTMODE
240+ if (skb == dev->test.tx_skb) {
241+ dev->test.tx_done++;
242+ if (dev->test.tx_queued == dev->test.tx_done)
243+ wake_up(&dev->tx_wait);
244+ }
245+#endif
246+
239247 if (!skb->prev) {
240248 hw = mt76_tx_status_get_hw(dev, skb);
241249 ieee80211_free_txskb(hw, skb);
@@ -259,6 +267,11 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta, · 17 unmodified lines
259267 int qid = skb_get_queue_mapping(skb);
260268 bool ext_phy = phy != &dev->phy;
261269
270+ if (mt76_testmode_enabled(dev)) {
271+ ieee80211_free_txskb(phy->hw, skb);
272+ return;
273+ }
274+
262275 if (WARN_ON(qid >= MT_TXQ_PSD)) {
263276 qid = MT_TXQ_BE;
264277 skb_set_queue_mapping(skb, qid);
@@ -579,6 +592,11 @@ void mt76_tx_tasklet(unsigned long data) · 314 unmodified lines
579592 mt76_txq_schedule_all(&dev->phy);
580593 if (dev->phy2)
581594 mt76_txq_schedule_all(dev->phy2);
595+
596+#ifdef CONFIG_NL80211_TESTMODE
597+ if (dev->test.tx_pending)
598+ mt76_testmode_tx_pending(dev);
599+#endif
582600 }
583601
584602 void mt76_stop_tx_queues(struct mt76_dev *dev, struct ieee80211_sta *sta,
@@ -659,3 +677,32 @@ u8 mt76_ac_to_hwq(u8 ac) · 74 unmodified lines
659677 return wmm_queue_map[ac];
660678 }
661679 EXPORT_SYMBOL_GPL(mt76_ac_to_hwq);
680+
681+int mt76_skb_adjust_pad(struct sk_buff *skb)
682+{
683+ struct sk_buff *iter, *last = skb;
684+ u32 pad;
685+
686+ /* Add zero pad of 4 - 7 bytes */
687+ pad = round_up(skb->len, 4) + 4 - skb->len;
688+
689+ /* First packet of a A-MSDU burst keeps track of the whole burst
690+ * length, need to update length of it and the last packet.
691+ */
692+ skb_walk_frags(skb, iter) {
693+ last = iter;
694+ if (!iter->next) {
695+ skb->data_len += pad;
696+ skb->len += pad;
697+ break;
698+ }
699+ }
700+
701+ if (skb_pad(last, pad))
702+ return -ENOMEM;
703+
704+ __skb_put(last, pad);
705+
706+ return 0;
707+}
708+EXPORT_SYMBOL_GPL(mt76_skb_adjust_pad);
drivers/net/wireless/mediatek/mt76/usb.c+16−74
@@ -672,17 +672,11 @@ mt76u_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) · 671 unmodified lines
672672 static void mt76u_rx_tasklet(unsigned long data)
673673 {
674674 struct mt76_dev *dev = (struct mt76_dev *)data;
675− struct mt76_queue *q;
676675 int i;
677676
678677 rcu_read_lock();
679− for (i = 0; i < __MT_RXQ_MAX; i++) {
680− q = &dev->q_rx[i];
681− if (!q->ndesc)
682− continue;
683−
684− mt76u_process_rx_queue(dev, q);
685− }
678+ mt76_for_each_q_rx(dev, i)
679+ mt76u_process_rx_queue(dev, &dev->q_rx[i]);
686680 rcu_read_unlock();
687681 }
688682
@@ -756,27 +750,19 @@ mt76u_free_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) · 67 unmodified lines
756750
757751 static void mt76u_free_rx(struct mt76_dev *dev)
758752 {
759− struct mt76_queue *q;
760753 int i;
761754
762− for (i = 0; i < __MT_RXQ_MAX; i++) {
763− q = &dev->q_rx[i];
764− if (!q->ndesc)
765− continue;
766−
767− mt76u_free_rx_queue(dev, q);
768− }
755+ mt76_for_each_q_rx(dev, i)
756+ mt76u_free_rx_queue(dev, &dev->q_rx[i]);
769757 }
770758
771759 void mt76u_stop_rx(struct mt76_dev *dev)
772760 {
773− struct mt76_queue *q;
774− int i, j;
761+ int i;
775762
776− for (i = 0; i < __MT_RXQ_MAX; i++) {
777− q = &dev->q_rx[i];
778− if (!q->ndesc)
779− continue;
763+ mt76_for_each_q_rx(dev, i) {
764+ struct mt76_queue *q = &dev->q_rx[i];
765+ int j;
780766
781767 for (j = 0; j < q->ndesc; j++)
782768 usb_poison_urb(q->entry[j].urb);
@@ -788,14 +774,11 @@ EXPORT_SYMBOL_GPL(mt76u_stop_rx); · 5 unmodified lines
788774
789775 int mt76u_resume_rx(struct mt76_dev *dev)
790776 {
791− struct mt76_queue *q;
792− int i, j, err;
793−
794− for (i = 0; i < __MT_RXQ_MAX; i++) {
795− q = &dev->q_rx[i];
777+ int i;
796778
797− if (!q->ndesc)
798− continue;
779+ mt76_for_each_q_rx(dev, i) {
780+ struct mt76_queue *q = &dev->q_rx[i];
781+ int err, j;
799782
800783 for (j = 0; j < q->ndesc; j++)
801784 usb_unpoison_urb(q->entry[j].urb);
@@ -859,7 +842,7 @@ static void mt76u_tx_tasklet(unsigned long data) · 57 unmodified lines
859842
860843 if (dev->drv->tx_status_data &&
861844 !test_and_set_bit(MT76_READING_STATS, &dev->phy.state))
862− queue_work(dev->usb.wq, &dev->usb.stat_work);
845+ queue_work(dev->wq, &dev->usb.stat_work);
863846 if (wake)
864847 ieee80211_wake_queue(dev->hw, i);
865848 }
@@ -885,7 +868,7 @@ static void mt76u_tx_status_data(struct work_struct *work) · 19 unmodified lines
885868 }
886869
887870 if (count && test_bit(MT76_STATE_RUNNING, &dev->phy.state))
888− queue_work(usb->wq, &usb->stat_work);
871+ queue_work(dev->wq, &usb->stat_work);
889872 else
890873 clear_bit(MT76_READING_STATS, &dev->phy.state);
891874 }
@@ -921,35 +904,6 @@ mt76u_tx_setup_buffers(struct mt76_dev *dev, struct sk_buff *skb, · 29 unmodified lines
921904 return urb->num_sgs;
922905 }
923906
924−int mt76u_skb_dma_info(struct sk_buff *skb, u32 info)
925−{
926− struct sk_buff *iter, *last = skb;
927− u32 pad;
928−
929− put_unaligned_le32(info, skb_push(skb, sizeof(info)));
930− /* Add zero pad of 4 - 7 bytes */
931− pad = round_up(skb->len, 4) + 4 - skb->len;
932−
933− /* First packet of a A-MSDU burst keeps track of the whole burst
934− * length, need to update length of it and the last packet.
935− */
936− skb_walk_frags(skb, iter) {
937− last = iter;
938− if (!iter->next) {
939− skb->data_len += pad;
940− skb->len += pad;
941− break;
942− }
943− }
944−
945− if (skb_pad(last, pad))
946− return -ENOMEM;
947− __skb_put(last, pad);
948−
949− return 0;
950−}
951−EXPORT_SYMBOL_GPL(mt76u_skb_dma_info);
952−
953907 static int
954908 mt76u_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
955909 struct sk_buff *skb, struct mt76_wcid *wcid,
@@ -1161,15 +1115,6 @@ static const struct mt76_queue_ops usb_queue_ops = { · 205 unmodified lines
11611115 .kick = mt76u_tx_kick,
11621116 };
11631117
1164−void mt76u_deinit(struct mt76_dev *dev)
1165−{
1166− if (dev->usb.wq) {
1167− destroy_workqueue(dev->usb.wq);
1168− dev->usb.wq = NULL;
1169− }
1170−}
1171−EXPORT_SYMBOL_GPL(mt76u_deinit);
1172−
11731118 int mt76u_init(struct mt76_dev *dev,
11741119 struct usb_interface *intf, bool ext)
11751120 {
@@ -1192,10 +1137,6 @@ int mt76u_init(struct mt76_dev *dev, · 16 unmodified lines
11921137 tasklet_init(&dev->tx_tasklet, mt76u_tx_tasklet, (unsigned long)dev);
11931138 INIT_WORK(&usb->stat_work, mt76u_tx_status_data);
11941139
1195− usb->wq = alloc_workqueue("mt76u", WQ_UNBOUND, 0);
1196− if (!usb->wq)
1197− return -ENOMEM;
1198−
11991140 usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1);
12001141 if (usb->data_len < 32)
12011142 usb->data_len = 32;
@@ -1219,7 +1160,8 @@ int mt76u_init(struct mt76_dev *dev, · 17 unmodified lines
12191160 return 0;
12201161
12211162 error:
1222− mt76u_deinit(dev);
1163+ destroy_workqueue(dev->wq);
1164+
12231165 return err;
12241166 }
12251167 EXPORT_SYMBOL_GPL(mt76u_init);
drivers/net/wireless/mediatek/mt76/util.c+2−2
@@ -13,7 +13,7 @@ bool __mt76_poll(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, · 12 unmodified lines
1313
1414 timeout /= 10;
1515 do {
16− cur = dev->bus->rr(dev, offset) & mask;
16+ cur = __mt76_rr(dev, offset) & mask;
1717 if (cur == val)
1818 return true;
1919
@@ -31,7 +31,7 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, · 11 unmodified lines
3131
3232 timeout /= 10;
3333 do {
34− cur = dev->bus->rr(dev, offset) & mask;
34+ cur = __mt76_rr(dev, offset) & mask;
3535 if (cur == val)
3636 return true;
3737
drivers/net/wireless/mediatek/mt7601u/mcu.c+3−1
@@ -116,8 +116,10 @@ mt7601u_mcu_msg_send(struct mt7601u_dev *dev, struct sk_buff *skb, · 115 unmodified lines
116116 int sent, ret;
117117 u8 seq = 0;
118118
119− if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
119+ if (test_bit(MT7601U_STATE_REMOVED, &dev->state)) {
120+ consume_skb(skb);
120121 return 0;
122+ }
121123
122124 mutex_lock(&dev->mcu.mutex);
123125
drivers/net/wireless/microchip/wilc1000/sdio.c+2−4
@@ -6,6 +6,7 @@ · 5 unmodified lines
66
77 #include <linux/clk.h>
88 #include <linux/mmc/sdio_func.h>
9+#include <linux/mmc/sdio_ids.h>
910 #include <linux/mmc/host.h>
1011 #include <linux/mmc/sdio.h>
1112 #include <linux/of_irq.h>
@@ -15,11 +16,8 @@ · 3 unmodified lines
1516
1617 #define SDIO_MODALIAS "wilc1000_sdio"
1718
18−#define SDIO_VENDOR_ID_WILC 0x0296
19−#define SDIO_DEVICE_ID_WILC 0x5347
20−
2119 static const struct sdio_device_id wilc_sdio_ids[] = {
22− { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
20+ { SDIO_DEVICE(SDIO_VENDOR_ID_MICROCHIP_WILC, SDIO_DEVICE_ID_MICROCHIP_WILC1000) },
2321 { },
2422 };
2523
drivers/net/wireless/quantenna/qtnfmac/core.c+4−1
@@ -446,8 +446,11 @@ static struct qtnf_wmac *qtnf_core_mac_alloc(struct qtnf_bus *bus, · 445 unmodified lines
446446 }
447447
448448 wiphy = qtnf_wiphy_allocate(bus, pdev);
449− if (!wiphy)
449+ if (!wiphy) {
450+ if (pdev)
451+ platform_device_unregister(pdev);
450452 return ERR_PTR(-ENOMEM);
453+ }
451454
452455 mac = wiphy_priv(wiphy);
453456
drivers/net/wireless/ralink/rt2x00/rt2400pci.c+1−2
@@ -1834,8 +1834,7 @@ static struct pci_driver rt2400pci_driver = { · 1833 unmodified lines
18341834 .id_table = rt2400pci_device_table,
18351835 .probe = rt2400pci_probe,
18361836 .remove = rt2x00pci_remove,
1837− .suspend = rt2x00pci_suspend,
1838− .resume = rt2x00pci_resume,
1837+ .driver.pm = &rt2x00pci_pm_ops,
18391838 };
18401839
18411840 module_pci_driver(rt2400pci_driver);
drivers/net/wireless/ralink/rt2x00/rt2500pci.c+1−2
@@ -2132,8 +2132,7 @@ static struct pci_driver rt2500pci_driver = { · 2131 unmodified lines
21322132 .id_table = rt2500pci_device_table,
21332133 .probe = rt2500pci_probe,
21342134 .remove = rt2x00pci_remove,
2135− .suspend = rt2x00pci_suspend,
2136− .resume = rt2x00pci_resume,
2135+ .driver.pm = &rt2x00pci_pm_ops,
21372136 };
21382137
21392138 module_pci_driver(rt2500pci_driver);
drivers/net/wireless/ralink/rt2x00/rt2800pci.c+1−2
@@ -455,8 +455,7 @@ static struct pci_driver rt2800pci_driver = { · 454 unmodified lines
455455 .id_table = rt2800pci_device_table,
456456 .probe = rt2800pci_probe,
457457 .remove = rt2x00pci_remove,
458− .suspend = rt2x00pci_suspend,
459− .resume = rt2x00pci_resume,
458+ .driver.pm = &rt2x00pci_pm_ops,
460459 };
461460
462461 module_pci_driver(rt2800pci_driver);
drivers/net/wireless/ralink/rt2x00/rt2x00.h+2−3
@@ -1487,9 +1487,8 @@ bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw); · 1486 unmodified lines
14871487 */
14881488 int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);
14891489 void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);
1490−#ifdef CONFIG_PM
1491−int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state);
1490+
1491+int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev);
14921492 int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
1493−#endif /* CONFIG_PM */
14941493
14951494 #endif /* RT2X00_H */
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c+1−3
@@ -1556,8 +1556,7 @@ EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); · 1555 unmodified lines
15561556 /*
15571557 * Device state handlers
15581558 */
1559−#ifdef CONFIG_PM
1560−int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1559+int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev)
15611560 {
15621561 rt2x00_dbg(rt2x00dev, "Going to sleep\n");
15631562
@@ -1614,7 +1613,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) · 50 unmodified lines
16141613 return 0;
16151614 }
16161615 EXPORT_SYMBOL_GPL(rt2x00lib_resume);
1617−#endif /* CONFIG_PM */
16181616
16191617 /*
16201618 * rt2x00lib module information.
drivers/net/wireless/ralink/rt2x00/rt2x00pci.c+8−23
@@ -169,39 +169,24 @@ void rt2x00pci_remove(struct pci_dev *pci_dev) · 168 unmodified lines
169169 }
170170 EXPORT_SYMBOL_GPL(rt2x00pci_remove);
171171
172−#ifdef CONFIG_PM
173−int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state)
172+static int __maybe_unused rt2x00pci_suspend(struct device *dev)
174173 {
175− struct ieee80211_hw *hw = pci_get_drvdata(pci_dev);
174+ struct ieee80211_hw *hw = dev_get_drvdata(dev);
176175 struct rt2x00_dev *rt2x00dev = hw->priv;
177− int retval;
178−
179− retval = rt2x00lib_suspend(rt2x00dev, state);
180− if (retval)
181− return retval;
182176
183− pci_save_state(pci_dev);
184− pci_disable_device(pci_dev);
185− return pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
177+ return rt2x00lib_suspend(rt2x00dev);
186178 }
187−EXPORT_SYMBOL_GPL(rt2x00pci_suspend);
188179
189−int rt2x00pci_resume(struct pci_dev *pci_dev)
180+static int __maybe_unused rt2x00pci_resume(struct device *dev)
190181 {
191− struct ieee80211_hw *hw = pci_get_drvdata(pci_dev);
182+ struct ieee80211_hw *hw = dev_get_drvdata(dev);
192183 struct rt2x00_dev *rt2x00dev = hw->priv;
193184
194− if (pci_set_power_state(pci_dev, PCI_D0) ||
195− pci_enable_device(pci_dev)) {
196− rt2x00_err(rt2x00dev, "Failed to resume device\n");
197− return -EIO;
198− }
199−
200− pci_restore_state(pci_dev);
201185 return rt2x00lib_resume(rt2x00dev);
202186 }
203−EXPORT_SYMBOL_GPL(rt2x00pci_resume);
204−#endif /* CONFIG_PM */
187+
188+SIMPLE_DEV_PM_OPS(rt2x00pci_pm_ops, rt2x00pci_suspend, rt2x00pci_resume);
189+EXPORT_SYMBOL_GPL(rt2x00pci_pm_ops);
205190
206191 /*
207192 * rt2x00pci module information.
drivers/net/wireless/ralink/rt2x00/rt2x00pci.h+2−7
@@ -21,12 +21,7 @@ · 20 unmodified lines
2121 */
2222 int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops);
2323 void rt2x00pci_remove(struct pci_dev *pci_dev);
24−#ifdef CONFIG_PM
25−int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state);
26−int rt2x00pci_resume(struct pci_dev *pci_dev);
27−#else
28−#define rt2x00pci_suspend NULL
29−#define rt2x00pci_resume NULL
30−#endif /* CONFIG_PM */
24+
25+extern const struct dev_pm_ops rt2x00pci_pm_ops;
3126
3227 #endif /* RT2X00PCI_H */
drivers/net/wireless/ralink/rt2x00/rt2x00soc.c+1−1
@@ -130,7 +130,7 @@ int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state) · 129 unmodified lines
130130 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
131131 struct rt2x00_dev *rt2x00dev = hw->priv;
132132
133− return rt2x00lib_suspend(rt2x00dev, state);
133+ return rt2x00lib_suspend(rt2x00dev);
134134 }
135135 EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
136136
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c+1−1
@@ -886,7 +886,7 @@ int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state) · 885 unmodified lines
886886 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
887887 struct rt2x00_dev *rt2x00dev = hw->priv;
888888
889− return rt2x00lib_suspend(rt2x00dev, state);
889+ return rt2x00lib_suspend(rt2x00dev);
890890 }
891891 EXPORT_SYMBOL_GPL(rt2x00usb_suspend);
892892
drivers/net/wireless/ralink/rt2x00/rt61pci.c+1−2
@@ -3009,8 +3009,7 @@ static struct pci_driver rt61pci_driver = { · 3008 unmodified lines
30093009 .id_table = rt61pci_device_table,
30103010 .probe = rt61pci_probe,
30113011 .remove = rt2x00pci_remove,
3012− .suspend = rt2x00pci_suspend,
3013− .resume = rt2x00pci_resume,
3012+ .driver.pm = &rt2x00pci_pm_ops,
30143013 };
30153014
30163015 module_pci_driver(rt61pci_driver);
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c+3−5
@@ -894,11 +894,9 @@ static void halbtc_display_wifi_status(struct btc_coexist *btcoexist, · 893 unmodified lines
894894 (low_power ? ", 32k" : ""));
895895
896896 seq_printf(m,
897− "\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)",
897+ "\n %-35s = %6ph (0x%x/0x%x)",
898898 "Power mode cmd(lps/rpwm)",
899− btcoexist->pwr_mode_val[0], btcoexist->pwr_mode_val[1],
900− btcoexist->pwr_mode_val[2], btcoexist->pwr_mode_val[3],
901− btcoexist->pwr_mode_val[4], btcoexist->pwr_mode_val[5],
899+ btcoexist->pwr_mode_val,
902900 btcoexist->bt_info.lps_val,
903901 btcoexist->bt_info.rpwm_val);
904902 }
@@ -1318,7 +1316,7 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter) · 413 unmodified lines
13181316 {
13191317 struct rtl_priv *rtlpriv = adapter;
13201318 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);
1321− u8 ant_num = 2, chip_type, single_ant_path = 0;
1319+ u8 ant_num, chip_type, single_ant_path;
13221320
13231321 if (!btcoexist)
13241322 return false;
drivers/net/wireless/realtek/rtw88/coex.c+2−1
@@ -1962,7 +1962,8 @@ static void rtw_coex_run_coex(struct rtw_dev *rtwdev, u8 reason) · 1961 unmodified lines
19621962 if (coex_stat->wl_under_ips)
19631963 return;
19641964
1965− if (coex->freeze && !coex_stat->bt_setup_link)
1965+ if (coex->freeze && coex_dm->reason == COEX_RSN_BTINFO &&
1966+ !coex_stat->bt_setup_link)
19661967 return;
19671968
19681969 coex_stat->cnt_wl[COEX_CNT_WL_COEXRUN]++;
drivers/net/wireless/realtek/rtw88/debug.c+30−0
@@ -344,6 +344,31 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp, · 343 unmodified lines
344344 return count;
345345 }
346346
347+static ssize_t rtw_debugfs_set_h2c(struct file *filp,
348+ const char __user *buffer,
349+ size_t count, loff_t *loff)
350+{
351+ struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
352+ struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
353+ char tmp[32 + 1];
354+ u8 param[8];
355+ int num;
356+
357+ rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
358+
359+ num = sscanf(tmp, "%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx,%hhx",
360+ &param[0], &param[1], &param[2], &param[3],
361+ &param[4], &param[5], &param[6], &param[7]);
362+ if (num != 8) {
363+ rtw_info(rtwdev, "invalid H2C command format for debug\n");
364+ return -EINVAL;
365+ }
366+
367+ rtw_fw_h2c_cmd_dbg(rtwdev, param);
368+
369+ return count;
370+}
371+
347372 static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
348373 const char __user *buffer,
349374 size_t count, loff_t *loff)
@@ -808,6 +833,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_write_reg = { · 458 unmodified lines
808833 .cb_write = rtw_debugfs_set_write_reg,
809834 };
810835
836+static struct rtw_debugfs_priv rtw_debug_priv_h2c = {
837+ .cb_write = rtw_debugfs_set_h2c,
838+};
839+
811840 static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {
812841 .cb_write = rtw_debugfs_set_rf_write,
813842 };
@@ -877,6 +906,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev) · 63 unmodified lines
877906 rtw_debugfs_add_r(phy_info);
878907 rtw_debugfs_add_r(coex_info);
879908 rtw_debugfs_add_rw(coex_enable);
909+ rtw_debugfs_add_w(h2c);
880910 rtw_debugfs_add_r(mac_0);
881911 rtw_debugfs_add_r(mac_1);
882912 rtw_debugfs_add_r(mac_2);
drivers/net/wireless/realtek/rtw88/fw.c+11−6
@@ -253,6 +253,11 @@ out: · 252 unmodified lines
253253 spin_unlock(&rtwdev->h2c.lock);
254254 }
255255
256+void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c)
257+{
258+ rtw_fw_send_h2c_command(rtwdev, h2c);
259+}
260+
256261 static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt)
257262 {
258263 int ret;
@@ -456,7 +461,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) · 197 unmodified lines
456461 SET_RA_INFO_INIT_RA_LVL(h2c_pkt, si->init_ra_lv);
457462 SET_RA_INFO_SGI_EN(h2c_pkt, si->sgi_enable);
458463 SET_RA_INFO_BW_MODE(h2c_pkt, si->bw_mode);
459− SET_RA_INFO_LDPC(h2c_pkt, si->ldpc_en);
464+ SET_RA_INFO_LDPC(h2c_pkt, !!si->ldpc_en);
460465 SET_RA_INFO_NO_UPDATE(h2c_pkt, no_update);
461466 SET_RA_INFO_VHT_EN(h2c_pkt, si->vht_enable);
462467 SET_RA_INFO_DIS_PT(h2c_pkt, disable_pt);
@@ -915,14 +920,14 @@ static struct sk_buff *rtw_get_rsvd_page_skb(struct ieee80211_hw *hw, · 452 unmodified lines
915920 return skb_new;
916921 }
917922
918−static void rtw_fill_rsvd_page_desc(struct rtw_dev *rtwdev, struct sk_buff *skb)
923+static void rtw_fill_rsvd_page_desc(struct rtw_dev *rtwdev, struct sk_buff *skb,
924+ enum rtw_rsvd_packet_type type)
919925 {
920− struct rtw_tx_pkt_info pkt_info;
926+ struct rtw_tx_pkt_info pkt_info = {0};
921927 struct rtw_chip_info *chip = rtwdev->chip;
922928 u8 *pkt_desc;
923929
924− memset(&pkt_info, 0, sizeof(pkt_info));
925− rtw_rsvd_page_pkt_info_update(rtwdev, &pkt_info, skb);
930+ rtw_tx_rsvd_page_pkt_info_update(rtwdev, &pkt_info, skb, type);
926931 pkt_desc = skb_push(skb, chip->tx_pkt_desc_sz);
927932 memset(pkt_desc, 0, chip->tx_pkt_desc_sz);
928933 rtw_tx_fill_tx_desc(&pkt_info, skb);
@@ -1261,7 +1266,7 @@ static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev, u32 *size) · 332 unmodified lines
12611266 * And iter->len will be added with size of tx_desc_sz.
12621267 */
12631268 if (rsvd_pkt->add_txdesc)
1264− rtw_fill_rsvd_page_desc(rtwdev, iter);
1269+ rtw_fill_rsvd_page_desc(rtwdev, iter, rsvd_pkt->type);
12651270
12661271 rsvd_pkt->skb = iter;
12671272 rsvd_pkt->page = total_page;
drivers/net/wireless/realtek/rtw88/fw.h+2−0
@@ -563,4 +563,6 @@ void rtw_fw_set_nlo_info(struct rtw_dev *rtwdev, bool enable); · 562 unmodified lines
563563 void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,
564564 struct cfg80211_ssid *ssid);
565565 void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable);
566+void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c);
567+
566568 #endif
drivers/net/wireless/realtek/rtw88/mac80211.c+27−0
@@ -231,6 +231,23 @@ static void rtw_ops_remove_interface(struct ieee80211_hw *hw, · 230 unmodified lines
231231 mutex_unlock(&rtwdev->mutex);
232232 }
233233
234+static int rtw_ops_change_interface(struct ieee80211_hw *hw,
235+ struct ieee80211_vif *vif,
236+ enum nl80211_iftype type, bool p2p)
237+{
238+ struct rtw_dev *rtwdev = hw->priv;
239+
240+ rtw_info(rtwdev, "change vif %pM (%d)->(%d), p2p (%d)->(%d)\n",
241+ vif->addr, vif->type, type, vif->p2p, p2p);
242+
243+ rtw_ops_remove_interface(hw, vif);
244+
245+ vif->type = type;
246+ vif->p2p = p2p;
247+
248+ return rtw_ops_add_interface(hw, vif);
249+}
250+
234251 static void rtw_ops_configure_filter(struct ieee80211_hw *hw,
235252 unsigned int changed_flags,
236253 unsigned int *new_flags,
@@ -373,6 +390,15 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw, · 136 unmodified lines
373390 if (changed & BSS_CHANGED_BEACON)
374391 rtw_fw_download_rsvd_page(rtwdev);
375392
393+ if (changed & BSS_CHANGED_BEACON_ENABLED) {
394+ if (conf->enable_beacon)
395+ rtw_write32_set(rtwdev, REG_FWHW_TXQ_CTRL,
396+ BIT_EN_BCNQ_DL);
397+ else
398+ rtw_write32_clr(rtwdev, REG_FWHW_TXQ_CTRL,
399+ BIT_EN_BCNQ_DL);
400+ }
401+
376402 if (changed & BSS_CHANGED_MU_GROUPS)
377403 rtw_chip_set_gid_table(rtwdev, vif, conf);
378404
@@ -827,6 +853,7 @@ const struct ieee80211_ops rtw_ops = { · 448 unmodified lines
827853 .config = rtw_ops_config,
828854 .add_interface = rtw_ops_add_interface,
829855 .remove_interface = rtw_ops_remove_interface,
856+ .change_interface = rtw_ops_change_interface,
830857 .configure_filter = rtw_ops_configure_filter,
831858 .bss_info_changed = rtw_ops_bss_info_changed,
832859 .conf_tx = rtw_ops_conf_tx,
drivers/net/wireless/realtek/rtw88/main.c+6−5
@@ -722,8 +722,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) · 721 unmodified lines
722722 stbc_en = VHT_STBC_EN;
723723 if (sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)
724724 ldpc_en = VHT_LDPC_EN;
725− if (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80)
726− is_support_sgi = true;
727725 } else if (sta->ht_cap.ht_supported) {
728726 ra_mask |= (sta->ht_cap.mcs.rx_mask[1] << 20) |
729727 (sta->ht_cap.mcs.rx_mask[0] << 12);
@@ -731,9 +729,6 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) · 1 unmodified line
731729 stbc_en = HT_STBC_EN;
732730 if (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)
733731 ldpc_en = HT_LDPC_EN;
734− if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20 ||
735− sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40)
736− is_support_sgi = true;
737732 }
738733
739734 if (efuse->hw_cap.nss == 1)
@@ -775,12 +770,18 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) · 35 unmodified lines
775770 switch (sta->bandwidth) {
776771 case IEEE80211_STA_RX_BW_80:
777772 bw_mode = RTW_CHANNEL_WIDTH_80;
773+ is_support_sgi = sta->vht_cap.vht_supported &&
774+ (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80);
778775 break;
779776 case IEEE80211_STA_RX_BW_40:
780777 bw_mode = RTW_CHANNEL_WIDTH_40;
778+ is_support_sgi = sta->ht_cap.ht_supported &&
779+ (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40);
781780 break;
782781 default:
783782 bw_mode = RTW_CHANNEL_WIDTH_20;
783+ is_support_sgi = sta->ht_cap.ht_supported &&
784+ (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20);
784785 break;
785786 }
786787
drivers/net/wireless/realtek/rtw88/main.h+2−0
@@ -592,6 +592,8 @@ struct rtw_tx_pkt_info { · 591 unmodified lines
592592 bool dis_qselseq;
593593 bool en_hwseq;
594594 u8 hw_ssn_sel;
595+ bool nav_use_hdr;
596+ bool bt_null;
595597 };
596598
597599 struct rtw_rx_pkt_stat {
drivers/net/wireless/realtek/rtw88/reg.h+1−0
@@ -61,6 +61,7 @@ · 60 unmodified lines
6161 #define BIT_FSPI_EN BIT(19)
6262 #define BIT_EN_SIC BIT(12)
6363 #define BIT_BT_AOD_GPIO3 BIT(9)
64+#define BIT_PO_BT_PTA_PINS BIT(9)
6465 #define BIT_BT_PTA_EN BIT(5)
6566 #define BIT_WLRFE_4_5_EN BIT(2)
6667
drivers/net/wireless/realtek/rtw88/rtw8821c.c+404−1
@@ -649,6 +649,197 @@ static void rtw8821c_phy_calibration(struct rtw_dev *rtwdev) · 648 unmodified lines
649649 rtw8821c_do_iqk(rtwdev);
650650 }
651651
652+/* for coex */
653+static void rtw8821c_coex_cfg_init(struct rtw_dev *rtwdev)
654+{
655+ /* enable TBTT nterrupt */
656+ rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION);
657+
658+ /* BT report packet sample rate */
659+ rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, SAMPLE_RATE_MASK,
660+ SAMPLE_RATE);
661+
662+ /* enable BT counter statistics */
663+ rtw_write8(rtwdev, REG_BT_STAT_CTRL, BT_CNT_ENABLE);
664+
665+ /* enable PTA (3-wire function form BT side) */
666+ rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_PTA_EN);
667+ rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_PO_BT_PTA_PINS);
668+
669+ /* enable PTA (tx/rx signal form WiFi side) */
670+ rtw_write8_set(rtwdev, REG_QUEUE_CTRL, BIT_PTA_WL_TX_EN);
671+ /* wl tx signal to PTA not case EDCCA */
672+ rtw_write8_clr(rtwdev, REG_QUEUE_CTRL, BIT_PTA_EDCCA_EN);
673+ /* GNT_BT=1 while select both */
674+ rtw_write16_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY);
675+
676+ /* beacon queue always hi-pri */
677+ rtw_write8_mask(rtwdev, REG_BT_COEX_TABLE_H + 3, BIT_BCN_QUEUE,
678+ BCN_PRI_EN);
679+}
680+
681+static void rtw8821c_coex_cfg_ant_switch(struct rtw_dev *rtwdev, u8 ctrl_type,
682+ u8 pos_type)
683+{
684+ struct rtw_coex *coex = &rtwdev->coex;
685+ struct rtw_coex_dm *coex_dm = &coex->dm;
686+ struct rtw_coex_rfe *coex_rfe = &coex->rfe;
687+ u32 switch_status = FIELD_PREP(CTRL_TYPE_MASK, ctrl_type) | pos_type;
688+ bool polarity_inverse;
689+ u8 regval = 0;
690+
691+ if (switch_status == coex_dm->cur_switch_status)
692+ return;
693+
694+ coex_dm->cur_switch_status = switch_status;
695+
696+ if (coex_rfe->ant_switch_diversity &&
697+ ctrl_type == COEX_SWITCH_CTRL_BY_BBSW)
698+ ctrl_type = COEX_SWITCH_CTRL_BY_ANTDIV;
699+
700+ polarity_inverse = (coex_rfe->ant_switch_polarity == 1);
701+
702+ switch (ctrl_type) {
703+ default:
704+ case COEX_SWITCH_CTRL_BY_BBSW:
705+ rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
706+ rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
707+ /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */
708+ rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89,
709+ DPDT_CTRL_PIN);
710+
711+ if (pos_type == COEX_SWITCH_TO_WLG_BT) {
712+ if (coex_rfe->rfe_module_type != 0x4 &&
713+ coex_rfe->rfe_module_type != 0x2)
714+ regval = 0x3;
715+ else
716+ regval = (!polarity_inverse ? 0x2 : 0x1);
717+ } else if (pos_type == COEX_SWITCH_TO_WLG) {
718+ regval = (!polarity_inverse ? 0x2 : 0x1);
719+ } else {
720+ regval = (!polarity_inverse ? 0x1 : 0x2);
721+ }
722+
723+ rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_R_RFE_SEL_15,
724+ regval);
725+ break;
726+ case COEX_SWITCH_CTRL_BY_PTA:
727+ rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
728+ rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
729+ /* PTA, DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */
730+ rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89,
731+ PTA_CTRL_PIN);
732+
733+ regval = (!polarity_inverse ? 0x2 : 0x1);
734+ rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_R_RFE_SEL_15,
735+ regval);
736+ break;
737+ case COEX_SWITCH_CTRL_BY_ANTDIV:
738+ rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
739+ rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
740+ rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89,
741+ ANTDIC_CTRL_PIN);
742+ break;
743+ case COEX_SWITCH_CTRL_BY_MAC:
744+ rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
745+
746+ regval = (!polarity_inverse ? 0x0 : 0x1);
747+ rtw_write8_mask(rtwdev, REG_PAD_CTRL1, BIT_SW_DPDT_SEL_DATA,
748+ regval);
749+ break;
750+ case COEX_SWITCH_CTRL_BY_FW:
751+ rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
752+ rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
753+ break;
754+ case COEX_SWITCH_CTRL_BY_BT:
755+ rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
756+ rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
757+ break;
758+ }
759+
760+ if (ctrl_type == COEX_SWITCH_CTRL_BY_BT) {
761+ rtw_write32_clr(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE1);
762+ rtw_write32_clr(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE2);
763+ } else {
764+ rtw_write32_set(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE1);
765+ rtw_write32_set(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE2);
766+ }
767+}
768+
769+static void rtw8821c_coex_cfg_gnt_fix(struct rtw_dev *rtwdev)
770+{}
771+
772+static void rtw8821c_coex_cfg_gnt_debug(struct rtw_dev *rtwdev)
773+{
774+ rtw_write32_clr(rtwdev, REG_PAD_CTRL1, BIT_BTGP_SPI_EN);
775+ rtw_write32_clr(rtwdev, REG_PAD_CTRL1, BIT_BTGP_JTAG_EN);
776+ rtw_write32_clr(rtwdev, REG_GPIO_MUXCFG, BIT_FSPI_EN);
777+ rtw_write32_clr(rtwdev, REG_PAD_CTRL1, BIT_LED1DIS);
778+ rtw_write32_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT_SDIO_INT);
779+ rtw_write32_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT_DBG_GNT_WL_BT);
780+}
781+
782+static void rtw8821c_coex_cfg_rfe_type(struct rtw_dev *rtwdev)
783+{
784+ struct rtw_coex *coex = &rtwdev->coex;
785+ struct rtw_coex_rfe *coex_rfe = &coex->rfe;
786+ struct rtw_efuse *efuse = &rtwdev->efuse;
787+
788+ coex_rfe->rfe_module_type = efuse->rfe_option;
789+ coex_rfe->ant_switch_polarity = 0;
790+ coex_rfe->ant_switch_exist = true;
791+ coex_rfe->wlg_at_btg = false;
792+
793+ switch (coex_rfe->rfe_module_type) {
794+ case 0:
795+ case 8:
796+ case 1:
797+ case 9: /* 1-Ant, Main, WLG */
798+ default: /* 2-Ant, DPDT, WLG */
799+ break;
800+ case 2:
801+ case 10: /* 1-Ant, Main, BTG */
802+ case 7:
803+ case 15: /* 2-Ant, DPDT, BTG */
804+ coex_rfe->wlg_at_btg = true;
805+ break;
806+ case 3:
807+ case 11: /* 1-Ant, Aux, WLG */
808+ coex_rfe->ant_switch_polarity = 1;
809+ break;
810+ case 4:
811+ case 12: /* 1-Ant, Aux, BTG */
812+ coex_rfe->wlg_at_btg = true;
813+ coex_rfe->ant_switch_polarity = 1;
814+ break;
815+ case 5:
816+ case 13: /* 2-Ant, no switch, WLG */
817+ case 6:
818+ case 14: /* 2-Ant, no antenna switch, WLG */
819+ coex_rfe->ant_switch_exist = false;
820+ break;
821+ }
822+}
823+
824+static void rtw8821c_coex_cfg_wl_tx_power(struct rtw_dev *rtwdev, u8 wl_pwr)
825+{
826+ struct rtw_coex *coex = &rtwdev->coex;
827+ struct rtw_coex_dm *coex_dm = &coex->dm;
828+ struct rtw_efuse *efuse = &rtwdev->efuse;
829+ bool share_ant = efuse->share_ant;
830+
831+ if (share_ant)
832+ return;
833+
834+ if (wl_pwr == coex_dm->cur_wl_pwr_lvl)
835+ return;
836+
837+ coex_dm->cur_wl_pwr_lvl = wl_pwr;
838+}
839+
840+static void rtw8821c_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain)
841+{}
842+
652843 static void
653844 rtw8821c_txagc_swing_offset(struct rtw_dev *rtwdev, u8 pwr_idx_offset,
654845 s8 pwr_idx_offset_lower,
@@ -1293,8 +1484,166 @@ static struct rtw_chip_ops rtw8821c_ops = { · 638 unmodified lines
12931484 .config_bfee = rtw8821c_bf_config_bfee,
12941485 .set_gid_table = rtw_bf_set_gid_table,
12951486 .cfg_csi_rate = rtw_bf_cfg_csi_rate,
1487+
1488+ .coex_set_init = rtw8821c_coex_cfg_init,
1489+ .coex_set_ant_switch = rtw8821c_coex_cfg_ant_switch,
1490+ .coex_set_gnt_fix = rtw8821c_coex_cfg_gnt_fix,
1491+ .coex_set_gnt_debug = rtw8821c_coex_cfg_gnt_debug,
1492+ .coex_set_rfe_type = rtw8821c_coex_cfg_rfe_type,
1493+ .coex_set_wl_tx_power = rtw8821c_coex_cfg_wl_tx_power,
1494+ .coex_set_wl_rx_gain = rtw8821c_coex_cfg_wl_rx_gain,
1495+};
1496+
1497+/* rssi in percentage % (dbm = % - 100) */
1498+static const u8 wl_rssi_step_8821c[] = {101, 45, 101, 40};
1499+static const u8 bt_rssi_step_8821c[] = {101, 101, 101, 101};
1500+
1501+/* Shared-Antenna Coex Table */
1502+static const struct coex_table_para table_sant_8821c[] = {
1503+ {0x55555555, 0x55555555}, /* case-0 */
1504+ {0x55555555, 0x55555555},
1505+ {0x66555555, 0x66555555},
1506+ {0xaaaaaaaa, 0xaaaaaaaa},
1507+ {0x5a5a5a5a, 0x5a5a5a5a},
1508+ {0xfafafafa, 0xfafafafa}, /* case-5 */
1509+ {0x6a5a5555, 0xaaaaaaaa},
1510+ {0x6a5a56aa, 0x6a5a56aa},
1511+ {0x6a5a5a5a, 0x6a5a5a5a},
1512+ {0x66555555, 0x5a5a5a5a},
1513+ {0x66555555, 0x6a5a5a5a}, /* case-10 */
1514+ {0x66555555, 0xaaaaaaaa},
1515+ {0x66555555, 0x6a5a5aaa},
1516+ {0x66555555, 0x6aaa6aaa},
1517+ {0x66555555, 0x6a5a5aaa},
1518+ {0x66555555, 0xaaaaaaaa}, /* case-15 */
1519+ {0xffff55ff, 0xfafafafa},
1520+ {0xffff55ff, 0x6afa5afa},
1521+ {0xaaffffaa, 0xfafafafa},
1522+ {0xaa5555aa, 0x5a5a5a5a},
1523+ {0xaa5555aa, 0x6a5a5a5a}, /* case-20 */
1524+ {0xaa5555aa, 0xaaaaaaaa},
1525+ {0xffffffff, 0x55555555},
1526+ {0xffffffff, 0x5a5a5a5a},
1527+ {0xffffffff, 0x5a5a5a5a},
1528+ {0xffffffff, 0x5a5a5aaa}, /* case-25 */
1529+ {0x55555555, 0x5a5a5a5a},
1530+ {0x55555555, 0xaaaaaaaa},
1531+ {0x66555555, 0x6a5a6a5a},
1532+ {0x66556655, 0x66556655},
1533+ {0x66556aaa, 0x6a5a6aaa}, /* case-30 */
1534+ {0xffffffff, 0x5aaa5aaa},
1535+ {0x56555555, 0x5a5a5aaa}
1536+};
1537+
1538+/* Non-Shared-Antenna Coex Table */
1539+static const struct coex_table_para table_nsant_8821c[] = {
1540+ {0xffffffff, 0xffffffff}, /* case-100 */
1541+ {0xffff55ff, 0xfafafafa},
1542+ {0x66555555, 0x66555555},
1543+ {0xaaaaaaaa, 0xaaaaaaaa},
1544+ {0x5a5a5a5a, 0x5a5a5a5a},
1545+ {0xffffffff, 0xffffffff}, /* case-105 */
1546+ {0x5afa5afa, 0x5afa5afa},
1547+ {0x55555555, 0xfafafafa},
1548+ {0x66555555, 0xfafafafa},
1549+ {0x66555555, 0x5a5a5a5a},
1550+ {0x66555555, 0x6a5a5a5a}, /* case-110 */
1551+ {0x66555555, 0xaaaaaaaa},
1552+ {0xffff55ff, 0xfafafafa},
1553+ {0xffff55ff, 0x5afa5afa},
1554+ {0xffff55ff, 0xaaaaaaaa},
1555+ {0xffff55ff, 0xffff55ff}, /* case-115 */
1556+ {0xaaffffaa, 0x5afa5afa},
1557+ {0xaaffffaa, 0xaaaaaaaa},
1558+ {0xffffffff, 0xfafafafa},
1559+ {0xffff55ff, 0xfafafafa},
1560+ {0xffffffff, 0xaaaaaaaa}, /* case-120 */
1561+ {0xffff55ff, 0x5afa5afa},
1562+ {0xffff55ff, 0x5afa5afa},
1563+ {0x55ff55ff, 0x55ff55ff}
1564+};
1565+
1566+/* Shared-Antenna TDMA */
1567+static const struct coex_tdma_para tdma_sant_8821c[] = {
1568+ { {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-0 */
1569+ { {0x61, 0x45, 0x03, 0x11, 0x11} }, /* case-1 */
1570+ { {0x61, 0x3a, 0x03, 0x11, 0x11} },
1571+ { {0x61, 0x35, 0x03, 0x11, 0x11} },
1572+ { {0x61, 0x20, 0x03, 0x11, 0x11} },
1573+ { {0x61, 0x3a, 0x03, 0x11, 0x11} }, /* case-5 */
1574+ { {0x61, 0x45, 0x03, 0x11, 0x10} },
1575+ { {0x61, 0x35, 0x03, 0x11, 0x10} },
1576+ { {0x61, 0x30, 0x03, 0x11, 0x10} },
1577+ { {0x61, 0x20, 0x03, 0x11, 0x10} },
1578+ { {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-10 */
1579+ { {0x61, 0x08, 0x03, 0x11, 0x15} },
1580+ { {0x61, 0x08, 0x03, 0x10, 0x14} },
1581+ { {0x51, 0x08, 0x03, 0x10, 0x54} },
1582+ { {0x51, 0x08, 0x03, 0x10, 0x55} },
1583+ { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-15 */
1584+ { {0x51, 0x45, 0x03, 0x10, 0x50} },
1585+ { {0x51, 0x3a, 0x03, 0x11, 0x50} },
1586+ { {0x51, 0x30, 0x03, 0x10, 0x50} },
1587+ { {0x51, 0x21, 0x03, 0x10, 0x50} },
1588+ { {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-20 */
1589+ { {0x51, 0x4a, 0x03, 0x10, 0x50} },
1590+ { {0x51, 0x08, 0x03, 0x30, 0x54} },
1591+ { {0x55, 0x08, 0x03, 0x10, 0x54} },
1592+ { {0x65, 0x10, 0x03, 0x11, 0x10} },
1593+ { {0x51, 0x10, 0x03, 0x10, 0x51} }, /* case-25 */
1594+ { {0x51, 0x21, 0x03, 0x10, 0x50} },
1595+ { {0x61, 0x08, 0x03, 0x11, 0x11} }
1596+};
1597+
1598+/* Non-Shared-Antenna TDMA */
1599+static const struct coex_tdma_para tdma_nsant_8821c[] = {
1600+ { {0x00, 0x00, 0x00, 0x40, 0x00} }, /* case-100 */
1601+ { {0x61, 0x45, 0x03, 0x11, 0x11} },
1602+ { {0x61, 0x25, 0x03, 0x11, 0x11} },
1603+ { {0x61, 0x35, 0x03, 0x11, 0x11} },
1604+ { {0x61, 0x20, 0x03, 0x11, 0x11} },
1605+ { {0x61, 0x10, 0x03, 0x11, 0x11} }, /* case-105 */
1606+ { {0x61, 0x45, 0x03, 0x11, 0x10} },
1607+ { {0x61, 0x30, 0x03, 0x11, 0x10} },
1608+ { {0x61, 0x30, 0x03, 0x11, 0x10} },
1609+ { {0x61, 0x20, 0x03, 0x11, 0x10} },
1610+ { {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-110 */
1611+ { {0x61, 0x10, 0x03, 0x11, 0x11} },
1612+ { {0x61, 0x08, 0x03, 0x10, 0x14} },
1613+ { {0x51, 0x08, 0x03, 0x10, 0x54} },
1614+ { {0x51, 0x08, 0x03, 0x10, 0x55} },
1615+ { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-115 */
1616+ { {0x51, 0x45, 0x03, 0x10, 0x50} },
1617+ { {0x51, 0x3a, 0x03, 0x10, 0x50} },
1618+ { {0x51, 0x30, 0x03, 0x10, 0x50} },
1619+ { {0x51, 0x21, 0x03, 0x10, 0x50} },
1620+ { {0x51, 0x21, 0x03, 0x10, 0x50} }, /* case-120 */
1621+ { {0x51, 0x10, 0x03, 0x10, 0x50} }
12961622 };
12971623
1624+static const struct coex_5g_afh_map afh_5g_8821c[] = { {0, 0, 0} };
1625+
1626+/* wl_tx_dec_power, bt_tx_dec_power, wl_rx_gain, bt_rx_lna_constrain */
1627+static const struct coex_rf_para rf_para_tx_8821c[] = {
1628+ {0, 0, false, 7}, /* for normal */
1629+ {0, 20, false, 7}, /* for WL-CPT */
1630+ {8, 17, true, 4},
1631+ {7, 18, true, 4},
1632+ {6, 19, true, 4},
1633+ {5, 20, true, 4}
1634+};
1635+
1636+static const struct coex_rf_para rf_para_rx_8821c[] = {
1637+ {0, 0, false, 7}, /* for normal */
1638+ {0, 20, false, 7}, /* for WL-CPT */
1639+ {3, 24, true, 5},
1640+ {2, 26, true, 5},
1641+ {1, 27, true, 5},
1642+ {0, 28, true, 5}
1643+};
1644+
1645+static_assert(ARRAY_SIZE(rf_para_tx_8821c) == ARRAY_SIZE(rf_para_rx_8821c));
1646+
12981647 static const u8 rtw8821c_pwrtrk_5gb_n[][RTW_PWR_TRK_TBL_SZ] = {
12991648 {0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 9, 10, 10,
13001649 11, 11, 12, 12, 12, 12, 12},
@@ -1371,7 +1720,7 @@ static const u8 rtw8821c_pwrtrk_2g_cck_a_p[] = { · 70 unmodified lines
13711720 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9
13721721 };
13731722
1374−const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = {
1723+static const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = {
13751724 .pwrtrk_5gb_n[0] = rtw8821c_pwrtrk_5gb_n[0],
13761725 .pwrtrk_5gb_n[1] = rtw8821c_pwrtrk_5gb_n[1],
13771726 .pwrtrk_5gb_n[2] = rtw8821c_pwrtrk_5gb_n[2],
@@ -1394,6 +1743,31 @@ const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = { · 16 unmodified lines
13941743 .pwrtrk_2g_ccka_p = rtw8821c_pwrtrk_2g_cck_a_p,
13951744 };
13961745
1746+static const struct rtw_reg_domain coex_info_hw_regs_8821c[] = {
1747+ {0xCB0, MASKDWORD, RTW_REG_DOMAIN_MAC32},
1748+ {0xCB4, MASKDWORD, RTW_REG_DOMAIN_MAC32},
1749+ {0xCBA, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
1750+ {0, 0, RTW_REG_DOMAIN_NL},
1751+ {0x430, MASKDWORD, RTW_REG_DOMAIN_MAC32},
1752+ {0x434, MASKDWORD, RTW_REG_DOMAIN_MAC32},
1753+ {0x42a, MASKLWORD, RTW_REG_DOMAIN_MAC16},
1754+ {0x426, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
1755+ {0x45e, BIT(3), RTW_REG_DOMAIN_MAC8},
1756+ {0x454, MASKLWORD, RTW_REG_DOMAIN_MAC16},
1757+ {0, 0, RTW_REG_DOMAIN_NL},
1758+ {0x4c, BIT(24) | BIT(23), RTW_REG_DOMAIN_MAC32},
1759+ {0x64, BIT(0), RTW_REG_DOMAIN_MAC8},
1760+ {0x4c6, BIT(4), RTW_REG_DOMAIN_MAC8},
1761+ {0x40, BIT(5), RTW_REG_DOMAIN_MAC8},
1762+ {0x1, RFREG_MASK, RTW_REG_DOMAIN_RF_A},
1763+ {0, 0, RTW_REG_DOMAIN_NL},
1764+ {0x550, MASKDWORD, RTW_REG_DOMAIN_MAC32},
1765+ {0x522, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
1766+ {0x953, BIT(1), RTW_REG_DOMAIN_MAC8},
1767+ {0xc50, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
1768+ {0x60A, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
1769+};
1770+
13971771 struct rtw_chip_info rtw8821c_hw_spec = {
13981772 .ops = &rtw8821c_ops,
13991773 .id = RTW_CHIP_TYPE_8821C,
@@ -1440,6 +1814,35 @@ struct rtw_chip_info rtw8821c_hw_spec = { · 40 unmodified lines
14401814 .iqk_threshold = 8,
14411815 .bfer_su_max_num = 2,
14421816 .bfer_mu_max_num = 1,
1817+
1818+ .coex_para_ver = 0x19092746,
1819+ .bt_desired_ver = 0x46,
1820+ .scbd_support = true,
1821+ .new_scbd10_def = false,
1822+ .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF,
1823+ .bt_rssi_type = COEX_BTRSSI_RATIO,
1824+ .ant_isolation = 15,
1825+ .rssi_tolerance = 2,
1826+ .wl_rssi_step = wl_rssi_step_8821c,
1827+ .bt_rssi_step = bt_rssi_step_8821c,
1828+ .table_sant_num = ARRAY_SIZE(table_sant_8821c),
1829+ .table_sant = table_sant_8821c,
1830+ .table_nsant_num = ARRAY_SIZE(table_nsant_8821c),
1831+ .table_nsant = table_nsant_8821c,
1832+ .tdma_sant_num = ARRAY_SIZE(tdma_sant_8821c),
1833+ .tdma_sant = tdma_sant_8821c,
1834+ .tdma_nsant_num = ARRAY_SIZE(tdma_nsant_8821c),
1835+ .tdma_nsant = tdma_nsant_8821c,
1836+ .wl_rf_para_num = ARRAY_SIZE(rf_para_tx_8821c),
1837+ .wl_rf_para_tx = rf_para_tx_8821c,
1838+ .wl_rf_para_rx = rf_para_rx_8821c,
1839+ .bt_afh_span_bw20 = 0x24,
1840+ .bt_afh_span_bw40 = 0x36,
1841+ .afh_5g_num = ARRAY_SIZE(afh_5g_8821c),
1842+ .afh_5g = afh_5g_8821c,
1843+
1844+ .coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8821c),
1845+ .coex_info_hw_regs = coex_info_hw_regs_8821c,
14431846 };
14441847 EXPORT_SYMBOL(rtw8821c_hw_spec);
14451848
drivers/net/wireless/realtek/rtw88/rtw8821c.h+26−0
@@ -160,6 +160,18 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) · 159 unmodified lines
160160 le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
161161 #define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \
162162 le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))
163+#define GET_PHY_STAT_P1_RXEVM_A(phy_stat) \
164+ le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(7, 0))
165+#define GET_PHY_STAT_P1_RXEVM_B(phy_stat) \
166+ le32_get_bits(*((__le32 *)(phy_stat) + 0x04), GENMASK(15, 8))
167+#define GET_PHY_STAT_P1_CFO_TAIL_A(phy_stat) \
168+ le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(7, 0))
169+#define GET_PHY_STAT_P1_CFO_TAIL_B(phy_stat) \
170+ le32_get_bits(*((__le32 *)(phy_stat) + 0x05), GENMASK(15, 8))
171+#define GET_PHY_STAT_P1_RXSNR_A(phy_stat) \
172+ le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(7, 0))
173+#define GET_PHY_STAT_P1_RXSNR_B(phy_stat) \
174+ le32_get_bits(*((__le32 *)(phy_stat) + 0x06), GENMASK(15, 8))
163175
164176 #define REG_INIRTS_RATE_SEL 0x0480
165177 #define REG_HTSTFWT 0x800
@@ -217,6 +229,20 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) · 51 unmodified lines
217229 #define REG_CCA_CCK 0xfcc
218230 #define REG_ANTWT 0x1904
219231 #define REG_IQKFAILMSK 0x1bf0
232+#define BIT_MASK_R_RFE_SEL_15 GENMASK(31, 28)
233+#define BIT_SDIO_INT BIT(18)
234+#define SAMPLE_RATE_MASK GENMASK(5, 0)
235+#define SAMPLE_RATE 0x5
236+#define BT_CNT_ENABLE 0x1
237+#define BIT_BCN_QUEUE BIT(3)
238+#define BCN_PRI_EN 0x1
239+#define PTA_CTRL_PIN 0x66
240+#define DPDT_CTRL_PIN 0x77
241+#define ANTDIC_CTRL_PIN 0x88
242+#define REG_CTRL_TYPE 0x67
243+#define BIT_CTRL_TYPE1 BIT(5)
244+#define BIT_CTRL_TYPE2 BIT(4)
245+#define CTRL_TYPE_MASK GENMASK(15, 8)
220246
221247 #define RF18_BAND_MASK (BIT(16) | BIT(9) | BIT(8))
222248 #define RF18_BAND_2G (0)
drivers/net/wireless/realtek/rtw88/tx.c+73−31
@@ -61,6 +61,8 @@ void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb) · 60 unmodified lines
6161 SET_TX_DESC_DISQSELSEQ(txdesc, pkt_info->dis_qselseq);
6262 SET_TX_DESC_EN_HWSEQ(txdesc, pkt_info->en_hwseq);
6363 SET_TX_DESC_HW_SSN_SEL(txdesc, pkt_info->hw_ssn_sel);
64+ SET_TX_DESC_NAVUSEHDR(txdesc, pkt_info->nav_use_hdr);
65+ SET_TX_DESC_BT_NULL(txdesc, pkt_info->bt_null);
6466 }
6567 EXPORT_SYMBOL(rtw_tx_fill_tx_desc);
6668
@@ -227,17 +229,58 @@ void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src) · 160 unmodified lines
227229 spin_unlock_irqrestore(&tx_report->q_lock, flags);
228230 }
229231
230−static void rtw_tx_mgmt_pkt_info_update(struct rtw_dev *rtwdev,
232+static void rtw_tx_pkt_info_update_rate(struct rtw_dev *rtwdev,
231233 struct rtw_tx_pkt_info *pkt_info,
232− struct ieee80211_sta *sta,
233234 struct sk_buff *skb)
234235 {
236+ if (rtwdev->hal.current_band_type == RTW_BAND_2G) {
237+ pkt_info->rate_id = RTW_RATEID_B_20M;
238+ pkt_info->rate = DESC_RATE1M;
239+ } else {
240+ pkt_info->rate_id = RTW_RATEID_G;
241+ pkt_info->rate = DESC_RATE6M;
242+ }
235243 pkt_info->use_rate = true;
236− pkt_info->rate_id = 6;
237244 pkt_info->dis_rate_fallback = true;
245+}
246+
247+static void rtw_tx_pkt_info_update_sec(struct rtw_dev *rtwdev,
248+ struct rtw_tx_pkt_info *pkt_info,
249+ struct sk_buff *skb)
250+{
251+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
252+ u8 sec_type = 0;
253+
254+ if (info && info->control.hw_key) {
255+ struct ieee80211_key_conf *key = info->control.hw_key;
256+
257+ switch (key->cipher) {
258+ case WLAN_CIPHER_SUITE_WEP40:
259+ case WLAN_CIPHER_SUITE_WEP104:
260+ case WLAN_CIPHER_SUITE_TKIP:
261+ sec_type = 0x01;
262+ break;
263+ case WLAN_CIPHER_SUITE_CCMP:
264+ sec_type = 0x03;
265+ break;
266+ default:
267+ break;
268+ }
269+ }
270+
271+ pkt_info->sec_type = sec_type;
272+}
273+
274+static void rtw_tx_mgmt_pkt_info_update(struct rtw_dev *rtwdev,
275+ struct rtw_tx_pkt_info *pkt_info,
276+ struct ieee80211_sta *sta,
277+ struct sk_buff *skb)
278+{
279+ rtw_tx_pkt_info_update_rate(rtwdev, pkt_info, skb);
238280 pkt_info->dis_qselseq = true;
239281 pkt_info->en_hwseq = true;
240282 pkt_info->hw_ssn_sel = 0;
283+ /* TODO: need to change hw port and hw ssn sel for multiple vifs */
241284 }
242285
243286 static void rtw_tx_data_pkt_info_update(struct rtw_dev *rtwdev,
@@ -312,7 +355,6 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 68 unmodified lines
312355 struct rtw_sta_info *si;
313356 struct ieee80211_vif *vif = NULL;
314357 __le16 fc = hdr->frame_control;
315− u8 sec_type = 0;
316358 bool bmc;
317359
318360 if (sta) {
@@ -325,23 +367,6 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 6 unmodified lines
325367 else if (ieee80211_is_data(fc))
326368 rtw_tx_data_pkt_info_update(rtwdev, pkt_info, sta, skb);
327369
328− if (info->control.hw_key) {
329− struct ieee80211_key_conf *key = info->control.hw_key;
330−
331− switch (key->cipher) {
332− case WLAN_CIPHER_SUITE_WEP40:
333− case WLAN_CIPHER_SUITE_WEP104:
334− case WLAN_CIPHER_SUITE_TKIP:
335− sec_type = 0x01;
336− break;
337− case WLAN_CIPHER_SUITE_CCMP:
338− sec_type = 0x03;
339− break;
340− default:
341− break;
342− }
343− }
344−
345370 bmc = is_broadcast_ether_addr(hdr->addr1) ||
346371 is_multicast_ether_addr(hdr->addr1);
347372
@@ -349,7 +374,7 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 1 unmodified line
349374 rtw_tx_report_enable(rtwdev, pkt_info);
350375
351376 pkt_info->bmc = bmc;
352− pkt_info->sec_type = sec_type;
377+ rtw_tx_pkt_info_update_sec(rtwdev, pkt_info, skb);
353378 pkt_info->tx_pkt_size = skb->len;
354379 pkt_info->offset = chip->tx_pkt_desc_sz;
355380 pkt_info->qsel = skb->priority;
@@ -359,24 +384,42 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 3 unmodified lines
359384 rtw_tx_stats(rtwdev, vif, skb);
360385 }
361386
362−void rtw_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
363− struct rtw_tx_pkt_info *pkt_info,
364− struct sk_buff *skb)
387+void rtw_tx_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
388+ struct rtw_tx_pkt_info *pkt_info,
389+ struct sk_buff *skb,
390+ enum rtw_rsvd_packet_type type)
365391 {
366392 struct rtw_chip_info *chip = rtwdev->chip;
367393 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
368394 bool bmc;
369395
396+ /* A beacon or dummy reserved page packet indicates that it is the first
397+ * reserved page, and the qsel of it will be set in each hci.
398+ */
399+ if (type != RSVD_BEACON && type != RSVD_DUMMY)
400+ pkt_info->qsel = TX_DESC_QSEL_MGMT;
401+
402+ rtw_tx_pkt_info_update_rate(rtwdev, pkt_info, skb);
403+
370404 bmc = is_broadcast_ether_addr(hdr->addr1) ||
371405 is_multicast_ether_addr(hdr->addr1);
372− pkt_info->use_rate = true;
373− pkt_info->rate_id = 6;
374− pkt_info->dis_rate_fallback = true;
375406 pkt_info->bmc = bmc;
376407 pkt_info->tx_pkt_size = skb->len;
377408 pkt_info->offset = chip->tx_pkt_desc_sz;
378− pkt_info->qsel = TX_DESC_QSEL_MGMT;
379409 pkt_info->ls = true;
410+ if (type == RSVD_PS_POLL) {
411+ pkt_info->nav_use_hdr = true;
412+ } else {
413+ pkt_info->dis_qselseq = true;
414+ pkt_info->en_hwseq = true;
415+ pkt_info->hw_ssn_sel = 0;
416+ }
417+ if (type == RSVD_QOS_NULL)
418+ pkt_info->bt_null = true;
419+
420+ rtw_tx_pkt_info_update_sec(rtwdev, pkt_info, skb);
421+
422+ /* TODO: need to change hw port and hw ssn sel for multiple vifs */
380423 }
381424
382425 struct sk_buff *
@@ -399,8 +442,7 @@ rtw_tx_write_data_rsvd_page_get(struct rtw_dev *rtwdev, · 16 unmodified lines
399442
400443 skb_reserve(skb, tx_pkt_desc_sz);
401444 skb_put_data(skb, buf, size);
402− pkt_info->tx_pkt_size = size;
403− pkt_info->offset = tx_pkt_desc_sz;
445+ rtw_tx_rsvd_page_pkt_info_update(rtwdev, pkt_info, skb, RSVD_BEACON);
404446
405447 return skb;
406448 }
drivers/net/wireless/realtek/rtw88/tx.h+10−3
@@ -59,6 +59,10 @@ · 58 unmodified lines
5959 le32p_replace_bits((__le32 *)(txdesc) + 0x08, value, BIT(15))
6060 #define SET_TX_DESC_HW_SSN_SEL(txdesc, value) \
6161 le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, GENMASK(7, 6))
62+#define SET_TX_DESC_NAVUSEHDR(txdesc, value) \
63+ le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(15))
64+#define SET_TX_DESC_BT_NULL(txdesc, value) \
65+ le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, BIT(23))
6266
6367 enum rtw_tx_desc_queue_select {
6468 TX_DESC_QSEL_TID0 = 0,
@@ -83,6 +87,8 @@ enum rtw_tx_desc_queue_select { · 18 unmodified lines
8387 TX_DESC_QSEL_H2C = 19,
8488 };
8589
90+enum rtw_rsvd_packet_type;
91+
8692 void rtw_tx(struct rtw_dev *rtwdev,
8793 struct ieee80211_tx_control *control,
8894 struct sk_buff *skb);
@@ -96,9 +102,10 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 7 unmodified lines
96102 void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb);
97103 void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn);
98104 void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src);
99−void rtw_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
100− struct rtw_tx_pkt_info *pkt_info,
101− struct sk_buff *skb);
105+void rtw_tx_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
106+ struct rtw_tx_pkt_info *pkt_info,
107+ struct sk_buff *skb,
108+ enum rtw_rsvd_packet_type type);
102109 struct sk_buff *
103110 rtw_tx_write_data_rsvd_page_get(struct rtw_dev *rtwdev,
104111 struct rtw_tx_pkt_info *pkt_info,
drivers/net/wireless/ti/wl1251/event.c+1−1
@@ -70,7 +70,7 @@ static int wl1251_event_ps_report(struct wl1251 *wl, · 69 unmodified lines
7070 break;
7171 }
7272
73− return 0;
73+ return ret;
7474 }
7575
7676 static void wl1251_event_mbox_dump(struct event_mailbox *mbox)
include/linux/mmc/sdio_ids.h+3−0
@@ -105,6 +105,9 @@ · 104 unmodified lines
105105 #define SDIO_DEVICE_ID_MEDIATEK_MT7663 0x7663
106106 #define SDIO_DEVICE_ID_MEDIATEK_MT7668 0x7668
107107
108+#define SDIO_VENDOR_ID_MICROCHIP_WILC 0x0296
109+#define SDIO_DEVICE_ID_MICROCHIP_WILC1000 0x5347
110+
108111 #define SDIO_VENDOR_ID_SIANO 0x039a
109112 #define SDIO_DEVICE_ID_SIANO_NOVA_B0 0x0201
110113 #define SDIO_DEVICE_ID_SIANO_NICE 0x0202

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t