linux-2.6-microblaze.git
4 years agomt76: mt7603: fix tx status rate index calculation
Felix Fietkau [Wed, 22 Apr 2020 11:15:06 +0000 (13:15 +0200)]
mt76: mt7603: fix tx status rate index calculation

A switch from one rate index to the next only happens when tx count from
the current slot is greater than MT7615_RATE_RETRY, which is 1 has to be
subtracted from count, instead of added to it.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix tx status rate index calculation
Felix Fietkau [Wed, 22 Apr 2020 11:10:00 +0000 (13:10 +0200)]
mt76: mt7615: fix tx status rate index calculation

A switch from one rate index to the next only happens when tx count from
the current slot is greater than MT7615_RATE_RETRY, which is 1 has to be
subtracted from count, instead of added to it.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: do not adjust MAC timings if the device is not running
Felix Fietkau [Wed, 22 Apr 2020 10:32:10 +0000 (12:32 +0200)]
mt76: mt7615: do not adjust MAC timings if the device is not running

Avoids register writes and MAC start/stop when the hardware isn't ready for it

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: adjust timing in mt7615_mac_set_timing to match fw/hw values
Felix Fietkau [Wed, 22 Apr 2020 10:28:19 +0000 (12:28 +0200)]
mt76: mt7615: adjust timing in mt7615_mac_set_timing to match fw/hw values

Slightly improves performance

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7603: never use an 802.11b CF-End rate on 5GHz
Felix Fietkau [Wed, 22 Apr 2020 15:46:58 +0000 (17:46 +0200)]
mt76: mt7603: never use an 802.11b CF-End rate on 5GHz

Sometimes mt7615_mac_set_timing gets called while the slot time is still
configured to 20. Ensure that in this case it always uses the OFDM CFend
rate.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: never use an 802.11b CF-End rate on 5GHz
Felix Fietkau [Wed, 22 Apr 2020 10:25:54 +0000 (12:25 +0200)]
mt76: mt7615: never use an 802.11b CF-End rate on 5GHz

Sometimes mt7615_mac_set_timing gets called while the slot time is still
configured to 20. Ensure that in this case it always uses the OFDM CFend
rate.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: use larger rx buffers if VHT is supported
Felix Fietkau [Mon, 20 Apr 2020 14:53:28 +0000 (16:53 +0200)]
mt76: mt7615: use larger rx buffers if VHT is supported

In VHT mode we can receive larger MPDUs. Increasing the buffer size reduces
fragmentation here, which should improve performance.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: fix A-MPDU density handling
Felix Fietkau [Mon, 20 Apr 2020 14:34:16 +0000 (16:34 +0200)]
mt76: fix A-MPDU density handling

The hardware requirements for A-MPDU density are entirely on the tx side,
not the rx side. Because of that, the IE value should stay at 0 and the
minimum value should instead be enforced in WTBL/TXWI

MT7615 has no restrictions here

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix sta ampdu factor for VHT
Felix Fietkau [Mon, 20 Apr 2020 13:49:35 +0000 (15:49 +0200)]
mt76: mt7615: fix sta ampdu factor for VHT

If VHT has a larger A-MPDU size limit, pass it to the MCU via the wtbl_ht
TLV element.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663u: enable AirTimeFairness
Lorenzo Bianconi [Wed, 22 Apr 2020 08:47:24 +0000 (10:47 +0200)]
mt76: mt7663u: enable AirTimeFairness

Initialize tx_status_data pointer in order to enable Air Time Fairness
for mt7663u chipset

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: rework mt7615_mac_sta_poll for usb code
Lorenzo Bianconi [Wed, 22 Apr 2020 08:47:23 +0000 (10:47 +0200)]
mt76: mt7615: rework mt7615_mac_sta_poll for usb code

Since usb code can't access device registers in interrupt context, move
rcu_read_lock/rcu_read_unlock in mt7615_poll_tx routine. Moreover loop
over a local msta list in mt7615_mac_sta_poll since mt7663u driver will
not be able to complete the inner while loop before sta_poll_list list
is refilled by mt7615_mac_add_txs/mt7615_mac_fill_rx

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix aid configuration in mt7615_mcu_wtbl_generic_tlv
Lorenzo Bianconi [Tue, 21 Apr 2020 14:31:40 +0000 (16:31 +0200)]
mt76: mt7615: fix aid configuration in mt7615_mcu_wtbl_generic_tlv

If the vif is running in station mode the aid will be passed by mac80211
using bss_conf.aid. Fix aid configuration in mt7615_mcu_wtbl_generic_tlv

Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix mt7615_driver_own routine
Lorenzo Bianconi [Mon, 20 Apr 2020 20:40:55 +0000 (22:40 +0200)]
mt76: mt7615: fix mt7615_driver_own routine

