summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek/mt76/mac80211.c
AgeCommit message (Collapse)AuthorFilesLines
2023-11-20wifi: mt76: mt7921: fix the wrong rate pickup for the chanctx driverSean Wang1-2/+7
[ Upstream commit 32b1000db221df33ec8b57794a091ba6075b6c28 ] The variable band should be determined by the ieee80211_chanctx_conf when the driver is a kind of chanctx one e.g mt7921 and mt7922 driver so we added the extension to mt76_connac2_mac_tx_rate_val by distinguishing if it can support chanctx to fix the incorrect rate pickup. Fixes: 41ac53c899bd ("wifi: mt76: mt7921: introduce chanctx support") Signed-off-by: Sean Wang <sean.wang@mediatek.com> Reviewed-by: David Ruth <druth@chromium.org> Tested-by: David Ruth <druth@chromium.org> Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-07page_pool: split types and declarations from page_pool.hYunsheng Lin1-1/+0
Split types and pure function declarations from page_pool.h and add them in page_page/types.h, so that C sources can include page_pool.h and headers should generally only include page_pool/types.h as suggested by jakub. Rename page_pool.h to page_pool/helpers.h to have both in one place. Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com> Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com> Link: https://lore.kernel.org/r/20230804180529.2483231-2-aleksander.lobakin@intel.com [Jakub: change microsoft/mana, fix kdoc paths in Documentation] Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-07-25wifi: mt76: mt7915: move sta_poll_list and sta_poll_lock in mt76_devLorenzo Bianconi1-0/+2
sta_poll_list and sta_poll_lock are used by most of the drivers, so move them in mt76_dev structure. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-07-25wifi: mt76: add tx_nss histogram to ethtool statsRyder Lee1-0/+3
mt76_connac2_mac_fill_txs() counts tx_nss but ethtool doesn't show stats. Add missing histogram accordingly. Signed-off-by: Ben Greear <greearb@candelatech.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-07-25wifi: mt76: enable UNII-4 channel 177 supportRyder Lee1-0/+1
Enable support for the 5GHz channel 177 with center frequency 5885MHz and operating class 125 based on IEEE Std 802.11ax-2021 Table E-4. Signed-off-by: Himanshu Goyal <himanshu.goyal@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-04-17wifi: mt76: get rid of unused sta_ps callbacksLorenzo Bianconi1-1/+2
sta_ps callback is just an empty stub for most of the drivers, so get rid of them. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-04-17wifi: mt76: mt7996: add eht rx rate supportShayne Chen1-3/+8
Add support to report eht rx rate. Note that extended fields for eht in mt76_rx_status will make the struct size exceed the cb size, so make nss and band share the same u8. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-04-17wifi: mt76: dynamic channel bandwidth changes in AP modeRyder Lee1-1/+2
Allow AP to change channel width for 40Mhz intolerant STA on the 2.4 GHz band. Signed-off-by: Himanshu Goyal <himanshu.goyal@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-03-13wifi: mt76: do not run mt76_unregister_device() on unregistered hwLorenzo Bianconi1-0/+8
Trying to probe a mt7921e pci card without firmware results in a successful probe where ieee80211_register_hw hasn't been called. When removing the driver, ieee802111_unregister_hw is called unconditionally leading to a kernel NULL pointer dereference. Fix the issue running mt76_unregister_device routine just for registered hw. Link: https://bugs.debian.org/1029116 Link: https://bugs.kali.org/view.php?id=8140 Reported-by: Stuart Hayhurst <stuart.a.hayhurst@gmail.com> Fixes: 1c71e03afe4b ("mt76: mt7921: move mt7921_init_hw in a dedicated work") Tested-by: Helmut Grohne <helmut@freexian.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/be3457d82f4e44bb71a22b2b5db27b644a37b1e1.1677107277.git.lorenzo@kernel.org
2023-02-03wifi: mt76: add EHT rate stats for ethtoolShayne Chen1-3/+8
Add support to get EHT rate stats from ethtool. This is the preliminary patch to add EHT support for mt7996. Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-02-03wifi: mt76: enable page_pool statsLorenzo Bianconi1-0/+15
Enable page_pool ethtool statistics for mt7915 and mt7921 chipsets. Tested-by: Felix Fietkau <nbd@nbd.name> Tested-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2023-02-03wifi: mt76: switch to page_pool allocatorLorenzo Bianconi1-0/+42
In order to reduce possible memory allocation failures due to memory fragmentation caused by page_frag_cache allocator, switch to page_pool allocator for dma and usb mt76 drivers. Remove per rx-queue page_frag_cache Co-developed-by: Felix Fietkau <nbd@nbd.name> Tested-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-12-09wifi: mt76: mt7915: enable per-phy led supportLorenzo Bianconi1-0/+8
Introduce the capability to support per-phy led blinking. This is needed for devices supporting dbdc. Tested-by: Frank Wunderlich <frank-w@public-files.de> Co-developed-by: Ryder Lee <ryder.Lee@mediatek.com> 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>
2022-12-09wifi: mt76: move leds struct in mt76_phyLorenzo Bianconi1-21/+27
Move leds struct in mt76_phy in order to have leds associated to phy (e.g. in dbdc mode) instead of per device. Tested-by: Frank Wunderlich <frank-w@public-files.de> Co-developed-by: Ryder Lee <ryder.Lee@mediatek.com> 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>
2022-12-09wifi: mt76: move leds field in leds structLorenzo Bianconi1-9/+9
This is a preliminary patch to support per-phy leds. Tested-by: Frank Wunderlich <frank-w@public-files.de> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-12-01wifi: mt76: mt7915: enable WED RX supportLorenzo Bianconi1-1/+4
Enable RX Wireless Ethernet Dispatch available on MT7986 Soc in oreder to offlad traffic received by WLAN NIC and forwarded to LAN/WAN one. Tested-by: Daniel Golle <daniel@makrotopia.org> Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com> Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-12-01wifi: mt76: introduce rxwi and rx token utility routinesSujuan Chen1-0/+5
This is a preliminary patch to introduce WED RX support for mt7915. Tested-by: Daniel Golle <daniel@makrotopia.org> Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-12-01wifi: mt76: mt7915: add ack signal supportRyder Lee1-5/+4
This reports signal strength of ACK packets from the peer as measured at each interface. Tested-by: Shurong Wen <shurong.wen@mediatek.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-12-01Revert "mt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of ↵Ben Greear1-2/+6
MT_DRV_AMSDU_OFFLOAD" This reverts commit f17f4864504d754bcbf31e4c89412cdf9946c409 and adds the MT_DRV_AMSDU_OFFLOAD flag for MT7921 USB/SDIO The reverted commit significantly decreases performance when running a test where two MT7915 radios have 16 station vdevs each, configured for AC mode, and transmitting UDP traffic to AP. Co-developed-by: Felix Fietkau <nbd@nbd.name> Reported-by: Carson Vandegriffe <carson.vandegriffe@candelatech.com> Signed-off-by: Ben Greear <greearb@candelatech.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-09-12wifi: mt76: fix 5 GHz connection regression on mt76x0/mt76x2Felix Fietkau1-1/+2
Some users have reported being unable to connect to MT76x0 APs running mt76 after a commit enabling the VHT extneded NSS BW feature. Fix this regression by ensuring that this feature only gets enabled on drivers that support it Cc: stable@vger.kernel.org Fixes: d9fcfc1424aa ("mt76: enable the VHT extended NSS BW feature") Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220907095228.82072-1-nbd@nbd.name
2022-07-11mediatek: mt76: mac80211: Fix missing of_node_put() in mt76_led_init()Liang He1-0/+1
We should use of_node_put() for the reference 'np' returned by of_get_child_by_name() which will increase the refcount. Fixes: 17f1de56df05 ("mt76: add common code shared between multiple chipsets") Signed-off-by: Liang He <windhl@126.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: add phy_idx to mt76_wcidLorenzo Bianconi1-6/+6
Introduce phy_idx to mt76_wcid structure instead of ext_phy. This is a preliminary patch to add newer chipset support. Co-developed-by: Bo Jiao <bo.jiao@mediatek.com> Signed-off-by: Bo Jiao <bo.jiao@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: introduce phys array in mt76_dev structureLorenzo Bianconi1-3/+6
Introduce phys array in mt76_dev structure to reference mt76_phy supported by the chipset. This is a preliminary patch to introduce newer chipset support. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: add phy_idx in mt76_rx_statusLorenzo Bianconi1-3/+3
Introduce phy_idx mt76_rx_status instead of ext_idx. This is a preliminary patch to add newer chipset support Co-developed-by: Bo Jiao <bo.jiao@mediatek.com> Signed-off-by: Bo Jiao <bo.jiao@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: allow receiving frames with invalid CCMP PN via monitor interfacesFelix Fietkau1-14/+10
This can be useful for debugging Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: do not check the ccmp pn for ONLY_MONITOR frameMeiChia Chiu1-0/+3
if the received frame enables RX_FLAG_ONLY_MONITOR, driver doesn't need to check the ccmp pn of this frame. Reviewed-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: enable the VHT extended NSS BW featureDeren Wu1-0/+2
According IEEE Std 802.11-2020, its definition is: Indicates whether the STA is capable of interpreting the Extended NSS BW Support subfield of the VHT Capabilities Information field. Some APs, such as Xiaomi AX6000, would check this one for BW settings. mt76 driver can get max BW capability only if the this field is confgured properly. Reviewed-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-07-11mt76: add 6 GHz band support in mt76_sar_freq_rangesDeren Wu1-0/+6
Add new frequencies support in mt76_sar_freq_ranges[] * 5945 - 6165 * 6165 - 6405 * 6405 - 6525 * 6525 - 6705 * 6705 - 6865 * 6865 - 7125 Reviewed-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-06-20wifi: mac80211: move some future per-link data to bss_confJohannes Berg1-2/+2
To add MLD, reuse the bss_conf structure later for per-link information, so move some things into it that are per link. Most transformations were done with the following spatch: @@ expression sdata; identifier var = { chanctx_conf, mu_mimo_owner, csa_active, color_change_active, color_change_color }; @@ -sdata->vif.var +sdata->vif.bss_conf.var @@ struct ieee80211_vif *vif; identifier var = { chanctx_conf, mu_mimo_owner, csa_active, color_change_active, color_change_color }; @@ -vif->var +vif->bss_conf.var Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2022-05-13mt76: mt7915: add Wireless Ethernet Dispatch supportFelix Fietkau1-1/+3
This is used to support hardware flow offloading from Ethernet to WLAN Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-13mt76: make number of tokens configurable dynamicallyFelix Fietkau1-0/+1
Preparation for adding Wireless Ethernet Dispatch support Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-13mt76: add support for overriding the device used for DMA mappingFelix Fietkau1-0/+1
WED support requires using non-coherent DMA, whereas the PCI device might be configured for coherent DMA. The WED driver will take care of changing the PCI HIF coherent IO setting on attach. Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-13mt76: fix tx status related use-after-free race on station removalFelix Fietkau1-0/+2
There is a small race window where ongoing tx activity can lead to a skb getting added to the status tracking idr after that idr has already been cleaned up, which will keep the wcid linked in the status poll list. Fix this by only adding status skbs if the wcid pointer is still assigned in dev->wcid, which gets cleared early by mt76_sta_pre_rcu_remove Fixes: bd1e3e7b693c ("mt76: introduce packet_id idr") Tested-by: Ben Greear <greearb@candelatech.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-13mt76: fix antenna config missing in 6G capDeren Wu1-2/+2
To make sure we have the proper antenna config in 6g cap, move IEEE80211_VHT_CAP_[T/R]X_ANTENNA_PATTERN to stream init. Fixes: edf9dab8ba27 ("mt76: add 6GHz support") Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-13mt76: fix use-after-free by removing a non-RCU wcid pointerFelix Fietkau1-1/+1
Fixes an issue caught by KASAN about use-after-free in mt76_txq_schedule by protecting mtxq->wcid with rcu_lock between mt76_txq_schedule and sta_info_[alloc, free]. [18853.876689] ================================================================== [18853.876751] BUG: KASAN: use-after-free in mt76_txq_schedule+0x204/0xaf8 [mt76] [18853.876773] Read of size 8 at addr ffffffaf989a2138 by task mt76-tx phy0/883 [18853.876786] [18853.876810] CPU: 5 PID: 883 Comm: mt76-tx phy0 Not tainted 5.10.100-fix-510-56778d365941-kasan #5 0b01fbbcf41a530f52043508fec2e31a4215 [18853.876840] Call trace: [18853.876861] dump_backtrace+0x0/0x3ec [18853.876878] show_stack+0x20/0x2c [18853.876899] dump_stack+0x11c/0x1ac [18853.876918] print_address_description+0x74/0x514 [18853.876934] kasan_report+0x134/0x174 [18853.876948] __asan_report_load8_noabort+0x44/0x50 [18853.876976] mt76_txq_schedule+0x204/0xaf8 [mt76 074e03e4640e97fe7405ee1fab547b81c4fa45d2] [18853.877002] mt76_txq_schedule_all+0x2c/0x48 [mt76 074e03e4640e97fe7405ee1fab547b81c4fa45d2] [18853.877030] mt7921_tx_worker+0xa0/0x1cc [mt7921_common f0875ebac9d7b4754e1010549e7db50fbd90a047] [18853.877054] __mt76_worker_fn+0x190/0x22c [mt76 074e03e4640e97fe7405ee1fab547b81c4fa45d2] [18853.877071] kthread+0x2f8/0x3b8 [18853.877087] ret_from_fork+0x10/0x30 [18853.877098] [18853.877112] Allocated by task 941: [18853.877131] kasan_save_stack+0x38/0x68 [18853.877147] __kasan_kmalloc+0xd4/0xfc [18853.877163] kasan_kmalloc+0x10/0x1c [18853.877177] __kmalloc+0x264/0x3c4 [18853.877294] sta_info_alloc+0x460/0xf88 [mac80211] [18853.877410] ieee80211_prep_connection+0x204/0x1ee0 [mac80211] [18853.877523] ieee80211_mgd_auth+0x6c4/0xa4c [mac80211] [18853.877635] ieee80211_auth+0x20/0x2c [mac80211] [18853.877733] rdev_auth+0x7c/0x438 [cfg80211] [18853.877826] cfg80211_mlme_auth+0x26c/0x390 [cfg80211] [18853.877919] nl80211_authenticate+0x6d4/0x904 [cfg80211] [18853.877938] genl_rcv_msg+0x748/0x93c [18853.877954] netlink_rcv_skb+0x160/0x2a8 [18853.877969] genl_rcv+0x3c/0x54 [18853.877985] netlink_unicast_kernel+0x104/0x1ec [18853.877999] netlink_unicast+0x178/0x268 [18853.878015] netlink_sendmsg+0x3cc/0x5f0 [18853.878030] sock_sendmsg+0xb4/0xd8 [18853.878043] ____sys_sendmsg+0x2f8/0x53c [18853.878058] ___sys_sendmsg+0xe8/0x150 [18853.878071] __sys_sendmsg+0xc4/0x1f4 [18853.878087] __arm64_compat_sys_sendmsg+0x88/0x9c [18853.878101] el0_svc_common+0x1b4/0x390 [18853.878115] do_el0_svc_compat+0x8c/0xdc [18853.878131] el0_svc_compat+0x10/0x1c [18853.878146] el0_sync_compat_handler+0xa8/0xcc [18853.878161] el0_sync_compat+0x188/0x1c0 [18853.878171] [18853.878183] Freed by task 10927: [18853.878200] kasan_save_stack+0x38/0x68 [18853.878215] kasan_set_track+0x28/0x3c [18853.878228] kasan_set_free_info+0x24/0x48 [18853.878244] __kasan_slab_free+0x11c/0x154 [18853.878259] kasan_slab_free+0x14/0x24 [18853.878273] slab_free_freelist_hook+0xac/0x1b0 [18853.878287] kfree+0x104/0x390 [18853.878402] sta_info_free+0x198/0x210 [mac80211] [18853.878515] __sta_info_destroy_part2+0x230/0x2d4 [mac80211] [18853.878628] __sta_info_flush+0x300/0x37c [mac80211] [18853.878740] ieee80211_set_disassoc+0x2cc/0xa7c [mac80211] [18853.878851] ieee80211_mgd_deauth+0x4a4/0x10a0 [mac80211] [18853.878962] ieee80211_deauth+0x20/0x2c [mac80211] [18853.879057] rdev_deauth+0x7c/0x438 [cfg80211] [18853.879150] cfg80211_mlme_deauth+0x274/0x414 [cfg80211] [18853.879243] cfg80211_mlme_down+0xe4/0x118 [cfg80211] [18853.879335] cfg80211_disconnect+0x218/0x2d8 [cfg80211] [18853.879427] __cfg80211_leave+0x17c/0x240 [cfg80211] [18853.879519] cfg80211_leave+0x3c/0x58 [cfg80211] [18853.879611] wiphy_suspend+0xdc/0x200 [cfg80211] [18853.879628] dpm_run_callback+0x58/0x408 [18853.879642] __device_suspend+0x4cc/0x864 [18853.879658] async_suspend+0x34/0xf4 [18853.879673] async_run_entry_fn+0xe0/0x37c [18853.879689] process_one_work+0x508/0xb98 [18853.879702] worker_thread+0x7f4/0xcd4 [18853.879717] kthread+0x2f8/0x3b8 [18853.879731] ret_from_fork+0x10/0x30 [18853.879741] [18853.879757] The buggy address belongs to the object at ffffffaf989a2000 [18853.879757] which belongs to the cache kmalloc-8k of size 8192 [18853.879774] The buggy address is located 312 bytes inside of [18853.879774] 8192-byte region [ffffffaf989a2000, ffffffaf989a4000) [18853.879787] The buggy address belongs to the page: [18853.879807] page:000000004bda2a59 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1d89a0 [18853.879823] head:000000004bda2a59 order:3 compound_mapcount:0 compound_pincount:0 [18853.879839] flags: 0x8000000000010200(slab|head) [18853.879857] raw: 8000000000010200 ffffffffbc89e208 ffffffffb7fb5208 ffffffaec000cc80 [18853.879873] raw: 0000000000000000 0000000000010001 00000001ffffffff 0000000000000000 [18853.879885] page dumped because: kasan: bad access detected [18853.879896] [18853.879907] Memory state around the buggy address: [18853.879922] ffffffaf989a2000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [18853.879935] ffffffaf989a2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [18853.879948] >ffffffaf989a2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [18853.879961] ^ [18853.879973] ffffffaf989a2180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [18853.879986] ffffffaf989a2200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [18853.879998] ================================================================== Cc: stable@vger.kernel.org Reported-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-03-16mt76: fix invalid rssi reportDeren Wu1-2/+3
Drop invalid rssi value to calculate a reasonable report Fixes: 4550fb9e9810 ("mt76: improve signal strength reporting") Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-02-24mt76: fix dfs state issue with 160 MHz channelsFelix Fietkau1-1/+1
When operating on a mix of DFS and non-DFS channels, the driver only checks the CAC status of the control channel. This causes beacons/tx to fail if the control channel is on a non-DFS channel. Fix this by calling cfg80211_reg_can_beacon to determine the DFS status of all affected channels Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-02-24mt76: improve signal strength reportingFelix Fietkau1-0/+32
Instead of just taking the maximum per-chain signal strength values, add an approximation for the sum of the combined signal. This should more accurately reflect the real signal strength, especially if the per-chain signal strength values are close to each other Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-02-03mt76: mt7915: fix/rewrite the dfs state handling logicFelix Fietkau1-0/+28
Client mode on DFS channels was broken, because the old code was activating the DFS detector on radar channels while leaving it in CAC state. This was caused by making the decision based on the channel radar flag, instead of hw->conf.radar_enabled. In order to properly deal with the various corner cases, rip out the state handling code and replace it with something that's much easier to reason about. Tested-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-02-03mt76: make mt76_sar_capa staticLorenzo Bianconi1-1/+1
Fix the following sparse warning: drivers/net/wireless/mediatek/mt76/mac80211.c:183:32: warning: symbol 'mt76_sar_capa' was not declared. Should it be static? Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-12-19mt76: move sar_capa configuration in common codeLorenzo Bianconi1-4/+16
Move wiphy SAR capability configuration in mt76 module and remove duplicated code. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-12-19mt76: clear sta powersave flag after notifying driverFelix Fietkau1-2/+4
If the driver has configured the hardware to drop packets for a sta that was in powersave mode, then clearing the flag too early opens up a small race window during which packets could be dropped on wakeup Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-12-19mt76: move sar utilities to mt76-core moduleLorenzo Bianconi1-0/+53
Move mt76_get_sar_power and mt76_init_sar_power in the common code. This is a preliminary patch to add sar support to mt76x02 drivers. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-12-19mt76: fix the wiphy's available antennas to the correct valueBo Jiao1-2/+2
the wiphy's available antennas may be incorrect When ext phy's antenna_mask is different from main phy Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-12-19mt76: fix possible OOB issue in mt76_calculate_default_rateLorenzo Bianconi1-3/+4
Cap max offset value to ARRAY_SIZE(mt76_rates) - 1 in mt76_calculate_default_rate routine in order to avoid possible Out Of Bound accesses. Fixes: 33920b2bf0483 ("mt76: add support for setting mcast rate") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-10-20mt76: move mt76_ethtool_worker_info in mt76 moduleLorenzo Bianconi1-0/+28
Move mt76_ethtool_worker_info in common code in order to be reused in mt7921 driver. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-10-20mt76: do not access 802.11 header in ccmp check for 802.3 rx skbsFelix Fietkau1-2/+5
Avoids false positive on detecting frags or encrypted mgmt frames Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-10-20mt76: use a separate CCMP PN receive counter for management framesXing Song1-4/+23
When received frame is decryped by hardware, CCMP PN is checked by mt76. When management frame protection (IEEE 802.11w) is used, we must use a separate counter for tracking received CCMP packet number for the management frames. The previously used counter was shared with data frames and that can cause problems in detecting replays incorrectly for robust management frames. Add a new counter just for robust management frames to avoid this issue. Signed-off-by: Xing Song <xing.song@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-10-20mt76: substitute sk_buff_head status_list with spinlock_t status_lockLorenzo Bianconi1-1/+1
Substitute sk_buff_head status_list with spinlock_t status_lock since we just need it for locking Tested-by: mrkiko.rs@gmail.com Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-10-20mt76: remove mt76_wcid pointer from mt76_tx_status_check signatureLorenzo Bianconi1-2/+2
Remove mt76_wcid pointer from mt76_tx_status_check signature since it is always set to NULL Tested-by: mrkiko.rs@gmail.com Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>