summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
Commit message (Collapse)AuthorAgeFilesLines
* mt76: fix fix ampdu lockingMarkus Theil2019-11-211-2/+4
| | | | | | | | | The current ampdu locking code does not unlock its mutex in the early return case. This patch fixes it. Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de> Acked-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
* mt76: move interface_modes definition in mt76_core moduleLorenzo Bianconi2019-11-201-8/+0
| | | | | | | | | Move interface modes declaration in common code since now mt76 chipsets support all modes (NL80211_IFTYPE_STATION, NL80211_IFTYPE_AP, NL80211_IFTYPE_MESH_POINT and NL80211_IFTYPE_ADHOC) Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move SUPPORTS_REORDERING_BUFFER hw property in mt76_register_deviceLorenzo Bianconi2019-11-201-1/+0
| | | | | | | | | Move SUPPORTS_REORDERING_BUFFER hw property configuration from chip specific code to mt76_register_device since it is supported by all mt76 drivers Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: use mt76_dev in mt76_is_{mmio,usb}Lorenzo Bianconi2019-11-201-3/+3
| | | | | | | | | Convert mt76_is_mmio and mt76_is_usb to rely on mt76_dev instead of mt76x02_dev since this is a property not strictly related to hw chipset and it will be more reusable Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add missing locking around ampdu actionFelix Fietkau2019-11-201-0/+2
| | | | | | | This is needed primarily to avoid races in dealing with rx aggregation related data structures Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt76x02: track approximate tx airtime for airtime fairness and surveyFelix Fietkau2019-11-201-0/+1
| | | | | | | Estimate by calculating duration for EWMA packet size + estimated A-MPDU length on tx status events Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mac80211: simplify TX aggregation startJohannes Berg2019-10-041-2/+1
| | | | | | | | | | | | | | | There really is no need to make drivers call the ieee80211_start_tx_ba_cb_irqsafe() function and then schedule the worker if all we want is to set a bit. Add a new return value (that was previously considered invalid) to indicate that the driver is immediately ready for the session, and make drivers use it. The only drivers that remain different are the Intel ones as they need to negotiate more with the firmware. Link: https://lore.kernel.org/r/1570007543-I152912660131cbab2e5d80b4218238c20f8a06e5@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
* mt76: do not send BAR frame on tx aggregation flush stopFelix Fietkau2019-09-051-1/+0
| | | | | | | | 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>
* mt76: add default implementation for mt76_sw_scan/mt76_sw_scan_completeLorenzo Bianconi2019-09-051-9/+0
| | | | | | | | | 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>
* mt76: mt76x02u: enable multi-vif supportLorenzo Bianconi2019-09-051-0/+26
| | | | | | | | | | | | | 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>
* mt76: switch to SPDX tag instead of verbose boilerplate textRyder Lee2019-09-051-12/+1
| | | | | | | | | 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>
* mt76: mt76x02: fix some checkpatch warningsRyder Lee2019-09-051-10/+10
| | | | | | | | | | | | | | | 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>
* mt76: mt76x02: use params->ssn value directlyStanislaw Gruszka2019-09-051-3/+3
| | | | | | | 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>
* mt76: do not enable/disable pre_tbtt_tasklet in scan_start/scan_completeLorenzo Bianconi2019-05-011-5/+0
| | | | | | | | | | Do not enable/disable pre_tbtt_tasklet tasklet in mt76x02_sw_scan/mt76x02_sw_scan_complete since it is already done setting the operating channel. Do run tbtt_tasklet while the device is offchannel Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move pre_tbtt_tasklet in mt76_devLorenzo Bianconi2019-05-011-2/+2
| | | | | | | | Move pre_tbtt_tasklet tasklet in mt76_dev data structure since it is used by all drivers Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move beacon_int in mt76_devLorenzo Bianconi2019-05-011-1/+1
| | | | | | | | Move beacon_int in mt76_dev data structure since it is used by all drivers Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: use macro for sn and seq_ctrl conversionRyder Lee2019-05-011-1/+1
| | | | | | | | Use macro to convert sn and seq_ctrl for better readability. Signed-off-by: Roy Luo <royluo@google.com> Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move mac_work in mt76_devLorenzo Bianconi2019-05-011-1/+1
| | | | | | | | | Move mac_work delayed work in mt76_dev data structure since it is used by all drivers and it will be reused adding mac work to mt7615 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: store wcid tx rate info in one u32 reduce lockingFelix Fietkau2019-05-011-1/+0
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: enable AP mode for USBStanislaw Gruszka2019-05-011-1/+1
| | | | | | | | Enable AP mode. For now without multi-vif support, this will require more testing and investigation. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: disable HW encryption for group framesStanislaw Gruszka2019-05-011-0/+10
| | | | | | | | This is required to sent multicast/broadcast frames in USB AP mode just after beacon. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02u: add sta_psStanislaw Gruszka2019-05-011-1/+2
| | | | | | | | Add sta_ps callback but dont set WCID drop sicne registers for USB can not be accessed from tasklet context. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: introduce mt76x02_beacon.cStanislaw Gruszka2019-05-011-62/+0
| | | | | | | | | Move most of beaconing code into separate file and separate beacon initialization for USB and MMIO as pre TBTT implementation for USB will be different. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move mt76x02_insert_hdr_pad in mt76-core moduleLorenzo Bianconi2019-05-011-16/+0
| | | | | | | | | | Move mt76x02_insert_hdr_pad in m76-core and rename it in mt76_insert_hdr_pad in order to be used in mt76_dma_tx_queue_skb. This is a preliminary patch in order to properly support tx dma mapping for new chipsets (e.g. mt7615) Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: introduce mt76_sw_queue data structureLorenzo Bianconi2019-05-011-1/+1
| | | | | | | | | Introduce mt76_sw_queue data structure in order to support new chipsets (e.g. mt7615) that have a shared hardware queue for all traffic identifiers. mt76_sw_queue will be used to track outstanding packets Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt76x02: only update the base mac address if necessaryFelix Fietkau2019-03-071-4/+6
| | | | | | | | | Also update the mask first before calculating the vif index. Fixes an issue where adding back the same interfaces in a different order fails because of duplicate vif index use Fixes: 06662264ce2ad ("mt76x02: use mask for vifs") Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt76x2: implement full device restart on watchdog resetFelix Fietkau2019-03-071-0/+4
| | | | | | | Restart the firmware and re-initialize the MAC to be able to recover from more kinds of hang states Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt76x02: only reset beacon drift counter when enabling beaconsFelix Fietkau2019-02-261-1/+0
| | | | | | | When the timer is already running, there is no need to reset the counter, because the drift will remain the same. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt76x02: fix beacon timer issueFelix Fietkau2019-02-261-3/+3
| | | | | | | | | | | | | When mt76x0 and mt76x2 beacon code was unified, it changed the order in which beacon enable and beacon interval are configured. Configuring beacon enable before beacon interval can in some cases cause problems with the beacon timer, leading to clients not waking up properly from powersave mode. Fix this by changing the order back to interval first, then enable. Fixes: cc726268e4dce ("mt76: move mt76x02_bss_info_changed in mt76x02-lib module") Cc: stable@vger.kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mt76x02: fix TSF sync modeFelix Fietkau2019-02-261-1/+1
| | | | | | | MT_BEACON_TIME_CFG_SYNC_MODE needs to be set for AP mode, according to the documentation. For other modes it should be irrelevant in this case. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: fix resetting software IV flag on key deleteFelix Fietkau2019-02-181-1/+1
| | | | | | | It needs to be unset instead of set Fixes: 23405236460b9 ("mt76: fix transmission of encrypted management frames") Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: enable support for IBSS and MESHStanislaw Gruszka2019-02-181-11/+10
| | | | | | | | | Since we implement beconing on USB now, similar interfaces should be supported for USB as are for MMIO. Tested only on IBSS mode and AP mode (not enabled due to lack of PS buffering). Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: beaconing fixes for USBStanislaw Gruszka2019-02-181-6/+2
| | | | | | | Configure beaconing on USB devices without PS buffering support. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: minor beaconing init changesStanislaw Gruszka2019-02-181-6/+12
| | | | | | | | Disable BEACON timer during init and configure interrupt registers only for mmio devices. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: initialize mutli bss mode when set up addressStanislaw Gruszka2019-02-181-11/+2
| | | | | | | | | BSSID is not strtirct related with beaconing (for example we can have 2 STA vifs) and more related with MAC address, so initaize BSSID when setting MAC address. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: use commmon add interface for mt76x2uStanislaw Gruszka2019-02-181-3/+3
| | | | | | | | | Since we now support mt76x2u feature to allow set mac address when creating interface in common code we can use it for mt76x2u. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: use mask for vifsStanislaw Gruszka2019-02-181-0/+11
| | | | | | | | | Use vif_mask to count interfaces to allow to set mac address in HW if there is only one interface and report error if we create interface with wrong BSSID resulting in already used index. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add channel switch announcement supportFelix Fietkau2019-01-171-0/+2
| | | | | | Use the appropriate mac80211 callbacks after beacon transmission Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move mt76x02_phy_get_min_avg_rssi to mt76 coreFelix Fietkau2019-01-171-2/+0
| | | | | | This will be used by mt7603 as well Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: move mt76x02_get_txpower to mt76 coreFelix Fietkau2019-01-171-18/+0
| | | | | | It will be reused by mt7603 later Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: add led support to mt76x0e driverLorenzo Bianconi2019-01-111-0/+59
| | | | | | | | | Move mt76x02 led support in mt76x02-lib module in order to add tpt led trigger to mt76x0e driver Tested-by: LGA1150 <dqfext@gmail.com> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76: mmio: introduce mt76x02_check_tx_hang watchdogLorenzo Bianconi2019-01-111-0/+2
| | | | | | | | | | | | | Port mt76x02_check_tx_hang watchdog from vendor driver in order to perform a device reset when tx mac/dma logic hangs. Tx mac/dma stuck has been observed when the device is heavy loaded or in a noisy environment. Moreover introduce wdt delayed work in order to run tx_hang watchdog. For the moment run mt76x02_check_tx_hang watchdog just on mt76x2 devices since the issue has not been observed on mt76x0 driver yet Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: set protection according to ht operation elementStanislaw Gruszka2019-01-111-0/+4
| | | | | | | | Configure protection based on information that are provided to us either by remote AP or by hostapd via HT operation IE. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* mt76x02: do not set protection on set_rts_threshold callbackStanislaw Gruszka2019-01-111-1/+1
| | | | | | | | | | | Use set_rts_threshold calback to enable/disable threshold only for legacy traffic. Protection for HT and VHT traffic is defined by HT operation element and it's provided by remote AP or by hostapd. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* Merge tag 'mt76-for-kvalo-2018-11-30' of https://github.com/nbd168/wirelessKalle Valo2018-12-131-36/+298
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | first batch of mt76 patches for 4.21 * use the same firmware for mt76x2e and mt76x2u * mt76x2 fixes * mt76x0 fixes * mt76x0e survey support * more unification between mt76x2 and mt76x0 * mt76x0e AP mode support * mt76x0e DFS support * rework and fix tx status handling for mt76x0 and mt76x2 kvalo: fixed a conflict in drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c and a build problem in drivers/net/wireless/mediatek/mt76/mt76x02_util.c
| * mt76: replace sta_add/remove ops with common sta_state functionFelix Fietkau2018-11-301-35/+8
| | | | | | | | | | | | | | Allows adding unassociated stations from mac80211 Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
| * mt76: mt76x02: remove mt76x02_txq_initFelix Fietkau2018-11-301-3/+15
| | | | | | | | | | | | Open-coding it simplifies the code Signed-off-by: Felix Fietkau <nbd@nbd.name>
| * mt76: add mt76_sta_remove helperFelix Fietkau2018-11-301-9/+3
| | | | | | | | | | | | This allows station removal code to be used by mt7603 later Signed-off-by: Felix Fietkau <nbd@nbd.name>
| * mt76: fix race condition in station removalFelix Fietkau2018-11-301-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | If there are still pending packets in the tx queue when removing a station, it could possibly lead to a call to further attempts to pull packets from the mac80211 tx queue after it has already been removed from the scheduling list. Prevent this from happening by calling synchronize_rcu after deleting the wcid pointer before further cleaning up the tx queues. To be extra careful, ensure that mtxq->list is always initialized properly. Signed-off-by: Felix Fietkau <nbd@nbd.name>
| * mt76: avoid queue/status spinlocks while passing tx status to mac80211Felix Fietkau2018-11-301-1/+1
| | | | | | | | | | | | | | | | | | There is some code in the mac80211 tx status processing code that could potentially call back into the tx codepath. To avoid deadlocks, make sure that no tx related spinlocks are taken during the ieee80211_tx_status call. Signed-off-by: Felix Fietkau <nbd@nbd.name>
OpenPOWER on IntegriCloud