platform/kernel/linux-rpi.git
6 years agomt76: check aggregation sequence number for frames sent via drv_tx
Felix Fietkau [Sat, 29 Sep 2018 11:15:32 +0000 (13:15 +0200)]
mt76: check aggregation sequence number for frames sent via drv_tx

ps-poll response frames can be sent via drv_tx. Store the frame sequence number
for such frames, in case a BlockAckReq needs to be sent

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: fix handling ps-poll frames
Felix Fietkau [Sat, 29 Sep 2018 11:13:09 +0000 (13:13 +0200)]
mt76: fix handling ps-poll frames

Hardware station lookup for pspoll frames can fail, which makes the driver
ignore ps-poll frames. Fix the resulting powersave issues by looking up
the station for pspoll frames in software

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: usb: move mt76x0u_tx_prepare_skb in usb.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:07 +0000 (13:39 +0200)]
mt76x0: usb: move mt76x0u_tx_prepare_skb in usb.c

Move mt76x0u_tx_prepare_skb routine in usb module in
order to remove leftover usb dependency from generic code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: eeprom: load eeprom data from mtd by default
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:06 +0000 (13:39 +0200)]
mt76x0: eeprom: load eeprom data from mtd by default

Read eeprom data from mtd memory by default and fall-back
to efuse if it fails

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: pci: add mt76x0e_{start/stop} callbacks
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:05 +0000 (13:39 +0200)]
mt76x0: pci: add mt76x0e_{start/stop} callbacks

Introduce mt76x0e_start and mt76x0e_stop mac80211
callbacks to start/stop device mac opening/closing
the netdevice

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: add ieee80211_ops ops pointer to mt76x0_alloc_device signature
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:04 +0000 (13:39 +0200)]
mt76x0: add ieee80211_ops ops pointer to mt76x0_alloc_device signature

Add ieee80211_ops ops pointer to mt76x0_alloc_device routine signature
in order to specify mac80211 callbacks and remove usb dependency from
mt76x0 generic code.
Move mt76x0_ops callbacks in usb module in order to remove leftover
usb dependency in mt76x0 generic code.
Introduce mt76x0e_ops mac80211 callbacks for pci code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move set_{tx,rx}_path routines in mt76x02-lib module
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:03 +0000 (13:39 +0200)]
mt76: move set_{tx,rx}_path routines in mt76x02-lib module

Move mt76x02_phy_set_rxpath and mt76x02_phy_tx_dac routines in
mt76x02_phy.c since they are shared between mt76x2 and mt76x0 drivers.
Moreover move chainmask variable from mt76x2/mt76x0 to mt76_dev data
structure

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: phy: set antenna parameter according to wireless band
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:02 +0000 (13:39 +0200)]
mt76x0: phy: set antenna parameter according to wireless band

Move mt76x0_ant_select routine in __mt76x0_phy_set_channel in order to
configure antenna parameters according to the current wireless channel

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: pci: add hw initialization at bootstrap
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:01 +0000 (13:39 +0200)]
mt76x0: pci: add hw initialization at bootstrap

Add mt76x0e_register_device routine in pci.c
to initialize the device during hw probe.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: usb: move initialization code in usb.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:39:00 +0000 (13:39 +0200)]
mt76x0: usb: move initialization code in usb.c

Move usb initialization code in mt76x0-usb module in
order to remove usb dependency from generic init code
(not completed yet). Moreover fix a memory leak in usb probe
if mt76x02_wait_for_mac fails

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add mt76x02_mac_start routine
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:59 +0000 (13:38 +0200)]
mt76: add mt76x02_mac_start routine

Introduce mt76x02_mac_start since the mac start code is shared between
mt76x0e and mt76x2 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: init rx filter in mt76x0_init_hardware
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:58 +0000 (13:38 +0200)]
mt76x0: init rx filter in mt76x0_init_hardware

Initialize rxfilter mask at bootstrap an not at mac start.
This is a preliminary patch to share mt76x2_mac_start routine
between mt76x2e and mt76x0e drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: init: remove MT_PBF_SYS_CTRL configuration in mt76x0_reset_csr_bbp
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:57 +0000 (13:38 +0200)]
mt76x0: init: remove MT_PBF_SYS_CTRL configuration in mt76x0_reset_csr_bbp

Remove MT_PBF_SYS_CTRL configuration in mt76x0_reset_csr_bbp since
it is already initialized in mt76x0_init_mac_registers routine

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: init: remove duplicated initialization
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:56 +0000 (13:38 +0200)]
mt76x0: init: remove duplicated initialization

Remove MT_HEADER_TRANS_CTRL_REG/MT_TSO_CTRL configuration
since they are already initialized in mt76x0_init_mac_registers
routine

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: use mt76x02 utility routines in mt76x0 init code
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:55 +0000 (13:38 +0200)]
mt76x0: use mt76x02 utility routines in mt76x0 init code

Use mt76x02_wait_for_wpdma and mt76x02_wait_for_txrx_idle
utility routines in mt76x0_init_hardware and mt76x0_mac_start
and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: usb: move mcu code in usb_mcu.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:54 +0000 (13:38 +0200)]
mt76x0: usb: move mcu code in usb_mcu.c

