summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mediatek/mt76/mt76.h
Commit message (Collapse)AuthorAgeFilesLines
* mt76: add stbc entries to mt76_rate_powerFelix Fietkau2018-10-011-1/+2
| | | | | | | | | | | | | Add stbc tx power eeprom parsing support for mt76x2 driver. When writing power entries, make a distinction between rates that are read from the same EEPROM value, but have separate register entries. No effect on runtime behavior, but preparation for unification with mt76x0 and for placing restrictions on individual rate power limits Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move seq_put_array in mt76-core moduleLorenzo Bianconi2018-10-011-0/+2
| | | | | | | | Move seq_put_array utility routine in mt76-core module in order to be reused in mt76x0 driver Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: use a per rx queue page fragment cacheFelix Fietkau2018-09-191-0/+1
| | | | | | | | | | | | | | | | Using the NAPI or netdev frag cache along with other drivers can lead to 32 KiB pages being held for a long time, despite only being used for very few page fragments. This can happen if the driver grabs one or two fragments for rx ring refill, while other drivers use (and free up) the remaining fragments. The 32 KiB higher-order page can only be freed once all users have freed their fragments. Depending on the traffic patterns, this can waste a lot of memory and look a lot like a memory leak. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move __iomem regs in mt76_mmioLorenzo Bianconi2018-09-191-1/+1
| | | | | | | Move __iomem regs pointer in mt76_mmio data structure Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: introduce mmio data structure in mt76_devLorenzo Bianconi2018-09-191-1/+15
| | | | | | | | | Introduce mt76_mmio data structure in mt76_dev and move mt76x2_mcu in mt76_mmio. This is a preliminary patch to unify mcu code between mt76x02{e,u} drivers Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: usb: move mt76u_skb_dma_info in mt76x02_usb_core.cLorenzo Bianconi2018-09-191-1/+0Star
| | | | | | | | | | | | Move mt76u_skb_dma_info routine in mt76x02-usb module and rename it in mt76x02u_skb_dma_info. Moreover move mt76x02u_set_txinfo in mt76x02_usb_core.c. This is a preliminary patch to move MT_TXD_INFO, MT_MCU_MSG and MT_RX_FCE_INFO defs in mt76x02-lib module since other chipsets (e.g. mt7603) use different dma definitions Acked-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: usb: move mt76x02 mcu code in mt76x02-usb moduleLorenzo Bianconi2018-09-191-4/+0Star
| | | | | | | | | | | | Introduce mt76x02_usb_mcu.c in order to contain mt76x02u mcu related code. Add mt76x02-usb module as a container for mt76x02 usb code. This is a preliminary patch to move MT_TXD_INFO, MT_MCU_MSG and MT_RX_FCE_INFO defs in mt76x02-lib module since other chipsets (e.g. mt7603) use different dma definitions Acked-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: usb: use common helpers for mcu_alloc_msg()/mcu_send_msg()Lorenzo Bianconi2018-09-191-13/+0Star
| | | | | | | | | | | | | | | | | | Use mcu common helpers instead of usb specific routines. Add static qualifier to the following functions: - mt76u_mcu_msg_alloc - __mt76u_mcu_send_msg - mt76u_mcu_send_msg - mt76u_mcu_wr_rp - mt76u_mcu_rd_rp - mt76u_wr_rp - mt76u_rd_rp This is a preliminary patch to move mt76x02 usb mcu code in mt76x02-usb module Acked-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add rd_rp and wr_rp to bus_ops/mcu_opsStanislaw Gruszka2018-09-191-5/+15
| | | | | | | | Add callbacks for reading and writing reg pairs tables. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add usb implementation of {wr,rd}_rpStanislaw Gruszka2018-09-191-0/+8
| | | | | | | | | | Add USB implementation for read and write reg pair routines. The actual implementation can use mcu related routines according to MCU state Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add mt76_mcu_ops data structure for mcu related pointersLorenzo Bianconi2018-09-191-0/+11
| | | | | | | | | | Introduce mt76_mcu_ops data structure to contain mcu related function pointers. This is a preliminary patch to move mt76x02 usb mcu code in mt76x02-usb module Acked-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: remove unused MT76_MORE_STATS stateLorenzo Bianconi2018-09-191-1/+0Star
| | | | | | | | Remove no longer used hw state Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: use mt76_rx_status in mt76x0Stanislaw Gruszka2018-09-191-0/+2
| | | | | | | Make rx status processing similar to mt76x2. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: unify sta_rate_tbl_update and related helpersStanislaw Gruszka2018-09-191-0/+2
| | | | | | | | | Use common sta_rate_tbl_update on mt76x0 and mt76x2. mt76x0 do not have support TPC (transmision power control) implmented, msta->wcid.max_txpwr_adj is only set for mt76x2. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: unify AC to hw queue mappingStanislaw Gruszka2018-09-191-7/+1Star
| | | | | | | | Use the same AC to hardware queue mappings for all subdrivers. Note: this change BK and BE mappings for USB drivers. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: unify ampdu_actionStanislaw Gruszka2018-09-191-0/+3
| | | | | | | | Use mt76x2_ampdu_action as common function, mt76x0 ampdu_action was diffrent, but mt76x2 version should work for this driver as well. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move wcid fields to common mt76_dev structStanislaw Gruszka2018-09-191-0/+7
| | | | | | | | All current MT devices including new MT7603 type chips support 128 WCIDs, we can unify wcid data in common mt76_dev structure. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add multiple regs read support to usb_mcu layerLorenzo Bianconi2018-09-041-0/+6
| | | | | | | | | Introduce multiple regs read support to mcu layer in mt76-usb module. Multiple regs read will be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: move mt76x2u_mcu_deinit routine in mt76-usb moduleLorenzo Bianconi2018-09-041-0/+1
| | | | | | | | | Move mt76x2u_mcu_deinit routine in usb_mcu layer in order to be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: split __mt76u_mcu_send_msg and mt76u_mcu_send_msg routinesLorenzo Bianconi2018-09-041-0/+2
| | | | | | | | | Split __mt76u_mcu_send_msg and mt76u_mcu_send_msg in order to be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: move mt76_reg_pair definition in mt76.hLorenzo Bianconi2018-09-041-0/+5
| | | | | | | | Move common definition of mt76_reg_pair in mt76.h and remove duplicated code in mt76x2_init_common.c Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: unify mac_wcid_set_keyStanislaw Gruszka2018-09-041-0/+3
| | | | | | | Merge mt76x{0,2}_mac_wcid_set_key into common code. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: add helpers for register access with mt76_dev structStanislaw Gruszka2018-09-041-0/+5
| | | | | | | Add helpers for register access from common code. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: create new mt76x02-lib module for common mt76x{0,2} codeStanislaw Gruszka2018-09-041-0/+5
| | | | | | | | | 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 <sgruszka@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: add more statesStanislaw Gruszka2018-08-021-0/+2
| | | | | | | Add states needed for mt76x0 driver. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: add usb support to mt76 layerLorenzo Bianconi2018-08-021-1/+142
| | | | | | | | This will be used by drivers for MT76x2u based devices Tested-by: <cug_yangyuancong@hotmail.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: introduce tx_queue_skb function pointer in mt76_bus_opsLorenzo Bianconi2018-08-021-0/+5
| | | | | | | | | | 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 <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: rename mt76_tx_queue_skb in mt76_dma_tx_queue_skbLorenzo Bianconi2018-08-021-3/+4
| | | | | | | | Move mt76_dma_tx_queue_skb routine in dma.c. Remove static qualifier from mt76_get_txwi definition Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76x2: add napi struct to mt76_rx_poll_complete/mt76_rx_complete signaturesLorenzo Bianconi2018-08-021-2/+3
| | | | | | | | | 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 <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: introduce mt76_{incr,decr} utility routinesLorenzo Bianconi2018-07-041-0/+12
| | | | | | | | Add mt76_{incr,decr} utility routines to increment/decrement a value with wrap-around (they will be used by mt76x2 DFS sw detector) Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: wait for pending tx to complete before switching channelFelix Fietkau2018-05-231-0/+2
| | | | | | | Reduces interruption caused by scanning Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: move ieee80211_hw allocation to common coreFelix Fietkau2018-05-231-0/+2
| | | | | | | | Allows it to be shared between different drivers and locks to be initialized earlier Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: only stop tx queues on offchannel, not during the entire scanFelix Fietkau2018-05-231-0/+1
| | | | | | | | | During scans, mac80211 frequently switches back to the home channel to minimize interruption of ongoing traffic. Keep regular tx queues active during that time. Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: fix concurrent rx calls on A-MPDU releaseFelix Fietkau2018-04-301-0/+1
| | | | | | | | | Add a spinlock in mt76_rx_complete. Without this, multiple stats updates could happen in parallel, which can lead to deadlocks. There are probably more corner cases fixed by this change. Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76x2: add mac80211 {set,get}_antenna callbacksLorenzo Bianconi2018-03-131-0/+1
| | | | | | | | | | Add capability to select tx/rx antennas. Possible values are: - 1: to use only the first antenna - 2: to use only the second antenna - 3: to use both of them Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: initialize available_antennas_{tx,rx} infoLorenzo Bianconi2018-03-131-0/+2
| | | | | | | | | | Initialize available_antennas related info in wiphy data structure according to antenna_mask field; antenna_mask info is initialized in device specific code and will be used in mac80211 {set,get}_antenna callbacks Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: implement AP_LINK_PSFelix Fietkau2018-02-011-0/+10
| | | | | | | | | | | With software A-MPDU reordering in place, frames that notify mac80211 of powersave changes are reordered as well, which can cause connection stalls. Fix this by implementing powersave state processing in the driver. Fixes: aee5b8cf2477 ("mt76: implement A-MPDU rx reordering in the driver code") Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: validate rx CCMP PNFelix Fietkau2018-01-261-2/+10
| | | | | | | | | | | | | | Apparently hardware does not perform CCMP PN validation in hardware, so we need to take care of this in the driver. This is important for protecting against replay attacks. Since validation of fragmented frames is more complex, the CCMP header for those is preserved. To keep the counter in sync, the first fragment is verified by both mt76 and mac80211, and all other fragments only by mac80211. Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: split mt76_rx_completeFelix Fietkau2018-01-261-2/+3
| | | | | | | | Add a separate function for processing frames after A-MPDU reordering, reduce code duplication Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: implement A-MPDU rx reordering in the driver codeFelix Fietkau2018-01-261-0/+35
| | | | | | | This is required for performing CCMP PN validation in software Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: get station pointer by wcid and pass it to mac80211Felix Fietkau2018-01-261-0/+14
| | | | | | | Avoids the rhashtable lookup based on the MAC address inside mac80211 Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: add an intermediate struct for rx status informationFelix Fietkau2018-01-261-0/+13
| | | | | | | Preparation for passing in more internal rx data via skb->cb Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: fix transmission of encrypted management framesFelix Fietkau2018-01-241-0/+1
| | | | | | | | | | | | Hardware encryption seems to break encrypted unicast mgmt tx. Unfortunately the hardware TXWI header does not have a bit to indicate that a frame is software encrypted, so sw-encrypted frames need to use a different WCID. For that to work, the CCMP PN needs to be generated in software, which makes things a bit slower, so only do it for keys that also need to tx management frames. Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: add common code shared between multiple chipsetsFelix Fietkau2017-12-071-0/+360
This will be used by drivers for MT76x2e, MT7603e and MT7628 Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>