platform/kernel/linux-rpi.git
5 years agomt76: mt7615: add support to read temperature from mcu
Lorenzo Bianconi [Mon, 2 Sep 2019 12:51:54 +0000 (14:51 +0200)]
mt76: mt7615: add support to read temperature from mcu

Introduce debugfs entry to read device temperature and related cmu
command. Introduce mt7615_mcu_parse_response to parse mcu response
messages and refactor mt7615_mcu_msg_send routine

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: introduce mt7615_txwi_to_txp utility routine
Lorenzo Bianconi [Wed, 28 Aug 2019 09:01:40 +0000 (11:01 +0200)]
mt76: mt7615: introduce mt7615_txwi_to_txp utility routine

Introduce mt7615_txwi_to_txp utility routine to convert mt76_txwi_cache
into mt7615_txp and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: use devm_platform_ioremap_resource() to simplify code
YueHaibing [Tue, 27 Aug 2019 13:44:45 +0000 (21:44 +0800)]
mt76: mt7603: use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x0: remove unneeded return value on set channel
Stanislaw Gruszka [Fri, 23 Aug 2019 08:52:17 +0000 (10:52 +0200)]
mt76: mt76x0: remove unneeded return value on set channel

We allways return 0 from mt76x0_phy_set_channel(), no need to pass
return value upward.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x0: remove redundant chandef copy
Stanislaw Gruszka [Fri, 23 Aug 2019 08:52:16 +0000 (10:52 +0200)]
mt76: mt76x0: remove redundant chandef copy

We set dev->mt76.chandef in mt76_set_channel() already.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: make mt76_rx_convert static
Stanislaw Gruszka [Fri, 23 Aug 2019 08:46:12 +0000 (10:46 +0200)]
mt76: make mt76_rx_convert static

mt76_rx_convert() not need to be exported any longer.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: remove offchannel check in tx scheduling
Felix Fietkau [Thu, 22 Aug 2019 08:08:56 +0000 (10:08 +0200)]
mt76: remove offchannel check in tx scheduling

tx queues are already disabled by mac80211 during scanning or other
off-channel activity. There is no need to repeat the check in mt76,
since scheduled queues are selected by mac80211 as well.

Signed-off-by: Balakrishna Bandi <b.balakrishna@globaledgesoft.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: do not send BAR frame on tx aggregation flush stop
Felix Fietkau [Thu, 22 Aug 2019 07:37:41 +0000 (09:37 +0200)]
mt76: do not send BAR frame on tx aggregation flush stop

There is no need to send a BAR frame after stopping aggregation, and doing
so could lead to sending class 3 frames after deauthentication from an AP

Signed-off-by: Balakrishna Bandi <b.balakrishna@globaledgesoft.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: stop rx aggregation on station removal
Felix Fietkau [Mon, 12 Aug 2019 13:48:53 +0000 (15:48 +0200)]
mt76: stop rx aggregation on station removal

Fixes use-after-free issues on forced station removal during hardware restart
on MT76x02

Fixes: aee5b8cf2477 ("mt76: implement A-MPDU rx reordering in the driver code")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: dma: reset q->rx_head on rx reset
Felix Fietkau [Mon, 12 Aug 2019 13:50:59 +0000 (15:50 +0200)]
mt76: dma: reset q->rx_head on rx reset

Fixes rx of the first frame if a fragmented rx was interrupted by the reset

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: apply calibration-free data from OTP
Felix Fietkau [Wed, 21 Aug 2019 13:21:00 +0000 (15:21 +0200)]
mt76: mt7615: apply calibration-free data from OTP

MT7615 chips usually come pre-calibrated, even when used on embedded boards.
In that case, the on-flash EEPROM data needs to be merged with some data
from OTP ROM.
Run this merge if the external EEPROM data is valid and OTP has valid fields.

Tested-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: add default implementation for mt76_sw_scan/mt76_sw_scan_complete
Lorenzo Bianconi [Wed, 21 Aug 2019 08:00:19 +0000 (10:00 +0200)]
mt76: add default implementation for mt76_sw_scan/mt76_sw_scan_complete

Introduce a default implementation for mt76_sw_scan and
mt76_sw_scan_complete in mt76 module and remove duplicated code
since most of the drivers share the same implementation

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: fix some checkpatch warnings
Ryder Lee [Wed, 21 Aug 2019 03:11:15 +0000 (11:11 +0800)]
mt76: fix some checkpatch warnings

This fixes the following checkpatch warnings:
CHECK: Alignment should match open parenthesis
CHECK: No space is necessary after a cast

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add BIP_CMAC_128 cipher support
Lorenzo Bianconi [Tue, 20 Aug 2019 14:56:25 +0000 (16:56 +0200)]
mt76: mt7615: add BIP_CMAC_128 cipher support

Refactor mt7615_mac_wtbl_set_key and introduce
the following routines in order to configure wtbl entries
and properly add hw support to BIP_CMAC_128 cipher:
- mt7615_mac_wtbl_update_cipher
- mt7615_mac_wtbl_update_pk
- mt7615_mac_wtbl_update_key

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: remove unnecessary mcu queue initialization
Lorenzo Bianconi [Fri, 9 Aug 2019 17:25:15 +0000 (19:25 +0200)]
mt76: mt7603: remove unnecessary mcu queue initialization

Remove unnecessary mcu queue initialization in mt7603_dma_init since it
has been already done in mt76_mmio_init

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: move mt76_tx_tasklet in mt76 module
Lorenzo Bianconi [Fri, 9 Aug 2019 17:06:02 +0000 (19:06 +0200)]
mt76: move mt76_tx_tasklet in mt76 module