Move usb mcu code in a dedicated source file in order to remove
usb dependency from generic source files and improve code
maintainability

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: pci: move mcu code in pci_mcu.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:53 +0000 (13:38 +0200)]
mt76x0: pci: move mcu code in pci_mcu.c

Move pci mcu code in a dedicated source file in order to
improve maintainability and facilitate new device support
development

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: update initvals to latest version of vendor driver
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:52 +0000 (13:38 +0200)]
mt76x0: update initvals to latest version of vendor driver

Update mac/rf/dcoc initial values to latest version of vendor driver.
Improve code readability

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x2_wait_for_bbp in mt76x02-lib module
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:51 +0000 (13:38 +0200)]
mt76: move mt76x2_wait_for_bbp in mt76x02-lib module

Move mt76x2_wait_for_bbp utility routine in mt76x02_util.h
in order to be resued by mt76x0 driver. Morover rename it in
mt76x02_wait_for_txrx_idle

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: mmio: add implementation of wr_rp and rd_rp
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:50 +0000 (13:38 +0200)]
mt76: mmio: add implementation of wr_rp and rd_rp

Introduce mmio implementation of mt76_mmio_rd_rp and
mt76_mmio_wr_rp and remove mt76x2 duplicated code.
mt76_mmio_{wr,rd}_rp allows to reuse mt76x0 init code
adding mt76x0e support

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x02_beacon_offset in mt76x02_util.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:49 +0000 (13:38 +0200)]
mt76: move mt76x02_beacon_offset in mt76x02_util.c

Move mt76x02_beacon_offset utility routine in mt76x02-lib module
since it is shared between mt76x0 and mt76x2 driver and remove
duplicated code. Moreover move beacon_offset data structure in
mt76x02-lib module since it is shared between mt76x0 and mt76x2
drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move queue initialization in mt76x02_mmio.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:48 +0000 (13:38 +0200)]
mt76: move queue initialization in mt76x02_mmio.c

Move mt76x02_dma_init, mt76x02_init_rx_queue and mt76x02_init_tx_queue
routines in mt76x02-lib module in order to be reused by mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x02_set_irq_mask in mt76x02_mmio.c
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:47 +0000 (13:38 +0200)]
mt76: move mt76x02_set_irq_mask in mt76x02_mmio.c

Move mt76x02_set_irq_mask, mt76x02_irq_enable and mt76x02_irq_disable
in mt76x02-lib module in order to be reused by mt76x0 driver.
Moreover move irq_lock and irqmask in mt76_mmio data structure

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add mt76x02_dma_enable/mt76x02_dma_disable utility routines
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:46 +0000 (13:38 +0200)]
mt76: add mt76x02_dma_enable/mt76x02_dma_disable utility routines

Introduce mt76x02_dma_enable and mt76x02_dma_disable utility routines
in order to be reused in mt76x0 mac configuration and remove duplicated
code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move wait_for_wpdma in mt76x02_dma.h
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:45 +0000 (13:38 +0200)]
mt76: move wait_for_wpdma in mt76x02_dma.h

Move wait_for_wpdma utility routine in mt76x02_dma.h
in order to be reused by mt76x0 driver. Moreover add
the possibility to specify the timeout value in
wait_for_wpdma signature

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: use mt76_poll in mt76x0_set_wlan_state
Lorenzo Bianconi [Fri, 28 Sep 2018 11:38:44 +0000 (13:38 +0200)]
mt76x0: use mt76_poll in mt76x0_set_wlan_state

Use mt76_poll utility routine in mt76x0_set_wlan_state to check
if the PLL/XTAL is ready

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: disable WLAN core before probe
Felix Fietkau [Wed, 26 Sep 2018 19:37:38 +0000 (21:37 +0200)]
mt76x2: disable WLAN core before probe

If the WLAN core is still active during initialization, it might cause
the MCU or DMA to hang. This can happen during soft reboot, so disable
the core + clock early to avoid this issue.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: add quirk to disable 2.4GHz band for Archer T1U
Stanislaw Gruszka [Tue, 25 Sep 2018 06:49:48 +0000 (08:49 +0200)]
mt76x0: add quirk to disable 2.4GHz band for Archer T1U

TP-LINK Archer T1U do not support 2.4GHz band despite EEPROM
reports that. Add quirk to mask out 2.4GHz support.

Reported-by: Sid Hayn <sidhayn@gmail.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: use skb_pad() instead of __skb_pad()
Hauke Mehrtens [Tue, 25 Sep 2018 19:52:51 +0000 (21:52 +0200)]
mt76: use skb_pad() instead of __skb_pad()

mt76 uses __skb_pad() with free_on_error set to true, this is the same
as calling skb_pad().
This patch does not change any functionality, but it makes it easier to
backport this driver in backports, because skb_pad() is also available
in older kernel versions.

Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: usb: make rx page_frag_cache access atomic
Lorenzo Bianconi [Wed, 26 Sep 2018 11:07:39 +0000 (13:07 +0200)]
mt76: usb: make rx page_frag_cache access atomic

Add rx_page_lock spinlock in order to make rx page fragment access
atomic. This patch fixes the following crash that occasionally
occurs during module loading/unloading

