Baochen Qiang [Thu, 30 May 2024 15:56:52 +0000 (18:56 +0300)]
wifi: ath12k: add panic handler
Currently for ath12k PCI devices, firmware could be running in one of
several execution environments, e.g., PBL, SBL and mission mode etc. Among
which PBL is the only stage where PCIe link negotiation could happen. So
normally firmware runs in PBL in order to be enumerated during system reboot.
However it might not work in kernel crash scenario: ath12k target is not
found after warm reboot from kernel crash. This is because when kernel crashes,
ath12k host does nothing to firmware. And during warm reboot, WLAN power
is sustained. So firmware is likely to keep running in mission mode throughout
the bootup process. As a result PCIe link is not established and thus target
not enumerated.
So add a handler in panic notification list for ath12k. When kernel crashes,
this handler gets called and tries to reset target to PBL state. Then PCIe
link negotiation could happen and target gets enumerated.
This change applies to all PCI devices including WCN7850 and QCN9274.
Baochen Qiang [Wed, 29 May 2024 01:53:57 +0000 (09:53 +0800)]
wifi: ath12k: do not process consecutive RDDM event
Currently we do reset for each RDDM event from MHI, however there are
cases, see below log, that we get two or more consecutive events, and
it is pointless to do reset for the subsequent ones. What's more, it
makes reset process more likely to fail.
[ 103.289864] mhi mhi0: System error detected
[ 103.289871] ath12k_pci 0000:03:00.0: mhi notify status reason MHI_CB_EE_RDDM
[ 103.293144] mhi mhi0: System error detected
[ 103.293150] ath12k_pci 0000:03:00.0: mhi notify status reason MHI_CB_EE_RDDM
Add a check to avoid reset again and again. This is done by tracking previous
MHI status: if we receive a new RDDM event while the previous event is
also the same, we treat it as duplicate and ignore it, because normally
we should at least receive a MHI_CB_EE_MISSION_MODE event between them.
Rob Herring (Arm) [Tue, 28 May 2024 13:46:09 +0000 (08:46 -0500)]
dt-bindings: net: wireless: ath11k: Drop "qcom,ipq8074-wcss-pil" from example
Convention for examples is to only show what's covered by the binding,
so drop the provider "qcom,ipq8074-wcss-pil". It is also not documented
by a schema which caused a warning.
Baochen Qiang [Fri, 24 May 2024 02:40:21 +0000 (10:40 +0800)]
wifi: ath12k: fix wrong definition of CE ring's base address
Base address of CE ring is defined as u32, currently this works
because DMA mask configured as 32 bit:
#define ATH12K_PCI_DMA_MASK 32
However this mask could be changed once firmware bugs are fixed
to fully support 36 bit DMA addressing. So to protect against any
future changes to the DMA mask, change the type of the fields that
are dependent upon it.
This is found during code review. Compile tested only.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240524024021.37711-1-quic_bqiang@quicinc.com
Baochen Qiang [Fri, 24 May 2024 02:36:42 +0000 (10:36 +0800)]
wifi: ath12k: fix race due to setting ATH12K_FLAG_EXT_IRQ_ENABLED too early
Commit 5082b3e3027e ("wifi: ath11k: fix race due to setting
ATH11K_FLAG_EXT_IRQ_ENABLED too early") fixes a race in ath11k
driver. Since ath12k shares the same logic as ath11k, currently
the race also exists in ath12k: in ath12k_pci_ext_irq_enable(),
ATH12K_FLAG_EXT_IRQ_ENABLED is set before NAPI is enabled.
In cases where only one MSI vector is allocated, this results
in a race condition: after ATH12K_FLAG_EXT_IRQ_ENABLED is set
but before NAPI enabled, CE interrupt breaks in. Since IRQ is
shared by CE and data path, ath12k_pci_ext_interrupt_handler()
is also called where we call disable_irq_nosync() to disable
IRQ. Then napi_schedule() is called but it does nothing because
NAPI is not enabled at that time, meaning that
ath12k_pci_ext_grp_napi_poll() will never run, so we have
no chance to call enable_irq() to enable IRQ back. Since IRQ
is shared, all interrupts are disabled and we would finally
get no response from target.
So port ath11k fix here, this is done by setting
ATH12K_FLAG_EXT_IRQ_ENABLED after all NAPI and IRQ work are
done. With the fix, we are sure that by the time
ATH12K_FLAG_EXT_IRQ_ENABLED is set, NAPI is enabled.
Note that the fix above also introduce some side effects:
if ath12k_pci_ext_interrupt_handler() breaks in after NAPI
enabled but before ATH12K_FLAG_EXT_IRQ_ENABLED set, nothing
will be done by the handler this time, the work will be
postponed till the next time the IRQ fires.
Baochen Qiang [Fri, 24 May 2024 02:15:58 +0000 (10:15 +0800)]
wifi: ath11k: fix wrong definition of CE ring's base address
Base address of CE ring is defined as u32, currently this works
because coherent DMA mask configured as 32 bit:
#define ATH11K_PCI_COHERENT_DMA_MASK 32
However this mask could be changed once firmware bugs are fixed
to fully support 36 bit DMA addressing. So to protect against any
future changes to the DMA mask, change the type of the fields that
are dependent upon it.
This is found during code review. Compile tested only.
Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240524021558.34452-1-quic_bqiang@quicinc.com
P Praneesh [Mon, 20 May 2024 07:00:45 +0000 (12:30 +0530)]
wifi: ath12k: fix firmware crash during reo reinject
When handling fragmented packets, the ath12k driver reassembles each
fragment into a normal packet and then reinjects it into the HW ring.
However, a firmware crash occurs during this reinjection process.
The issue arises because the driver populates peer metadata in
reo_ent_ring->queue_addr_lo, while the firmware expects the physical
address obtained from the corresponding peer’s queue descriptor. Fix it
by filling peer's queue descriptor's physical address in queue_addr_lo.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: P Praneesh <quic_ppranees@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240520070045.631029-4-quic_ppranees@quicinc.com
P Praneesh [Mon, 20 May 2024 07:00:44 +0000 (12:30 +0530)]
wifi: ath12k: fix invalid memory access while processing fragmented packets
The monitor ring and the reo reinject ring share the same ring mask index.
When the driver receives an interrupt for the reo reinject ring, the
monitor ring is also processed, leading to invalid memory access. Since
monitor support is not yet enabled in ath12k, the ring mask for the monitor
ring should be removed.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: P Praneesh <quic_ppranees@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240520070045.631029-3-quic_ppranees@quicinc.com
P Praneesh [Mon, 20 May 2024 07:00:43 +0000 (12:30 +0530)]
wifi: ath12k: change DMA direction while mapping reinjected packets
For fragmented packets, ath12k reassembles each fragment as a normal
packet and then reinjects it into HW ring. In this case, the DMA
direction should be DMA_TO_DEVICE, not DMA_FROM_DEVICE. Otherwise,
an invalid payload may be reinjected into the HW and
subsequently delivered to the host.
Given that arbitrary memory can be allocated to the skb buffer,
knowledge about the data contained in the reinjected buffer is lacking.
Consequently, there’s a risk of private information being leaked.
The reason is, during resume, firmware is reinitialized but host does
not send current country code to firmware. So default reg rules with
country code set to 'na' is uploaded to host, as shown above.
Fix it by restoring country code to firmware during resume.
Karthikeyan Periyasamy [Tue, 21 May 2024 08:08:10 +0000 (11:08 +0300)]
wifi: ath12k: improve the rx descriptor error information
The ath12k_dp_get_rx_desc() failure log currently contains the same
information across multiple Rx data paths and lacks sufficient detail for
debugging purposes. To address this, change the ath12k_dp_get_rx_desc()
failure log to include cookie information along with Rx path details.
This will provide more specific data for debugging purposes.
Currently, data path Rx descriptor placed in the CMEM memory respective
to the Rx offset. This Rx descriptor CMEM placement is not meeting the
requirements to support inter device MLO. In inter device MLO, multiple
devices participate in a group. The device specific Rx descriptor buffers
transmit to multiple device REO rings. To distinguish between device
specific Rx descriptor buffers, the CMEM setup configuration need to
choose a different placement based on the unique identifier (device index).
Below are the CMEM configuration placement representation:
Baochen Qiang [Mon, 20 May 2024 11:58:28 +0000 (14:58 +0300)]
wifi: ath12k: fix Smatch warnings on ath12k_core_suspend()
Smatch is throwing below warning:
Commit 692921ead832 ("wifi: ath12k: flush all packets before
suspend") leads to the following Smatch static checker warning:
drivers/net/wireless/ath/ath12k/core.c:58 ath12k_core_suspend()
warn: sleeping in atomic context
and also gives the reason:
drivers/net/wireless/ath/ath12k/core.c
48 int ret, i;
49
50 if (!ab->hw_params->supports_suspend)
51 return -EOPNOTSUPP;
52
53 rcu_read_lock();
^^^^^^^^^^^^^^^
Disables preemption.
54 for (i = 0; i < ab->num_radios; i++) {
55 ar = ath12k_mac_get_ar_by_pdev_id(ab, i);
56 if (!ar)
57 continue;
--> 58 ret = ath12k_mac_wait_tx_complete(ar);
^^^^^^^
Sleeping in atomic context.
But it is weird that no warning on this in run time even with
CONFIG_DEBUG_ATOMIC_SLEEP=y. With some debug it is found that this is
because: when system goes to suspend, ath12k_mac_op_stop() gets called
where then in ath12k_mac_stop() ab->pdevs_active[ar->pdev_idx] is cleared.
This results in ath12k_mac_get_ar_by_pdev_id() always returning a NULL ar,
and thereby ath12k_mac_wait_tx_complete() never gets a chance to run.
Fix it by retrieving ar directly from ab->pdevs[].ar instead of using
ath12k_mac_get_ar_by_pdev_id(). Since ab->pdevs[].ar is set at boot time
and won't get cleared when suspend, ath12k_mac_wait_tx_complete() won't
be skipped. In addition, with ath12k_mac_get_ar_by_pdev_id() removed,
rcu_read_lock()/unlock() are not needed any more, so remove them. This
also fixes the warning above.
Fixes: 692921ead832 ("wifi: ath12k: flush all packets before suspend") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/ath12k/7a96ca11-80b5-4751-8cfc-fa637f3aa63a@moroto.mountain/ Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240511095045.9623-1-quic_bqiang@quicinc.com
Muna Sinada [Fri, 17 May 2024 07:00:30 +0000 (10:00 +0300)]
wifi: ath12k: dynamic VLAN support
Add support for dynamic VLAN. VLAN group traffic is encapsulated and
encrypted in mac80211 and driver needs to set flags for the VLAN group
traffic to skip hardware encapsulation and encryption.
VLAN group traffic utilizes ext MSDU and HTT Metadata to set
encapsulation type to RAW and encryption type to OPEN in order to
inform firmware to skip hardware encapsulation and encryption.
Lingbo Kong [Thu, 16 May 2024 08:30:44 +0000 (11:30 +0300)]
wifi: ath12k: fix ack signal strength calculation
Currently, the calculation of ack signal strength is incorrect.
This is because before calculating the ack signal strength, ath12k need
to determine whether the hardware and firmware support db2dbm. If the
hardware and firmware support db2dbm, do not need to add noise floor,
otherwise, need to add noise floor.
Besides, the value of ack_rssi passed by firmware to ath12k should be a
signed number, so change its type to s8.
This patch affects QCN9274 and WCN7850 because they have the same issue.
Karthikeyan Periyasamy [Tue, 14 May 2024 06:34:12 +0000 (12:04 +0530)]
wifi: ath12k: use correct MAX_RADIOS
The current value of the MAX_RADIOS definition is 3. This is incorrect
because no device supports more than 2 radios.
An incorrect MAX_RADIOS value can lead to:
- unnecessary memory allocation for pdev related entities.
- invalid pdev id validation.
- Misconceptions for code readers.
Kang Yang [Fri, 10 May 2024 11:12:38 +0000 (19:12 +0800)]
wifi: ath12k: remove redundant peer delete for WCN7850
ath12k_mac_op_unassign_vif_chanctx() will do peer delete for WCN7850's monitor
interface. But for host no need to do peer create/delete for monitor interface
because firmware doesn't require it, QCN9274 is the same. Also, the first
judgement is true only for WCN7850, so this logic won't affect QCN9274 at any
time.
Nithyanantham Paramasivam [Fri, 10 May 2024 07:04:27 +0000 (12:34 +0530)]
wifi: ath12k: Fix tx completion ring (WBM2SW) setup failure
We observe intermittent ping failures from the access point (AP) to
station (STA) in any mode (AP-STA or Mesh) configured. Specifically,
the transmission completion status is not received at tx completion
ring id 4 (WBM2SW ring4) for the packets transmitted via TCL DATA
ring id 3. This prevents freeing up tx descriptors and leads
to buffer exhaustion.
Currently, during initialization of the WBM2SW ring, we are directly
mapping the ring number to the ring mask to obtain the ring mask
group index. This approach is causing setup failures for WBM2SW
ring 4. Similarly, during runtime, when receiving incoming
transmission completion status, the validation of the ring number by
mapping the interrupted ring mask. This is resulting in
validation failure. Thereby preventing entry into the completion
handler ath12k_dp_tx_completion_handler().
The existing design assumed that the ring numbers would always be
sequential and could be directly mapped with the ring mask. However,
this assumption does not hold true for WBM2SW ring 4. Therefore,
modify the design such that, instead of mapping the ring number,
the ring ID is mapped with the ring mask.
According to this design:
1. During initialization of the WBM2SW ring, mapping the ring ID
to the ring mask will ensure obtaining the correct ring mask group
ID.
2. During runtime, validating the interrupted ring mask group ID
within the transmission completion group is sufficient. This
approach allows the ring ID to be derived from the interrupted ring
mask and enables entry into the completion handler.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Nithyanantham Paramasivam <quic_nithp@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240510070427.206152-1-quic_nithp@quicinc.com
Aloka Dixit [Wed, 8 May 2024 20:29:12 +0000 (13:29 -0700)]
wifi: ath12k: skip sending vdev down for channel switch
Remove the unnecessary WMI vdev down operation as firmware
internally does so already as part of WMI vdev restart.
Repeated vdev down results in a firmware crash during channel
switch operation when multiple BSSID advertisements are enabled:
ath12k_pci 0000:06:00.0: firmware crashed: MHI_CB_SYS_ERROR
ath12k_pci 0000:06:00.0: failed to send WMI_VDEV_SET_PARAM_CMDID
ath12k_pci 0000:06:00.0: failed to set vdev 5 HE MU mode: -108 param_value 7b
ath12k_pci 0000:06:00.0: failed to set he mode vdev 5
ath12k_pci 0000:06:00.0: failed to restart vdev 5: -108
ath12k_pci 0000:06:00.0: failed to send WMI_VDEV_SET_PARAM_CMDID
ath12k_pci 0000:06:00.0: failed to set vdev 4 HE MU mode: -108 param_value 7b
ath12k_pci 0000:06:00.0: failed to set he mode vdev 4
ath12k_pci 0000:06:00.0: failed to restart vdev 4: -108
ath12k_pci 0000:06:00.0: failed to send WMI_VDEV_SET_PARAM_CMDID
Aloka Dixit [Wed, 8 May 2024 20:29:11 +0000 (13:29 -0700)]
wifi: ath12k: add EMA beacon support
Add new function ath12k_mac_setup_bcn_tmpl_ema() which retrieves
a list of EMA (Enhanced Multi-BSSID Advertisements) beacon templates
from mac80211 and sends all to firmware. Add support to send EMA
configurations to firmware by adding a new parameter 'ema_params' in
struct wmi_bcn_tmpl_cmd.
Aloka Dixit [Wed, 8 May 2024 20:29:10 +0000 (13:29 -0700)]
wifi: ath12k: add MBSSID beacon support
- A single beacon template is used for one multiple BSSID group as
only one interface from group transmits the beacons. But firmware
requires the host to send this template each time a nontransmitted
interface is brought up. Hence, modify existing logic to retrieve
the template from vif context of the transmitting interface. Also,
firmware crashes if host sends a template for a nontransmitted
interface which is already up, add a check to avoid this.
- Set rsnie_present and wpaie_present fields for nontransmitted VAPs.
- Send offset to the multiple BSSID element in the beacon template
firmware.
Aloka Dixit [Wed, 8 May 2024 20:29:07 +0000 (13:29 -0700)]
wifi: ath12k: create a structure for WMI vdev up parameters
Host needs to send multiple BSSID configurations to firmware for
each vdev in ath12k_wmi_vdev_up() for AP mode. This function accepts
individual input parameters hence any new argument will require changes
to all callers. Most of these will use default value (0 or NULL).
Create a structure for the function arguments and include objects with
all members initialized to zero to minimize future changes.
Aloka Dixit [Wed, 8 May 2024 20:29:06 +0000 (13:29 -0700)]
wifi: ath12k: rename MBSSID fields in wmi_vdev_up_cmd
Rename trans_bssid to tx_vdev_bssid to make it similar to vdev_bssid.
Rename profile_num to nontx_profile_cnt, and profile_idx to
nontx_profile_idx which make it clear that these configurations
correspond to nontransmitted MBSSID profiles.
Aloka Dixit [Wed, 8 May 2024 20:29:05 +0000 (13:29 -0700)]
wifi: ath12k: configure MBSSID params in vdev create/start
Configure multiple BSSID flags and vdev_id of the transmited profile
in vdev create/start commands depending on the service bit
WMI_TLV_SERVICE_MBSS_PARAM_IN_VDEV_START_SUPPORT.
Aloka Dixit [Wed, 8 May 2024 20:29:04 +0000 (13:29 -0700)]
wifi: ath12k: advertise driver capabilities for MBSSID and EMA
Advertise the driver support for multiple BSSID (MBSSID) and
enhanced multi-BSSID advertisements (EMA) by setting extended
capabilities.
Configure mbssid_max_interfaces and ema_max_profile_periodicity
fields in structure wiphy which are used to advertise maximum number
of interfaces and profile periodicity supported by the driver.
Add new WMI fields to configure maximum vdev count supported for
MBSSID and profile periodicity in case of EMA.
Set WMI_RSRC_CFG_FLAGS2_CALC_NEXT_DTIM_COUNT_SET flag to allow
firmware to track and update the DTIM counts for each nontransmitted
profile.
wifi: ath12k: support SMPS configuration for 6 GHz
Parse SMPS configuration from IEs and configure. Without this,
SMPS is not enabled for 6 GHz band. This is disabled for
WCN7850 as hardware does not support it.
Move fetching SMPS value to a new function and use u16_get_bits
to extract it from capabilities. This will help in extending the
functionality when SMPS support in 6 GHz band gets added in
subsequent patches.
wifi: ath12k: add 6 GHz params in peer assoc command
Currently A-MPDU aggregation parameters are not being configured
during peer association for 6 GHz band. Hence, extract these
parameters from station's capabilities received in association
request and send to firmware. Without this, A-MPDU aggregation
is not happening in 6 GHz band.
Co-developed-by: Avula Sri Charan <quic_asrichar@quicinc.com> Signed-off-by: Avula Sri Charan <quic_asrichar@quicinc.com> Signed-off-by: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240508173655.22191-5-quic_pradeepc@quicinc.com
When ath12k receives survey request, choose the 6 GHz band
when enabled. Without this, survey requests do not include
any 6 GHz band results, leading to failures in auto channel
selection.
wifi: ath12k: Correct 6 GHz frequency value in rx status
The frequency in the rx status is currently being filled
incorrectly for the 6 GHz band. The channel number received is
invalid in this case, resulting in packet drops. Fix this
issue by correcting the frequency calculation.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240508173655.22191-3-quic_pradeepc@quicinc.com
Sebastian Gottschall [Mon, 13 May 2024 14:22:25 +0000 (17:22 +0300)]
wifi: ath10k: add LED and GPIO controlling support for various chipsets
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984
based chipsets with on chipset connected led's using WMI Firmware API.
The LED device will get available named as "ath10k-phyX" at sysfs and
can be controlled with various triggers.
Adds also debugfs interface for gpio control.
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com> Reviewed-by: Steve deRosier <derosier@cal-sierra.com>
[kvalo: major reorg and cleanup] Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
[ansuel: rebase and small cleanup] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20230611080505.17393-1-ansuelsmth@gmail.com
Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].
Un-embed the net_device from struct ath12k_ext_irq_grp by converting it
into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
the net_device object at ath12k_pci_ext_irq_config().
The free of the device occurs at ath12k_pci_free_ext_irq().
Marc Gonzalez [Mon, 29 Apr 2024 14:06:29 +0000 (16:06 +0200)]
wifi: ath10k: do not always wait for MSA_READY indicator
The ath10k driver waits for an "MSA_READY" indicator
to complete initialization. If the indicator is not
received, then the device remains unusable.
Several msm8998-based devices are affected by this issue.
Oddly, it seems safe to NOT wait for the indicator, and
proceed immediately when QMI_EVENT_SERVER_ARRIVE.
The feedback I received was "it might be ok to change all ath10k qmi
to skip waiting for msa_ready", and it was pointed out that ath11k
(and ath12k) do not wait for it.
However with so many deployed devices, "might be ok" isn't a strong
argument for changing the default behavior.
Signed-off-by: Marc Gonzalez <mgonzalez@freebox.fr> Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/23540303-5816-45d5-a1af-5f09d645a73b@freebox.fr
The ath10k driver waits for an "MSA_READY" indicator
to complete initialization. If the indicator is not
received, then the device remains unusable.
cf. ath10k_qmi_driver_event_work()
Several msm8998-based devices are affected by this issue.
Oddly, it seems safe to NOT wait for the indicator, and
proceed immediately when QMI_EVENT_SERVER_ARRIVE.
Jeff Johnson wrote:
The feedback I received was "it might be ok to change all ath10k qmi
to skip waiting for msa_ready", and it was pointed out that ath11k
(and ath12k) do not wait for it.
However with so many deployed devices, "might be ok" isn't a strong
argument for changing the default behavior.
Kalle Valo first suggested setting a bit in firmware-5.bin to trigger
work-around in the driver. However, firmware-5.bin is parsed too late.
So we are stuck with a DT property.
Signed-off-by: Marc Gonzalez <mgonzalez@freebox.fr> Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/54ac2295-36b4-49fc-9583-a10db8d9d5d6@freebox.fr
Jeff Johnson [Tue, 7 May 2024 10:45:03 +0000 (13:45 +0300)]
wifi: ath12k: initialize 'ret' in ath12k_dp_rxdma_ring_sel_config_wcn7850()
smatch flagged the following issue:
drivers/net/wireless/ath/ath12k/dp_rx.c:4065 ath12k_dp_rxdma_ring_sel_config_wcn7850() error: uninitialized symbol 'ret'.
In ath12k_dp_rxdma_ring_sel_config_wcn7850() if it were ever the case
that ab->hw_params->num_rxdma_per_pdev was 0 then 'ret' would be
uninitialized when it is returned. This should never be the case, but
to be safe and to quiet smatch, add an initializer to the declaration
of 'ret'.
Karthikeyan Periyasamy [Mon, 6 May 2024 17:30:17 +0000 (23:00 +0530)]
wifi: ath12k: avoid double SW2HW_MACID conversion
Currently, ath12k_wmi_pdev_dma_ring_cfg() fails due to an invalid pdev_id
parameter passed to the WMI_PDEV_DMA_RING_CFG_REQ_CMDID WMI command. This
invalid pdev_id is caused by a double conversion of the MAC ID. Since the
the caller of ath12k_wmi_pdev_dma_ring_cfg() already performs the MAC ID
conversion, it is unnecessary to do it again within the function. To fix
this, remove the software (SW) to hardware (HW) MAC ID conversion from
ath12k_wmi_pdev_dma_ring_cfg() to avoid this redundant conversion.
Jeff Johnson [Sat, 4 May 2024 18:52:09 +0000 (11:52 -0700)]
wifi: ath11k: initialize 'ret' in ath11k_qmi_load_file_target_mem()
smatch flagged the following issue:
drivers/net/wireless/ath/ath11k/qmi.c:2401 ath11k_qmi_load_file_target_mem() error: uninitialized symbol 'ret'.
The reality is that 'ret' is initialized in every path through
ath11k_qmi_load_file_target_mem() except one, the case where the input
'len' is 0, and hence the "while (remaining)" loop is never entered.
But to make sure this case is also handled, add an initializer to the
declaration of 'ret'.
Jeff Johnson [Sat, 4 May 2024 18:52:08 +0000 (11:52 -0700)]
wifi: ath12k: initialize 'ret' in ath12k_qmi_load_file_target_mem()
smatch flagged the following issue:
drivers/net/wireless/ath/ath12k/qmi.c:2619 ath12k_qmi_load_file_target_mem() error: uninitialized symbol 'ret'.
The reality is that 'ret' is initialized in every path through
ath12k_qmi_load_file_target_mem() except one, the case where the input
'len' is 0, and hence the "while (remaining)" loop is never entered.
But to make sure this case is also handled, add an initializer to the
declaration of 'ret'.
Kang Yang [Mon, 29 Apr 2024 08:15:25 +0000 (16:15 +0800)]
wifi: ath12k: remove invalid peer create logic
In ath12k_mac_op_assign_vif_chanctx(), there is a logic to
create peer using ar->mac_addr for a STA vdev. This is invalid
because a STA vdev should have a peer created using AP's
MAC address. Besides, if we run into that logic, it means a peer
has already been created earlier, we should not create it again.
So remove it.
Kang Yang [Mon, 29 Apr 2024 08:15:22 +0000 (16:15 +0800)]
wifi: ath12k: avoid duplicated vdev stop
ath12k_mac_op_unassign_vif_chanctx() will do vdev stop in
ath12k_mac_monitor_stop(). This ath12k_mac_vdev_stop() will do vdev stop
again, then might trigger firmware crash.
Fixes: c9e4e41e71ff ("wifi: ath12k: move peer delete after vdev stop of station for WCN7850") Signed-off-by: Kang Yang <quic_kangyang@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240429081525.983-3-quic_kangyang@quicinc.com
Currently memory allocation for multiple hardware rings done
in host as these memory will be used by firmware/hardware.
But in case of tcl_cmd_ring and tcl_status_ring neither firmware
nor hardware uses host allocated memory and it uses memory
allocated by firmware itself. So avoid tcl_cmd_ring and
tcl_status_ring setup in host.
wifi: ath12k: fix calling correct function for rx monitor mode
Currently in ath12k_dp_tx_htt_monitor_mode_ring_config()
ath12k_dp_tx_htt_tx_monitor_mode_ring_config() function wrongly called twice.
Fix that by calling ath12k_dp_tx_htt_rx_monitor_mode_ring_config().
Currently monitor mode is disabled in driver so the change is compile
tested and boot sequence verified.
Breno Leitao [Fri, 3 May 2024 10:32:56 +0000 (03:32 -0700)]
wifi: wil6210: Do not use embedded netdev in wil6210_priv
Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].
Un-embed the net_device from struct wil6210_priv by converting it
into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
the net_device object at wil_if_add(). The free of the device
occurs at wil_if_remove().
Venkateswara Naralasetty [Fri, 3 May 2024 13:24:16 +0000 (16:24 +0300)]
wifi: ath11k: skip status ring entry processing
If STATUS_BUFFER_DONE is not set for a monitor status ring entry,
we don't process the status ring until STATUS_BUFFER_DONE set
for that status ring entry.
During LMAC reset it may happen that hardware will not write
STATUS_BUFFER_DONE tlv in status buffer, in that case we end up
waiting for STATUS_BUFFER_DONE leading to backpressure on monitor
status ring.
To fix the issue, when HP (Head Pointer) + 1 entry is peeked and if DMA is not
done and if HP + 2 entry's DMA done is set, replenish HP + 1 entry and start
processing in next interrupt. If HP + 2 entry's DMA done is not set, poll onto
HP + 1 entry DMA done to be set.
Also, during monitor attach HP points to the end of the ring and TP (Tail
Pointer) points to the start of the ring. Using ath11k_hal_srng_src_peek() may
result in processing invalid buffer for the very first interrupt. Since, HW
starts writing buffer from TP.
To avoid this issue call ath11k_hal_srng_src_next_peek() instead of
calling ath11k_hal_srng_src_peek().
Signed-off-by: Venkateswara Naralasetty <quic_vnaralas@quicinc.com> Co-developed-by: Tamizh Chelvam Raja <quic_tamizhr@quicinc.com> Signed-off-by: Tamizh Chelvam Raja <quic_tamizhr@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240429073624.736147-1-quic_tamizhr@quicinc.com
Karthikeyan Kathirvel [Fri, 3 May 2024 10:34:39 +0000 (13:34 +0300)]
wifi: ath12k: drop failed transmitted frames from metric calculation.
In mesh node traffic, internal firmware-transmitted failures are
reported as transmitted failures in mesh metric calculation, leading
to the breakage of the mesh link.
Fix the issue by dropping the internal firmware-transmitted failures
before updating the TX completion status to mac80211, in order to
prevent false failure averaging in mesh metric calculation.
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Karthikeyan Kathirvel <quic_kathirve@quicinc.com> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://msgid.link/20240430074313.885807-3-quic_kathirve@quicinc.com
Sven Eckelmann [Fri, 3 May 2024 10:34:39 +0000 (13:34 +0300)]
wifi: ath12k: Don't drop tx_status in failure case
When a station idles for a long time, hostapd will try to send
a QoS Null frame to the station as "poll". NL80211_CMD_PROBE_CLIENT
is used for this purpose.
And the skb will be added to ack_status_frame - waiting for a
completion via ieee80211_report_ack_skb().
But when the peer was already removed before the tx_complete arrives,
the peer will be missing. And when using dev_kfree_skb_any (instead
of going through mac80211), the entry will stay inside
ack_status_frames thus not clean up related information in its
internal data structures. This IDR will therefore run full after
8K request were generated for such clients.
At this point, the access point will then just stall and not allow
any new clients because idr_alloc() for ack_status_frame will fail.
ieee80211_free_txskb() on the other hand will (when required) call
ieee80211_report_ack_skb() and make sure that (when required) remove
the entry from the ack_status_frame and clean up related
information in its internal data structures.
Karthikeyan Periyasamy [Fri, 3 May 2024 10:34:39 +0000 (13:34 +0300)]
wifi: ath12k: add multi device support for WBM idle ring buffer setup
Currently, inter device MLO is not supported. Therefore, the WBM idle ring
buffers choose the implicit return buffer manager (DEV0_IDLE_DESC_LIST).
However, this implicit return buffer manager design is not meeting the
requirements to support inter device MLO. In inter device MLO, multiple
devices participate. The device specific WBM idle ring buffers transmit
to multiple device REO rings. To distinguish between device specific WBM
idle buffers, the setup configuration need to choose a different return
buffer manager based on the unique identifier (device index).
Karthikeyan Periyasamy [Fri, 3 May 2024 10:34:38 +0000 (13:34 +0300)]
wifi: ath12k: Introduce device index
Introduce a device index parameter in the ath12k_base structure. This
value is used as unique identifier for devices involved in Inter-device
MLO. It is also used to configure the MLO parameter within the QMI host
capability send request. While currently set to zero, future logic will
be added for inter device support to populate this parameter with
non-zero values.
Karthikeyan Periyasamy [Fri, 3 May 2024 10:34:38 +0000 (13:34 +0300)]
wifi: ath12k: Refactor idle ring descriptor setup
Currently, the WBM idle ring descriptor setup uses implicit value
HAL_RX_BUF_RBM_WBM_DEV0_IDLE_DESC_LIST for the return buffer manager
parameter. To support inter-device MLO (Multi-link operation), this
parameter needs to be configure dynamically based on the device identifier
within the MLO group. Therefore, introduce a new argument to the helper
function ath12k_hal_set_link_desc_addr().
Jeff Johnson [Fri, 3 May 2024 10:34:38 +0000 (13:34 +0300)]
wifi: ath11k: unmap the CE in ath11k_ahb_probe() error path
Currently, in ath11k_ahb_probe(), if a failure occurs after
ath11k_ahb_ce_remap() is called, and if hw_params->ce_remap is
enabled, the CE register memory is not unmapped. So add a call to
ath11k_ahb_ce_unmap() in the error path.
This issue was identified by smatch/smatch_scripts/kchecker:
drivers/net/wireless/ath/ath11k/ahb.c:1218 ath11k_ahb_probe() warn: 'ab->mem_ce' from ioremap() not released on lines: 1218.
Since this is a rare error path with no simple way to test, and since
the change is trivial to review, compile tested only.
Jeff Johnson [Fri, 3 May 2024 10:34:37 +0000 (13:34 +0300)]
wifi: ath11k: refactor CE remap & unmap
Currently the logic that handles hw_params->ce_remap is inline code,
both for doing the remap and the unmap. An upcoming change needs to do
the unmap in a second place, so refactor the unmap logic into a
separate function. And although it is only called from one place,
refactor the remap logic as well to have functional symmetry.
Karthikeyan Periyasamy [Fri, 3 May 2024 10:34:37 +0000 (13:34 +0300)]
wifi: ath12k: Add lock to protect the hardware state
Currently, hardware state is not protected across the reconfigure
operations. However, in single wiphy models, multiple radio/links is
exposed as a MAC hardware (ieee80211_hw) through the driver hardware
abstraction (ath12k_hw) layer. In such scenario, we need to protect
hardware state across the multiple radio/link at the driver hardware
abstraction (ath12k_hw) layer. Therefore, introduce a new mutex in
the ath12k_hw layer.
Karthikeyan Periyasamy [Fri, 3 May 2024 10:34:37 +0000 (13:34 +0300)]
wifi: ath12k: Refactor the hardware state
Currently, in multi wiphy models, the mac80211 hardware state is maintained
within the radio/link structure. However, in single wiphy models, the
mac80211 hardware state is needed at the hardware abstraction layer
(ath12k_hw). Therefore, move the hardware state from the radio/link
structure to the hardware abstraction layer (ath12k_hw). Additionally,
update the naming convention of the state enums to enhance clarity and
consistency.
Karthikeyan Periyasamy [Fri, 3 May 2024 10:34:36 +0000 (13:34 +0300)]
wifi: ath12k: Refactor the hardware recovery procedure
Currently, in multi-wiphy models, the recovery handler access mac80211
HW from the radio/link structure. This will be incorrect for single wiphy
model, as they will hold multiple link/radio structures. To fix this,
access mac80211 HW based on the number of hardware in the SoC/chip. This
approach makes the recovery handler compatible with both multi wiphy and
single wiphy models.
In order to support color change with MLO, handle the link ID now
passed from cfg80211, adjust the code to do everything per link
and call the notifications to cfg80211 correctly.
Currently, during color change, no link id information is passed down.
In order to support color change during Multi Link Operation, it is
required to pass link id as well.
Additionally, update notification APIs to allow drivers/mac80211 to
pass the link ID.
Xin Deng [Fri, 26 Apr 2024 09:25:01 +0000 (02:25 -0700)]
wifi: cfg80211: Clear mlo_links info when STA disconnects
wdev->valid_links is not cleared when upper layer disconnect from a
wdev->AP MLD. It has been observed that this would prevent offchannel
operations like remain-on-channel which would be needed for user space
operations with Public Action frame.
Clear the wdev->valid_links when STA disconnects.
struct net_device shouldn't be embedded into any structure, instead,
the owner should use the priv space to embed their state into net_device.
Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].
Un-embed the net_device from struct iwl_trans_pcie by converting it
into a pointer. Then use the leverage alloc_netdev() to allocate the
net_device object at iwl_trans_pcie_alloc.
The private data of net_device becomes a pointer for the struct
iwl_trans_pcie, so, it is easy to get back to the iwl_trans_pcie parent
given the net_device object.
Deren Wu [Mon, 15 Apr 2024 13:03:42 +0000 (21:03 +0800)]
wifi: mt76: mt7925: add EHT radiotap support in monitor mode
Add IEEE80211_RADIOTAP_EHT and IEEE80211_RADIOTAP_EHT_USIG radiotap
to fill in EHT information, such as MCS, NSS, GI and bandwidth.
Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@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>
Introduce wifi LED switch control, add flow to Control a wifi
gpio pin based on the status of WIFI radio, if the pin is connected
to an LED, the LED will indicate the status of the WiFi radio.
Signed-off-by: Hao Zhang <hao.zhang@mediatek.com> Co-developed-by: Quan Zhou <quan.zhou@mediatek.com> Signed-off-by: Quan Zhou <quan.zhou@mediatek.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Michael-CY Lee [Mon, 8 Apr 2024 06:14:21 +0000 (14:14 +0800)]
wifi: mt76: mt7996: let upper layer handle MGMT frame protection
The firmware support for management frame protection has limitations:
- do not support cipher BIP-GMAC-128 and BIP-GMAC-256
- support cipher BIP-CMAC-128 and BIP-CMAC-256, except action frame with
action type 'not robust'.
Therefore, to simplify the logic, do not set the IGTK to firmware and
let the encryption of management frames be handled by upper layer.
Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
The implementation amounts to setting the driver flag
IEEE80211_VIF_SUPPORTS_CQM_RSSI, and then providing
mechanisms for continuously updating enough information
to be able to provide notifications to userspace when
RSSI drops below a certain threshold
Signed-off-by: Rong Yan <rong.yan@mediatek.com> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Howard Hsu [Wed, 20 Mar 2024 11:09:15 +0000 (19:09 +0800)]
wifi: mt76: connac: enable critical packet mode support for mt7992
For mt7992 chipsets, critical packet mode should be properly configured
to let the HW SDO module correctly fill the AC queue in TX descriptors of
some higher priority packets such as ARP and ICMP.
Without this patch, HW queues may hang when running MU traffic.
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Howard Hsu [Wed, 20 Mar 2024 11:09:12 +0000 (19:09 +0800)]
wifi: mt76: connac: enable HW CSO module for mt7996
For mt7996 chipsets, the HW CSO module can help to identify TCP traffic,
which assists the firmware in adjusting algorithms to improve overall
performance.
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Shayne Chen [Wed, 20 Mar 2024 11:09:09 +0000 (19:09 +0800)]
wifi: mt76: connac: use peer address for station BMC entry
Set peer address and aid for the BMC wtbl of station interface. For some
functions such as parsing MU_EDCA parameters from beacon, firmware will
need the peer address to do correct parsing.
Without this patch, MU uplink traffic would get suffered.
Reported-by: Howard Hsu <howard-yh.hsu@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Shayne Chen [Wed, 20 Mar 2024 11:09:10 +0000 (19:09 +0800)]
wifi: mt76: mt7996: disable rx header translation for BMC entry
When a BMC wtbl of station interface is correctly set with peer address,
HW will do rx header translation for broadcast data packets, which makes
mac80211 unable to find the corresponding ieee80211_sta and drop the
packets. To fix this, disable HW rx header translation for BMC entry.
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Even if it is not a real issue at the moment since concurrent access to
mcu message queue is protected by mcu mutex, make the code more robust
and move mcu queue free space check inside queue spinlock critical section.
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Leon Yen [Thu, 7 Mar 2024 09:46:32 +0000 (17:46 +0800)]
wifi: mt76: mt7921s: fix potential hung tasks during chip recovery
During chip recovery (e.g. chip reset), there is a possible situation that
kernel worker reset_work is holding the lock and waiting for kernel thread
stat_worker to be parked, while stat_worker is waiting for the release of
the same lock.
It causes a deadlock resulting in the dumping of hung tasks messages and
possible rebooting of the device.
This patch prevents the execution of stat_worker during the chip recovery.
Signed-off-by: Leon Yen <leon.yen@mediatek.com> Signed-off-by: Ming Yen Hsieh <MingYen.Hsieh@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Deren Wu [Wed, 6 Mar 2024 12:22:14 +0000 (20:22 +0800)]
wifi: mt76: mt7921: introduce mt7920 PCIe support
mt7920e is a mt7921 series chipset with 802.11ax 2x2:2SS support.
The major difference is in firmware side only, at this moment.
This patch would add some mandatory changes for new chip id and
firmware download control.
Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Muhammad Usama Anjum [Fri, 1 Mar 2024 14:44:06 +0000 (19:44 +0500)]
wifi: mt76: connac: check for null before dereferencing
The wcid can be NULL. It should be checked for validity before
dereferencing it to avoid crash.
Fixes: 098428c400ff ("wifi: mt76: connac: set correct muar_idx for mt799x chipsets") Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>