Move mt76{15,03}_tx_tasklet in mt76_alloc_device in order to be used as
default tx_tasklet initialization. Remove duplicated code in
mt7603/mt7615 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: enable survey support
Lorenzo Bianconi [Mon, 5 Aug 2019 06:55:53 +0000 (08:55 +0200)]
mt76: mt7615: enable survey support

Introduce channel survey support for mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: move survey_time in mt76_dev
Lorenzo Bianconi [Mon, 5 Aug 2019 06:55:52 +0000 (08:55 +0200)]
mt76: mt7603: move survey_time in mt76_dev

Move survey_time field in mt76_dev in order to be reused adding survey
support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02u: enable survey support
Lorenzo Bianconi [Mon, 5 Aug 2019 06:55:51 +0000 (08:55 +0200)]
mt76: mt76x02u: enable survey support

Introduce channel survey support for mt76x2u and mt76x0u drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02u: enable multi-vif support
Lorenzo Bianconi [Fri, 2 Aug 2019 14:36:20 +0000 (16:36 +0200)]
mt76: mt76x02u: enable multi-vif support

Enable multi-interface support for mt76x02u driver. For the moment
allow max two concurrent interfaces in order to preserve enough room
for ps traffic since we are using beacon slots for it.
I have successfully tested the following configuration:
- AP + STA
- AP0 + AP1

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: do not copy beacon skb in mt76x02_mac_set_beacon_enable
Lorenzo Bianconi [Thu, 1 Aug 2019 08:26:23 +0000 (10:26 +0200)]
mt76: mt76x02: do not copy beacon skb in mt76x02_mac_set_beacon_enable

Do not copy beacon skb in mt76x02_mac_set_beacon_enable for usb devices
since it will be done in mt76x02_update_beacon_iter. Moreover squash
mt76x02_mac_set_beacon_enable and __mt76x02_mac_set_beacon_enable since
the latter is run just by mt76x02_mac_set_beacon_enable

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: introduce mt76x02_pre_tbtt_enable and mt76x02_beacon_enable macros
Lorenzo Bianconi [Thu, 1 Aug 2019 08:26:22 +0000 (10:26 +0200)]
mt76: mt76x02: introduce mt76x02_pre_tbtt_enable and mt76x02_beacon_enable macros

Improve code readability introducing mt76x02_pre_tbtt_enable and
mt76x02_beacon_enable utility macros

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add Smart Carrier Sense support
Lorenzo Bianconi [Sun, 28 Jul 2019 19:03:18 +0000 (21:03 +0200)]
mt76: mt7615: add Smart Carrier Sense support

Introduce Smart Carrier Sense support in order to tune device
sensitivity according to RTS error rate and False CCA reported by the
radio

Tested-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: rework locking scheme for mt7615_set_channel
Lorenzo Bianconi [Sun, 28 Jul 2019 19:03:17 +0000 (21:03 +0200)]
mt76: mt7615: rework locking scheme for mt7615_set_channel

As already done for mt7603 driver, move mt76.mutex lock inside
mt7615_set_channel since we need to grab mt76.mutex in mt7615_mac_work.
This is a preliminary patch to add Smart Carrier Sense (SCS) support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: switch to SPDX tag instead of verbose boilerplate text
Ryder Lee [Wed, 24 Jul 2019 08:58:20 +0000 (16:58 +0800)]
mt76: switch to SPDX tag instead of verbose boilerplate text

No functional change intended.

Add SPDX identifiers to all remaining files in /mt76.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: fix some checkpatch warnings
Ryder Lee [Wed, 24 Jul 2019 08:58:18 +0000 (16:58 +0800)]
mt76: mt76x02: fix some checkpatch warnings

This fixes the following checkpatch warnings:

ERROR: code indent should use tabs where possible
CHECK: Alignment should match open parenthesis
CHECK: No space is necessary after a cast
CHECK: Please don't use multiple blank lines
CHECK: Avoid precedence issues in macro
WARNING: Statements should start on a tabstop
WARNING: Unnecessary space before function pointer arguments

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fix some checkpatch warnings
Ryder Lee [Wed, 24 Jul 2019 08:58:17 +0000 (16:58 +0800)]
mt76: mt7615: fix some checkpatch warnings

This fixes the following checkpatch warnings:

WARNING: Improper SPDX comment style
Fix blank lines.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: fix some checkpatch warnings
Ryder Lee [Wed, 24 Jul 2019 08:58:16 +0000 (16:58 +0800)]
mt76: mt7603: fix some checkpatch warnings

This fixes the following checkpatch warnings:

WARNING: Improper SPDX comment style
CHECK: No space is necessary after a cast

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: Add paragraphs to describe the config symbols fully
Ryder Lee [Wed, 24 Jul 2019 08:58:15 +0000 (16:58 +0800)]
mt76: Add paragraphs to describe the config symbols fully

Update the help text to fix a checkpatch warning:

WARNING: please write a paragraph that describes the config symbol fully

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: update cw_min/max related settings
Ryder Lee [Mon, 22 Jul 2019 08:50:09 +0000 (16:50 +0800)]
mt76: mt7615: update cw_min/max related settings

Add default values of cw_min/max and use fls() for configuration.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add 4 WMM sets support
Ryder Lee [Mon, 22 Jul 2019 08:50:08 +0000 (16:50 +0800)]
mt76: mt7615: add 4 WMM sets support

Hardware supports 4 sets of WMM that should be put to good use.
And fix incorrect queue mapping in mt7615_conf_tx().

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: fix watchdog rescheduling in mt7603_set_channel
Lorenzo Bianconi [Thu, 18 Jul 2019 22:50:42 +0000 (00:50 +0200)]
mt76: mt7603: fix watchdog rescheduling in mt7603_set_channel