BUG: unable to handle kernel paging request at ffff9f8322e19000
PGD 27ba01067 P4D 27ba01067 PUD 27ddba063 PMD 263b35063 PTE 8000000262e19061
Oops: 0003 [#1] SMP PTI
CPU: 2 PID: 1766 Comm: systemd-udevd Not tainted 4.19.0-rc5+ #6
Hardware name: ASUSTeK COMPUTER INC. ESC2000 G2/Z9PE-D8 WS, BIOS 0405 03/19/2012
RIP: 0010:__memcpy+0x12/0x20
RSP: 0018:ffffba13849b3ad8 EFLAGS: 00010246
RAX: ffff9f8322e17004 RBX: 00000000000038f0 RCX: 000000000000031f
RDX: 0000000000000000 RSI: ffffba13844cf058 RDI: ffff9f8322e18ffc
RBP: 0000000000010c6c R08: 0000000000000000 R09: 0000607ec0000000
R10: 0000000000000003 R11: 0000000000003e2e R12: ffff9f8324cd9540
R13: 0000000000000000 R14: ffffba13849b3b30 R15: ffff9f8322e17000
FS:  00007fadec85b880(0000) GS:ffff9f833fa80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff9f8322e19000 CR3: 0000000263428001 CR4: 00000000000606e0
Call Trace:
 mt76x02u_mcu_fw_send_data+0x16c/0x270 [mt76x02_usb]
 mt76x0u_probe+0x35a/0x598 [mt76x0u]
 usb_probe_interface+0x113/0x310
 really_probe+0x1c8/0x400
 driver_probe_device+0x5c/0x130
 __driver_attach+0xec/0x110
 bus_for_each_dev+0x50/0x90
 bus_add_driver+0x1c0/0x280
 driver_register+0x5b/0xe0
 usb_register_driver+0x7c/0x140
 do_one_initcall+0x44/0x19b
 do_init_module+0x5a/0x210
 load_module+0x175c/0x1bc0
 __do_sys_finit_module+0x97/0xc0
 do_syscall_64+0x3f/0xf0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fadeb6f1809
RSP: 002b:00007ffe548f9f38 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 00007fadebdf0d89 RCX: 00007fadeb6f1809
RDX: 0000000000000000 RSI: 00007fadebdf0d89 RDI: 0000000000000006
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000006 R11: 0000000000000246 R12: 0000560b9ef58ab0
R13: 0000560b9ef29800 R14: 0000560b9ef59040 R15: 0000000000020000

Fixes: c12128ce44b0 ("mt76: use a per rx queue page fragment cache")
Reported-by: Stanislaw Gruszka <sgruszka@redhat.com>
Tested-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: report firmware version using ethtool
Davide Caratti [Thu, 20 Sep 2018 12:30:56 +0000 (14:30 +0200)]
mt76: report firmware version using ethtool

print fw_ver and build_ver members of struct mt76x02_fw_header, similarly
to what appears in the output of 'dmesg' when the MCU firmware is loaded.

Reported-by: Sid Hayn <sidhayn@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: include linux/module.h in files using MODULE_*
Felix Fietkau [Mon, 24 Sep 2018 09:13:11 +0000 (11:13 +0200)]
mt76: include linux/module.h in files using MODULE_*

Fix source files using MODULE_* macros without including linux/module.h

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: phy: introduce mt76x0_phy_set_txpower routine
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:37 +0000 (13:45 +0200)]
mt76x0: phy: introduce mt76x0_phy_set_txpower routine

Add mt76x0_phy_set_txpower routine in order to configure
base and per rate tx power gain. Moreover take into account
txpower_conf in order to limit the tx power gain according to
the bound provided by mac80211

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: use shared debugfs implementation
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:36 +0000 (13:45 +0200)]
mt76x0: use shared debugfs implementation

Use mt76 shared debugfs implementation and remove duplicated code
in mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove eeprom dependency from mt76x0_get_power_info
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:35 +0000 (13:45 +0200)]
mt76x0: remove eeprom dependency from mt76x0_get_power_info

In order to unify eeprom parsing between mt76x0 and mt76x2 drivers,
remove eeprom pointer dependency from mt76x0_get_power_info routine.
Remove mt76x0_eeprom_params since it is now an empty structure

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove eeprom dependency from mt76x0_set_tx_power_per_rate
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:34 +0000 (13:45 +0200)]
mt76x0: remove eeprom dependency from mt76x0_set_tx_power_per_rate

In order to unify eeprom parsing between mt76x0 and mt76x2 drivers,
remove eeprom pointer dependency from mt76x0_set_tx_power_per_rate.
Moreover use mt76_rate_power to store power vs rate calibration data.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove mt76x0_phy_set_tx_power and mt76x0_extra_power_over_mac
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:33 +0000 (13:45 +0200)]
mt76x0: remove mt76x0_phy_set_tx_power and mt76x0_extra_power_over_mac

Remove mt76x0_extra_power_over_mac and mt76x0_phy_set_tx_power routines
since they are not actually used and tx power handling will be unified
with mt76x2 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x02_rate_power_val in mt76x02-lib module
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:32 +0000 (13:45 +0200)]
mt76: move mt76x02_rate_power_val in mt76x02-lib module

Move mt76x02_rate_power_val and mt76x2_sign_extend_optional utility
routines in mt76x02_eeprom.h in order to reuse them in mt76x0 eeprom
parsing

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move rate_txpower handler in mt76 debugfs
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:31 +0000 (13:45 +0200)]
mt76: move rate_txpower handler in mt76 debugfs