Introduce MT_PCIE_DOORBELL_PUSH register to fix mt7615_driver_own
routine for mt7663e

Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix max wtbl size for 7663
Lorenzo Bianconi [Mon, 20 Apr 2020 12:39:02 +0000 (14:39 +0200)]
mt76: mt7615: fix max wtbl size for 7663

Current mt7663 offload firmware can support up to 32 wtbl entries

Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e 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>
4 years agomt76: mt7615: fix mt7615_firmware_own for mt7663e
Lorenzo Bianconi [Mon, 20 Apr 2020 12:07:45 +0000 (14:07 +0200)]
mt76: mt7615: fix mt7615_firmware_own for mt7663e

Check the firmware-own configuration has been applied polling
MT_CONN_HIF_ON_LPCTL register

Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: parse mcu return code for unified commands
Lorenzo Bianconi [Mon, 20 Apr 2020 11:58:44 +0000 (13:58 +0200)]
mt76: mt7615: parse mcu return code for unified commands

Add return code parsing for the following unified commands:
- MCU_UNI_CMD_DEV_INFO_UPDATE
- MCU_UNI_CMD_BSS_INFO_UPDATE
- MCU_UNI_CMD_STA_REC_UPDATE

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>
4 years agomt76: add rx queues info to mt76 debugfs
Lorenzo Bianconi [Sun, 19 Apr 2020 20:11:41 +0000 (22:11 +0200)]
mt76: add rx queues info to mt76 debugfs

Introduce rx-queues debugfs node in order to dump rx queues status.
This would be useful for mcu fw debugging

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: make Kconfig entry obvious for MT7663E
Sean Wang [Fri, 17 Apr 2020 11:13:28 +0000 (13:13 +0200)]
mt76: mt7615: make Kconfig entry obvious for MT7663E

Make Kconfig entry obvious for MT7663E

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663: introduce 802.11 PS support in sta mode
Lorenzo Bianconi [Fri, 17 Apr 2020 11:10:06 +0000 (13:10 +0200)]
mt76: mt7663: introduce 802.11 PS support in sta mode

Enable 802.11 power-save support available in mt7663 firmware

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>
4 years agomt76: remove PS_NULLFUNC_STACK capability
Lorenzo Bianconi [Fri, 17 Apr 2020 11:10:05 +0000 (13:10 +0200)]
mt76: remove PS_NULLFUNC_STACK capability

remove IEEE80211_HW_PS_NULLFUNC_STACK capability from mt76_phy_init
routine since 802.11 ps is not currently supported by any devices and it
will conflict with mt7663 ps fw support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: provide aid info to the mcu
Lorenzo Bianconi [Fri, 17 Apr 2020 11:10:04 +0000 (13:10 +0200)]
mt76: mt7615: provide aid info to the mcu

For sta mode mac80211 provides aid in vif->bss_conf.aid.
In order to properly support 802.11 power-save, configure correct aid
to mcu during sta association

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>
4 years agomt76: mt7615: disable aspm by default
Lorenzo Bianconi [Fri, 17 Apr 2020 10:10:54 +0000 (12:10 +0200)]
mt76: mt7615: disable aspm by default

The vendor SDK also disables ASPM by default

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: enable scs for mt7663 driver
Lorenzo Bianconi [Thu, 16 Apr 2020 14:36:19 +0000 (16:36 +0200)]
mt76: mt7615: enable scs for mt7663 driver

Add missing register definitions in order to enable sensitivity tuning
for mt7663 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce mt7663u support
Lorenzo Bianconi [Thu, 16 Apr 2020 14:32:51 +0000 (16:32 +0200)]
mt76: mt7615: introduce mt7663u support

Introduce support for mt7663u 802.11ac 2x2:2 chipset to mt7615 driver.
Main difference respect to pcie code base is the usb code needs to
configure wtbl from non-atomic context

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>
4 years agomt76: mt7615: move core shared code in mt7615-common module
Lorenzo Bianconi [Thu, 16 Apr 2020 14:32:50 +0000 (16:32 +0200)]
mt76: mt7615: move core shared code in mt7615-common module

Create mt7615-common module in order to collect shared code between usb
and mmio code. Move the following source files in mt7615-common module:
- main.c
- init.c
- mcu.c
- mac.c
- debugfs.c
- eeprom.c
- trace.c

Create the following source files for mmio only source code and move them
in mt7615e module:
- pci_init.c
- dma.c
- pci_mac.c

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix possible deadlock in mt7615_stop
Lorenzo Bianconi [Mon, 13 Apr 2020 14:28:48 +0000 (16:28 +0200)]
mt76: mt7615: fix possible deadlock in mt7615_stop

make mac_work per phy instead of per device and fix a possible deadlock
in mt7615_stop since mt7615_mac_work runs holding mt76 mutex

Fixes: fdd2e570764c2 ("mt76: mt7615: add dual-phy support for mac80211 ops")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: remove unnecessary annotations
Jules Irenge [Sat, 11 Apr 2020 00:19:26 +0000 (01:19 +0100)]
mt76: remove unnecessary annotations