Convert MT7603_WATCHDOG_TIME in jiffies rescheduling watchdog delayed
work

Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fix MT7615_WATCHDOG_TIME definition
Lorenzo Bianconi [Thu, 18 Jul 2019 22:44:16 +0000 (00:44 +0200)]
mt76: mt7615: fix MT7615_WATCHDOG_TIME definition

Express watchdog timeout in jiffies since it is used directly in
ieee80211_queue_delayed_work

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>
5 years agomt76: introduce mt76_mmio_read_copy routine
Lorenzo Bianconi [Sat, 13 Jul 2019 15:09:06 +0000 (17:09 +0200)]
mt76: introduce mt76_mmio_read_copy routine

Add mt76_mmio_read_copy routine and the related function pointer in
mt76_bus_ops data structure. mt76_mmio_read_copy will be used to add
BIP_CMAC_128 cipher hw support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add set_key_cmd and mt76_wcid to mt7615_mac_wtbl_set_key signature
Lorenzo Bianconi [Sat, 13 Jul 2019 15:09:05 +0000 (17:09 +0200)]
mt76: mt7615: add set_key_cmd and mt76_wcid to mt7615_mac_wtbl_set_key signature

Introduce set_key_cmd and mt76_wcid pointer to mt7615_mac_wtbl_set_key
signature and do not set key to NULL if cmd is DISABLE_KEY.
This is a preliminary patch to add BIP_CMAC_128 hw support to mt7615
driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: remove wtbl_sec_key definition
Lorenzo Bianconi [Sat, 13 Jul 2019 15:09:04 +0000 (17:09 +0200)]
mt76: mt7615: remove wtbl_sec_key definition

Get rid of wtbl_sec_key definition since it is no longer used

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: introduce mt7615_mac_wtbl_set_key routine
Lorenzo Bianconi [Sat, 13 Jul 2019 15:09:03 +0000 (17:09 +0200)]
mt76: mt7615: introduce mt7615_mac_wtbl_set_key routine

Add mt7615_mac_wtbl_set_key routine to configure wtbl key parameter
directly from host cpu. This is a preliminary patch to add BIP_CMAC_128
hw support. Moreover add static qualifier to mt7615_mac_get_key_info
routine

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add mt7615_mac_wtbl_addr routine
Lorenzo Bianconi [Sat, 13 Jul 2019 15:09:02 +0000 (17:09 +0200)]
mt76: mt7615: add mt7615_mac_wtbl_addr routine

Introduce mt7615_mac_wtbl_addr rouinte to compute sta wtbl address.
This is a preliminary patch to update wtbl key directly from host
processor

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: move mt7615_mac_get_key_info in mac.c
Lorenzo Bianconi [Sat, 13 Jul 2019 15:09:01 +0000 (17:09 +0200)]
mt76: mt7615: move mt7615_mac_get_key_info in mac.c

This is a preliminary patch to update wtbl key directly from host
processor

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add missing register initialization
Felix Fietkau [Tue, 16 Jul 2019 16:12:07 +0000 (18:12 +0200)]
mt76: mt7615: add missing register initialization

- initialize CCA signal source
- initialize clock for band 1 (7615D)
- initialize BAR rate

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x0u: add support to TP-Link T2UHP
Lorenzo Bianconi [Fri, 5 Jul 2019 19:01:04 +0000 (21:01 +0200)]
mt76: mt76x0u: add support to TP-Link T2UHP

Introduce support to TP-Link T2UHP
https://wikidevi.com/wiki/TP-LINK_Archer_T2UHP

Tested-by: Sid Hayn <sidhayn@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: use params->ssn value directly
Stanislaw Gruszka [Fri, 12 Jul 2019 12:08:00 +0000 (14:08 +0200)]
mt76: mt7615: use params->ssn value directly

There is no point to use pointer to params->ssn.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: use params->ssn value directly
Stanislaw Gruszka [Fri, 12 Jul 2019 12:07:59 +0000 (14:07 +0200)]
mt76: mt7603: use params->ssn value directly

There is no point to use pointer to params->ssn.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76x02: use params->ssn value directly
Stanislaw Gruszka [Fri, 12 Jul 2019 12:07:58 +0000 (14:07 +0200)]
mt76: mt76x02: use params->ssn value directly

There is no point to use pointer to params->ssn.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: remove unneeded {put,get}_unaligned
Stanislaw Gruszka [Tue, 9 Jul 2019 15:14:55 +0000 (17:14 +0200)]
mt76: usb: remove unneeded {put,get}_unaligned

Compiler give us guarantees on variables alignment, so use
an variable as buffer when read/write registers and remove
unneeded {put,get}_unaligned.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: usb: fix endian in mt76u_copy
Stanislaw Gruszka [Tue, 9 Jul 2019 15:14:54 +0000 (17:14 +0200)]
mt76: usb: fix endian in mt76u_copy

In contrast to mt76_wr() which we use to program registers,
on mt76_wr_copy() we should not change endian of the data.

Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: fix invalid fallback rates
Felix Fietkau [Fri, 12 Jul 2019 06:19:35 +0000 (08:19 +0200)]
mt76: mt7603: fix invalid fallback rates

Only decrement the rate index on duplicate rates if it is not already 0

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fix invalid fallback rates
Felix Fietkau [Thu, 11 Jul 2019 19:34:25 +0000 (21:34 +0200)]
mt76: mt7615: fix invalid fallback rates

Only decrement the rate index on duplicate rates if it is not already 0

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fix PS buffering of action frames
Felix Fietkau [Thu, 11 Jul 2019 19:32:00 +0000 (21:32 +0200)]
mt76: mt7615: fix PS buffering of action frames