Move rate_txpower handler in mt76 debugfs in order to be reused
in mt76x0 driver and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add mt76x02_phy_set_txpower utility routine
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:30 +0000 (13:45 +0200)]
mt76: add mt76x02_phy_set_txpower utility routine

Add mt76x02_phy_set_txpower utility routine in mt76x02_phy.c
in order to be reused in mt76x0 tx power management code.
Moreover move following routines in mt76x02-lib module:
- mt76x02_tx_power_mask
- mt76x02_get_max_rate_power
- mt76x02_limit_rate_power
- mt76x02_add_rate_power_offset

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76_rate_power in mt76_dev
Lorenzo Bianconi [Sat, 22 Sep 2018 11:45:29 +0000 (13:45 +0200)]
mt76: move mt76_rate_power in mt76_dev

Move mt76_rate_power data structure from mt76x2_dev to mt76_dev in order
to share it with mt76x0 driver. Moreover move txpower_conf and
txpower_cur in mt76_dev

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: fix return value of mt76x02_wait_for_mac
Stanislaw Gruszka [Thu, 6 Sep 2018 09:38:34 +0000 (11:38 +0200)]
mt76: fix return value of mt76x02_wait_for_mac

We need to return bool value in mt76x02_wait_for_mac.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 2735a6dd7df3 ("mt76: unify wait_for_mac")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: usb: remove WARN_ON in mt76u_get_rx_entry_len
Lorenzo Bianconi [Tue, 18 Sep 2018 12:12:05 +0000 (14:12 +0200)]
mt76: usb: remove WARN_ON in mt76u_get_rx_entry_len

Remove not useful WARN_ON macros in mt76u_get_rx_entry_len routine
since corrupted frames should just be silently discarded

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x2_tssi_enabled in mt76x02_eeprom.h
Lorenzo Bianconi [Thu, 20 Sep 2018 09:12:04 +0000 (11:12 +0200)]
mt76: move mt76x2_tssi_enabled in mt76x02_eeprom.h

Move mt76x2_tssi_enabled and mt76x02_temp_tx_alc_enabled in
mt76x02_eeprom.h in order to be reused in mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: unify parse hw capabilities
Lorenzo Bianconi [Thu, 20 Sep 2018 09:12:03 +0000 (11:12 +0200)]
mt76x0: unify parse hw capabilities

Unify parse hw capabilities with mt76x2 driver using
mt76x02_eeprom_parse_hw_cap utility routine available
in mt76x02-lib module

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x02_eeprom_parse_hw_cap in mt76x02-lib module
Lorenzo Bianconi [Thu, 20 Sep 2018 09:12:02 +0000 (11:12 +0200)]
mt76: move mt76x02_eeprom_parse_hw_cap in mt76x02-lib module

Move mt76x02_eeprom_parse_hw_cap utility routine in mt76x02-lib
module in order to be reused in mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: unify freq offset parsing
Lorenzo Bianconi [Thu, 20 Sep 2018 09:12:01 +0000 (11:12 +0200)]
mt76x0: unify freq offset parsing

Unify frequency offset parsing with mt76x2 driver using
eeprom utility routines available in mt76x02-lib module

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: unify temperature offset parsing
Lorenzo Bianconi [Thu, 20 Sep 2018 09:12:00 +0000 (11:12 +0200)]
mt76x0: unify temperature offset parsing

Unify temperature offset parsing with mt76x2 driver using
eeprom utility routines available in mt76x02-lib module

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: unify rssi_offset parsing
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:59 +0000 (11:11 +0200)]
mt76x0: unify rssi_offset parsing

Unify rssi_offset parsing with mt76x2 driver using eeprom utility
routines available in mt76x02-lib module

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: unify lna_gain parsing
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:58 +0000 (11:11 +0200)]
mt76x0: unify lna_gain parsing

Unify lna gain parsing with mt76x2 driver using eeprom utility
routines available in mt76x02-lib module

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add mt76x02_get_rx_gain and mt76x02_get_lna_gain utility routines
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:57 +0000 (11:11 +0200)]
mt76: add mt76x02_get_rx_gain and mt76x02_get_lna_gain utility routines

Add mt76x02_get_rx_gain and mt76x02_get_lna_gain utility routines
for rx gain parsing. mt76x02_get_rx_gain and mt76x02_get_lna_gain
will be reused for eeprom parsing in mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove mt76x0_set_country_reg routine
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:56 +0000 (11:11 +0200)]
mt76x0: remove mt76x0_set_country_reg routine

Remove mt76x0_set_country_reg routine for the moment
since it is partial and it is not actually used

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x2_ext_pa_enabled routine in mt76x02_eeprom.c
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:55 +0000 (11:11 +0200)]
mt76: move mt76x2_ext_pa_enabled routine in mt76x02_eeprom.c

Move mt76x2_ext_pa_enabled utility routine in mt76x02_eeprom.c
and remove duplicated code. This is a preliminary patch to
unify eeprom code between mt76x2 and mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x2_get_efuse_data in mt76x02-lib module
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:54 +0000 (11:11 +0200)]
mt76: move mt76x2_get_efuse_data in mt76x02-lib module

