Commit Graph
751 Commits
Author SHA1 Message Date
Stanislaw GruszkaandFelix Fietkau 51b74acc22 mt76: use mac_wcid_set_drop in mt76x0
Move mt76x02_mac_wcid_set_drop to common code and use it in mt76x0.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 732535e54b mt76: unify mac_wcid_setup
Merge mt76x{0,2}_mac_wcid_setup into common code.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 428625526e mt76: unify mt76x02_mac_wcid_set_key
Merge mt76x{0,2}_mac_wcid_set_key into common code.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 34a95b8bf5 mt76: unify mac_shared_key_setup
Merge mt76x{0,2} mac_shared_key_setup into common code.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau f6c19cff97 mt76: add helpers for register access with mt76_dev struct
Add helpers for register access from common code.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 55bceeeda2 mt76: unify mac_get_key_info
Merge mt76x{0,2} mac_get_key_info into new mt76x02_mac.c file.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau a2380992d8 mt76: create new mt76x02-lib module for common mt76x{0,2} code
Move rxfilter and mutex to common structure. Create mt76x02-lib.ko
for mt76x0 and mt76x2 common functions and create new unified
mt76x02_configure_filter() function there.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 493feb90c9 mt76: merge mt76x0/regs.h into mt76x02_regs.h
Add missed definitions for mt76x0 into mt76x02_regs.h. Remove
mt76x0/regs.h and fixup mt76x0 code to adjust to some diffrent
registers/fields names.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau fc636f0a21 mt76: rename mt76x2_regs.h
MAC registers are the same for mt76x0 and mt76x2. Rename mt76x2_regs.h
file to reflect that.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 884eca5f4b mt76: unify wait_for_mac
Create new mt76x02_mac.h for common mac functions of mt76x0 and mt76x2
and unity wait_for_mac for both drivers.

Signed-off-by: Stanislaw Gruszka <[email protected]>
2018-09-11 13:49:19 +02:00
Geert UytterhoevenandFelix Fietkau f8a0da45ab mt76: Fix comparisons with invalid hardware key index
With gcc 4.1.2:

    drivers/net/wireless/mediatek/mt76/mt76x0/tx.c: In function ‘mt76x0_tx’:
    drivers/net/wireless/mediatek/mt76/mt76x0/tx.c:169: warning: comparison is always true due to limited range of data type
    drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c: In function ‘mt76x2_tx’:
    drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c:35: warning: comparison is always true due to limited range of data type

While assigning -1 to a u8 works fine, comparing with -1 does not work
as expected.

Fix this by comparing with 0xff, like is already done in some other
places.

Signed-off-by: Geert Uytterhoeven <[email protected]>
2018-09-11 13:49:19 +02:00
Kees CookandFelix Fietkau d1645aa45b mt76x0: Remove VLA usage
Even with "const" variables, the compiler will generate warnings about
VLA usage. In the quest to remove all VLAs from the kernel[1], this uses
a #define instead of a const to do the array sizing.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Fixes: e87b5039511a ("mt76x0: eeprom files")
Signed-off-by: Kees Cook <[email protected]>
Acked-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 560b643ebd mt76x0: perform mt76x0_mac_set_ampdu_factor
Remove return added accidentally in mt76x0_mac_set_ampdu_factor.

Reported-by: Dan Carpenter <[email protected]>
Fixes: a77443498137 ("mt76x0: mac files")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 4fe2b16a93 mt76x0: correct type for eeprom gain value
Change type to u8 to allow sanity check agaist 0xff;

Reported-by: Dan Carpenter <[email protected]>
Fixes: e87b5039511a ("mt76x0: eeprom files")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 1cb65d573f mt76x0: rename trace symbols
Rename trace symbols that conflict with mt7601u and remove some
definitions that are not used.

Patch fixes build errors like this:
ld: drivers/net/wireless/mediatek/mt76/mt76x0/trace.o:(__tracepoints+0x0): multiple definition of `__tracepoint_set_shared_key'; drivers/net/wireless/mediatek/mt7601u/trace.o:(__tracepoints+0x0): first defined here

Reported-by: Stephen Rothwell <[email protected]>
Fixes: 7b4859026ccd ("mt76x0: core files")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 1388140d6d mt76x0: rename mt76_* functions
mt76_* functions conflicts with mt7601u driver what prevents to build
those drivers in the kernel or use both drivers modules at once.

Patch fixes build errors like this:
ld: drivers/net/wireless/mediatek/mt76/mt76x0/mac.o:(.opd+0x30): multiple definition of `mt76_mac_tx_rate_val'; drivers/net/wireless/mediatek/mt7601u/mac.o:(.opd+0x30): first defined here

Reported-by: Stephen Rothwell <[email protected]>
Fixes: 7b4859026ccd ("mt76x0: core files")
Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 2f37f6009c mt76x0: load firmware from mediatek subdir
Firmware blob will be located in mediatek subdirectory. Add "u" suffix
to indicate this is USB device firmware.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 5c38d48ef7 mt76x0: disable HW before probe
Disable HW before probe, otherwise after reboot we will fail
to initialize MCU.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau e176af8f13 mt76: Kconfig and Makefile for mt76x0 driver
Add Kconfig and Makefiles for mt76x0 driver. Now the driver
can be build.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 5892efd49a mt76: add more states
Add states needed for mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 08dec4cd69 mt76x0: main file
Add main file of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 7395bbae59 mt76x0: dma and tx files
Add dma and tx files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 18a9d4e4e7 mt76x0: trace and debugfs files
Add trace and debugfs files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau c6336547c6 mt76x0: eeprom files
Add eeprom files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 5d50834213 mt76x0: init files
Add init files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 0d7d9eda0b mt76x0: phy files
Add phy files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau c332481b58 mt76x0: mcu files
Add mcu files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau a2c1068719 mt76x0: usb files
Add usb files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 6ed7bc2be7 mt76x0: mac files
Add mac files of mt76x0 driver.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Stanislaw GruszkaandFelix Fietkau 253c44367f mt76x0: core files
Core files of mt76x0 driver.