Sparse report warnings at mt76_tx_status_unlock() and mt76_tx_status_lock()

warning: context imbalance in mt76_tx_status_lock() - wrong count at exit
warning: context imbalance in mt76_tx_status_unlock() - unexpected unlock

The root cause is the additional __acquire(&dev->status_list.lock)
and __release(&dev->status_list.unlock) called
 from inside mt76_tx_status_lock() and mt76_tx_status_unlock().

Remove __acquire(&dev->status_list.lock) annotation
Remove __releases(&dev->status_list.unlock)
Correct &dev->status_list.unlock to &dev->status_list.lock
-unlock not defined in the sk_buff_head struct

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: enable MSI by default
Lorenzo Bianconi [Thu, 9 Apr 2020 16:37:04 +0000 (18:37 +0200)]
mt76: mt7615: enable MSI by default

Enable MSI/MSI-X PCI interrupts by default. This patch has been tested
using Banana Pi r64 board

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: rework IRQ handling to prepare for MSI support
Felix Fietkau [Thu, 9 Apr 2020 12:37:50 +0000 (14:37 +0200)]
mt76: mt7615: rework IRQ handling to prepare for MSI support

With MSI interrupts, IRQs must not be enabled from within the IRQ handler,
because that can lead to lost events.
Defer IRQ processing to a tasklet, which is also responsible for enabling
IRQs (to avoid race conditions against the handler)

Co-developed-by: Soul Huang <Soul.Huang@mediatek.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Soul Huang <soul.huang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663: fix DMA unmap length
Lorenzo Bianconi [Thu, 9 Apr 2020 11:14:57 +0000 (13:14 +0200)]
mt76: mt7663: fix DMA unmap length

Fix DMA unmap length for mt7663e devices in mt7615_txp_skb_unmap_hw

Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support")
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Soul Huang <soul.huang@mediatek.com>
Signed-off-by: Soul Huang <soul.huang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
4 years agomt76: mt7622: fix DMA unmap length
Lorenzo Bianconi [Thu, 9 Apr 2020 11:14:56 +0000 (13:14 +0200)]
mt76: mt7622: fix DMA unmap length

Fix DMA unmap length estimation in mt7615_txp_skb_unmap_hw for mt7622
chipset

Fixes: 6aa4ed7927f1 ("mt76: mt7615: implement DMA support for MT7622")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
4 years agomt76: mt7615: set hw scan limits only for firmware with offload support
Felix Fietkau [Wed, 8 Apr 2020 16:10:35 +0000 (18:10 +0200)]
mt76: mt7615: set hw scan limits only for firmware with offload support

They do not apply to software scan

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: disable hw/sched scan ops for non-offload firmware
Felix Fietkau [Thu, 9 Apr 2020 09:51:17 +0000 (11:51 +0200)]
mt76: mt7615: disable hw/sched scan ops for non-offload firmware

Avoid having to attempt hw scan and fall back to software for every scan
on devices/firmware without hw scan support

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663: fix aggr range entry in debugfs
Lorenzo Bianconi [Wed, 8 Apr 2020 12:20:39 +0000 (14:20 +0200)]
mt76: mt7663: fix aggr range entry in debugfs

Fix register definitions for aggr range counter registers for mt7663
chipset

Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: fix possible division by 0 in mt7615_mac_update_mib_stats
Lorenzo Bianconi [Mon, 6 Apr 2020 21:56:30 +0000 (23:56 +0200)]
mt76: mt7615: fix possible division by 0 in mt7615_mac_update_mib_stats

Check that val is not zero before aggr_per estimation in order to avoid a
possible division by 0

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x2: disable merge of OTP ROM data by default
Felix Fietkau [Mon, 6 Apr 2020 12:03:06 +0000 (14:03 +0200)]
mt76: mt76x2: disable merge of OTP ROM data by default

The reference driver does not seem to enable it by default, only under certain
conditions, e.g. when a .bin file is loaded.
Make it opt-in via a device tree property for now, in case it is needed on some
boards.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7603: disable merge of OTP ROM data by default
Felix Fietkau [Mon, 6 Apr 2020 12:01:56 +0000 (14:01 +0200)]
mt76: mt7603: disable merge of OTP ROM data by default

The reference driver does not seem to enable it by default, only under certain
conditions, e.g. when a .bin file is loaded.
Make it opt-in via a device tree property for now, in case it is needed on some
boards.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: add support for applying tx DPD calibration from EEPROM
Felix Fietkau [Mon, 6 Apr 2020 09:14:56 +0000 (11:14 +0200)]
mt76: mt7615: add support for applying tx DPD calibration from EEPROM

When the EEPROM data is read from flash, it can contain tx DPD calibration
data. Add support for sending the data to the firmware.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: add support for applying DC offset calibration from EEPROM
Felix Fietkau [Mon, 30 Mar 2020 13:02:45 +0000 (15:02 +0200)]
mt76: mt7615: add support for applying DC offset calibration from EEPROM