Move mt76x2_efuse_read and mt76x2_get_efuse_data in mt76x02_eeprom.c
in order to be reused in mt76x0 driver for eeprom parsing

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x02_mac_setaddr in mt76x02-lib module
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:53 +0000 (11:11 +0200)]
mt76: move mt76x02_mac_setaddr in mt76x02-lib module

Move mt76x02_mac_setaddr utility routine in mt76x02-lib
module and remove duplicated code. This is a preliminary patch
to unify eeprom code between mt76x2 and mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x2_eeprom_get in mt76x02_eeprom.h
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:52 +0000 (11:11 +0200)]
mt76: move mt76x2_eeprom_get in mt76x02_eeprom.h

Move mt76x2_eeprom_get utility routine in mt76x02_eeprom.h since
it will be used to parse mt76x0 eeprom in order to unify eeprom
support between mt76x2 and mt76x0 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move eeprom utility routines in mt76x02_eeprom.h
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:51 +0000 (11:11 +0200)]
mt76: move eeprom utility routines in mt76x02_eeprom.h

Move shared eeprom utility routines in mt76x02_eeprom.h and
remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move common eeprom definitions in mt76x02-lib module
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:50 +0000 (11:11 +0200)]
mt76: move common eeprom definitions in mt76x02-lib module

Move mt76x2 and mt76x0 common definitions in mt76x02_eeprom.h
and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add stbc entries to mt76_rate_power
Felix Fietkau [Thu, 20 Sep 2018 09:11:49 +0000 (11:11 +0200)]
mt76: add stbc entries to mt76_rate_power

Add stbc tx power eeprom parsing support for mt76x2 driver.
When writing power entries, make a distinction between rates that are
read from the same EEPROM value, but have separate register entries.

No effect on runtime behavior, but preparation for unification with mt76x0
and for placing restrictions on individual rate power limits

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move seq_put_array in mt76-core module
Lorenzo Bianconi [Thu, 20 Sep 2018 09:11:48 +0000 (11:11 +0200)]
mt76: move seq_put_array in mt76-core module

Move seq_put_array utility routine in mt76-core module
in order to be reused in mt76x0 driver

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: pci: add fw uploading routine
Lorenzo Bianconi [Wed, 19 Sep 2018 11:53:58 +0000 (13:53 +0200)]
mt76x0: pci: add fw uploading routine

Add pci load firmware routine. Move some shared mcu definitions
in mt76x02_mcu.h

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: pci: add mt7650 PCI ID
Lorenzo Bianconi [Wed, 19 Sep 2018 11:42:44 +0000 (13:42 +0200)]
mt76x0: pci: add mt7650 PCI ID

Add mt7650 PCI id found on ASUS rt-51ac to pci_device_id table

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: fix tx power configuration for VHT mcs 9
Lorenzo Bianconi [Fri, 21 Sep 2018 13:57:50 +0000 (15:57 +0200)]
mt76x2: fix tx power configuration for VHT mcs 9

Fix tx power configuration for VHT 1SS/STBC mcs 9 since
in MT_TX_PWR_CFG_{8,9} mcs 8,9 bits are GENMASK(21,16) and
GENMASK(29,24) while GENMASK(15,6) are marked as reserved

Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agoqtnfmac: remove set but not used variable 'vif'
YueHaibing [Tue, 11 Sep 2018 12:28:24 +0000 (12:28 +0000)]
qtnfmac: remove set but not used variable 'vif'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/quantenna/qtnfmac/cfg80211.c: In function 'qtnf_dump_survey':
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c:694:19: warning:
 variable 'vif' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcmsmac: Use kvmalloc() for ucode allocations
Takashi Iwai [Thu, 13 Sep 2018 06:15:17 +0000 (08:15 +0200)]
brcmsmac: Use kvmalloc() for ucode allocations

The ucode chunk might be relatively large and the allocation with
kmalloc() may fail occasionally.  Since the data isn't DMA-transferred
but by manual loops, we can use vmalloc instead of kmalloc.
For a better performance, though, kvmalloc() would be the best choice
in such a case, so let's replace with it.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1103431
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcmfmac: remove set but not used variables 'sfdoff' and 'pad_size'
YueHaibing [Tue, 11 Sep 2018 03:24:04 +0000 (11:24 +0800)]
brcmfmac: remove set but not used variables 'sfdoff' and 'pad_size'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c: In function 'brcmf_sdio_rxglom':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:1466:11: warning:
 variable 'sfdoff' set but not used [-Wunused-but-set-variable]

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c: In function 'brcmf_sdio_bus_preinit':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:3408:7: warning:
 variable 'pad_size' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcm80211: remove redundant condition check before debugfs_remove_recursive
zhong jiang [Sat, 8 Sep 2018 13:40:43 +0000 (21:40 +0800)]
brcm80211: remove redundant condition check before debugfs_remove_recursive

debugfs_remove_recursive has taken IS_ERR_OR_NULL into account. So just
remove the condition check before debugfs_remove_recursive.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcmfmac: increase buffer for obtaining firmware capabilities
Arend van Spriel [Wed, 5 Sep 2018 07:48:59 +0000 (09:48 +0200)]
brcmfmac: increase buffer for obtaining firmware capabilities