mt76x0 driver adds support for Mediatek MT7610U based
USB Wi-Fi dongles.

Signed-off-by: Stanislaw Gruszka <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 25b4598274 mt76: add driver code for MT76x2u based devices
MT76x2u is a 2x2 USB 802.11ac chipset by MediaTek. This driver currently
support station mode

Tested-by: <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 99a3afad76 mt76: add usb support to mt76 layer
This will be used by drivers for MT76x2u based devices

Tested-by: <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 7625508f42 mt76: move mt76x2_debugfs in mt76-common module
Move mt76x2_debugfs code in mt76-common module since it is shared
between mt76x2 and mt76x2u

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 264edbe6df mt76: add mt76x2_phy_common to mt76x2-common module
Move phy related code shared between mt76x2 and mt76x2u in
mt76x2-common module

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 61c4c614b0 mt76: add mt76x2_common to mt76x2-common module
Move core related code shared between mt76x2 and mt76x2u in
mt76x2-common module

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 8f568cebdb mt76: add mt76x2_init_common to mt76x2-common module
Move init related code shared between mt76x2 and mt76x2u in
mt76x2-common module

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 29f960aa27 mt76: add mt76x2_mac_common to mt76x2-common module
Move mac related code shared between mt76x2 and mt76x2u in
mt76x2-common module

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 9bf1aa1d8c mt76: add mt76x2_tx_common to mt76x2-common module
Move tx related code shared between mt76x2 and mt76x2u in mt76x2-common
module

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau d099694a3d mt76: introduce mt76x2-common module
In order to remove usb dependency from pcie code, add mt76x2-common as
a container of shared code between mt76x2 and mt76x2u. Add eeprom code
to mt76x2-common module

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 66f394984d mt76: introduce tx_queue_skb function pointer in mt76_bus_ops
Add tx_queue_skb function pointer in mt76_bus_ops since mt76x2u based
devices do not map mt76x2_txwi on dma buffers and it is not possible
to reuse mt76_dma_tx_queue_skb() routine to enqueue tx frames to
hw buffers

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 7ac6dac9a3 mt76: rename mt76_tx_queue_skb in mt76_dma_tx_queue_skb
Move mt76_dma_tx_queue_skb routine in dma.c.
Remove static qualifier from mt76_get_txwi definition

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 1ab6cea9e5 mt76x2: add buffer len to mt76x2_mac_write_txwi signature
Add frame length to mt76x2_mac_write_txwi routine signature and do not
fetch it from skb since txwi data structure is added at the beginning of
the skb for usb based devices and mt76x2_mac_write_txwi will be shared
between pci and usb related code

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 730b86c73a mt76x2: add napi struct to mt76_rx_poll_complete/mt76_rx_complete signatures
in order to reuse mt76_rx_complete routine supporting mt76x2u based
devices add napi struct to mt76_rx_poll_complete and mt76_rx_complete
routine signatures and do not fetch it according to the rx queue index

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 5aa0972d78 mt76x2: introduce mt76x2_mac_load_tx_status routine
Add mt76x2_mac_load_tx_status routine since tx stats register map is
shared between usb and pci based devices but usb devices do not have a
tx stat irq line as pcie ones and it is necessary to load tx statistics
using a workqueue

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 6a1e809102 mt76x2: move interface_modes definition in mt76x2_init
Move  wiphy interface_modes definition in mt76x2_init in order to
reuse mt76_register_device routine supporting mt76x2u based chipsets
since mt76x2u currently supports just sta mode

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau d08ea82f7f mt76x2: introduce mt76x2_init_device routine
Add mt76x2_init_device routine in order to reuse common pcie/usb mac80211
initialization code supporting mt76x2u based device

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau c55d29bcf1 mt76x2: move utility routines in mt76x2.h
In order to reuse them supporting mt76x2u based devices, move
mt76x2_wait_for_mac, wait_for_wpdma and mt76x2_channel_silent in
mt76x2.h

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 911e6aa6b3 mt76x2: move mt76x2_fw_header and mt76x2_patch_header definitions in mcu.h
move mt76x2_fw_header and mt76x2_patch_header definitions in mcu.h in
order to reuse them in mt76x2u mcu related code

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau a6915cbc99 mt76: move MT_TXD_INFO, MT_MCU_MSG and MT_RX_FCE_INFO defs in dma.h
Since MT_TXD_INFO, MT_MCU_MSG and MT_RX_FCE_INFO definitions are in
common between mt76x2u, mt76x2 and mt76x0u move them in dma.h in order
to reuse usb code supporting mt76x2u and mt76x0u based devices

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Lorenzo BianconiandFelix Fietkau 016df9cc4c mt76x2: debugfs: add sw pulse statistics to dfs debugfs
Add sw pattern detector statistics to mt76x2 debugfs.
Moreover track down number of allocated sequence by the detector

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00