When the EEPROM data is read from flash, it can contain DC offset calibration
data. Add support for sending the data to the firmware.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: disable merge of OTP ROM data by default
Felix Fietkau [Mon, 6 Apr 2020 08:19:48 +0000 (10:19 +0200)]
mt76: mt7615: disable merge of OTP ROM data by default

The reference driver does not seem to enable it by default, only under certain
conditions, e.g. when a .bin file is loaded.
Make it opt-in via a device tree property for now, in case it is needed on some
boards.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agodt-bindings: net: wireless: mt76: document mediatek,eeprom-merge-otp property
Felix Fietkau [Mon, 6 Apr 2020 10:16:22 +0000 (12:16 +0200)]
dt-bindings: net: wireless: mt76: document mediatek,eeprom-merge-otp property

It is used to enable merging of Flash EEPROM data with OTP ROM calibration.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: Delete an error message in mt7622_wmac_probe()
Markus Elfring [Sun, 5 Apr 2020 14:45:48 +0000 (16:45 +0200)]
mt76: mt7615: Delete an error message in mt7622_wmac_probe()

The function “platform_get_irq” can log an error already.
Thus omit a redundant message for the exception handling in the
calling function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: do not always reset the dfs state setting the channel
Lorenzo Bianconi [Fri, 3 Apr 2020 19:01:56 +0000 (21:01 +0200)]
mt76: mt7615: do not always reset the dfs state setting the channel

mac80211/hostapd runs mt7615_set_channel with the same channel
parameters sending multiple rdd commands overwriting the previous ones.
This behaviour is causing tpt issues on dfs channels.
Fix the issue checking new channel freq/width with the running one.

Fixes: 5dabdf71e94e ("mt76: mt7615: add multiple wiphy support to the dfs support code")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663: correct the name of the rom patch
Sean Wang [Fri, 3 Apr 2020 09:09:16 +0000 (17:09 +0800)]
mt76: mt7663: correct the name of the rom patch

Rom patch is shared between Bluetooth and Wifi devices, so correct the
naming to allow two drivers to share the same file.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: add address parameter to mt7615_eeprom_init
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:56 +0000 (20:18 +0200)]
mt76: mt7615: add address parameter to mt7615_eeprom_init

Introduce address parameter to mt7615_eeprom_init routine in order to be
reused adding usb support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce mt7615_wtbl_desc data structure
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:55 +0000 (20:18 +0200)]
mt76: mt7615: introduce mt7615_wtbl_desc data structure

Generalize mt7615_rate_desc introducing mt7615_wtbl_desc and
mt7615_key_desc data structures in order to configure the hw wtbl
in a non-atomic context for usb devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: rework wtbl key configuration
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:54 +0000 (20:18 +0200)]
mt76: mt7615: rework wtbl key configuration

Remove key dependency from mt7615_mac_wtbl_update_key and export
mt7615_mac_wtbl_update_key, mt7615_mac_wtbl_update_pk and
mt7615_mac_wtbl_update_cipher in order to reuse them in usb code.
Move mt7615_mac_get_cipher in mac.h

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76u: rely on mt7622 queue scheme for mt7663u
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:53 +0000 (20:18 +0200)]
mt76: mt76u: rely on mt7622 queue scheme for mt7663u

Rely on the mt7622 endpoint definitions for mt7663u

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: move mt7615_mac_wtbl_addr in mac.h
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:52 +0000 (20:18 +0200)]
mt76: mt7615: move mt7615_mac_wtbl_addr in mac.h

Move mt7615_mac_wtbl_addr in mac.h and add inline qualifier in order to
be reused adding usb support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce __mt7663_load_firmware routine
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:51 +0000 (20:18 +0200)]
mt76: mt7615: introduce __mt7663_load_firmware routine

Introduce __mt7663_load_firmware routine to load firmware for usb
devices.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce mt7615_mac_update_rate_desc routine
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:50 +0000 (20:18 +0200)]
mt76: mt7615: introduce mt7615_mac_update_rate_desc routine

Move register configuration out of mt7615_mac_set_rates since usb
driver can't access device register in interrupt context. Introduce
mt7615_mac_update_rate_desc routine to report rate info to
mt7615_mac_set_rates

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>
4 years agomt76: mt7615: introduce mt7663u support to mt7615_write_txwi
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:49 +0000 (20:18 +0200)]
mt76: mt7615: introduce mt7663u support to mt7615_write_txwi

Extend mt7615_write_txwi routine to support usb txwi configuration

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>
4 years agomt76: add headroom and tailroom to mt76_mcu_ops data structure
Lorenzo Bianconi [Thu, 2 Apr 2020 18:18:48 +0000 (20:18 +0200)]
mt76: add headroom and tailroom to mt76_mcu_ops data structure