When obtaining the firmware capability a buffer is provided of 512
bytes. However, if all features in firmware are supported the buffer
needs to be 565 bytes as otherwise truncated information is retrieved
from firmware. Increasing the buffer to 768 bytes on stack.

Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agobrcmfmac: fix for proper support of 160MHz bandwidth
Arend van Spriel [Wed, 5 Sep 2018 07:48:58 +0000 (09:48 +0200)]
brcmfmac: fix for proper support of 160MHz bandwidth

Decoding of firmware channel information was not complete for 160MHz
support. This resulted in the following warning:

  WARNING: CPU: 2 PID: 2222 at .../broadcom/brcm80211/brcmutil/d11.c:196
brcmu_d11ac_decchspec+0x2e/0x100 [brcmutil]
  Modules linked in: brcmfmac(O) brcmutil(O) sha256_generic cfg80211 ...
  CPU: 2 PID: 2222 Comm: kworker/2:0 Tainted: G           O
  4.17.0-wt-testing-x64-00002-gf1bed50 #1
  Hardware name: Dell Inc. Latitude E6410/07XJP9, BIOS A07 02/15/2011
  Workqueue: events request_firmware_work_func
  RIP: 0010:brcmu_d11ac_decchspec+0x2e/0x100 [brcmutil]
  RSP: 0018:ffffc90000047bd0 EFLAGS: 00010206
  RAX: 000000000000e832 RBX: ffff8801146fe910 RCX: ffff8801146fd3c0
  RDX: 0000000000002800 RSI: 0000000000000070 RDI: ffffc90000047c30
  RBP: ffffc90000047bd0 R08: 0000000000000000 R09: ffffffffa0798c80
  R10: ffff88012bca55e0 R11: ffff880110a4ea00 R12: ffff8801146f8000
  R13: ffffc90000047c30 R14: ffff8801146fe930 R15: ffff8801138e02e0
  FS:  0000000000000000(0000) GS:ffff88012bc80000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 00007f18ce8b8070 CR3: 000000000200a003 CR4: 00000000000206e0
  Call Trace:
   brcmf_setup_wiphybands+0x212/0x780 [brcmfmac]
   brcmf_cfg80211_attach+0xae2/0x11a0 [brcmfmac]
   brcmf_attach+0x1fc/0x4b0 [brcmfmac]
   ? __kmalloc+0x13c/0x1c0
   brcmf_pcie_setup+0x99b/0xe00 [brcmfmac]
   brcmf_fw_request_done+0x16a/0x1f0 [brcmfmac]
   request_firmware_work_func+0x36/0x60
   process_one_work+0x146/0x350
   worker_thread+0x4a/0x3b0
   kthread+0x102/0x140
   ? process_one_work+0x350/0x350
   ? kthread_bind+0x20/0x20
   ret_from_fork+0x35/0x40
  Code: 66 90 0f b7 07 55 48 89 e5 89 c2 88 47 02 88 47 03 66 81 e2 00 38
66 81 fa 00 18 74 6e 66 81 fa 00 20 74 39 66 81 fa 00 10 74 14 <0f>
0b 66 25 00 c0 74 20 66 3d 00 c0 75 20 c6 47 04 01 5d c3 66
  ---[ end trace 550c46682415b26d ]---
  brcmfmac: brcmf_construct_chaninfo: Ignoring unexpected firmware channel 50

This patch adds the missing stuff to properly handle this.

Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
6 years agoMerge tag 'mt76-for-kvalo-2018-09-19' of https://github.com/nbd168/wireless
Kalle Valo [Thu, 20 Sep 2018 11:15:40 +0000 (14:15 +0300)]
Merge tag 'mt76-for-kvalo-2018-09-19' of https://github.com/nbd168/wireless

mt76 patches for 4.20

* lots of mt76x0 cleanups / fixes
* mt76x2u fixes
* unify code between mt76x0, mt76x2e and mt76x2u
* rename mt76x0 to mt76x0u
* improve rx buffer allocation for all variants
* prepare for adding mt76x0e (pci-e variant) support
  add CONFIG_MT76x0E kconfig symbol

6 years agomt76x0: usb: remove mt76_fw definition
Lorenzo Bianconi [Wed, 12 Sep 2018 15:19:36 +0000 (17:19 +0200)]
mt76x0: usb: remove mt76_fw definition

Remove mt76_fw dependency from mt76x0u_upload_firmware routine since
it does not define firmware layout properly. Moreover use mt76_poll_msec
utility routine to check if the fw is properly running

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove unused usb header file
Lorenzo Bianconi [Tue, 11 Sep 2018 21:09:30 +0000 (23:09 +0200)]
mt76x0: remove unused usb header file

Remove unused usb header file and move mt76x0 firmware definition
in usb.c

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove mcu source file
Lorenzo Bianconi [Tue, 11 Sep 2018 21:09:29 +0000 (23:09 +0200)]
mt76x0: remove mcu source file

Remove mcu.c source file since it contains just 'one-line' function
that is shared between PCI and USB code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: usb: move firmware loading to usb.c
Stanislaw Gruszka [Tue, 11 Sep 2018 21:09:28 +0000 (23:09 +0200)]
mt76x0: usb: move firmware loading to usb.c

Firmware loading is usb specific, move it to usb.c file.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: use a per rx queue page fragment cache
Felix Fietkau [Fri, 13 Jul 2018 14:26:15 +0000 (16:26 +0200)]
mt76: use a per rx queue page fragment cache

