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
78solution intended to be used for purposes other than development, please78solution intended to be used for purposes other than development, please
79obtain a tested driver from Intel Customer Support at:79obtain a tested driver from Intel Customer Support at:
80 80
81http://www.intel.com/support/wireless/sb/CS-006408.htm81https://www.intel.com/support/wireless/sb/CS-006408.htm
82 82
831. Introduction831. Introduction
84===============84===============
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
122static int bcma_gpio_irq_init(struct bcma_drv_cc *cc)122static int bcma_gpio_irq_init(struct bcma_drv_cc *cc)
123{123{
124 struct gpio_chip *chip = &cc->gpio;124 struct gpio_chip *chip = &cc->gpio;
125 struct gpio_irq_chip *girq = &chip->irq;
125 int hwirq, err;126 int hwirq, err;
126 127
127 if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC)128 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
136 bcma_chipco_gpio_intmask(cc, ~0, 0);137 bcma_chipco_gpio_intmask(cc, ~0, 0);
137 bcma_cc_set32(cc, BCMA_CC_IRQMASK, BCMA_CC_IRQ_GPIO);138 bcma_cc_set32(cc, BCMA_CC_IRQMASK, BCMA_CC_IRQ_GPIO);
138 139
139 err = gpiochip_irqchip_add(chip,140 girq->chip = &bcma_gpio_irq_chip;
140 &bcma_gpio_irq_chip,141 /* This will let us handle the parent IRQ in the driver */
141 0,142 girq->parent_handler = NULL;
142 handle_simple_irq,143 girq->num_parents = 0;
143 IRQ_TYPE_NONE);144 girq->parents = NULL;
144 if (err) {145 girq->default_type = IRQ_TYPE_NONE;
145 free_irq(hwirq, cc);146 girq->handler = handle_simple_irq;
146 return err;
147 }
148 147
149 return 0;148 return 0;
150}149}
@@ -212,13 +211,13 @@ int bcma_gpio_init(struct bcma_drv_cc *cc) · 61 unmodified lines
212 else211 else
213 chip->base = -1;212 chip->base = -1;
214 213
215 err = gpiochip_add_data(chip, cc);214 err = bcma_gpio_irq_init(cc);
216 if (err)215 if (err)
217 return err;216 return err;
218 217
219 err = bcma_gpio_irq_init(cc);218 err = gpiochip_add_data(chip, cc);
220 if (err) {219 if (err) {
221 gpiochip_remove(chip);220 bcma_gpio_irq_exit(cc);
222 return err;221 return err;
223 }222 }
224 223
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
219static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,219static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
220 u32 type, u8 port)220 u32 type, u8 port)
221{221{
222 u32 addrl, addrh, sizeh = 0;222 u32 addrl;
223 u32 size;223 u32 size;
224 224
225 u32 ent = bcma_erom_get_ent(bus, eromptr);225 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
233 233
234 addrl = ent & SCAN_ADDR_ADDR;234 addrl = ent & SCAN_ADDR_ADDR;
235 if (ent & SCAN_ADDR_AG32)235 if (ent & SCAN_ADDR_AG32)
236 addrh = bcma_erom_get_ent(bus, eromptr);236 bcma_erom_get_ent(bus, eromptr);
237 else
238 addrh = 0;
239 237
240 if ((ent & SCAN_ADDR_SZ) == SCAN_ADDR_SZ_SZD) {238 if ((ent & SCAN_ADDR_SZ) == SCAN_ADDR_SZ_SZD) {
241 size = bcma_erom_get_ent(bus, eromptr);239 size = bcma_erom_get_ent(bus, eromptr);
242 if (size & SCAN_SIZE_SG32)240 if (size & SCAN_SIZE_SG32)
243 sizeh = bcma_erom_get_ent(bus, eromptr);241 bcma_erom_get_ent(bus, eromptr);
244 }242 }
245 243
246 return addrl;244 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
734}734}
735 735
736/* DummyTransmission function, as documented on736/* DummyTransmission function, as documented on
737 * http://bcm-v4.sipsolutions.net/802.11/DummyTransmission737 * https://bcm-v4.sipsolutions.net/802.11/DummyTransmission
738 */738 */
739void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)739void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
740{740{
@@ -1198,7 +1198,7 @@ void b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags) · 457 unmodified lines
1198 }1198 }
1199}1199}
1200 1200
1201/* http://bcm-v4.sipsolutions.net/802.11/PHY/BmacCorePllReset */1201/* https://bcm-v4.sipsolutions.net/802.11/PHY/BmacCorePllReset */
1202void b43_wireless_core_phy_pll_reset(struct b43_wldev *dev)1202void b43_wireless_core_phy_pll_reset(struct b43_wldev *dev)
1203{1203{
1204 struct bcma_drv_cc *bcma_cc __maybe_unused;1204 struct bcma_drv_cc *bcma_cc __maybe_unused;
@@ -2290,7 +2290,7 @@ err_format: · 1085 unmodified lines
2290 return -EPROTO;2290 return -EPROTO;
2291}2291}
2292 2292
2293/* http://bcm-v4.sipsolutions.net/802.11/Init/Firmware */2293/* https://bcm-v4.sipsolutions.net/802.11/Init/Firmware */
2294static int b43_try_request_fw(struct b43_request_fw_context *ctx)2294static int b43_try_request_fw(struct b43_request_fw_context *ctx)
2295{2295{
2296 struct b43_wldev *dev = ctx->dev;2296 struct b43_wldev *dev = ctx->dev;
@@ -2843,7 +2843,7 @@ static int b43_upload_initvals_band(struct b43_wldev *dev) · 546 unmodified lines
2843}2843}
2844 2844
2845/* Initialize the GPIOs2845/* Initialize the GPIOs
2846 * http://bcm-specs.sipsolutions.net/GPIO2846 * https://bcm-specs.sipsolutions.net/GPIO
2847 */2847 */
2848 2848
2849#ifdef CONFIG_B43_SSB2849#ifdef CONFIG_B43_SSB
@@ -2971,7 +2971,7 @@ void b43_mac_enable(struct b43_wldev *dev) · 121 unmodified lines
2971 }2971 }
2972}2972}
2973 2973
2974/* http://bcm-specs.sipsolutions.net/SuspendMAC */2974/* https://bcm-specs.sipsolutions.net/SuspendMAC */
2975void b43_mac_suspend(struct b43_wldev *dev)2975void b43_mac_suspend(struct b43_wldev *dev)
2976{2976{
2977 int i;2977 int i;
@@ -3004,7 +3004,7 @@ out: · 26 unmodified lines
3004 dev->mac_suspended++;3004 dev->mac_suspended++;
3005}3005}
3006 3006
3007/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */3007/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/MacPhyClkSet */
3008void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on)3008void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on)
3009{3009{
3010 u32 tmp;3010 u32 tmp;
@@ -3231,7 +3231,7 @@ static void b43_chip_exit(struct b43_wldev *dev) · 220 unmodified lines
3231}3231}
3232 3232
3233/* Initialize the chip3233/* Initialize the chip
3234 * http://bcm-specs.sipsolutions.net/ChipInit3234 * https://bcm-specs.sipsolutions.net/ChipInit
3235 */3235 */
3236static int b43_chip_init(struct b43_wldev *dev)3236static int b43_chip_init(struct b43_wldev *dev)
3237{3237{
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
559 return dev->phy.chandef->width == NL80211_CHAN_WIDTH_40;559 return dev->phy.chandef->width == NL80211_CHAN_WIDTH_40;
560}560}
561 561
562/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */562/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */
563void b43_phy_force_clock(struct b43_wldev *dev, bool force)563void b43_phy_force_clock(struct b43_wldev *dev, bool force)
564{564{
565 u32 tmp;565 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
357 b43_dummy_transmission(dev, false, true);357 b43_dummy_transmission(dev, false, true);
358}358}
359 359
360/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */360/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
361static void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val)361static void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val)
362{362{
363 b43_phy_write(dev, B43_PHY_NRSSILT_CTRL, offset);363 b43_phy_write(dev, B43_PHY_NRSSILT_CTRL, offset);
364 b43_phy_write(dev, B43_PHY_NRSSILT_DATA, (u16) val);364 b43_phy_write(dev, B43_PHY_NRSSILT_DATA, (u16) val);
365}365}
366 366
367/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */367/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
368static s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset)368static s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset)
369{369{
370 u16 val;370 u16 val;
@@ -375,7 +375,7 @@ static s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset) · 4 unmodified lines
375 return (s16) val;375 return (s16) val;
376}376}
377 377
378/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */378/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
379static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)379static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)
380{380{
381 u16 i;381 u16 i;
@@ -389,7 +389,7 @@ static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val) · 7 unmodified lines
389 }389 }
390}390}
391 391
392/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */392/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
393static void b43_nrssi_mem_update(struct b43_wldev *dev)393static void b43_nrssi_mem_update(struct b43_wldev *dev)
394{394{
395 struct b43_phy_g *gphy = dev->phy.g;395 struct b43_phy_g *gphy = dev->phy.g;
@@ -1575,7 +1575,7 @@ static void b43_phy_initb5(struct b43_wldev *dev) · 1179 unmodified lines
1575 b43_write16(dev, 0x03E4, (b43_read16(dev, 0x03E4) & 0xFFC0) | 0x0004);1575 b43_write16(dev, 0x03E4, (b43_read16(dev, 0x03E4) & 0xFFC0) | 0x0004);
1576}1576}
1577 1577
1578/* http://bcm-v4.sipsolutions.net/802.11/PHY/Init/B6 */1578/* https://bcm-v4.sipsolutions.net/802.11/PHY/Init/B6 */
1579static void b43_phy_initb6(struct b43_wldev *dev)1579static void b43_phy_initb6(struct b43_wldev *dev)
1580{1580{
1581 struct b43_phy *phy = &dev->phy;1581 struct b43_phy *phy = &dev->phy;
@@ -2746,7 +2746,7 @@ static int b43_gphy_op_interf_mitigation(struct b43_wldev *dev, · 1164 unmodified lines
2746 return 0;2746 return 0;
2747}2747}
2748 2748
2749/* http://bcm-specs.sipsolutions.net/EstimatePowerOut2749/* https://bcm-specs.sipsolutions.net/EstimatePowerOut
2750 * This function converts a TSSI value to dBm in Q5.22750 * This function converts a TSSI value to dBm in Q5.2
2751 */2751 */
2752static s8 b43_gphy_estimate_power_out(struct b43_wldev *dev, s8 tssi)2752static 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
1018 phy->ht = NULL;1018 phy->ht = NULL;
1019}1019}
1020 1020
1021/* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */1021/* https://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
1022static void b43_phy_ht_op_software_rfkill(struct b43_wldev *dev,1022static void b43_phy_ht_op_software_rfkill(struct b43_wldev *dev,
1023 bool blocked)1023 bool blocked)
1024{1024{
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
70 dev->phy.lp = NULL;70 dev->phy.lp = NULL;
71}71}
72 72
73/* http://bcm-v4.sipsolutions.net/802.11/PHY/LP/ReadBandSrom */73/* https://bcm-v4.sipsolutions.net/802.11/PHY/LP/ReadBandSrom */
74static void lpphy_read_band_sprom(struct b43_wldev *dev)74static void lpphy_read_band_sprom(struct b43_wldev *dev)
75{75{
76 struct ssb_sprom *sprom = dev->dev->bus_sprom;76 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
98 (dev->phy.n->ipa5g_on && band == NL80211_BAND_5GHZ));98 (dev->phy.n->ipa5g_on && band == NL80211_BAND_5GHZ));
99}99}
100 100
101/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */101/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */
102static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev)102static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev)
103{103{
104 return (b43_phy_read(dev, B43_NPHY_RFSEQCA) & B43_NPHY_RFSEQCA_RXEN) >>104 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
109 * RF (just without b43_nphy_rf_ctl_intc_override)109 * RF (just without b43_nphy_rf_ctl_intc_override)
110 **************************************************/110 **************************************************/
111 111
112/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ForceRFSeq */112/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ForceRFSeq */
113static void b43_nphy_force_rf_sequence(struct b43_wldev *dev,113static void b43_nphy_force_rf_sequence(struct b43_wldev *dev,
114 enum b43_nphy_rf_sequence seq)114 enum b43_nphy_rf_sequence seq)
115{115{
@@ -146,7 +146,7 @@ static void b43_nphy_rf_ctl_override_rev19(struct b43_wldev *dev, u16 field, · 30 unmodified lines
146 /* TODO */146 /* TODO */
147}147}
148 148
149/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverrideRev7 */149/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverrideRev7 */
150static void b43_nphy_rf_ctl_override_rev7(struct b43_wldev *dev, u16 field,150static void b43_nphy_rf_ctl_override_rev7(struct b43_wldev *dev, u16 field,
151 u16 value, u8 core, bool off,151 u16 value, u8 core, bool off,
152 u8 override)152 u8 override)
@@ -193,7 +193,7 @@ static void b43_nphy_rf_ctl_override_rev7(struct b43_wldev *dev, u16 field, · 40 unmodified lines
193 }193 }
194}194}
195 195
196/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverideOneToMany */196/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverideOneToMany */
197static void b43_nphy_rf_ctl_override_one_to_many(struct b43_wldev *dev,197static void b43_nphy_rf_ctl_override_one_to_many(struct b43_wldev *dev,
198 enum n_rf_ctl_over_cmd cmd,198 enum n_rf_ctl_over_cmd cmd,
199 u16 value, u8 core, bool off)199 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
237 }237 }
238}238}
239 239
240/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverride */240/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverride */
241static void b43_nphy_rf_ctl_override(struct b43_wldev *dev, u16 field,241static void b43_nphy_rf_ctl_override(struct b43_wldev *dev, u16 field,
242 u16 value, u8 core, bool off)242 u16 value, u8 core, bool off)
243{243{
@@ -382,7 +382,7 @@ static void b43_nphy_rf_ctl_intc_override_rev7(struct b43_wldev *dev, · 138 unmodified lines
382 }382 }
383}383}
384 384
385/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlIntcOverride */385/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlIntcOverride */
386static void b43_nphy_rf_ctl_intc_override(struct b43_wldev *dev,386static void b43_nphy_rf_ctl_intc_override(struct b43_wldev *dev,
387 enum n_intc_override intc_override,387 enum n_intc_override intc_override,
388 u16 value, u8 core)388 u16 value, u8 core)
@@ -490,7 +490,7 @@ static void b43_nphy_rf_ctl_intc_override(struct b43_wldev *dev, · 101 unmodified lines
490 * Various PHY ops490 * Various PHY ops
491 **************************************************/491 **************************************************/
492 492
493/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */493/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */
494static void b43_nphy_write_clip_detection(struct b43_wldev *dev,494static void b43_nphy_write_clip_detection(struct b43_wldev *dev,
495 const u16 *clip_st)495 const u16 *clip_st)
496{496{
@@ -498,14 +498,14 @@ static void b43_nphy_write_clip_detection(struct b43_wldev *dev, · 1 unmodified line
498 b43_phy_write(dev, B43_NPHY_C2_CLIP1THRES, clip_st[1]);498 b43_phy_write(dev, B43_NPHY_C2_CLIP1THRES, clip_st[1]);
499}499}
500 500
501/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */501/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */
502static void b43_nphy_read_clip_detection(struct b43_wldev *dev, u16 *clip_st)502static void b43_nphy_read_clip_detection(struct b43_wldev *dev, u16 *clip_st)
503{503{
504 clip_st[0] = b43_phy_read(dev, B43_NPHY_C1_CLIP1THRES);504 clip_st[0] = b43_phy_read(dev, B43_NPHY_C1_CLIP1THRES);
505 clip_st[1] = b43_phy_read(dev, B43_NPHY_C2_CLIP1THRES);505 clip_st[1] = b43_phy_read(dev, B43_NPHY_C2_CLIP1THRES);
506}506}
507 507
508/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */508/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */
509static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val)509static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val)
510{510{
511 u16 tmp;511 u16 tmp;
@@ -526,7 +526,7 @@ static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val) · 14 unmodified lines
526 return tmp;526 return tmp;
527}527}
528 528
529/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */529/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */
530static void b43_nphy_reset_cca(struct b43_wldev *dev)530static void b43_nphy_reset_cca(struct b43_wldev *dev)
531{531{
532 u16 bbcfg;532 u16 bbcfg;
@@ -540,7 +540,7 @@ static void b43_nphy_reset_cca(struct b43_wldev *dev) · 7 unmodified lines
540 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);540 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
541}541}
542 542
543/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/carriersearch */543/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/carriersearch */
544static void b43_nphy_stay_in_carrier_search(struct b43_wldev *dev, bool enable)544static void b43_nphy_stay_in_carrier_search(struct b43_wldev *dev, bool enable)
545{545{
546 struct b43_phy *phy = &dev->phy;546 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
564 }564 }
565}565}
566 566
567/* http://bcm-v4.sipsolutions.net/PHY/N/Read_Lpf_Bw_Ctl */567/* https://bcm-v4.sipsolutions.net/PHY/N/Read_Lpf_Bw_Ctl */
568static u16 b43_nphy_read_lpf_ctl(struct b43_wldev *dev, u16 offset)568static u16 b43_nphy_read_lpf_ctl(struct b43_wldev *dev, u16 offset)
569{569{
570 if (!offset)570 if (!offset)
@@ -572,7 +572,7 @@ static u16 b43_nphy_read_lpf_ctl(struct b43_wldev *dev, u16 offset) · 1 unmodified line
572 return b43_ntab_read(dev, B43_NTAB16(7, offset)) & 0x7;572 return b43_ntab_read(dev, B43_NTAB16(7, offset)) & 0x7;
573}573}
574 574
575/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/AdjustLnaGainTbl */575/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/AdjustLnaGainTbl */
576static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)576static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)
577{577{
578 struct b43_phy_n *nphy = dev->phy.n;578 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
628 b43_nphy_stay_in_carrier_search(dev, 0);628 b43_nphy_stay_in_carrier_search(dev, 0);
629}629}
630 630
631/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRfSeq */631/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRfSeq */
632static void b43_nphy_set_rf_sequence(struct b43_wldev *dev, u8 cmd,632static void b43_nphy_set_rf_sequence(struct b43_wldev *dev, u8 cmd,
633 u8 *events, u8 *delays, u8 length)633 u8 *events, u8 *delays, u8 length)
634{634{
@@ -805,7 +805,7 @@ static void b43_radio_2057_setup(struct b43_wldev *dev, · 170 unmodified lines
805}805}
806 806
807/* Calibrate resistors in LPF of PLL?807/* Calibrate resistors in LPF of PLL?
808 * http://bcm-v4.sipsolutions.net/PHY/radio205x_rcal808 * https://bcm-v4.sipsolutions.net/PHY/radio205x_rcal
809 */809 */
810static u8 b43_radio_2057_rcal(struct b43_wldev *dev)810static u8 b43_radio_2057_rcal(struct b43_wldev *dev)
811{811{
@@ -919,7 +919,7 @@ static u8 b43_radio_2057_rcal(struct b43_wldev *dev) · 107 unmodified lines
919}919}
920 920
921/* Calibrate the internal RC oscillator?921/* Calibrate the internal RC oscillator?
922 * http://bcm-v4.sipsolutions.net/PHY/radio2057_rccal922 * https://bcm-v4.sipsolutions.net/PHY/radio2057_rccal
923 */923 */
924static u16 b43_radio_2057_rccal(struct b43_wldev *dev)924static u16 b43_radio_2057_rccal(struct b43_wldev *dev)
925{925{
@@ -1030,7 +1030,7 @@ static void b43_radio_2057_init_post(struct b43_wldev *dev) · 104 unmodified lines
1030 b43_radio_mask(dev, R2057_RFPLL_MASTER, ~0x8);1030 b43_radio_mask(dev, R2057_RFPLL_MASTER, ~0x8);
1031}1031}
1032 1032
1033/* http://bcm-v4.sipsolutions.net/802.11/Radio/2057/Init */1033/* https://bcm-v4.sipsolutions.net/802.11/Radio/2057/Init */
1034static void b43_radio_2057_init(struct b43_wldev *dev)1034static void b43_radio_2057_init(struct b43_wldev *dev)
1035{1035{
1036 b43_radio_2057_init_pre(dev);1036 b43_radio_2057_init_pre(dev);
@@ -1117,7 +1117,7 @@ static void b43_chantab_radio_2056_upload(struct b43_wldev *dev, · 80 unmodified lines
1117 e->radio_tx1_mixg_boost_tune);1117 e->radio_tx1_mixg_boost_tune);
1118}1118}
1119 1119
1120/* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2056Setup */1120/* https://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2056Setup */
1121static void b43_radio_2056_setup(struct b43_wldev *dev,1121static void b43_radio_2056_setup(struct b43_wldev *dev,
1122 const struct b43_nphy_channeltab_entry_rev3 *e)1122 const struct b43_nphy_channeltab_entry_rev3 *e)
1123{1123{
@@ -1356,7 +1356,7 @@ static void b43_radio_init2056_post(struct b43_wldev *dev) · 232 unmodified lines
1356 1356
1357/*1357/*
1358 * Initialize a Broadcom 2056 N-radio1358 * Initialize a Broadcom 2056 N-radio
1359 * http://bcm-v4.sipsolutions.net/802.11/Radio/2056/Init1359 * https://bcm-v4.sipsolutions.net/802.11/Radio/2056/Init
1360 */1360 */
1361static void b43_radio_init2056(struct b43_wldev *dev)1361static void b43_radio_init2056(struct b43_wldev *dev)
1362{1362{
@@ -1406,7 +1406,7 @@ static void b43_chantab_radio_upload(struct b43_wldev *dev, · 43 unmodified lines
1406 b43_radio_write(dev, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim);1406 b43_radio_write(dev, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim);
1407}1407}
1408 1408
1409/* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2055Setup */1409/* https://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2055Setup */
1410static void b43_radio_2055_setup(struct b43_wldev *dev,1410static void b43_radio_2055_setup(struct b43_wldev *dev,
1411 const struct b43_nphy_channeltab_entry_rev2 *e)1411 const struct b43_nphy_channeltab_entry_rev2 *e)
1412{1412{
@@ -1480,7 +1480,7 @@ static void b43_radio_init2055_post(struct b43_wldev *dev) · 67 unmodified lines
1480 1480
1481/*1481/*
1482 * Initialize a Broadcom 2055 N-radio1482 * Initialize a Broadcom 2055 N-radio
1483 * http://bcm-v4.sipsolutions.net/802.11/Radio/2055/Init1483 * https://bcm-v4.sipsolutions.net/802.11/Radio/2055/Init
1484 */1484 */
1485static void b43_radio_init2055(struct b43_wldev *dev)1485static void b43_radio_init2055(struct b43_wldev *dev)
1486{1486{
@@ -1499,7 +1499,7 @@ static void b43_radio_init2055(struct b43_wldev *dev) · 12 unmodified lines
1499 * Samples1499 * Samples
1500 **************************************************/1500 **************************************************/
1501 1501
1502/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/LoadSampleTable */1502/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/LoadSampleTable */
1503static int b43_nphy_load_samples(struct b43_wldev *dev,1503static int b43_nphy_load_samples(struct b43_wldev *dev,
1504 struct cordic_iq *samples, u16 len) {1504 struct cordic_iq *samples, u16 len) {
1505 struct b43_phy_n *nphy = dev->phy.n;1505 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
1526 return 0;1526 return 0;
1527}1527}
1528 1528
1529/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GenLoadSamples */1529/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/GenLoadSamples */
1530static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max,1530static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max,
1531 bool test)1531 bool test)
1532{1532{
@@ -1569,7 +1569,7 @@ static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max, · 36 unmodified lines
1569 return (i < 0) ? 0 : len;1569 return (i < 0) ? 0 : len;
1570}1570}
1571 1571
1572/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RunSamples */1572/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RunSamples */
1573static void b43_nphy_run_samples(struct b43_wldev *dev, u16 samps, u16 loops,1573static void b43_nphy_run_samples(struct b43_wldev *dev, u16 samps, u16 loops,
1574 u16 wait, bool iqmode, bool dac_test,1574 u16 wait, bool iqmode, bool dac_test,
1575 bool modify_bbmult)1575 bool modify_bbmult)
@@ -1650,7 +1650,7 @@ static void b43_nphy_run_samples(struct b43_wldev *dev, u16 samps, u16 loops, · 74 unmodified lines
1650 * RSSI1650 * RSSI
1651 **************************************************/1651 **************************************************/
1652 1652
1653/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ScaleOffsetRssi */1653/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ScaleOffsetRssi */
1654static void b43_nphy_scale_offset_rssi(struct b43_wldev *dev, u16 scale,1654static void b43_nphy_scale_offset_rssi(struct b43_wldev *dev, u16 scale,
1655 s8 offset, u8 core,1655 s8 offset, u8 core,
1656 enum n_rail_type rail,1656 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
1895 }1895 }
1896}1896}
1897 1897
1898/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSISel */1898/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSISel */
1899static void b43_nphy_rssi_select(struct b43_wldev *dev, u8 code,1899static void b43_nphy_rssi_select(struct b43_wldev *dev, u8 code,
1900 enum n_rssi_type type)1900 enum n_rssi_type type)
1901{1901{
@@ -1907,7 +1907,7 @@ static void b43_nphy_rssi_select(struct b43_wldev *dev, u8 code, · 5 unmodified lines
1907 b43_nphy_rev2_rssi_select(dev, code, type);1907 b43_nphy_rev2_rssi_select(dev, code, type);
1908}1908}
1909 1909
1910/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRssi2055Vcm */1910/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRssi2055Vcm */
1911static void b43_nphy_set_rssi_2055_vcm(struct b43_wldev *dev,1911static void b43_nphy_set_rssi_2055_vcm(struct b43_wldev *dev,
1912 enum n_rssi_type rssi_type, u8 *buf)1912 enum n_rssi_type rssi_type, u8 *buf)
1913{1913{
@@ -1936,7 +1936,7 @@ static void b43_nphy_set_rssi_2055_vcm(struct b43_wldev *dev, · 22 unmodified lines
1936 }1936 }
1937}1937}
1938 1938
1939/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/PollRssi */1939/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/PollRssi */
1940static int b43_nphy_poll_rssi(struct b43_wldev *dev, enum n_rssi_type rssi_type,1940static int b43_nphy_poll_rssi(struct b43_wldev *dev, enum n_rssi_type rssi_type,
1941 s32 *buf, u8 nsamp)1941 s32 *buf, u8 nsamp)
1942{1942{
@@ -2025,7 +2025,7 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, enum n_rssi_type rssi_type, · 82 unmodified lines
2025 return out;2025 return out;
2026}2026}
2027 2027
2028/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */2028/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
2029static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)2029static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
2030{2030{
2031 struct b43_phy *phy = &dev->phy;2031 struct b43_phy *phy = &dev->phy;
@@ -2287,7 +2287,7 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev) · 255 unmodified lines
2287 b43_nphy_write_clip_detection(dev, clip_state);2287 b43_nphy_write_clip_detection(dev, clip_state);
2288}2288}
2289 2289
2290/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */2290/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */
2291static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, enum n_rssi_type type)2291static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, enum n_rssi_type type)
2292{2292{
2293 int i, j, vcm;2293 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
2453 2453
2454/*2454/*
2455 * RSSI Calibration2455 * RSSI Calibration
2456 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal2456 * https://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal
2457 */2457 */
2458static void b43_nphy_rssi_cal(struct b43_wldev *dev)2458static void b43_nphy_rssi_cal(struct b43_wldev *dev)
2459{2459{
@@ -2680,7 +2680,7 @@ static void b43_nphy_gain_ctl_workarounds_rev1_2(struct b43_wldev *dev) · 220 unmodified lines
2680 b43_phy_maskset(dev, B43_PHY_N(0xC5D), 0xFF80, 4);2680 b43_phy_maskset(dev, B43_PHY_N(0xC5D), 0xFF80, 4);
2681}2681}
2682 2682
2683/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */2683/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */
2684static void b43_nphy_gain_ctl_workarounds(struct b43_wldev *dev)2684static void b43_nphy_gain_ctl_workarounds(struct b43_wldev *dev)
2685{2685{
2686 if (dev->phy.rev >= 19)2686 if (dev->phy.rev >= 19)
@@ -3433,7 +3433,7 @@ static void b43_nphy_workarounds_rev1_2(struct b43_wldev *dev) · 746 unmodified lines
3433 B43_NPHY_FINERX2_CGC_DECGC);3433 B43_NPHY_FINERX2_CGC_DECGC);
3434}3434}
3435 3435
3436/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */3436/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */
3437static void b43_nphy_workarounds(struct b43_wldev *dev)3437static void b43_nphy_workarounds(struct b43_wldev *dev)
3438{3438{
3439 struct b43_phy *phy = &dev->phy;3439 struct b43_phy *phy = &dev->phy;
@@ -3468,7 +3468,7 @@ static void b43_nphy_workarounds(struct b43_wldev *dev) · 28 unmodified lines
3468 3468
3469/*3469/*
3470 * Transmits a known value for LO calibration3470 * Transmits a known value for LO calibration
3471 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone3471 * https://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone
3472 */3472 */
3473static int b43_nphy_tx_tone(struct b43_wldev *dev, u32 freq, u16 max_val,3473static int b43_nphy_tx_tone(struct b43_wldev *dev, u32 freq, u16 max_val,
3474 bool iqmode, bool dac_test, bool modify_bbmult)3474 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
3481 return 0;3481 return 0;
3482}3482}
3483 3483
3484/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */3484/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */
3485static void b43_nphy_update_txrx_chain(struct b43_wldev *dev)3485static void b43_nphy_update_txrx_chain(struct b43_wldev *dev)
3486{3486{
3487 struct b43_phy_n *nphy = dev->phy.n;3487 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
3509 ~B43_NPHY_RFSEQMODE_CAOVER);3509 ~B43_NPHY_RFSEQMODE_CAOVER);
3510}3510}
3511 3511
3512/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */3512/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */
3513static void b43_nphy_stop_playback(struct b43_wldev *dev)3513static void b43_nphy_stop_playback(struct b43_wldev *dev)
3514{3514{
3515 struct b43_phy *phy = &dev->phy;3515 struct b43_phy *phy = &dev->phy;
@@ -3546,7 +3546,7 @@ static void b43_nphy_stop_playback(struct b43_wldev *dev) · 30 unmodified lines
3546 b43_nphy_stay_in_carrier_search(dev, 0);3546 b43_nphy_stay_in_carrier_search(dev, 0);
3547}3547}
3548 3548
3549/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */3549/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */
3550static void b43_nphy_iq_cal_gain_params(struct b43_wldev *dev, u16 core,3550static void b43_nphy_iq_cal_gain_params(struct b43_wldev *dev, u16 core,
3551 struct nphy_txgains target,3551 struct nphy_txgains target,
3552 struct nphy_iqcal_params *params)3552 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
3595 * Tx and Rx3595 * Tx and Rx
3596 **************************************************/3596 **************************************************/
3597 3597
3598/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlEnable */3598/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlEnable */
3599static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable)3599static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable)
3600{3600{
3601 struct b43_phy *phy = &dev->phy;3601 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
3732 b43_nphy_stay_in_carrier_search(dev, 0);3732 b43_nphy_stay_in_carrier_search(dev, 0);
3733}3733}
3734 3734
3735/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrFix */3735/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrFix */
3736static void b43_nphy_tx_power_fix(struct b43_wldev *dev)3736static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
3737{3737{
3738 struct b43_phy *phy = &dev->phy;3738 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
3926/*3926/*
3927 * Stop radio and transmit known signal. Then check received signal strength to3927 * Stop radio and transmit known signal. Then check received signal strength to
3928 * get TSSI (Transmit Signal Strength Indicator).3928 * get TSSI (Transmit Signal Strength Indicator).
3929 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlIdleTssi3929 * https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlIdleTssi
3930 */3930 */
3931static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev)3931static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev)
3932{3932{
@@ -3978,7 +3978,7 @@ static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev) · 45 unmodified lines
3978 nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF;3978 nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF;
3979}3979}
3980 3980
3981/* http://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */3981/* https://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */
3982static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev)3982static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev)
3983{3983{
3984 struct b43_phy_n *nphy = dev->phy.n;3984 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
4039 }4039 }
4040}4040}
4041 4041
4042/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */4042/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */
4043static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)4043static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)
4044{4044{
4045 struct b43_phy *phy = &dev->phy;4045 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
4272 }4272 }
4273}4273}
4274 4274
4275/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/PA%20override */4275/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/PA%20override */
4276static void b43_nphy_pa_override(struct b43_wldev *dev, bool enable)4276static void b43_nphy_pa_override(struct b43_wldev *dev, bool enable)
4277{4277{
4278 struct b43_phy_n *nphy = dev->phy.n;4278 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
4310 4310
4311/*4311/*
4312 * TX low-pass filter bandwidth setup4312 * TX low-pass filter bandwidth setup
4313 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxLpFbw4313 * https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxLpFbw
4314 */4314 */
4315static void b43_nphy_tx_lpf_bw(struct b43_wldev *dev)4315static void b43_nphy_tx_lpf_bw(struct b43_wldev *dev)
4316{4316{
@@ -4333,7 +4333,7 @@ static void b43_nphy_tx_lpf_bw(struct b43_wldev *dev) · 16 unmodified lines
4333 }4333 }
4334}4334}
4335 4335
4336/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */4336/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */
4337static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est,4337static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est,
4338 u16 samps, u8 time, bool wait)4338 u16 samps, u8 time, bool wait)
4339{4339{
@@ -4372,7 +4372,7 @@ static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est, · 32 unmodified lines
4372 memset(est, 0, sizeof(*est));4372 memset(est, 0, sizeof(*est));
4373}4373}
4374 4374
4375/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqCoeffs */4375/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqCoeffs */
4376static void b43_nphy_rx_iq_coeffs(struct b43_wldev *dev, bool write,4376static void b43_nphy_rx_iq_coeffs(struct b43_wldev *dev, bool write,
4377 struct b43_phy_n_iq_comp *pcomp)4377 struct b43_phy_n_iq_comp *pcomp)
4378{4378{
@@ -4391,7 +4391,7 @@ static void b43_nphy_rx_iq_coeffs(struct b43_wldev *dev, bool write, · 12 unmodified lines
4391 4391
4392#if 04392#if 0
4393/* Ready but not used anywhere */4393/* 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 */
4395static void b43_nphy_rx_cal_phy_cleanup(struct b43_wldev *dev, u8 core)4395static void b43_nphy_rx_cal_phy_cleanup(struct b43_wldev *dev, u8 core)
4396{4396{
4397 u16 *regs = dev->phy.n->tx_rx_cal_phy_saveregs;4397 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
4414 b43_phy_write(dev, B43_NPHY_PAPD_EN1, regs[10]);4414 b43_phy_write(dev, B43_NPHY_PAPD_EN1, regs[10]);
4415}4415}
4416 4416
4417/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhySetup */4417/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhySetup */
4418static void b43_nphy_rx_cal_phy_setup(struct b43_wldev *dev, u8 core)4418static void b43_nphy_rx_cal_phy_setup(struct b43_wldev *dev, u8 core)
4419{4419{
4420 u8 rxval, txval;4420 u8 rxval, txval;
@@ -4476,7 +4476,7 @@ static void b43_nphy_rx_cal_phy_setup(struct b43_wldev *dev, u8 core) · 55 unmodified lines
4476}4476}
4477#endif4477#endif
4478 4478
4479/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalcRxIqComp */4479/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalcRxIqComp */
4480static void b43_nphy_calc_rx_iq_comp(struct b43_wldev *dev, u8 mask)4480static void b43_nphy_calc_rx_iq_comp(struct b43_wldev *dev, u8 mask)
4481{4481{
4482 int i;4482 int i;
@@ -4574,7 +4574,7 @@ static void b43_nphy_calc_rx_iq_comp(struct b43_wldev *dev, u8 mask) · 91 unmodified lines
4574 b43_nphy_rx_iq_coeffs(dev, true, &new);4574 b43_nphy_rx_iq_coeffs(dev, true, &new);
4575}4575}
4576 4576
4577/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxIqWar */4577/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxIqWar */
4578static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev)4578static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev)
4579{4579{
4580 u16 array[4];4580 u16 array[4];
@@ -4586,7 +4586,7 @@ static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev) · 5 unmodified lines
4586 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_NPHY_TXIQW3, array[3]);4586 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_NPHY_TXIQW3, array[3]);
4587}4587}
4588 4588
4589/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */4589/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */
4590static void b43_nphy_spur_workaround(struct b43_wldev *dev)4590static void b43_nphy_spur_workaround(struct b43_wldev *dev)
4591{4591{
4592 struct b43_phy_n *nphy = dev->phy.n;4592 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
4645 b43_nphy_stay_in_carrier_search(dev, 0);4645 b43_nphy_stay_in_carrier_search(dev, 0);
4646}4646}
4647 4647
4648/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */4648/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */
4649static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev)4649static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev)
4650{4650{
4651 struct b43_phy_n *nphy = dev->phy.n;4651 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
4713 4713
4714/*4714/*
4715 * Restore RSSI Calibration4715 * Restore RSSI Calibration
4716 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreRssiCal4716 * https://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreRssiCal
4717 */4717 */
4718static void b43_nphy_restore_rssi_cal(struct b43_wldev *dev)4718static void b43_nphy_restore_rssi_cal(struct b43_wldev *dev)
4719{4719{
@@ -4822,7 +4822,7 @@ static void b43_nphy_tx_cal_radio_setup_rev7(struct b43_wldev *dev) · 102 unmodified lines
4822 }4822 }
4823}4823}
4824 4824
4825/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalRadioSetup */4825/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalRadioSetup */
4826static void b43_nphy_tx_cal_radio_setup(struct b43_wldev *dev)4826static void b43_nphy_tx_cal_radio_setup(struct b43_wldev *dev)
4827{4827{
4828 struct b43_phy *phy = &dev->phy;4828 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
4921 }4921 }
4922}4922}
4923 4923
4924/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */4924/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */
4925static void b43_nphy_update_tx_cal_ladder(struct b43_wldev *dev, u16 core)4925static void b43_nphy_update_tx_cal_ladder(struct b43_wldev *dev, u16 core)
4926{4926{
4927 struct b43_phy_n *nphy = dev->phy.n;4927 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
4955 b43_phy_write(dev, offset, filter[i]);4955 b43_phy_write(dev, offset, filter[i]);
4956}4956}
4957 4957
4958/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ExtPaSetTxDigiFilts */4958/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ExtPaSetTxDigiFilts */
4959static void b43_nphy_ext_pa_set_tx_dig_filters(struct b43_wldev *dev)4959static void b43_nphy_ext_pa_set_tx_dig_filters(struct b43_wldev *dev)
4960{4960{
4961 b43_nphy_pa_set_tx_dig_filter(dev, 0x2C5,4961 b43_nphy_pa_set_tx_dig_filter(dev, 0x2C5,
4962 tbl_tx_filter_coef_rev4[2]);4962 tbl_tx_filter_coef_rev4[2]);
4963}4963}
4964 4964
4965/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IpaSetTxDigiFilts */4965/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/IpaSetTxDigiFilts */
4966static void b43_nphy_int_pa_set_tx_dig_filters(struct b43_wldev *dev)4966static void b43_nphy_int_pa_set_tx_dig_filters(struct b43_wldev *dev)
4967{4967{
4968 /* B43_NPHY_TXF_20CO_S0A1, B43_NPHY_TXF_40CO_S0A1, unknown */4968 /* 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
5002 }5002 }
5003}5003}
5004 5004
5005/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetTxGain */5005/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/GetTxGain */
5006static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev)5006static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev)
5007{5007{
5008 struct b43_phy_n *nphy = dev->phy.n;5008 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
5077 return target;5077 return target;
5078}5078}
5079 5079
5080/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */5080/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */
5081static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev *dev)5081static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev *dev)
5082{5082{
5083 u16 *regs = dev->phy.n->tx_rx_cal_phy_saveregs;5083 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
5106 }5106 }
5107}5107}
5108 5108
5109/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */5109/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */
5110static void b43_nphy_tx_cal_phy_setup(struct b43_wldev *dev)5110static void b43_nphy_tx_cal_phy_setup(struct b43_wldev *dev)
5111{5111{
5112 struct b43_phy *phy = &dev->phy;5112 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
5207 }5207 }
5208}5208}
5209 5209
5210/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SaveCal */5210/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SaveCal */
5211static void b43_nphy_save_cal(struct b43_wldev *dev)5211static void b43_nphy_save_cal(struct b43_wldev *dev)
5212{5212{
5213 struct b43_phy *phy = &dev->phy;5213 struct b43_phy *phy = &dev->phy;
@@ -5278,7 +5278,7 @@ static void b43_nphy_save_cal(struct b43_wldev *dev) · 64 unmodified lines
5278 b43_nphy_stay_in_carrier_search(dev, 0);5278 b43_nphy_stay_in_carrier_search(dev, 0);
5279}5279}
5280 5280
5281/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */5281/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */
5282static void b43_nphy_restore_cal(struct b43_wldev *dev)5282static void b43_nphy_restore_cal(struct b43_wldev *dev)
5283{5283{
5284 struct b43_phy *phy = &dev->phy;5284 struct b43_phy *phy = &dev->phy;
@@ -5366,7 +5366,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev) · 81 unmodified lines
5366 b43_nphy_rx_iq_coeffs(dev, true, rxcal_coeffs);5366 b43_nphy_rx_iq_coeffs(dev, true, rxcal_coeffs);
5367}5367}
5368 5368
5369/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalTxIqlo */5369/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalTxIqlo */
5370static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,5370static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
5371 struct nphy_txgains target,5371 struct nphy_txgains target,
5372 bool full, bool mphase)5372 bool full, bool mphase)
@@ -5599,7 +5599,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev, · 226 unmodified lines
5599 return error;5599 return error;
5600}5600}
5601 5601
5602/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ReapplyTxCalCoeffs */5602/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ReapplyTxCalCoeffs */
5603static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)5603static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
5604{5604{
5605 struct b43_phy_n *nphy = dev->phy.n;5605 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
5634 }5634 }
5635}5635}
5636 5636
5637/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIqRev2 */5637/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIqRev2 */
5638static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,5638static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
5639 struct nphy_txgains target, u8 type, bool debug)5639 struct nphy_txgains target, u8 type, bool debug)
5640{5640{
@@ -5821,7 +5821,7 @@ static int b43_nphy_rev3_cal_rx_iq(struct b43_wldev *dev, · 180 unmodified lines
5821 return -1;5821 return -1;
5822}5822}
5823 5823
5824/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIq */5824/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIq */
5825static int b43_nphy_cal_rx_iq(struct b43_wldev *dev,5825static int b43_nphy_cal_rx_iq(struct b43_wldev *dev,
5826 struct nphy_txgains target, u8 type, bool debug)5826 struct nphy_txgains target, u8 type, bool debug)
5827{5827{
@@ -5834,7 +5834,7 @@ static int b43_nphy_cal_rx_iq(struct b43_wldev *dev, · 6 unmodified lines
5834 return b43_nphy_rev2_cal_rx_iq(dev, target, type, debug);5834 return b43_nphy_rev2_cal_rx_iq(dev, target, type, debug);
5835}5835}
5836 5836
5837/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreSetState */5837/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreSetState */
5838static void b43_nphy_set_rx_core_state(struct b43_wldev *dev, u8 mask)5838static void b43_nphy_set_rx_core_state(struct b43_wldev *dev, u8 mask)
5839{5839{
5840 struct b43_phy *phy = &dev->phy;5840 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
5939 * N-PHY init5939 * N-PHY init
5940 **************************************************/5940 **************************************************/
5941 5941
5942/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */5942/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */
5943static void b43_nphy_update_mimo_config(struct b43_wldev *dev, s32 preamble)5943static void b43_nphy_update_mimo_config(struct b43_wldev *dev, s32 preamble)
5944{5944{
5945 u16 mimocfg = b43_phy_read(dev, B43_NPHY_MIMOCFG);5945 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
5953 b43_phy_write(dev, B43_NPHY_MIMOCFG, mimocfg);5953 b43_phy_write(dev, B43_NPHY_MIMOCFG, mimocfg);
5954}5954}
5955 5955
5956/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BPHYInit */5956/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/BPHYInit */
5957static void b43_nphy_bphy_init(struct b43_wldev *dev)5957static void b43_nphy_bphy_init(struct b43_wldev *dev)
5958{5958{
5959 unsigned int i;5959 unsigned int i;
@@ -5972,7 +5972,7 @@ static void b43_nphy_bphy_init(struct b43_wldev *dev) · 12 unmodified lines
5972 b43_phy_write(dev, B43_PHY_N_BMODE(0x38), 0x668);5972 b43_phy_write(dev, B43_PHY_N_BMODE(0x38), 0x668);
5973}5973}
5974 5974
5975/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SuperSwitchInit */5975/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SuperSwitchInit */
5976static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)5976static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)
5977{5977{
5978 if (dev->phy.rev >= 7)5978 if (dev->phy.rev >= 7)
@@ -6246,7 +6246,7 @@ static void b43_chantab_phy_upload(struct b43_wldev *dev, · 267 unmodified lines
6246 b43_phy_write(dev, B43_NPHY_BW6, e->phy_bw6);6246 b43_phy_write(dev, B43_NPHY_BW6, e->phy_bw6);
6247}6247}
6248 6248
6249/* http://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */6249/* https://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */
6250static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid)6250static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid)
6251{6251{
6252 switch (dev->dev->bus_type) {6252 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
6265 }6265 }
6266}6266}
6267 6267
6268/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */6268/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */
6269static void b43_nphy_channel_setup(struct b43_wldev *dev,6269static void b43_nphy_channel_setup(struct b43_wldev *dev,
6270 const struct b43_phy_n_sfo_cfg *e,6270 const struct b43_phy_n_sfo_cfg *e,
6271 struct ieee80211_channel *new_channel)6271 struct ieee80211_channel *new_channel)
@@ -6372,7 +6372,7 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev, · 100 unmodified lines
6372 b43_nphy_spur_workaround(dev);6372 b43_nphy_spur_workaround(dev);
6373}6373}
6374 6374
6375/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetChanspec */6375/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/SetChanspec */
6376static int b43_nphy_set_channel(struct b43_wldev *dev,6376static int b43_nphy_set_channel(struct b43_wldev *dev,
6377 struct ieee80211_channel *channel,6377 struct ieee80211_channel *channel,
6378 enum nl80211_channel_type channel_type)6378 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
6589 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);6589 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
6590}6590}
6591 6591
6592/* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */6592/* https://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
6593static void b43_nphy_op_software_rfkill(struct b43_wldev *dev,6593static void b43_nphy_op_software_rfkill(struct b43_wldev *dev,
6594 bool blocked)6594 bool blocked)
6595{6595{
@@ -6643,7 +6643,7 @@ static void b43_nphy_op_software_rfkill(struct b43_wldev *dev, · 47 unmodified lines
6643 }6643 }
6644}6644}
6645 6645
6646/* http://bcm-v4.sipsolutions.net/802.11/PHY/Anacore */6646/* https://bcm-v4.sipsolutions.net/802.11/PHY/Anacore */
6647static void b43_nphy_op_switch_analog(struct b43_wldev *dev, bool on)6647static void b43_nphy_op_switch_analog(struct b43_wldev *dev, bool on)
6648{6648{
6649 struct b43_phy *phy = &dev->phy;6649 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
3072 .phy_regs.phy_bw5 = r4, \3072 .phy_regs.phy_bw5 = r4, \
3073 .phy_regs.phy_bw6 = r53073 .phy_regs.phy_bw6 = r5
3074 3074
3075/* http://bcm-v4.sipsolutions.net/802.11/Radio/2056/ChannelTable */3075/* https://bcm-v4.sipsolutions.net/802.11/Radio/2056/ChannelTable */
3076static const struct b43_nphy_channeltab_entry_rev3 b43_nphy_channeltab_phy_rev3[] = {3076static const struct b43_nphy_channeltab_entry_rev3 b43_nphy_channeltab_phy_rev3[] = {
3077 { .freq = 4920,3077 { .freq = 4920,
3078 RADIOREGS3(0xff, 0x01, 0x01, 0x01, 0xec, 0x05, 0x05, 0x04,3078 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
3620 ntab_upload(dev, B43_NTAB_C1_LOFEEDTH, b43_ntab_loftlt1);3620 ntab_upload(dev, B43_NTAB_C1_LOFEEDTH, b43_ntab_loftlt1);
3621}3621}
3622 3622
3623/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables */3623/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables */
3624void b43_nphy_tables_init(struct b43_wldev *dev)3624void b43_nphy_tables_init(struct b43_wldev *dev)
3625{3625{
3626 if (dev->phy.rev >= 16)3626 if (dev->phy.rev >= 16)
@@ -3633,7 +3633,7 @@ void b43_nphy_tables_init(struct b43_wldev *dev) · 6 unmodified lines
3633 b43_nphy_tables_init_rev0(dev);3633 b43_nphy_tables_init_rev0(dev);
3634}3634}
3635 3635
3636/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */3636/* https://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
3637static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)3637static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
3638{3638{
3639 struct b43_phy *phy = &dev->phy;3639 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
591}591}
592 592
593/* DummyTransmission function, as documented on593/* DummyTransmission function, as documented on
594 * http://bcm-specs.sipsolutions.net/DummyTransmission594 * https://bcm-specs.sipsolutions.net/DummyTransmission
595 */595 */
596void b43legacy_dummy_transmission(struct b43legacy_wldev *dev)596void b43legacy_dummy_transmission(struct b43legacy_wldev *dev)
597{597{
@@ -1870,7 +1870,7 @@ out: · 1272 unmodified lines
1870}1870}
1871 1871
1872/* Initialize the GPIOs1872/* Initialize the GPIOs
1873 * http://bcm-specs.sipsolutions.net/GPIO1873 * https://bcm-specs.sipsolutions.net/GPIO
1874 */1874 */
1875static int b43legacy_gpio_init(struct b43legacy_wldev *dev)1875static int b43legacy_gpio_init(struct b43legacy_wldev *dev)
1876{1876{
@@ -1960,7 +1960,7 @@ void b43legacy_mac_enable(struct b43legacy_wldev *dev) · 83 unmodified lines
1960 }1960 }
1961}1961}
1962 1962
1963/* http://bcm-specs.sipsolutions.net/SuspendMAC */1963/* https://bcm-specs.sipsolutions.net/SuspendMAC */
1964void b43legacy_mac_suspend(struct b43legacy_wldev *dev)1964void b43legacy_mac_suspend(struct b43legacy_wldev *dev)
1965{1965{
1966 int i;1966 int i;
@@ -2141,7 +2141,7 @@ static void b43legacy_chip_exit(struct b43legacy_wldev *dev) · 174 unmodified lines
2141}2141}
2142 2142
2143/* Initialize the chip2143/* Initialize the chip
2144 * http://bcm-specs.sipsolutions.net/ChipInit2144 * https://bcm-specs.sipsolutions.net/ChipInit
2145 */2145 */
2146static int b43legacy_chip_init(struct b43legacy_wldev *dev)2146static int b43legacy_chip_init(struct b43legacy_wldev *dev)
2147{2147{
drivers/net/wireless/broadcom/b43legacy/phy.c+4−4
@@ -129,7 +129,7 @@ void b43legacy_phy_calibrate(struct b43legacy_wldev *dev) · 128 unmodified lines
129}129}
130 130
131/* initialize B PHY power control131/* initialize B PHY power control
132 * as described in http://bcm-specs.sipsolutions.net/InitPowerControl132 * as described in https://bcm-specs.sipsolutions.net/InitPowerControl
133 */133 */
134static void b43legacy_phy_init_pctl(struct b43legacy_wldev *dev)134static void b43legacy_phy_init_pctl(struct b43legacy_wldev *dev)
135{135{
@@ -1461,7 +1461,7 @@ void b43legacy_phy_set_baseband_attenuation(struct b43legacy_wldev *dev, · 1325 unmodified lines
1461 b43legacy_phy_write(dev, 0x0060, value);1461 b43legacy_phy_write(dev, 0x0060, value);
1462}1462}
1463 1463
1464/* http://bcm-specs.sipsolutions.net/LocalOscillator/Measure */1464/* https://bcm-specs.sipsolutions.net/LocalOscillator/Measure */
1465void b43legacy_phy_lo_g_measure(struct b43legacy_wldev *dev)1465void b43legacy_phy_lo_g_measure(struct b43legacy_wldev *dev)
1466{1466{
1467 static const u8 pairorder[10] = { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8 };1467 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
1721 }1721 }
1722}1722}
1723 1723
1724/* http://bcm-specs.sipsolutions.net/EstimatePowerOut1724/* https://bcm-specs.sipsolutions.net/EstimatePowerOut
1725 * This function converts a TSSI value to dBm in Q5.21725 * This function converts a TSSI value to dBm in Q5.2
1726 */1726 */
1727static s8 b43legacy_phy_estimate_power_out(struct b43legacy_wldev *dev, s8 tssi)1727static 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
1747 return dbm;1747 return dbm;
1748}1748}
1749 1749
1750/* http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */1750/* https://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */
1751void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)1751void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
1752{1752{
1753 struct b43legacy_phy *phy = &dev->phy;1753 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
313 return ret[channel - 1];313 return ret[channel - 1];
314}314}
315 315
316/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */316/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
317void b43legacy_nrssi_hw_write(struct b43legacy_wldev *dev, u16 offset, s16 val)317void b43legacy_nrssi_hw_write(struct b43legacy_wldev *dev, u16 offset, s16 val)
318{318{
319 b43legacy_phy_write(dev, B43legacy_PHY_NRSSILT_CTRL, offset);319 b43legacy_phy_write(dev, B43legacy_PHY_NRSSILT_CTRL, offset);
320 b43legacy_phy_write(dev, B43legacy_PHY_NRSSILT_DATA, (u16)val);320 b43legacy_phy_write(dev, B43legacy_PHY_NRSSILT_DATA, (u16)val);
321}321}
322 322
323/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */323/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
324s16 b43legacy_nrssi_hw_read(struct b43legacy_wldev *dev, u16 offset)324s16 b43legacy_nrssi_hw_read(struct b43legacy_wldev *dev, u16 offset)
325{325{
326 u16 val;326 u16 val;
@@ -331,7 +331,7 @@ s16 b43legacy_nrssi_hw_read(struct b43legacy_wldev *dev, u16 offset) · 4 unmodified lines
331 return (s16)val;331 return (s16)val;
332}332}
333 333
334/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */334/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
335void b43legacy_nrssi_hw_update(struct b43legacy_wldev *dev, u16 val)335void b43legacy_nrssi_hw_update(struct b43legacy_wldev *dev, u16 val)
336{336{
337 u16 i;337 u16 i;
@@ -345,7 +345,7 @@ void b43legacy_nrssi_hw_update(struct b43legacy_wldev *dev, u16 val) · 7 unmodified lines
345 }345 }
346}346}
347 347
348/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */348/* https://bcm-specs.sipsolutions.net/NRSSILookupTable */
349void b43legacy_nrssi_mem_update(struct b43legacy_wldev *dev)349void b43legacy_nrssi_mem_update(struct b43legacy_wldev *dev)
350{350{
351 struct b43legacy_phy *phy = &dev->phy;351 struct b43legacy_phy *phy = &dev->phy;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c+8−0
@@ -84,6 +84,8 @@ · 83 unmodified lines
84 84
85#define BRCMF_ND_INFO_TIMEOUT msecs_to_jiffies(2000)85#define BRCMF_ND_INFO_TIMEOUT msecs_to_jiffies(2000)
86 86
87#define BRCMF_PS_MAX_TIMEOUT_MS 2000
88
87#define BRCMF_ASSOC_PARAMS_FIXED_SIZE \89#define BRCMF_ASSOC_PARAMS_FIXED_SIZE \
88 (sizeof(struct brcmf_assoc_params_le) - sizeof(u16))90 (sizeof(struct brcmf_assoc_params_le) - sizeof(u16))
89 91
@@ -2942,6 +2944,12 @@ brcmf_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, · 2852 unmodified lines
2942 else2944 else
2943 bphy_err(drvr, "error (%d)\n", err);2945 bphy_err(drvr, "error (%d)\n", err);
2944 }2946 }
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
2945done:2953done:
2946 brcmf_dbg(TRACE, "Exit\n");2954 brcmf_dbg(TRACE, "Exit\n");
2947 return err;2955 return err;
drivers/net/wireless/cisco/airo.c+19−20
@@ -74,16 +74,19 @@ MODULE_DEVICE_TABLE(pci, card_ids); · 73 unmodified lines
74 74
75static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *);75static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *);
76static void airo_pci_remove(struct pci_dev *);76static void airo_pci_remove(struct pci_dev *);
77static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state);77static int __maybe_unused airo_pci_suspend(struct device *dev);
78static int airo_pci_resume(struct pci_dev *pdev);78static int __maybe_unused airo_pci_resume(struct device *dev);
79
80static SIMPLE_DEV_PM_OPS(airo_pci_pm_ops,
81 airo_pci_suspend,
82 airo_pci_resume);
79 83
80static struct pci_driver airo_driver = {84static struct pci_driver airo_driver = {
81 .name = DRV_NAME,85 .name = DRV_NAME,
82 .id_table = card_ids,86 .id_table = card_ids,
83 .probe = airo_pci_probe,87 .probe = airo_pci_probe,
84 .remove = airo_pci_remove,88 .remove = airo_pci_remove,
85 .suspend = airo_pci_suspend,89 .driver.pm = &airo_pci_pm_ops,
86 .resume = airo_pci_resume,
87};90};
88#endif /* CONFIG_PCI */91#endif /* CONFIG_PCI */
89 92
@@ -5573,9 +5576,9 @@ static void airo_pci_remove(struct pci_dev *pdev) · 5483 unmodified lines
5573 pci_disable_device(pdev);5576 pci_disable_device(pdev);
5574}5577}
5575 5578
5576static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)5579static int __maybe_unused airo_pci_suspend(struct device *dev_d)
5577{5580{
5578 struct net_device *dev = pci_get_drvdata(pdev);5581 struct net_device *dev = dev_get_drvdata(dev_d);
5579 struct airo_info *ai = dev->ml_priv;5582 struct airo_info *ai = dev->ml_priv;
5580 Cmd cmd;5583 Cmd cmd;
5581 Resp rsp;5584 Resp rsp;
@@ -5591,25 +5594,21 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) · 9 unmodified lines
5591 return -EAGAIN;5594 return -EAGAIN;
5592 disable_MAC(ai, 0);5595 disable_MAC(ai, 0);
5593 netif_device_detach(dev);5596 netif_device_detach(dev);
5594 ai->power = state;5597 ai->power = PMSG_SUSPEND;
5595 cmd.cmd = HOSTSLEEP;5598 cmd.cmd = HOSTSLEEP;
5596 issuecommand(ai, &cmd, &rsp);5599 issuecommand(ai, &cmd, &rsp);
5597 5600
5598 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);5601 device_wakeup_enable(dev_d);
5599 pci_save_state(pdev);
5600 pci_set_power_state(pdev, pci_choose_state(pdev, state));
5601 return 0;5602 return 0;
5602}5603}
5603 5604
5604static int airo_pci_resume(struct pci_dev *pdev)5605static int __maybe_unused airo_pci_resume(struct device *dev_d)
5605{5606{
5606 struct net_device *dev = pci_get_drvdata(pdev);5607 struct net_device *dev = dev_get_drvdata(dev_d);
5607 struct airo_info *ai = dev->ml_priv;5608 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;
5609 5610
5610 pci_set_power_state(pdev, PCI_D0);5611 device_wakeup_disable(dev_d);
5611 pci_restore_state(pdev);
5612 pci_enable_wake(pdev, PCI_D0, 0);
5613 5612
5614 if (prev_state != PCI_D1) {5613 if (prev_state != PCI_D1) {
5615 reset_card(dev, 0);5614 reset_card(dev, 0);
drivers/net/wireless/intel/ipw2x00/Kconfig+2−2
@@ -28,7 +28,7 @@ config IPW2100 · 27 unmodified lines
28 You will also very likely need the Wireless Tools in order to28 You will also very likely need the Wireless Tools in order to
29 configure your card:29 configure your card:
30 30
31 <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.31 <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
32 32
33 It is recommended that you compile this driver as a module (M)33 It is recommended that you compile this driver as a module (M)
34 rather than built-in (Y). This driver requires firmware at device34 rather than built-in (Y). This driver requires firmware at device
@@ -90,7 +90,7 @@ config IPW2200 · 55 unmodified lines
90 You will also very likely need the Wireless Tools in order to90 You will also very likely need the Wireless Tools in order to
91 configure your card:91 configure your card:
92 92
93 <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.93 <https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
94 94
95 It is recommended that you compile this driver as a module (M)95 It is recommended that you compile this driver as a module (M)
96 rather than built-in (Y). This driver requires firmware at device96 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
2295 return -ENOMEM;2295 return -ENOMEM;
2296 2296
2297 packet->rxp = (struct ipw2100_rx *)packet->skb->data;2297 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,
2299 sizeof(struct ipw2100_rx),2300 sizeof(struct ipw2100_rx),
2300 PCI_DMA_FROMDEVICE);2301 DMA_FROM_DEVICE);
2301 if (pci_dma_mapping_error(priv->pci_dev, packet->dma_addr)) {2302 if (dma_mapping_error(&priv->pci_dev->dev, packet->dma_addr)) {
2302 dev_kfree_skb(packet->skb);2303 dev_kfree_skb(packet->skb);
2303 return -ENOMEM;2304 return -ENOMEM;
2304 }2305 }
@@ -2479,9 +2480,8 @@ static void isr_rx(struct ipw2100_priv *priv, int i, · 174 unmodified lines
2479 return;2480 return;
2480 }2481 }
2481 2482
2482 pci_unmap_single(priv->pci_dev,2483 dma_unmap_single(&priv->pci_dev->dev, packet->dma_addr,
2483 packet->dma_addr,2484 sizeof(struct ipw2100_rx), DMA_FROM_DEVICE);
2484 sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE);
2485 2485
2486 skb_put(packet->skb, status->frame_size);2486 skb_put(packet->skb, status->frame_size);
2487 2487
@@ -2563,8 +2563,8 @@ static void isr_rx_monitor(struct ipw2100_priv *priv, int i, · 75 unmodified lines
2563 return;2563 return;
2564 }2564 }
2565 2565
2566 pci_unmap_single(priv->pci_dev, packet->dma_addr,2566 dma_unmap_single(&priv->pci_dev->dev, packet->dma_addr,
2567 sizeof(struct ipw2100_rx), PCI_DMA_FROMDEVICE);2567 sizeof(struct ipw2100_rx), DMA_FROM_DEVICE);
2568 memmove(packet->skb->data + sizeof(struct ipw_rt_hdr),2568 memmove(packet->skb->data + sizeof(struct ipw_rt_hdr),
2569 packet->skb->data, status->frame_size);2569 packet->skb->data, status->frame_size);
2570 2570
@@ -2689,9 +2689,9 @@ static void __ipw2100_rx_process(struct ipw2100_priv *priv) · 118 unmodified lines
2689 2689
2690 /* Sync the DMA for the RX buffer so CPU is sure to get2690 /* Sync the DMA for the RX buffer so CPU is sure to get
2691 * the correct values */2691 * the correct values */
2692 pci_dma_sync_single_for_cpu(priv->pci_dev, packet->dma_addr,2692 dma_sync_single_for_cpu(&priv->pci_dev->dev, packet->dma_addr,
2693 sizeof(struct ipw2100_rx),2693 sizeof(struct ipw2100_rx),
2694 PCI_DMA_FROMDEVICE);2694 DMA_FROM_DEVICE);
2695 2695
2696 if (unlikely(ipw2100_corruption_check(priv, i))) {2696 if (unlikely(ipw2100_corruption_check(priv, i))) {
2697 ipw2100_corruption_detected(priv, i);2697 ipw2100_corruption_detected(priv, i);
@@ -2923,9 +2923,8 @@ static int __ipw2100_tx_process(struct ipw2100_priv *priv) · 225 unmodified lines
2923 (packet->index + 1 + i) % txq->entries,2923 (packet->index + 1 + i) % txq->entries,
2924 tbd->host_addr, tbd->buf_length);2924 tbd->host_addr, tbd->buf_length);
2925 2925
2926 pci_unmap_single(priv->pci_dev,2926 dma_unmap_single(&priv->pci_dev->dev, tbd->host_addr,
2927 tbd->host_addr,2927 tbd->buf_length, DMA_TO_DEVICE);
2928 tbd->buf_length, PCI_DMA_TODEVICE);
2929 }2928 }
2930 2929
2931 libipw_txb_free(packet->info.d_struct.txb);2930 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
3165 tbd->buf_length = packet->info.d_struct.txb->3164 tbd->buf_length = packet->info.d_struct.txb->
3166 fragments[i]->len - LIBIPW_3ADDR_LEN;3165 fragments[i]->len - LIBIPW_3ADDR_LEN;
3167 3166
3168 tbd->host_addr = pci_map_single(priv->pci_dev,3167 tbd->host_addr = dma_map_single(&priv->pci_dev->dev,
3169 packet->info.d_struct.3168 packet->info.d_struct.
3170 txb->fragments[i]->3169 txb->fragments[i]->data +
3171 data +
3172 LIBIPW_3ADDR_LEN,3170 LIBIPW_3ADDR_LEN,
3173 tbd->buf_length,3171 tbd->buf_length,
3174 PCI_DMA_TODEVICE);3172 DMA_TO_DEVICE);
3175 if (pci_dma_mapping_error(priv->pci_dev,3173 if (dma_mapping_error(&priv->pci_dev->dev, tbd->host_addr)) {
3176 tbd->host_addr)) {
3177 IPW_DEBUG_TX("dma mapping error\n");3174 IPW_DEBUG_TX("dma mapping error\n");
3178 break;3175 break;
3179 }3176 }
@@ -3182,10 +3179,10 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) · 2 unmodified lines
3182 txq->next, tbd->host_addr,3179 txq->next, tbd->host_addr,
3183 tbd->buf_length);3180 tbd->buf_length);
3184 3181
3185 pci_dma_sync_single_for_device(priv->pci_dev,3182 dma_sync_single_for_device(&priv->pci_dev->dev,
3186 tbd->host_addr,3183 tbd->host_addr,
3187 tbd->buf_length,3184 tbd->buf_length,
3188 PCI_DMA_TODEVICE);3185 DMA_TO_DEVICE);
3189 3186
3190 txq->next++;3187 txq->next++;
3191 txq->next %= txq->entries;3188 txq->next %= txq->entries;
@@ -3440,9 +3437,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) · 248 unmodified lines
3440 return -ENOMEM;3437 return -ENOMEM;
3441 3438
3442 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {3439 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3443 v = pci_zalloc_consistent(priv->pci_dev,3440 v = dma_alloc_coherent(&priv->pci_dev->dev,
3444 sizeof(struct ipw2100_cmd_header),3441 sizeof(struct ipw2100_cmd_header), &p,
3445 &p);3442 GFP_KERNEL);
3446 if (!v) {3443 if (!v) {
3447 printk(KERN_ERR DRV_NAME ": "3444 printk(KERN_ERR DRV_NAME ": "
3448 "%s: PCI alloc failed for msg "3445 "%s: PCI alloc failed for msg "
@@ -3461,11 +3458,10 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) · 12 unmodified lines
3461 return 0;3458 return 0;
3462 3459
3463 for (j = 0; j < i; j++) {3460 for (j = 0; j < i; j++) {
3464 pci_free_consistent(priv->pci_dev,3461 dma_free_coherent(&priv->pci_dev->dev,
3465 sizeof(struct ipw2100_cmd_header),3462 sizeof(struct ipw2100_cmd_header),
3466 priv->msg_buffers[j].info.c_struct.cmd,3463 priv->msg_buffers[j].info.c_struct.cmd,
3467 priv->msg_buffers[j].info.c_struct.3464 priv->msg_buffers[j].info.c_struct.cmd_phys);
3468 cmd_phys);
3469 }3465 }
3470 3466
3471 kfree(priv->msg_buffers);3467 kfree(priv->msg_buffers);
@@ -3496,11 +3492,10 @@ static void ipw2100_msg_free(struct ipw2100_priv *priv) · 24 unmodified lines
3496 return;3492 return;
3497 3493
3498 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {3494 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3499 pci_free_consistent(priv->pci_dev,3495 dma_free_coherent(&priv->pci_dev->dev,
3500 sizeof(struct ipw2100_cmd_header),3496 sizeof(struct ipw2100_cmd_header),
3501 priv->msg_buffers[i].info.c_struct.cmd,3497 priv->msg_buffers[i].info.c_struct.cmd,
3502 priv->msg_buffers[i].info.c_struct.3498 priv->msg_buffers[i].info.c_struct.cmd_phys);
3503 cmd_phys);
3504 }3499 }
3505 3500
3506 kfree(priv->msg_buffers);3501 kfree(priv->msg_buffers);
@@ -4323,7 +4318,8 @@ static int status_queue_allocate(struct ipw2100_priv *priv, int entries) · 816 unmodified lines
4323 IPW_DEBUG_INFO("enter\n");4318 IPW_DEBUG_INFO("enter\n");
4324 4319
4325 q->size = entries * sizeof(struct ipw2100_status);4320 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);
4327 if (!q->drv) {4323 if (!q->drv) {
4328 IPW_DEBUG_WARNING("Can not allocate status queue.\n");4324 IPW_DEBUG_WARNING("Can not allocate status queue.\n");
4329 return -ENOMEM;4325 return -ENOMEM;
@@ -4339,9 +4335,10 @@ static void status_queue_free(struct ipw2100_priv *priv) · 9 unmodified lines
4339 IPW_DEBUG_INFO("enter\n");4335 IPW_DEBUG_INFO("enter\n");
4340 4336
4341 if (priv->status_queue.drv) {4337 if (priv->status_queue.drv) {
4342 pci_free_consistent(priv->pci_dev, priv->status_queue.size,4338 dma_free_coherent(&priv->pci_dev->dev,
4343 priv->status_queue.drv,4339 priv->status_queue.size,
4344 priv->status_queue.nic);4340 priv->status_queue.drv,
4341 priv->status_queue.nic);
4345 priv->status_queue.drv = NULL;4342 priv->status_queue.drv = NULL;
4346 }4343 }
4347 4344
@@ -4357,7 +4354,8 @@ static int bd_queue_allocate(struct ipw2100_priv *priv, · 9 unmodified lines
4357 4354
4358 q->entries = entries;4355 q->entries = entries;
4359 q->size = entries * sizeof(struct ipw2100_bd);4356 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);
4361 if (!q->drv) {4359 if (!q->drv) {
4362 IPW_DEBUG_INFO4360 IPW_DEBUG_INFO
4363 ("can't allocate shared memory for buffer descriptors\n");4361 ("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
4377 return;4375 return;
4378 4376
4379 if (q->drv) {4377 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);
4381 q->drv = NULL;4380 q->drv = NULL;
4382 }4381 }
4383 4382
@@ -4430,16 +4429,16 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv) · 46 unmodified lines
4430 4429
4431 priv->tx_buffers = kmalloc_array(TX_PENDED_QUEUE_LENGTH,4430 priv->tx_buffers = kmalloc_array(TX_PENDED_QUEUE_LENGTH,
4432 sizeof(struct ipw2100_tx_packet),4431 sizeof(struct ipw2100_tx_packet),
4433 GFP_ATOMIC);4432 GFP_KERNEL);
4434 if (!priv->tx_buffers) {4433 if (!priv->tx_buffers) {
4435 bd_queue_free(priv, &priv->tx_queue);4434 bd_queue_free(priv, &priv->tx_queue);
4436 return -ENOMEM;4435 return -ENOMEM;
4437 }4436 }
4438 4437
4439 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {4438 for (i = 0; i < TX_PENDED_QUEUE_LENGTH; i++) {
4440 v = pci_alloc_consistent(priv->pci_dev,4439 v = dma_alloc_coherent(&priv->pci_dev->dev,
4441 sizeof(struct ipw2100_data_header),4440 sizeof(struct ipw2100_data_header), &p,
4442 &p);4441 GFP_KERNEL);
4443 if (!v) {4442 if (!v) {
4444 printk(KERN_ERR DRV_NAME4443 printk(KERN_ERR DRV_NAME
4445 ": %s: PCI alloc failed for tx " "buffers.\n",4444 ": %s: PCI alloc failed for tx " "buffers.\n",
@@ -4459,11 +4458,10 @@ static int ipw2100_tx_allocate(struct ipw2100_priv *priv) · 13 unmodified lines
4459 return 0;4458 return 0;
4460 4459
4461 for (j = 0; j < i; j++) {4460 for (j = 0; j < i; j++) {
4462 pci_free_consistent(priv->pci_dev,4461 dma_free_coherent(&priv->pci_dev->dev,
4463 sizeof(struct ipw2100_data_header),4462 sizeof(struct ipw2100_data_header),
4464 priv->tx_buffers[j].info.d_struct.data,4463 priv->tx_buffers[j].info.d_struct.data,
4465 priv->tx_buffers[j].info.d_struct.4464 priv->tx_buffers[j].info.d_struct.data_phys);
4466 data_phys);
4467 }4465 }
4468 4466
4469 kfree(priv->tx_buffers);4467 kfree(priv->tx_buffers);
@@ -4540,12 +4538,10 @@ static void ipw2100_tx_free(struct ipw2100_priv *priv) · 70 unmodified lines
4540 priv->tx_buffers[i].info.d_struct.txb = NULL;4538 priv->tx_buffers[i].info.d_struct.txb = NULL;
4541 }4539 }
4542 if (priv->tx_buffers[i].info.d_struct.data)4540 if (priv->tx_buffers[i].info.d_struct.data)
4543 pci_free_consistent(priv->pci_dev,4541 dma_free_coherent(&priv->pci_dev->dev,
4544 sizeof(struct ipw2100_data_header),4542 sizeof(struct ipw2100_data_header),
4545 priv->tx_buffers[i].info.d_struct.4543 priv->tx_buffers[i].info.d_struct.data,
4546 data,4544 priv->tx_buffers[i].info.d_struct.data_phys);
4547 priv->tx_buffers[i].info.d_struct.
4548 data_phys);
4549 }4545 }
4550 4546
4551 kfree(priv->tx_buffers);4547 kfree(priv->tx_buffers);
@@ -4608,9 +4604,10 @@ static int ipw2100_rx_allocate(struct ipw2100_priv *priv) · 56 unmodified lines
4608 return 0;4604 return 0;
4609 4605
4610 for (j = 0; j < i; j++) {4606 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,
4612 sizeof(struct ipw2100_rx_packet),4609 sizeof(struct ipw2100_rx_packet),
4613 PCI_DMA_FROMDEVICE);4610 DMA_FROM_DEVICE);
4614 dev_kfree_skb(priv->rx_buffers[j].skb);4611 dev_kfree_skb(priv->rx_buffers[j].skb);
4615 }4612 }
4616 4613
@@ -4662,10 +4659,10 @@ static void ipw2100_rx_free(struct ipw2100_priv *priv) · 45 unmodified lines
4662 4659
4663 for (i = 0; i < RX_QUEUE_LENGTH; i++) {4660 for (i = 0; i < RX_QUEUE_LENGTH; i++) {
4664 if (priv->rx_buffers[i].rxp) {4661 if (priv->rx_buffers[i].rxp) {
4665 pci_unmap_single(priv->pci_dev,4662 dma_unmap_single(&priv->pci_dev->dev,
4666 priv->rx_buffers[i].dma_addr,4663 priv->rx_buffers[i].dma_addr,
4667 sizeof(struct ipw2100_rx),4664 sizeof(struct ipw2100_rx),
4668 PCI_DMA_FROMDEVICE);4665 DMA_FROM_DEVICE);
4669 dev_kfree_skb(priv->rx_buffers[i].skb);4666 dev_kfree_skb(priv->rx_buffers[i].skb);
4670 }4667 }
4671 }4668 }
@@ -6196,7 +6193,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, · 1524 unmodified lines
6196 pci_set_master(pci_dev);6193 pci_set_master(pci_dev);
6197 pci_set_drvdata(pci_dev, priv);6194 pci_set_drvdata(pci_dev, priv);
6198 6195
6199 err = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));6196 err = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32));
6200 if (err) {6197 if (err) {
6201 printk(KERN_WARNING DRV_NAME6198 printk(KERN_WARNING DRV_NAME
6202 "Error calling pci_set_dma_mask.\n");6199 "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
3442 /* In the reset function, these buffers may have been allocated3442 /* In the reset function, these buffers may have been allocated
3443 * to an SKB, so we need to unmap and free potential storage */3443 * to an SKB, so we need to unmap and free potential storage */
3444 if (rxq->pool[i].skb != NULL) {3444 if (rxq->pool[i].skb != NULL) {
3445 pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,3445 dma_unmap_single(&priv->pci_dev->dev,
3446 IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);3446 rxq->pool[i].dma_addr,
3447 IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
3447 dev_kfree_skb(rxq->pool[i].skb);3448 dev_kfree_skb(rxq->pool[i].skb);
3448 rxq->pool[i].skb = NULL;3449 rxq->pool[i].skb = NULL;
3449 }3450 }
@@ -3774,7 +3775,8 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, · 324 unmodified lines
3774 return -ENOMEM;3775 return -ENOMEM;
3775 3776
3776 q->bd =3777 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);
3778 if (!q->bd) {3780 if (!q->bd) {
3779 IPW_ERROR("pci_alloc_consistent(%zd) failed\n",3781 IPW_ERROR("pci_alloc_consistent(%zd) failed\n",
3780 sizeof(q->bd[0]) * count);3782 sizeof(q->bd[0]) * count);
@@ -3816,9 +3818,10 @@ static void ipw_queue_tx_free_tfd(struct ipw_priv *priv, · 35 unmodified lines
3816 3818
3817 /* unmap chunks if any */3819 /* unmap chunks if any */
3818 for (i = 0; i < le32_to_cpu(bd->u.data.num_chunks); i++) {3820 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]),
3820 le16_to_cpu(bd->u.data.chunk_len[i]),3823 le16_to_cpu(bd->u.data.chunk_len[i]),
3821 PCI_DMA_TODEVICE);3824 DMA_TO_DEVICE);
3822 if (txq->txb[txq->q.last_used]) {3825 if (txq->txb[txq->q.last_used]) {
3823 libipw_txb_free(txq->txb[txq->q.last_used]);3826 libipw_txb_free(txq->txb[txq->q.last_used]);
3824 txq->txb[txq->q.last_used] = NULL;3827 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
3850 }3853 }
3851 3854
3852 /* free buffers belonging to queue itself */3855 /* free buffers belonging to queue itself */
3853 pci_free_consistent(dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd,3856 dma_free_coherent(&dev->dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd,
3854 q->dma_addr);3857 q->dma_addr);
3855 kfree(txq->txb);3858 kfree(txq->txb);
3856 3859
3857 /* 0 fill whole structure */3860 /* 0 fill whole structure */
@@ -5196,8 +5199,8 @@ static void ipw_rx_queue_replenish(void *data) · 1338 unmodified lines
5196 list_del(element);5199 list_del(element);
5197 5200
5198 rxb->dma_addr =5201 rxb->dma_addr =
5199 pci_map_single(priv->pci_dev, rxb->skb->data,5202 dma_map_single(&priv->pci_dev->dev, rxb->skb->data,
5200 IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);5203 IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
5201 5204
5202 list_add_tail(&rxb->list, &rxq->rx_free);5205 list_add_tail(&rxb->list, &rxq->rx_free);
5203 rxq->free_count++;5206 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
5230 5233
5231 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {5234 for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) {
5232 if (rxq->pool[i].skb != NULL) {5235 if (rxq->pool[i].skb != NULL) {
5233 pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr,5236 dma_unmap_single(&priv->pci_dev->dev,
5234 IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);5237 rxq->pool[i].dma_addr,
5238 IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
5235 dev_kfree_skb(rxq->pool[i].skb);5239 dev_kfree_skb(rxq->pool[i].skb);
5236 }5240 }
5237 }5241 }
@@ -8263,9 +8267,8 @@ static void ipw_rx(struct ipw_priv *priv) · 3025 unmodified lines
8263 }8267 }
8264 priv->rxq->queue[i] = NULL;8268 priv->rxq->queue[i] = NULL;
8265 8269
8266 pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr,8270 dma_sync_single_for_cpu(&priv->pci_dev->dev, rxb->dma_addr,
8267 IPW_RX_BUF_SIZE,8271 IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
8268 PCI_DMA_FROMDEVICE);
8269 8272
8270 pkt = (struct ipw_rx_packet *)rxb->skb->data;8273 pkt = (struct ipw_rx_packet *)rxb->skb->data;
8271 IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n",8274 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
8417 rxb->skb = NULL;8420 rxb->skb = NULL;
8418 }8421 }
8419 8422
8420 pci_unmap_single(priv->pci_dev, rxb->dma_addr,8423 dma_unmap_single(&priv->pci_dev->dev, rxb->dma_addr,
8421 IPW_RX_BUF_SIZE, PCI_DMA_FROMDEVICE);8424 IPW_RX_BUF_SIZE, DMA_FROM_DEVICE);
8422 list_add_tail(&rxb->list, &priv->rxq->rx_used);8425 list_add_tail(&rxb->list, &priv->rxq->rx_used);
8423 8426
8424 i = (i + 1) % RX_QUEUE_SIZE;8427 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
10217 txb->fragments[i]->len - hdr_len);10220 txb->fragments[i]->len - hdr_len);
10218 10221
10219 tfd->u.data.chunk_ptr[i] =10222 tfd->u.data.chunk_ptr[i] =
10220 cpu_to_le32(pci_map_single10223 cpu_to_le32(dma_map_single(&priv->pci_dev->dev,
10221 (priv->pci_dev,10224 txb->fragments[i]->data + hdr_len,
10222 txb->fragments[i]->data + hdr_len,10225 txb->fragments[i]->len - hdr_len,
10223 txb->fragments[i]->len - hdr_len,10226 DMA_TO_DEVICE));
10224 PCI_DMA_TODEVICE));
10225 tfd->u.data.chunk_len[i] =10227 tfd->u.data.chunk_len[i] =
10226 cpu_to_le16(txb->fragments[i]->len - hdr_len);10228 cpu_to_le16(txb->fragments[i]->len - hdr_len);
10227 }10229 }
@@ -10251,10 +10253,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct libipw_txb *txb, · 23 unmodified lines
10251 dev_kfree_skb_any(txb->fragments[i]);10253 dev_kfree_skb_any(txb->fragments[i]);
10252 txb->fragments[i] = skb;10254 txb->fragments[i] = skb;
10253 tfd->u.data.chunk_ptr[i] =10255 tfd->u.data.chunk_ptr[i] =
10254 cpu_to_le32(pci_map_single10256 cpu_to_le32(dma_map_single(&priv->pci_dev->dev,
10255 (priv->pci_dev, skb->data,10257 skb->data,
10256 remaining_bytes,10258 remaining_bytes,
10257 PCI_DMA_TODEVICE));10259 DMA_TO_DEVICE));
10258 10260
10259 le32_add_cpu(&tfd->u.data.num_chunks, 1);10261 le32_add_cpu(&tfd->u.data.num_chunks, 1);
10260 }10262 }
@@ -11620,9 +11622,9 @@ static int ipw_pci_probe(struct pci_dev *pdev, · 1359 unmodified lines
11620 11622
11621 pci_set_master(pdev);11623 pci_set_master(pdev);
11622 11624
11623 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));11625 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
11624 if (!err)11626 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));
11626 if (err) {11628 if (err) {
11627 printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n");11629 printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n");
11628 goto out_pci_disable_device;11630 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
480 if (!iwlwifi_mod_params.enable_ini)480 if (!iwlwifi_mod_params.enable_ini)
481 return;481 return;
482 482
483 res = request_firmware(&fw, "iwl-debug-yoyo.bin", dev);483 res = firmware_request_nowarn(&fw, "iwl-debug-yoyo.bin", dev);
484 if (res)484 if (res)
485 return;485 return;
486 486
drivers/net/wireless/intersil/Kconfig+1−1
@@ -30,7 +30,7 @@ config PRISM54 · 29 unmodified lines
30 30
31 For more information refer to the p54 wiki:31 For more information refer to the p54 wiki:
32 32
33 http://wireless.kernel.org/en/users/Drivers/p5433 http://wireless.wiki.kernel.org/en/users/Drivers/p54
34 34
35 Note: You need a motherboard with DMA support to use any of these cards35 Note: You need a motherboard with DMA support to use any of these cards
36 36
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
3366}3366}
3367 3367
3368 3368
3369#if (defined(PRISM2_PCI) && defined(CONFIG_PM)) || defined(PRISM2_PCCARD)3369#if defined(PRISM2_PCI) || defined(PRISM2_PCCARD)
3370static void prism2_suspend(struct net_device *dev)3370static void __maybe_unused prism2_suspend(struct net_device *dev)
3371{3371{
3372 struct hostap_interface *iface;3372 struct hostap_interface *iface;
3373 struct local_info *local;3373 struct local_info *local;
@@ -3385,7 +3385,7 @@ static void prism2_suspend(struct net_device *dev) · 11 unmodified lines
3385 /* Disable hardware and firmware */3385 /* Disable hardware and firmware */
3386 prism2_hw_shutdown(dev, 0);3386 prism2_hw_shutdown(dev, 0);
3387}3387}
3388#endif /* (PRISM2_PCI && CONFIG_PM) || PRISM2_PCCARD */3388#endif /* PRISM2_PCI || PRISM2_PCCARD */
3389 3389
3390 3390
3391/* These might at some point be compiled separately and used as separate3391/* 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
403 pci_disable_device(pdev);403 pci_disable_device(pdev);
404}404}
405 405
406 406static int __maybe_unused prism2_pci_suspend(struct device *dev_d)
407#ifdef CONFIG_PM
408static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state)
409{407{
410 struct net_device *dev = pci_get_drvdata(pdev);408 struct net_device *dev = dev_get_drvdata(dev_d);
411 409
412 if (netif_running(dev)) {410 if (netif_running(dev)) {
413 netif_stop_queue(dev);411 netif_stop_queue(dev);
414 netif_device_detach(dev);412 netif_device_detach(dev);
415 }413 }
416 prism2_suspend(dev);414 prism2_suspend(dev);
417 pci_save_state(pdev);
418 pci_disable_device(pdev);
419 pci_set_power_state(pdev, PCI_D3hot);
420 415
421 return 0;416 return 0;
422}417}
423 418
424static int prism2_pci_resume(struct pci_dev *pdev)419static int __maybe_unused prism2_pci_resume(struct device *dev_d)
425{420{
426 struct net_device *dev = pci_get_drvdata(pdev);421 struct net_device *dev = dev_get_drvdata(dev_d);
427 int err;422
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);
436 prism2_hw_config(dev, 0);423 prism2_hw_config(dev, 0);
437 if (netif_running(dev)) {424 if (netif_running(dev)) {
438 netif_device_attach(dev);425 netif_device_attach(dev);
@@ -441,20 +428,19 @@ static int prism2_pci_resume(struct pci_dev *pdev) · 2 unmodified lines
441 428
442 return 0;429 return 0;
443}430}
444#endif /* CONFIG_PM */
445
446 431
447MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);432MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
448 433
434static SIMPLE_DEV_PM_OPS(prism2_pci_pm_ops,
435 prism2_pci_suspend,
436 prism2_pci_resume);
437
449static struct pci_driver prism2_pci_driver = {438static struct pci_driver prism2_pci_driver = {
450 .name = "hostap_pci",439 .name = "hostap_pci",
451 .id_table = prism2_pci_id_table,440 .id_table = prism2_pci_id_table,
452 .probe = prism2_pci_probe,441 .probe = prism2_pci_probe,
453 .remove = prism2_pci_remove,442 .remove = prism2_pci_remove,
454#ifdef CONFIG_PM443 .driver.pm = &prism2_pci_pm_ops,
455 .suspend = prism2_pci_suspend,
456 .resume = prism2_pci_resume,
457#endif /* CONFIG_PM */
458};444};
459 445
460module_pci_driver(prism2_pci_driver);446module_pci_driver(prism2_pci_driver);
drivers/net/wireless/intersil/orinoco/Kconfig+2−2
@@ -27,7 +27,7 @@ config HERMES · 26 unmodified lines
27 27
28 You will also very likely also need the Wireless Tools in order to28 You will also very likely also need the Wireless Tools in order to
29 configure your card and that /etc/pcmcia/wireless.opts works :29 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>
31 31
32config HERMES_PRISM32config HERMES_PRISM
33 bool "Support Prism 2/2.5 chipset"33 bool "Support Prism 2/2.5 chipset"
@@ -120,7 +120,7 @@ config PCMCIA_HERMES · 86 unmodified lines
120 120
121 You will very likely need the Wireless Tools in order to121 You will very likely need the Wireless Tools in order to
122 configure your card and that /etc/pcmcia/wireless.opts works:122 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>.
124 124
125config PCMCIA_SPECTRUM125config PCMCIA_SPECTRUM
126 tristate "Symbol Spectrum24 Trilogy PCMCIA card support"126 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
10 also need to be enabled in order to support any devices.10 also need to be enabled in order to support any devices.
11 11
12 These devices require softmac firmware which can be found at12 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>
14 14
15 If you choose to build a module, it'll be called p54common.15 If you choose to build a module, it'll be called p54common.
16 16
@@ -22,7 +22,7 @@ config P54_USB · 5 unmodified lines
22 This driver is for USB isl38xx based wireless cards.22 This driver is for USB isl38xx based wireless cards.
23 23
24 These devices require softmac firmware which can be found at24 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>
26 26
27 If you choose to build a module, it'll be called p54usb.27 If you choose to build a module, it'll be called p54usb.
28 28
@@ -36,7 +36,7 @@ config P54_PCI · 7 unmodified lines
36 supported by the fullmac driver/firmware.36 supported by the fullmac driver/firmware.
37 37
38 This driver requires softmac firmware which can be found at38 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>
40 40
41 If you choose to build a module, it'll be called p54pci.41 If you choose to build a module, it'll be called p54pci.
42 42
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
132 if (priv->fw_var < 0x500)132 if (priv->fw_var < 0x500)
133 wiphy_info(priv->hw->wiphy,133 wiphy_info(priv->hw->wiphy,
134 "you are using an obsolete firmware. "134 "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 "
136 "and grab one for \"kernel >= 2.6.28\"!\n");136 "and grab one for \"kernel >= 2.6.28\"!\n");
137 137
138 if (priv->fw_var >= 0x300) {138 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
153 if (!skb)153 if (!skb)
154 break;154 break;
155 155
156 mapping = pci_map_single(priv->pdev,156 mapping = dma_map_single(&priv->pdev->dev,
157 skb_tail_pointer(skb),157 skb_tail_pointer(skb),
158 priv->common.rx_mtu + 32,158 priv->common.rx_mtu + 32,
159 PCI_DMA_FROMDEVICE);159 DMA_FROM_DEVICE);
160 160
161 if (pci_dma_mapping_error(priv->pdev, mapping)) {161 if (dma_mapping_error(&priv->pdev->dev, mapping)) {
162 dev_kfree_skb_any(skb);162 dev_kfree_skb_any(skb);
163 dev_err(&priv->pdev->dev,163 dev_err(&priv->pdev->dev,
164 "RX DMA Mapping error\n");164 "RX DMA Mapping error\n");
@@ -215,19 +215,22 @@ static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index, · 50 unmodified lines
215 len = priv->common.rx_mtu;215 len = priv->common.rx_mtu;
216 }216 }
217 dma_addr = le32_to_cpu(desc->host_addr);217 dma_addr = le32_to_cpu(desc->host_addr);
218 pci_dma_sync_single_for_cpu(priv->pdev, dma_addr,218 dma_sync_single_for_cpu(&priv->pdev->dev, dma_addr,
219 priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);219 priv->common.rx_mtu + 32,
220 DMA_FROM_DEVICE);
220 skb_put(skb, len);221 skb_put(skb, len);
221 222
222 if (p54_rx(dev, skb)) {223 if (p54_rx(dev, skb)) {
223 pci_unmap_single(priv->pdev, dma_addr,224 dma_unmap_single(&priv->pdev->dev, dma_addr,
224 priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);225 priv->common.rx_mtu + 32,
226 DMA_FROM_DEVICE);
225 rx_buf[i] = NULL;227 rx_buf[i] = NULL;
226 desc->host_addr = cpu_to_le32(0);228 desc->host_addr = cpu_to_le32(0);
227 } else {229 } else {
228 skb_trim(skb, 0);230 skb_trim(skb, 0);
229 pci_dma_sync_single_for_device(priv->pdev, dma_addr,231 dma_sync_single_for_device(&priv->pdev->dev, dma_addr,
230 priv->common.rx_mtu + 32, PCI_DMA_FROMDEVICE);232 priv->common.rx_mtu + 32,
233 DMA_FROM_DEVICE);
231 desc->len = cpu_to_le16(priv->common.rx_mtu + 32);234 desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
232 }235 }
233 236
@@ -258,8 +261,9 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index, · 24 unmodified lines
258 skb = tx_buf[i];261 skb = tx_buf[i];
259 tx_buf[i] = NULL;262 tx_buf[i] = NULL;
260 263
261 pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),264 dma_unmap_single(&priv->pdev->dev,
262 le16_to_cpu(desc->len), PCI_DMA_TODEVICE);265 le32_to_cpu(desc->host_addr),
266 le16_to_cpu(desc->len), DMA_TO_DEVICE);
263 267
264 desc->host_addr = 0;268 desc->host_addr = 0;
265 desc->device_addr = 0;269 desc->device_addr = 0;
@@ -334,9 +338,9 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb) · 68 unmodified lines
334 idx = le32_to_cpu(ring_control->host_idx[1]);338 idx = le32_to_cpu(ring_control->host_idx[1]);
335 i = idx % ARRAY_SIZE(ring_control->tx_data);339 i = idx % ARRAY_SIZE(ring_control->tx_data);
336 340
337 mapping = pci_map_single(priv->pdev, skb->data, skb->len,341 mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len,
338 PCI_DMA_TODEVICE);342 DMA_TO_DEVICE);
339 if (pci_dma_mapping_error(priv->pdev, mapping)) {343 if (dma_mapping_error(&priv->pdev->dev, mapping)) {
340 spin_unlock_irqrestore(&priv->lock, flags);344 spin_unlock_irqrestore(&priv->lock, flags);
341 p54_free_skb(dev, skb);345 p54_free_skb(dev, skb);
342 dev_err(&priv->pdev->dev, "TX DMA mapping error\n");346 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
378 for (i = 0; i < ARRAY_SIZE(priv->rx_buf_data); i++) {382 for (i = 0; i < ARRAY_SIZE(priv->rx_buf_data); i++) {
379 desc = &ring_control->rx_data[i];383 desc = &ring_control->rx_data[i];
380 if (desc->host_addr)384 if (desc->host_addr)
381 pci_unmap_single(priv->pdev,385 dma_unmap_single(&priv->pdev->dev,
382 le32_to_cpu(desc->host_addr),386 le32_to_cpu(desc->host_addr),
383 priv->common.rx_mtu + 32,387 priv->common.rx_mtu + 32,
384 PCI_DMA_FROMDEVICE);388 DMA_FROM_DEVICE);
385 kfree_skb(priv->rx_buf_data[i]);389 kfree_skb(priv->rx_buf_data[i]);
386 priv->rx_buf_data[i] = NULL;390 priv->rx_buf_data[i] = NULL;
387 }391 }
@@ -389,10 +393,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 1 unmodified line
389 for (i = 0; i < ARRAY_SIZE(priv->rx_buf_mgmt); i++) {393 for (i = 0; i < ARRAY_SIZE(priv->rx_buf_mgmt); i++) {
390 desc = &ring_control->rx_mgmt[i];394 desc = &ring_control->rx_mgmt[i];
391 if (desc->host_addr)395 if (desc->host_addr)
392 pci_unmap_single(priv->pdev,396 dma_unmap_single(&priv->pdev->dev,
393 le32_to_cpu(desc->host_addr),397 le32_to_cpu(desc->host_addr),
394 priv->common.rx_mtu + 32,398 priv->common.rx_mtu + 32,
395 PCI_DMA_FROMDEVICE);399 DMA_FROM_DEVICE);
396 kfree_skb(priv->rx_buf_mgmt[i]);400 kfree_skb(priv->rx_buf_mgmt[i]);
397 priv->rx_buf_mgmt[i] = NULL;401 priv->rx_buf_mgmt[i] = NULL;
398 }402 }
@@ -400,10 +404,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 1 unmodified line
400 for (i = 0; i < ARRAY_SIZE(priv->tx_buf_data); i++) {404 for (i = 0; i < ARRAY_SIZE(priv->tx_buf_data); i++) {
401 desc = &ring_control->tx_data[i];405 desc = &ring_control->tx_data[i];
402 if (desc->host_addr)406 if (desc->host_addr)
403 pci_unmap_single(priv->pdev,407 dma_unmap_single(&priv->pdev->dev,
404 le32_to_cpu(desc->host_addr),408 le32_to_cpu(desc->host_addr),
405 le16_to_cpu(desc->len),409 le16_to_cpu(desc->len),
406 PCI_DMA_TODEVICE);410 DMA_TO_DEVICE);
407 411
408 p54_free_skb(dev, priv->tx_buf_data[i]);412 p54_free_skb(dev, priv->tx_buf_data[i]);
409 priv->tx_buf_data[i] = NULL;413 priv->tx_buf_data[i] = NULL;
@@ -412,10 +416,10 @@ static void p54p_stop(struct ieee80211_hw *dev) · 2 unmodified lines
412 for (i = 0; i < ARRAY_SIZE(priv->tx_buf_mgmt); i++) {416 for (i = 0; i < ARRAY_SIZE(priv->tx_buf_mgmt); i++) {
413 desc = &ring_control->tx_mgmt[i];417 desc = &ring_control->tx_mgmt[i];
414 if (desc->host_addr)418 if (desc->host_addr)
415 pci_unmap_single(priv->pdev,419 dma_unmap_single(&priv->pdev->dev,
416 le32_to_cpu(desc->host_addr),420 le32_to_cpu(desc->host_addr),
417 le16_to_cpu(desc->len),421 le16_to_cpu(desc->len),
418 PCI_DMA_TODEVICE);422 DMA_TO_DEVICE);
419 423
420 p54_free_skb(dev, priv->tx_buf_mgmt[i]);424 p54_free_skb(dev, priv->tx_buf_mgmt[i]);
421 priv->tx_buf_mgmt[i] = NULL;425 priv->tx_buf_mgmt[i] = NULL;
@@ -568,9 +572,9 @@ static int p54p_probe(struct pci_dev *pdev, · 146 unmodified lines
568 goto err_disable_dev;572 goto err_disable_dev;
569 }573 }
570 574
571 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));575 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
572 if (!err)576 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));
574 if (err) {578 if (err) {
575 dev_err(&pdev->dev, "No suitable DMA available\n");579 dev_err(&pdev->dev, "No suitable DMA available\n");
576 goto err_free_reg;580 goto err_free_reg;
@@ -603,8 +607,9 @@ static int p54p_probe(struct pci_dev *pdev, · 26 unmodified lines
603 goto err_free_dev;607 goto err_free_dev;
604 }608 }
605 609
606 priv->ring_control = pci_alloc_consistent(pdev, sizeof(*priv->ring_control),610 priv->ring_control = dma_alloc_coherent(&pdev->dev,
607 &priv->ring_control_dma);611 sizeof(*priv->ring_control),
612 &priv->ring_control_dma, GFP_KERNEL);
608 if (!priv->ring_control) {613 if (!priv->ring_control) {
609 dev_err(&pdev->dev, "Cannot allocate rings\n");614 dev_err(&pdev->dev, "Cannot allocate rings\n");
610 err = -ENOMEM;615 err = -ENOMEM;
@@ -623,8 +628,8 @@ static int p54p_probe(struct pci_dev *pdev, · 12 unmodified lines
623 if (!err)628 if (!err)
624 return 0;629 return 0;
625 630
626 pci_free_consistent(pdev, sizeof(*priv->ring_control),631 dma_free_coherent(&pdev->dev, sizeof(*priv->ring_control),
627 priv->ring_control, priv->ring_control_dma);632 priv->ring_control, priv->ring_control_dma);
628 633
629 err_iounmap:634 err_iounmap:
630 iounmap(priv->map);635 iounmap(priv->map);
@@ -653,8 +658,8 @@ static void p54p_remove(struct pci_dev *pdev) · 22 unmodified lines
653 wait_for_completion(&priv->fw_loaded);658 wait_for_completion(&priv->fw_loaded);
654 p54_unregister_common(dev);659 p54_unregister_common(dev);
655 release_firmware(priv->firmware);660 release_firmware(priv->firmware);
656 pci_free_consistent(pdev, sizeof(*priv->ring_control),661 dma_free_coherent(&pdev->dev, sizeof(*priv->ring_control),
657 priv->ring_control, priv->ring_control_dma);662 priv->ring_control, priv->ring_control_dma);
658 iounmap(priv->map);663 iounmap(priv->map);
659 pci_release_regions(pdev);664 pci_release_regions(pdev);
660 pci_disable_device(pdev);665 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
36 * Note:36 * Note:
37 *37 *
38 * Always update our wiki's device list (located at:38 * 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 ),
40 * whenever you add a new device.40 * whenever you add a new device.
41 */41 */
42 42
drivers/net/wireless/intersil/prism54/isl_oid.h+1−1
@@ -143,7 +143,7 @@ enum dot11_priv_t { · 142 unmodified lines
143 * together with a CSMA contention. Without this all frames are143 * together with a CSMA contention. Without this all frames are
144 * sent with a CSMA contention.144 * sent with a CSMA contention.
145 * Bibliography:145 * Bibliography:
146 * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html146 * https://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html
147 */147 */
148enum dot11_maxframeburst_t {148enum dot11_maxframeburst_t {
149 /* Values for DOT11_OID_MAXFRAMEBURST */149 /* 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
636 */636 */
637 637
638 /* perform the allocation */638 /* perform the allocation */
639 priv->driver_mem_address = pci_alloc_consistent(priv->pdev,639 priv->driver_mem_address = dma_alloc_coherent(&priv->pdev->dev,
640 HOST_MEM_BLOCK,640 HOST_MEM_BLOCK,
641 &priv->641 &priv->device_host_address,
642 device_host_address);642 GFP_KERNEL);
643 643
644 if (!priv->driver_mem_address) {644 if (!priv->driver_mem_address) {
645 /* error allocating the block of PCI memory */645 /* error allocating the block of PCI memory */
@@ -692,11 +692,9 @@ islpci_alloc_memory(islpci_private *priv) · 46 unmodified lines
692 692
693 /* map the allocated skb data area to pci */693 /* map the allocated skb data area to pci */
694 priv->pci_map_rx_address[counter] =694 priv->pci_map_rx_address[counter] =
695 pci_map_single(priv->pdev, (void *) skb->data,695 dma_map_single(&priv->pdev->dev, (void *)skb->data,
696 MAX_FRAGMENT_SIZE_RX + 2,696 MAX_FRAGMENT_SIZE_RX + 2, DMA_FROM_DEVICE);
697 PCI_DMA_FROMDEVICE);697 if (dma_mapping_error(&priv->pdev->dev, priv->pci_map_rx_address[counter])) {
698 if (pci_dma_mapping_error(priv->pdev,
699 priv->pci_map_rx_address[counter])) {
700 priv->pci_map_rx_address[counter] = 0;698 priv->pci_map_rx_address[counter] = 0;
701 /* error mapping the buffer to device699 /* error mapping the buffer to device
702 accessible memory address */700 accessible memory address */
@@ -727,9 +725,9 @@ islpci_free_memory(islpci_private *priv) · 24 unmodified lines
727 725
728 /* free consistent DMA area... */726 /* free consistent DMA area... */
729 if (priv->driver_mem_address)727 if (priv->driver_mem_address)
730 pci_free_consistent(priv->pdev, HOST_MEM_BLOCK,728 dma_free_coherent(&priv->pdev->dev, HOST_MEM_BLOCK,
731 priv->driver_mem_address,729 priv->driver_mem_address,
732 priv->device_host_address);730 priv->device_host_address);
733 731
734 /* clear some dangling pointers */732 /* clear some dangling pointers */
735 priv->driver_mem_address = NULL;733 priv->driver_mem_address = NULL;
@@ -741,8 +739,8 @@ islpci_free_memory(islpci_private *priv) · 5 unmodified lines
741 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {739 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {
742 struct islpci_membuf *buf = &priv->mgmt_rx[counter];740 struct islpci_membuf *buf = &priv->mgmt_rx[counter];
743 if (buf->pci_addr)741 if (buf->pci_addr)
744 pci_unmap_single(priv->pdev, buf->pci_addr,742 dma_unmap_single(&priv->pdev->dev, buf->pci_addr,
745 buf->size, PCI_DMA_FROMDEVICE);743 buf->size, DMA_FROM_DEVICE);
746 buf->pci_addr = 0;744 buf->pci_addr = 0;
747 kfree(buf->mem);745 kfree(buf->mem);
748 buf->size = 0;746 buf->size = 0;
@@ -752,10 +750,10 @@ islpci_free_memory(islpci_private *priv) · 3 unmodified lines
752 /* clean up data rx buffers */750 /* clean up data rx buffers */
753 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {751 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
754 if (priv->pci_map_rx_address[counter])752 if (priv->pci_map_rx_address[counter])
755 pci_unmap_single(priv->pdev,753 dma_unmap_single(&priv->pdev->dev,
756 priv->pci_map_rx_address[counter],754 priv->pci_map_rx_address[counter],
757 MAX_FRAGMENT_SIZE_RX + 2,755 MAX_FRAGMENT_SIZE_RX + 2,
758 PCI_DMA_FROMDEVICE);756 DMA_FROM_DEVICE);
759 priv->pci_map_rx_address[counter] = 0;757 priv->pci_map_rx_address[counter] = 0;
760 758
761 if (priv->data_low_rx[counter])759 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
50 skb, skb->data, skb->len, skb->truesize);50 skb, skb->data, skb->len, skb->truesize);
51#endif51#endif
52 52
53 pci_unmap_single(priv->pdev,53 dma_unmap_single(&priv->pdev->dev,
54 priv->pci_map_tx_address[index],54 priv->pci_map_tx_address[index],
55 skb->len, PCI_DMA_TODEVICE);55 skb->len, DMA_TO_DEVICE);
56 dev_kfree_skb_irq(skb);56 dev_kfree_skb_irq(skb);
57 skb = NULL;57 skb = NULL;
58 }58 }
@@ -176,10 +176,9 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev) · 117 unmodified lines
176#endif176#endif
177 177
178 /* map the skb buffer to pci memory for DMA operation */178 /* map the skb buffer to pci memory for DMA operation */
179 pci_map_address = pci_map_single(priv->pdev,179 pci_map_address = dma_map_single(&priv->pdev->dev, (void *)skb->data,
180 (void *) skb->data, skb->len,180 skb->len, DMA_TO_DEVICE);
181 PCI_DMA_TODEVICE);181 if (dma_mapping_error(&priv->pdev->dev, pci_map_address)) {
182 if (pci_dma_mapping_error(priv->pdev, pci_map_address)) {
183 printk(KERN_WARNING "%s: cannot map buffer to PCI\n",182 printk(KERN_WARNING "%s: cannot map buffer to PCI\n",
184 ndev->name);183 ndev->name);
185 goto drop_free;184 goto drop_free;
@@ -323,9 +322,8 @@ islpci_eth_receive(islpci_private *priv) · 137 unmodified lines
323#endif322#endif
324 323
325 /* delete the streaming DMA mapping before processing the skb */324 /* delete the streaming DMA mapping before processing the skb */
326 pci_unmap_single(priv->pdev,325 dma_unmap_single(&priv->pdev->dev, priv->pci_map_rx_address[index],
327 priv->pci_map_rx_address[index],326 MAX_FRAGMENT_SIZE_RX + 2, DMA_FROM_DEVICE);
328 MAX_FRAGMENT_SIZE_RX + 2, PCI_DMA_FROMDEVICE);
329 327
330 /* update the skb structure and align the buffer */328 /* update the skb structure and align the buffer */
331 skb_put(skb, size);329 skb_put(skb, size);
@@ -431,11 +429,9 @@ islpci_eth_receive(islpci_private *priv) · 99 unmodified lines
431 429
432 /* set the streaming DMA mapping for proper PCI bus operation */430 /* set the streaming DMA mapping for proper PCI bus operation */
433 priv->pci_map_rx_address[index] =431 priv->pci_map_rx_address[index] =
434 pci_map_single(priv->pdev, (void *) skb->data,432 dma_map_single(&priv->pdev->dev, (void *)skb->data,
435 MAX_FRAGMENT_SIZE_RX + 2,433 MAX_FRAGMENT_SIZE_RX + 2, DMA_FROM_DEVICE);
436 PCI_DMA_FROMDEVICE);434 if (dma_mapping_error(&priv->pdev->dev, priv->pci_map_rx_address[index])) {
437 if (pci_dma_mapping_error(priv->pdev,
438 priv->pci_map_rx_address[index])) {
439 /* error mapping the buffer to device accessible memory address */435 /* error mapping the buffer to device accessible memory address */
440 DEBUG(SHOW_ERROR_MESSAGES,436 DEBUG(SHOW_ERROR_MESSAGES,
441 "Error mapping DMA address\n");437 "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
26/* In this order: vendor, device, subvendor, subdevice, class, class_mask,26/* In this order: vendor, device, subvendor, subdevice, class, class_mask,
27 * driver_data27 * driver_data
28 * If you have an update for this please contact prism54-devel@prism54.org28 * 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 */
30static const struct pci_device_id prism54_id_tbl[] = {31static const struct pci_device_id prism54_id_tbl[] = {
31 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */32 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
32 {33 {
@@ -63,16 +64,17 @@ MODULE_DEVICE_TABLE(pci, prism54_id_tbl); · 30 unmodified lines
63 64
64static int prism54_probe(struct pci_dev *, const struct pci_device_id *);65static int prism54_probe(struct pci_dev *, const struct pci_device_id *);
65static void prism54_remove(struct pci_dev *);66static void prism54_remove(struct pci_dev *);
66static int prism54_suspend(struct pci_dev *, pm_message_t state);67static int __maybe_unused prism54_suspend(struct device *);
67static int prism54_resume(struct pci_dev *);68static int __maybe_unused prism54_resume(struct device *);
69
70static SIMPLE_DEV_PM_OPS(prism54_pm_ops, prism54_suspend, prism54_resume);
68 71
69static struct pci_driver prism54_driver = {72static struct pci_driver prism54_driver = {
70 .name = DRV_NAME,73 .name = DRV_NAME,
71 .id_table = prism54_id_tbl,74 .id_table = prism54_id_tbl,
72 .probe = prism54_probe,75 .probe = prism54_probe,
73 .remove = prism54_remove,76 .remove = prism54_remove,
74 .suspend = prism54_suspend,77 .driver.pm = &prism54_pm_ops,
75 .resume = prism54_resume,
76};78};
77 79
78/******************************************************************************80/******************************************************************************
@@ -106,7 +108,7 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 27 unmodified lines
106 }108 }
107 109
108 /* enable PCI DMA */110 /* 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))) {
110 printk(KERN_ERR "%s: 32-bit PCI DMA not supported", DRV_NAME);112 printk(KERN_ERR "%s: 32-bit PCI DMA not supported", DRV_NAME);
111 goto do_pci_disable_device;113 goto do_pci_disable_device;
112 }114 }
@@ -243,16 +245,13 @@ prism54_remove(struct pci_dev *pdev) · 130 unmodified lines
243 pci_disable_device(pdev);245 pci_disable_device(pdev);
244}246}
245 247
246static int248static int __maybe_unused
247prism54_suspend(struct pci_dev *pdev, pm_message_t state)249prism54_suspend(struct device *dev)
248{250{
249 struct net_device *ndev = pci_get_drvdata(pdev);251 struct net_device *ndev = dev_get_drvdata(dev);
250 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;252 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
251 BUG_ON(!priv);253 BUG_ON(!priv);
252 254
253
254 pci_save_state(pdev);
255
256 /* tell the device not to trigger interrupts for now... */255 /* tell the device not to trigger interrupts for now... */
257 isl38xx_disable_interrupts(priv->device_base);256 isl38xx_disable_interrupts(priv->device_base);
258 257
@@ -266,26 +265,16 @@ prism54_suspend(struct pci_dev *pdev, pm_message_t state) · 7 unmodified lines
266 return 0;265 return 0;
267}266}
268 267
269static int268static int __maybe_unused
270prism54_resume(struct pci_dev *pdev)269prism54_resume(struct device *dev)
271{270{
272 struct net_device *ndev = pci_get_drvdata(pdev);271 struct net_device *ndev = dev_get_drvdata(dev);
273 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;272 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
274 int err;
275 273
276 BUG_ON(!priv);274 BUG_ON(!priv);
277 275
278 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);276 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
279 277
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
289 /* alright let's go into the PREBOOT state */278 /* alright let's go into the PREBOOT state */
290 islpci_reset(priv, 1);279 islpci_reset(priv, 1);
291 280
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
115 buf->size = MGMT_FRAME_SIZE;115 buf->size = MGMT_FRAME_SIZE;
116 }116 }
117 if (buf->pci_addr == 0) {117 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,
119 MGMT_FRAME_SIZE,120 MGMT_FRAME_SIZE,
120 PCI_DMA_FROMDEVICE);121 DMA_FROM_DEVICE);
121 if (pci_dma_mapping_error(priv->pdev, buf->pci_addr)) {122 if (dma_mapping_error(&priv->pdev->dev, buf->pci_addr)) {
122 printk(KERN_WARNING123 printk(KERN_WARNING
123 "Failed to make memory DMA'able.\n");124 "Failed to make memory DMA'able.\n");
124 return -ENOMEM;125 return -ENOMEM;
@@ -203,9 +204,9 @@ islpci_mgt_transmit(struct net_device *ndev, int operation, unsigned long oid, · 78 unmodified lines
203#endif204#endif
204 205
205 err = -ENOMEM;206 err = -ENOMEM;
206 buf.pci_addr = pci_map_single(priv->pdev, buf.mem, frag_len,207 buf.pci_addr = dma_map_single(&priv->pdev->dev, buf.mem, frag_len,
207 PCI_DMA_TODEVICE);208 DMA_TO_DEVICE);
208 if (pci_dma_mapping_error(priv->pdev, buf.pci_addr)) {209 if (dma_mapping_error(&priv->pdev->dev, buf.pci_addr)) {
209 printk(KERN_WARNING "%s: cannot map PCI memory for mgmt\n",210 printk(KERN_WARNING "%s: cannot map PCI memory for mgmt\n",
210 ndev->name);211 ndev->name);
211 goto error_free;212 goto error_free;
@@ -302,8 +303,8 @@ islpci_mgt_receive(struct net_device *ndev) · 90 unmodified lines
302 }303 }
303 304
304 /* Ensure the results of device DMA are visible to the CPU. */305 /* Ensure the results of device DMA are visible to the CPU. */
305 pci_dma_sync_single_for_cpu(priv->pdev, buf->pci_addr,306 dma_sync_single_for_cpu(&priv->pdev->dev, buf->pci_addr,
306 buf->size, PCI_DMA_FROMDEVICE);307 buf->size, DMA_FROM_DEVICE);
307 308
308 /* Perform endianess conversion for PIMFOR header in-place. */309 /* Perform endianess conversion for PIMFOR header in-place. */
309 header = pimfor_decode_header(buf->mem, frag_len);310 header = pimfor_decode_header(buf->mem, frag_len);
@@ -414,8 +415,8 @@ islpci_mgt_cleanup_transmit(struct net_device *ndev) · 104 unmodified lines
414 for (; priv->index_mgmt_tx < curr_frag; priv->index_mgmt_tx++) {415 for (; priv->index_mgmt_tx < curr_frag; priv->index_mgmt_tx++) {
415 int index = priv->index_mgmt_tx % ISL38XX_CB_MGMT_QSIZE;416 int index = priv->index_mgmt_tx % ISL38XX_CB_MGMT_QSIZE;
416 struct islpci_membuf *buf = &priv->mgmt_tx[index];417 struct islpci_membuf *buf = &priv->mgmt_tx[index];
417 pci_unmap_single(priv->pdev, buf->pci_addr, buf->size,418 dma_unmap_single(&priv->pdev->dev, buf->pci_addr, buf->size,
418 PCI_DMA_TODEVICE);419 DMA_TO_DEVICE);
419 buf->pci_addr = 0;420 buf->pci_addr = 0;
420 kfree(buf->mem);421 kfree(buf->mem);
421 buf->mem = NULL;422 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
398 new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),398 new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),
399 GFP_KERNEL);399 GFP_KERNEL);
400 if (!new_node->rx_reorder_ptr) {400 if (!new_node->rx_reorder_ptr) {
401 kfree((u8 *) new_node);401 kfree(new_node);
402 mwifiex_dbg(priv->adapter, ERROR,402 mwifiex_dbg(priv->adapter, ERROR,
403 "%s: failed to alloc reorder_ptr\n", __func__);403 "%s: failed to alloc reorder_ptr\n", __func__);
404 return;404 return;
drivers/net/wireless/mediatek/mt76/Kconfig+4−0
@@ -12,6 +12,10 @@ config MT76_USB · 11 unmodified lines
12 tristate12 tristate
13 depends on MT76_CORE13 depends on MT76_CORE
14 14
15config MT76_SDIO
16 tristate
17 depends on MT76_CORE
18
15config MT76x02_LIB19config MT76x02_LIB
16 tristate20 tristate
17 select MT76_CORE21 select MT76_CORE
drivers/net/wireless/mediatek/mt76/Makefile+3−0
@@ -1,6 +1,7 @@
1# SPDX-License-Identifier: GPL-2.0-only1# SPDX-License-Identifier: GPL-2.0-only
2obj-$(CONFIG_MT76_CORE) += mt76.o2obj-$(CONFIG_MT76_CORE) += mt76.o
3obj-$(CONFIG_MT76_USB) += mt76-usb.o3obj-$(CONFIG_MT76_USB) += mt76-usb.o
4obj-$(CONFIG_MT76_SDIO) += mt76-sdio.o
4obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o5obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
5obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o6obj-$(CONFIG_MT76x02_USB) += mt76x02-usb.o
6 7
@@ -9,8 +10,10 @@ mt76-y := \ · 2 unmodified lines
9 tx.o agg-rx.o mcu.o10 tx.o agg-rx.o mcu.o
10 11
11mt76-$(CONFIG_PCI) += pci.o12mt76-$(CONFIG_PCI) += pci.o
13mt76-$(CONFIG_NL80211_TESTMODE) += testmode.o
12 14
13mt76-usb-y := usb.o usb_trace.o15mt76-usb-y := usb.o usb_trace.o
16mt76-sdio-y := sdio.o
14 17
15CFLAGS_trace.o := -I$(src)18CFLAGS_trace.o := -I$(src)
16CFLAGS_usb_trace.o := -I$(src)19CFLAGS_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
9{9{
10 struct mt76_dev *dev = data;10 struct mt76_dev *dev = data;
11 11
12 dev->bus->wr(dev, dev->debugfs_reg, val);12 __mt76_wr(dev, dev->debugfs_reg, val);
13 return 0;13 return 0;
14}14}
15 15
@@ -18,7 +18,7 @@ mt76_reg_get(void *data, u64 *val) · 2 unmodified lines
18{18{
19 struct mt76_dev *dev = data;19 struct mt76_dev *dev = data;
20 20
21 *val = dev->bus->rr(dev, dev->debugfs_reg);21 *val = __mt76_rr(dev, dev->debugfs_reg);
22 return 0;22 return 0;
23}23}
24 24
@@ -54,9 +54,6 @@ static int mt76_rx_queues_read(struct seq_file *s, void *data) · 29 unmodified lines
54 mt76_for_each_q_rx(dev, i) {54 mt76_for_each_q_rx(dev, i) {
55 struct mt76_queue *q = &dev->q_rx[i];55 struct mt76_queue *q = &dev->q_rx[i];
56 56
57 if (!q->ndesc)
58 continue;
59
60 queued = mt76_is_usb(dev) ? q->ndesc - q->queued : q->queued;57 queued = mt76_is_usb(dev) ? q->ndesc - q->queued : q->queued;
61 seq_printf(s, "%d: queued=%d head=%d tail=%d\n",58 seq_printf(s, "%d: queued=%d head=%d tail=%d\n",
62 i, queued, q->head, q->tail);59 i, queued, q->head, q->tail);
drivers/net/wireless/mediatek/mt76/dma.c+6−0
@@ -370,6 +370,12 @@ unmap: · 369 unmodified lines
370 tx_info.buf[n].len, DMA_TO_DEVICE);370 tx_info.buf[n].len, DMA_TO_DEVICE);
371 371
372free:372free:
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
373 e.skb = tx_info.skb;379 e.skb = tx_info.skb;
374 e.txwi = t;380 e.txwi = t;
375 dev->drv->tx_complete_skb(dev, qid, &e);381 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
74 &data[i]);74 &data[i]);
75 }75 }
76 76
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
77out_put_node:82out_put_node:
78 of_node_put(np);83 of_node_put(np);
79 return ret;84 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
58 CHAN5G(132, 5660),58 CHAN5G(132, 5660),
59 CHAN5G(136, 5680),59 CHAN5G(136, 5680),
60 CHAN5G(140, 5700),60 CHAN5G(140, 5700),
61 CHAN5G(144, 5720),
61 62
62 CHAN5G(149, 5745),63 CHAN5G(149, 5745),
63 CHAN5G(153, 5765),64 CHAN5G(153, 5765),
64 CHAN5G(157, 5785),65 CHAN5G(157, 5785),
65 CHAN5G(161, 5805),66 CHAN5G(161, 5805),
66 CHAN5G(165, 5825),67 CHAN5G(165, 5825),
68 CHAN5G(169, 5845),
69 CHAN5G(173, 5865),
67};70};
68 71
69static const struct ieee80211_tpt_blink mt76_tpt_blink[] = {72static 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
279 282
280 wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;283 wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
281 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH |284 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH |
282 WIPHY_FLAG_SUPPORTS_TDLS;285 WIPHY_FLAG_SUPPORTS_TDLS |
286 WIPHY_FLAG_AP_UAPSD;
283 287
284 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);288 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
285 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_AIRTIME_FAIRNESS);289 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
289 wiphy->available_antennas_rx = dev->phy.antenna_mask;293 wiphy->available_antennas_rx = dev->phy.antenna_mask;
290 294
291 hw->txq_data_size = sizeof(struct mt76_txq);295 hw->txq_data_size = sizeof(struct mt76_txq);
296 hw->uapsd_max_sp_len = IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL;
292 297
293 if (!hw->max_tx_fragments)298 if (!hw->max_tx_fragments)
294 hw->max_tx_fragments = 16;299 hw->max_tx_fragments = 16;
@@ -300,7 +305,11 @@ mt76_phy_init(struct mt76_dev *dev, struct ieee80211_hw *hw) · 5 unmodified lines
300 ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);305 ieee80211_hw_set(hw, SUPPORTS_CLONED_SKBS);
301 ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);306 ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
302 ieee80211_hw_set(hw, TX_AMSDU);307 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
304 ieee80211_hw_set(hw, MFP_CAPABLE);313 ieee80211_hw_set(hw, MFP_CAPABLE);
305 ieee80211_hw_set(hw, AP_LINK_PS);314 ieee80211_hw_set(hw, AP_LINK_PS);
306 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);315 ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
@@ -432,6 +441,12 @@ mt76_alloc_device(struct device *pdev, unsigned int size, · 125 unmodified lines
432 441
433 tasklet_init(&dev->tx_tasklet, mt76_tx_tasklet, (unsigned long)dev);442 tasklet_init(&dev->tx_tasklet, mt76_tx_tasklet, (unsigned long)dev);
434 443
444 dev->wq = alloc_ordered_workqueue("mt76", 0);
445 if (!dev->wq) {
446 ieee80211_free_hw(hw);
447 return NULL;
448 }
449
435 return dev;450 return dev;
436}451}
437EXPORT_SYMBOL_GPL(mt76_alloc_device);452EXPORT_SYMBOL_GPL(mt76_alloc_device);
@@ -485,7 +500,12 @@ EXPORT_SYMBOL_GPL(mt76_unregister_device); · 47 unmodified lines
485 500
486void mt76_free_device(struct mt76_dev *dev)501void mt76_free_device(struct mt76_dev *dev)
487{502{
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);
489 ieee80211_free_hw(dev->hw);509 ieee80211_free_hw(dev->hw);
490}510}
491EXPORT_SYMBOL_GPL(mt76_free_device);511EXPORT_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
500 return;520 return;
501 }521 }
502 522
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
503 __skb_queue_tail(&dev->rx_skb[q], skb);530 __skb_queue_tail(&dev->rx_skb[q], skb);
504}531}
505EXPORT_SYMBOL_GPL(mt76_rx);532EXPORT_SYMBOL_GPL(mt76_rx);
@@ -537,8 +564,7 @@ mt76_channel_state(struct mt76_phy *phy, struct ieee80211_channel *c) · 31 unmodified lines
537 return &msband->chan[idx];564 return &msband->chan[idx];
538}565}
539 566
540static void567void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
541mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time)
542{568{
543 struct mt76_channel_state *state = phy->chan_state;569 struct mt76_channel_state *state = phy->chan_state;
544 570
@@ -546,6 +572,7 @@ mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time) · 1 unmodified line
546 phy->survey_time));572 phy->survey_time));
547 phy->survey_time = time;573 phy->survey_time = time;
548}574}
575EXPORT_SYMBOL_GPL(mt76_update_survey_active_time);
549 576
550void mt76_update_survey(struct mt76_dev *dev)577void mt76_update_survey(struct mt76_dev *dev)
551{578{
drivers/net/wireless/mediatek/mt76/mt76.h+112−3
@@ -15,6 +15,7 @@ · 14 unmodified lines
15#include <linux/average.h>15#include <linux/average.h>
16#include <net/mac80211.h>16#include <net/mac80211.h>
17#include "util.h"17#include "util.h"
18#include "testmode.h"
18 19
19#define MT_TX_RING_SIZE 25620#define MT_TX_RING_SIZE 256
20#define MT_MCU_RING_SIZE 3221#define MT_MCU_RING_SIZE 32
@@ -33,6 +34,7 @@ struct mt76_reg_pair { · 12 unmodified lines
33enum mt76_bus_type {34enum mt76_bus_type {
34 MT76_BUS_MMIO,35 MT76_BUS_MMIO,
35 MT76_BUS_USB,36 MT76_BUS_USB,
37 MT76_BUS_SDIO,
36};38};
37 39
38struct mt76_bus_ops {40struct mt76_bus_ops {
@@ -52,6 +54,7 @@ struct mt76_bus_ops { · 13 unmodified lines
52 54
53#define mt76_is_usb(dev) ((dev)->bus->type == MT76_BUS_USB)55#define mt76_is_usb(dev) ((dev)->bus->type == MT76_BUS_USB)
54#define mt76_is_mmio(dev) ((dev)->bus->type == MT76_BUS_MMIO)56#define mt76_is_mmio(dev) ((dev)->bus->type == MT76_BUS_MMIO)
57#define mt76_is_sdio(dev) ((dev)->bus->type == MT76_BUS_SDIO)
55 58
56enum mt76_txq_id {59enum mt76_txq_id {
57 MT_TXQ_VO = IEEE80211_AC_VO,60 MT_TXQ_VO = IEEE80211_AC_VO,
@@ -94,6 +97,7 @@ struct mt76_queue_entry { · 36 unmodified lines
94 union {97 union {
95 struct mt76_txwi_cache *txwi;98 struct mt76_txwi_cache *txwi;
96 struct urb *urb;99 struct urb *urb;
100 int buf_sz;
97 };101 };
98 enum mt76_txq_id qid;102 enum mt76_txq_id qid;
99 bool skip_buf0:1;103 bool skip_buf0:1;
@@ -146,6 +150,8 @@ struct mt76_mcu_ops { · 46 unmodified lines
146 int len, bool wait_resp);150 int len, bool wait_resp);
147 int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,151 int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
148 int cmd, bool wait_resp);152 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);
149 int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,155 int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,
150 const struct mt76_reg_pair *rp, int len);156 const struct mt76_reg_pair *rp, int len);
151 int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base,157 int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base,
@@ -290,6 +296,7 @@ enum { · 138 unmodified lines
290 MT76_STATE_POWER_OFF,296 MT76_STATE_POWER_OFF,
291 MT76_STATE_SUSPEND,297 MT76_STATE_SUSPEND,
292 MT76_STATE_ROC,298 MT76_STATE_ROC,
299 MT76_STATE_PM,
293};300};
294 301
295struct mt76_hw_cap {302struct mt76_hw_cap {
@@ -422,7 +429,6 @@ struct mt76_usb { · 126 unmodified lines
422 u16 data_len;429 u16 data_len;
423 430
424 struct tasklet_struct rx_tasklet;431 struct tasklet_struct rx_tasklet;
425 struct workqueue_struct *wq;
426 struct work_struct stat_work;432 struct work_struct stat_work;
427 433
428 u8 out_ep[__MT_EP_OUT_MAX];434 u8 out_ep[__MT_EP_OUT_MAX];
@@ -439,6 +445,24 @@ struct mt76_usb { · 10 unmodified lines
439 } mcu;445 } mcu;
440};446};
441 447
448struct 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
442struct mt76_mmio {466struct mt76_mmio {
443 void __iomem *regs;467 void __iomem *regs;
444 spinlock_t irq_lock;468 spinlock_t irq_lock;
@@ -475,6 +499,47 @@ struct mt76_rx_status { · 30 unmodified lines
475 s8 chain_signal[IEEE80211_MAX_CHAINS];499 s8 chain_signal[IEEE80211_MAX_CHAINS];
476};500};
477 501
502struct 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
509struct 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
478struct mt76_phy {543struct mt76_phy {
479 struct ieee80211_hw *hw;544 struct ieee80211_hw *hw;
480 struct mt76_dev *dev;545 struct mt76_dev *dev;
@@ -491,6 +556,8 @@ struct mt76_phy { · 10 unmodified lines
491 struct mt76_sband sband_2g;556 struct mt76_sband sband_2g;
492 struct mt76_sband sband_5g;557 struct mt76_sband sband_5g;
493 558
559 u32 vif_mask;
560
494 int txpower_cur;561 int txpower_cur;
495 u8 antenna_mask;562 u8 antenna_mask;
496};563};
@@ -572,9 +639,17 @@ struct mt76_dev { · 75 unmodified lines
572 639
573 u32 rxfilter;640 u32 rxfilter;
574 641
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
575 union {649 union {
576 struct mt76_mmio mmio;650 struct mt76_mmio mmio;
577 struct mt76_usb usb;651 struct mt76_usb usb;
652 struct mt76_sdio sdio;
578 };653 };
579};654};
580 655
@@ -805,6 +880,15 @@ static inline u8 mt76_tx_power_nss_delta(u8 nss) · 224 unmodified lines
805 return nss_delta[nss - 1];880 return nss_delta[nss - 1];
806}881}
807 882
883static 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
808void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);892void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
809void mt76_tx(struct mt76_phy *dev, struct ieee80211_sta *sta,893void mt76_tx(struct mt76_phy *dev, struct ieee80211_sta *sta,
810 struct mt76_wcid *wcid, struct sk_buff *skb);894 struct mt76_wcid *wcid, struct sk_buff *skb);
@@ -824,6 +908,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw, · 13 unmodified lines
824bool mt76_has_tx_pending(struct mt76_phy *phy);908bool mt76_has_tx_pending(struct mt76_phy *phy);
825void mt76_set_channel(struct mt76_phy *phy);909void mt76_set_channel(struct mt76_phy *phy);
826void mt76_update_survey(struct mt76_dev *dev);910void mt76_update_survey(struct mt76_dev *dev);
911void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
827int mt76_get_survey(struct ieee80211_hw *hw, int idx,912int mt76_get_survey(struct ieee80211_hw *hw, int idx,
828 struct survey_info *survey);913 struct survey_info *survey);
829void mt76_set_stream_caps(struct mt76_phy *phy, bool vht);914void 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
877 const u8 *mac);962 const u8 *mac);
878void mt76_sw_scan_complete(struct ieee80211_hw *hw,963void mt76_sw_scan_complete(struct ieee80211_hw *hw,
879 struct ieee80211_vif *vif);964 struct ieee80211_vif *vif);
965int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
966 void *data, int len);
967int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
968 struct netlink_callback *cb, void *data, int len);
969int mt76_testmode_set_state(struct mt76_dev *dev, enum mt76_testmode_state state);
970
971static 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
880 983
881/* internal */984/* internal */
882static inline struct ieee80211_hw *985static inline struct ieee80211_hw *
@@ -901,6 +1004,7 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames, · 18 unmodified lines
901void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,1004void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
902 struct napi_struct *napi);1005 struct napi_struct *napi);
903void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);1006void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);
1007void mt76_testmode_tx_pending(struct mt76_dev *dev);
904 1008
905/* usb */1009/* usb */
906static inline bool mt76u_urb_error(struct urb *urb)1010static 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
935 return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout);1039 return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout);
936}1040}
937 1041
938int mt76u_skb_dma_info(struct sk_buff *skb, u32 info);1042int mt76_skb_adjust_pad(struct sk_buff *skb);
939int mt76u_vendor_request(struct mt76_dev *dev, u8 req,1043int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
940 u8 req_type, u16 val, u16 offset,1044 u8 req_type, u16 val, u16 offset,
941 void *buf, size_t len);1045 void *buf, size_t len);
942void mt76u_single_wr(struct mt76_dev *dev, const u8 req,1046void mt76u_single_wr(struct mt76_dev *dev, const u8 req,
943 const u16 offset, const u32 val);1047 const u16 offset, const u32 val);
944void mt76u_deinit(struct mt76_dev *dev);
945int mt76u_init(struct mt76_dev *dev, struct usb_interface *intf,1048int mt76u_init(struct mt76_dev *dev, struct usb_interface *intf,
946 bool ext);1049 bool ext);
947int mt76u_alloc_mcu_queue(struct mt76_dev *dev);1050int mt76u_alloc_mcu_queue(struct mt76_dev *dev);
@@ -951,6 +1054,12 @@ void mt76u_stop_rx(struct mt76_dev *dev); · 3 unmodified lines
951int mt76u_resume_rx(struct mt76_dev *dev);1054int mt76u_resume_rx(struct mt76_dev *dev);
952void mt76u_queues_deinit(struct mt76_dev *dev);1055void mt76u_queues_deinit(struct mt76_dev *dev);
953 1056
1057int mt76s_init(struct mt76_dev *dev, struct sdio_func *func,
1058 const struct mt76_bus_ops *bus_ops);
1059int mt76s_alloc_queues(struct mt76_dev *dev);
1060void mt76s_stop_txrx(struct mt76_dev *dev);
1061void mt76s_deinit(struct mt76_dev *dev);
1062
954struct sk_buff *1063struct sk_buff *
955mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,1064mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
956 int data_len);1065 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
44 44
45 mutex_lock(&dev->mt76.mutex);45 mutex_lock(&dev->mt76.mutex);
46 46
47 mvif->idx = ffs(~dev->vif_mask) - 1;47 mvif->idx = ffs(~dev->mphy.vif_mask) - 1;
48 if (mvif->idx >= MT7603_MAX_INTERFACES) {48 if (mvif->idx >= MT7603_MAX_INTERFACES) {
49 ret = -ENOSPC;49 ret = -ENOSPC;
50 goto out;50 goto out;
@@ -65,7 +65,7 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 14 unmodified lines
65 }65 }
66 66
67 idx = MT7603_WTBL_RESERVED - 1 - mvif->idx;67 idx = MT7603_WTBL_RESERVED - 1 - mvif->idx;
68 dev->vif_mask |= BIT(mvif->idx);68 dev->mphy.vif_mask |= BIT(mvif->idx);
69 INIT_LIST_HEAD(&mvif->sta.poll_list);69 INIT_LIST_HEAD(&mvif->sta.poll_list);
70 mvif->sta.wcid.idx = idx;70 mvif->sta.wcid.idx = idx;
71 mvif->sta.wcid.hw_key_idx = -1;71 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
107 spin_unlock_bh(&dev->sta_poll_lock);107 spin_unlock_bh(&dev->sta_poll_lock);
108 108
109 mutex_lock(&dev->mt76.mutex);109 mutex_lock(&dev->mt76.mutex);
110 dev->vif_mask &= ~BIT(mvif->idx);110 dev->mphy.vif_mask &= ~BIT(mvif->idx);
111 mutex_unlock(&dev->mt76.mutex);111 mutex_unlock(&dev->mt76.mutex);
112}112}
113 113
drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h+0−2
@@ -108,8 +108,6 @@ struct mt7603_dev { · 107 unmodified lines
108 108
109 u32 rxfilter;109 u32 rxfilter;
110 110
111 u8 vif_mask;
112
113 struct list_head sta_poll_list;111 struct list_head sta_poll_list;
114 spinlock_t sta_poll_lock;112 spinlock_t sta_poll_lock;
115 113
drivers/net/wireless/mediatek/mt76/mt7615/Kconfig+17−2
@@ -28,13 +28,28 @@ config MT7622_WMAC · 27 unmodified lines
28 which has the same feature set as a MT7615, but limited to28 which has the same feature set as a MT7615, but limited to
29 2.4 GHz only.29 2.4 GHz only.
30 30
31config MT7663_USB_SDIO_COMMON
32 tristate
33 select MT7615_COMMON
34
31config MT7663U35config MT7663U
32 tristate "MediaTek MT7663U (USB) support"36 tristate "MediaTek MT7663U (USB) support"
33 select MT76_USB37 select MT76_USB
34 select MT7615_COMMON38 select MT7663_USB_SDIO_COMMON
35 depends on MAC8021139 depends on MAC80211
36 depends on USB40 depends on USB
37 help41 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
46config 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.
39 54
40 To compile this driver as a module, choose M here.55 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
2 2
3obj-$(CONFIG_MT7615_COMMON) += mt7615-common.o3obj-$(CONFIG_MT7615_COMMON) += mt7615-common.o
4obj-$(CONFIG_MT7615E) += mt7615e.o4obj-$(CONFIG_MT7615E) += mt7615e.o
5obj-$(CONFIG_MT7663_USB_SDIO_COMMON) += mt7663-usb-sdio-common.o
5obj-$(CONFIG_MT7663U) += mt7663u.o6obj-$(CONFIG_MT7663U) += mt7663u.o
7obj-$(CONFIG_MT7663S) += mt7663s.o
6 8
7CFLAGS_trace.o := -I$(src)9CFLAGS_trace.o := -I$(src)
8 10
9mt7615-common-y := main.o init.o mcu.o eeprom.o mac.o \11mt7615-common-y := main.o init.o mcu.o eeprom.o mac.o \
10 debugfs.o trace.o12 debugfs.o trace.o
13mt7615-common-$(CONFIG_NL80211_TESTMODE) += testmode.o
11 14
12mt7615e-y := pci.o pci_init.o dma.o pci_mac.o mmio.o15mt7615e-y := pci.o pci_init.o dma.o pci_mac.o mmio.o
13mt7615e-$(CONFIG_MT7622_WMAC) += soc.o16mt7615e-$(CONFIG_MT7622_WMAC) += soc.o
14 17
15mt7663u-y := usb.o usb_mcu.o usb_init.o18mt7663-usb-sdio-common-y := usb_sdio.o
19mt7663u-y := usb.o usb_mcu.o
20mt7663s-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
6mt7615_radar_pattern_set(void *data, u64 val)6mt7615_radar_pattern_set(void *data, u64 val)
7{7{
8 struct mt7615_dev *dev = data;8 struct mt7615_dev *dev = data;
9 int err;
9 10
10 if (!mt7615_wait_for_mcu_init(dev))11 if (!mt7615_wait_for_mcu_init(dev))
11 return 0;12 return 0;
12 13
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;
14}19}
15 20
16DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_pattern, NULL,21DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_pattern, NULL,
@@ -46,6 +51,52 @@ mt7615_scs_get(void *data, u64 *val) · 29 unmodified lines
46DEFINE_DEBUGFS_ATTRIBUTE(fops_scs, mt7615_scs_get,51DEFINE_DEBUGFS_ATTRIBUTE(fops_scs, mt7615_scs_get,
47 mt7615_scs_set, "%lld\n");52 mt7615_scs_set, "%lld\n");
48 53
54static int
55mt7615_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
65static int
66mt7615_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
75DEFINE_DEBUGFS_ATTRIBUTE(fops_pm, mt7615_pm_get, mt7615_pm_set, "%lld\n");
76
77static int
78mt7615_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
87static int
88mt7615_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
97DEFINE_DEBUGFS_ATTRIBUTE(fops_pm_idle_timeout, mt7615_pm_idle_timeout_get,
98 mt7615_pm_idle_timeout_set, "%lld\n");
99
49static int100static int
50mt7615_dbdc_set(void *data, u64 val)101mt7615_dbdc_set(void *data, u64 val)
51{102{
@@ -84,7 +135,10 @@ mt7615_fw_debug_set(void *data, u64 val) · 32 unmodified lines
84 return 0;135 return 0;
85 136
86 dev->fw_debug = val;137 dev->fw_debug = val;
138
139 mt7615_mutex_acquire(dev);
87 mt7615_mcu_fw_log_2_host(dev, dev->fw_debug ? 2 : 0);140 mt7615_mcu_fw_log_2_host(dev, dev->fw_debug ? 2 : 0);
141 mt7615_mutex_release(dev);
88 142
89 return 0;143 return 0;
90}144}
@@ -111,6 +165,8 @@ mt7615_reset_test_set(void *data, u64 val) · 20 unmodified lines
111 if (!mt7615_wait_for_mcu_init(dev))165 if (!mt7615_wait_for_mcu_init(dev))
112 return 0;166 return 0;
113 167
168 mt7615_mutex_acquire(dev);
169
114 skb = alloc_skb(1, GFP_KERNEL);170 skb = alloc_skb(1, GFP_KERNEL);
115 if (!skb)171 if (!skb)
116 return -ENOMEM;172 return -ENOMEM;
@@ -118,6 +174,8 @@ mt7615_reset_test_set(void *data, u64 val) · 1 unmodified line
118 skb_put(skb, 1);174 skb_put(skb, 1);
119 mt76_tx_queue_skb_raw(dev, 0, skb, 0);175 mt76_tx_queue_skb_raw(dev, 0, skb, 0);
120 176
177 mt7615_mutex_release(dev);
178
121 return 0;179 return 0;
122}180}
123 181
@@ -167,9 +225,13 @@ mt7615_ampdu_stat_read(struct seq_file *file, void *data) · 43 unmodified lines
167{225{
168 struct mt7615_dev *dev = file->private;226 struct mt7615_dev *dev = file->private;
169 227
228 mt7615_mutex_acquire(dev);
229
170 mt7615_ampdu_stat_read_phy(&dev->phy, file);230 mt7615_ampdu_stat_read_phy(&dev->phy, file);
171 mt7615_ampdu_stat_read_phy(mt7615_ext_phy(dev), file);231 mt7615_ampdu_stat_read_phy(mt7615_ext_phy(dev), file);
172 232
233 mt7615_mutex_release(dev);
234
173 return 0;235 return 0;
174}236}
175 237
@@ -221,7 +283,10 @@ static int mt7615_read_temperature(struct seq_file *s, void *data) · 45 unmodified lines
221 return 0;283 return 0;
222 284
223 /* cpu */285 /* cpu */
286 mt7615_mutex_acquire(dev);
224 temp = mt7615_mcu_get_temperature(dev, 0);287 temp = mt7615_mcu_get_temperature(dev, 0);
288 mt7615_mutex_release(dev);
289
225 seq_printf(s, "Temperature: %d\n", temp);290 seq_printf(s, "Temperature: %d\n", temp);
226 291
227 return 0;292 return 0;
@@ -233,6 +298,8 @@ mt7615_queues_acq(struct seq_file *s, void *data) · 5 unmodified lines
233 struct mt7615_dev *dev = dev_get_drvdata(s->private);298 struct mt7615_dev *dev = dev_get_drvdata(s->private);
234 int i;299 int i;
235 300
301 mt7615_mutex_acquire(dev);
302
236 for (i = 0; i < 16; i++) {303 for (i = 0; i < 16; i++) {
237 int j, wmm_idx = i % MT7615_MAX_WMM_SETS;304 int j, wmm_idx = i % MT7615_MAX_WMM_SETS;
238 int acs = i / MT7615_MAX_WMM_SETS;305 int acs = i / MT7615_MAX_WMM_SETS;
@@ -253,6 +320,8 @@ mt7615_queues_acq(struct seq_file *s, void *data) · 14 unmodified lines
253 seq_printf(s, "AC%d%d: queued=%d\n", wmm_idx, acs, qlen);320 seq_printf(s, "AC%d%d: queued=%d\n", wmm_idx, acs, qlen);
254 }321 }
255 322
323 mt7615_mutex_release(dev);
324
256 return 0;325 return 0;
257}326}
258 327
@@ -285,6 +354,29 @@ mt7615_queues_read(struct seq_file *s, void *data) · 26 unmodified lines
285 return 0;354 return 0;
286}355}
287 356
357static int
358mt7615_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
367static int
368mt7615_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
377DEFINE_DEBUGFS_ATTRIBUTE(fops_rf_reg, mt7615_rf_reg_get, mt7615_rf_reg_set,
378 "0x%08llx\n");
379
288int mt7615_init_debugfs(struct mt7615_dev *dev)380int mt7615_init_debugfs(struct mt7615_dev *dev)
289{381{
290 struct dentry *dir;382 struct dentry *dir;
@@ -305,6 +397,9 @@ int mt7615_init_debugfs(struct mt7615_dev *dev) · 14 unmodified lines
305 debugfs_create_file("scs", 0600, dir, dev, &fops_scs);397 debugfs_create_file("scs", 0600, dir, dev, &fops_scs);
306 debugfs_create_file("dbdc", 0600, dir, dev, &fops_dbdc);398 debugfs_create_file("dbdc", 0600, dir, dev, &fops_dbdc);
307 debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug);399 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);
308 debugfs_create_devm_seqfile(dev->mt76.dev, "radio", dir,403 debugfs_create_devm_seqfile(dev->mt76.dev, "radio", dir,
309 mt7615_radio_read);404 mt7615_radio_read);
310 debugfs_create_u32("dfs_hw_pattern", 0400, dir, &dev->hw_pattern);405 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
324 debugfs_create_devm_seqfile(dev->mt76.dev, "temperature", dir,419 debugfs_create_devm_seqfile(dev->mt76.dev, "temperature", dir,
325 mt7615_read_temperature);420 mt7615_read_temperature);
326 421
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
327 return 0;427 return 0;
328}428}
329EXPORT_SYMBOL_GPL(mt7615_init_debugfs);429EXPORT_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
122 122
123 mt7615_tx_cleanup(dev);123 mt7615_tx_cleanup(dev);
124 124
125 rcu_read_lock();
126 mt7615_mac_sta_poll(dev);
127 rcu_read_unlock();
128
129 tasklet_schedule(&dev->mt76.tx_tasklet);125 tasklet_schedule(&dev->mt76.tx_tasklet);
130 126
131 return 0;127 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
285 if (!(chandef->chan->flags & IEEE80211_CHAN_RADAR))285 if (!(chandef->chan->flags & IEEE80211_CHAN_RADAR))
286 return;286 return;
287 287
288 mt7615_mutex_acquire(dev);
288 mt7615_dfs_init_radar_detector(phy);289 mt7615_dfs_init_radar_detector(phy);
290 mt7615_mutex_release(dev);
289}291}
290 292
291static void293static void
@@ -321,6 +323,7 @@ mt7615_init_wiphy(struct ieee80211_hw *hw) · 29 unmodified lines
321 323
322 ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);324 ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
323 ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN);325 ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN);
326 ieee80211_hw_set(hw, WANT_MONITOR_VIF);
324 327
325 if (is_mt7615(&phy->dev->mt76))328 if (is_mt7615(&phy->dev->mt76))
326 hw->max_tx_fragments = MT_TXP_MAX_BUF_NUM;329 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
405 mphy->sband_2g.sband.n_channels = 0;408 mphy->sband_2g.sband.n_channels = 0;
406 mphy->hw->wiphy->bands[NL80211_BAND_2GHZ] = NULL;409 mphy->hw->wiphy->bands[NL80211_BAND_2GHZ] = NULL;
407 410
408 /* The second interface does not get any packets unless it has a vif */
409 ieee80211_hw_set(mphy->hw, WANT_MONITOR_VIF);
410
411 ret = mt76_register_phy(mphy);411 ret = mt76_register_phy(mphy);
412 if (ret)412 if (ret)
413 ieee80211_free_hw(mphy->hw);413 ieee80211_free_hw(mphy->hw);
@@ -437,6 +437,12 @@ void mt7615_init_device(struct mt7615_dev *dev) · 23 unmodified lines
437 dev->phy.dev = dev;437 dev->phy.dev = dev;
438 dev->phy.mt76 = &dev->mt76.phy;438 dev->phy.mt76 = &dev->mt76.phy;
439 dev->mt76.phy.priv = &dev->phy;439 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);
440 INIT_DELAYED_WORK(&dev->phy.mac_work, mt7615_mac_work);446 INIT_DELAYED_WORK(&dev->phy.mac_work, mt7615_mac_work);
441 INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);447 INIT_DELAYED_WORK(&dev->phy.scan_work, mt7615_scan_work);
442 skb_queue_head_init(&dev->phy.scan_event_list);448 skb_queue_head_init(&dev->phy.scan_event_list);
@@ -450,6 +456,7 @@ void mt7615_init_device(struct mt7615_dev *dev) · 7 unmodified lines
450 timer_setup(&dev->phy.roc_timer, mt7615_roc_timer, 0);456 timer_setup(&dev->phy.roc_timer, mt7615_roc_timer, 0);
451 457
452 mt7615_init_wiphy(hw);458 mt7615_init_wiphy(hw);
459 dev->pm.idle_timeout = MT7615_PM_TIMEOUT;
453 dev->mphy.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;460 dev->mphy.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
454 dev->mphy.sband_5g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;461 dev->mphy.sband_5g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
455 dev->mphy.sband_5g.sband.vht_cap.cap |=462 dev->mphy.sband_5g.sband.vht_cap.cap |=
@@ -457,5 +464,9 @@ void mt7615_init_device(struct mt7615_dev *dev) · 1 unmodified line
457 IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK;464 IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK;
458 mt7615_cap_dbdc_disable(dev);465 mt7615_cap_dbdc_disable(dev);
459 dev->phy.dfs_state = -1;466 dev->phy.dfs_state = -1;
467
468#ifdef CONFIG_NL80211_TESTMODE
469 dev->mt76.test_ops = &mt7615_testmode_ops;
470#endif
460}471}
461EXPORT_SYMBOL_GPL(mt7615_init_device);472EXPORT_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
186 status->freq = ieee80211_channel_to_frequency(chfreq, status->band);186 status->freq = ieee80211_channel_to_frequency(chfreq, status->band);
187}187}
188 188
189static 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
189static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)223static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
190{224{
191 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;225 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
401 status->chain_signal[i]);435 status->chain_signal[i]);
402 }436 }
403 437
438 mt7615_mac_fill_tm_rx(dev, rxd);
439
404 rxd += 6;440 rxd += 6;
405 if ((u8 *)rxd - skb->data >= skb->len)441 if ((u8 *)rxd - skb->data >= skb->len)
406 return -EINVAL;442 return -EINVAL;
@@ -493,18 +529,18 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 86 unmodified lines
493 struct ieee80211_sta *sta, int pid,529 struct ieee80211_sta *sta, int pid,
494 struct ieee80211_key_conf *key, bool beacon)530 struct ieee80211_key_conf *key, bool beacon)
495{531{
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;
496 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);534 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
497 struct ieee80211_tx_rate *rate = &info->control.rates[0];535 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;
499 bool multicast = is_multicast_ether_addr(hdr->addr1);537 bool multicast = is_multicast_ether_addr(hdr->addr1);
500 struct ieee80211_vif *vif = info->control.vif;538 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;
501 struct mt76_phy *mphy = &dev->mphy;541 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;
506 __le16 fc = hdr->frame_control;542 __le16 fc = hdr->frame_control;
507 u32 val, sz_txd = is_usb ? MT_USB_TXD_SIZE : MT_TXD_SIZE;543 int tx_count = 8;
508 u16 seqno = 0;544 u16 seqno = 0;
509 545
510 if (vif) {546 if (vif) {
@@ -530,10 +566,10 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 19 unmodified lines
530 p_fmt = MT_TX_TYPE_FW;566 p_fmt = MT_TX_TYPE_FW;
531 q_idx = ext_phy ? MT_LMAC_BCN1 : MT_LMAC_BCN0;567 q_idx = ext_phy ? MT_LMAC_BCN1 : MT_LMAC_BCN0;
532 } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {568 } 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;
534 q_idx = ext_phy ? MT_LMAC_ALTX1 : MT_LMAC_ALTX0;570 q_idx = ext_phy ? MT_LMAC_ALTX1 : MT_LMAC_ALTX0;
535 } else {571 } 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;
537 q_idx = wmm_idx * MT7615_MAX_WMM_SETS +573 q_idx = wmm_idx * MT7615_MAX_WMM_SETS +
538 mt7615_lmac_mapping(dev, skb_get_queue_mapping(skb));574 mt7615_lmac_mapping(dev, skb_get_queue_mapping(skb));
539 }575 }
@@ -617,16 +653,19 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 77 unmodified lines
617 }653 }
618 654
619 val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count);655 val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count);
620 if (ieee80211_is_data_qos(hdr->frame_control)) {656 if (info->flags & IEEE80211_TX_CTL_INJECTED) {
621 seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));657 seqno = le16_to_cpu(hdr->seq_ctrl);
622 val |= MT_TXD3_SN_VALID;658
623 } else if (ieee80211_is_back_req(hdr->frame_control)) {659 if (ieee80211_is_back_req(hdr->frame_control)) {
624 struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data;660 struct ieee80211_bar *bar;
625 661
626 seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(bar->start_seq_num));662 bar = (struct ieee80211_bar *)skb->data;
627 val |= MT_TXD3_SN_VALID;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));
628 }668 }
629 val |= FIELD_PREP(MT_TXD3_SEQ, seqno);
630 669
631 txwi[3] |= cpu_to_le32(val);670 txwi[3] |= cpu_to_le32(val);
632 671
@@ -636,7 +675,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, · 3 unmodified lines
636 txwi[7] = FIELD_PREP(MT_TXD7_TYPE, fc_type) |675 txwi[7] = FIELD_PREP(MT_TXD7_TYPE, fc_type) |
637 FIELD_PREP(MT_TXD7_SUB_TYPE, fc_stype) |676 FIELD_PREP(MT_TXD7_SUB_TYPE, fc_stype) |
638 FIELD_PREP(MT_TXD7_SPE_IDX, 0x18);677 FIELD_PREP(MT_TXD7_SPE_IDX, 0x18);
639 if (is_usb)678 if (!is_mmio)
640 txwi[8] = FIELD_PREP(MT_TXD8_L_TYPE, fc_type) |679 txwi[8] = FIELD_PREP(MT_TXD8_L_TYPE, fc_type) |
641 FIELD_PREP(MT_TXD8_L_SUB_TYPE, fc_stype);680 FIELD_PREP(MT_TXD8_L_SUB_TYPE, fc_stype);
642 681
@@ -878,6 +917,9 @@ mt7615_mac_queue_rate_update(struct mt7615_phy *phy, struct mt7615_sta *sta, · 235 unmodified lines
878 struct mt7615_dev *dev = phy->dev;917 struct mt7615_dev *dev = phy->dev;
879 struct mt7615_wtbl_desc *wd;918 struct mt7615_wtbl_desc *wd;
880 919
920 if (work_pending(&dev->wtbl_work))
921 return -EBUSY;
922
881 wd = kzalloc(sizeof(*wd), GFP_ATOMIC);923 wd = kzalloc(sizeof(*wd), GFP_ATOMIC);
882 if (!wd)924 if (!wd)
883 return -ENOMEM;925 return -ENOMEM;
@@ -888,11 +930,34 @@ mt7615_mac_queue_rate_update(struct mt7615_phy *phy, struct mt7615_sta *sta, · 4 unmodified lines
888 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates,930 mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates,
889 &wd->rate);931 &wd->rate);
890 list_add_tail(&wd->node, &dev->wd_head);932 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);
892 934
893 return 0;935 return 0;
894}936}
895 937
938u32 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
896void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,961void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
897 struct ieee80211_tx_rate *probe_rate,962 struct ieee80211_tx_rate *probe_rate,
898 struct ieee80211_tx_rate *rates)963 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
902 struct mt7615_rate_desc rd;967 struct mt7615_rate_desc rd;
903 u32 w5, w27, addr;968 u32 w5, w27, addr;
904 969
905 if (mt76_is_usb(&dev->mt76)) {970 if (!mt76_is_mmio(&dev->mt76)) {
906 mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates);971 mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates);
907 return;972 return;
908 }973 }
@@ -961,6 +1026,7 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, · 52 unmodified lines
961 1026
962 sta->rate_count = 2 * MT7615_RATE_RETRY * n_rates;1027 sta->rate_count = 2 * MT7615_RATE_RETRY * n_rates;
963 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;1028 sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
1029 sta->rate_probe = !!probe_rate;
964}1030}
965EXPORT_SYMBOL_GPL(mt7615_mac_set_rates);1031EXPORT_SYMBOL_GPL(mt7615_mac_set_rates);
966 1032
@@ -1169,7 +1235,6 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, · 202 unmodified lines
1169 phy = dev->mt76.phy2->priv;1235 phy = dev->mt76.phy2->priv;
1170 1236
1171 mt7615_mac_set_rates(phy, sta, NULL, sta->rates);1237 mt7615_mac_set_rates(phy, sta, NULL, sta->rates);
1172 sta->rate_probe = false;
1173 }1238 }
1174 spin_unlock_bh(&dev->mt76.lock);1239 spin_unlock_bh(&dev->mt76.lock);
1175 } else {1240 } else {
@@ -1373,6 +1438,12 @@ static void mt7615_mac_tx_free(struct mt7615_dev *dev, struct sk_buff *skb) · 197 unmodified lines
1373 }1438 }
1374 1439
1375 dev_kfree_skb(skb);1440 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);
1376}1447}
1377 1448
1378void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,1449void 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
1462 bool ext_phy = phy != &dev->phy;1533 bool ext_phy = phy != &dev->phy;
1463 u32 reg, mask;1534 u32 reg, mask;
1464 1535
1465 mutex_lock(&dev->mt76.mutex);1536 mt7615_mutex_acquire(dev);
1466 1537
1467 if (phy->scs_en == enable)1538 if (phy->scs_en == enable)
1468 goto out;1539 goto out;
@@ -1489,7 +1560,7 @@ void mt7615_mac_set_scs(struct mt7615_phy *phy, bool enable) · 20 unmodified lines
1489 phy->scs_en = enable;1560 phy->scs_en = enable;
1490 1561
1491out:1562out:
1492 mutex_unlock(&dev->mt76.mutex);1563 mt7615_mutex_release(dev);
1493}1564}
1494 1565
1495void mt7615_mac_enable_nf(struct mt7615_dev *dev, bool ext_phy)1566void 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
1679 state->noise = -(phy->noise >> 4);1750 state->noise = -(phy->noise >> 4);
1680}1751}
1681 1752
1682void mt7615_update_channel(struct mt76_dev *mdev)1753static void __mt7615_update_channel(struct mt7615_dev *dev)
1683{1754{
1684 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);1755 struct mt76_dev *mdev = &dev->mt76;
1685 1756
1686 mt7615_phy_update_channel(&mdev->phy, 0);1757 mt7615_phy_update_channel(&mdev->phy, 0);
1687 if (mdev->phy2)1758 if (mdev->phy2)
@@ -1690,8 +1761,32 @@ void mt7615_update_channel(struct mt76_dev *mdev) · 2 unmodified lines
1690 /* reset obss airtime */1761 /* reset obss airtime */
1691 mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);1762 mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
1692}1763}
1764
1765void 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}
1693EXPORT_SYMBOL_GPL(mt7615_update_channel);1775EXPORT_SYMBOL_GPL(mt7615_update_channel);
1694 1776
1777static 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
1695static void1790static void
1696mt7615_mac_update_mib_stats(struct mt7615_phy *phy)1791mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
1697{1792{
@@ -1740,6 +1835,163 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy) · 42 unmodified lines
1740 }1835 }
1741}1836}
1742 1837
1838void 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
1873out:
1874 ieee80211_wake_queues(mphy->hw);
1875 complete_all(&dev->pm.wake_cmpl);
1876}
1877
1878int 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}
1905EXPORT_SYMBOL_GPL(mt7615_pm_wake);
1906
1907void 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}
1930EXPORT_SYMBOL_GPL(mt7615_pm_power_save_sched);
1931
1932void 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;
1948out:
1949 queue_delayed_work(dev->mt76.wq, &dev->pm.ps_work, delta);
1950}
1951
1952static void
1953mt7615_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
1973int 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);
1989out:
1990 mt7615_mutex_release(dev);
1991
1992 return 0;
1993}
1994
1743void mt7615_mac_work(struct work_struct *work)1995void mt7615_mac_work(struct work_struct *work)
1744{1996{
1745 struct mt7615_phy *phy;1997 struct mt7615_phy *phy;
@@ -1749,9 +2001,9 @@ void mt7615_mac_work(struct work_struct *work) · 3 unmodified lines
1749 mac_work.work);2001 mac_work.work);
1750 mdev = &phy->dev->mt76;2002 mdev = &phy->dev->mt76;
1751 2003
1752 mutex_lock(&mdev->mutex);2004 mt7615_mutex_acquire(phy->dev);
1753 2005
1754 mt76_update_survey(mdev);2006 mt7615_update_survey(phy->dev);
1755 if (++phy->mac_work_count == 5) {2007 if (++phy->mac_work_count == 5) {
1756 phy->mac_work_count = 0;2008 phy->mac_work_count = 0;
1757 2009
@@ -1759,7 +2011,7 @@ void mt7615_mac_work(struct work_struct *work) · 1 unmodified line
1759 mt7615_mac_scs_check(phy);2011 mt7615_mac_scs_check(phy);
1760 }2012 }
1761 2013
1762 mutex_unlock(&mdev->mutex);2014 mt7615_mutex_release(phy->dev);
1763 2015
1764 mt76_tx_status_check(mdev, NULL, false);2016 mt76_tx_status_check(mdev, NULL, false);
1765 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mac_work,2017 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
1863 napi_disable(&dev->mt76.napi[1]);2115 napi_disable(&dev->mt76.napi[1]);
1864 napi_disable(&dev->mt76.tx_napi);2116 napi_disable(&dev->mt76.tx_napi);
1865 2117
1866 mutex_lock(&dev->mt76.mutex);2118 mt7615_mutex_acquire(dev);
1867 2119
1868 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_PDMA_STOPPED);2120 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_PDMA_STOPPED);
1869 2121
@@ -1896,10 +2148,10 @@ void mt7615_mac_reset_work(struct work_struct *work) · 26 unmodified lines
1896 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_RESET_DONE);2148 mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_RESET_DONE);
1897 mt7615_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE);2149 mt7615_wait_reset_state(dev, MT_MCU_CMD_NORMAL_STATE);
1898 2150
1899 mutex_unlock(&dev->mt76.mutex);
1900
1901 mt7615_update_beacons(dev);2151 mt7615_update_beacons(dev);
1902 2152
2153 mt7615_mutex_release(dev);
2154
1903 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->phy.mac_work,2155 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->phy.mac_work,
1904 MT7615_WATCHDOG_TIME);2156 MT7615_WATCHDOG_TIME);
1905 if (phy2)2157 if (phy2)
drivers/net/wireless/mediatek/mt76/mt7615/mac.h+5−0
@@ -100,11 +100,16 @@ enum rx_pkt_type { · 99 unmodified lines
100#define MT_RXV2_GROUP_ID GENMASK(26, 21)100#define MT_RXV2_GROUP_ID GENMASK(26, 21)
101#define MT_RXV2_LENGTH GENMASK(20, 0)101#define MT_RXV2_LENGTH GENMASK(20, 0)
102 102
103#define MT_RXV3_WB_RSSI GENMASK(31, 24)
104#define MT_RXV3_IB_RSSI GENMASK(23, 16)
105
103#define MT_RXV4_RCPI3 GENMASK(31, 24)106#define MT_RXV4_RCPI3 GENMASK(31, 24)
104#define MT_RXV4_RCPI2 GENMASK(23, 16)107#define MT_RXV4_RCPI2 GENMASK(23, 16)
105#define MT_RXV4_RCPI1 GENMASK(15, 8)108#define MT_RXV4_RCPI1 GENMASK(15, 8)
106#define MT_RXV4_RCPI0 GENMASK(7, 0)109#define MT_RXV4_RCPI0 GENMASK(7, 0)
107 110
111#define MT_RXV5_FOE GENMASK(11, 0)
112
108#define MT_RXV6_NF3 GENMASK(31, 24)113#define MT_RXV6_NF3 GENMASK(31, 24)
109#define MT_RXV6_NF2 GENMASK(23, 16)114#define MT_RXV6_NF2 GENMASK(23, 16)
110#define MT_RXV6_NF1 GENMASK(15, 8)115#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
24 return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state);24 return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state);
25}25}
26 26
27static 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
27static int mt7615_start(struct ieee80211_hw *hw)43static int mt7615_start(struct ieee80211_hw *hw)
28{44{
29 struct mt7615_dev *dev = mt7615_hw_dev(hw);45 struct mt7615_dev *dev = mt7615_hw_dev(hw);
@@ -33,7 +49,7 @@ static int mt7615_start(struct ieee80211_hw *hw) · 3 unmodified lines
33 if (!mt7615_wait_for_mcu_init(dev))49 if (!mt7615_wait_for_mcu_init(dev))
34 return -EIO;50 return -EIO;
35 51
36 mutex_lock(&dev->mt76.mutex);52 mt7615_mutex_acquire(dev);
37 53
38 running = mt7615_dev_running(dev);54 running = mt7615_dev_running(dev);
39 55
@@ -60,7 +76,7 @@ static int mt7615_start(struct ieee80211_hw *hw) · 20 unmodified lines
60 if (!running)76 if (!running)
61 mt7615_mac_reset_counters(dev);77 mt7615_mac_reset_counters(dev);
62 78
63 mutex_unlock(&dev->mt76.mutex);79 mt7615_mutex_release(dev);
64 80
65 return 0;81 return 0;
66}82}
@@ -74,7 +90,14 @@ static void mt7615_stop(struct ieee80211_hw *hw) · 7 unmodified lines
74 del_timer_sync(&phy->roc_timer);90 del_timer_sync(&phy->roc_timer);
75 cancel_work_sync(&phy->roc_work);91 cancel_work_sync(&phy->roc_work);
76 92
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);
78 101
79 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);102 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
80 cancel_delayed_work_sync(&phy->scan_work);103 cancel_delayed_work_sync(&phy->scan_work);
@@ -89,7 +112,7 @@ static void mt7615_stop(struct ieee80211_hw *hw) · 8 unmodified lines
89 mt7615_mcu_set_mac_enable(dev, 0, false);112 mt7615_mcu_set_mac_enable(dev, 0, false);
90 }113 }
91 114
92 mutex_unlock(&dev->mt76.mutex);115 mt7615_mutex_release(dev);
93}116}
94 117
95static int get_omac_idx(enum nl80211_iftype type, u32 mask)118static 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
135 bool ext_phy = phy != &dev->phy;158 bool ext_phy = phy != &dev->phy;
136 int idx, ret = 0;159 int idx, ret = 0;
137 160
138 mutex_lock(&dev->mt76.mutex);161 mt7615_mutex_acquire(dev);
162
163 mt76_testmode_reset(&dev->mt76, true);
139 164
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;
141 if (mvif->idx >= MT7615_MAX_INTERFACES) {170 if (mvif->idx >= MT7615_MAX_INTERFACES) {
142 ret = -ENOSPC;171 ret = -ENOSPC;
143 goto out;172 goto out;
@@ -157,7 +186,7 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, · 13 unmodified lines
157 else186 else
158 mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;187 mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
159 188
160 dev->vif_mask |= BIT(mvif->idx);189 dev->mphy.vif_mask |= BIT(mvif->idx);
161 dev->omac_mask |= BIT(mvif->omac_idx);190 dev->omac_mask |= BIT(mvif->omac_idx);
162 phy->omac_mask |= BIT(mvif->omac_idx);191 phy->omac_mask |= BIT(mvif->omac_idx);
163 192
@@ -180,8 +209,20 @@ static int mt7615_add_interface(struct ieee80211_hw *hw, · 16 unmodified lines
180 }209 }
181 210
182 ret = mt7615_mcu_add_dev_info(dev, vif, true);211 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 }
183out:224out:
184 mutex_unlock(&dev->mt76.mutex);225 mt7615_mutex_release(dev);
185 226
186 return ret;227 return ret;
187}228}
@@ -197,17 +238,32 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw, · 9 unmodified lines
197 238
198 /* TODO: disable beacon for the bss */239 /* TODO: disable beacon for the bss */
199 240
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 }
200 mt7615_mcu_add_dev_info(dev, vif, false);256 mt7615_mcu_add_dev_info(dev, vif, false);
201 257
202 rcu_assign_pointer(dev->mt76.wcid[idx], NULL);258 rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
203 if (vif->txq)259 if (vif->txq)
204 mt76_txq_remove(&dev->mt76, vif->txq);260 mt76_txq_remove(&dev->mt76, vif->txq);
205 261
206 mutex_lock(&dev->mt76.mutex);262 dev->mphy.vif_mask &= ~BIT(mvif->idx);
207 dev->vif_mask &= ~BIT(mvif->idx);
208 dev->omac_mask &= ~BIT(mvif->omac_idx);263 dev->omac_mask &= ~BIT(mvif->omac_idx);
209 phy->omac_mask &= ~BIT(mvif->omac_idx);264 phy->omac_mask &= ~BIT(mvif->omac_idx);
210 mutex_unlock(&dev->mt76.mutex);265
266 mt7615_mutex_release(dev);
211 267
212 spin_lock_bh(&dev->sta_poll_lock);268 spin_lock_bh(&dev->sta_poll_lock);
213 if (!list_empty(&msta->poll_list))269 if (!list_empty(&msta->poll_list))
@@ -234,7 +290,7 @@ static void mt7615_init_dfs_state(struct mt7615_phy *phy) · 20 unmodified lines
234 phy->dfs_state = -1;290 phy->dfs_state = -1;
235}291}
236 292
237static int mt7615_set_channel(struct mt7615_phy *phy)293int mt7615_set_channel(struct mt7615_phy *phy)
238{294{
239 struct mt7615_dev *dev = phy->dev;295 struct mt7615_dev *dev = phy->dev;
240 bool ext_phy = phy != &dev->phy;296 bool ext_phy = phy != &dev->phy;
@@ -242,7 +298,8 @@ static int mt7615_set_channel(struct mt7615_phy *phy) · 1 unmodified line
242 298
243 cancel_delayed_work_sync(&phy->mac_work);299 cancel_delayed_work_sync(&phy->mac_work);
244 300
245 mutex_lock(&dev->mt76.mutex);301 mt7615_mutex_acquire(dev);
302
246 set_bit(MT76_RESET, &phy->mt76->state);303 set_bit(MT76_RESET, &phy->mt76->state);
247 304
248 mt7615_init_dfs_state(phy);305 mt7615_init_dfs_state(phy);
@@ -260,7 +317,7 @@ static int mt7615_set_channel(struct mt7615_phy *phy) · 11 unmodified lines
260 mt7615_mac_set_timing(phy);317 mt7615_mac_set_timing(phy);
261 ret = mt7615_dfs_init_radar_detector(phy);318 ret = mt7615_dfs_init_radar_detector(phy);
262 mt7615_mac_cca_stats_reset(phy);319 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));
264 321
265 mt7615_mac_reset_counters(dev);322 mt7615_mac_reset_counters(dev);
266 phy->noise = 0;323 phy->noise = 0;
@@ -268,11 +325,15 @@ static int mt7615_set_channel(struct mt7615_phy *phy) · 1 unmodified line
268 325
269out:326out:
270 clear_bit(MT76_RESET, &phy->mt76->state);327 clear_bit(MT76_RESET, &phy->mt76->state);
271 mutex_unlock(&dev->mt76.mutex);328
329 mt7615_mutex_release(dev);
272 330
273 mt76_txq_schedule_all(phy->mt76);331 mt76_txq_schedule_all(phy->mt76);
274 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mac_work,332
275 MT7615_WATCHDOG_TIME);333 if (!mt76_testmode_enabled(&dev->mt76))
334 ieee80211_queue_delayed_work(phy->mt76->hw, &phy->mac_work,
335 MT7615_WATCHDOG_TIME);
336
276 return ret;337 return ret;
277}338}
278 339
@@ -301,7 +362,7 @@ mt7615_queue_key_update(struct mt7615_dev *dev, enum set_key_cmd cmd, · 22 unmodified lines
301 wd->key.cmd = cmd;362 wd->key.cmd = cmd;
302 363
303 list_add_tail(&wd->node, &dev->wd_head);364 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);
305 366
306 return 0;367 return 0;
307}368}
@@ -315,7 +376,7 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, · 7 unmodified lines
315 struct mt7615_sta *msta = sta ? (struct mt7615_sta *)sta->drv_priv :376 struct mt7615_sta *msta = sta ? (struct mt7615_sta *)sta->drv_priv :
316 &mvif->sta;377 &mvif->sta;
317 struct mt76_wcid *wcid = &msta->wcid;378 struct mt76_wcid *wcid = &msta->wcid;
318 int idx = key->keyidx;379 int idx = key->keyidx, err;
319 380
320 /* The hardware does not support per-STA RX GTK, fallback381 /* The hardware does not support per-STA RX GTK, fallback
321 * to software mode for these.382 * 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
345 return -EOPNOTSUPP;406 return -EOPNOTSUPP;
346 }407 }
347 408
409 mt7615_mutex_acquire(dev);
410
348 if (cmd == SET_KEY) {411 if (cmd == SET_KEY) {
349 key->hw_key_idx = wcid->idx;412 key->hw_key_idx = wcid->idx;
350 wcid->hw_key_idx = idx;413 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
354 mt76_wcid_key_setup(&dev->mt76, wcid,417 mt76_wcid_key_setup(&dev->mt76, wcid,
355 cmd == SET_KEY ? key : NULL);418 cmd == SET_KEY ? key : NULL);
356 419
357 if (mt76_is_usb(&dev->mt76))420 if (mt76_is_mmio(&dev->mt76))
358 return mt7615_queue_key_update(dev, cmd, msta, key);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);
359 426
360 return mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);427 return err;
361}428}
362 429
363static int mt7615_config(struct ieee80211_hw *hw, u32 changed)430static 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
369 436
370 if (changed & (IEEE80211_CONF_CHANGE_CHANNEL |437 if (changed & (IEEE80211_CONF_CHANGE_CHANNEL |
371 IEEE80211_CONF_CHANGE_POWER)) {438 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
372 ieee80211_stop_queues(hw);446 ieee80211_stop_queues(hw);
373 ret = mt7615_set_channel(phy);447 ret = mt7615_set_channel(phy);
374 ieee80211_wake_queues(hw);448 ieee80211_wake_queues(hw);
375 }449 }
376 450
377 mutex_lock(&dev->mt76.mutex);451 mt7615_mutex_acquire(dev);
378 452
379 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {453 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
454 mt76_testmode_reset(&dev->mt76, true);
455
380 if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))456 if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
381 phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;457 phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
382 else458 else
@@ -385,7 +461,7 @@ static int mt7615_config(struct ieee80211_hw *hw, u32 changed) · 2 unmodified lines
385 mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);461 mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
386 }462 }
387 463
388 mutex_unlock(&dev->mt76.mutex);464 mt7615_mutex_release(dev);
389 465
390 return ret;466 return ret;
391}467}
@@ -396,11 +472,17 @@ mt7615_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, · 4 unmodified lines
396{472{
397 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;473 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
398 struct mt7615_dev *dev = mt7615_hw_dev(hw);474 struct mt7615_dev *dev = mt7615_hw_dev(hw);
475 int err;
476
477 mt7615_mutex_acquire(dev);
399 478
400 queue = mt7615_lmac_mapping(dev, queue);479 queue = mt7615_lmac_mapping(dev, queue);
401 queue += mvif->wmm_idx * MT7615_MAX_WMM_SETS;480 queue += mvif->wmm_idx * MT7615_MAX_WMM_SETS;
481 err = mt7615_mcu_set_wmm(dev, queue, params);
402 482
403 return mt7615_mcu_set_wmm(dev, queue, params);483 mt7615_mutex_release(dev);
484
485 return err;
404}486}
405 487
406static void mt7615_configure_filter(struct ieee80211_hw *hw,488static void mt7615_configure_filter(struct ieee80211_hw *hw,
@@ -419,10 +501,13 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw, · 12 unmodified lines
419 MT_WF_RFCR1_DROP_CFACK;501 MT_WF_RFCR1_DROP_CFACK;
420 u32 flags = 0;502 u32 flags = 0;
421 503
504 mt7615_mutex_acquire(dev);
505
422#define MT76_FILTER(_flag, _hw) do { \506#define MT76_FILTER(_flag, _hw) do { \
423 flags |= *total_flags & FIF_##_flag; \507 flags |= *total_flags & FIF_##_flag; \
424 phy->rxfilter &= ~(_hw); \508 phy->rxfilter &= ~(_hw); \
425 phy->rxfilter |= !(flags & FIF_##_flag) * (_hw); \509 if (!mt76_testmode_enabled(&dev->mt76)) \
510 phy->rxfilter |= !(flags & FIF_##_flag) * (_hw);\
426 } while (0)511 } while (0)
427 512
428 phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS |513 phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS |
@@ -455,6 +540,8 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw, · 26 unmodified lines
455 mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags);540 mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags);
456 else541 else
457 mt76_set(dev, MT_WF_RFCR1(band), ctl_flags);542 mt76_set(dev, MT_WF_RFCR1(band), ctl_flags);
543
544 mt7615_mutex_release(dev);
458}545}
459 546
460static void mt7615_bss_info_changed(struct ieee80211_hw *hw,547static 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
465 struct mt7615_dev *dev = mt7615_hw_dev(hw);552 struct mt7615_dev *dev = mt7615_hw_dev(hw);
466 struct mt7615_phy *phy = mt7615_hw_phy(hw);553 struct mt7615_phy *phy = mt7615_hw_phy(hw);
467 554
468 mutex_lock(&dev->mt76.mutex);555 mt7615_mutex_acquire(dev);
469 556
470 if (changed & BSS_CHANGED_ERP_SLOT) {557 if (changed & BSS_CHANGED_ERP_SLOT) {
471 int slottime = info->use_short_slot ? 9 : 20;558 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
491 if (changed & BSS_CHANGED_PS)578 if (changed & BSS_CHANGED_PS)
492 mt7615_mcu_set_vif_ps(dev, vif);579 mt7615_mcu_set_vif_ps(dev, vif);
493 580
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);
495}585}
496 586
497static void587static void
@@ -501,9 +591,9 @@ mt7615_channel_switch_beacon(struct ieee80211_hw *hw, · 3 unmodified lines
501{591{
502 struct mt7615_dev *dev = mt7615_hw_dev(hw);592 struct mt7615_dev *dev = mt7615_hw_dev(hw);
503 593
504 mutex_lock(&dev->mt76.mutex);594 mt7615_mutex_acquire(dev);
505 mt7615_mcu_add_beacon(dev, hw, vif, true);595 mt7615_mcu_add_beacon(dev, hw, vif, true);
506 mutex_unlock(&dev->mt76.mutex);596 mt7615_mutex_release(dev);
507}597}
508 598
509int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,599int 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
512 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);602 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
513 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;603 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
514 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;604 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
515 int idx;605 int idx, err;
516 606
517 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7615_WTBL_STA - 1);607 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7615_WTBL_STA - 1);
518 if (idx < 0)608 if (idx < 0)
@@ -524,6 +614,10 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 5 unmodified lines
524 msta->wcid.idx = idx;614 msta->wcid.idx = idx;
525 msta->wcid.ext_phy = mvif->band_idx;615 msta->wcid.ext_phy = mvif->band_idx;
526 616
617 err = mt7615_pm_wake(dev);
618 if (err)
619 return err;
620
527 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {621 if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls) {
528 struct mt7615_phy *phy;622 struct mt7615_phy *phy;
529 623
@@ -534,6 +628,8 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, · 4 unmodified lines
534 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);628 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
535 mt7615_mcu_sta_add(dev, vif, sta, true);629 mt7615_mcu_sta_add(dev, vif, sta, true);
536 630
631 mt7615_pm_power_save_sched(dev);
632
537 return 0;633 return 0;
538}634}
539EXPORT_SYMBOL_GPL(mt7615_mac_sta_add);635EXPORT_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
544 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);640 struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
545 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;641 struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
546 642
643 mt7615_free_pending_tx_skbs(dev, msta);
644 mt7615_pm_wake(dev);
645
547 mt7615_mcu_sta_add(dev, vif, sta, false);646 mt7615_mcu_sta_add(dev, vif, sta, false);
548 mt7615_mac_wtbl_update(dev, msta->wcid.idx,647 mt7615_mac_wtbl_update(dev, msta->wcid.idx,
549 MT_WTBL_UPDATE_ADM_COUNT_CLEAR);648 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
559 if (!list_empty(&msta->poll_list))658 if (!list_empty(&msta->poll_list))
560 list_del_init(&msta->poll_list);659 list_del_init(&msta->poll_list);
561 spin_unlock_bh(&dev->sta_poll_lock);660 spin_unlock_bh(&dev->sta_poll_lock);
661
662 mt7615_pm_power_save_sched(dev);
562}663}
563EXPORT_SYMBOL_GPL(mt7615_mac_sta_remove);664EXPORT_SYMBOL_GPL(mt7615_mac_sta_remove);
564 665
@@ -582,11 +683,29 @@ static void mt7615_sta_rate_tbl_update(struct ieee80211_hw *hw, · 17 unmodified lines
582 break;683 break;
583 }684 }
584 msta->n_rates = i;685 msta->n_rates = i;
585 mt7615_mac_set_rates(phy, msta, NULL, msta->rates);686 if (!test_bit(MT76_STATE_PM, &phy->mt76->state))
586 msta->rate_probe = false;687 mt7615_mac_set_rates(phy, msta, NULL, msta->rates);
587 spin_unlock_bh(&dev->mt76.lock);688 spin_unlock_bh(&dev->mt76.lock);
588}689}
589 690
691static void
692mt7615_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
590static void mt7615_tx(struct ieee80211_hw *hw,709static void mt7615_tx(struct ieee80211_hw *hw,
591 struct ieee80211_tx_control *control,710 struct ieee80211_tx_control *control,
592 struct sk_buff *skb)711 struct sk_buff *skb)
@@ -596,22 +715,43 @@ static void mt7615_tx(struct ieee80211_hw *hw, · 3 unmodified lines
596 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);715 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
597 struct ieee80211_vif *vif = info->control.vif;716 struct ieee80211_vif *vif = info->control.vif;
598 struct mt76_wcid *wcid = &dev->mt76.global_wcid;717 struct mt76_wcid *wcid = &dev->mt76.global_wcid;
718 struct mt7615_sta *msta = NULL;
719 int qid;
599 720
600 if (control->sta) {721 if (control->sta) {
601 struct mt7615_sta *sta;722 msta = (struct mt7615_sta *)control->sta->drv_priv;
602 723 wcid = &msta->wcid;
603 sta = (struct mt7615_sta *)control->sta->drv_priv;
604 wcid = &sta->wcid;
605 }724 }
606 725
607 if (vif && !control->sta) {726 if (vif && !control->sta) {
608 struct mt7615_vif *mvif;727 struct mt7615_vif *mvif;
609 728
610 mvif = (struct mt7615_vif *)vif->drv_priv;729 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);
612 }743 }
613 744
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);
615}755}
616 756
617static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val)757static 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
619 struct mt7615_dev *dev = mt7615_hw_dev(hw);759 struct mt7615_dev *dev = mt7615_hw_dev(hw);
620 struct mt7615_phy *phy = mt7615_hw_phy(hw);760 struct mt7615_phy *phy = mt7615_hw_phy(hw);
621 761
622 mutex_lock(&dev->mt76.mutex);762 mt7615_mutex_acquire(dev);
623 mt7615_mcu_set_rts_thresh(phy, val);763 mt7615_mcu_set_rts_thresh(phy, val);
624 mutex_unlock(&dev->mt76.mutex);764 mt7615_mutex_release(dev);
625 765
626 return 0;766 return 0;
627}767}
@@ -645,7 +785,8 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 17 unmodified lines
645 785
646 mtxq = (struct mt76_txq *)txq->drv_priv;786 mtxq = (struct mt76_txq *)txq->drv_priv;
647 787
648 mutex_lock(&dev->mt76.mutex);788 mt7615_mutex_acquire(dev);
789
649 switch (action) {790 switch (action) {
650 case IEEE80211_AMPDU_RX_START:791 case IEEE80211_AMPDU_RX_START:
651 mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,792 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
660 mtxq->aggr = true;801 mtxq->aggr = true;
661 mtxq->send_bar = false;802 mtxq->send_bar = false;
662 mt7615_mcu_add_tx_ba(dev, params, true);803 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));
663 break;807 break;
664 case IEEE80211_AMPDU_TX_STOP_FLUSH:808 case IEEE80211_AMPDU_TX_STOP_FLUSH:
665 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:809 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
667 mt7615_mcu_add_tx_ba(dev, params, false);811 mt7615_mcu_add_tx_ba(dev, params, false);
668 break;812 break;
669 case IEEE80211_AMPDU_TX_START:813 case IEEE80211_AMPDU_TX_START:
814 ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
815 params->ssn = ssn;
670 mtxq->agg_ssn = IEEE80211_SN_TO_SEQ(ssn);816 mtxq->agg_ssn = IEEE80211_SN_TO_SEQ(ssn);
671 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;817 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
672 break;818 break;
@@ -676,7 +822,7 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 3 unmodified lines
676 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);822 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
677 break;823 break;
678 }824 }
679 mutex_unlock(&dev->mt76.mutex);825 mt7615_mutex_release(dev);
680 826
681 return ret;827 return ret;
682}828}
@@ -721,27 +867,47 @@ mt7615_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 38 unmodified lines
721 u32 t32[2];867 u32 t32[2];
722 } tsf;868 } tsf;
723 869
724 mutex_lock(&dev->mt76.mutex);870 mt7615_mutex_acquire(dev);
725 871
726 mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */872 mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */
727 tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0);873 tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0);
728 tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1);874 tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1);
729 875
730 mutex_unlock(&dev->mt76.mutex);876 mt7615_mutex_release(dev);
731 877
732 return tsf.t64;878 return tsf.t64;
733}879}
734 880
881static void
882mt7615_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
735static void901static void
736mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)902mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
737{903{
738 struct mt7615_phy *phy = mt7615_hw_phy(hw);904 struct mt7615_phy *phy = mt7615_hw_phy(hw);
739 struct mt7615_dev *dev = phy->dev;905 struct mt7615_dev *dev = phy->dev;
740 906
741 mutex_lock(&dev->mt76.mutex);907 mt7615_mutex_acquire(dev);
742 phy->coverage_class = max_t(s16, coverage_class, 0);908 phy->coverage_class = max_t(s16, coverage_class, 0);
743 mt7615_mac_set_timing(phy);909 mt7615_mac_set_timing(phy);
744 mutex_unlock(&dev->mt76.mutex);910 mt7615_mutex_release(dev);
745}911}
746 912
747static int913static int
@@ -758,7 +924,7 @@ mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) · 10 unmodified lines
758 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)924 if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
759 tx_ant = BIT(ffs(tx_ant) - 1) - 1;925 tx_ant = BIT(ffs(tx_ant) - 1) - 1;
760 926
761 mutex_lock(&dev->mt76.mutex);927 mt7615_mutex_acquire(dev);
762 928
763 phy->mt76->antenna_mask = tx_ant;929 phy->mt76->antenna_mask = tx_ant;
764 if (ext_phy) {930 if (ext_phy) {
@@ -771,7 +937,7 @@ mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) · 6 unmodified lines
771 937
772 mt76_set_stream_caps(phy->mt76, true);938 mt76_set_stream_caps(phy->mt76, true);
773 939
774 mutex_unlock(&dev->mt76.mutex);940 mt7615_mutex_release(dev);
775 941
776 return 0;942 return 0;
777}943}
@@ -794,9 +960,11 @@ void mt7615_roc_work(struct work_struct *work) · 16 unmodified lines
794 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))960 if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
795 return;961 return;
796 962
963 mt7615_mutex_acquire(phy->dev);
797 ieee80211_iterate_active_interfaces(phy->mt76->hw,964 ieee80211_iterate_active_interfaces(phy->mt76->hw,
798 IEEE80211_IFACE_ITER_RESUME_ALL,965 IEEE80211_IFACE_ITER_RESUME_ALL,
799 mt7615_roc_iter, phy);966 mt7615_roc_iter, phy);
967 mt7615_mutex_release(phy->dev);
800 ieee80211_remain_on_channel_expired(phy->mt76->hw);968 ieee80211_remain_on_channel_expired(phy->mt76->hw);
801}969}
802 970
@@ -844,17 +1012,26 @@ static int · 41 unmodified lines
844mt7615_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,1012mt7615_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
845 struct ieee80211_scan_request *req)1013 struct ieee80211_scan_request *req)
846{1014{
1015 struct mt7615_dev *dev = mt7615_hw_dev(hw);
847 struct mt76_phy *mphy = hw->priv;1016 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);
848 1022
849 return mt7615_mcu_hw_scan(mphy->priv, vif, req);1023 return err;
850}1024}
851 1025
852static void1026static void
853mt7615_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)1027mt7615_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
854{1028{
1029 struct mt7615_dev *dev = mt7615_hw_dev(hw);
855 struct mt76_phy *mphy = hw->priv;1030 struct mt76_phy *mphy = hw->priv;
856 1031
1032 mt7615_mutex_acquire(dev);
857 mt7615_mcu_cancel_hw_scan(mphy->priv, vif);1033 mt7615_mcu_cancel_hw_scan(mphy->priv, vif);
1034 mt7615_mutex_release(dev);
858}1035}
859 1036
860static int1037static int
@@ -862,22 +1039,35 @@ mt7615_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, · 1 unmodified line
862 struct cfg80211_sched_scan_request *req,1039 struct cfg80211_sched_scan_request *req,
863 struct ieee80211_scan_ies *ies)1040 struct ieee80211_scan_ies *ies)
864{1041{
1042 struct mt7615_dev *dev = mt7615_hw_dev(hw);
865 struct mt76_phy *mphy = hw->priv;1043 struct mt76_phy *mphy = hw->priv;
866 int err;1044 int err;
867 1045
1046 mt7615_mutex_acquire(dev);
1047
868 err = mt7615_mcu_sched_scan_req(mphy->priv, vif, req);1048 err = mt7615_mcu_sched_scan_req(mphy->priv, vif, req);
869 if (err < 0)1049 if (err < 0)
870 return err;1050 goto out;
1051
1052 err = mt7615_mcu_sched_scan_enable(mphy->priv, vif, true);
1053out:
1054 mt7615_mutex_release(dev);
871 1055
872 return mt7615_mcu_sched_scan_enable(mphy->priv, vif, true);1056 return err;
873}1057}
874 1058
875static int1059static int
876mt7615_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)1060mt7615_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
877{1061{
1062 struct mt7615_dev *dev = mt7615_hw_dev(hw);
878 struct mt76_phy *mphy = hw->priv;1063 struct mt76_phy *mphy = hw->priv;
1064 int err;
879 1065
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;
881}1071}
882 1072
883static int mt7615_remain_on_channel(struct ieee80211_hw *hw,1073static 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
892 if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))1082 if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))
893 return 0;1083 return 0;
894 1084
1085 mt7615_mutex_acquire(phy->dev);
1086
895 err = mt7615_mcu_set_roc(phy, vif, chan, duration);1087 err = mt7615_mcu_set_roc(phy, vif, chan, duration);
896 if (err < 0) {1088 if (err < 0) {
897 clear_bit(MT76_STATE_ROC, &phy->mt76->state);1089 clear_bit(MT76_STATE_ROC, &phy->mt76->state);
898 return err;1090 goto out;
899 }1091 }
900 1092
901 if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, HZ)) {1093 if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, HZ)) {
902 mt7615_mcu_set_roc(phy, vif, NULL, 0);1094 mt7615_mcu_set_roc(phy, vif, NULL, 0);
903 clear_bit(MT76_STATE_ROC, &phy->mt76->state);1095 clear_bit(MT76_STATE_ROC, &phy->mt76->state);
904 1096 err = -ETIMEDOUT;
905 return -ETIMEDOUT;
906 }1097 }
907 1098
908 return 0;1099out:
1100 mt7615_mutex_release(phy->dev);
1101
1102 return err;
909}1103}
910 1104
911static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw,1105static 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
919 del_timer_sync(&phy->roc_timer);1113 del_timer_sync(&phy->roc_timer);
920 cancel_work_sync(&phy->roc_work);1114 cancel_work_sync(&phy->roc_work);
921 1115
1116 mt7615_mutex_acquire(phy->dev);
922 mt7615_mcu_set_roc(phy, vif, NULL, 0);1117 mt7615_mcu_set_roc(phy, vif, NULL, 0);
1118 mt7615_mutex_release(phy->dev);
923 1119
924 return 0;1120 return 0;
925}1121}
@@ -933,7 +1129,10 @@ static int mt7615_suspend(struct ieee80211_hw *hw, · 7 unmodified lines
933 bool ext_phy = phy != &dev->phy;1129 bool ext_phy = phy != &dev->phy;
934 int err = 0;1130 int err = 0;
935 1131
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);
937 1136
938 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);1137 clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
939 cancel_delayed_work_sync(&phy->scan_work);1138 cancel_delayed_work_sync(&phy->scan_work);
@@ -949,7 +1148,7 @@ static int mt7615_suspend(struct ieee80211_hw *hw, · 9 unmodified lines
949 if (!mt7615_dev_running(dev))1148 if (!mt7615_dev_running(dev))
950 err = mt7615_mcu_set_hif_suspend(dev, true);1149 err = mt7615_mcu_set_hif_suspend(dev, true);
951 1150
952 mutex_unlock(&dev->mt76.mutex);1151 mt7615_mutex_release(dev);
953 1152
954 return err;1153 return err;
955}1154}
@@ -960,7 +1159,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) · 4 unmodified lines
960 struct mt7615_phy *phy = mt7615_hw_phy(hw);1159 struct mt7615_phy *phy = mt7615_hw_phy(hw);
961 bool running, ext_phy = phy != &dev->phy;1160 bool running, ext_phy = phy != &dev->phy;
962 1161
963 mutex_lock(&dev->mt76.mutex);1162 mt7615_mutex_acquire(dev);
964 1163
965 running = mt7615_dev_running(dev);1164 running = mt7615_dev_running(dev);
966 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);1165 set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
@@ -970,7 +1169,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) · 3 unmodified lines
970 1169
971 err = mt7615_mcu_set_hif_suspend(dev, false);1170 err = mt7615_mcu_set_hif_suspend(dev, false);
972 if (err < 0) {1171 if (err < 0) {
973 mutex_unlock(&dev->mt76.mutex);1172 mt7615_mutex_release(dev);
974 return err;1173 return err;
975 }1174 }
976 }1175 }
@@ -984,7 +1183,7 @@ static int mt7615_resume(struct ieee80211_hw *hw) · 7 unmodified lines
984 MT7615_WATCHDOG_TIME);1183 MT7615_WATCHDOG_TIME);
985 mt76_clear(dev, MT_WF_RFCR(ext_phy), MT_WF_RFCR_DROP_OTHER_BEACON);1184 mt76_clear(dev, MT_WF_RFCR(ext_phy), MT_WF_RFCR_DROP_OTHER_BEACON);
986 1185
987 mutex_unlock(&dev->mt76.mutex);1186 mt7615_mutex_release(dev);
988 1187
989 return 0;1188 return 0;
990}1189}
@@ -1001,7 +1200,11 @@ static void mt7615_set_rekey_data(struct ieee80211_hw *hw, · 10 unmodified lines
1001 struct ieee80211_vif *vif,1200 struct ieee80211_vif *vif,
1002 struct cfg80211_gtk_rekey_data *data)1201 struct cfg80211_gtk_rekey_data *data)
1003{1202{
1203 struct mt7615_dev *dev = mt7615_hw_dev(hw);
1204
1205 mt7615_mutex_acquire(dev);
1004 mt7615_mcu_update_gtk_rekey(hw, vif, data);1206 mt7615_mcu_update_gtk_rekey(hw, vif, data);
1207 mt7615_mutex_release(dev);
1005}1208}
1006#endif /* CONFIG_PM */1209#endif /* CONFIG_PM */
1007 1210
@@ -1021,7 +1224,7 @@ const struct ieee80211_ops mt7615_ops = { · 13 unmodified lines
1021 .set_key = mt7615_set_key,1224 .set_key = mt7615_set_key,
1022 .ampdu_action = mt7615_ampdu_action,1225 .ampdu_action = mt7615_ampdu_action,
1023 .set_rts_threshold = mt7615_set_rts_threshold,1226 .set_rts_threshold = mt7615_set_rts_threshold,
1024 .wake_tx_queue = mt76_wake_tx_queue,1227 .wake_tx_queue = mt7615_wake_tx_queue,
1025 .sta_rate_tbl_update = mt7615_sta_rate_tbl_update,1228 .sta_rate_tbl_update = mt7615_sta_rate_tbl_update,
1026 .sw_scan_start = mt76_sw_scan,1229 .sw_scan_start = mt76_sw_scan,
1027 .sw_scan_complete = mt76_sw_scan_complete,1230 .sw_scan_complete = mt76_sw_scan_complete,
@@ -1030,6 +1233,7 @@ const struct ieee80211_ops mt7615_ops = { · 2 unmodified lines
1030 .channel_switch_beacon = mt7615_channel_switch_beacon,1233 .channel_switch_beacon = mt7615_channel_switch_beacon,
1031 .get_stats = mt7615_get_stats,1234 .get_stats = mt7615_get_stats,
1032 .get_tsf = mt7615_get_tsf,1235 .get_tsf = mt7615_get_tsf,
1236 .set_tsf = mt7615_set_tsf,
1033 .get_survey = mt76_get_survey,1237 .get_survey = mt76_get_survey,
1034 .get_antenna = mt76_get_antenna,1238 .get_antenna = mt76_get_antenna,
1035 .set_antenna = mt7615_set_antenna,1239 .set_antenna = mt7615_set_antenna,
@@ -1040,6 +1244,8 @@ const struct ieee80211_ops mt7615_ops = { · 4 unmodified lines
1040 .sched_scan_stop = mt7615_stop_sched_scan,1244 .sched_scan_stop = mt7615_stop_sched_scan,
1041 .remain_on_channel = mt7615_remain_on_channel,1245 .remain_on_channel = mt7615_remain_on_channel,
1042 .cancel_remain_on_channel = mt7615_cancel_remain_on_channel,1246 .cancel_remain_on_channel = mt7615_cancel_remain_on_channel,
1247 CFG80211_TESTMODE_CMD(mt76_testmode_cmd)
1248 CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
1043#ifdef CONFIG_PM1249#ifdef CONFIG_PM
1044 .suspend = mt7615_suspend,1250 .suspend = mt7615_suspend,
1045 .resume = mt7615_resume,1251 .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
146 mcu_txd->cid = mcu_cmd;146 mcu_txd->cid = mcu_cmd;
147 break;147 break;
148 case MCU_CE_PREFIX:148 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;
150 mcu_txd->cid = mcu_cmd;153 mcu_txd->cid = mcu_cmd;
151 break;154 break;
152 default:155 default:
153 mcu_txd->cid = MCU_CMD_EXT_CID;156 mcu_txd->cid = MCU_CMD_EXT_CID;
154 mcu_txd->set_query = MCU_Q_SET;157 if (cmd & MCU_QUERY_PREFIX)
155 mcu_txd->ext_cid = cmd;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;
156 mcu_txd->ext_cid_ack = 1;162 mcu_txd->ext_cid_ack = 1;
157 break;163 break;
158 }164 }
@@ -180,8 +186,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, · 21 unmodified lines
180 struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;186 struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;
181 int ret = 0;187 int ret = 0;
182 188
183 if (seq != rxd->seq)189 if (seq != rxd->seq) {
184 return -EAGAIN;190 ret = -EAGAIN;
191 goto out;
192 }
185 193
186 switch (cmd) {194 switch (cmd) {
187 case MCU_CMD_PATCH_SEM_CONTROL:195 case MCU_CMD_PATCH_SEM_CONTROL:
@@ -192,6 +200,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, · 4 unmodified lines
192 skb_pull(skb, sizeof(*rxd));200 skb_pull(skb, sizeof(*rxd));
193 ret = le32_to_cpu(*(__le32 *)skb->data);201 ret = le32_to_cpu(*(__le32 *)skb->data);
194 break;202 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;
195 case MCU_UNI_CMD_DEV_INFO_UPDATE:207 case MCU_UNI_CMD_DEV_INFO_UPDATE:
196 case MCU_UNI_CMD_BSS_INFO_UPDATE:208 case MCU_UNI_CMD_BSS_INFO_UPDATE:
197 case MCU_UNI_CMD_STA_REC_UPDATE:209 case MCU_UNI_CMD_STA_REC_UPDATE:
@@ -205,9 +217,18 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, · 7 unmodified lines
205 ret = le32_to_cpu(event->status);217 ret = le32_to_cpu(event->status);
206 break;218 break;
207 }219 }
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 }
208 default:228 default:
209 break;229 break;
210 }230 }
231out:
211 dev_kfree_skb(skb);232 dev_kfree_skb(skb);
212 233
213 return ret;234 return ret;
@@ -271,6 +292,38 @@ int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, · 57 unmodified lines
271}292}
272EXPORT_SYMBOL_GPL(mt7615_mcu_msg_send);293EXPORT_SYMBOL_GPL(mt7615_mcu_msg_send);
273 294
295u32 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
311int 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
274static void327static void
275mt7615_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)328mt7615_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
276{329{
@@ -926,6 +979,38 @@ mt7615_mcu_sta_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) · 649 unmodified lines
926 }979 }
927}980}
928 981
982static void
983mt7615_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
929static void1014static void
930mt7615_mcu_wtbl_ba_tlv(struct sk_buff *skb,1015mt7615_mcu_wtbl_ba_tlv(struct sk_buff *skb,
931 struct ieee80211_ampdu_params *params,1016 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
1188 return PTR_ERR(sskb);1273 return PTR_ERR(sskb);
1189 1274
1190 mt7615_mcu_sta_basic_tlv(sskb, vif, sta, enable);1275 mt7615_mcu_sta_basic_tlv(sskb, vif, sta, enable);
1191 if (enable && sta)1276 if (enable && sta) {
1192 mt7615_mcu_sta_ht_tlv(sskb, sta);1277 mt7615_mcu_sta_ht_tlv(sskb, sta);
1278 mt7615_mcu_sta_uapsd(sskb, vif, sta);
1279 }
1193 1280
1194 wtbl_hdr = mt7615_mcu_alloc_wtbl_req(dev, msta, WTBL_RESET_AND_SET,1281 wtbl_hdr = mt7615_mcu_alloc_wtbl_req(dev, msta, WTBL_RESET_AND_SET,
1195 NULL, &wskb);1282 NULL, &wskb);
@@ -1206,8 +1293,12 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 10 unmodified lines
1206 skb = enable ? wskb : sskb;1293 skb = enable ? wskb : sskb;
1207 1294
1208 err = __mt76_mcu_skb_send_msg(&dev->mt76, skb, cmd, true);1295 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
1210 return err;1300 return err;
1301 }
1211 1302
1212 cmd = enable ? MCU_EXT_CMD_STA_REC_UPDATE : MCU_EXT_CMD_WTBL_UPDATE;1303 cmd = enable ? MCU_EXT_CMD_STA_REC_UPDATE : MCU_EXT_CMD_WTBL_UPDATE;
1213 skb = enable ? sskb : wskb;1304 skb = enable ? sskb : wskb;
@@ -1285,8 +1376,10 @@ mt7615_mcu_add_sta_cmd(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 71 unmodified lines
1285 return PTR_ERR(skb);1376 return PTR_ERR(skb);
1286 1377
1287 mt7615_mcu_sta_basic_tlv(skb, vif, sta, enable);1378 mt7615_mcu_sta_basic_tlv(skb, vif, sta, enable);
1288 if (enable && sta)1379 if (enable && sta) {
1289 mt7615_mcu_sta_ht_tlv(skb, sta);1380 mt7615_mcu_sta_ht_tlv(skb, sta);
1381 mt7615_mcu_sta_uapsd(skb, vif, sta);
1382 }
1290 1383
1291 sta_wtbl = mt7615_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv));1384 sta_wtbl = mt7615_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv));
1292 1385
@@ -1429,6 +1522,7 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif, · 136 unmodified lines
1429 u8 pad[3];1522 u8 pad[3];
1430 } __packed hdr;1523 } __packed hdr;
1431 struct mt7615_bss_basic_tlv basic;1524 struct mt7615_bss_basic_tlv basic;
1525 struct mt7615_bss_qos_tlv qos;
1432 } basic_req = {1526 } basic_req = {
1433 .hdr = {1527 .hdr = {
1434 .bss_idx = mvif->idx,1528 .bss_idx = mvif->idx,
@@ -1444,6 +1538,11 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif, · 9 unmodified lines
1444 .active = true, /* keep bss deactivated */1538 .active = true, /* keep bss deactivated */
1445 .phymode = 0x38,1539 .phymode = 0x38,
1446 },1540 },
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 },
1447 };1546 };
1448 struct {1547 struct {
1449 struct {1548 struct {
@@ -1808,44 +1907,66 @@ static void mt7622_trigger_hif_int(struct mt7615_dev *dev, bool en) · 358 unmodified lines
1808 1907
1809int mt7615_driver_own(struct mt7615_dev *dev)1908int mt7615_driver_own(struct mt7615_dev *dev)
1810{1909{
1910 struct mt76_phy *mphy = &dev->mt76.phy;
1811 struct mt76_dev *mdev = &dev->mt76;1911 struct mt76_dev *mdev = &dev->mt76;
1812 u32 addr;1912 int i;
1813 1913
1814 addr = is_mt7663(mdev) ? MT_PCIE_DOORBELL_PUSH : MT_CFG_LPCR_HOST;1914 if (!test_and_clear_bit(MT76_STATE_PM, &mphy->state))
1815 mt76_wr(dev, addr, MT_CFG_LPCR_HOST_DRV_OWN);1915 goto out;
1816 1916
1817 mt7622_trigger_hif_int(dev, true);1917 mt7622_trigger_hif_int(dev, true);
1818 1918
1819 addr = is_mt7663(mdev) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;1919 for (i = 0; i < MT7615_DRV_OWN_RETRY_COUNT; i++) {
1820 if (!mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN, 0, 3000)) {1920 u32 addr;
1821 dev_err(dev->mt76.dev, "Timeout for driver own\n");1921
1822 return -EIO;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;
1823 }1928 }
1824 1929
1825 mt7622_trigger_hif_int(dev, false);1930 mt7622_trigger_hif_int(dev, false);
1826 1931
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
1938out:
1939 dev->pm.last_activity = jiffies;
1940
1827 return 0;1941 return 0;
1828}1942}
1829EXPORT_SYMBOL_GPL(mt7615_driver_own);1943EXPORT_SYMBOL_GPL(mt7615_driver_own);
1830 1944
1831int mt7615_firmware_own(struct mt7615_dev *dev)1945int mt7615_firmware_own(struct mt7615_dev *dev)
1832{1946{
1947 struct mt76_phy *mphy = &dev->mt76.phy;
1948 int err = 0;
1833 u32 addr;1949 u32 addr;
1834 1950
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
1836 mt7622_trigger_hif_int(dev, true);1954 mt7622_trigger_hif_int(dev, true);
1837 1955
1956 addr = is_mt7663(&dev->mt76) ? MT_CONN_HIF_ON_LPCTL : MT_CFG_LPCR_HOST;
1838 mt76_wr(dev, addr, MT_CFG_LPCR_HOST_FW_OWN);1957 mt76_wr(dev, addr, MT_CFG_LPCR_HOST_FW_OWN);
1839 1958
1840 if (!is_mt7615(&dev->mt76) &&1959 if (is_mt7622(&dev->mt76) &&
1841 !mt76_poll_msec(dev, addr, MT_CFG_LPCR_HOST_FW_OWN,1960 !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)) {
1843 dev_err(dev->mt76.dev, "Timeout for firmware own\n");1962 dev_err(dev->mt76.dev, "Timeout for firmware own\n");
1844 return -EIO;1963 clear_bit(MT76_STATE_PM, &mphy->state);
1964 err = -EIO;
1845 }1965 }
1966
1846 mt7622_trigger_hif_int(dev, false);1967 mt7622_trigger_hif_int(dev, false);
1847 1968
1848 return 0;1969 return err;
1849}1970}
1850EXPORT_SYMBOL_GPL(mt7615_firmware_own);1971EXPORT_SYMBOL_GPL(mt7615_firmware_own);
1851 1972
@@ -2725,6 +2846,14 @@ int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd) · 873 unmodified lines
2725 .center_chan2 = ieee80211_frequency_to_channel(freq2),2846 .center_chan2 = ieee80211_frequency_to_channel(freq2),
2726 };2847 };
2727 2848
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
2728 if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)2857 if (dev->mt76.hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
2729 req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;2858 req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
2730 else if ((chandef->chan->flags & IEEE80211_CHAN_RADAR) &&2859 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
2736 req.band_idx = phy != &dev->phy;2865 req.band_idx = phy != &dev->phy;
2737 req.bw = mt7615_mcu_chan_bw(chandef);2866 req.bw = mt7615_mcu_chan_bw(chandef);
2738 2867
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);
2740 2872
2741 return __mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true);2873 return __mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), true);
2742}2874}
@@ -2754,6 +2886,27 @@ int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index) · 11 unmodified lines
2754 sizeof(req), true);2886 sizeof(req), true);
2755}2887}
2756 2888
2889int 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
2757int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable)2910int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable)
2758{2911{
2759 struct mt7615_dev *dev = phy->dev;2912 struct mt7615_dev *dev = phy->dev;
@@ -3332,43 +3485,8 @@ out: · 572 unmodified lines
3332 return ret;3485 return ret;
3333}3486}
3334 3487
3335#ifdef CONFIG_PM3488int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
3336int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend)3489 bool enable)
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}
3367EXPORT_SYMBOL_GPL(mt7615_mcu_set_hif_suspend);
3368
3369static int
3370mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
3371 bool enable)
3372{3490{
3373 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;3491 struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
3374 struct {3492 struct {
@@ -3408,6 +3526,40 @@ mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif, · 33 unmodified lines
3408 &req, sizeof(req), false);3526 &req, sizeof(req), false);
3409}3527}
3410 3528
3529#ifdef CONFIG_PM
3530int 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}
3561EXPORT_SYMBOL_GPL(mt7615_mcu_set_hif_suspend);
3562
3411static int3563static int
3412mt7615_mcu_set_wow_ctrl(struct mt7615_phy *phy, struct ieee80211_vif *vif,3564mt7615_mcu_set_wow_ctrl(struct mt7615_phy *phy, struct ieee80211_vif *vif,
3413 bool suspend, struct cfg80211_wowlan *wowlan)3565 bool suspend, struct cfg80211_wowlan *wowlan)
@@ -3542,6 +3694,32 @@ mt7615_mcu_set_gtk_rekey(struct mt7615_dev *dev, · 128 unmodified lines
3542 &req, sizeof(req), true);3694 &req, sizeof(req), true);
3543}3695}
3544 3696
3697static int
3698mt7615_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
3545void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,3723void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
3546 struct ieee80211_vif *vif)3724 struct ieee80211_vif *vif)
3547{3725{
@@ -3554,6 +3732,7 @@ void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac, · 6 unmodified lines
3554 mt7615_mcu_set_bss_pm(phy->dev, vif, suspend);3732 mt7615_mcu_set_bss_pm(phy->dev, vif, suspend);
3555 3733
3556 mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend);3734 mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend);
3735 mt7615_mcu_set_arp_filter(phy->dev, vif, suspend);
3557 3736
3558 mt7615_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true);3737 mt7615_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true);
3559 3738
@@ -3653,6 +3832,53 @@ int mt7615_mcu_set_roc(struct mt7615_phy *phy, struct ieee80211_vif *vif, · 93 unmodified lines
3653 sizeof(req), false);3832 sizeof(req), false);
3654}3833}
3655 3834
3835int 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
3656int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw,3882int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw,
3657 struct ieee80211_vif *vif)3883 struct ieee80211_vif *vif)
3658{3884{
@@ -3674,3 +3900,32 @@ int mt7615_mcu_set_p2p_oppps(struct ieee80211_hw *hw, · 15 unmodified lines
3674 return __mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_P2P_OPPPS,3900 return __mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_P2P_OPPPS,
3675 &req, sizeof(req), false);3901 &req, sizeof(req), false);
3676}3902}
3903
3904u32 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}
3916EXPORT_SYMBOL_GPL(mt7615_mcu_reg_rr);
3917
3918void 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}
3931EXPORT_SYMBOL_GPL(mt7615_mcu_reg_wr);
drivers/net/wireless/mediatek/mt76/mt7615/mcu.h+51−3
@@ -81,6 +81,7 @@ enum { · 80 unmodified lines
81 MCU_EVENT_GENERIC = 0x01,81 MCU_EVENT_GENERIC = 0x01,
82 MCU_EVENT_ACCESS_REG = 0x02,82 MCU_EVENT_ACCESS_REG = 0x02,
83 MCU_EVENT_MT_PATCH_SEM = 0x04,83 MCU_EVENT_MT_PATCH_SEM = 0x04,
84 MCU_EVENT_REG_ACCESS = 0x05,
84 MCU_EVENT_SCAN_DONE = 0x0d,85 MCU_EVENT_SCAN_DONE = 0x0d,
85 MCU_EVENT_ROC = 0x10,86 MCU_EVENT_ROC = 0x10,
86 MCU_EVENT_BSS_ABSENCE = 0x11,87 MCU_EVENT_BSS_ABSENCE = 0x11,
@@ -238,8 +239,11 @@ enum { · 151 unmodified lines
238#define MCU_FW_PREFIX BIT(31)239#define MCU_FW_PREFIX BIT(31)
239#define MCU_UNI_PREFIX BIT(30)240#define MCU_UNI_PREFIX BIT(30)
240#define MCU_CE_PREFIX BIT(29)241#define MCU_CE_PREFIX BIT(29)
242#define MCU_QUERY_PREFIX BIT(28)
241#define MCU_CMD_MASK ~(MCU_FW_PREFIX | MCU_UNI_PREFIX | \243#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)
243 247
244enum {248enum {
245 MCU_CMD_TARGET_ADDRESS_LEN_REQ = MCU_FW_PREFIX | 0x01,249 MCU_CMD_TARGET_ADDRESS_LEN_REQ = MCU_FW_PREFIX | 0x01,
@@ -254,6 +258,7 @@ enum { · 8 unmodified lines
254};258};
255 259
256enum {260enum {
261 MCU_EXT_CMD_RF_REG_ACCESS = 0x02,
257 MCU_EXT_CMD_PM_STATE_CTRL = 0x07,262 MCU_EXT_CMD_PM_STATE_CTRL = 0x07,
258 MCU_EXT_CMD_CHANNEL_SWITCH = 0x08,263 MCU_EXT_CMD_CHANNEL_SWITCH = 0x08,
259 MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11,264 MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11,
@@ -266,6 +271,7 @@ enum { · 6 unmodified lines
266 MCU_EXT_CMD_GET_TEMP = 0x2c,271 MCU_EXT_CMD_GET_TEMP = 0x2c,
267 MCU_EXT_CMD_WTBL_UPDATE = 0x32,272 MCU_EXT_CMD_WTBL_UPDATE = 0x32,
268 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,273 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
274 MCU_EXT_CMD_ATE_CTRL = 0x3d,
269 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,275 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
270 MCU_EXT_CMD_DBDC_CTRL = 0x45,276 MCU_EXT_CMD_DBDC_CTRL = 0x45,
271 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,277 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
@@ -287,6 +293,11 @@ enum { · 15 unmodified lines
287 MCU_UNI_CMD_HIF_CTRL = MCU_UNI_PREFIX | 0x07,293 MCU_UNI_CMD_HIF_CTRL = MCU_UNI_PREFIX | 0x07,
288};294};
289 295
296enum {
297 MCU_ATE_SET_FREQ_OFFSET = 0xa,
298 MCU_ATE_SET_TX_POWER_CONTROL = 0x15,
299};
300
290struct mt7615_mcu_uni_event {301struct mt7615_mcu_uni_event {
291 u8 cid;302 u8 cid;
292 u8 pad[3];303 u8 pad[3];
@@ -421,6 +432,11 @@ struct nt7615_sched_scan_done { · 128 unmodified lines
421 __le16 pad;432 __le16 pad;
422} __packed;433} __packed;
423 434
435struct mt7615_mcu_reg_event {
436 __le32 reg;
437 __le32 val;
438} __packed;
439
424struct mt7615_mcu_bss_event {440struct mt7615_mcu_bss_event {
425 u8 bss_idx;441 u8 bss_idx;
426 u8 is_absent;442 u8 is_absent;
@@ -454,6 +470,13 @@ struct mt7615_bss_basic_tlv { · 27 unmodified lines
454 u8 pad[3];470 u8 pad[3];
455} __packed;471} __packed;
456 472
473struct mt7615_bss_qos_tlv {
474 __le16 tag;
475 __le16 len;
476 u8 qos;
477 u8 pad[3];
478} __packed;
479
457struct mt7615_wow_ctrl_tlv {480struct mt7615_wow_ctrl_tlv {
458 __le16 tag;481 __le16 tag;
459 __le16 len;482 __le16 len;
@@ -545,6 +568,15 @@ struct mt7615_roc_tlv { · 85 unmodified lines
545 u8 rsv1[8];568 u8 rsv1[8];
546} __packed;569} __packed;
547 570
571struct 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
548/* offload mcu commands */580/* offload mcu commands */
549enum {581enum {
550 MCU_CMD_START_HW_SCAN = MCU_CE_PREFIX | 0x03,582 MCU_CMD_START_HW_SCAN = MCU_CE_PREFIX | 0x03,
@@ -557,6 +589,8 @@ enum { · 6 unmodified lines
557 MCU_CMD_SET_P2P_OPPPS = MCU_CE_PREFIX | 0x33,589 MCU_CMD_SET_P2P_OPPPS = MCU_CE_PREFIX | 0x33,
558 MCU_CMD_SCHED_SCAN_ENABLE = MCU_CE_PREFIX | 0x61,590 MCU_CMD_SCHED_SCAN_ENABLE = MCU_CE_PREFIX | 0x61,
559 MCU_CMD_SCHED_SCAN_REQ = MCU_CE_PREFIX | 0x62,591 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,
560};594};
561 595
562#define MCU_CMD_ACK BIT(0)596#define MCU_CMD_ACK BIT(0)
@@ -569,6 +603,8 @@ enum { · 6 unmodified lines
569 UNI_BSS_INFO_BASIC = 0,603 UNI_BSS_INFO_BASIC = 0,
570 UNI_BSS_INFO_RLM = 2,604 UNI_BSS_INFO_RLM = 2,
571 UNI_BSS_INFO_BCN_CONTENT = 7,605 UNI_BSS_INFO_BCN_CONTENT = 7,
606 UNI_BSS_INFO_QBSS = 15,
607 UNI_BSS_INFO_UAPSD = 19,
572};608};
573 609
574enum {610enum {
@@ -580,8 +616,8 @@ enum { · 5 unmodified lines
580};616};
581 617
582enum {618enum {
583 UNI_OFFLOAD_OFFLOAD_ARPNS_IPV4,619 UNI_OFFLOAD_OFFLOAD_ARP,
584 UNI_OFFLOAD_OFFLOAD_ARPNS_IPV6,620 UNI_OFFLOAD_OFFLOAD_ND,
585 UNI_OFFLOAD_OFFLOAD_GTK_REKEY,621 UNI_OFFLOAD_OFFLOAD_GTK_REKEY,
586 UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT,622 UNI_OFFLOAD_OFFLOAD_BMC_RPY_DETECT,
587};623};
@@ -882,6 +918,7 @@ struct wtbl_raw { · 294 unmodified lines
882 sizeof(struct sta_rec_basic) + \918 sizeof(struct sta_rec_basic) + \
883 sizeof(struct sta_rec_ht) + \919 sizeof(struct sta_rec_ht) + \
884 sizeof(struct sta_rec_vht) + \920 sizeof(struct sta_rec_vht) + \
921 sizeof(struct sta_rec_uapsd) + \
885 sizeof(struct tlv) + \922 sizeof(struct tlv) + \
886 MT7615_WTBL_UPDATE_MAX_SIZE)923 MT7615_WTBL_UPDATE_MAX_SIZE)
887 924
@@ -971,6 +1008,17 @@ struct sta_rec_ba { · 83 unmodified lines
971 __le16 winsize;1008 __le16 winsize;
972} __packed;1009} __packed;
973 1010
1011struct 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
974enum {1022enum {
975 STA_REC_BASIC,1023 STA_REC_BASIC,
976 STA_REC_RA,1024 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
17 [MT_CSR_BASE] = 0x07000,17 [MT_CSR_BASE] = 0x07000,
18 [MT_PLE_BASE] = 0x08000,18 [MT_PLE_BASE] = 0x08000,
19 [MT_PSE_BASE] = 0x0c000,19 [MT_PSE_BASE] = 0x0c000,
20 [MT_PHY_BASE] = 0x10000,
21 [MT_CFG_BASE] = 0x20200,20 [MT_CFG_BASE] = 0x20200,
22 [MT_AGG_BASE] = 0x20a00,21 [MT_AGG_BASE] = 0x20a00,
23 [MT_TMAC_BASE] = 0x21000,22 [MT_TMAC_BASE] = 0x21000,
@@ -44,7 +43,7 @@ const u32 mt7663e_reg_map[] = { · 20 unmodified lines
44 [MT_CSR_BASE] = 0x07000,43 [MT_CSR_BASE] = 0x07000,
45 [MT_PLE_BASE] = 0x08000,44 [MT_PLE_BASE] = 0x08000,
46 [MT_PSE_BASE] = 0x0c000,45 [MT_PSE_BASE] = 0x0c000,
47 [MT_PHY_BASE] = 0x10000,46 [MT_PP_BASE] = 0x0e000,
48 [MT_CFG_BASE] = 0x20000,47 [MT_CFG_BASE] = 0x20000,
49 [MT_AGG_BASE] = 0x22000,48 [MT_AGG_BASE] = 0x22000,
50 [MT_TMAC_BASE] = 0x24000,49 [MT_TMAC_BASE] = 0x24000,
@@ -140,6 +139,38 @@ static void mt7615_irq_tasklet(unsigned long data) · 89 unmodified lines
140 mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0);139 mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0);
141}140}
142 141
142static 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
150static 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
158static 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
166static 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
143int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,174int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
144 int irq, const u32 *map)175 int irq, const u32 *map)
145{176{
@@ -159,6 +190,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, · 13 unmodified lines
159 .sta_remove = mt7615_mac_sta_remove,190 .sta_remove = mt7615_mac_sta_remove,
160 .update_survey = mt7615_update_channel,191 .update_survey = mt7615_update_channel,
161 };192 };
193 struct mt76_bus_ops *bus_ops;
162 struct ieee80211_ops *ops;194 struct ieee80211_ops *ops;
163 struct mt7615_dev *dev;195 struct mt7615_dev *dev;
164 struct mt76_dev *mdev;196 struct mt76_dev *mdev;
@@ -182,6 +214,19 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, · 17 unmodified lines
182 (mt76_rr(dev, MT_HW_REV) & 0xff);214 (mt76_rr(dev, MT_HW_REV) & 0xff);
183 dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);215 dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
184 216
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
185 ret = devm_request_irq(mdev->dev, irq, mt7615_irq_handler,230 ret = devm_request_irq(mdev->dev, irq, mt7615_irq_handler,
186 IRQF_SHARED, KBUILD_MODNAME, dev);231 IRQF_SHARED, KBUILD_MODNAME, dev);
187 if (ret)232 if (ret)
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h+91−4
@@ -4,6 +4,7 @@ · 3 unmodified lines
4#ifndef __MT7615_H4#ifndef __MT7615_H
5#define __MT7615_H5#define __MT7615_H
6 6
7#include <linux/completion.h>
7#include <linux/interrupt.h>8#include <linux/interrupt.h>
8#include <linux/ktime.h>9#include <linux/ktime.h>
9#include <linux/regmap.h>10#include <linux/regmap.h>
@@ -18,6 +19,7 @@ · 8 unmodified lines
18#define MT7615_WTBL_STA (MT7615_WTBL_RESERVED - \19#define MT7615_WTBL_STA (MT7615_WTBL_RESERVED - \
19 MT7615_MAX_INTERFACES)20 MT7615_MAX_INTERFACES)
20 21
22#define MT7615_PM_TIMEOUT (HZ / 12)
21#define MT7615_WATCHDOG_TIME (HZ / 10)23#define MT7615_WATCHDOG_TIME (HZ / 10)
22#define MT7615_HW_SCAN_TIMEOUT (HZ / 10)24#define MT7615_HW_SCAN_TIMEOUT (HZ / 10)
23#define MT7615_RESET_TIMEOUT (30 * HZ)25#define MT7615_RESET_TIMEOUT (30 * HZ)
@@ -31,6 +33,8 @@ · 7 unmodified lines
31#define MT7615_RX_RING_SIZE 102433#define MT7615_RX_RING_SIZE 1024
32#define MT7615_RX_MCU_RING_SIZE 51234#define MT7615_RX_MCU_RING_SIZE 512
33 35
36#define MT7615_DRV_OWN_RETRY_COUNT 10
37
34#define MT7615_FIRMWARE_CR4 "mediatek/mt7615_cr4.bin"38#define MT7615_FIRMWARE_CR4 "mediatek/mt7615_cr4.bin"
35#define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin"39#define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin"
36#define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin"40#define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin"
@@ -169,6 +173,8 @@ struct mt7615_phy { · 132 unmodified lines
169 struct mt76_phy *mt76;173 struct mt76_phy *mt76;
170 struct mt7615_dev *dev;174 struct mt7615_dev *dev;
171 175
176 struct ieee80211_vif *monitor_vif;
177
172 u32 rxfilter;178 u32 rxfilter;
173 u32 omac_mask;179 u32 omac_mask;
174 180
@@ -240,10 +246,10 @@ struct mt7615_dev { · 65 unmodified lines
240 struct mt76_phy mphy;246 struct mt76_phy mphy;
241 };247 };
242 248
249 const struct mt76_bus_ops *bus_ops;
243 struct tasklet_struct irq_tasklet;250 struct tasklet_struct irq_tasklet;
244 251
245 struct mt7615_phy phy;252 struct mt7615_phy phy;
246 u32 vif_mask;
247 u32 omac_mask;253 u32 omac_mask;
248 254
249 u16 chainmask;255 u16 chainmask;
@@ -280,6 +286,37 @@ struct mt7615_dev { · 30 unmodified lines
280 286
281 struct work_struct wtbl_work;287 struct work_struct wtbl_work;
282 struct list_head wd_head;288 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;
283};320};
284 321
285enum tx_pkt_queue_idx {322enum tx_pkt_queue_idx {
@@ -372,8 +409,10 @@ extern struct ieee80211_rate mt7615_rates[12]; · 86 unmodified lines
372extern const struct ieee80211_ops mt7615_ops;409extern const struct ieee80211_ops mt7615_ops;
373extern const u32 mt7615e_reg_map[__MT_BASE_MAX];410extern const u32 mt7615e_reg_map[__MT_BASE_MAX];
374extern const u32 mt7663e_reg_map[__MT_BASE_MAX];411extern const u32 mt7663e_reg_map[__MT_BASE_MAX];
412extern const u32 mt7663_usb_sdio_reg_map[__MT_BASE_MAX];
375extern struct pci_driver mt7615_pci_driver;413extern struct pci_driver mt7615_pci_driver;
376extern struct platform_driver mt7622_wmac_driver;414extern struct platform_driver mt7622_wmac_driver;
415extern const struct mt76_testmode_ops mt7615_testmode_ops;
377 416
378#ifdef CONFIG_MT7622_WMAC417#ifdef CONFIG_MT7622_WMAC
379int mt7622_wmac_init(struct mt7615_dev *dev);418int mt7622_wmac_init(struct mt7615_dev *dev);
@@ -408,6 +447,11 @@ bool mt7615_wait_for_mcu_init(struct mt7615_dev *dev); · 28 unmodified lines
408void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,447void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
409 struct ieee80211_tx_rate *probe_rate,448 struct ieee80211_tx_rate *probe_rate,
410 struct ieee80211_tx_rate *rates);449 struct ieee80211_tx_rate *rates);
450int mt7615_pm_set_enable(struct mt7615_dev *dev, bool enable);
451void mt7615_pm_wake_work(struct work_struct *work);
452int mt7615_pm_wake(struct mt7615_dev *dev);
453void mt7615_pm_power_save_sched(struct mt7615_dev *dev);
454void mt7615_pm_power_save_work(struct work_struct *work);
411int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);455int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
412int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);456int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);
413int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,457int 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
462 return MT7615_WTBL_SIZE;506 return MT7615_WTBL_SIZE;
463}507}
464 508
509static 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
516static 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
465static inline u8 mt7615_lmac_mapping(struct mt7615_dev *dev, u8 ac)523static inline u8 mt7615_lmac_mapping(struct mt7615_dev *dev, u8 ac)
466{524{
467 static const u8 lmac_queue_map[] = {525 static const u8 lmac_queue_map[] = {
@@ -485,6 +543,7 @@ void mt7615_init_txpower(struct mt7615_dev *dev, · 17 unmodified lines
485 struct ieee80211_supported_band *sband);543 struct ieee80211_supported_band *sband);
486void mt7615_phy_init(struct mt7615_dev *dev);544void mt7615_phy_init(struct mt7615_dev *dev);
487void mt7615_mac_init(struct mt7615_dev *dev);545void mt7615_mac_init(struct mt7615_dev *dev);
546int mt7615_set_channel(struct mt7615_phy *phy);
488 547
489int mt7615_mcu_restart(struct mt76_dev *dev);548int mt7615_mcu_restart(struct mt76_dev *dev);
490void mt7615_update_channel(struct mt76_dev *mdev);549void mt7615_update_channel(struct mt76_dev *mdev);
@@ -516,15 +575,19 @@ int mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, · 25 unmodified lines
516 enum mt7615_cipher_type cipher,575 enum mt7615_cipher_type cipher,
517 enum set_key_cmd cmd);576 enum set_key_cmd cmd);
518void mt7615_mac_reset_work(struct work_struct *work);577void mt7615_mac_reset_work(struct work_struct *work);
578u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid);
519 579
520int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);580int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
521int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,581int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
522 int len, bool wait_resp);582 int len, bool wait_resp);
583u32 mt7615_rf_rr(struct mt7615_dev *dev, u32 wf, u32 reg);
584int mt7615_rf_wr(struct mt7615_dev *dev, u32 wf, u32 reg, u32 val);
523int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);585int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);
524int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);586int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
525int mt7615_mcu_set_mac_enable(struct mt7615_dev *dev, int band, bool enable);587int mt7615_mcu_set_mac_enable(struct mt7615_dev *dev, int band, bool enable);
526int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val);588int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val);
527int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index);589int mt7615_mcu_get_temperature(struct mt7615_dev *dev, int index);
590int mt7615_mcu_set_tx_power(struct mt7615_phy *phy);
528void mt7615_mcu_exit(struct mt7615_dev *dev);591void mt7615_mcu_exit(struct mt7615_dev *dev);
529void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,592void mt7615_mcu_fill_msg(struct mt7615_dev *dev, struct sk_buff *skb,
530 int cmd, int *wait_seq);593 int cmd, int *wait_seq);
@@ -563,6 +626,8 @@ int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev, · 32 unmodified lines
563 const struct mt7615_dfs_pulse *pulse);626 const struct mt7615_dfs_pulse *pulse);
564int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,627int mt7615_mcu_set_radar_th(struct mt7615_dev *dev, int index,
565 const struct mt7615_dfs_pattern *pattern);628 const struct mt7615_dfs_pattern *pattern);
629int mt7615_mcu_set_test_param(struct mt7615_dev *dev, u8 param, bool test_mode,
630 u32 val);
566int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);631int mt7615_mcu_set_sku_en(struct mt7615_phy *phy, bool enable);
567int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);632int mt7615_mcu_apply_rx_dcoc(struct mt7615_phy *phy);
568int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);633int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
@@ -579,18 +644,40 @@ int mt7615_driver_own(struct mt7615_dev *dev); · 10 unmodified lines
579int mt7615_init_debugfs(struct mt7615_dev *dev);644int mt7615_init_debugfs(struct mt7615_dev *dev);
580int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);645int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
581 646
647int mt7615_mcu_set_bss_pm(struct mt7615_dev *dev, struct ieee80211_vif *vif,
648 bool enable);
582int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend);649int mt7615_mcu_set_hif_suspend(struct mt7615_dev *dev, bool suspend);
583void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,650void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
584 struct ieee80211_vif *vif);651 struct ieee80211_vif *vif);
585int mt7615_mcu_update_gtk_rekey(struct ieee80211_hw *hw,652int mt7615_mcu_update_gtk_rekey(struct ieee80211_hw *hw,
586 struct ieee80211_vif *vif,653 struct ieee80211_vif *vif,
587 struct cfg80211_gtk_rekey_data *key);654 struct cfg80211_gtk_rekey_data *key);
588 655int mt7615_mcu_update_arp_filter(struct ieee80211_hw *hw,
656 struct ieee80211_vif *vif,
657 struct ieee80211_bss_conf *info);
589int __mt7663_load_firmware(struct mt7615_dev *dev);658int __mt7663_load_firmware(struct mt7615_dev *dev);
659u32 mt7615_mcu_reg_rr(struct mt76_dev *dev, u32 offset);
660void mt7615_mcu_reg_wr(struct mt76_dev *dev, u32 offset, u32 val);
590 661
591/* usb */662/* usb */
592void mt7663u_wtbl_work(struct work_struct *work);663int 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);
667bool mt7663_usb_sdio_tx_status_data(struct mt76_dev *mdev, u8 *update);
668void mt7663_usb_sdio_tx_complete_skb(struct mt76_dev *mdev,
669 enum mt76_txq_id qid,
670 struct mt76_queue_entry *e);
671void mt7663_usb_sdio_wtbl_work(struct work_struct *work);
672int mt7663_usb_sdio_register_device(struct mt7615_dev *dev);
593int mt7663u_mcu_init(struct mt7615_dev *dev);673int mt7663u_mcu_init(struct mt7615_dev *dev);
594int mt7663u_register_device(struct mt7615_dev *dev);674
675/* sdio */
676u32 mt7663s_read_pcr(struct mt7615_dev *dev);
677int mt7663s_mcu_init(struct mt7615_dev *dev);
678int mt7663s_driver_own(struct mt7615_dev *dev);
679int mt7663s_firmware_own(struct mt7615_dev *dev);
680int mt7663s_kthread_run(void *data);
681void mt7663s_sdio_irq(struct sdio_func *func);
595 682
596#endif683#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
75 bool hif_suspend;75 bool hif_suspend;
76 int i, err;76 int i, err;
77 77
78 err = mt7615_pm_wake(dev);
79 if (err < 0)
80 return err;
81
78 hif_suspend = !test_bit(MT76_STATE_SUSPEND, &dev->mphy.state) &&82 hif_suspend = !test_bit(MT76_STATE_SUSPEND, &dev->mphy.state) &&
79 mt7615_firmware_offload(dev);83 mt7615_firmware_offload(dev);
80 if (hif_suspend) {84 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
70 70
71 mt76 = container_of(led_cdev, struct mt76_dev, led_cdev);71 mt76 = container_of(led_cdev, struct mt76_dev, led_cdev);
72 dev = container_of(mt76, struct mt7615_dev, mt76);72 dev = container_of(mt76, struct mt7615_dev, mt76);
73
74 if (test_bit(MT76_STATE_PM, &mt76->phy.state))
75 return;
76
73 val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xffff) |77 val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xffff) |
74 FIELD_PREP(MT_LED_STATUS_OFF, delay_off) |78 FIELD_PREP(MT_LED_STATUS_OFF, delay_off) |
75 FIELD_PREP(MT_LED_STATUS_ON, delay_on);79 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
155 spin_lock_bh(&dev->mt76.lock);155 spin_lock_bh(&dev->mt76.lock);
156 mt7615_mac_set_rates(phy, msta, &info->control.rates[0],156 mt7615_mac_set_rates(phy, msta, &info->control.rates[0],
157 msta->rates);157 msta->rates);
158 msta->rate_probe = true;
159 spin_unlock_bh(&dev->mt76.lock);158 spin_unlock_bh(&dev->mt76.lock);
160 }159 }
161 160
drivers/net/wireless/mediatek/mt76/mt7615/regs.h+31−2
@@ -14,7 +14,6 @@ enum mt7615_reg_base { · 13 unmodified lines
14 MT_CSR_BASE,14 MT_CSR_BASE,
15 MT_PLE_BASE,15 MT_PLE_BASE,
16 MT_PSE_BASE,16 MT_PSE_BASE,
17 MT_PHY_BASE,
18 MT_CFG_BASE,17 MT_CFG_BASE,
19 MT_AGG_BASE,18 MT_AGG_BASE,
20 MT_TMAC_BASE,19 MT_TMAC_BASE,
@@ -29,6 +28,7 @@ enum mt7615_reg_base { · 8 unmodified lines
29 MT_PCIE_REMAP_BASE2,28 MT_PCIE_REMAP_BASE2,
30 MT_TOP_MISC_BASE,29 MT_TOP_MISC_BASE,
31 MT_EFUSE_ADDR_BASE,30 MT_EFUSE_ADDR_BASE,
31 MT_PP_BASE,
32 __MT_BASE_MAX,32 __MT_BASE_MAX,
33};33};
34 34
@@ -153,6 +153,8 @@ enum mt7615_reg_base { · 118 unmodified lines
153 153
154#define MT_PLE(ofs) ((dev)->reg_map[MT_PLE_BASE] + (ofs))154#define MT_PLE(ofs) ((dev)->reg_map[MT_PLE_BASE] + (ofs))
155 155
156#define MT_PLE_PG_HIF0_GROUP MT_PLE(0x110)
157#define MT_HIF0_MIN_QUOTA GENMASK(11, 0)
156#define MT_PLE_FL_Q0_CTRL MT_PLE(0x1b0)158#define MT_PLE_FL_Q0_CTRL MT_PLE(0x1b0)
157#define MT_PLE_FL_Q1_CTRL MT_PLE(0x1b4)159#define MT_PLE_FL_Q1_CTRL MT_PLE(0x1b4)
158#define MT_PLE_FL_Q2_CTRL MT_PLE(0x1b8)160#define MT_PLE_FL_Q2_CTRL MT_PLE(0x1b8)
@@ -162,6 +164,10 @@ enum mt7615_reg_base { · 3 unmodified lines
162 ((n) << 2))164 ((n) << 2))
163 165
164#define MT_PSE(ofs) ((dev)->reg_map[MT_PSE_BASE] + (ofs))166#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)
165#define MT_PSE_QUEUE_EMPTY MT_PSE(0x0b4)171#define MT_PSE_QUEUE_EMPTY MT_PSE(0x0b4)
166#define MT_HIF_0_EMPTY_MASK BIT(16)172#define MT_HIF_0_EMPTY_MASK BIT(16)
167#define MT_HIF_1_EMPTY_MASK BIT(17)173#define MT_HIF_1_EMPTY_MASK BIT(17)
@@ -169,7 +175,12 @@ enum mt7615_reg_base { · 1 unmodified line
169#define MT_PSE_PG_INFO MT_PSE(0x194)175#define MT_PSE_PG_INFO MT_PSE(0x194)
170#define MT_PSE_SRC_CNT GENMASK(27, 16)176#define MT_PSE_SRC_CNT GENMASK(27, 16)
171 177
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
173#define MT_WF_PHY(ofs) (MT_WF_PHY_BASE + (ofs))184#define MT_WF_PHY(ofs) (MT_WF_PHY_BASE + (ofs))
174 185
175#define MT_WF_PHY_WF2_RFCTRL0(n) MT_WF_PHY(0x1900 + (n) * 0x400)186#define MT_WF_PHY_WF2_RFCTRL0(n) MT_WF_PHY(0x1900 + (n) * 0x400)
@@ -213,6 +224,9 @@ enum mt7615_reg_base { · 37 unmodified lines
213#define MT_WF_PHY_RXTD2_BASE MT_WF_PHY(0x2a00)224#define MT_WF_PHY_RXTD2_BASE MT_WF_PHY(0x2a00)
214#define MT_WF_PHY_RXTD2(_n) (MT_WF_PHY_RXTD2_BASE + ((_n) << 2))225#define MT_WF_PHY_RXTD2(_n) (MT_WF_PHY_RXTD2_BASE + ((_n) << 2))
215 226
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
216#define MT_WF_CFG_BASE ((dev)->reg_map[MT_CFG_BASE])230#define MT_WF_CFG_BASE ((dev)->reg_map[MT_CFG_BASE])
217#define MT_WF_CFG(ofs) (MT_WF_CFG_BASE + (ofs))231#define MT_WF_CFG(ofs) (MT_WF_CFG_BASE + (ofs))
218 232
@@ -256,6 +270,13 @@ enum mt7615_reg_base { · 37 unmodified lines
256#define MT_WF_ARB_BASE ((dev)->reg_map[MT_ARB_BASE])270#define MT_WF_ARB_BASE ((dev)->reg_map[MT_ARB_BASE])
257#define MT_WF_ARB(ofs) (MT_WF_ARB_BASE + (ofs))271#define MT_WF_ARB(ofs) (MT_WF_ARB_BASE + (ofs))
258 272
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
259#define MT_ARB_SCR MT_WF_ARB(0x080)280#define MT_ARB_SCR MT_WF_ARB(0x080)
260#define MT_ARB_SCR_TX0_DISABLE BIT(8)281#define MT_ARB_SCR_TX0_DISABLE BIT(8)
261#define MT_ARB_SCR_RX0_DISABLE BIT(9)282#define MT_ARB_SCR_RX0_DISABLE BIT(9)
@@ -417,6 +438,7 @@ enum mt7615_reg_base { · 155 unmodified lines
417 438
418#define MT_LPON_T0CR MT_LPON(0x010)439#define MT_LPON_T0CR MT_LPON(0x010)
419#define MT_LPON_T0CR_MODE GENMASK(1, 0)440#define MT_LPON_T0CR_MODE GENMASK(1, 0)
441#define MT_LPON_T0CR_WRITE BIT(0)
420 442
421#define MT_LPON_UTTR0 MT_LPON(0x018)443#define MT_LPON_UTTR0 MT_LPON(0x018)
422#define MT_LPON_UTTR1 MT_LPON(0x01c)444#define MT_LPON_UTTR1 MT_LPON(0x01c)
@@ -550,4 +572,11 @@ enum mt7615_reg_base { · 127 unmodified lines
550#define MT_WL_RX_BUSY BIT(30)572#define MT_WL_RX_BUSY BIT(30)
551#define MT_WL_TX_BUSY BIT(31)573#define MT_WL_TX_BUSY BIT(31)
552 574
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
553#endif582#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
21static const struct sdio_device_id mt7663s_table[] = {
22 { SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, 0x7603) },
23 { } /* Terminating entry */
24};
25
26static u32 mt7663s_read_whisr(struct mt76_dev *dev)
27{
28 return sdio_readl(dev->sdio.func, MCR_WHISR, NULL);
29}
30
31u32 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
38static 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
87out:
88 sdio_release_host(func);
89
90 return val;
91}
92
93static 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
142out:
143 sdio_release_host(func);
144}
145
146static 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
154static 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
162static 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
170static 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
182static 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
194static 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
208static 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
222static 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
237static 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
289disable_func:
290 sdio_disable_func(func);
291release:
292 sdio_release_host(func);
293
294 return ret;
295}
296
297static 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
321static 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
394err_deinit:
395 mt76s_deinit(&dev->mt76);
396err_free:
397 mt76_free_device(&dev->mt76);
398
399 return ret;
400}
401
402static 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
415static 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
434static 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
451static const struct dev_pm_ops mt7663s_pm_ops = {
452 .suspend = mt7663s_suspend,
453 .resume = mt7663s_resume,
454};
455#endif
456
457MODULE_DEVICE_TABLE(sdio, mt7663s_table);
458MODULE_FIRMWARE(MT7663_OFFLOAD_FIRMWARE_N9);
459MODULE_FIRMWARE(MT7663_OFFLOAD_ROM_PATCH);
460MODULE_FIRMWARE(MT7663_FIRMWARE_N9);
461MODULE_FIRMWARE(MT7663_ROM_PATCH);
462
463static 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};
474module_sdio_driver(mt7663s_driver);
475
476MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
477MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
478MODULE_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
103struct 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
19static 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
42static int
43mt7663s_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
60out:
61 mutex_unlock(&mdev->mcu.mutex);
62
63 return ret;
64}
65
66int 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
92out:
93 dev->pm.last_activity = jiffies;
94
95 return 0;
96}
97
98int 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
124int 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
22static 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
39static 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
64static 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
119static 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
160static 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
191static 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
208int 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
233void 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);
265out:
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
8enum {
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
18static 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
24static 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
37static 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
47static int
48mt7615_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
98static void
99mt7615_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
133static void
134mt7615_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
149static void
150mt7615_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
158static void
159mt7615_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
178static void
179mt7615_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
231static void
232mt7615_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
247static void
248mt7615_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
263static int
264mt7615_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
300static int
301mt7615_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
328static int
329mt7615_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
359const 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
15#include "mcu.h"15#include "mcu.h"
16#include "regs.h"16#include "regs.h"
17 17
18static 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
43static const struct usb_device_id mt7615_device_table[] = {18static const struct usb_device_id mt7615_device_table[] = {
44 { USB_DEVICE_AND_INTERFACE_INFO(0x0e8d, 0x7663, 0xff, 0xff, 0xff) },19 { USB_DEVICE_AND_INTERFACE_INFO(0x0e8d, 0x7663, 0xff, 0xff, 0xff) },
45 { },20 { },
@@ -64,205 +39,19 @@ static void mt7663u_cleanup(struct mt7615_dev *dev) · 18 unmodified lines
64 mt76u_queues_deinit(&dev->mt76);39 mt76u_queues_deinit(&dev->mt76);
65}40}
66 41
67static void42static void mt7663u_init_work(struct work_struct *work)
68mt7663u_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
88static 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
157static 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
197void mt7663u_wtbl_work(struct work_struct *work)
198{43{
199 struct mt7615_wtbl_desc *wd, *wd_next;
200 struct mt7615_dev *dev;44 struct mt7615_dev *dev;
201 45
202 dev = (struct mt7615_dev *)container_of(work, struct mt7615_dev,46 dev = container_of(work, struct mt7615_dev, mcu_work);
203 wtbl_work);47 if (mt7663u_mcu_init(dev))
204 48 return;
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
225static void
226mt7663u_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
233static int
234mt7663u_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
257static 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);
264 49
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);
266}55}
267 56
268static int mt7663u_probe(struct usb_interface *usb_intf,57static int mt7663u_probe(struct usb_interface *usb_intf,
@@ -271,9 +60,9 @@ static int mt7663u_probe(struct usb_interface *usb_intf, · 2 unmodified lines
271 static const struct mt76_driver_ops drv_ops = {60 static const struct mt76_driver_ops drv_ops = {
272 .txwi_size = MT_USB_TXD_SIZE,61 .txwi_size = MT_USB_TXD_SIZE,
273 .drv_flags = MT_DRV_RX_DMA_HDR | MT_DRV_HW_MGMT_TXQ,62 .drv_flags = MT_DRV_RX_DMA_HDR | MT_DRV_HW_MGMT_TXQ,
274 .tx_prepare_skb = mt7663u_tx_prepare_skb,63 .tx_prepare_skb = mt7663_usb_sdio_tx_prepare_skb,
275 .tx_complete_skb = mt7663u_tx_complete_skb,64 .tx_complete_skb = mt7663_usb_sdio_tx_complete_skb,
276 .tx_status_data = mt7663u_tx_status_data,65 .tx_status_data = mt7663_usb_sdio_tx_status_data,
277 .rx_skb = mt7615_queue_rx_skb,66 .rx_skb = mt7615_queue_rx_skb,
278 .sta_ps = mt7615_sta_ps,67 .sta_ps = mt7615_sta_ps,
279 .sta_add = mt7615_mac_sta_add,68 .sta_add = mt7615_mac_sta_add,
@@ -303,7 +92,8 @@ static int mt7663u_probe(struct usb_interface *usb_intf, · 23 unmodified lines
303 92
304 usb_set_intfdata(usb_intf, dev);93 usb_set_intfdata(usb_intf, dev);
305 94
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;
307 dev->ops = ops;97 dev->ops = ops;
308 ret = mt76u_init(mdev, usb_intf, true);98 ret = mt76u_init(mdev, usb_intf, true);
309 if (ret < 0)99 if (ret < 0)
@@ -342,7 +132,7 @@ alloc_queues: · 32 unmodified lines
342 if (ret)132 if (ret)
343 goto error_free_q;133 goto error_free_q;
344 134
345 ret = mt7663u_register_device(dev);135 ret = mt7663_usb_sdio_register_device(dev);
346 if (ret)136 if (ret)
347 goto error_free_q;137 goto error_free_q;
348 138
@@ -351,11 +141,10 @@ alloc_queues: · 2 unmodified lines
351error_free_q:141error_free_q:
352 mt76u_queues_deinit(&dev->mt76);142 mt76u_queues_deinit(&dev->mt76);
353error:143error:
354 mt76u_deinit(&dev->mt76);
355 usb_set_intfdata(usb_intf, NULL);144 usb_set_intfdata(usb_intf, NULL);
356 usb_put_dev(interface_to_usbdev(usb_intf));145 usb_put_dev(interface_to_usbdev(usb_intf));
357 146
358 ieee80211_free_hw(mdev->hw);147 mt76_free_device(&dev->mt76);
359 148
360 return ret;149 return ret;
361}150}
@@ -373,8 +162,7 @@ static void mt7663u_disconnect(struct usb_interface *usb_intf) · 11 unmodified lines
373 usb_set_intfdata(usb_intf, NULL);162 usb_set_intfdata(usb_intf, NULL);
374 usb_put_dev(interface_to_usbdev(usb_intf));163 usb_put_dev(interface_to_usbdev(usb_intf));
375 164
376 mt76u_deinit(&dev->mt76);165 mt76_free_device(&dev->mt76);
377 ieee80211_free_hw(dev->mt76.hw);
378}166}
379 167
380#ifdef CONFIG_PM168#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
16static 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
68static 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
94static 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
109int 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
28 else28 else
29 ep = MT_EP_OUT_AC_BE;29 ep = MT_EP_OUT_AC_BE;
30 30
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);
32 if (ret < 0)33 if (ret < 0)
33 goto out;34 goto out;
34 35
35 ret = mt76u_bulk_msg(&dev->mt76, skb->data, skb->len, NULL,36 ret = mt76u_bulk_msg(&dev->mt76, skb->data, skb->len, NULL,
36 1000, ep);37 1000, ep);
37 dev_kfree_skb(skb);
38 if (ret < 0)38 if (ret < 0)
39 goto out;39 goto out;
40 40
@@ -43,6 +43,7 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, · 2 unmodified lines
43 43
44out:44out:
45 mutex_unlock(&mdev->mcu.mutex);45 mutex_unlock(&mdev->mcu.mutex);
46 dev_kfree_skb(skb);
46 47
47 return ret;48 return ret;
48}49}
@@ -60,6 +61,8 @@ int mt7663u_mcu_init(struct mt7615_dev *dev) · 11 unmodified lines
60 61
61 dev->mt76.mcu_ops = &mt7663u_mcu_ops,62 dev->mt76.mcu_ops = &mt7663u_mcu_ops,
62 63
64 /* usb does not support runtime-pm */
65 clear_bit(MT76_STATE_PM, &dev->mphy.state);
63 mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);66 mt76_set(dev, MT_UDMA_TX_QSEL, MT_FW_DL_EN);
64 67
65 if (test_and_clear_bit(MT76_STATE_POWER_OFF, &dev->mphy.state)) {68 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
17const 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};
41EXPORT_SYMBOL_GPL(mt7663_usb_sdio_reg_map);
42
43static void
44mt7663_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
64static int
65mt7663_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
135static int
136mt7663_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);
175out:
176 kfree(key->key);
177
178 return err;
179}
180
181void 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}
214EXPORT_SYMBOL_GPL(mt7663_usb_sdio_wtbl_work);
215
216bool 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}
226EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_status_data);
227
228void 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}
240EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_complete_skb);
241
242int 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}
267EXPORT_SYMBOL_GPL(mt7663_usb_sdio_tx_prepare_skb);
268
269static 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
321static 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
349int 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}
390EXPORT_SYMBOL_GPL(mt7663_usb_sdio_register_device);
391
392MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
393MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
394MODULE_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
277err:277err:
278 usb_set_intfdata(usb_intf, NULL);278 usb_set_intfdata(usb_intf, NULL);
279 usb_put_dev(interface_to_usbdev(usb_intf));279 usb_put_dev(interface_to_usbdev(usb_intf));
280 mt76u_deinit(&dev->mt76);280 mt76_free_device(&dev->mt76);
281 281
282 ieee80211_free_hw(mdev->hw);
283 return ret;282 return ret;
284}283}
285 284
@@ -297,8 +296,7 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf) · 11 unmodified lines
297 usb_set_intfdata(usb_intf, NULL);296 usb_set_intfdata(usb_intf, NULL);
298 usb_put_dev(interface_to_usbdev(usb_intf));297 usb_put_dev(interface_to_usbdev(usb_intf));
299 298
300 mt76u_deinit(&dev->mt76);299 mt76_free_device(&dev->mt76);
301 ieee80211_free_hw(dev->mt76.hw);
302}300}
303 301
304static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,302static 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
80 80
81 struct mutex phy_mutex;81 struct mutex phy_mutex;
82 82
83 u16 vif_mask;
84 u16 chainmask;83 u16 chainmask;
85 84
86 u8 txdone_seq;85 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
439 memset(msta, 0, sizeof(*msta));439 memset(msta, 0, sizeof(*msta));
440 }440 }
441 441
442 dev->vif_mask = 0;442 dev->mphy.vif_mask = 0;
443 dev->mt76.beacon_mask = 0;443 dev->mt76.beacon_mask = 0;
444}444}
445 445
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
56 */56 */
57 info = FIELD_PREP(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |57 info = FIELD_PREP(MT_TXD_INFO_LEN, round_up(skb->len, 4)) |
58 FIELD_PREP(MT_TXD_INFO_DPORT, port) | flags;58 FIELD_PREP(MT_TXD_INFO_DPORT, port) | flags;
59 put_unaligned_le32(info, skb_push(skb, sizeof(info)));
59 60
60 return mt76u_skb_dma_info(skb, info);61 return mt76_skb_adjust_pad(skb);
61}62}
62 63
63int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,64int 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
87 u32 info;87 u32 info;
88 int ret;88 int ret;
89 89
90 if (test_bit(MT76_REMOVED, &dev->phy.state))90 if (test_bit(MT76_REMOVED, &dev->phy.state)) {
91 return 0;91 ret = 0;
92 goto out;
93 }
92 94
93 if (wait_resp) {95 if (wait_resp) {
94 seq = ++dev->mcu.msg_seq & 0xf;96 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
111 if (wait_resp)113 if (wait_resp)
112 ret = mt76x02u_mcu_wait_resp(dev, seq);114 ret = mt76x02u_mcu_wait_resp(dev, seq);
113 115
116out:
114 consume_skb(skb);117 consume_skb(skb);
115 118
116 return ret;119 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
305 unsigned int idx = 0;305 unsigned int idx = 0;
306 306
307 /* Allow to change address in HW if we create first interface. */307 /* Allow to change address in HW if we create first interface. */
308 if (!dev->vif_mask &&308 if (!dev->mphy.vif_mask &&
309 (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) ||309 (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) ||
310 memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1)))310 memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1)))
311 mt76x02_mac_setaddr(dev, vif->addr);311 mt76x02_mac_setaddr(dev, vif->addr);
@@ -330,11 +330,11 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) · 18 unmodified lines
330 idx += 8;330 idx += 8;
331 331
332 /* vif is already set or idx is 8 for AP/Mesh/... */332 /* 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) ||
334 (vif->type != NL80211_IFTYPE_STATION && idx > 7))334 (vif->type != NL80211_IFTYPE_STATION && idx > 7))
335 return -EBUSY;335 return -EBUSY;
336 336
337 dev->vif_mask |= BIT(idx);337 dev->mphy.vif_mask |= BIT(idx);
338 338
339 mt76x02_vif_init(dev, vif, idx);339 mt76x02_vif_init(dev, vif, idx);
340 return 0;340 return 0;
@@ -348,7 +348,7 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw, · 7 unmodified lines
348 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;348 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
349 349
350 mt76_txq_remove(&dev->mt76, vif->txq);350 mt76_txq_remove(&dev->mt76, vif->txq);
351 dev->vif_mask &= ~BIT(mvif->idx);351 dev->mphy.vif_mask &= ~BIT(mvif->idx);
352}352}
353EXPORT_SYMBOL_GPL(mt76x02_remove_interface);353EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
354 354
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
39extern const struct ieee80211_ops mt76x2_ops;39extern const struct ieee80211_ops mt76x2_ops;
40 40
41int mt76x2_register_device(struct mt76x02_dev *dev);41int mt76x2_register_device(struct mt76x02_dev *dev);
42int mt76x2_resume_device(struct mt76x02_dev *dev);
42 43
43void mt76x2_phy_power_on(struct mt76x02_dev *dev);44void mt76x2_phy_power_on(struct mt76x02_dev *dev);
44void mt76x2_stop_hardware(struct mt76x02_dev *dev);45void mt76x2_stop_hardware(struct mt76x02_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2/pci.c+63−7
@@ -9,7 +9,7 @@ · 8 unmodified lines
9 9
10#include "mt76x2.h"10#include "mt76x2.h"
11 11
12static const struct pci_device_id mt76pci_device_table[] = {12static const struct pci_device_id mt76x2e_device_table[] = {
13 { PCI_DEVICE(0x14c3, 0x7662) },13 { PCI_DEVICE(0x14c3, 0x7662) },
14 { PCI_DEVICE(0x14c3, 0x7612) },14 { PCI_DEVICE(0x14c3, 0x7612) },
15 { PCI_DEVICE(0x14c3, 0x7602) },15 { PCI_DEVICE(0x14c3, 0x7602) },
@@ -17,7 +17,7 @@ static const struct pci_device_id mt76pci_device_table[] = { · 1 unmodified line
17};17};
18 18
19static int19static int
20mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)20mt76x2e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
21{21{
22 static const struct mt76_driver_ops drv_ops = {22 static const struct mt76_driver_ops drv_ops = {
23 .txwi_size = sizeof(struct mt76x02_txwi),23 .txwi_size = sizeof(struct mt76x02_txwi),
@@ -93,7 +93,7 @@ error: · 69 unmodified lines
93}93}
94 94
95static void95static void
96mt76pci_remove(struct pci_dev *pdev)96mt76x2e_remove(struct pci_dev *pdev)
97{97{
98 struct mt76_dev *mdev = pci_get_drvdata(pdev);98 struct mt76_dev *mdev = pci_get_drvdata(pdev);
99 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);99 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
@@ -103,16 +103,72 @@ mt76pci_remove(struct pci_dev *pdev) · 3 unmodified lines
103 mt76_free_device(mdev);103 mt76_free_device(mdev);
104}104}
105 105
106MODULE_DEVICE_TABLE(pci, mt76pci_device_table);106static int __maybe_unused
107mt76x2e_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
127restore:
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
135static int __maybe_unused
136mt76x2e_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
158MODULE_DEVICE_TABLE(pci, mt76x2e_device_table);
107MODULE_FIRMWARE(MT7662_FIRMWARE);159MODULE_FIRMWARE(MT7662_FIRMWARE);
108MODULE_FIRMWARE(MT7662_ROM_PATCH);160MODULE_FIRMWARE(MT7662_ROM_PATCH);
109MODULE_LICENSE("Dual BSD/GPL");161MODULE_LICENSE("Dual BSD/GPL");
110 162
111static struct pci_driver mt76pci_driver = {163static struct pci_driver mt76pci_driver = {
112 .name = KBUILD_MODNAME,164 .name = KBUILD_MODNAME,
113 .id_table = mt76pci_device_table,165 .id_table = mt76x2e_device_table,
114 .probe = mt76pci_probe,166 .probe = mt76x2e_probe,
115 .remove = mt76pci_remove,167 .remove = mt76x2e_remove,
168#ifdef CONFIG_PM
169 .suspend = mt76x2e_suspend,
170 .resume = mt76x2e_resume,
171#endif /* CONFIG_PM */
116};172};
117 173
118module_pci_driver(mt76pci_driver);174module_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
217 mt76x2_power_on_rf(dev, 1);217 mt76x2_power_on_rf(dev, 1);
218}218}
219 219
220int 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
220static int mt76x2_init_hardware(struct mt76x02_dev *dev)237static int mt76x2_init_hardware(struct mt76x02_dev *dev)
221{238{
222 int ret;239 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
16 { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USBAC1200 - Alfa AWUS036ACM */16 { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USBAC1200 - Alfa AWUS036ACM */
17 { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */17 { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */
18 { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */18 { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */
19 { USB_DEVICE(0x0e8d, 0x7632) }, /* HC-M7662BU1 */
19 { USB_DEVICE(0x2c4e, 0x0103) }, /* Mercury UD13 */20 { USB_DEVICE(0x2c4e, 0x0103) }, /* Mercury UD13 */
20 { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */21 { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */
21 { USB_DEVICE(0x045e, 0x02e6) }, /* XBox One Wireless Adapter */22 { USB_DEVICE(0x045e, 0x02e6) }, /* XBox One Wireless Adapter */
@@ -74,8 +75,7 @@ static int mt76x2u_probe(struct usb_interface *intf, · 52 unmodified lines
74 return 0;75 return 0;
75 76
76err:77err:
77 ieee80211_free_hw(mt76_hw(dev));78 mt76_free_device(&dev->mt76);
78 mt76u_deinit(&dev->mt76);
79 usb_set_intfdata(intf, NULL);79 usb_set_intfdata(intf, NULL);
80 usb_put_dev(udev);80 usb_put_dev(udev);
81 81
@@ -91,9 +91,7 @@ static void mt76x2u_disconnect(struct usb_interface *intf) · 9 unmodified lines
91 set_bit(MT76_REMOVED, &dev->mphy.state);91 set_bit(MT76_REMOVED, &dev->mphy.state);
92 ieee80211_unregister_hw(hw);92 ieee80211_unregister_hw(hw);
93 mt76x2u_cleanup(dev);93 mt76x2u_cleanup(dev);
94 mt76u_deinit(&dev->mt76);94 mt76_free_device(&dev->mt76);
95
96 ieee80211_free_hw(hw);
97 usb_set_intfdata(intf, NULL);95 usb_set_intfdata(intf, NULL);
98 usb_put_dev(udev);96 usb_put_dev(udev);
99}97}
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
178 seq_printf(s, "Tx Beamformee feedback triggered counts: %ld\n",178 seq_printf(s, "Tx Beamformee feedback triggered counts: %ld\n",
179 FIELD_GET(MT_ETBF_TX_FB_TRI, cnt));179 FIELD_GET(MT_ETBF_TX_FB_TRI, cnt));
180 180
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);
182 cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy));189 cnt = mt76_rr(dev, MT_MIB_DR11(ext_phy));
183 seq_printf(s, "Tx single-user successful MPDU counts: %d\n", cnt);190 seq_printf(s, "Tx single-user successful MPDU counts: %d\n", cnt);
184 191
@@ -384,6 +391,7 @@ int mt7915_init_debugfs(struct mt7915_dev *dev) · 199 unmodified lines
384 return 0;391 return 0;
385}392}
386 393
394#ifdef CONFIG_MAC80211_DEBUGFS
387/** per-station debugfs **/395/** per-station debugfs **/
388 396
389/* usage: <tx mode> <ldpc> <stbc> <bw> <gi> <nss> <mcs> */397/* 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
461 debugfs_create_file("fixed_rate", 0600, dir, sta, &fops_fixed_rate);469 debugfs_create_file("fixed_rate", 0600, dir, sta, &fops_fixed_rate);
462 debugfs_create_file("stats", 0400, dir, sta, &fops_sta_stats);470 debugfs_create_file("stats", 0400, dir, sta, &fops_sta_stats);
463}471}
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
79 }79 }
80}80}
81 81
82static void
83mt7915_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
82static int mt7915_poll_tx(struct napi_struct *napi, int budget)91static int mt7915_poll_tx(struct napi_struct *napi, int budget)
83{92{
84 static const u8 queue_map[] = {
85 MT_TXQ_MCU,
86 MT_TXQ_MCU_WA,
87 MT_TXQ_BE
88 };
89 struct mt7915_dev *dev;93 struct mt7915_dev *dev;
90 int i;
91 94
92 dev = container_of(napi, struct mt7915_dev, mt76.tx_napi);95 dev = container_of(napi, struct mt7915_dev, mt76.tx_napi);
93 96
94 for (i = 0; i < ARRAY_SIZE(queue_map); i++)97 mt7915_tx_cleanup(dev);
95 mt76_queue_tx_cleanup(dev, queue_map[i], false);
96 98
97 if (napi_complete_done(napi, 0))99 if (napi_complete_done(napi, 0))
98 mt7915_irq_enable(dev, MT_INT_TX_DONE_ALL);100 mt7915_irq_enable(dev, MT_INT_TX_DONE_ALL);
99 101
100 for (i = 0; i < ARRAY_SIZE(queue_map); i++)102 mt7915_tx_cleanup(dev);
101 mt76_queue_tx_cleanup(dev, queue_map[i], false);
102 103
103 mt7915_mac_sta_poll(dev);104 mt7915_mac_sta_poll(dev);
104 105
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
417 417
418 he_cap_elem->mac_cap_info[0] =418 he_cap_elem->mac_cap_info[0] =
419 IEEE80211_HE_MAC_CAP0_HTC_HE;419 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;
425 he_cap_elem->mac_cap_info[3] =420 he_cap_elem->mac_cap_info[3] =
426 IEEE80211_HE_MAC_CAP3_OMI_CONTROL |421 IEEE80211_HE_MAC_CAP3_OMI_CONTROL |
427 IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_RESERVED;422 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
443 IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ |438 IEEE80211_HE_PHY_CAP2_STBC_TX_UNDER_80MHZ |
444 IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ;439 IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ;
445 440
446 /* TODO: OFDMA */
447
448 switch (i) {441 switch (i) {
449 case NL80211_IFTYPE_AP:442 case NL80211_IFTYPE_AP:
450 he_cap_elem->mac_cap_info[0] |=443 he_cap_elem->mac_cap_info[0] |=
451 IEEE80211_HE_MAC_CAP0_TWT_RES;444 IEEE80211_HE_MAC_CAP0_TWT_RES;
445 he_cap_elem->mac_cap_info[2] |=
446 IEEE80211_HE_MAC_CAP2_BSR;
452 he_cap_elem->mac_cap_info[4] |=447 he_cap_elem->mac_cap_info[4] |=
453 IEEE80211_HE_MAC_CAP4_BQR;448 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;
454 he_cap_elem->phy_cap_info[3] |=451 he_cap_elem->phy_cap_info[3] |=
455 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK |452 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_TX_QPSK |
456 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK;453 IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_QPSK;
457 he_cap_elem->phy_cap_info[6] |=454 he_cap_elem->phy_cap_info[6] |=
458 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT;455 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;
461 break;456 break;
462 case NL80211_IFTYPE_STATION:457 case NL80211_IFTYPE_STATION:
463 he_cap_elem->mac_cap_info[0] |=458 he_cap_elem->mac_cap_info[0] |=
464 IEEE80211_HE_MAC_CAP0_TWT_REQ;459 IEEE80211_HE_MAC_CAP0_TWT_REQ;
465 he_cap_elem->mac_cap_info[3] |=460 he_cap_elem->mac_cap_info[1] |=
466 IEEE80211_HE_MAC_CAP3_FLEX_TWT_SCHED;461 IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US;
467 462
468 if (band == NL80211_BAND_2GHZ)463 if (band == NL80211_BAND_2GHZ)
469 he_cap_elem->phy_cap_info[0] |=464 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
473 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G;468 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G;
474 469
475 he_cap_elem->phy_cap_info[1] |=470 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;
477 he_cap_elem->phy_cap_info[8] |=483 he_cap_elem->phy_cap_info[8] |=
478 IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G |484 IEEE80211_HE_PHY_CAP8_20MHZ_IN_40MHZ_HE_PPDU_IN_2G |
479 IEEE80211_HE_PHY_CAP8_20MHZ_IN_160MHZ_HE_PPDU |485 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;
481 he_cap_elem->phy_cap_info[9] |=488 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;
483 break;495 break;
484#ifdef CONFIG_MAC80211_MESH
485 case NL80211_IFTYPE_MESH_POINT:
486 break;
487#endif
488 }496 }
489 497
490 he_mcs->rx_mcs_80 = cpu_to_le16(mcs_map);498 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
178 178
179static void179static void
180mt7915_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,180mt7915_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
181 struct mt7915_rxv *rxv,181 struct ieee80211_radiotap_he *he,
182 struct ieee80211_radiotap_he *he)182 __le32 *rxv)
183{183{
184 u32 ru_h, ru_l;184 u32 ru_h, ru_l;
185 u8 ru, offs = 0;185 u8 ru, offs = 0;
186 186
187 ru_l = FIELD_GET(MT_PRXV_HE_RU_ALLOC_L, le32_to_cpu(rxv->v[0]));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->v[1]));188 ru_h = FIELD_GET(MT_PRXV_HE_RU_ALLOC_H, le32_to_cpu(rxv[1]));
189 ru = (u8)(ru_l | ru_h << 4);189 ru = (u8)(ru_l | ru_h << 4);
190 190
191 status->bw = RATE_INFO_BW_HE_RU;191 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
228static void228static void
229mt7915_mac_decode_he_radiotap(struct sk_buff *skb,229mt7915_mac_decode_he_radiotap(struct sk_buff *skb,
230 struct mt76_rx_status *status,230 struct mt76_rx_status *status,
231 struct mt7915_rxv *rxv)231 __le32 *rxv, u32 phy)
232{232{
233 /* TODO: struct ieee80211_radiotap_he_mu */233 /* TODO: struct ieee80211_radiotap_he_mu */
234 static const struct ieee80211_radiotap_he known = {234 static const struct ieee80211_radiotap_he known = {
@@ -245,48 +245,45 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, · 10 unmodified lines
245 HE_BITS(DATA2_TXOP_KNOWN),245 HE_BITS(DATA2_TXOP_KNOWN),
246 };246 };
247 struct ieee80211_radiotap_he *he = NULL;247 struct ieee80211_radiotap_he *he = NULL;
248 __le32 v2 = rxv->v[2];248 u32 ltf_size = le32_get_bits(rxv[2], MT_CRXV_HE_LTF_SIZE) + 1;
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;
252 249
253 he = skb_push(skb, sizeof(known));250 he = skb_push(skb, sizeof(known));
254 memcpy(he, &known, sizeof(known));251 memcpy(he, &known, sizeof(known));
255 252
256 he->data3 = HE_PREP(DATA3_BSS_COLOR, BSS_COLOR, v14) |253 he->data3 = HE_PREP(DATA3_BSS_COLOR, BSS_COLOR, rxv[14]) |
257 HE_PREP(DATA3_LDPC_XSYMSEG, LDPC_EXT_SYM, v2);254 HE_PREP(DATA3_LDPC_XSYMSEG, LDPC_EXT_SYM, rxv[2]);
258 he->data5 = HE_PREP(DATA5_PE_DISAMBIG, PE_DISAMBIG, v2) |255 he->data5 = HE_PREP(DATA5_PE_DISAMBIG, PE_DISAMBIG, rxv[2]) |
259 le16_encode_bits(ltf_size,256 le16_encode_bits(ltf_size,
260 IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE);257 IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE);
261 he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, v14) |258 he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) |
262 HE_PREP(DATA6_DOPPLER, DOPPLER, v14);259 HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]);
263 260
264 switch (rxv->phy) {261 switch (phy) {
265 case MT_PHY_TYPE_HE_SU:262 case MT_PHY_TYPE_HE_SU:
266 he->data1 |= HE_BITS(DATA1_FORMAT_SU) |263 he->data1 |= HE_BITS(DATA1_FORMAT_SU) |
267 HE_BITS(DATA1_UL_DL_KNOWN) |264 HE_BITS(DATA1_UL_DL_KNOWN) |
268 HE_BITS(DATA1_BEAM_CHANGE_KNOWN) |265 HE_BITS(DATA1_BEAM_CHANGE_KNOWN) |
269 HE_BITS(DATA1_SPTL_REUSE_KNOWN);266 HE_BITS(DATA1_SPTL_REUSE_KNOWN);
270 267
271 he->data3 |= HE_PREP(DATA3_BEAM_CHANGE, BEAM_CHNG, v14) |268 he->data3 |= HE_PREP(DATA3_BEAM_CHANGE, BEAM_CHNG, rxv[14]) |
272 HE_PREP(DATA3_UL_DL, UPLINK, v2);269 HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
273 he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, v11);270 he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, rxv[11]);
274 break;271 break;
275 case MT_PHY_TYPE_HE_EXT_SU:272 case MT_PHY_TYPE_HE_EXT_SU:
276 he->data1 |= HE_BITS(DATA1_FORMAT_EXT_SU) |273 he->data1 |= HE_BITS(DATA1_FORMAT_EXT_SU) |
277 HE_BITS(DATA1_UL_DL_KNOWN);274 HE_BITS(DATA1_UL_DL_KNOWN);
278 275
279 he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, v2);276 he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
280 break;277 break;
281 case MT_PHY_TYPE_HE_MU:278 case MT_PHY_TYPE_HE_MU:
282 he->data1 |= HE_BITS(DATA1_FORMAT_MU) |279 he->data1 |= HE_BITS(DATA1_FORMAT_MU) |
283 HE_BITS(DATA1_UL_DL_KNOWN) |280 HE_BITS(DATA1_UL_DL_KNOWN) |
284 HE_BITS(DATA1_SPTL_REUSE_KNOWN);281 HE_BITS(DATA1_SPTL_REUSE_KNOWN);
285 282
286 he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, v2);283 he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
287 he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, v11);284 he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, rxv[11]);
288 285
289 mt7915_mac_decode_he_radiotap_ru(status, rxv, he);286 mt7915_mac_decode_he_radiotap_ru(status, he, rxv);
290 break;287 break;
291 case MT_PHY_TYPE_HE_TB:288 case MT_PHY_TYPE_HE_TB:
292 he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) |289 he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) |
@@ -295,12 +292,12 @@ mt7915_mac_decode_he_radiotap(struct sk_buff *skb, · 2 unmodified lines
295 HE_BITS(DATA1_SPTL_REUSE3_KNOWN) |292 HE_BITS(DATA1_SPTL_REUSE3_KNOWN) |
296 HE_BITS(DATA1_SPTL_REUSE4_KNOWN);293 HE_BITS(DATA1_SPTL_REUSE4_KNOWN);
297 294
298 he->data4 |= HE_PREP(DATA4_TB_SPTL_REUSE1, SR_MASK, v11) |295 he->data4 |= HE_PREP(DATA4_TB_SPTL_REUSE1, SR_MASK, rxv[11]) |
299 HE_PREP(DATA4_TB_SPTL_REUSE2, SR1_MASK, v11) |296 HE_PREP(DATA4_TB_SPTL_REUSE2, SR1_MASK, rxv[11]) |
300 HE_PREP(DATA4_TB_SPTL_REUSE3, SR2_MASK, v11) |297 HE_PREP(DATA4_TB_SPTL_REUSE3, SR2_MASK, rxv[11]) |
301 HE_PREP(DATA4_TB_SPTL_REUSE4, SR3_MASK, v11);298 HE_PREP(DATA4_TB_SPTL_REUSE4, SR3_MASK, rxv[11]);
302 299
303 mt7915_mac_decode_he_radiotap_ru(status, rxv, he);300 mt7915_mac_decode_he_radiotap_ru(status, he, rxv);
304 break;301 break;
305 default:302 default:
306 break;303 break;
@@ -314,8 +311,9 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 7 unmodified lines
314 struct mt7915_phy *phy = &dev->phy;311 struct mt7915_phy *phy = &dev->phy;
315 struct ieee80211_supported_band *sband;312 struct ieee80211_supported_band *sband;
316 struct ieee80211_hdr *hdr;313 struct ieee80211_hdr *hdr;
317 struct mt7915_rxv rxv = {};
318 __le32 *rxd = (__le32 *)skb->data;314 __le32 *rxd = (__le32 *)skb->data;
315 __le32 *rxv = NULL;
316 u32 mode = 0;
319 u32 rxd1 = le32_to_cpu(rxd[1]);317 u32 rxd1 = le32_to_cpu(rxd[1]);
320 u32 rxd2 = le32_to_cpu(rxd[2]);318 u32 rxd2 = le32_to_cpu(rxd[2]);
321 u32 rxd3 = le32_to_cpu(rxd[3]);319 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
427 if (rxd1 & MT_RXD1_NORMAL_GROUP_3) {425 if (rxd1 & MT_RXD1_NORMAL_GROUP_3) {
428 u32 v0, v1, v2;426 u32 v0, v1, v2;
429 427
430 memcpy(rxv.v, rxd, sizeof(rxv.v));428 rxv = rxd;
431
432 rxd += 2;429 rxd += 2;
433 if ((u8 *)rxd - skb->data >= skb->len)430 if ((u8 *)rxd - skb->data >= skb->len)
434 return -EINVAL;431 return -EINVAL;
435 432
436 v0 = le32_to_cpu(rxv.v[0]);433 v0 = le32_to_cpu(rxv[0]);
437 v1 = le32_to_cpu(rxv.v[1]);434 v1 = le32_to_cpu(rxv[1]);
438 v2 = le32_to_cpu(rxv.v[2]);435 v2 = le32_to_cpu(rxv[2]);
439 436
440 if (v0 & MT_PRXV_HT_AD_CODE)437 if (v0 & MT_PRXV_HT_AD_CODE)
441 status->enc_flags |= RX_ENC_FLAG_LDPC;438 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
466 return -EINVAL;463 return -EINVAL;
467 464
468 idx = i = FIELD_GET(MT_PRXV_TX_RATE, v0);465 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);
470 467
471 switch (rxv.phy) {468 switch (mode) {
472 case MT_PHY_TYPE_CCK:469 case MT_PHY_TYPE_CCK:
473 cck = true;470 cck = true;
474 /* fall through */471 /* fall through */
@@ -503,8 +500,7 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 28 unmodified lines
503 if (gi <= NL80211_RATE_INFO_HE_GI_3_2)500 if (gi <= NL80211_RATE_INFO_HE_GI_3_2)
504 status->he_gi = gi;501 status->he_gi = gi;
505 502
506 if (idx & MT_PRXV_TX_DCM)503 status->he_dcm = !!(idx & MT_PRXV_TX_DCM);
507 status->he_dcm = true;
508 break;504 break;
509 default:505 default:
510 return -EINVAL;506 return -EINVAL;
@@ -515,7 +511,7 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 4 unmodified lines
515 case IEEE80211_STA_RX_BW_20:511 case IEEE80211_STA_RX_BW_20:
516 break;512 break;
517 case IEEE80211_STA_RX_BW_40:513 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 &&
519 (idx & MT_PRXV_TX_ER_SU_106T)) {515 (idx & MT_PRXV_TX_ER_SU_106T)) {
520 status->bw = RATE_INFO_BW_HE_RU;516 status->bw = RATE_INFO_BW_HE_RU;
521 status->he_ru =517 status->he_ru =
@@ -535,7 +531,7 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 13 unmodified lines
535 }531 }
536 532
537 status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc;533 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)
539 status->enc_flags |= RX_ENC_FLAG_SHORT_GI;535 status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
540 }536 }
541 }537 }
@@ -548,8 +544,8 @@ int mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) · 6 unmodified lines
548 mt76_insert_ccmp_hdr(skb, key_id);544 mt76_insert_ccmp_hdr(skb, key_id);
549 }545 }
550 546
551 if (status->flag & RX_FLAG_RADIOTAP_HE)547 if (rxv && status->flag & RX_FLAG_RADIOTAP_HE)
552 mt7915_mac_decode_he_radiotap(skb, status, &rxv);548 mt7915_mac_decode_he_radiotap(skb, status, rxv, mode);
553 549
554 hdr = mt76_skb_get_hdr(skb);550 hdr = mt76_skb_get_hdr(skb);
555 if (!status->wcid || !ieee80211_is_data_qos(hdr->frame_control))551 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
591 fc_type = (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) >> 2;587 fc_type = (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) >> 2;
592 fc_stype = (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) >> 4;588 fc_stype = (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) >> 4;
593 589
594 if (ieee80211_is_data(fc) || ieee80211_is_bufferable_mmpdu(fc)) {590 if (beacon) {
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;
600 p_fmt = MT_TX_TYPE_FW;591 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;
602 q_idx = MT_LMAC_ALTX0;595 q_idx = MT_LMAC_ALTX0;
596 } else {
603 p_fmt = MT_TX_TYPE_CT;597 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));
604 }600 }
605 601
606 val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + MT_TXD_SIZE) |602 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
616 FIELD_PREP(MT_TXD1_TID,612 FIELD_PREP(MT_TXD1_TID,
617 skb->priority & IEEE80211_QOS_CTL_TID_MASK) |613 skb->priority & IEEE80211_QOS_CTL_TID_MASK) |
618 FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);614 FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
615
619 if (ext_phy && q_idx >= MT_LMAC_ALTX0 && q_idx <= MT_LMAC_BCN0)616 if (ext_phy && q_idx >= MT_LMAC_ALTX0 && q_idx <= MT_LMAC_BCN0)
620 val |= MT_TXD1_TGID;617 val |= MT_TXD1_TGID;
621 618
drivers/net/wireless/mediatek/mt76/mt7915/mac.h+0−17
@@ -128,13 +128,6 @@ enum rx_pkt_type { · 127 unmodified lines
128#define MT_CRXV_HE_BEAM_CHNG BIT(13)128#define MT_CRXV_HE_BEAM_CHNG BIT(13)
129#define MT_CRXV_HE_DOPPLER BIT(16)129#define MT_CRXV_HE_DOPPLER BIT(16)
130 130
131struct mt7915_rxv {
132 u32 phy;
133
134 /* P-RXV: bit 0~1, C-RXV: bit 2~19 */
135 __le32 v[20];
136};
137
138enum tx_header_format {131enum tx_header_format {
139 MT_HDR_FORMAT_802_3,132 MT_HDR_FORMAT_802_3,
140 MT_HDR_FORMAT_CMD,133 MT_HDR_FORMAT_CMD,
@@ -149,16 +142,6 @@ enum tx_pkt_type { · 8 unmodified lines
149 MT_TX_TYPE_FW,142 MT_TX_TYPE_FW,
150};143};
151 144
152enum 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
162enum tx_port_idx {145enum tx_port_idx {
163 MT_TX_PORT_IDX_LMAC,146 MT_TX_PORT_IDX_LMAC,
164 MT_TX_PORT_IDX_MCU147 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
125 125
126 mutex_lock(&dev->mt76.mutex);126 mutex_lock(&dev->mt76.mutex);
127 127
128 mvif->idx = ffs(~phy->vif_mask) - 1;128 mvif->idx = ffs(~phy->mt76->vif_mask) - 1;
129 if (mvif->idx >= MT7915_MAX_INTERFACES) {129 if (mvif->idx >= MT7915_MAX_INTERFACES) {
130 ret = -ENOSPC;130 ret = -ENOSPC;
131 goto out;131 goto out;
@@ -150,7 +150,7 @@ static int mt7915_add_interface(struct ieee80211_hw *hw, · 18 unmodified lines
150 if (ret)150 if (ret)
151 goto out;151 goto out;
152 152
153 phy->vif_mask |= BIT(mvif->idx);153 phy->mt76->vif_mask |= BIT(mvif->idx);
154 phy->omac_mask |= BIT(mvif->omac_idx);154 phy->omac_mask |= BIT(mvif->omac_idx);
155 155
156 idx = MT7915_WTBL_RESERVED - mvif->idx;156 idx = MT7915_WTBL_RESERVED - mvif->idx;
@@ -194,7 +194,7 @@ static void mt7915_remove_interface(struct ieee80211_hw *hw, · 37 unmodified lines
194 mt76_txq_remove(&dev->mt76, vif->txq);194 mt76_txq_remove(&dev->mt76, vif->txq);
195 195
196 mutex_lock(&dev->mt76.mutex);196 mutex_lock(&dev->mt76.mutex);
197 phy->vif_mask &= ~BIT(mvif->idx);197 phy->mt76->vif_mask &= ~BIT(mvif->idx);
198 phy->omac_mask &= ~BIT(mvif->omac_idx);198 phy->omac_mask &= ~BIT(mvif->omac_idx);
199 mutex_unlock(&dev->mt76.mutex);199 mutex_unlock(&dev->mt76.mutex);
200 200
@@ -350,13 +350,12 @@ static int · 149 unmodified lines
350mt7915_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,350mt7915_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
351 const struct ieee80211_tx_queue_params *params)351 const struct ieee80211_tx_queue_params *params)
352{352{
353 struct mt7915_dev *dev = mt7915_hw_dev(hw);
353 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;354 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
354 355
355 /* no need to update right away, we'll get BSS_CHANGED_QOS */356 /* no need to update right away, we'll get BSS_CHANGED_QOS */
356 mvif->wmm[queue].cw_min = params->cw_min;357 queue = mt7915_lmac_mapping(dev, queue);
357 mvif->wmm[queue].cw_max = params->cw_max;358 mvif->queue_params[queue] = *params;
358 mvif->wmm[queue].aifs = params->aifs;
359 mvif->wmm[queue].txop = params->txop;
360 359
361 return 0;360 return 0;
362}361}
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
312 struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data;312 struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data;
313 int ret = 0;313 int ret = 0;
314 314
315 if (seq != rxd->seq)315 if (seq != rxd->seq) {
316 return -EAGAIN;316 ret = -EAGAIN;
317 goto out;
318 }
317 319
318 switch (cmd) {320 switch (cmd) {
319 case -MCU_CMD_PATCH_SEM_CONTROL:321 case -MCU_CMD_PATCH_SEM_CONTROL:
@@ -330,6 +332,7 @@ mt7915_mcu_parse_response(struct mt7915_dev *dev, int cmd, · 10 unmodified lines
330 default:332 default:
331 break;333 break;
332 }334 }
335out:
333 dev_kfree_skb(skb);336 dev_kfree_skb(skb);
334 337
335 return ret;338 return ret;
@@ -505,15 +508,22 @@ static void · 169 unmodified lines
505mt7915_mcu_tx_rate_report(struct mt7915_dev *dev, struct sk_buff *skb)508mt7915_mcu_tx_rate_report(struct mt7915_dev *dev, struct sk_buff *skb)
506{509{
507 struct mt7915_mcu_ra_info *ra = (struct mt7915_mcu_ra_info *)skb->data;510 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;
513 struct rate_info rate = {}, prob_rate = {};511 struct rate_info rate = {}, prob_rate = {};
512 u16 probe = le16_to_cpu(ra->prob_up_rate);
514 u16 attempts = le16_to_cpu(ra->attempts);513 u16 attempts = le16_to_cpu(ra->attempts);
515 u16 curr = le16_to_cpu(ra->curr_rate);514 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;
517 527
518 if (msta->wcid.ext_phy && dev->mt76.phy2)528 if (msta->wcid.ext_phy && dev->mt76.phy2)
519 mphy = dev->mt76.phy2;529 mphy = dev->mt76.phy2;
@@ -1166,19 +1176,31 @@ mt7915_mcu_sta_ba(struct mt7915_dev *dev, · 646 unmodified lines
1166 struct wtbl_req_hdr *wtbl_hdr;1176 struct wtbl_req_hdr *wtbl_hdr;
1167 struct tlv *sta_wtbl;1177 struct tlv *sta_wtbl;
1168 struct sk_buff *skb;1178 struct sk_buff *skb;
1179 int ret;
1169 1180
1170 skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta,1181 skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta,
1171 MT7915_STA_UPDATE_MAX_SIZE);1182 MT7915_STA_UPDATE_MAX_SIZE);
1172 if (IS_ERR(skb))1183 if (IS_ERR(skb))
1173 return PTR_ERR(skb);1184 return PTR_ERR(skb);
1174 1185
1175 mt7915_mcu_sta_ba_tlv(skb, params, enable, tx);
1176 sta_wtbl = mt7915_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv));1186 sta_wtbl = mt7915_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv));
1177 1187
1178 wtbl_hdr = mt7915_mcu_alloc_wtbl_req(dev, msta, WTBL_SET, sta_wtbl,1188 wtbl_hdr = mt7915_mcu_alloc_wtbl_req(dev, msta, WTBL_SET, sta_wtbl,
1179 &skb);1189 &skb);
1180 mt7915_mcu_wtbl_ba_tlv(skb, params, enable, tx, sta_wtbl, wtbl_hdr);1190 mt7915_mcu_wtbl_ba_tlv(skb, params, enable, tx, sta_wtbl, wtbl_hdr);
1181 1191
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
1182 return __mt76_mcu_skb_send_msg(&dev->mt76, skb,1204 return __mt76_mcu_skb_send_msg(&dev->mt76, skb,
1183 MCU_EXT_CMD_STA_REC_UPDATE, true);1205 MCU_EXT_CMD_STA_REC_UPDATE, true);
1184}1206}
@@ -1466,16 +1488,39 @@ mt7915_mcu_sta_muru_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) · 281 unmodified lines
1466 HE_PHY(CAP2_UL_MU_PARTIAL_MU_MIMO, elem->phy_cap_info[2]);1488 HE_PHY(CAP2_UL_MU_PARTIAL_MU_MIMO, elem->phy_cap_info[2]);
1467}1489}
1468 1490
1491static int
1492mt7915_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
1469static void1514static void
1470mt7915_mcu_sta_tlv(struct mt7915_dev *dev, struct sk_buff *skb,1515mt7915_mcu_sta_tlv(struct mt7915_dev *dev, struct sk_buff *skb,
1471 struct ieee80211_sta *sta)1516 struct ieee80211_sta *sta)
1472{1517{
1473 struct tlv *tlv;1518 struct tlv *tlv;
1474 1519
1520 /* starec ht */
1475 if (sta->ht_cap.ht_supported) {1521 if (sta->ht_cap.ht_supported) {
1476 struct sta_rec_ht *ht;1522 struct sta_rec_ht *ht;
1477 1523
1478 /* starec ht */
1479 tlv = mt7915_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));1524 tlv = mt7915_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht));
1480 ht = (struct sta_rec_ht *)tlv;1525 ht = (struct sta_rec_ht *)tlv;
1481 ht->ht_cap = cpu_to_le16(sta->ht_cap.cap);1526 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
1495 /* starec he */1540 /* starec he */
1496 if (sta->he_cap.has_he)1541 if (sta->he_cap.has_he)
1497 mt7915_mcu_sta_he_tlv(skb, sta);1542 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);
1502}1543}
1503 1544
1504static void1545static void
@@ -2064,6 +2105,32 @@ int mt7915_mcu_add_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif, · 559 unmodified lines
2064 MCU_EXT_CMD_STA_REC_UPDATE, true);2105 MCU_EXT_CMD_STA_REC_UPDATE, true);
2065}2106}
2066 2107
2108static int
2109mt7915_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
2067int mt7915_mcu_add_sta_adv(struct mt7915_dev *dev, struct ieee80211_vif *vif,2134int mt7915_mcu_add_sta_adv(struct mt7915_dev *dev, struct ieee80211_vif *vif,
2068 struct ieee80211_sta *sta, bool enable)2135 struct ieee80211_sta *sta, bool enable)
2069{2136{
@@ -2073,10 +2140,18 @@ int mt7915_mcu_add_sta_adv(struct mt7915_dev *dev, struct ieee80211_vif *vif, · 3 unmodified lines
2073 return 0;2140 return 0;
2074 2141
2075 /* must keep the order */2142 /* must keep the order */
2143 ret = mt7915_mcu_add_group(dev, vif, sta);
2144 if (ret)
2145 return ret;
2146
2076 ret = mt7915_mcu_add_txbf(dev, vif, sta, enable);2147 ret = mt7915_mcu_add_txbf(dev, vif, sta, enable);
2077 if (ret)2148 if (ret)
2078 return ret;2149 return ret;
2079 2150
2151 ret = mt7915_mcu_add_mu(dev, vif, sta);
2152 if (ret)
2153 return ret;
2154
2080 if (enable)2155 if (enable)
2081 return mt7915_mcu_add_rate_ctrl(dev, vif, sta);2156 return mt7915_mcu_add_rate_ctrl(dev, vif, sta);
2082 2157
@@ -2823,23 +2898,23 @@ int mt7915_mcu_set_tx(struct mt7915_dev *dev, struct ieee80211_vif *vif) · 740 unmodified lines
2823 int ac;2898 int ac;
2824 2899
2825 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {2900 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
2901 struct ieee80211_tx_queue_params *q = &mvif->queue_params[ac];
2826 struct edca *e = &req.edca[ac];2902 struct edca *e = &req.edca[ac];
2827 2903
2828 e->queue = ac + mvif->wmm_idx * MT7915_MAX_WMM_SETS;2904 e->queue = ac + mvif->wmm_idx * MT7915_MAX_WMM_SETS;
2829 e->aifs = mvif->wmm[ac].aifs;2905 e->aifs = q->aifs;
2830 e->txop = cpu_to_le16(mvif->wmm[ac].txop);2906 e->txop = cpu_to_le16(q->txop);
2831 2907
2832 if (mvif->wmm[ac].cw_min)2908 if (q->cw_min)
2833 e->cw_min = fls(mvif->wmm[ac].cw_max);2909 e->cw_min = fls(q->cw_min);
2834 else2910 else
2835 e->cw_min = 5;2911 e->cw_min = 5;
2836 2912
2837 if (mvif->wmm[ac].cw_max)2913 if (q->cw_max)
2838 e->cw_max = cpu_to_le16(fls(mvif->wmm[ac].cw_max));2914 e->cw_max = cpu_to_le16(fls(q->cw_max));
2839 else2915 else
2840 e->cw_max = cpu_to_le16(10);2916 e->cw_max = cpu_to_le16(10);
2841 }2917 }
2842
2843 return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,2918 return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
2844 &req, sizeof(req), true);2919 &req, sizeof(req), true);
2845}2920}
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h+3−3
@@ -201,6 +201,7 @@ enum { · 200 unmodified lines
201 MCU_EXT_CMD_EDCA_UPDATE = 0x27,201 MCU_EXT_CMD_EDCA_UPDATE = 0x27,
202 MCU_EXT_CMD_DEV_INFO_UPDATE = 0x2A,202 MCU_EXT_CMD_DEV_INFO_UPDATE = 0x2A,
203 MCU_EXT_CMD_THERMAL_CTRL = 0x2c,203 MCU_EXT_CMD_THERMAL_CTRL = 0x2c,
204 MCU_EXT_CMD_SET_DRR_CTRL = 0x36,
204 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,205 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
205 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,206 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
206 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,207 MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
@@ -653,7 +654,7 @@ struct sta_rec_muru { · 446 unmodified lines
653 bool ofdma_ul_en;654 bool ofdma_ul_en;
654 bool mimo_dl_en;655 bool mimo_dl_en;
655 bool mimo_ul_en;656 bool mimo_ul_en;
656 bool rsv[4];657 u8 rsv[4];
657 } cfg;658 } cfg;
658 659
659 struct {660 struct {
@@ -664,7 +665,7 @@ struct sta_rec_muru { · 4 unmodified lines
664 bool lt16_sigb;665 bool lt16_sigb;
665 bool rx_su_comp_sigb;666 bool rx_su_comp_sigb;
666 bool rx_su_non_comp_sigb;667 bool rx_su_non_comp_sigb;
667 bool rsv;668 u8 rsv;
668 } ofdma_dl;669 } ofdma_dl;
669 670
670 struct {671 struct {
@@ -951,7 +952,6 @@ enum { · 280 unmodified lines
951 sizeof(struct sta_rec_ba) + \952 sizeof(struct sta_rec_ba) + \
952 sizeof(struct sta_rec_vht) + \953 sizeof(struct sta_rec_vht) + \
953 sizeof(struct tlv) + \954 sizeof(struct tlv) + \
954 sizeof(struct sta_rec_muru) + \
955 MT7915_WTBL_UPDATE_MAX_SIZE)955 MT7915_WTBL_UPDATE_MAX_SIZE)
956 956
957#define MT7915_WTBL_UPDATE_BA_SIZE (sizeof(struct wtbl_req_hdr) + \957#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
99 u8 band_idx;99 u8 band_idx;
100 u8 wmm_idx;100 u8 wmm_idx;
101 101
102 struct {
103 u16 cw_min;
104 u16 cw_max;
105 u16 txop;
106 u8 aifs;
107 } wmm[IEEE80211_NUM_ACS];
108
109 struct mt7915_sta sta;102 struct mt7915_sta sta;
110 struct mt7915_dev *dev;103 struct mt7915_dev *dev;
104
105 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS];
111};106};
112 107
113struct mib_stats {108struct mib_stats {
@@ -125,7 +120,6 @@ struct mt7915_phy { · 11 unmodified lines
125 struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES];120 struct ieee80211_sband_iftype_data iftype[2][NUM_NL80211_IFTYPES];
126 121
127 u32 rxfilter;122 u32 rxfilter;
128 u32 vif_mask;
129 u32 omac_mask;123 u32 omac_mask;
130 124
131 u16 noise;125 u16 noise;
@@ -199,6 +193,16 @@ enum { · 67 unmodified lines
199 EXT_BSSID_END193 EXT_BSSID_END
200};194};
201 195
196enum {
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
202enum {206enum {
203 MT_RX_SEL0,207 MT_RX_SEL0,
204 MT_RX_SEL1,208 MT_RX_SEL1,
@@ -254,6 +258,21 @@ mt7915_ext_phy(struct mt7915_dev *dev) · 49 unmodified lines
254 return phy->priv;258 return phy->priv;
255}259}
256 260
261static 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
257static inline void276static inline void
258mt7915_set_aggr_state(struct mt7915_sta *msta, u8 tid,277mt7915_set_aggr_state(struct mt7915_sta *msta, u8 tid,
259 enum mt7915_ampdu_state state)278 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
103 static const struct mt76_driver_ops drv_ops = {103 static const struct mt76_driver_ops drv_ops = {
104 /* txwi_size = txd size + txp size */104 /* txwi_size = txd size + txp size */
105 .txwi_size = MT_TXD_SIZE + sizeof(struct mt7915_txp),105 .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,
107 .survey_flags = SURVEY_INFO_TIME_TX |107 .survey_flags = SURVEY_INFO_TIME_TX |
108 SURVEY_INFO_TIME_RX |108 SURVEY_INFO_TIME_RX |
109 SURVEY_INFO_TIME_BSS_RX,109 SURVEY_INFO_TIME_BSS_RX,
drivers/net/wireless/mediatek/mt76/mt7915/regs.h+5−0
@@ -117,11 +117,16 @@ · 116 unmodified lines
117#define MT_MIB_SDR16(_band) MT_WF_MIB(_band, 0x048)117#define MT_MIB_SDR16(_band) MT_WF_MIB(_band, 0x048)
118#define MT_MIB_SDR16_BUSY_MASK GENMASK(23, 0)118#define MT_MIB_SDR16_BUSY_MASK GENMASK(23, 0)
119 119
120#define MT_MIB_SDR34(_band) MT_WF_MIB(_band, 0x090)
121#define MT_MIB_MU_BF_TX_CNT GENMASK(15, 0)
122
120#define MT_MIB_SDR36(_band) MT_WF_MIB(_band, 0x098)123#define MT_MIB_SDR36(_band) MT_WF_MIB(_band, 0x098)
121#define MT_MIB_SDR36_TXTIME_MASK GENMASK(23, 0)124#define MT_MIB_SDR36_TXTIME_MASK GENMASK(23, 0)
122#define MT_MIB_SDR37(_band) MT_WF_MIB(_band, 0x09c)125#define MT_MIB_SDR37(_band) MT_WF_MIB(_band, 0x09c)
123#define MT_MIB_SDR37_RXTIME_MASK GENMASK(23, 0)126#define MT_MIB_SDR37_RXTIME_MASK GENMASK(23, 0)
124 127
128#define MT_MIB_DR8(_band) MT_WF_MIB(_band, 0x0c0)
129#define MT_MIB_DR9(_band) MT_WF_MIB(_band, 0x0c4)
125#define MT_MIB_DR11(_band) MT_WF_MIB(_band, 0x0cc)130#define MT_MIB_DR11(_band) MT_WF_MIB(_band, 0x0cc)
126 131
127#define MT_MIB_MB_SDR0(_band, n) MT_WF_MIB(_band, 0x100 + ((n) << 4))132#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
3 * Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org>3 * Copyright (C) 2019 Lorenzo Bianconi <lorenzo@kernel.org>
4 */4 */
5 5
6#include "mt76.h"
6#include <linux/pci.h>7#include <linux/pci.h>
7 8
8void mt76_pci_disable_aspm(struct pci_dev *pdev)9void 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
20static int
21mt76s_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
39static 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
67void 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}
76EXPORT_SYMBOL_GPL(mt76s_stop_txrx);
77
78int 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}
88EXPORT_SYMBOL_GPL(mt76s_alloc_queues);
89
90static struct mt76_queue_entry *
91mt76s_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
106static int
107mt76s_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
132static 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);
183out:
184 return n_dequeued;
185}
186
187static 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
212static int
213mt76s_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
240static int
241mt76s_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
260out:
261 spin_unlock_bh(&q->lock);
262
263 return ret;
264}
265
266static 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
273static 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
279static 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
316void 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}
344EXPORT_SYMBOL_GPL(mt76s_deinit);
345
346int 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}
364EXPORT_SYMBOL_GPL(mt76s_init);
365
366MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
367MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
368MODULE_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
5static 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
20void 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
53static int
54mt76_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
155static void
156mt76_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
166static void
167mt76_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
183static inline void
184mt76_testmode_param_set(struct mt76_testmode_data *td, u16 idx)
185{
186 td->param_set[idx / 32] |= BIT(idx % 32);
187}
188
189static inline bool
190mt76_testmode_param_present(struct mt76_testmode_data *td, u16 idx)
191{
192 return td->param_set[idx / 32] & BIT(idx % 32);
193}
194
195static void
196mt76_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
209static 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
243int 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}
268EXPORT_SYMBOL(mt76_testmode_set_state);
269
270static int
271mt76_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
286int 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
383out:
384 mutex_unlock(&dev->mutex);
385
386 return err;
387}
388EXPORT_SYMBOL(mt76_testmode_cmd);
389
390static int
391mt76_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
418int 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
492out:
493 mutex_unlock(&dev->mutex);
494
495 return err;
496}
497EXPORT_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 */
37enum 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 */
79enum 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 */
105enum 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 */
126enum 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 */
145enum 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
236 struct ieee80211_hw *hw;236 struct ieee80211_hw *hw;
237 struct sk_buff_head list;237 struct sk_buff_head list;
238 238
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
239 if (!skb->prev) {247 if (!skb->prev) {
240 hw = mt76_tx_status_get_hw(dev, skb);248 hw = mt76_tx_status_get_hw(dev, skb);
241 ieee80211_free_txskb(hw, skb);249 ieee80211_free_txskb(hw, skb);
@@ -259,6 +267,11 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta, · 17 unmodified lines
259 int qid = skb_get_queue_mapping(skb);267 int qid = skb_get_queue_mapping(skb);
260 bool ext_phy = phy != &dev->phy;268 bool ext_phy = phy != &dev->phy;
261 269
270 if (mt76_testmode_enabled(dev)) {
271 ieee80211_free_txskb(phy->hw, skb);
272 return;
273 }
274
262 if (WARN_ON(qid >= MT_TXQ_PSD)) {275 if (WARN_ON(qid >= MT_TXQ_PSD)) {
263 qid = MT_TXQ_BE;276 qid = MT_TXQ_BE;
264 skb_set_queue_mapping(skb, qid);277 skb_set_queue_mapping(skb, qid);
@@ -579,6 +592,11 @@ void mt76_tx_tasklet(unsigned long data) · 314 unmodified lines
579 mt76_txq_schedule_all(&dev->phy);592 mt76_txq_schedule_all(&dev->phy);
580 if (dev->phy2)593 if (dev->phy2)
581 mt76_txq_schedule_all(dev->phy2);594 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
582}600}
583 601
584void mt76_stop_tx_queues(struct mt76_dev *dev, struct ieee80211_sta *sta,602void 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
659 return wmm_queue_map[ac];677 return wmm_queue_map[ac];
660}678}
661EXPORT_SYMBOL_GPL(mt76_ac_to_hwq);679EXPORT_SYMBOL_GPL(mt76_ac_to_hwq);
680
681int 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}
708EXPORT_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
672static void mt76u_rx_tasklet(unsigned long data)672static void mt76u_rx_tasklet(unsigned long data)
673{673{
674 struct mt76_dev *dev = (struct mt76_dev *)data;674 struct mt76_dev *dev = (struct mt76_dev *)data;
675 struct mt76_queue *q;
676 int i;675 int i;
677 676
678 rcu_read_lock();677 rcu_read_lock();
679 for (i = 0; i < __MT_RXQ_MAX; i++) {678 mt76_for_each_q_rx(dev, i)
680 q = &dev->q_rx[i];679 mt76u_process_rx_queue(dev, &dev->q_rx[i]);
681 if (!q->ndesc)
682 continue;
683
684 mt76u_process_rx_queue(dev, q);
685 }
686 rcu_read_unlock();680 rcu_read_unlock();
687}681}
688 682
@@ -756,27 +750,19 @@ mt76u_free_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) · 67 unmodified lines
756 750
757static void mt76u_free_rx(struct mt76_dev *dev)751static void mt76u_free_rx(struct mt76_dev *dev)
758{752{
759 struct mt76_queue *q;
760 int i;753 int i;
761 754
762 for (i = 0; i < __MT_RXQ_MAX; i++) {755 mt76_for_each_q_rx(dev, i)
763 q = &dev->q_rx[i];756 mt76u_free_rx_queue(dev, &dev->q_rx[i]);
764 if (!q->ndesc)
765 continue;
766
767 mt76u_free_rx_queue(dev, q);
768 }
769}757}
770 758
771void mt76u_stop_rx(struct mt76_dev *dev)759void mt76u_stop_rx(struct mt76_dev *dev)
772{760{
773 struct mt76_queue *q;761 int i;
774 int i, j;
775 762
776 for (i = 0; i < __MT_RXQ_MAX; i++) {763 mt76_for_each_q_rx(dev, i) {
777 q = &dev->q_rx[i];764 struct mt76_queue *q = &dev->q_rx[i];
778 if (!q->ndesc)765 int j;
779 continue;
780 766
781 for (j = 0; j < q->ndesc; j++)767 for (j = 0; j < q->ndesc; j++)
782 usb_poison_urb(q->entry[j].urb);768 usb_poison_urb(q->entry[j].urb);
@@ -788,14 +774,11 @@ EXPORT_SYMBOL_GPL(mt76u_stop_rx); · 5 unmodified lines
788 774
789int mt76u_resume_rx(struct mt76_dev *dev)775int mt76u_resume_rx(struct mt76_dev *dev)
790{776{
791 struct mt76_queue *q;777 int i;
792 int i, j, err;
793
794 for (i = 0; i < __MT_RXQ_MAX; i++) {
795 q = &dev->q_rx[i];
796 778
797 if (!q->ndesc)779 mt76_for_each_q_rx(dev, i) {
798 continue;780 struct mt76_queue *q = &dev->q_rx[i];
781 int err, j;
799 782
800 for (j = 0; j < q->ndesc; j++)783 for (j = 0; j < q->ndesc; j++)
801 usb_unpoison_urb(q->entry[j].urb);784 usb_unpoison_urb(q->entry[j].urb);
@@ -859,7 +842,7 @@ static void mt76u_tx_tasklet(unsigned long data) · 57 unmodified lines
859 842
860 if (dev->drv->tx_status_data &&843 if (dev->drv->tx_status_data &&
861 !test_and_set_bit(MT76_READING_STATS, &dev->phy.state))844 !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);
863 if (wake)846 if (wake)
864 ieee80211_wake_queue(dev->hw, i);847 ieee80211_wake_queue(dev->hw, i);
865 }848 }
@@ -885,7 +868,7 @@ static void mt76u_tx_status_data(struct work_struct *work) · 19 unmodified lines
885 }868 }
886 869
887 if (count && test_bit(MT76_STATE_RUNNING, &dev->phy.state))870 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);
889 else872 else
890 clear_bit(MT76_READING_STATS, &dev->phy.state);873 clear_bit(MT76_READING_STATS, &dev->phy.state);
891}874}
@@ -921,35 +904,6 @@ mt76u_tx_setup_buffers(struct mt76_dev *dev, struct sk_buff *skb, · 29 unmodified lines
921 return urb->num_sgs;904 return urb->num_sgs;
922}905}
923 906
924int 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}
951EXPORT_SYMBOL_GPL(mt76u_skb_dma_info);
952
953static int907static int
954mt76u_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,908mt76u_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
955 struct sk_buff *skb, struct mt76_wcid *wcid,909 struct sk_buff *skb, struct mt76_wcid *wcid,
@@ -1161,15 +1115,6 @@ static const struct mt76_queue_ops usb_queue_ops = { · 205 unmodified lines
1161 .kick = mt76u_tx_kick,1115 .kick = mt76u_tx_kick,
1162};1116};
1163 1117
1164void 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}
1171EXPORT_SYMBOL_GPL(mt76u_deinit);
1172
1173int mt76u_init(struct mt76_dev *dev,1118int mt76u_init(struct mt76_dev *dev,
1174 struct usb_interface *intf, bool ext)1119 struct usb_interface *intf, bool ext)
1175{1120{
@@ -1192,10 +1137,6 @@ int mt76u_init(struct mt76_dev *dev, · 16 unmodified lines
1192 tasklet_init(&dev->tx_tasklet, mt76u_tx_tasklet, (unsigned long)dev);1137 tasklet_init(&dev->tx_tasklet, mt76u_tx_tasklet, (unsigned long)dev);
1193 INIT_WORK(&usb->stat_work, mt76u_tx_status_data);1138 INIT_WORK(&usb->stat_work, mt76u_tx_status_data);
1194 1139
1195 usb->wq = alloc_workqueue("mt76u", WQ_UNBOUND, 0);
1196 if (!usb->wq)
1197 return -ENOMEM;
1198
1199 usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1);1140 usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1);
1200 if (usb->data_len < 32)1141 if (usb->data_len < 32)
1201 usb->data_len = 32;1142 usb->data_len = 32;
@@ -1219,7 +1160,8 @@ int mt76u_init(struct mt76_dev *dev, · 17 unmodified lines
1219 return 0;1160 return 0;
1220 1161
1221error:1162error:
1222 mt76u_deinit(dev);1163 destroy_workqueue(dev->wq);
1164
1223 return err;1165 return err;
1224}1166}
1225EXPORT_SYMBOL_GPL(mt76u_init);1167EXPORT_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
13 13
14 timeout /= 10;14 timeout /= 10;
15 do {15 do {
16 cur = dev->bus->rr(dev, offset) & mask;16 cur = __mt76_rr(dev, offset) & mask;
17 if (cur == val)17 if (cur == val)
18 return true;18 return true;
19 19
@@ -31,7 +31,7 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val, · 11 unmodified lines
31 31
32 timeout /= 10;32 timeout /= 10;
33 do {33 do {
34 cur = dev->bus->rr(dev, offset) & mask;34 cur = __mt76_rr(dev, offset) & mask;
35 if (cur == val)35 if (cur == val)
36 return true;36 return true;
37 37
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
116 int sent, ret;116 int sent, ret;
117 u8 seq = 0;117 u8 seq = 0;
118 118
119 if (test_bit(MT7601U_STATE_REMOVED, &dev->state))119 if (test_bit(MT7601U_STATE_REMOVED, &dev->state)) {
120 consume_skb(skb);
120 return 0;121 return 0;
122 }
121 123
122 mutex_lock(&dev->mcu.mutex);124 mutex_lock(&dev->mcu.mutex);
123 125
drivers/net/wireless/microchip/wilc1000/sdio.c+2−4
@@ -6,6 +6,7 @@ · 5 unmodified lines
6 6
7#include <linux/clk.h>7#include <linux/clk.h>
8#include <linux/mmc/sdio_func.h>8#include <linux/mmc/sdio_func.h>
9#include <linux/mmc/sdio_ids.h>
9#include <linux/mmc/host.h>10#include <linux/mmc/host.h>
10#include <linux/mmc/sdio.h>11#include <linux/mmc/sdio.h>
11#include <linux/of_irq.h>12#include <linux/of_irq.h>
@@ -15,11 +16,8 @@ · 3 unmodified lines
15 16
16#define SDIO_MODALIAS "wilc1000_sdio"17#define SDIO_MODALIAS "wilc1000_sdio"
17 18
18#define SDIO_VENDOR_ID_WILC 0x0296
19#define SDIO_DEVICE_ID_WILC 0x5347
20
21static const struct sdio_device_id wilc_sdio_ids[] = {19static 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) },
23 { },21 { },
24};22};
25 23
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
446 }446 }
447 447
448 wiphy = qtnf_wiphy_allocate(bus, pdev);448 wiphy = qtnf_wiphy_allocate(bus, pdev);
449 if (!wiphy)449 if (!wiphy) {
450 if (pdev)
451 platform_device_unregister(pdev);
450 return ERR_PTR(-ENOMEM);452 return ERR_PTR(-ENOMEM);
453 }
451 454
452 mac = wiphy_priv(wiphy);455 mac = wiphy_priv(wiphy);
453 456
drivers/net/wireless/ralink/rt2x00/rt2400pci.c+1−2
@@ -1834,8 +1834,7 @@ static struct pci_driver rt2400pci_driver = { · 1833 unmodified lines
1834 .id_table = rt2400pci_device_table,1834 .id_table = rt2400pci_device_table,
1835 .probe = rt2400pci_probe,1835 .probe = rt2400pci_probe,
1836 .remove = rt2x00pci_remove,1836 .remove = rt2x00pci_remove,
1837 .suspend = rt2x00pci_suspend,1837 .driver.pm = &rt2x00pci_pm_ops,
1838 .resume = rt2x00pci_resume,
1839};1838};
1840 1839
1841module_pci_driver(rt2400pci_driver);1840module_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
2132 .id_table = rt2500pci_device_table,2132 .id_table = rt2500pci_device_table,
2133 .probe = rt2500pci_probe,2133 .probe = rt2500pci_probe,
2134 .remove = rt2x00pci_remove,2134 .remove = rt2x00pci_remove,
2135 .suspend = rt2x00pci_suspend,2135 .driver.pm = &rt2x00pci_pm_ops,
2136 .resume = rt2x00pci_resume,
2137};2136};
2138 2137
2139module_pci_driver(rt2500pci_driver);2138module_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
455 .id_table = rt2800pci_device_table,455 .id_table = rt2800pci_device_table,
456 .probe = rt2800pci_probe,456 .probe = rt2800pci_probe,
457 .remove = rt2x00pci_remove,457 .remove = rt2x00pci_remove,
458 .suspend = rt2x00pci_suspend,458 .driver.pm = &rt2x00pci_pm_ops,
459 .resume = rt2x00pci_resume,
460};459};
461 460
462module_pci_driver(rt2800pci_driver);461module_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
1487 */1487 */
1488int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);1488int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev);
1489void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);1489void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev);
1490#ifdef CONFIG_PM1490
1491int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state);1491int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev);
1492int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);1492int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev);
1493#endif /* CONFIG_PM */
1494 1493
1495#endif /* RT2X00_H */1494#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
1556/*1556/*
1557 * Device state handlers1557 * Device state handlers
1558 */1558 */
1559#ifdef CONFIG_PM1559int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev)
1560int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1561{1560{
1562 rt2x00_dbg(rt2x00dev, "Going to sleep\n");1561 rt2x00_dbg(rt2x00dev, "Going to sleep\n");
1563 1562
@@ -1614,7 +1613,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) · 50 unmodified lines
1614 return 0;1613 return 0;
1615}1614}
1616EXPORT_SYMBOL_GPL(rt2x00lib_resume);1615EXPORT_SYMBOL_GPL(rt2x00lib_resume);
1617#endif /* CONFIG_PM */
1618 1616
1619/*1617/*
1620 * rt2x00lib module information.1618 * 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
169}169}
170EXPORT_SYMBOL_GPL(rt2x00pci_remove);170EXPORT_SYMBOL_GPL(rt2x00pci_remove);
171 171
172#ifdef CONFIG_PM172static int __maybe_unused rt2x00pci_suspend(struct device *dev)
173int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state)
174{173{
175 struct ieee80211_hw *hw = pci_get_drvdata(pci_dev);174 struct ieee80211_hw *hw = dev_get_drvdata(dev);
176 struct rt2x00_dev *rt2x00dev = hw->priv;175 struct rt2x00_dev *rt2x00dev = hw->priv;
177 int retval;
178
179 retval = rt2x00lib_suspend(rt2x00dev, state);
180 if (retval)
181 return retval;
182 176
183 pci_save_state(pci_dev);177 return rt2x00lib_suspend(rt2x00dev);
184 pci_disable_device(pci_dev);
185 return pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
186}178}
187EXPORT_SYMBOL_GPL(rt2x00pci_suspend);
188 179
189int rt2x00pci_resume(struct pci_dev *pci_dev)180static int __maybe_unused rt2x00pci_resume(struct device *dev)
190{181{
191 struct ieee80211_hw *hw = pci_get_drvdata(pci_dev);182 struct ieee80211_hw *hw = dev_get_drvdata(dev);
192 struct rt2x00_dev *rt2x00dev = hw->priv;183 struct rt2x00_dev *rt2x00dev = hw->priv;
193 184
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);
201 return rt2x00lib_resume(rt2x00dev);185 return rt2x00lib_resume(rt2x00dev);
202}186}
203EXPORT_SYMBOL_GPL(rt2x00pci_resume);187
204#endif /* CONFIG_PM */188SIMPLE_DEV_PM_OPS(rt2x00pci_pm_ops, rt2x00pci_suspend, rt2x00pci_resume);
189EXPORT_SYMBOL_GPL(rt2x00pci_pm_ops);
205 190
206/*191/*
207 * rt2x00pci module information.192 * rt2x00pci module information.
drivers/net/wireless/ralink/rt2x00/rt2x00pci.h+2−7
@@ -21,12 +21,7 @@ · 20 unmodified lines
21 */21 */
22int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops);22int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops);
23void rt2x00pci_remove(struct pci_dev *pci_dev);23void rt2x00pci_remove(struct pci_dev *pci_dev);
24#ifdef CONFIG_PM24
25int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state);25extern const struct dev_pm_ops rt2x00pci_pm_ops;
26int rt2x00pci_resume(struct pci_dev *pci_dev);
27#else
28#define rt2x00pci_suspend NULL
29#define rt2x00pci_resume NULL
30#endif /* CONFIG_PM */
31 26
32#endif /* RT2X00PCI_H */27#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
130 struct ieee80211_hw *hw = platform_get_drvdata(pdev);130 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
131 struct rt2x00_dev *rt2x00dev = hw->priv;131 struct rt2x00_dev *rt2x00dev = hw->priv;
132 132
133 return rt2x00lib_suspend(rt2x00dev, state);133 return rt2x00lib_suspend(rt2x00dev);
134}134}
135EXPORT_SYMBOL_GPL(rt2x00soc_suspend);135EXPORT_SYMBOL_GPL(rt2x00soc_suspend);
136 136
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
886 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);886 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
887 struct rt2x00_dev *rt2x00dev = hw->priv;887 struct rt2x00_dev *rt2x00dev = hw->priv;
888 888
889 return rt2x00lib_suspend(rt2x00dev, state);889 return rt2x00lib_suspend(rt2x00dev);
890}890}
891EXPORT_SYMBOL_GPL(rt2x00usb_suspend);891EXPORT_SYMBOL_GPL(rt2x00usb_suspend);
892 892
drivers/net/wireless/ralink/rt2x00/rt61pci.c+1−2
@@ -3009,8 +3009,7 @@ static struct pci_driver rt61pci_driver = { · 3008 unmodified lines
3009 .id_table = rt61pci_device_table,3009 .id_table = rt61pci_device_table,
3010 .probe = rt61pci_probe,3010 .probe = rt61pci_probe,
3011 .remove = rt2x00pci_remove,3011 .remove = rt2x00pci_remove,
3012 .suspend = rt2x00pci_suspend,3012 .driver.pm = &rt2x00pci_pm_ops,
3013 .resume = rt2x00pci_resume,
3014};3013};
3015 3014
3016module_pci_driver(rt61pci_driver);3015module_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
894 (low_power ? ", 32k" : ""));894 (low_power ? ", 32k" : ""));
895 895
896 seq_printf(m,896 seq_printf(m,
897 "\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)",897 "\n %-35s = %6ph (0x%x/0x%x)",
898 "Power mode cmd(lps/rpwm)",898 "Power mode cmd(lps/rpwm)",
899 btcoexist->pwr_mode_val[0], btcoexist->pwr_mode_val[1],899 btcoexist->pwr_mode_val,
900 btcoexist->pwr_mode_val[2], btcoexist->pwr_mode_val[3],
901 btcoexist->pwr_mode_val[4], btcoexist->pwr_mode_val[5],
902 btcoexist->bt_info.lps_val,900 btcoexist->bt_info.lps_val,
903 btcoexist->bt_info.rpwm_val);901 btcoexist->bt_info.rpwm_val);
904}902}
@@ -1318,7 +1316,7 @@ bool exhalbtc_bind_bt_coex_withadapter(void *adapter) · 413 unmodified lines
1318{1316{
1319 struct rtl_priv *rtlpriv = adapter;1317 struct rtl_priv *rtlpriv = adapter;
1320 struct btc_coexist *btcoexist = rtl_btc_coexist(rtlpriv);1318 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;
1322 1320
1323 if (!btcoexist)1321 if (!btcoexist)
1324 return false;1322 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
1962 if (coex_stat->wl_under_ips)1962 if (coex_stat->wl_under_ips)
1963 return;1963 return;
1964 1964
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)
1966 return;1967 return;
1967 1968
1968 coex_stat->cnt_wl[COEX_CNT_WL_COEXRUN]++;1969 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
344 return count;344 return count;
345}345}
346 346
347static 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
347static ssize_t rtw_debugfs_set_rf_write(struct file *filp,372static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
348 const char __user *buffer,373 const char __user *buffer,
349 size_t count, loff_t *loff)374 size_t count, loff_t *loff)
@@ -808,6 +833,10 @@ static struct rtw_debugfs_priv rtw_debug_priv_write_reg = { · 458 unmodified lines
808 .cb_write = rtw_debugfs_set_write_reg,833 .cb_write = rtw_debugfs_set_write_reg,
809};834};
810 835
836static struct rtw_debugfs_priv rtw_debug_priv_h2c = {
837 .cb_write = rtw_debugfs_set_h2c,
838};
839
811static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {840static struct rtw_debugfs_priv rtw_debug_priv_rf_write = {
812 .cb_write = rtw_debugfs_set_rf_write,841 .cb_write = rtw_debugfs_set_rf_write,
813};842};
@@ -877,6 +906,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev) · 63 unmodified lines
877 rtw_debugfs_add_r(phy_info);906 rtw_debugfs_add_r(phy_info);
878 rtw_debugfs_add_r(coex_info);907 rtw_debugfs_add_r(coex_info);
879 rtw_debugfs_add_rw(coex_enable);908 rtw_debugfs_add_rw(coex_enable);
909 rtw_debugfs_add_w(h2c);
880 rtw_debugfs_add_r(mac_0);910 rtw_debugfs_add_r(mac_0);
881 rtw_debugfs_add_r(mac_1);911 rtw_debugfs_add_r(mac_1);
882 rtw_debugfs_add_r(mac_2);912 rtw_debugfs_add_r(mac_2);
drivers/net/wireless/realtek/rtw88/fw.c+11−6
@@ -253,6 +253,11 @@ out: · 252 unmodified lines
253 spin_unlock(&rtwdev->h2c.lock);253 spin_unlock(&rtwdev->h2c.lock);
254}254}
255 255
256void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c)
257{
258 rtw_fw_send_h2c_command(rtwdev, h2c);
259}
260
256static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt)261static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt)
257{262{
258 int ret;263 int ret;
@@ -456,7 +461,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) · 197 unmodified lines
456 SET_RA_INFO_INIT_RA_LVL(h2c_pkt, si->init_ra_lv);461 SET_RA_INFO_INIT_RA_LVL(h2c_pkt, si->init_ra_lv);
457 SET_RA_INFO_SGI_EN(h2c_pkt, si->sgi_enable);462 SET_RA_INFO_SGI_EN(h2c_pkt, si->sgi_enable);
458 SET_RA_INFO_BW_MODE(h2c_pkt, si->bw_mode);463 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);
460 SET_RA_INFO_NO_UPDATE(h2c_pkt, no_update);465 SET_RA_INFO_NO_UPDATE(h2c_pkt, no_update);
461 SET_RA_INFO_VHT_EN(h2c_pkt, si->vht_enable);466 SET_RA_INFO_VHT_EN(h2c_pkt, si->vht_enable);
462 SET_RA_INFO_DIS_PT(h2c_pkt, disable_pt);467 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
915 return skb_new;920 return skb_new;
916}921}
917 922
918static void rtw_fill_rsvd_page_desc(struct rtw_dev *rtwdev, struct sk_buff *skb)923static void rtw_fill_rsvd_page_desc(struct rtw_dev *rtwdev, struct sk_buff *skb,
924 enum rtw_rsvd_packet_type type)
919{925{
920 struct rtw_tx_pkt_info pkt_info;926 struct rtw_tx_pkt_info pkt_info = {0};
921 struct rtw_chip_info *chip = rtwdev->chip;927 struct rtw_chip_info *chip = rtwdev->chip;
922 u8 *pkt_desc;928 u8 *pkt_desc;
923 929
924 memset(&pkt_info, 0, sizeof(pkt_info));930 rtw_tx_rsvd_page_pkt_info_update(rtwdev, &pkt_info, skb, type);
925 rtw_rsvd_page_pkt_info_update(rtwdev, &pkt_info, skb);
926 pkt_desc = skb_push(skb, chip->tx_pkt_desc_sz);931 pkt_desc = skb_push(skb, chip->tx_pkt_desc_sz);
927 memset(pkt_desc, 0, chip->tx_pkt_desc_sz);932 memset(pkt_desc, 0, chip->tx_pkt_desc_sz);
928 rtw_tx_fill_tx_desc(&pkt_info, skb);933 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
1261 * And iter->len will be added with size of tx_desc_sz.1266 * And iter->len will be added with size of tx_desc_sz.
1262 */1267 */
1263 if (rsvd_pkt->add_txdesc)1268 if (rsvd_pkt->add_txdesc)
1264 rtw_fill_rsvd_page_desc(rtwdev, iter);1269 rtw_fill_rsvd_page_desc(rtwdev, iter, rsvd_pkt->type);
1265 1270
1266 rsvd_pkt->skb = iter;1271 rsvd_pkt->skb = iter;
1267 rsvd_pkt->page = total_page;1272 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
563void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,563void rtw_fw_update_pkt_probe_req(struct rtw_dev *rtwdev,
564 struct cfg80211_ssid *ssid);564 struct cfg80211_ssid *ssid);
565void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable);565void rtw_fw_channel_switch(struct rtw_dev *rtwdev, bool enable);
566void rtw_fw_h2c_cmd_dbg(struct rtw_dev *rtwdev, u8 *h2c);
567
566#endif568#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
231 mutex_unlock(&rtwdev->mutex);231 mutex_unlock(&rtwdev->mutex);
232}232}
233 233
234static 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
234static void rtw_ops_configure_filter(struct ieee80211_hw *hw,251static void rtw_ops_configure_filter(struct ieee80211_hw *hw,
235 unsigned int changed_flags,252 unsigned int changed_flags,
236 unsigned int *new_flags,253 unsigned int *new_flags,
@@ -373,6 +390,15 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw, · 136 unmodified lines
373 if (changed & BSS_CHANGED_BEACON)390 if (changed & BSS_CHANGED_BEACON)
374 rtw_fw_download_rsvd_page(rtwdev);391 rtw_fw_download_rsvd_page(rtwdev);
375 392
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
376 if (changed & BSS_CHANGED_MU_GROUPS)402 if (changed & BSS_CHANGED_MU_GROUPS)
377 rtw_chip_set_gid_table(rtwdev, vif, conf);403 rtw_chip_set_gid_table(rtwdev, vif, conf);
378 404
@@ -827,6 +853,7 @@ const struct ieee80211_ops rtw_ops = { · 448 unmodified lines
827 .config = rtw_ops_config,853 .config = rtw_ops_config,
828 .add_interface = rtw_ops_add_interface,854 .add_interface = rtw_ops_add_interface,
829 .remove_interface = rtw_ops_remove_interface,855 .remove_interface = rtw_ops_remove_interface,
856 .change_interface = rtw_ops_change_interface,
830 .configure_filter = rtw_ops_configure_filter,857 .configure_filter = rtw_ops_configure_filter,
831 .bss_info_changed = rtw_ops_bss_info_changed,858 .bss_info_changed = rtw_ops_bss_info_changed,
832 .conf_tx = rtw_ops_conf_tx,859 .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
722 stbc_en = VHT_STBC_EN;722 stbc_en = VHT_STBC_EN;
723 if (sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)723 if (sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)
724 ldpc_en = VHT_LDPC_EN;724 ldpc_en = VHT_LDPC_EN;
725 if (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80)
726 is_support_sgi = true;
727 } else if (sta->ht_cap.ht_supported) {725 } else if (sta->ht_cap.ht_supported) {
728 ra_mask |= (sta->ht_cap.mcs.rx_mask[1] << 20) |726 ra_mask |= (sta->ht_cap.mcs.rx_mask[1] << 20) |
729 (sta->ht_cap.mcs.rx_mask[0] << 12);727 (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
731 stbc_en = HT_STBC_EN;729 stbc_en = HT_STBC_EN;
732 if (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)730 if (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING)
733 ldpc_en = HT_LDPC_EN;731 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;
737 }732 }
738 733
739 if (efuse->hw_cap.nss == 1)734 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
775 switch (sta->bandwidth) {770 switch (sta->bandwidth) {
776 case IEEE80211_STA_RX_BW_80:771 case IEEE80211_STA_RX_BW_80:
777 bw_mode = RTW_CHANNEL_WIDTH_80;772 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);
778 break;775 break;
779 case IEEE80211_STA_RX_BW_40:776 case IEEE80211_STA_RX_BW_40:
780 bw_mode = RTW_CHANNEL_WIDTH_40;777 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);
781 break;780 break;
782 default:781 default:
783 bw_mode = RTW_CHANNEL_WIDTH_20;782 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);
784 break;785 break;
785 }786 }
786 787
drivers/net/wireless/realtek/rtw88/main.h+2−0
@@ -592,6 +592,8 @@ struct rtw_tx_pkt_info { · 591 unmodified lines
592 bool dis_qselseq;592 bool dis_qselseq;
593 bool en_hwseq;593 bool en_hwseq;
594 u8 hw_ssn_sel;594 u8 hw_ssn_sel;
595 bool nav_use_hdr;
596 bool bt_null;
595};597};
596 598
597struct rtw_rx_pkt_stat {599struct rtw_rx_pkt_stat {
drivers/net/wireless/realtek/rtw88/reg.h+1−0
@@ -61,6 +61,7 @@ · 60 unmodified lines
61#define BIT_FSPI_EN BIT(19)61#define BIT_FSPI_EN BIT(19)
62#define BIT_EN_SIC BIT(12)62#define BIT_EN_SIC BIT(12)
63#define BIT_BT_AOD_GPIO3 BIT(9)63#define BIT_BT_AOD_GPIO3 BIT(9)
64#define BIT_PO_BT_PTA_PINS BIT(9)
64#define BIT_BT_PTA_EN BIT(5)65#define BIT_BT_PTA_EN BIT(5)
65#define BIT_WLRFE_4_5_EN BIT(2)66#define BIT_WLRFE_4_5_EN BIT(2)
66 67
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
649 rtw8821c_do_iqk(rtwdev);649 rtw8821c_do_iqk(rtwdev);
650}650}
651 651
652/* for coex */
653static 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
681static 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
769static void rtw8821c_coex_cfg_gnt_fix(struct rtw_dev *rtwdev)
770{}
771
772static 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
782static 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
824static 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
840static void rtw8821c_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain)
841{}
842
652static void843static void
653rtw8821c_txagc_swing_offset(struct rtw_dev *rtwdev, u8 pwr_idx_offset,844rtw8821c_txagc_swing_offset(struct rtw_dev *rtwdev, u8 pwr_idx_offset,
654 s8 pwr_idx_offset_lower,845 s8 pwr_idx_offset_lower,
@@ -1293,8 +1484,166 @@ static struct rtw_chip_ops rtw8821c_ops = { · 638 unmodified lines
1293 .config_bfee = rtw8821c_bf_config_bfee,1484 .config_bfee = rtw8821c_bf_config_bfee,
1294 .set_gid_table = rtw_bf_set_gid_table,1485 .set_gid_table = rtw_bf_set_gid_table,
1295 .cfg_csi_rate = rtw_bf_cfg_csi_rate,1486 .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) */
1498static const u8 wl_rssi_step_8821c[] = {101, 45, 101, 40};
1499static const u8 bt_rssi_step_8821c[] = {101, 101, 101, 101};
1500
1501/* Shared-Antenna Coex Table */
1502static 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 */
1539static 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 */
1567static 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 */
1599static 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} }
1296};1622};
1297 1623
1624static 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 */
1627static 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
1636static 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
1645static_assert(ARRAY_SIZE(rf_para_tx_8821c) == ARRAY_SIZE(rf_para_rx_8821c));
1646
1298static const u8 rtw8821c_pwrtrk_5gb_n[][RTW_PWR_TRK_TBL_SZ] = {1647static const u8 rtw8821c_pwrtrk_5gb_n[][RTW_PWR_TRK_TBL_SZ] = {
1299 {0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 9, 10, 10,1648 {0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 9, 10, 10,
1300 11, 11, 12, 12, 12, 12, 12},1649 11, 11, 12, 12, 12, 12, 12},
@@ -1371,7 +1720,7 @@ static const u8 rtw8821c_pwrtrk_2g_cck_a_p[] = { · 70 unmodified lines
1371 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 91720 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9
1372};1721};
1373 1722
1374const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = {1723static const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = {
1375 .pwrtrk_5gb_n[0] = rtw8821c_pwrtrk_5gb_n[0],1724 .pwrtrk_5gb_n[0] = rtw8821c_pwrtrk_5gb_n[0],
1376 .pwrtrk_5gb_n[1] = rtw8821c_pwrtrk_5gb_n[1],1725 .pwrtrk_5gb_n[1] = rtw8821c_pwrtrk_5gb_n[1],
1377 .pwrtrk_5gb_n[2] = rtw8821c_pwrtrk_5gb_n[2],1726 .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
1394 .pwrtrk_2g_ccka_p = rtw8821c_pwrtrk_2g_cck_a_p,1743 .pwrtrk_2g_ccka_p = rtw8821c_pwrtrk_2g_cck_a_p,
1395};1744};
1396 1745
1746static 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
1397struct rtw_chip_info rtw8821c_hw_spec = {1771struct rtw_chip_info rtw8821c_hw_spec = {
1398 .ops = &rtw8821c_ops,1772 .ops = &rtw8821c_ops,
1399 .id = RTW_CHIP_TYPE_8821C,1773 .id = RTW_CHIP_TYPE_8821C,
@@ -1440,6 +1814,35 @@ struct rtw_chip_info rtw8821c_hw_spec = { · 40 unmodified lines
1440 .iqk_threshold = 8,1814 .iqk_threshold = 8,
1441 .bfer_su_max_num = 2,1815 .bfer_su_max_num = 2,
1442 .bfer_mu_max_num = 1,1816 .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,
1443};1846};
1444EXPORT_SYMBOL(rtw8821c_hw_spec);1847EXPORT_SYMBOL(rtw8821c_hw_spec);
1445 1848
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
160 le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))160 le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(11, 8))
161#define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \161#define GET_PHY_STAT_P1_HT_RXSC(phy_stat) \
162 le32_get_bits(*((__le32 *)(phy_stat) + 0x01), GENMASK(15, 12))162 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))
163 175
164#define REG_INIRTS_RATE_SEL 0x0480176#define REG_INIRTS_RATE_SEL 0x0480
165#define REG_HTSTFWT 0x800177#define REG_HTSTFWT 0x800
@@ -217,6 +229,20 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data) · 51 unmodified lines
217#define REG_CCA_CCK 0xfcc229#define REG_CCA_CCK 0xfcc
218#define REG_ANTWT 0x1904230#define REG_ANTWT 0x1904
219#define REG_IQKFAILMSK 0x1bf0231#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)
220 246
221#define RF18_BAND_MASK (BIT(16) | BIT(9) | BIT(8))247#define RF18_BAND_MASK (BIT(16) | BIT(9) | BIT(8))
222#define RF18_BAND_2G (0)248#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
61 SET_TX_DESC_DISQSELSEQ(txdesc, pkt_info->dis_qselseq);61 SET_TX_DESC_DISQSELSEQ(txdesc, pkt_info->dis_qselseq);
62 SET_TX_DESC_EN_HWSEQ(txdesc, pkt_info->en_hwseq);62 SET_TX_DESC_EN_HWSEQ(txdesc, pkt_info->en_hwseq);
63 SET_TX_DESC_HW_SSN_SEL(txdesc, pkt_info->hw_ssn_sel);63 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);
64}66}
65EXPORT_SYMBOL(rtw_tx_fill_tx_desc);67EXPORT_SYMBOL(rtw_tx_fill_tx_desc);
66 68
@@ -227,17 +229,58 @@ void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src) · 160 unmodified lines
227 spin_unlock_irqrestore(&tx_report->q_lock, flags);229 spin_unlock_irqrestore(&tx_report->q_lock, flags);
228}230}
229 231
230static void rtw_tx_mgmt_pkt_info_update(struct rtw_dev *rtwdev,232static void rtw_tx_pkt_info_update_rate(struct rtw_dev *rtwdev,
231 struct rtw_tx_pkt_info *pkt_info,233 struct rtw_tx_pkt_info *pkt_info,
232 struct ieee80211_sta *sta,
233 struct sk_buff *skb)234 struct sk_buff *skb)
234{235{
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 }
235 pkt_info->use_rate = true;243 pkt_info->use_rate = true;
236 pkt_info->rate_id = 6;
237 pkt_info->dis_rate_fallback = true;244 pkt_info->dis_rate_fallback = true;
245}
246
247static 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
274static 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);
238 pkt_info->dis_qselseq = true;280 pkt_info->dis_qselseq = true;
239 pkt_info->en_hwseq = true;281 pkt_info->en_hwseq = true;
240 pkt_info->hw_ssn_sel = 0;282 pkt_info->hw_ssn_sel = 0;
283 /* TODO: need to change hw port and hw ssn sel for multiple vifs */
241}284}
242 285
243static void rtw_tx_data_pkt_info_update(struct rtw_dev *rtwdev,286static 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
312 struct rtw_sta_info *si;355 struct rtw_sta_info *si;
313 struct ieee80211_vif *vif = NULL;356 struct ieee80211_vif *vif = NULL;
314 __le16 fc = hdr->frame_control;357 __le16 fc = hdr->frame_control;
315 u8 sec_type = 0;
316 bool bmc;358 bool bmc;
317 359
318 if (sta) {360 if (sta) {
@@ -325,23 +367,6 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 6 unmodified lines
325 else if (ieee80211_is_data(fc))367 else if (ieee80211_is_data(fc))
326 rtw_tx_data_pkt_info_update(rtwdev, pkt_info, sta, skb);368 rtw_tx_data_pkt_info_update(rtwdev, pkt_info, sta, skb);
327 369
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
345 bmc = is_broadcast_ether_addr(hdr->addr1) ||370 bmc = is_broadcast_ether_addr(hdr->addr1) ||
346 is_multicast_ether_addr(hdr->addr1);371 is_multicast_ether_addr(hdr->addr1);
347 372
@@ -349,7 +374,7 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 1 unmodified line
349 rtw_tx_report_enable(rtwdev, pkt_info);374 rtw_tx_report_enable(rtwdev, pkt_info);
350 375
351 pkt_info->bmc = bmc;376 pkt_info->bmc = bmc;
352 pkt_info->sec_type = sec_type;377 rtw_tx_pkt_info_update_sec(rtwdev, pkt_info, skb);
353 pkt_info->tx_pkt_size = skb->len;378 pkt_info->tx_pkt_size = skb->len;
354 pkt_info->offset = chip->tx_pkt_desc_sz;379 pkt_info->offset = chip->tx_pkt_desc_sz;
355 pkt_info->qsel = skb->priority;380 pkt_info->qsel = skb->priority;
@@ -359,24 +384,42 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 3 unmodified lines
359 rtw_tx_stats(rtwdev, vif, skb);384 rtw_tx_stats(rtwdev, vif, skb);
360}385}
361 386
362void rtw_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,387void rtw_tx_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
363 struct rtw_tx_pkt_info *pkt_info,388 struct rtw_tx_pkt_info *pkt_info,
364 struct sk_buff *skb)389 struct sk_buff *skb,
390 enum rtw_rsvd_packet_type type)
365{391{
366 struct rtw_chip_info *chip = rtwdev->chip;392 struct rtw_chip_info *chip = rtwdev->chip;
367 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;393 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
368 bool bmc;394 bool bmc;
369 395
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
370 bmc = is_broadcast_ether_addr(hdr->addr1) ||404 bmc = is_broadcast_ether_addr(hdr->addr1) ||
371 is_multicast_ether_addr(hdr->addr1);405 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;
375 pkt_info->bmc = bmc;406 pkt_info->bmc = bmc;
376 pkt_info->tx_pkt_size = skb->len;407 pkt_info->tx_pkt_size = skb->len;
377 pkt_info->offset = chip->tx_pkt_desc_sz;408 pkt_info->offset = chip->tx_pkt_desc_sz;
378 pkt_info->qsel = TX_DESC_QSEL_MGMT;
379 pkt_info->ls = true;409 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 */
380}423}
381 424
382struct sk_buff *425struct sk_buff *
@@ -399,8 +442,7 @@ rtw_tx_write_data_rsvd_page_get(struct rtw_dev *rtwdev, · 16 unmodified lines
399 442
400 skb_reserve(skb, tx_pkt_desc_sz);443 skb_reserve(skb, tx_pkt_desc_sz);
401 skb_put_data(skb, buf, size);444 skb_put_data(skb, buf, size);
402 pkt_info->tx_pkt_size = size;445 rtw_tx_rsvd_page_pkt_info_update(rtwdev, pkt_info, skb, RSVD_BEACON);
403 pkt_info->offset = tx_pkt_desc_sz;
404 446
405 return skb;447 return skb;
406}448}
drivers/net/wireless/realtek/rtw88/tx.h+10−3
@@ -59,6 +59,10 @@ · 58 unmodified lines
59 le32p_replace_bits((__le32 *)(txdesc) + 0x08, value, BIT(15))59 le32p_replace_bits((__le32 *)(txdesc) + 0x08, value, BIT(15))
60#define SET_TX_DESC_HW_SSN_SEL(txdesc, value) \60#define SET_TX_DESC_HW_SSN_SEL(txdesc, value) \
61 le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, GENMASK(7, 6))61 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))
62 66
63enum rtw_tx_desc_queue_select {67enum rtw_tx_desc_queue_select {
64 TX_DESC_QSEL_TID0 = 0,68 TX_DESC_QSEL_TID0 = 0,
@@ -83,6 +87,8 @@ enum rtw_tx_desc_queue_select { · 18 unmodified lines
83 TX_DESC_QSEL_H2C = 19,87 TX_DESC_QSEL_H2C = 19,
84};88};
85 89
90enum rtw_rsvd_packet_type;
91
86void rtw_tx(struct rtw_dev *rtwdev,92void rtw_tx(struct rtw_dev *rtwdev,
87 struct ieee80211_tx_control *control,93 struct ieee80211_tx_control *control,
88 struct sk_buff *skb);94 struct sk_buff *skb);
@@ -96,9 +102,10 @@ void rtw_tx_pkt_info_update(struct rtw_dev *rtwdev, · 7 unmodified lines
96void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb);102void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb);
97void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn);103void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn);
98void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src);104void rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src);
99void rtw_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,105void rtw_tx_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
100 struct rtw_tx_pkt_info *pkt_info,106 struct rtw_tx_pkt_info *pkt_info,
101 struct sk_buff *skb);107 struct sk_buff *skb,
108 enum rtw_rsvd_packet_type type);
102struct sk_buff *109struct sk_buff *
103rtw_tx_write_data_rsvd_page_get(struct rtw_dev *rtwdev,110rtw_tx_write_data_rsvd_page_get(struct rtw_dev *rtwdev,
104 struct rtw_tx_pkt_info *pkt_info,111 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
70 break;70 break;
71 }71 }
72 72
73 return 0;73 return ret;
74}74}
75 75
76static void wl1251_event_mbox_dump(struct event_mailbox *mbox)76static void wl1251_event_mbox_dump(struct event_mailbox *mbox)
include/linux/mmc/sdio_ids.h+3−0
@@ -105,6 +105,9 @@ · 104 unmodified lines
105#define SDIO_DEVICE_ID_MEDIATEK_MT7663 0x7663105#define SDIO_DEVICE_ID_MEDIATEK_MT7663 0x7663
106#define SDIO_DEVICE_ID_MEDIATEK_MT7668 0x7668106#define SDIO_DEVICE_ID_MEDIATEK_MT7668 0x7668
107 107
108#define SDIO_VENDOR_ID_MICROCHIP_WILC 0x0296
109#define SDIO_DEVICE_ID_MICROCHIP_WILC1000 0x5347
110
108#define SDIO_VENDOR_ID_SIANO 0x039a111#define SDIO_VENDOR_ID_SIANO 0x039a
109#define SDIO_DEVICE_ID_SIANO_NOVA_B0 0x0201112#define SDIO_DEVICE_ID_SIANO_NOVA_B0 0x0201
110#define SDIO_DEVICE_ID_SIANO_NICE 0x0202113#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