Introduce headroom and tailroom to mt76_mcu_ops data structure in order
to unify the routine used for mcu message allocation. This is a
preliminary patch to add mt7663u support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: remove unnecessary register operations
Sean Wang [Thu, 2 Apr 2020 13:06:42 +0000 (15:06 +0200)]
mt76: mt7615: remove unnecessary register operations

Remove mt76_wr(dev, MT_CSR(0x010), 0x8208) that would cause
MT_PCIE_IRQ_ENABLE to be disabled; MT_PCIE_IRQ_ENABLE should always keep
on enabled when the driver is running.

0x44064 is a not existing address

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>
4 years agomt76: mt7615: introduce rlm tlv in bss_info mcu command
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:41 +0000 (15:06 +0200)]
mt76: mt7615: introduce rlm tlv in bss_info mcu command

Introduce rlm tlv header in bss_info mcu command in order to
inform the mcu about operating channel. Rlm header is necessary only if
the mcu is running low power functionalities (e.g offloaded scan)

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>
4 years agomt76: mt7615: introduce BSS absence event
Sean Wang [Thu, 2 Apr 2020 13:06:40 +0000 (15:06 +0200)]
mt76: mt7615: introduce BSS absence event

Introduce BSS absence event that is reported when the fw
is leaving or entering current operational channel.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce scheduled scan support
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:39 +0000 (15:06 +0200)]
mt76: mt7615: introduce scheduled scan support

Introduce scheduled scan support for mt7663e 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>
4 years agomt76: mt7615: introduce hw scan support
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:38 +0000 (15:06 +0200)]
mt76: mt7615: introduce hw scan support

Introduce hw scan support to mt7663e driver

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>
4 years agomt76: mt7663: keep Rx filters as the default
Sean Wang [Thu, 2 Apr 2020 13:06:37 +0000 (15:06 +0200)]
mt76: mt7663: keep Rx filters as the default

Keep Rx filters default value if the firmware supports offload and
low power features.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: introduce mt7615_mcu_set_channel_domain mcu command
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:36 +0000 (15:06 +0200)]
mt76: mt7615: introduce mt7615_mcu_set_channel_domain mcu command

Introduce mt7615_mcu_set_channel_domain routines in order to instruct
the mcu about supported band/channels. This is a preliminary patch to
add hw scan support to mt7663e driver

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>
4 years agomt76: mt7615: add ethool support to mt7663 driver
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:35 +0000 (15:06 +0200)]
mt76: mt7615: add ethool support to mt7663 driver

Report n9 firmware version using ethtool

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663: disable RDD commands
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:34 +0000 (15:06 +0200)]
mt76: mt7663: disable RDD commands

Disable dfs RDD mcu commands for mt7663 driver since they are not
currently supported by the 7663 firmware

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>
4 years agomt76: mt7615: make scs configurable per phy
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:33 +0000 (15:06 +0200)]
mt76: mt7615: make scs configurable per phy

Make scs configurable per phy since most of the chipsets do not
support dbdc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7663: enable nf estimation
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:32 +0000 (15:06 +0200)]
mt76: mt7663: enable nf estimation

Enable Noise floor estimation for mt7663 driver

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>
4 years agomt76: mt7663: fix mt7615_mac_cca_stats_reset routine
Lorenzo Bianconi [Thu, 2 Apr 2020 13:06:31 +0000 (15:06 +0200)]
mt76: mt7663: fix mt7615_mac_cca_stats_reset routine

Fix PHYMUX_5 register definition for mt7663 in
mt7615_mac_cca_stats_reset routine