Using the NAPI or netdev frag cache along with other drivers can lead to
32 KiB pages being held for a long time, despite only being used for
very few page fragments.

This can happen if the driver grabs one or two fragments for rx ring
refill, while other drivers use (and free up) the remaining fragments.
The 32 KiB higher-order page can only be freed once all users have freed
their fragments.

Depending on the traffic patterns, this can waste a lot of memory and
look a lot like a memory leak.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: move mt76x2_phy_tssi_compensate in mt76x2-common module
Lorenzo Bianconi [Sun, 9 Sep 2018 21:58:05 +0000 (23:58 +0200)]
mt76x2: move mt76x2_phy_tssi_compensate in mt76x2-common module

Move mt76x2_phy_tssi_compensate routine in mt76x2-common module
since it is shared between mt76x2 and mt76x2u drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move shared mcu_calibrate routine in mt76x02-lib module
Lorenzo Bianconi [Sun, 9 Sep 2018 21:58:04 +0000 (23:58 +0200)]
mt76: move shared mcu_calibrate routine in mt76x02-lib module

Move mcu_calibrate routine in mt76x02-lib module since it is
shared between USB and PCI code. Moreover remove duplicated
code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: move mt76x2 mcu shared code in mt76x2_mcu_common.c
Lorenzo Bianconi [Sun, 9 Sep 2018 21:58:03 +0000 (23:58 +0200)]
mt76x2: move mt76x2 mcu shared code in mt76x2_mcu_common.c

Move shared mt76x2 {pcie/usb} mcu shared code in a common file
and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76{0,2} mcu shared code in mt76x02_mcu.c
Lorenzo Bianconi [Sun, 9 Sep 2018 21:58:02 +0000 (23:58 +0200)]
mt76: move mt76{0,2} mcu shared code in mt76x02_mcu.c

Move shared mt76x2/mt76x0 mcu shared code in a common file
and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: unify firmware header between mt76x0 and mt76x2
Lorenzo Bianconi [Sun, 9 Sep 2018 21:58:01 +0000 (23:58 +0200)]
mt76: unify firmware header between mt76x0 and mt76x2

Move mt76x2_fw_header definition in mt76x02_mcu.h and remove
duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: use common helpers for mcu_alloc_msg()/mcu_send_msg()
Lorenzo Bianconi [Sun, 9 Sep 2018 21:58:00 +0000 (23:58 +0200)]
mt76x2: use common helpers for mcu_alloc_msg()/mcu_send_msg()

Use mcu common helpers instead of mt76x2 specific routines for
mcu_alloc_msg()/mcu_send_msg(). This is a preliminary patch to
unify mt76e and mt76u mcu code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: use mt76_dev instead of mt76x2_dev in mt76x2_mcu_msg_send
Lorenzo Bianconi [Sun, 9 Sep 2018 21:57:59 +0000 (23:57 +0200)]
mt76x2: use mt76_dev instead of mt76x2_dev in mt76x2_mcu_msg_send

Use mt76_dev data structure instead of mt76x2_dev one in mt76x2_mcu_msg_send
and mt76x2_mcu_get_response routines. Moreover add wait_resp parameter to
mt76x2_mcu_msg_send signature. This is a preliminary patch in order to unify
mcu_msg_alloc()/mcu_msg_send() between pcie and usb code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move __iomem regs in mt76_mmio
Lorenzo Bianconi [Sun, 9 Sep 2018 21:57:58 +0000 (23:57 +0200)]
mt76: move __iomem regs in mt76_mmio

Move __iomem regs pointer in mt76_mmio data structure

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: introduce mmio data structure in mt76_dev
Lorenzo Bianconi [Sun, 9 Sep 2018 21:57:57 +0000 (23:57 +0200)]
mt76: introduce mmio data structure in mt76_dev

Introduce mt76_mmio data structure in mt76_dev and
move mt76x2_mcu in mt76_mmio. This is a preliminary
patch to unify mcu code between mt76x02{e,u} drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: remove leftover mt76u_buf data structure in mt76x2_mcu
Lorenzo Bianconi [Sun, 9 Sep 2018 21:57:56 +0000 (23:57 +0200)]
mt76x2: remove leftover mt76u_buf data structure in mt76x2_mcu

Remove unused usb buffer in mt76x2_mcu data structure

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x2: use mt76_dev instead of mt76x2_dev in mt76x2_tx_queue_mcu
Lorenzo Bianconi [Sun, 9 Sep 2018 21:57:55 +0000 (23:57 +0200)]
mt76x2: use mt76_dev instead of mt76x2_dev in mt76x2_tx_queue_mcu

Use mt76_dev data structure instead of mt76x2_dev one in
mt76x2_tx_queue_mcu routine. This is a preliminary patch
to share mcu code between mt76x2e and mt76x0e

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: usb: remove skb check in mt76x{0,2}u mcu routines
Lorenzo Bianconi [Sun, 9 Sep 2018 21:57:54 +0000 (23:57 +0200)]
mt76: usb: remove skb check in mt76x{0,2}u mcu routines

Remove mt76_mcu_msg_alloc return value check since it is already
evaluated in __mt76x02u_mcu_send_msg

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove mt76x0_burst_write_regs()
Stanislaw Gruszka [Sun, 9 Sep 2018 20:32:46 +0000 (22:32 +0200)]
mt76x0: remove mt76x0_burst_write_regs()

