Felix Fietkau [Wed, 12 Feb 2020 08:07:49 +0000 (09:07 +0100)]
mt76: mt7615: rework rx phy index handling
Overwriting the RMAC_CHFREQ register is not reliable enough, as the firmware
could potentially write it again.
Since there is no PHY index indication in the rx info, we need to use another
way:
If both PHYs are using different channels, find the PHY where chfreq matches
the register value.
The only corner case remaining is when both PHYs are using the same channel.
In that case, the per-packet noise value on the primary PHY will have
information belonging to the chains of the secondary PHY from the previous
received packet of that PHY. The secondary PHY will set noise to 0 for extra
chains.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 11 Feb 2020 20:00:56 +0000 (21:00 +0100)]
mt76: fix rounding issues on converting per-chain and combined txpower
Unify code converting between the different txpower values. Always add/remove
the combined txpower delta before dividing half-dB values.
Also fix the combined txpower delta values. The correct half-dB delta for
3 chains is 9, not 8.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 6 Feb 2020 17:31:08 +0000 (18:31 +0100)]
mt76: mt76x2: avoid starting the MAC too early
Do not set the tx/rx start bits in MT_MAC_SYS_CTRL from within initvals.
The driver sets these later when the hardware is ready
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 6 Feb 2020 17:30:08 +0000 (18:30 +0100)]
mt76: avoid extra RCU synchronization on station removal
Use sta_pre_rcu_remove callback to clear wcid pointer earlier
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Sun, 2 Feb 2020 15:24:08 +0000 (16:24 +0100)]
mt76: mt7615: fix monitor mode on second PHY
The second PHY receives no packets unless there is an active vif present.
Set the WANT_MONITOR_VIF flag to deal with that
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Sun, 2 Feb 2020 15:12:49 +0000 (16:12 +0100)]
mt76: mt7615: fix adding active monitor interfaces
Treat them the same as AP iftype internally for MCU commands
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:52 +0000 (23:33 +0800)]
mt76: mt7615: switch mt7615_mcu_set_rx_ba to v2 format
To adapt new firmware version.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Tested-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:51 +0000 (23:33 +0800)]
mt76: mt7615: switch mt7615_mcu_set_tx_ba to v2 format
To adapt new firmware version.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Tested-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:50 +0000 (23:33 +0800)]
mt76: mt7615: use new tag sta_rec_wtbl
In order to reduce command/event times, newer firmware adds a tag
sta_rec_wtbl to take care of WTBL operations.
MCU_EXT_CMD_WTBL_UPDATE is deprecated.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Tested-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:49 +0000 (23:33 +0800)]
mt76: mt7615: add starec operating flow for firmware v2
Add fw_ver in mt7615_dev to check firmware version, and adjust
mt7615_mcu_send_sta_rec() to adapt firmware v2 changes.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Tested-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:48 +0000 (23:33 +0800)]
mt76: mt7615: add a helper to encapsulate sta_rec operation
Operating command is simpler and just as clear
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Tested-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:47 +0000 (23:33 +0800)]
mt76: mt7615: simplify mcu_set_sta flow
Move mcu_add_wtbl and mcu_set_ht_cap into mcu_set_sta to simplify flow.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 1 Feb 2020 15:33:46 +0000 (23:33 +0800)]
mt76: mt7615: simplify mcu_set_bmc flow
Move set_bmc_wtbl into sta_rec function to simplify flow.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Fri, 31 Jan 2020 10:10:29 +0000 (11:10 +0100)]
mt76: mt7615: add support for testing hardware reset
Send an undersized corrupt packet to the DMA queue, which causes the
firmware to issue a full chip reset
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 30 Jan 2020 16:42:55 +0000 (17:42 +0100)]
mt76: mt7615: implement hardware reset support
When the firmware detects a problem, it needs the host to stop/reset DMA and
resume it again when the hardware state has been reset.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Sun, 29 Dec 2019 12:49:18 +0000 (13:49 +0100)]
mt76: mt7615: report firmware log event messages
Useful for debugging firmware issues. Can be turned on via the "fw_debug"
debugfs file
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 30 Jan 2020 13:12:43 +0000 (14:12 +0100)]
mt76: mt7615: fix and rework tx power handling
Setting the tx power by manipulating EEPROM may in some cases not be enough,
since it only covers the base target power and not per-rate offsets.
In other cases, it could limit tx power of rates too much, possibly reducing
throughput or range.
Use firmware support for applying per-rate limit and power offsets for
different values of Nss.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Wed, 18 Dec 2019 16:49:59 +0000 (17:49 +0100)]
mt76: mt7615: add Kconfig entry for MT7622
This enables building support for the MT7622 SoC built-in WLAN chip
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Sat, 21 Dec 2019 21:57:07 +0000 (22:57 +0100)]
mt76: mt7615: disable DBDC on MT7622
It is only supported on MT7615
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 19 Dec 2019 21:21:44 +0000 (22:21 +0100)]
mt76: mt7615: decrease rx ring size for MT7622
Since it's 2.4 GHz only, it needs fewer buffers
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Wed, 18 Dec 2019 16:46:27 +0000 (17:46 +0100)]
mt76: mt7615: implement DMA support for MT7622
MT7622 does not have the CR4 microcontroller sitting in the data path.
Because of that, it uses the chip's native tx descriptor format instead of
something parsed and converted by the firmware.
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Felix Fietkau [Wed, 18 Dec 2019 09:48:23 +0000 (10:48 +0100)]
mt76: mt7615: implement probing and firmware loading on MT7622
MT7622 does not have a CR4 microcontroller, so it only uses its own N9
firmware.
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Wed, 18 Dec 2019 10:15:20 +0000 (11:15 +0100)]
mt76: mt7615: disable 5 GHz on MT7622
It is not supported by the chip, so avoid issues with potentially wrong
EEPROM configurations.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 19 Dec 2019 21:57:40 +0000 (22:57 +0100)]
mt76: mt7615: add calibration free support for MT7622
MT7622 uses fewer efuse overrides than MT7615
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 Dec 2019 11:56:00 +0000 (12:56 +0100)]
mt76: mt7615: add eeprom support for MT7622
When sending EEPROM data to the MCU, MT7622 uses a longer buffer
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 Dec 2019 05:49:29 +0000 (06:49 +0100)]
mt76: mt7615: add dma and tx queue initialization for MT7622
MT7622 queue mapping is different from MT7615 and requires an extra dma
scheduler init and a few register tweaks
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 16 Dec 2019 17:27:42 +0000 (18:27 +0100)]
mt76: mt7615: fix MT_INT_TX_DONE_ALL definition for MT7622
MT7622 uses more interrupt bits for queue tx completion events.
Enabling those extra bits is harmless on MT7615
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 Dec 2019 03:59:05 +0000 (04:59 +0100)]
mt76: mt7615: store N9 firmware version instead of CR4
CR4 is used very little, N9 is the main firmware that the driver interacts with
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Tue, 17 Dec 2019 03:57:50 +0000 (04:57 +0100)]
mt76: mt7615: split up firmware loading functions
Preparation for adding MT7622 support
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 16 Dec 2019 17:39:44 +0000 (18:39 +0100)]
mt76: mt7615: move mmio related code from pci.c to mmio.c
Will be shared with MT7622 SoC support
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Wed, 18 Dec 2019 13:24:47 +0000 (14:24 +0100)]
mt76: mt7615: add __aligned(4) to txp structs
The beginning of the struct is guaranteed to be 4-byte aligned, and this
attribute allows the compiler to generate more efficient code
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 30 Jan 2020 12:22:25 +0000 (13:22 +0100)]
dt-bindings: net: wireless: mt76: document bindings for MT7622
MT7622 is a SoC that includes a 2.4 GHz 4x4 802.11n WMAC. Its
feature set is comparable to a MT7615 chip, but limited to 2.4 GHz.
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 20 Jan 2020 11:16:26 +0000 (12:16 +0100)]
mt76: enable Airtime Queue Limit support
It is supported by all drivers
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 20 Jan 2020 11:14:56 +0000 (12:14 +0100)]
mt76: mt7603: increase dma mcu rx ring size
The ring is used for looping back tx powersave filtered frames, so it could
use some more room, in case more than one aggregate was queued
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 20 Jan 2020 11:11:07 +0000 (12:11 +0100)]
mt76: dma: do not write cpu_idx on rx queue reset until after refill
The hardware should only start processing the ring after at least one
buffer has been added
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 20 Jan 2020 11:08:30 +0000 (12:08 +0100)]
mt76: fix handling full tx queues in mt76_dma_tx_queue_skb_raw
Fixes a theoretical issue where it could potentially overwrite an existing
descriptor entry (and leaking its skb)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 20 Jan 2020 11:07:09 +0000 (12:07 +0100)]
mt76: set dma-done flag for flushed descriptors
Avoids a theoretical corner case where the hardware could try to process
a stale descriptor after a watchdog reset
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:58 +0000 (11:58 +0100)]
mt76: mt76u: introduce MT_DRV_RX_DMA_HDR flag
Define MT_DRV_RX_DMA_HDR flag in drv_flag in order to not skip rx frame
dma header since new devices (e.g. mt7663u) reports rx frame info in the
usb dma header
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:57 +0000 (11:58 +0100)]
mt76: mt76u: add endpoint to mt76u_bulk_msg signature
This is a preliminary patch to support mt7663u usb dongles
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:56 +0000 (11:58 +0100)]
mt76: mt76u: introduce mt76u_skb_dma_info routine
Introduce mt76u_skb_dma_info utility routine in mt76-usb module in order
to be reused adding mt7663u support
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:55 +0000 (11:58 +0100)]
mt76: mt76u: take into account different queue mapping for 7663
7663u devices rely on a different endpoint mapping. Take it into account
in mt76u_alloc_tx routine
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:54 +0000 (11:58 +0100)]
mt76: mt76u: add {read/write}_extended utility routines
Introduce extended utility routines to read/write data o usb bus. New
devices (e.g. mt7663u) will rely on both upper and lower part of the
register address. Add ext parameter to mt76u_init signature in order to
reuse the code adding mt7663u support.
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:53 +0000 (11:58 +0100)]
mt76: mt76u: introduce mt76u_alloc_mcu_queue utility routine
Add mt76u_alloc_mcu_queue utility routine to allocate mcu hw rx queue.
This is a preliminary patch to support new devices (e.g. mt7663u) that
rely on a hw queue for mcu messages
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:52 +0000 (11:58 +0100)]
mt76: mt76u: resume all rx queue in mt76u_resume_rx
Resume all possible rx queues after suspend. This is a preliminary patch
to support mt7663u devices
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:51 +0000 (11:58 +0100)]
mt76: mt76u: add queue parameter to mt76u_rx_urb_alloc
Add mt76_queue parameter to mt76u_rx_urb_alloc signature since this
routine will be used to allocate urbs for mcu hw queue used by new
chipset generation (e.g. mt7663u). Check sg_max_size in in
mt76u_urb_alloc in order to use linear urb for mcu queue
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:50 +0000 (11:58 +0100)]
mt76: mt76u: add mt76u_alloc_rx_queue utility routine
Introduce mt76u_alloc_rx_queue routine to allocate rx hw queue.
This is a preliminary patch to support new devices (e.g. mt7663u) that
rely on a hw queue for mcu messages
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:49 +0000 (11:58 +0100)]
mt76: mt76u: stop/free all possible rx queues
Stop/free all configured rx queues (data/mcu) in
mt76u_stop_rx/mt76u_free_rx. This is a preliminary patch to support new
devices (e.g. mt7663u) that rely on a hw queue for mcu messages
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:48 +0000 (11:58 +0100)]
mt76: mt76u: introduce mt76u_free_rx_queue utility routine
Introduce mt76u_free_rx_queue utility routine to free rx hw queue.
This is a preliminary patch to support new devices (e.g. mt7663u) that
rely on a hw queue for mcu messages
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:47 +0000 (11:58 +0100)]
mt76: mt76u: move mcu buffer allocation in mt76x02u drivers
Move mcu buffer allocation in mt76x2u/mt76x0u drivers since newer
chipsets (e.g. mt7663u) does not rely on synchronous mcu communication
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:46 +0000 (11:58 +0100)]
mt76: mt76u: add queue id parameter to mt76u_submit_rx_buffers
Add queue_id parameter to mt76u_submit_rx_buffers in order to reuse it
adding mt7663u support
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:45 +0000 (11:58 +0100)]
mt76: mt76u: use mt76_queue as mt76u_complete_rx context
In order to reuse mt76u_complete_rx for both data and mcu rx queue, rely
on mt76_queue as urb context in mt76u_complete_rx. Moreover set usb rx
endoint according to rx queue in mt76u_submit_rx_buf. This is a
preliminary patch to add mt7663u support
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:44 +0000 (11:58 +0100)]
mt76: mt76u: add mt76_queue to mt76u_refill_rx signature
Introduce mt76_queue parameter to mt76u_refill_rx signature in order to
reuse it for mcu hw rx queue
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:43 +0000 (11:58 +0100)]
mt76: mt76u: add mt76_queue to mt76u_get_next_rx_entry signature
Rely on mt76_queue pointer in mt76u_get_next_rx_entry in order to add
support for new devices (e.g 7663u) that reports fw events through hw rx
mcu queue
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:42 +0000 (11:58 +0100)]
mt76: mt76u: add mt76u_process_rx_queue utility routine
Introduce mt76u_process_rx_queue routine to process rx hw queue.
This is a preliminary patch to support new devices (e.g. mt7663u) that
rely on a hw queue for mcu messages
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 15 Jan 2020 10:58:41 +0000 (11:58 +0100)]
mt76: mt76u: check tx_status_data pointer in mt76u_tx_tasklet
New devices (e.g. mt7663u) do not rely on stats workqueue to load tx
statistics but will be reported by the firmware. Check tx_status_data
pointer in mt76u_tx_tasklet in order to reuse tx tasklet for new devices
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 23 Dec 2019 13:03:32 +0000 (14:03 +0100)]
mt76: mt76x02u: avoid overwrite max_tx_fragments
Starting from 'commit
ee8040139ab1 ("mt76: do not overwrite
max_tx_fragments if it has been set")' we can avoid overwriting
max_tx_fragments for mt76x02u devices
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 9 Dec 2019 16:53:04 +0000 (17:53 +0100)]
mt76: rely on mac80211 utility routines to compute airtime
Rely on mac80211 airitme utility routines and remove mt76 duplicated code
to estimate tx/rx airtime
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Thu, 9 Jan 2020 13:26:53 +0000 (14:26 +0100)]
mt76: mt7615: remove leftover routine declaration
Get rid of mt76_dfs_start_rdd unused declaration
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Tue, 7 Jan 2020 13:59:34 +0000 (14:59 +0100)]
mt76: move WIPHY_FLAG_HAS_CHANNEL_SWITCH in mt76_phy_init
Move WIPHY_FLAG_HAS_CHANNEL_SWITCH in mt76-core module since now all
drivers support Channel Switch Announcement
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Wed, 1 Jan 2020 05:56:25 +0000 (13:56 +0800)]
mt76: mt7615: fix endianness in mt7615_mcu_set_eeprom
The field 'u16 len' should be __le16.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Tue, 31 Dec 2019 12:25:23 +0000 (13:25 +0100)]
mt76: mt7615: initialize radar specs from host driver
Introduce dfs radar pattern specs in mt7615 driver in order to make
dfs debugging easier. Radar pulse/pattern thresholds are taken from
vendor SDK.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 29 Dec 2019 10:03:08 +0000 (11:03 +0100)]
mt76: mt76x2: get rid of leftover target
Remove tracing leftover target in mt76x2 Makefile
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 29 Dec 2019 10:03:07 +0000 (11:03 +0100)]
mt76: mt7615: add tracing support
Introduce token tracing support in mt7615_mac_tx_free routine
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 29 Dec 2019 10:03:06 +0000 (11:03 +0100)]
mt76: move mac_txdone tracepoint in mt76 module
Move mac_txdone tracepoint in common code in order to
be reused by mt7603 and mt7615 drivers
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 29 Dec 2019 10:03:05 +0000 (11:03 +0100)]
mt76: move dev_irq tracepoint in mt76 module
Move dev_irq tracepoint in common code in order to be reused by mt7603
and mt7615 drivers
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 28 Dec 2019 03:05:12 +0000 (11:05 +0800)]
mt76: mt7615: add a get_stats() callback
Add a get_stats() callback for mib statistics.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 28 Dec 2019 03:05:11 +0000 (11:05 +0800)]
mt76: mt7615: add per-phy mib statistics
Update per-phy mib counters every 500ms.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 28 Dec 2019 03:05:10 +0000 (11:05 +0800)]
mt76: mt7615: report TSF information
This adds a get_tsf() callback for ibss.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sun, 22 Dec 2019 20:11:39 +0000 (04:11 +0800)]
mt76: mt7615: add set_antenna callback
Add a set_antenna callback to setup per phy tx/rx streams.
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sun, 22 Dec 2019 20:11:38 +0000 (04:11 +0800)]
mt76: mt7615: rework set_channel function
No need to send both MCU_EXT_CMD_SET_RX_PATH and MCU_EXT_CMD_CHANNEL_SWITCH
together to MCU.
Split them out by passing the proper command in the corresponding flow.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Tue, 24 Dec 2019 01:24:25 +0000 (09:24 +0800)]
mt76: mt7615: add missing settings for simultaneous dual-band support
MT7615 supports dual-wiphy which means that it can run on 2.4G and 5GHz
channels simultaneously, and driver should configure each band.
Add missing register settings, and refine band related definitions to
avoid duplicate codes.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 16 Dec 2019 18:32:10 +0000 (19:32 +0100)]
mt76: fix compilation warning in mt76_eeprom_override()
Fix the following compilation warning in mt76_eeprom_override routine
when CONFIG_OF is not set and label 'out' is not actually used
drivers/net/wireless/mediatek/mt76/eeprom.c: In function ‘mt76_eeprom_override’:
drivers/net/wireless/mediatek/mt76/eeprom.c:100:1: warning: label ‘out’ defined but not used [-Wunused-label]
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 16 Dec 2019 13:19:59 +0000 (14:19 +0100)]
mt76: mt7603: simplify led reg definitions
Rely on FIELD_PREP macro for led register definitions and
remove open coding
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 16 Dec 2019 13:19:58 +0000 (14:19 +0100)]
mt76: mt76x02: simplify led reg definitions
Rely on FIELD_PREP macro for led register definitions and
remove open coding
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 16 Dec 2019 13:05:05 +0000 (14:05 +0100)]
mt76: mt7615: introduce LED support
Initialize brightness_set and blink_set callbacks to
mt7615_led_set_brightness and mt7615_led_set_blink in order to enable
LED support in mt7615 driver
Tested-by: Deng Qingfang <dengqf6@mail2.sysu.edu.cn>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Fri, 13 Dec 2019 23:15:26 +0000 (00:15 +0100)]
mt76: clear skb pointers from rx aggregation reorder buffer during cleanup
During the cleanup of the aggregation session, a rx handler (or release timer)
on another CPU might still hold a pointer to the reorder buffer and could
attempt to release some packets.
Clearing pointers during cleanup avoids a theoretical use-after-free bug here.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Sat, 21 Dec 2019 15:46:53 +0000 (16:46 +0100)]
mt76: mt7603: fix input validation issues for powersave-filtered frames
Before extracting the tid out of the packet, check if it was qos-data.
Only accept tid values 0-7
Also, avoid accepting the hardware queue as skb queue mapping, it could
lead to an overrun. Instead, derive the hardware queue from the tid number,
in order to avoid issues with packets being filtered multiple times.
This also fixes a mismatch between hardware and software queue indexes.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 19 Dec 2019 12:41:24 +0000 (13:41 +0100)]
mt76: mt7615: increase MCU command timeout
MCU_EXT_CMD_EFUSE_BUFFER_MODE needs more time on initialization, and
with only 10 seconds it sometimes runs into timeouts.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Sat, 14 Dec 2019 19:08:59 +0000 (20:08 +0100)]
mt76: mt7615: measure channel noise and report it via survey
Read measurements every 100 ms and build a simple moving average
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Ryder Lee [Sat, 21 Dec 2019 07:17:00 +0000 (15:17 +0800)]
mt76: mt7615: fix MT7615_CFEND_RATE_DEFAULT value
Fix default CFEND_RATE and replace hardcode values.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Stanislaw Gruszka [Fri, 29 Nov 2019 12:32:28 +0000 (13:32 +0100)]
mt76: mt76x02: minor mt76x02_mac_set_beacon optimization
We do not call mt76x02_mac_set_beacon() with NULL skb any longer and
we do not need to return error value.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Stanislaw Gruszka [Fri, 29 Nov 2019 12:32:27 +0000 (13:32 +0100)]
mt76: mt76x02u: do not set NULL beacons
With current implementation we do not cleanup beacon memory, so is not
needed to call mt76x02_mac_set_beacon() with NULL skb.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Stanislaw Gruszka [Fri, 29 Nov 2019 12:32:26 +0000 (13:32 +0100)]
mt76: usb: use max packet length for m76u_copy
For transferring data over USB the optimal size is endpoint maxpacket.
For my hardware maxpaket for control endpoint is 64 bytes and changing
to this value from 128 bytes further shorten TBTT work time from
3ms to 1ms.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Wed, 18 Dec 2019 16:07:54 +0000 (17:07 +0100)]
mt76: mt76x02: add channel switch support for usb interfaces
This patch enables channel switch support on mt76 usb interfaces.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Wed, 18 Dec 2019 16:07:53 +0000 (17:07 +0100)]
mt76: speed up usb bulk copy
Use larger batches for usb copy to speed this operation up. Otherwise it
would be too slow for copying new beacons or broadcast frames over usb.
Assure, that always a multiple of 4 Bytes is copied, as outlined in
850e8f6fbd "mt76: round up length on mt76_wr_copy" from Felix Fietkau.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Wed, 18 Dec 2019 16:07:52 +0000 (17:07 +0100)]
mt76: mt76x02: remove a copy call for usb speedup
This patch removes a mt76_wr_copy call from the beacon path to hw.
The skb which is used in this place gets therefore build with txwi
inside its data. For mt76 usb drivers, this saves one synchronuous
copy call over usb, which lets the beacon work complete faster.
In mmio case, there is not enough headroom to put the txwi into the
skb, it is therefore using an additional mt76_wr_copy, which is fast
over mmio. Thanks Stanislaw for pointing this out.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Wed, 18 Dec 2019 16:07:51 +0000 (17:07 +0100)]
mt76: mt76x02: add check for invalid vif idx
On adding vifs the idx can become 1 + (7 & 7) = 8 for APs.
Check against that, as only AP vif idx 0-7 is possible.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Wed, 18 Dec 2019 16:07:50 +0000 (17:07 +0100)]
mt76: mt76x02: split beaconing
Sending beacons to the hardware always happens in batches. In order to
speed up beacon processing on usb devices, this patch splits out common
code an calls it only once.
Beacons are sequentially written into the beacon memory area, by
tracking its usage with the dev->beacon_data_count. For MBSS support
and buffered traffic dev->beacon_data_count is used to create the bypass
mask.
The code is also adapted for the mmio part of the driver, but should not
have any performance implication there.
MBSS tests were performed with AVM AC860 USB NIC with temporary support
for 5 BSS'. Different combinations of active vifs were created and
brought up. Afterwards connection and data transfer was tested for the
announced BSS'.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Wed, 18 Dec 2019 16:07:49 +0000 (17:07 +0100)]
mt76: mt76x02: omit beacon slot clearing
mt76 hw does not send beacons from beacon slots, if the corresponding
bitmask is set accordingly. Therefore we can omit clearing the beacon
memory. Clearing uses many usb calls, if usb drivers are used. These
calls unnecessarily slow down the beacon tasklet. Thanks to Stanislaw
Gruzska for pointing this out.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Markus Theil [Sat, 14 Dec 2019 09:58:59 +0000 (10:58 +0100)]
mt76: use AC specific reorder timeout
Before this patch, mt76 handled rx traffic for all TIDs equally,
when released from reorder buffer early. This patch uses an AC specific
reorder timeout, in order to release partial aggregated frames for video
ACs earlier. Voice ACs are currently not aggregated (thanks to Felix for
this hint). For example, ath10k also uses AC specific reorder timeouts
(reported by firmware in that case).
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 8 Dec 2019 07:25:40 +0000 (08:25 +0100)]
mt76: mt7615: add set_coverage class support
Add the capability to configure acktimeout for mt7615 driver. Moreover
configure slottime according to the value provided by mac80211
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 8 Dec 2019 07:25:39 +0000 (08:25 +0100)]
mt76: mt7603: set 0 as min coverage_class value
Set 0 as minimum configurable value for coverage_class since mt76 does
not support dynack
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Sun, 8 Dec 2019 07:25:38 +0000 (08:25 +0100)]
mt76: mt76x02: fix coverage_class type
Fix coverage_class type in mt76x02_dev data structure since
coverage_class can be negative to enable dynack (just supported by
ath9k). Set 0 as minimum value for coverage_class
Fixes:
7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Mon, 9 Dec 2019 19:58:59 +0000 (20:58 +0100)]
mt76: mt7615: report firmware version using ethtool
Print fw_ver and build_date members of struct mt7615_fw_trailer
similarly to what appears in the output of 'dmesg' when the MCU firmware
is loaded.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Pablo Greco [Sun, 1 Dec 2019 18:17:10 +0000 (15:17 -0300)]
mt76: mt7615: Fix build with older compilers
Some compilers (tested with 4.8.5 from CentOS 7) fail properly process
FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
Convert inline function to a macro.
Fixes commit
bf92e7685100 ("mt76: mt7615: add support for per-chain
signal strength reporting")
Reported in https://lkml.org/lkml/2019/9/21/146
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Pablo Greco <pgreco@centosproject.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 27 Nov 2019 14:46:34 +0000 (16:46 +0200)]
dt-bindings: net: wireless: mt76: introduce big-endian property
Introduce big-endian property to specify mtd radio partition endianness
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Wed, 27 Nov 2019 14:46:33 +0000 (16:46 +0200)]
mt76: eeprom: add support for big endian eeprom partition
mt76x0e users reported some devices (e.g TP-Link Archer VR200v) have
been flashed with big endian radio partition. Add the possibility to
specify eeprom endianness using big-endian dts property and in case
covert eeprom data in little endian
Tested-by: Kevin Schmidt <kevin.patrick.schmidt@googlemail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Lorenzo Bianconi [Thu, 21 Nov 2019 08:42:13 +0000 (10:42 +0200)]
mt76: mt7603: reset STA_CCA counter setting the channel
Reset MT_MIB_STAT_CCA after channel switch since it is used to track busy
time starting from 'commit
dcff8d4dc301 ("mt76: mt7603: switch to a
different counter for survey busy time")'
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Shayne Chen [Tue, 26 Nov 2019 13:15:54 +0000 (21:15 +0800)]
mt76: fix possible undetected invalid MAC address
Make sure the MAC address is checked before function returns.
If CONFIG_OF is set and the device node is null, the function will
return directly, and an invalid MAC address will not be checked.
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 5 Dec 2019 16:46:42 +0000 (17:46 +0100)]
mt76: disable bh in mt76_dma_rx_poll
Fixes potential RCU issues and avoids calling ieee80211_rx_napi with softirq
enabled.
Signed-off-by: Felix Fietkau <nbd@nbd.name>