Bufferable management frames need to be put in the data queue, otherwise
they will not be buffered when the receiver is asleep.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fix using VHT STBC rates
Felix Fietkau [Thu, 11 Jul 2019 19:17:06 +0000 (21:17 +0200)]
mt76: mt7615: fix using VHT STBC rates

The hardware expects MT_TX_RATE_NSS to be filled with the number of
space/time streams. For non-STBC rates, this is equal to nss.
For 1-stream STBC, this needs to be set to 2.
This is relevant for VHT rates only, on HT, the value is derived from MCS
internally.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt76u: fix typo in mt76u_fill_rx_sg
Lorenzo Bianconi [Wed, 3 Jul 2019 22:59:19 +0000 (00:59 +0200)]
mt76: mt76u: fix typo in mt76u_fill_rx_sg

Fix typo setting urb->transfer_buffer_length in mt76u_fill_rx_sg

Fixes: b40b15e1521f ("mt76: add usb support to mt76 layer")
Fixes: f8f527b16db5 ("mt76: usb: use EP max packet aligned buffer sizes for rx")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: sync with mt7603 rate control changes
Felix Fietkau [Wed, 3 Jul 2019 19:39:04 +0000 (21:39 +0200)]
mt76: mt7615: sync with mt7603 rate control changes

- Store the previous and current rate set in the driver + the TSF value
  at the time of the switch.
- Use the tx status TSF value to determine which rate set needs to be used
  as reference.
- Report only short or long GI rates for a single status event, not a mix.
- The hardware reports the last used rate index. Use it along with the
  retry count to figure out what rate was used for the first attempt.
- Use the same retry count value for all rate slots to make this calculation
  work.
- Derive the probe rate from the current rateset instead of the skb cb
- Do not wait for a status report for the probe frame before removing the
  probe rate from the rate table. Do it immediately after it was referenced
  in a tx status report.
- Use the first half of the first rate retry budget for the probe rate
  in order to avoid using too many retries on that rate
- Switch from lower rates to higher rates more conservatively
- enable hardware rate up/down selection

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: reset rate index/counters on rate table update
Felix Fietkau [Wed, 3 Jul 2019 19:32:10 +0000 (21:32 +0200)]
mt76: mt7615: reset rate index/counters on rate table update

These values must be initialized to zero, otherwise the hardware could
reuse previous values, especially the rate index

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: move mt7615_mcu_set_rates to mac.c
Felix Fietkau [Wed, 3 Jul 2019 18:08:35 +0000 (20:08 +0200)]
mt76: mt7615: move mt7615_mcu_set_rates to mac.c

It bypasses the MCU, so it does not belong in mcu.c
Also make mt7615_mac_tx_rate_val static

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7603: enable hardware rate up/down selection
Felix Fietkau [Wed, 3 Jul 2019 19:44:23 +0000 (21:44 +0200)]
mt76: mt7603: enable hardware rate up/down selection

Improves performance by switching away from bad rates faster

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: introduce mt7615_mcu_send_ram_firmware routine
Lorenzo Bianconi [Tue, 2 Jul 2019 11:39:49 +0000 (13:39 +0200)]
mt76: mt7615: introduce mt7615_mcu_send_ram_firmware routine

Add mt7615_mcu_send_ram_firmware routine since mt7615_load_ram runs the
same code to send ram firmware to cr4 and n9 mcus. Moreover rename
gen_dl_mode in mt7615_mcu_gen_dl_mode.
This patch does not introduce any behaviour change, it is just code
refactor.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: always release sem in mt7615_load_patch
Lorenzo Bianconi [Tue, 2 Jul 2019 09:24:51 +0000 (11:24 +0200)]
mt76: mt7615: always release sem in mt7615_load_patch

Release patch semaphore even if request_firmware fails in
mt7615_load_patch

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fall back to sw encryption for unsupported ciphers
Lorenzo Bianconi [Mon, 1 Jul 2019 13:04:39 +0000 (15:04 +0200)]
mt76: mt7615: fall back to sw encryption for unsupported ciphers

Fix following warning falling back to sw encryption for unsupported
ciphers

WARNING: CPU: 2 PID: 1495 at backports-4.19.32-1/net/mac80211/key.c:1023
mt76_wcid_key_setup+0x68/0xbc [mt76]
CPU: 2 PID: 1495 Comm: hostapd Not tainted 4.14.131 #0
Stack : 00000000 8f0f8bc0 00000000 8007ccec 805f0000 8058ec18 00000000 00000000
80559788 8dca79bc 8fefb10c 805c89c7 805545c8 00000001 8dca7960 53261662
00000000 00000000 80640000 00004668 00000000 000000e9 00000007 00000000
00000000 805d0000 00072537 00000000 80000000 00000000 805f0000 8f1e70d0
8e8fa098 000003ff 805c0000 8f0f8bc0 00000001 802d4340 00000008 80630008
[<800108d0>] show_stack+0x58/0x100
[<8049214c>] dump_stack+0x9c/0xe0
[<80033998>] __warn+0xe0/0x138
[<80033a80>] warn_slowpath_null+0x1c/0x2c
[<8e8fa098>] mt76_wcid_key_setup+0x68/0xbc [mt76]
[<8e889930>] mt7615_eeprom_init+0x7c0/0xe14 [mt7615e]

Suggested-by: Sebastian Gottschall <s.gottschall@newmedia-net.de>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: clean up FWDL TXQ during/after firmware upload
Felix Fietkau [Mon, 1 Jul 2019 18:17:40 +0000 (20:17 +0200)]
mt76: mt7615: clean up FWDL TXQ during/after firmware upload