We don't need to use custom burst write regs via MCU, we can use
generic mt76_wr_copy() for the same purpose.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: remove unused mt76x0_burst_read_regs
Stanislaw Gruszka [Sun, 9 Sep 2018 20:32:45 +0000 (22:32 +0200)]
mt76x0: remove unused mt76x0_burst_read_regs

mt76x0_burst_read_regs is not used, but keep it for eventual use. Since
we have this function now in the driver git history, we can remove it and
eventually revert this commit it the function will be needed.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x02: add static qualifier to mt76x02_remove_dma_hdr
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:44 +0000 (22:32 +0200)]
mt76x02: add static qualifier to mt76x02_remove_dma_hdr

Add static qualifier to mt76x02_remove_dma_hdr routine and
do not export the symbol since it is only used in mt76x02_util.c

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x02: move TXD/RXD/MCU definitions in mt76x02_dma.h
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:43 +0000 (22:32 +0200)]
mt76x02: move TXD/RXD/MCU definitions in mt76x02_dma.h

Introduce mt76x02_dma.h header file to contain mt76x02 dma
related definitions

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: usb: move mt76u_skb_dma_info in mt76x02_usb_core.c
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:42 +0000 (22:32 +0200)]
mt76: usb: move mt76u_skb_dma_info in mt76x02_usb_core.c

Move mt76u_skb_dma_info routine in mt76x02-usb module and rename it in
mt76x02u_skb_dma_info. Moreover move mt76x02u_set_txinfo in
mt76x02_usb_core.c. This is a preliminary patch to move MT_TXD_INFO,
MT_MCU_MSG and MT_RX_FCE_INFO defs in mt76x02-lib module since other
chipsets (e.g. mt7603) use different dma definitions

Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: usb: move mt76x02 mcu code in mt76x02-usb module
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:41 +0000 (22:32 +0200)]
mt76: usb: move mt76x02 mcu code in mt76x02-usb module

Introduce mt76x02_usb_mcu.c in order to contain mt76x02u mcu related
code. Add mt76x02-usb module as a container for mt76x02 usb code.
This is a preliminary patch to move MT_TXD_INFO, MT_MCU_MSG and
MT_RX_FCE_INFO defs in mt76x02-lib module since other chipsets (e.g.
mt7603) use different dma definitions

Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: usb: use common helpers for mcu_alloc_msg()/mcu_send_msg()
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:40 +0000 (22:32 +0200)]
mt76: usb: use common helpers for mcu_alloc_msg()/mcu_send_msg()

Use mcu common helpers instead of usb specific routines.
Add static qualifier to the following functions:
- mt76u_mcu_msg_alloc
- __mt76u_mcu_send_msg
- mt76u_mcu_send_msg
- mt76u_mcu_wr_rp
- mt76u_mcu_rd_rp
- mt76u_wr_rp
- mt76u_rd_rp
This is a preliminary patch to move mt76x02 usb mcu code in
mt76x02-usb module

Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add rd_rp and wr_rp to bus_ops/mcu_ops
Stanislaw Gruszka [Sun, 9 Sep 2018 20:32:39 +0000 (22:32 +0200)]
mt76: add rd_rp and wr_rp to bus_ops/mcu_ops

Add callbacks for reading and writing reg pairs tables.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add usb implementation of {wr,rd}_rp
Stanislaw Gruszka [Sun, 9 Sep 2018 20:32:38 +0000 (22:32 +0200)]
mt76: add usb implementation of {wr,rd}_rp

Add USB implementation for read and write reg pair routines.
The actual implementation can use mcu related routines according to
MCU state

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: add mt76_mcu_ops data structure for mcu related pointers
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:37 +0000 (22:32 +0200)]
mt76: add mt76_mcu_ops data structure for mcu related pointers

Introduce mt76_mcu_ops data structure to contain mcu related function
pointers. This is a preliminary patch to move mt76x02 usb mcu code in
mt76x02-usb module

Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76: move mt76x0 and mt76x2 mcu shared defs in mt76x02_mcu.h
Lorenzo Bianconi [Sun, 9 Sep 2018 20:32:36 +0000 (22:32 +0200)]
mt76: move mt76x0 and mt76x2 mcu shared defs in mt76x02_mcu.h

Move mt76x0 and mt76x2 mcu shared definition in mt76x02_mcu.h
and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: run vco calibration for each channel configuration
Lorenzo Bianconi [Fri, 7 Sep 2018 21:13:12 +0000 (23:13 +0200)]
mt76x0: run vco calibration for each channel configuration

According to vendor sdk, vco calibration has to be executed
for each channel configuration whereas mcu calibration has to be
performed during channel scanning. This patch fixes the mt76x0
monitor mode issue since in that configuration vco calibration
was never executed

Fixes: 10de7a8b4ab9 ("mt76x0: phy files")
Tested-by: Sid Hayn <sidhayn@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years agomt76x0: make device allocation bus neutral
Stanislaw Gruszka [Thu, 6 Sep 2018 09:18:58 +0000 (11:18 +0200)]
mt76x0: make device allocation bus neutral

Remove some USB specific code form mt76x0_alloc_device.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>