Fixes: f40ac0f3d3c0 ("mt76: mt7615: introduce mt7663e support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: add more useful Tx mib counters
Ryder Lee [Tue, 31 Mar 2020 06:51:38 +0000 (14:51 +0800)]
mt76: mt7615: add more useful Tx mib counters

Add ba_miss_cnt and ampdu_per in mib_stats.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: cleanup mib related defines and structs
Ryder Lee [Tue, 31 Mar 2020 06:51:37 +0000 (14:51 +0800)]
mt76: mt7615: cleanup mib related defines and structs

Simplify mib macros and use proper type for related counters.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: enable aggr_stats for both phy
Ryder Lee [Tue, 31 Mar 2020 06:51:36 +0000 (14:51 +0800)]
mt76: mt7615: enable aggr_stats for both phy

Use bottom half of aggr_stats for second phy.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt7615: modify mt7615_ampdu_stat_read for each phy
Ryder Lee [Tue, 31 Mar 2020 06:51:35 +0000 (14:51 +0800)]
mt76: mt7615: modify mt7615_ampdu_stat_read for each phy

This is a preliminary patch to add more Tx counters.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x0: pci: add mt7610 PCI ID
Pawel Dembicki [Wed, 25 Mar 2020 05:55:23 +0000 (06:55 +0100)]
mt76: mt76x0: pci: add mt7610 PCI ID

Add mt7610 PCI id found on D-Link DWR-960 to pci_device_id table.

Run-tested on D-Link DWR-960 with no-name half-size mPCIE card
with mt7610e.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x2u: introduce Mercury UD13 support
Lorenzo Bianconi [Sat, 21 Mar 2020 15:14:42 +0000 (16:14 +0100)]
mt76: mt76x2u: introduce Mercury UD13 support

Introduce Mercury UD13 dual-band dongle support to mt76x2u driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02u: Add support for newer versions of the XBox One wifi adapter
Matthew Garrett [Wed, 18 Mar 2020 23:07:48 +0000 (16:07 -0700)]
mt76: mt76x02u: Add support for newer versions of the XBox One wifi adapter

The current version has a new USB ID and reports as an 0x7632 device.
Adding the IDs results in it working out of the box.

Signed-off-by: Matthew Garrett <mjg59@google.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agomt76: mt76x02: fix handling MCU timeouts during hw restart
Felix Fietkau [Sun, 16 Feb 2020 15:08:58 +0000 (16:08 +0100)]
mt76: mt76x02: fix handling MCU timeouts during hw restart

If a MCU timeout occurs before a hw restart completes, another hw restart
is scheduled, and the station state gets corrupted.
To speed up dealing with that, do not issue any MCU commands after the first
timeout, and defer handling timeouts until the reset has completed.
Also ignore errors in MCU commands during start/config to avoid making user
space fail on this condition. If it happens, another restart is scheduled
quickly, and that usually recovers the hardware properly.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
4 years agoipw2x00: Fix comment for CLOCK_BOOTTIME constant
Pali Rohár [Fri, 8 May 2020 19:51:39 +0000 (21:51 +0200)]
ipw2x00: Fix comment for CLOCK_BOOTTIME constant

Correct name of constant is CLOCK_BOOTTIME and not CLOCK_BOOTIME.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200508195139.20078-1-pali@kernel.org
4 years agorndis_wlan: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 19:26:47 +0000 (14:26 -0500)]
rndis_wlan: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507192647.GA16710@embeddedor
4 years agoqtnfmac: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 19:19:26 +0000 (14:19 -0500)]
qtnfmac: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507191926.GA15970@embeddedor
4 years agoprism54: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 19:02:10 +0000 (14:02 -0500)]
prism54: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507190210.GA15375@embeddedor
4 years agomwl8k: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 18:59:14 +0000 (13:59 -0500)]
mwl8k: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507185914.GA15124@embeddedor
4 years agoiwlegacy: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 18:55:29 +0000 (13:55 -0500)]
iwlegacy: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507185529.GA14639@embeddedor
4 years agoipw2x00: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 18:54:51 +0000 (13:54 -0500)]
ipw2x00: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507185451.GA14603@embeddedor
4 years agorndis_wlan: Remove logically dead code
Gustavo A. R. Silva [Tue, 5 May 2020 23:52:05 +0000 (18:52 -0500)]
rndis_wlan: Remove logically dead code

caps_buf is always of size sizeof(*caps) because
sizeof(caps->auth_encr_pair) * 16 is always zero. Notice
that when using zero-length arrays, sizeof evaluates to zero[1].

So, the code introduced by
commit 0308383f9591 ("rndis_wlan: get max_num_pmkids from device")
is logically dead, hence is never executed and can be removed. As a
consequence, the rest of the related code can be refactored a bit.

Notice that this code has been out there since March 2010.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200505235205.GA18539@embeddedor
Link: https://lore.kernel.org/r/20200507110741.37757-1-yanaijie@huawei.com
4 years agobrcmfmac: remove Comparison to bool in brcmf_p2p_send_action_frame()
Jason Yan [Fri, 8 May 2020 07:43:51 +0000 (15:43 +0800)]
brcmfmac: remove Comparison to bool in brcmf_p2p_send_action_frame()

Fix the following coccicheck warning:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c:1785:5-8:
WARNING: Comparison to bool

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Reviewed-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200508074351.19193-1-yanaijie@huawei.com
4 years agobrcmfmac: make non-global functions static
Chen Zhou [Fri, 8 May 2020 01:32:49 +0000 (09:32 +0800)]
brcmfmac: make non-global functions static

Fix sparse warning:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c:2206:5:
warning: symbol 'brcmf_p2p_get_conn_idx' was not declared. Should it be static?

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Reviewed-by: Wright Feng <wright.feng@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200508013249.95196-1-chenzhou10@huawei.com
4 years agobrcmfmac: Use seq/seq_len and set iv_initialize when plumbing of rxiv in (GTK) keys
Soontak Lee [Wed, 6 May 2020 13:03:21 +0000 (08:03 -0500)]
brcmfmac: Use seq/seq_len and set iv_initialize when plumbing of rxiv in (GTK) keys