Since we don't clean that tx queue from the tx tasklet, we need to do it
after the firmware upload is done. This patch also adds a cleanup step during
the upload, to help reclaim memory faster.

Fixes unprocessed queued frames eating up memory  long after the firmware
upload has already completed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add radar pattern test knob to debugfs
Lorenzo Bianconi [Sat, 29 Jun 2019 10:36:11 +0000 (12:36 +0200)]
mt76: mt7615: add radar pattern test knob to debugfs

Introduce mt7615_mcu_rdd_send_pattern routine to trigger a radar pattern
detection. Moreover move debugfs related routines in a dedicated source
file.

Suggested-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add csa support
Lorenzo Bianconi [Sat, 29 Jun 2019 10:36:10 +0000 (12:36 +0200)]
mt76: mt7615: add csa support

Add Channel Switch Announcement support to mt7615 driver updating beacon
template with CSA IE received from mac80211

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: do not perform txcalibration before cac is complited
Lorenzo Bianconi [Sat, 29 Jun 2019 10:36:08 +0000 (12:36 +0200)]
mt76: mt7615: do not perform txcalibration before cac is complited

Delay channel calibration after Channel Availability Check. Add some
code cleanup to mt7615_mcu_set_channel

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: add hw dfs pattern detector support
Lorenzo Bianconi [Sat, 29 Jun 2019 10:36:07 +0000 (12:36 +0200)]
mt76: mt7615: add hw dfs pattern detector support

Add hw radar detection support to mt7615 driver in order to
unlock dfs channels on 5GHz band

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: introduce mt7615_regd_notifier
Lorenzo Bianconi [Sat, 29 Jun 2019 10:36:06 +0000 (12:36 +0200)]
mt76: mt7615: introduce mt7615_regd_notifier

Introduce mt7615_regd_notifier callback. This is a preliminary patch to
add radar detection support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agomt76: mt7615: fix sparse warnings: warning: restricted __le16 degrades to integer
Lorenzo Bianconi [Thu, 27 Jun 2019 14:49:44 +0000 (16:49 +0200)]
mt76: mt7615: fix sparse warnings: warning: restricted __le16 degrades to integer

Fix the following sparse warning in __mt7615_mcu_msg_send:
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c:78:15: sparse: warning:
restricted __le16 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c:78:15: sparse: warning:
cast from restricted __le16

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>
5 years agomt76: round up length on mt76_wr_copy
Felix Fietkau [Mon, 1 Jul 2019 11:15:07 +0000 (13:15 +0200)]
mt76: round up length on mt76_wr_copy

When beacon length is not a multiple of 4, the beacon could be sent with
the last 1-3 bytes corrupted. The skb data is guaranteed to have enough
room for reading beyond the end, because it is always followed by
skb_shared_info, so rounding up is safe.
All other callers of mt76_wr_copy have multiple-of-4 length already.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years agozd1211rw: zd_usb: Use struct_size() helper
Gustavo A. R. Silva [Fri, 30 Aug 2019 18:57:16 +0000 (13:57 -0500)]
zd1211rw: zd_usb: Use struct_size() helper

One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct usb_int_regs {
...
        struct reg_data regs[0];
} __packed;

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

So, replace the following function:

static int usb_int_regs_length(unsigned int count)
{
       return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data);
}

with:

struct_size(regs, regs, count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agobrcmfmac: get chip's default RAM info during PCIe setup
Rafał Miłecki [Thu, 29 Aug 2019 08:27:01 +0000 (10:27 +0200)]
brcmfmac: get chip's default RAM info during PCIe setup

Getting RAM info just once per driver's lifetime (during chip
recognition) is not enough as it may get adjusted later (depending on
the used firmware). Subsequent inits may load different firmwares so a
full RAM recognition is required on every PCIe setup. This is especially
important since implementing hardware reset on a firmware crash.

Moreover calling brcmf_chip_get_raminfo() makes sure that RAM core is
up. It's important as having BCMA_CORE_SYS_MEM down on BCM4366 was
resulting in firmware failing to initialize and following error:
[   65.657546] brcmfmac 0000:01:00.0: brcmf_pcie_download_fw_nvram: Invalid shared RAM address 0x04000001

This change makes brcmf_chip_get_raminfo() call during chip recognition
redundant for PCIe devices but SDIO and USB still need it and it's a
very small overhead anyway.

Fixes: 4684997d9eea ("brcmfmac: reset PCIe bus on a firmware crash")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agobcma: fix incorrect update of BCMA_CORE_PCI_MDIO_DATA
Colin Ian King [Tue, 27 Aug 2019 08:16:20 +0000 (09:16 +0100)]
bcma: fix incorrect update of BCMA_CORE_PCI_MDIO_DATA

An earlier commit re-worked the setting of the bitmask and is now
assigning v with some bit flags rather than bitwise or-ing them
into v, consequently the earlier bit-settings of v are being lost.
Fix this by replacing an assignment with the bitwise or instead.

Addresses-Coverity: ("Unused value")
Fixes: 2be25cac8402 ("bcma: add constants for PCI and use them")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agobrcmfmac: replace strncpy() by strscpy()
Xulin Sun [Fri, 23 Aug 2019 07:47:08 +0000 (15:47 +0800)]
brcmfmac: replace strncpy() by strscpy()

The strncpy() may truncate the copied string,
replace it by the safer strscpy().

To avoid below compile warning with gcc 8.2:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:In function 'brcmf_vndr_ie':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:4227:2:
warning: 'strncpy' output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(iebuf, add_del_cmd, VNDR_IE_CMD_LEN - 1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agort2x00: do not set IEEE80211_TX_STAT_AMPDU_NO_BACK on tx status
Stanislaw Gruszka [Fri, 23 Aug 2019 07:09:56 +0000 (09:09 +0200)]
rt2x00: do not set IEEE80211_TX_STAT_AMPDU_NO_BACK on tx status

According to documentation IEEE80211_TX_STAT_AMPDU_NO_BACK is suppose
to be used when we do not recive BA (BlockAck). However on rt2x00 we
use it when remote station fail to decode one or more subframes within
AMPDU (some bits are not set in BlockAck bitmap). Setting the flag result
in sent of BAR (BlockAck Request) frame and this might result of abuse
of BA session, since remote station can sent BA with incorrect
sequence numbers after receiving BAR. This problem is visible especially
when connecting two rt2800 devices.

Previously I observed some performance benefits when using the flag
when connecting with iwlwifi devices. But currently possibly due
to reacent changes in rt2x00 removing the flag has no effect on
those test cases.

So remove the IEEE80211_TX_STAT_AMPDU_NO_BACK.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agoipw2x00: fix spelling mistake "initializationg" -> "initialization"
Colin Ian King [Thu, 22 Aug 2019 22:00:25 +0000 (23:00 +0100)]
ipw2x00: fix spelling mistake "initializationg" -> "initialization"

There is a spelling mistake in an IPW_DEBUG_INFO message. Fix it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agoairo: fix memory leaks
Wenwen Wang [Fri, 16 Aug 2019 03:50:02 +0000 (22:50 -0500)]
airo: fix memory leaks

In proc_BSSList_open(), 'file->private_data' is allocated through kzalloc()
and 'data->rbuffer' is allocated through kmalloc(). In the following
execution, if an error occurs, they are not deallocated, leading to memory
leaks. To fix this issue, free the allocated memory regions before
returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agozd1211rw: remove false assertion from zd_mac_clear()
Oliver Neukum [Tue, 13 Aug 2019 12:04:11 +0000 (14:04 +0200)]
zd1211rw: remove false assertion from zd_mac_clear()

The function is called before the lock which is asserted was ever used.
Just remove it.

Reported-by: syzbot+74c65761783d66a9c97c@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agobrcmfmac: remove redundant assignment to pointer hash
Colin Ian King [Fri, 9 Aug 2019 17:22:17 +0000 (18:22 +0100)]
brcmfmac: remove redundant assignment to pointer hash

The pointer hash is being initialized with a value that is never read
and is being re-assigned a little later on. The assignment is
redundant and hence can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agobcma: remove two unused variables
YueHaibing [Fri, 9 Aug 2019 08:53:08 +0000 (16:53 +0800)]
bcma: remove two unused variables

drivers/bcma/driver_mips.c:70:18: warning:
 ipsflag_irq_shift defined but not used [-Wunused-const-variable=]
drivers/bcma/driver_mips.c:62:18: warning:
 ipsflag_irq_mask defined but not used [-Wunused-const-variable=]

They are never used, so can be removed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agobrcm80211: Avoid possible null-pointer dereferences in wlc_phy_radio_init_2056()
Jia-Ju Bai [Mon, 29 Jul 2019 09:56:52 +0000 (17:56 +0800)]
brcm80211: Avoid possible null-pointer dereferences in wlc_phy_radio_init_2056()

In wlc_phy_radio_init_2056(), regs_SYN_2056_ptr, regs_TX_2056_ptr and
regs_RX_2056_ptr may be not assigned, and thus they are still NULL.
Then, they are used on lines 20042-20050:
    wlc_phy_init_radio_regs(pi, regs_SYN_2056_ptr, (u16) RADIO_2056_SYN);
wlc_phy_init_radio_regs(pi, regs_TX_2056_ptr, (u16) RADIO_2056_TX0);
wlc_phy_init_radio_regs(pi, regs_TX_2056_ptr, (u16) RADIO_2056_TX1);
wlc_phy_init_radio_regs(pi, regs_RX_2056_ptr, (u16) RADIO_2056_RX0);
wlc_phy_init_radio_regs(pi, regs_RX_2056_ptr, (u16) RADIO_2056_RX1);

Thus, possible null-pointer dereferences may occur.

To avoid these bugs, when these variables are not assigned,
wlc_phy_radio_init_2056() directly returns.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortw88: pci: enable MSI interrupt
Yu-Yen Ting [Tue, 3 Sep 2019 09:14:07 +0000 (17:14 +0800)]
rtw88: pci: enable MSI interrupt

MSI interrupt should be enabled on certain platform.

Add a module parameter disable_msi to disable MSI interrupt,
driver will then use legacy interrupt instead.

One could rebind the PCI device, probe() will pick up the
new value of the module parameter. Such as:

    echo '0000:01:00.0' > /sys/bus/pci/drivers/rtw_pci/unbind
    echo '0000:01:00.0' > /sys/bus/pci/drivers/rtw_pci/bind

Tested-by: Ján Veselý <jano.vesely@gmail.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Yu-Yen Ting <steventing@realtek.com>
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortw88: pci: Move a mass of jobs in hw IRQ to soft IRQ
Jian-Hong Pan [Tue, 3 Sep 2019 09:14:06 +0000 (17:14 +0800)]
rtw88: pci: Move a mass of jobs in hw IRQ to soft IRQ

There is a mass of jobs between spin lock and unlock in the hardware
IRQ which will occupy much time originally. To make system work more
efficiently, this patch moves the jobs to the soft IRQ (bottom half) to
reduce the time in hardware IRQ.

Signed-off-by: Jian-Hong Pan <jian-hong@endlessm.com>
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortw88: remove redundant assignment to pointer debugfs_topdir
Colin Ian King [Thu, 22 Aug 2019 11:37:28 +0000 (12:37 +0100)]
rtw88: remove redundant assignment to pointer debugfs_topdir

Pointer debugfs_topdir is initialized to a value that is never read
and it is re-assigned later. The initialization is redundant and can
be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortw88: drop unused rtw_coex_coex_dm_reset()
Guenter Roeck [Mon, 19 Aug 2019 18:17:57 +0000 (11:17 -0700)]
rtw88: drop unused rtw_coex_coex_dm_reset()

0day reports:

sparse warnings:

drivers/net/wireless/realtek/rtw88/coex.c:2457:6: sparse:
symbol 'rtw_coex_coex_dm_reset' was not declared. Should it be static?

rtw_coex_coex_dm_reset() is not called. Remove it.

Fixes: 4136214f7c46 ("rtw88: add BT co-existence support")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortw88: Fix an error message
Dan Carpenter [Wed, 14 Aug 2019 10:46:42 +0000 (13:46 +0300)]
rtw88: Fix an error message

The WARN_ON() macro takes a condition, not a warning message.  I've
changed this to use WARN() instead.

Fixes: 4136214f7c46 ("rtw88: add BT co-existence support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192ce: Fix incorrect returned values
Larry Finger [Tue, 3 Sep 2019 01:18:13 +0000 (20:18 -0500)]
rtlwifi: rtl8192ce: Fix incorrect returned values

In commit 98fd8db59a00 ("rtlwifi: rtl8192ce: Convert macros that set
descriptor"), all the routines that get fields from a descriptor
were changed to return signed integer values. This is incorrect for the
routines that get the entire 32-bit word. In this case, an unsigned
quantity is required.

Fixes: 98fd8db59a00 ("rtlwifi: rtl8192ce: Convert macros that set descriptor")
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8188ee: Fix incorrect returned values
Larry Finger [Tue, 3 Sep 2019 01:18:12 +0000 (20:18 -0500)]
rtlwifi: rtl8188ee: Fix incorrect returned values

In commit 36eda7568f2e ("rtlwifi: rtl8188ee: Convert macros that set
descriptor"), all the routines that get fields from a descriptor were
changed to return signed integer values. This is incorrect for the
routines that get the entire 32-bit word. In this case, an unsigned
quantity is required.

Fixes: 36eda7568f2e ("rtlwifi: rtl8188ee: Convert macros that set descriptor")
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8821ae: Fix incorrect returned values
Larry Finger [Tue, 3 Sep 2019 01:18:11 +0000 (20:18 -0500)]
rtlwifi: rtl8821ae: Fix incorrect returned values

In commit bd421dab7515 ("rtlwifi: rtl8821ae: Convert macros that set
descriptor"), all the routines that get fields from a descriptor
were changed to return signed integer values. This is incorrect for the
routines that get the entire 32-bit word. In this case, an unsigned
quantity is required.

Fixes: bd421dab7515 ("rtlwifi: rtl8821ae: Convert macros that set descriptor")
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192cu: Convert inline routines to little-endian words
Larry Finger [Sun, 1 Sep 2019 15:47:06 +0000 (10:47 -0500)]
rtlwifi: rtl8192cu: Convert inline routines to little-endian words

In this step, the read/write routines for the descriptors are converted
to use __le32 quantities, thus a lot of casts can be removed. Callback
routines still use the 8-bit arrays, but these are changed within the
specified routine.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192cu: Convert macros that set descriptor
Larry Finger [Sun, 1 Sep 2019 15:47:05 +0000 (10:47 -0500)]
rtlwifi: rtl8192cu: Convert macros that set descriptor

As a first step in the conversion, the macros that set the RX and TX
descriptors are converted to static inline routines, and the names are
changed from upper to lower case. To minimize the changes in a given
step, the input descriptor information is left as as a byte array
(u8 *), even though it should be a little-endian word array (__le32 *).
That will be changed in the next patch.

Several places where checkpatch.pl complains about a space after a cast
and other warnings are fixed.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192cu: Replace local bit manipulation macros
Larry Finger [Sun, 1 Sep 2019 15:47:04 +0000 (10:47 -0500)]
rtlwifi: rtl8192cu: Replace local bit manipulation macros

This driver uses a set of local macros to manipulate the TX and RX
descriptors, which are all little-endian quantities. These macros
are replaced by the bitfield macros le32p_replace_bits() and
le32_get_bits(). In several places, the macros operated on an entire
32-bit word. In these cases, a direct read or replacement is used.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192cu: Remove unused GET_XXX and SET_XXX
Larry Finger [Sun, 1 Sep 2019 15:47:03 +0000 (10:47 -0500)]
rtlwifi: rtl8192cu: Remove unused GET_XXX and SET_XXX

As the first step in converting from macros that get/set information
in the RX and TX descriptors, unused macros are being removed.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192ee: Remove some variable initializations
Larry Finger [Sat, 31 Aug 2019 18:06:44 +0000 (13:06 -0500)]
rtlwifi: rtl8192ee: Remove some variable initializations

A number of variables are initialized when declared that set later in the
routine, thus the initialization can be removed.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192ee: Convert inline routines to little-endian words
Larry Finger [Sat, 31 Aug 2019 18:06:43 +0000 (13:06 -0500)]
rtlwifi: rtl8192ee: Convert inline routines to little-endian words

In this step, the read/write routines for the descriptors are converted
to use __le32 quantities, thus a lot of casts can be removed. Callback
routines still use the 8-bit arrays, but these are changed within the
specified routine.

The macro that cleared a descriptor has now been converted into an inline
routine.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192ee: Convert macros that set descriptor
Larry Finger [Sat, 31 Aug 2019 18:06:42 +0000 (13:06 -0500)]
rtlwifi: rtl8192ee: Convert macros that set descriptor

As a first step in the conversion, the macros that set the RX and TX
descriptors are converted to static inline routines, and the names are
changed from upper to lower case. To minimize the changes in a given
step, the input descriptor information is left as as a byte array
(u8 *), even though it should be a little-endian word array (__le32 *).
That will be changed in the next patch.

Several places where checkpatch.pl reports lines too long are fixed.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192ee: Replace local bit manipulation macros
Larry Finger [Sat, 31 Aug 2019 18:06:41 +0000 (13:06 -0500)]
rtlwifi: rtl8192ee: Replace local bit manipulation macros

This driver uses a set of local macros to manipulate the RX and TX
descriptors, which are all little-endian quantities. These macros
are replaced by the bitfield macros le32p_replace_bits() and
le32_get_bits(). In several places, the macros operated on an entire
32-bit word. In these cases, a direct read or replacement is used.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192ee: Remove unused GET_XXX and SET_XXX
Larry Finger [Sat, 31 Aug 2019 18:06:40 +0000 (13:06 -0500)]
rtlwifi: rtl8192ee: Remove unused GET_XXX and SET_XXX

As the first step in converting from macros that get/set information
in the RX and TX descriptors, unused macros are being removed.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl_pci: Fix memory leak when hardware init fails
Larry Finger [Mon, 26 Aug 2019 22:03:44 +0000 (17:03 -0500)]
rtlwifi: rtl_pci: Fix memory leak when hardware init fails

If the call to hw_init() fails for any of the drivers, the driver will
leak memory that was allocated in BT coexistence setup. Technically, each
of the drivers should have done this free; however placing it in rtl_pci
fixes all the drivers with only a single patch.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: remove unused variables 'RTL8712_SDIO_EFUSE_TABLE' and 'MAX_PGPKT_SIZE'
YueHaibing [Fri, 16 Aug 2019 14:05:13 +0000 (22:05 +0800)]
rtlwifi: remove unused variables 'RTL8712_SDIO_EFUSE_TABLE' and 'MAX_PGPKT_SIZE'

drivers/net/wireless/realtek/rtlwifi/efuse.c:16:31:
 warning: RTL8712_SDIO_EFUSE_TABLE defined but not used [-Wunused-const-variable=]
drivers/net/wireless/realtek/rtlwifi/efuse.c:9:17:
 warning: MAX_PGPKT_SIZE defined but not used [-Wunused-const-variable=]

They are never used, so can be removed.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: rtl8192cu: Fix value set in descriptor
Larry Finger [Mon, 12 Aug 2019 19:27:41 +0000 (14:27 -0500)]
rtlwifi: rtl8192cu: Fix value set in descriptor

In the process of converting the bit manipulation macros were converted
to use GENMASK(), the compiler reported a value too big for the field.
The offending statement was trying to write 0x100 into a 5-bit field.
An accompaning comment says to set bit 3, thus the code is changed
appropriately.

This error has been in the driver since its initial submission.

Fixes: 29d00a3e46bb ("rtlwifi: rtl8192cu: Add routine trx")
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agortlwifi: fix non-kerneldoc comment in usb.c
Valdis Klētnieks [Thu, 8 Aug 2019 01:51:58 +0000 (21:51 -0400)]
rtlwifi: fix non-kerneldoc comment in usb.c

Fix spurious warning message when building with W=1:

  CC [M]  drivers/net/wireless/realtek/rtlwifi/usb.o
drivers/net/wireless/realtek/rtlwifi/usb.c:243: warning: Cannot understand  * on line 243 - I thought it was a doc line
drivers/net/wireless/realtek/rtlwifi/usb.c:760: warning: Cannot understand  * on line 760 - I thought it was a doc line
drivers/net/wireless/realtek/rtlwifi/usb.c:790: warning: Cannot understand  * on line 790 - I thought it was a doc line

Clean up the comment format.

Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
5 years agoMerge branch 'mvpp2-per-cpu-buffers'
David S. Miller [Mon, 2 Sep 2019 19:07:46 +0000 (12:07 -0700)]
Merge branch 'mvpp2-per-cpu-buffers'

Matteo Croce says:

====================
mvpp2: per-cpu buffers

This patchset workarounds an PP2 HW limitation which prevents to use
per-cpu rx buffers.
The first patch is just a refactor to prepare for the second one.
The second one allocates percpu buffers if the following conditions are met:
- CPU number is less or equal 4
- no port is using jumbo frames

If the following conditions are not met at load time, of jumbo frame is enabled
later on, the shared allocation is reverted.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
5 years agomvpp2: percpu buffers
Matteo Croce [Mon, 2 Sep 2019 10:21:37 +0000 (12:21 +0200)]
mvpp2: percpu buffers

Every mvpp2 unit can use up to 8 buffers mapped by the BM (the HW buffer
manager). The HW will place the frames in the buffer pool depending on the
frame size: short (< 128 bytes), long (< 1664) or jumbo (up to 9856).

As any unit can have up to 4 ports, the driver allocates only 2 pools,
one for small and one long frames, and share them between ports.
When the first port MTU is set higher than 1664 bytes, a third pool is
allocated for jumbo frames.

This shared allocation makes impossible to use percpu allocators,
and creates contention between HW queues.

If possible, i.e. if the number of possible CPU are less than 8 and jumbo
frames are not used, switch to a new scheme: allocate 8 per-cpu pools for
short and long frames and bind every pool to an RXQ.

When the first port MTU is set higher than 1664 bytes, the allocation
scheme is reverted to the old behaviour (3 shared pools), and when all
ports MTU are lowered, the per-cpu buffers are allocated again.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>