When plumbing rxiv for (GTK) keys, current code does not use seq/seq_len
when present nor set iv_initialized for iovar wsec_key. This could
result in missing broadcast traffic after GTK rekey. The fix is setting
iv_initialized and using seq/seq_len for iovar wsec_key.

Signed-off-by: Soontak Lee <soontak.lee@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Wright Feng <wright.feng@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1588770201-54361-4-git-send-email-wright.feng@cypress.com
4 years agobrcmfmac: use actframe_abort to cancel ongoing action frame
Ryohei Kondo [Wed, 6 May 2020 13:03:20 +0000 (08:03 -0500)]
brcmfmac: use actframe_abort to cancel ongoing action frame

The driver sends an action frame down and waits for dwell time to be
completed or aborted before sending out the next action frame.
Driver issues "scan abort" to cancel the current time slot, but this
doesn't have any effect because, we are not using scan engine for
sending action frame.
Fix is to use "actframe_abort" to cancels the current action frame.

Signed-off-by: Ryohei Kondo <ryohei.kondo@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Wright Feng <wright.feng@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1588770201-54361-3-git-send-email-wright.feng@cypress.com
4 years agobrcmfmac: set security after reiniting interface
Jia-Shyr Chuang [Wed, 6 May 2020 13:03:19 +0000 (08:03 -0500)]
brcmfmac: set security after reiniting interface

Host driver parses and sets security params into FW passed by
supplicant. This has to be done after reiniting interface in the
firmware.

Signed-off-by: Jia-Shyr Chuang <joseph.chuang@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Wright Feng <wright.feng@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1588770201-54361-2-git-send-email-wright.feng@cypress.com
4 years agobrcmfmac: fix 802.1d priority to ac mapping for pcie dongles
Pramod Prakash [Tue, 5 May 2020 06:51:27 +0000 (01:51 -0500)]
brcmfmac: fix 802.1d priority to ac mapping for pcie dongles

802.1d defines 0,3 for BE and 1,2 for BK. In pcie dongles, 0 & 3 are
mapped to 0 and 1,2 are mapped to 1. This change corrects this mapping,
so that BE & BK are given access precedence accordingly by pcie dongles.

Signed-off-by: Pramod Prakash <pramod.prakash@cypress.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1588661487-21884-3-git-send-email-chi-hsien.lin@cypress.com
4 years agobrcmfmac: map 802.1d priority to precedence level based on AP WMM params
Saravanan Shanmugham [Tue, 5 May 2020 06:51:26 +0000 (01:51 -0500)]
brcmfmac: map 802.1d priority to precedence level based on AP WMM params

In WLAN, priority among various access categories of traffic is
always set by the AP using WMM parameters and this may not always
follow the standard 802.1d priority.

In this change, priority is adjusted based on the AP WMM params
received as part of the Assoc Response and the same is later used
to map the priority of all incoming traffic.

In a specific scenario where EDCA parameters are configured to be same
for all ACs, use the default FW priority definition to avoid queuing
packets of all ACs to the same priority queue.

This change fixes the following 802.11 certification tests:
* 11n - 5.2.31 ACM Bit Conformance test
* 11n - 5.2.32 AC Parameter Modification test
* 11ac - 5.2.33 TXOP Limit test

Signed-off-by: Saravanan Shanmugham <saravanan.shanmugham@cypress.com>
Signed-off-by: Justin Li <justin.li@cypress.com>
Signed-off-by: Madhan Mohan R <madhanmohan.r@cypress.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1588661487-21884-2-git-send-email-chi-hsien.lin@cypress.com
4 years agonet: relax SO_TXTIME CAP_NET_ADMIN check
Eric Dumazet [Thu, 7 May 2020 17:05:39 +0000 (10:05 -0700)]
net: relax SO_TXTIME CAP_NET_ADMIN check

Now sch_fq has horizon feature, we want to allow QUIC/UDP applications
to use EDT model so that pacing can be offloaded to the kernel (sch_fq)
or the NIC.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'bonding-report-transmit-status-to-callers'
David S. Miller [Fri, 8 May 2020 01:11:07 +0000 (18:11 -0700)]
Merge branch 'bonding-report-transmit-status-to-callers'

Eric Dumazet says:

====================
bonding: report transmit status to callers

First patches cleanup netpoll, and make sure it provides tx status to its users.

Last patch changes bonding to not pretend packets were sent without error.

By providing more accurate status, TCP stack can avoid adding more
packets if the slave qdisc is already full.

This came while testing latest horizon feature in sch_fq, with
very low pacing rate flows, but should benefit hosts under stress.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agobonding: propagate transmit status
Eric Dumazet [Thu, 7 May 2020 16:32:22 +0000 (09:32 -0700)]
bonding: propagate transmit status

Currently, bonding always returns NETDEV_TX_OK to its caller.

It is worth trying to be more accurate : TCP for instance
can have different recovery strategies if it can have more
precise status, if packet was dropped by slave qdisc.

This is especially important when host is under stress.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jay Vosburgh <j.vosburgh@gmail.com>
Cc: Veaceslav Falico <vfalico@gmail.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetpoll: accept NULL np argument in netpoll_send_skb()
Eric Dumazet [Thu, 7 May 2020 16:32:21 +0000 (09:32 -0700)]
netpoll: accept NULL np argument in netpoll_send_skb()

netpoll_send_skb() callers seem to leak skb if
the np pointer is NULL. While this should not happen, we
can make the code more robust.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetpoll: netpoll_send_skb() returns transmit status
Eric Dumazet [Thu, 7 May 2020 16:32:20 +0000 (09:32 -0700)]
netpoll: netpoll_send_skb() returns transmit status

Some callers want to know if the packet has been sent or
dropped, to inform upper stacks.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetpoll: move netpoll_send_skb() out of line
Eric Dumazet [Thu, 7 May 2020 16:32:19 +0000 (09:32 -0700)]
netpoll: move netpoll_send_skb() out of line

There is no need to inline this helper, as we intend to add more
code in this function.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonetpoll: remove dev argument from netpoll_send_skb_on_dev()
Eric Dumazet [Thu, 7 May 2020 16:32:18 +0000 (09:32 -0700)]
netpoll: remove dev argument from netpoll_send_skb_on_dev()

netpoll_send_skb_on_dev() can get the device pointer directly from np->dev

Rename it to __netpoll_send_skb()

Following patch will move netpoll_send_skb() out-of-line.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: phy: fix less than zero comparison with unsigned variable val
Colin Ian King [Thu, 7 May 2020 14:34:30 +0000 (15:34 +0100)]
net: phy: fix less than zero comparison with unsigned variable val

The unsigned variable val is being checked for an error by checking
if it is less than zero. This can never occur because val is unsigned.
Fix this by making val a plain int.

Addresses-Coverity: ("Unsigned compared against zero")
Fixes: bdbdac7649fa ("ethtool: provide UAPI for PHY master/slave configuration.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet/smc: remove set but not used variables 'del_llc, del_llc_resp'
YueHaibing [Thu, 7 May 2020 14:24:06 +0000 (16:24 +0200)]
net/smc: remove set but not used variables 'del_llc, del_llc_resp'

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

net/smc/smc_llc.c: In function 'smc_llc_cli_conf_link':
net/smc/smc_llc.c:753:31: warning:
 variable 'del_llc' set but not used [-Wunused-but-set-variable]
  struct smc_llc_msg_del_link *del_llc;
                               ^
net/smc/smc_llc.c: In function 'smc_llc_process_srv_delete_link':
net/smc/smc_llc.c:1311:33: warning:
 variable 'del_llc_resp' set but not used [-Wunused-but-set-variable]
    struct smc_llc_msg_del_link *del_llc_resp;
                                 ^

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agotcp: tcp_mark_head_lost is only valid for sack-tcp
zhang kai [Thu, 7 May 2020 03:08:30 +0000 (11:08 +0800)]
tcp: tcp_mark_head_lost is only valid for sack-tcp

so tcp_is_sack/reno checks are removed from tcp_mark_head_lost.

Signed-off-by: zhang kai <zhangkaiheb@126.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agonet: remove newlines in NL_SET_ERR_MSG_MOD
Jacob Keller [Thu, 7 May 2020 00:58:27 +0000 (17:58 -0700)]
net: remove newlines in NL_SET_ERR_MSG_MOD

The NL_SET_ERR_MSG_MOD macro is used to report a string describing an
error message to userspace via the netlink extended ACK structure. It
should not have a trailing newline.

Add a cocci script which catches cases where the newline marker is
present. Using this script, fix the handful of cases which accidentally
included a trailing new line.

I couldn't figure out a way to get a patch mode working, so this script
only implements context, report, and org.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4 years agoMerge branch 'ti-am65x-cpts-follow-up-dt-bindings-update'
David S. Miller [Fri, 8 May 2020 00:51:03 +0000 (17:51 -0700)]
Merge branch 'ti-am65x-cpts-follow-up-dt-bindings-update'

Grygorii Strashko says:

====================
net: ethernet: ti: am65x-cpts: follow up dt bindings update

This series is follow update for  TI A65x/J721E Common platform time sync (CPTS)
driver [1] to implement  DT bindings review comments from
Rob Herring <robh@kernel.org> [2].
 - "reg" and "compatible" properties are made required for CPTS DT nodes which
   also required to change K3 CPSW driver to use of_platform_device_create()
   instead of of_platform_populate() for proper CPTS and MDIO initialization
 - minor DT bindings format changes
 - K3 CPTS example added to K3 MCU CPSW bindings

[1] https://lwn.net/Articles/819313/
[2] https://lwn.net/ml/linux-kernel/20200505040419.GA8509@bogus/
====================

Signed-off-by: David S. Miller <davem@davemloft.net>