linux-2.6-block.git
9 months agowifi: ath9k: Remove unnecessary (void*) conversions
Wu Yunchuan [Wed, 22 Nov 2023 18:31:03 +0000 (20:31 +0200)]
wifi: ath9k: Remove unnecessary (void*) conversions

No need cast (void *) to (struct owl_ctx *), (struct ath_hw *),
(struct cmd_buf *) or other types.

Signed-off-by: Wu Yunchuan <yunchuan@nfschina.com>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230919045226.524544-1-yunchuan@nfschina.com
9 months agowifi: ath12k: refactor DP Rxdma ring structure
Karthikeyan Periyasamy [Wed, 22 Nov 2023 18:31:02 +0000 (20:31 +0200)]
wifi: ath12k: refactor DP Rxdma ring structure

Currently data path Rxdma ring structure store the IDR buffer and lock.
These IDR handling is needed only for SW cookie conversion and not
needed for HW cookie conversion. REO Rxdma ring use the HW cookie
conversion and monitor Rxdma ring use the SW cookie conversion.
Since idr not needed for REO Rxdma ring, remove the IDR data entity
from the data path Rxdma ring structure. Introduce the new data path ring
structure for monitor rxmda rings since it need IDR data entity.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00125-QCAHKSWPL_SILICONZ-1

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231111043934.20485-5-quic_periyasa@quicinc.com
9 months agowifi: ath12k: avoid explicit HW conversion argument in Rxdma replenish
Karthikeyan Periyasamy [Wed, 22 Nov 2023 18:31:02 +0000 (20:31 +0200)]
wifi: ath12k: avoid explicit HW conversion argument in Rxdma replenish

Currently Rxdma replenish require HW conversion argument which is
unnecessary argument since ath12k driver configures the Rxdma only
in HW conversion. To optimize the rx data path per packet, avoid
the explicit unnecessary argument and condition check in the rx
replenish.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00125-QCAHKSWPL_SILICONZ-1

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231111043934.20485-4-quic_periyasa@quicinc.com
9 months agowifi: ath12k: avoid explicit RBM id argument in Rxdma replenish
Karthikeyan Periyasamy [Wed, 22 Nov 2023 18:31:02 +0000 (20:31 +0200)]
wifi: ath12k: avoid explicit RBM id argument in Rxdma replenish

Currently all Rxdma replenish callers pass the same return
buffer manager id argument, so make it implicitly. To
optimize the rx data path per packet, avoid the explicit
unnecessary argument in Rxdma replenish function.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00125-QCAHKSWPL_SILICONZ-1

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231111043934.20485-3-quic_periyasa@quicinc.com
9 months agowifi: ath12k: avoid explicit mac id argument in Rxdma replenish
Karthikeyan Periyasamy [Wed, 22 Nov 2023 18:31:02 +0000 (20:31 +0200)]
wifi: ath12k: avoid explicit mac id argument in Rxdma replenish

Currently all Rxdma replenish callers pass zero for the mac id
argument, so make it as zero implicitly. To optimize the rx
data path per packet, avoid the explicit unnecessary argument
in Rxdma replenish function.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00125-QCAHKSWPL_SILICONZ-1

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231111043934.20485-2-quic_periyasa@quicinc.com
9 months agowifi: ath12k: fix the error handler of rfkill config
Karthikeyan Periyasamy [Wed, 22 Nov 2023 18:31:02 +0000 (20:31 +0200)]
wifi: ath12k: fix the error handler of rfkill config

When the core rfkill config throws error, it should free the
allocated resources. Currently it is not freeing the core pdev
create resources. Avoid this issue by calling the core pdev
destroy in the error handler of core rfkill config.

Found this issue in the code review and it is compile tested only.

Fixes: 004ccbc0dd49 ("wifi: ath12k: add support for hardware rfkill for WCN7850")
Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231111040107.18708-1-quic_periyasa@quicinc.com
9 months agowifi: ath12k: use select for CRYPTO_MICHAEL_MIC
James Prestwood [Mon, 13 Nov 2023 15:35:44 +0000 (07:35 -0800)]
wifi: ath12k: use select for CRYPTO_MICHAEL_MIC

Let ath12k select this option automatically which makes building
more intuitive if the user enables this driver (rather than the
driver not building unless CRYPTO_MICHAEL_MIC is explicitly enabled).

Further investigation shows that ath11k and ath12k are the only who use
'depends on' with CRYPTO_MICHAEL_MIC:

./drivers/net/wireless/intel/ipw2x00/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/net/wireless/intersil/hostap/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/net/wireless/intersil/orinoco/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/net/wireless/ath/ath11k/Kconfig: depends on CRYPTO_MICHAEL_MIC
./drivers/net/wireless/ath/ath12k/Kconfig: depends on CRYPTO_MICHAEL_MIC
./drivers/staging/rtl8192e/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/staging/ks7010/Kconfig: select CRYPTO_MICHAEL_MIC

Signed-off-by: James Prestwood <prestwoj@gmail.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231113153544.282461-2-prestwoj@gmail.com
9 months agowifi: ath11k: use select for CRYPTO_MICHAEL_MIC
James Prestwood [Mon, 13 Nov 2023 15:35:43 +0000 (07:35 -0800)]
wifi: ath11k: use select for CRYPTO_MICHAEL_MIC

Let ath11k select this option automatically which makes building
more intuitive if the user enables this driver (rather than the
driver not building unless CRYPTO_MICHAEL_MIC is explicitly enabled).

Further investigation shows that ath11k and ath12k are the only who use
'depends on' with CRYPTO_MICHAEL_MIC:

./drivers/net/wireless/intel/ipw2x00/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/net/wireless/intersil/hostap/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/net/wireless/intersil/orinoco/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/net/wireless/ath/ath11k/Kconfig: depends on CRYPTO_MICHAEL_MIC
./drivers/net/wireless/ath/ath12k/Kconfig: depends on CRYPTO_MICHAEL_MIC
./drivers/staging/rtl8192e/Kconfig: select CRYPTO_MICHAEL_MIC
./drivers/staging/ks7010/Kconfig: select CRYPTO_MICHAEL_MIC

Signed-off-by: James Prestwood <prestwoj@gmail.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231113153544.282461-1-prestwoj@gmail.com
10 months agowifi: ath12k: Consolidate WMI peer flags
Jeff Johnson [Mon, 6 Nov 2023 18:26:06 +0000 (10:26 -0800)]
wifi: ath12k: Consolidate WMI peer flags

Currently wmi.h has two separate set of definitions for peer
flags. One set of flags is defined in enum wmi_tlv_peer_flags, and,
except for the last three, are named WMI_TLV_PEER_*. The other set of
flags are defined as macros, and are named WMI_PEER_*. The last three
macros have the same name as the last three wmi_tlv_peer_flags
enumerators.

The code only uses the WMI_PEER_* names; the WMI_TLV_PEER_* names are
unused. So as a first step in consolidation, remove all the
WMI_TLV_PEER_* names.

But since having an enum to define all the flags is actually a good
thing since that provides a handle by which to refer to the entire set
of flags, recast the WMI_PEER_* macros into enumerators.

Compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231106-ath-peer-flags-v1-4-781e83b7e8e8@quicinc.com
10 months agowifi: ath11k: Consolidate WMI peer flags
Jeff Johnson [Mon, 6 Nov 2023 18:26:05 +0000 (10:26 -0800)]
wifi: ath11k: Consolidate WMI peer flags

Currently wmi.h has two separate set of definitions for peer
flags. One set of flags is defined in enum wmi_tlv_peer_flags, and,
except for the last three, are named WMI_TLV_PEER_*. The other set of
flags are defined as macros, and are named WMI_PEER_*. The last three
macros have the same name as the last three wmi_tlv_peer_flags
enumerators.

The code only uses the WMI_PEER_* names; the WMI_TLV_PEER_* names are
unused. So as a first step in consolidation, remove all the
WMI_TLV_PEER_* names.

But since having an enum to define all the flags is actually a good
thing since that provides a handle by which to refer to the entire set
of flags, recast the WMI_PEER_* macros into enumerators.

Compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231106-ath-peer-flags-v1-3-781e83b7e8e8@quicinc.com
10 months agowifi: ath12k: Remove obsolete struct wmi_peer_flags_map *peer_flags
Jeff Johnson [Mon, 6 Nov 2023 18:26:04 +0000 (10:26 -0800)]
wifi: ath12k: Remove obsolete struct wmi_peer_flags_map *peer_flags

Currently both struct ath12k_wmi_pdev and struct ath12k_wmi_base
define:
        const struct wmi_peer_flags_map *peer_flags;

But that member is not used, and in fact, struct wmi_peer_flags_map
is not defined within ath12k; these are obsolete remnants inherited
from ath11k. So remove them.

Compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231106-ath-peer-flags-v1-2-781e83b7e8e8@quicinc.com
10 months agowifi: ath11k: Remove obsolete struct wmi_peer_flags_map *peer_flags
Jeff Johnson [Mon, 6 Nov 2023 18:26:03 +0000 (10:26 -0800)]
wifi: ath11k: Remove obsolete struct wmi_peer_flags_map *peer_flags

Currently both struct ath11k_pdev_wmi and struct ath11k_wmi_base
define:
const struct wmi_peer_flags_map *peer_flags;

But that member is not used, and in fact, struct wmi_peer_flags_map
is not defined within ath11k; these are obsolete remnants inherited
from ath10k. So remove them.

Compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231106-ath-peer-flags-v1-1-781e83b7e8e8@quicinc.com
10 months agowifi: ath12k: Remove struct ath12k::ops
Jeff Johnson [Mon, 6 Nov 2023 18:21:05 +0000 (10:21 -0800)]
wifi: ath12k: Remove struct ath12k::ops

Currently struct ath12k defines the following member:
struct ieee80211_ops *ops;

This is being flagged by checkpatch.pl:
WARNING: struct ieee80211_ops should normally be const

The original plan was to add the const qualifier.  However, it turns
out this is actually unused, so remove it.

No functional changes, compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231106-ath12k-remove-ieee80211_ops-v1-2-d72cef1a855b@quicinc.com
10 months agowifi: ath11k: Remove struct ath11k::ops
Jeff Johnson [Mon, 6 Nov 2023 18:21:04 +0000 (10:21 -0800)]
wifi: ath11k: Remove struct ath11k::ops

Currently struct ath11k defines the following member:
        struct ieee80211_ops *ops;

This is being flagged by checkpatch.pl:
WARNING: struct ieee80211_ops should normally be const

The original plan was to add the const qualifier.  However, it turns
out this is actually unused, so remove it.

No functional changes, compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231106-ath12k-remove-ieee80211_ops-v1-1-d72cef1a855b@quicinc.com
10 months agowifi: ath10k: Remove unused struct ath10k_htc_frame
Jeff Johnson [Fri, 3 Nov 2023 22:05:36 +0000 (15:05 -0700)]
wifi: ath10k: Remove unused struct ath10k_htc_frame

struct ath10k_htc_frame is unused, and since it illogically contains
two consecutive flexible arrays, it could never be used, so remove it.

No functional changes, compile tested only.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231103-ath10k_htc_frame-v1-1-ff00b38a9630@quicinc.com
10 months agowifi: ath10k: simplify __ath10k_htt_tx_txq_recalc()
Dmitry Antipov [Thu, 2 Nov 2023 11:54:52 +0000 (14:54 +0300)]
wifi: ath10k: simplify __ath10k_htt_tx_txq_recalc()

Since 'ieee80211_txq_get_depth()' allows NULL for 2nd and
3rd arguments, simplify '__ath10k_htt_tx_txq_recalc()' by
dropping unused 'frame_cnt'. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231102115459.69791-1-dmantipov@yandex.ru
10 months agowifi: ath11k: Remove unneeded semicolon
Yang Li [Mon, 30 Oct 2023 06:02:25 +0000 (14:02 +0800)]
wifi: ath11k: Remove unneeded semicolon

./drivers/net/wireless/ath/ath11k/fw.c:136:2-3: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=7073
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231030060225.28987-1-yang.lee@linux.alibaba.com
10 months agowifi: ath11k: Defer on rproc_get failure
Luca Weiss [Fri, 27 Oct 2023 06:57:18 +0000 (08:57 +0200)]
wifi: ath11k: Defer on rproc_get failure

If we already have gotten the rproc_handle (meaning the "qcom,rproc"
property is defined in the devicetree), it's a valid state that the
remoteproc module hasn't probed yet so we should defer probing instead
of just failing to probe.

This resolves a race condition when the ath11k driver probes and fails
before the wpss remoteproc driver has probed, like the following:

  [    6.232360] ath11k 17a10040.wifi: failed to get rproc
  [    6.232366] ath11k 17a10040.wifi: failed to get rproc: -22
  [    6.232478] ath11k: probe of 17a10040.wifi failed with error -22
       ...
  [    6.252415] remoteproc remoteproc2: 8a00000.remoteproc is available
  [    6.252776] remoteproc remoteproc2: powering up 8a00000.remoteproc
  [    6.252781] remoteproc remoteproc2: Booting fw image qcom/qcm6490/fairphone5/wpss.mdt, size 7188

So, defer the probe if we hit that so we can retry later once the wpss
remoteproc is available.

Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-01264-QCAMSLSWPLZ-1.37886.3

Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231027-ath11k-rproc-defer-v1-1-f6b6a812cd18@fairphone.com
10 months agowifi: ath10k: replace deprecated strncpy with memcpy
Justin Stitt [Wed, 25 Oct 2023 17:47:56 +0000 (20:47 +0300)]
wifi: ath10k: replace deprecated strncpy with memcpy

strncpy() is deprecated [1] and we should prefer less ambiguous
interfaces.

In this case, arvif->u.ap.ssid has its length maintained by
arvif->u.ap.ssid_len which indicates it may not need to be
NUL-terminated. Make this explicit with __nonstring and use a plain old
memcpy.

This is also consistent with future copies into arvif->u.ap.ssid:

if (changed & BSS_CHANGED_SSID &&
    vif->type == NL80211_IFTYPE_AP) {
arvif->u.ap.ssid_len = vif->cfg.ssid_len;
if (vif->cfg.ssid_len)
memcpy(arvif->u.ap.ssid, vif->cfg.ssid,
       vif->cfg.ssid_len);
arvif->u.ap.hidden_ssid = info->hidden_ssid;
}

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231024-strncpy-drivers-net-wireless-ath-ath10k-mac-c-v2-1-4c1f4cd4b4df@google.com
10 months agowifi: ath12k: drop NULL pointer check in ath12k_update_per_peer_tx_stats()
Ma Ke [Wed, 25 Oct 2023 17:47:56 +0000 (20:47 +0300)]
wifi: ath12k: drop NULL pointer check in ath12k_update_per_peer_tx_stats()

Since 'user_stats' is a fixed-size array of 'struct htt_ppdu_user_stats'
in 'struct htt_ppdu_stats', any of its member can't be NULL and so
relevant check may be dropped.

Signed-off-by: Ma Ke <make_ruc2021@163.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231013074711.2202850-1-make_ruc2021@163.com
11 months agowifi: ray_cs: Remove unnecessary (void*) conversions
Wu Yunchuan [Fri, 20 Oct 2023 09:34:31 +0000 (17:34 +0800)]
wifi: ray_cs: Remove unnecessary (void*) conversions

No need cast (void *) to (struct net_device *).

Signed-off-by: Wu Yunchuan <yunchuan@nfschina.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231020093432.214001-1-yunchuan@nfschina.com
11 months agoMerge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Kalle Valo [Wed, 25 Oct 2023 17:10:23 +0000 (20:10 +0300)]
Merge ath-next from git://git./linux/kernel/git/kvalo/ath.git

ath.git patches for v6.7.

Major changes:

ath12k

* QCN9274: mesh support

ath11k

* firmware-2.bin support

11 months agoRevert "wifi: ath11k: call ath11k_mac_fils_discovery() without condition"
Kalle Valo [Mon, 23 Oct 2023 16:41:20 +0000 (19:41 +0300)]
Revert "wifi: ath11k: call ath11k_mac_fils_discovery() without condition"

This reverts commit e149353e6562f3e3246f75dfc4cca6a0cc5b4efc. The commit caused
QCA6390 hw2.0 firmware WLAN.HST.1.0.1-05266-QCAHSTSWPLZ_V2_TO_X86-1 to crash
during disconnect:

[71990.787525] ath11k_pci 0000:72:00.0: firmware crashed: MHI_CB_EE_RDDM

Closes: https://lore.kernel.org/all/87edhu3550.fsf@kernel.org/
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20231023164120.651151-1-kvalo@kernel.org
11 months agowifi: ath12k: Introduce and use ath12k_sta_to_arsta()
Jeff Johnson [Thu, 19 Oct 2023 16:57:50 +0000 (09:57 -0700)]
wifi: ath12k: Introduce and use ath12k_sta_to_arsta()

Currently, the logic to return an ath12k_sta pointer, given a
ieee80211_sta pointer, uses typecasting throughout the driver. In
general, conversion functions are preferable to typecasting since
using a conversion function allows the compiler to validate the types
of both the input and output parameters.

ath12k already defines a conversion function ath12k_vif_to_arvif() for
a similar conversion. So introduce ath12k_sta_to_arsta() for this use
case, and convert all of the existing typecasting to use this
function.

Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019-upstream-ath12k_sta_to_arsta-v1-1-06f06f693338@quicinc.com
11 months agowifi: ath12k: fix htt mlo-offset event locking
Johan Hovold [Thu, 19 Oct 2023 11:36:50 +0000 (13:36 +0200)]
wifi: ath12k: fix htt mlo-offset event locking

The ath12k active pdevs are protected by RCU but the htt mlo-offset
event handling code calling ath12k_mac_get_ar_by_pdev_id() was not
marked as a read-side critical section.

Mark the code in question as an RCU read-side critical section to avoid
any potential use-after-free issues.

Compile tested only.

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Cc: stable@vger.kernel.org # v6.2
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019113650.9060-3-johan+linaro@kernel.org
11 months agowifi: ath12k: fix dfs-radar and temperature event locking
Johan Hovold [Thu, 19 Oct 2023 11:36:49 +0000 (13:36 +0200)]
wifi: ath12k: fix dfs-radar and temperature event locking

The ath12k active pdevs are protected by RCU but the DFS-radar and
temperature event handling code calling ath12k_mac_get_ar_by_pdev_id()
was not marked as a read-side critical section.

Mark the code in question as RCU read-side critical sections to avoid
any potential use-after-free issues.

Note that the temperature event handler looks like a place holder
currently but would still trigger an RCU lockdep splat.

Compile tested only.

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Cc: stable@vger.kernel.org # v6.2
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019113650.9060-2-johan+linaro@kernel.org
11 months agowifi: ath11k: fix gtk offload status event locking
Johan Hovold [Thu, 19 Oct 2023 15:53:42 +0000 (17:53 +0200)]
wifi: ath11k: fix gtk offload status event locking

The ath11k active pdevs are protected by RCU but the gtk offload status
event handling code calling ath11k_mac_get_arvif_by_vdev_id() was not
marked as a read-side critical section.

Mark the code in question as an RCU read-side critical section to avoid
any potential use-after-free issues.

Compile tested only.

Fixes: a16d9b50cfba ("ath11k: support GTK rekey offload")
Cc: stable@vger.kernel.org # 5.18
Cc: Carl Huang <quic_cjhuang@quicinc.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019155342.31631-1-johan+linaro@kernel.org
11 months agowifi: ath11k: fix htt pktlog locking
Johan Hovold [Thu, 19 Oct 2023 11:25:21 +0000 (13:25 +0200)]
wifi: ath11k: fix htt pktlog locking

The ath11k active pdevs are protected by RCU but the htt pktlog handling
code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a
read-side critical section.

Mark the code in question as an RCU read-side critical section to avoid
any potential use-after-free issues.

Compile tested only.

Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Cc: stable@vger.kernel.org # 5.6
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019112521.2071-1-johan+linaro@kernel.org
11 months agowifi: ath11k: fix dfs radar event locking
Johan Hovold [Thu, 19 Oct 2023 15:31:15 +0000 (17:31 +0200)]
wifi: ath11k: fix dfs radar event locking

The ath11k active pdevs are protected by RCU but the DFS radar event
handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a
read-side critical section.

Mark the code in question as an RCU read-side critical section to avoid
any potential use-after-free issues.

Compile tested only.

Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Cc: stable@vger.kernel.org # 5.6
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019153115.26401-3-johan+linaro@kernel.org
11 months agowifi: ath11k: fix temperature event locking
Johan Hovold [Thu, 19 Oct 2023 15:31:14 +0000 (17:31 +0200)]
wifi: ath11k: fix temperature event locking

The ath11k active pdevs are protected by RCU but the temperature event
handling code calling ath11k_mac_get_ar_by_pdev_id() was not marked as a
read-side critical section as reported by RCU lockdep:

=============================
WARNING: suspicious RCU usage
6.6.0-rc6 #7 Not tainted
-----------------------------
drivers/net/wireless/ath/ath11k/mac.c:638 suspicious rcu_dereference_check() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
no locks held by swapper/0/0.
...
Call trace:
...
 lockdep_rcu_suspicious+0x16c/0x22c
 ath11k_mac_get_ar_by_pdev_id+0x194/0x1b0 [ath11k]
 ath11k_wmi_tlv_op_rx+0xa84/0x2c1c [ath11k]
 ath11k_htc_rx_completion_handler+0x388/0x510 [ath11k]

Mark the code in question as an RCU read-side critical section to avoid
any potential use-after-free issues.

Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23

Fixes: a41d10348b01 ("ath11k: add thermal sensor device support")
Cc: stable@vger.kernel.org # 5.7
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231019153115.26401-2-johan+linaro@kernel.org
11 months agowifi: ath12k: rename the sc naming convention to ab
Karthikeyan Periyasamy [Wed, 18 Oct 2023 15:30:08 +0000 (21:00 +0530)]
wifi: ath12k: rename the sc naming convention to ab

In PCI and HAL interface layer module, the identifier sc is used
to represent an instance of ath12k_base structure. However,
within ath12k, the convention is to use "ab" to represent an SoC
"base" struct. So change the all instances of sc to ab.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00125-QCAHKSWPL_SILICONZ-1

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231018153008.29820-3-quic_periyasa@quicinc.com
11 months agowifi: ath12k: rename the wmi_sc naming convention to wmi_ab
Karthikeyan Periyasamy [Wed, 18 Oct 2023 15:30:07 +0000 (21:00 +0530)]
wifi: ath12k: rename the wmi_sc naming convention to wmi_ab

In WMI layer module, the identifier wmi_sc is used to represent
an instance of ath12k_wmi_base structure. However, within ath12k,
the convention is to use "ab" to represent an SoC "base" struct.
So change the all instances of wmi_sc to wmi_ab.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00125-QCAHKSWPL_SILICONZ-1

Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231018153008.29820-2-quic_periyasa@quicinc.com
11 months agowifi: ath11k: add firmware-2.bin support
Anilkumar Kolli [Wed, 18 Oct 2023 08:37:06 +0000 (11:37 +0300)]
wifi: ath11k: add firmware-2.bin support

Firmware IE containers can dynamically provide various information
what firmware supports. Also it can embed more than one image so
updating firmware is easy, user just needs to update one file in
/lib/firmware/.

The firmware API 2 or higher will use the IE container format, the
current API 1 will not use the new format but it still is supported
for some time. Firmware API 2 files are named as firmware-2.bin
(which contains both amss.bin and m3.bin images) and API 1 files are
amss.bin and m3.bin.

Currently ath11k PCI driver provides firmware binary (amss.bin) path to
MHI driver, MHI driver reads firmware from filesystem and boots it. Add
provision to read firmware files from ath11k driver and provide the amss.bin
firmware data and size to MHI using a pointer.

Currently enum ath11k_fw_features is empty, the patches adding features will
add the flags.

With AHB devices there's no amss.bin or m3.bin, so no changes in how AHB
firmware files are used. But AHB devices can use future additions to the meta
data, for example in enum ath11k_fw_features.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9

Co-developed-by: P Praneesh <quic_ppranees@quicinc.com>
Signed-off-by: P Praneesh <quic_ppranees@quicinc.com>
Signed-off-by: Anilkumar Kolli <quic_akolli@quicinc.com>
Co-developed-by: Kalle Valo <quic_kvalo@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230727100430.3603551-4-kvalo@kernel.org
11 months agowifi: ath11k: qmi: refactor ath11k_qmi_m3_load()
Kalle Valo [Wed, 18 Oct 2023 08:37:06 +0000 (11:37 +0300)]
wifi: ath11k: qmi: refactor ath11k_qmi_m3_load()

Simple refactoring to make it easier to add firmware-2.bin support in the
following patch.

Earlier ath11k_qmi_m3_load() supported changing m3.bin contents while ath11k is
running. But that's not going to actually work, m3.bin is supposed to be the
same during the lifetime of ath11k, for example we don't support changing the
firmware capabilities on the fly. Due to this ath11k requests m3.bin firmware
file first and only then checks m3_mem->vaddr, so we are basically requesting
the firmware file even if it's not needed. Reverse the code so that m3_mem
buffer is checked first, and only if it doesn't exist, then m3.bin is requested
from user space.

Checking for m3_mem->size is redundant when m3_mem->vaddr is NULL, we would
not be able to use the buffer in that case. So remove the check for size.

Simplify the exit handling and use 'goto out'.

Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230727100430.3603551-3-kvalo@kernel.org
11 months agowifi: rtw89: cleanup firmware elements parsing
Dmitry Antipov [Fri, 20 Oct 2023 04:09:36 +0000 (07:09 +0300)]
wifi: rtw89: cleanup firmware elements parsing

When compiling with clang-18, I've noticed the following:

drivers/net/wireless/realtek/rtw89/fw.c:389:28: warning: cast to smaller
integer type 'enum rtw89_fw_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
  389 |         enum rtw89_fw_type type = (enum rtw89_fw_type)data;
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw89/fw.c:569:13: warning: cast to smaller
integer type 'enum rtw89_rf_path' from 'const void *' [-Wvoid-pointer-to-enum-cast]
  569 |                 rf_path = (enum rtw89_rf_path)data;
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~

So avoid brutal everything-to-const-void-and-back casts, introduce
'union rtw89_fw_element_arg' to pass parameters to element handler
callbacks, and adjust all of the related bits accordingly. Compile
tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231020040940.33154-1-dmantipov@yandex.ru
11 months agowifi: rt2x00: rework MT7620 PA/LNA RF calibration
Shiji Yang [Thu, 19 Oct 2023 11:58:58 +0000 (19:58 +0800)]
wifi: rt2x00: rework MT7620 PA/LNA RF calibration

1. Move MT7620 PA/LNA calibration code to dedicated functions.
2. For external PA/LNA devices, restore RF and BBP registers before
   R-Calibration.
3. Do Rx DCOC calibration again before RXIQ calibration.
4. Add some missing LNA related registers' initialization.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB0315979F92DC563019B8F238BCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
11 months agowifi: rt2x00: rework MT7620 channel config function
Shiji Yang [Thu, 19 Oct 2023 11:58:57 +0000 (19:58 +0800)]
wifi: rt2x00: rework MT7620 channel config function

1. Move the channel configuration code from rt2800_vco_calibration()
   to the rt2800_config_channel().
2. Use MT7620 SoC specific AGC initial LNA value instead of the
   RT5592's value.
3. BBP{195,196} pairing write has been replaced with
   rt2800_bbp_glrt_write() to reduce redundant code.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB0315622A4340BFFA530B1B86BCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
11 months agowifi: rt2x00: improve MT7620 register initialization
Shiji Yang [Thu, 19 Oct 2023 11:58:56 +0000 (19:58 +0800)]
wifi: rt2x00: improve MT7620 register initialization

1. Do not hard reset the BBP. We can use soft reset instead. This
   change has some help to the calibration failure issue.
2. Enable falling back to legacy rate from the HT/RTS rate by
   setting the HT_FBK_TO_LEGACY register.
3. Implement MCS rate specific maximum PSDU size. It can improve
   the transmission quality under the low RSSI condition.
4. Set BBP_84 register value to 0x19. This is used for extension
   channel overlapping IOT.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB031553CCD4B7A3B89C85935DBCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
11 months agoMAINTAINERS: wifi: rt2x00: drop Helmut Schaa
Stanislaw Gruszka [Thu, 19 Oct 2023 20:26:51 +0000 (22:26 +0200)]
MAINTAINERS: wifi: rt2x00: drop Helmut Schaa

Helmut hasn't been responding to rt2x00 related emails since 2016,
remove him from rt2x00 mainterner list.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231019202651.518136-1-stf_xl@wp.pl
11 months agowifi: wlcore: main: replace deprecated strncpy with strscpy
Justin Stitt [Wed, 18 Oct 2023 21:50:01 +0000 (21:50 +0000)]
wifi: wlcore: main: replace deprecated strncpy with strscpy

strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

We expect fw_version strings to be NUL-terminated based on other similar
assignments:

wireless/broadcom/brcm80211/brcmsmac/main.c
7867:           snprintf(wlc->wiphy->fw_version,
7868:                    sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch);

wireless/broadcom/b43legacy/main.c
1765:   snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u",

wireless/broadcom/b43/main.c
2730:   snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u",

wireless/intel/iwlwifi/dvm/main.c
1465:   snprintf(priv->hw->wiphy->fw_version,
1466:            sizeof(priv->hw->wiphy->fw_version),

wireless/intel/ipw2x00/ipw2100.c
5905:   snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",

Based on this, NUL-padding is not required.

A suitable replacement is `strscpy` [2] due to the fact that it
guarantees NUL-termination on the destination buffer without
unnecessarily NUL-padding.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231018-strncpy-drivers-net-wireless-ti-wlcore-main-c-v1-1-1b1055f482a1@google.com
11 months agowifi: wlcore: boot: replace deprecated strncpy with strscpy
Justin Stitt [Wed, 18 Oct 2023 21:36:56 +0000 (21:36 +0000)]
wifi: wlcore: boot: replace deprecated strncpy with strscpy

strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

We expect wl->chip.fw_ver_str to be NUL-terminated based on its usage
with DRIVER_STATE_PRINT_STR() in debugfs.c:
491 | DRIVER_STATE_PRINT_STR(chip.fw_ver_str);
... which uses DRIVER_STATE_PRINT():
444 | #define DRIVER_STATE_PRINT_STR(x)  DRIVER_STATE_PRINT(x, "%s")
... which relies on scnprintf:
434 | #define DRIVER_STATE_PRINT(x, fmt)   \
435 |  (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
436 |    #x " = " fmt "\n", wl->x))

Moreover, NUL-padding is not required.

Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Similar-to: https://lore.kernel.org/all/20231018-strncpy-drivers-net-wireless-ti-wl18xx-main-c-v2-1-ab828a491ce5@google.com/
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231018-strncpy-drivers-net-wireless-ti-wlcore-boot-c-v1-1-d3c6cc6b80fe@google.com
11 months agowifi: wl18xx: replace deprecated strncpy with strscpy
Justin Stitt [Wed, 18 Oct 2023 21:18:24 +0000 (21:18 +0000)]
wifi: wl18xx: replace deprecated strncpy with strscpy

strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

wl->chip.phy_fw_ver_str is obviously intended to be NUL-terminated by
the deliberate comment telling us as much. Furthermore, its only use is
drivers/net/wireless/ti/wlcore/debugfs.c shows us it should be
NUL-terminated since its used in scnprintf:
492 | DRIVER_STATE_PRINT_STR(chip.phy_fw_ver_str);
which is defined as:
| #define DRIVER_STATE_PRINT_STR(x)  DRIVER_STATE_PRINT(x, "%s")
...
| #define DRIVER_STATE_PRINT(x, fmt)   \
|  (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\
|    #x " = " fmt "\n", wl->x))

We can also see that NUL-padding is not required.

Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

The very fact that a plain-english comment had to be made alongside a
manual NUL-byte assignment for such a simple purpose shows why strncpy
is faulty. It has non-obvious behavior that has to be clarified every
time it is used (and if it isn't then the reader suffers).

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231018-strncpy-drivers-net-wireless-ti-wl18xx-main-c-v2-1-ab828a491ce5@google.com
11 months agowifi: wl1251: replace deprecated strncpy with strscpy
Justin Stitt [Wed, 18 Oct 2023 21:15:23 +0000 (21:15 +0000)]
wifi: wl1251: replace deprecated strncpy with strscpy

strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

Based on other assignments of similar fw_version fields we can see that
NUL-termination is required but not NUL-padding:
ethernet/intel/ixgbe/ixgbe_ethtool.c
1111:   strscpy(drvinfo->fw_version, adapter->eeprom_id,
1112:           sizeof(drvinfo->fw_version));

ethernet/intel/igc/igc_ethtool.c
147:    scnprintf(adapter->fw_version,
148:              sizeof(adapter->fw_version),
153:    strscpy(drvinfo->fw_version, adapter->fw_version,
154:            sizeof(drvinfo->fw_version));

wireless/broadcom/brcm80211/brcmfmac/core.c
569:    strscpy(info->fw_version, drvr->fwver, sizeof(info->fw_version));

wireless/broadcom/brcm80211/brcmsmac/main.c
7867:           snprintf(wlc->wiphy->fw_version,
7868:                    sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch);

wireless/broadcom/b43legacy/main.c
1765:   snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u",

wireless/broadcom/b43/main.c
2730:   snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "%u.%u",

wireless/intel/iwlwifi/dvm/main.c
1465:   snprintf(priv->hw->wiphy->fw_version,
1466:            sizeof(priv->hw->wiphy->fw_version),

wireless/intel/ipw2x00/ipw2100.c
5905:   snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",

A suitable replacement is `strscpy` due to the fact that it guarantees
NUL-termination on the destination buffer without unnecessarily
NUL-padding.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231018-strncpy-drivers-net-wireless-ti-wl1251-main-c-v2-1-67b63dfcb1b8@google.com
11 months agowifi: mt76: mt7921: fix kernel panic by accessing invalid 6GHz channel info
Ming Yen Hsieh [Wed, 18 Oct 2023 04:29:35 +0000 (12:29 +0800)]
wifi: mt76: mt7921: fix kernel panic by accessing invalid 6GHz channel info

When the chip not support 6GHz capability, the channels of 6GHz information
should not be updated. This caused a crash:

[   19.442078] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000014
[   19.457535] Mem abort info:
[   19.465329]   ESR = 0x0000000096000004
[   19.473295]   EC = 0x25: DABT (current EL), IL = 32 bits
[   19.482354]   SET = 0, FnV = 0
[   19.489143]   EA = 0, S1PTW = 0
[   19.495991]   FSC = 0x04: level 0 translation fault
[   19.504554] Data abort info:
[   19.511111]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[   19.520269]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[   19.528988]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[   19.537960] user pgtable: 4k pages, 48-bit VAs, pgdp=00000001027a9000
[   19.548014] [0000000000000014] pgd=0000000000000000, p4d=000000000000
[   19.558429] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
[   19.568270] Modules linked in: mt7921e mt7921_common mt792x_lib
mt76_connac_lib mt76 mac80211 btusb btintel cfg80211 btmtk snd_sof_ipc_msg_
btrtl snd_sof_ipc_flood_test btbcm bluetooth snd_sof_mt8195 uvcvideo
mtk_adsp_common snd_sof_xtensa_dsp uvc snd_sof_of snd_sof videobuf2_vmalloc
ecdh_generic ecc snd_sof_utils cros_ec_lid_angle cros_ec_sensors crct10dif_
cros_ec_sensors_core cros_usbpd_logger crypto_user fuse ip_tables ipv6
[   19.614237] CPU: 1 PID: 105 Comm: kworker/1:1 Not tainted 6.6.0-rc6-next-20231017+ #324
[   19.625957] Hardware name: Acer Tomato (rev2) board (DT)
[   19.634970] Workqueue: events mt7921_init_work [mt7921_common]
[   19.644522] pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTY
[   19.655182] pc : mt7921_regd_notifier+0x180/0x290 [mt7921_common]
[   19.664983] lr : mt7921_regd_notifier+0xd4/0x290 [mt7921_common]
[   19.674679] sp : ffff800080acba80
[   19.681649] x29: ffff800080acba80 x28: 0000000000000000 x27: ffff4faf
[   19.692483] x26: 0000000000000000 x25: 0000000000000000 x24: ffff4faf
[   19.703294] x23: 00000000ffffe926 x22: ffff4faf16031fa0 x21: 00000000
[   19.714108] x20: 000000000000001c x19: ffff4faf16ba6f40 x18: 00000000
[   19.724928] x17: 0000000000000000 x16: ffffac6b891c2750 x15: ffff8000
[   19.735722] x14: 0000000000000180 x13: 0000000000000000 x12: 00000000
[   19.746478] x11: 0000000000000002 x10: ffff4faf01c21780 x9 : ffffac6b
[   19.757214] x8 : 00000000006c0000 x7 : ffffac6b6b020cf0 x6 : ffffac6b
[   19.767945] x5 : ffffac6b6b020d00 x4 : ffffac6b6b020cf8 x3 : ffff4faf
[   19.778648] x2 : 0000000000000000 x1 : 000000000000001c x0 : 00000000
[   19.789366] Call trace:
[   19.795381]  mt7921_regd_notifier+0x180/0x290 [mt7921_common]
[   19.804675]  wiphy_update_regulatory+0x2bc/0xa08 [cfg80211]
[   19.813864]  wiphy_regulatory_register+0x4c/0x88 [cfg80211]
[   19.823029]  wiphy_register+0x75c/0x8d0 [cfg80211]
[   19.831446]  ieee80211_register_hw+0x70c/0xc10 [mac80211]
[   19.840479]  mt76_register_device+0x168/0x2e8 [mt76]
[   19.849008]  mt7921_init_work+0xdc/0x250 [mt7921_common]
[   19.857817]  process_one_work+0x148/0x3c0
[   19.865292]  worker_thread+0x32c/0x450
[   19.872489]  kthread+0x11c/0x128
[   19.879173]  ret_from_fork+0x10/0x20
[   19.886153] Code: f0000041 9100a021 94000aef aa0003f9 (b9401780)
[   19.895634] ---[ end trace 0000000000000000 ]---

Reported-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Closes: https://lore.kernel.org/all/927e7d50-826d-4c92-9931-3c59b18c6945@collabora.com/
Fixes: 09382d8f8641 ("wifi: mt76: mt7921: update the channel usage when the regd domain changed")
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/cf77a58a60d81c77a28388bc8d312b87ffb48434.1697603002.git.deren.wu@mediatek.com
11 months agowifi: ipw2x00: replace deprecated strncpy with strscpy_pad
Justin Stitt [Tue, 17 Oct 2023 21:48:15 +0000 (21:48 +0000)]
wifi: ipw2x00: replace deprecated strncpy with strscpy_pad

strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

`extra` is intended to be NUL-terminated which is evident by the manual
assignment of a NUL-byte as well as its immediate usage with strlen().

Moreover, many of these getters and setters are NUL-padding buffers with
memset():
2439  | memset(&tx_power, 0, sizeof(tx_power));
9998  | memset(sys_config, 0, sizeof(struct ipw_sys_config));
10084 | memset(tfd, 0, sizeof(*tfd));
10261 | memset(&dummystats, 0, sizeof(dummystats));
... let's maintain this behavior and NUL-pad our destination buffer.

Considering the above, a suitable replacement is `strscpy_pad` due to
the fact that it guarantees both NUL-termination and NUL-padding on the
destination buffer.

To be clear, there is no bug in the current implementation as
MAX_WX_STRING is much larger than the size of the string literals being
copied from. Also, strncpy() does NUL-pad the destination buffer and
using strscpy_pad() simply matches that behavior. All in all, there
should be no functional change but we are one step closer to eliminating
usage of strncpy().

Do note that we cannot use the more idiomatic strscpy invocation of
(dest, src, sizeof(dest)) as the destination buffer cannot have its size
determined at compile time. So, let's stick with (dest, src, LEN).

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231017-strncpy-drivers-net-wireless-intel-ipw2x00-ipw2200-c-v2-1-465e10dc817c@google.com
11 months agowifi: rt2x00: fix rt2800 watchdog function
Shiji Yang [Sat, 14 Oct 2023 06:55:01 +0000 (14:55 +0800)]
wifi: rt2x00: fix rt2800 watchdog function

The watchdog function is broken on rt2800 series SoCs. This patch
fixes the incorrect watchdog logic to make it work again.

1. Update current wdt queue index if it's not equal to the previous
   index. Watchdog compares the current and previous queue index to
   judge if the queue hung.
2. Make sure hung_{rx,tx} 'true' status won't be override by the
   normal queue. Any queue hangs should trigger a reset action.
3. Clear the watchdog counter of all queues before resetting the
   hardware. This change may help to avoid the reset loop.
4. Change hang check function return type to bool as we only need
   to return two status, yes or no.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB0315BC1D83D31154924F0D39BCD1A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
11 months agowifi: ath9k_htc: fix format-truncation warning
Kalle Valo [Thu, 12 Oct 2023 13:58:54 +0000 (16:58 +0300)]
wifi: ath9k_htc: fix format-truncation warning

On v6.6-rc4 with GCC 13.2 I see:

drivers/net/wireless/ath/ath9k/hif_usb.c:1223:42: warning: '.0.fw' directive output may be truncated writing 5 bytes into a region of size between 4 and 11 [-Wformat-truncation=]
drivers/net/wireless/ath/ath9k/hif_usb.c:1222:17: note: 'snprintf' output between 27 and 34 bytes into a destination of size 32

Fix it by increasing the size of the fw_name field to 64 bytes.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231012135854.3473332-3-kvalo@kernel.org
11 months agowifi: ipw2x00: fix format-truncation warnings
Kalle Valo [Thu, 12 Oct 2023 13:58:53 +0000 (16:58 +0300)]
wifi: ipw2x00: fix format-truncation warnings

On v6.6-rc4 with GCC 13.2 I see:

drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: 'snprintf' output between 4 and 140 bytes into a destination of size 32
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: 'snprintf' output between 4 and 98 bytes into a destination of size 32

Fix this by copying only the firmware version and not providing any extra
information via ethtool. This is an ancient driver anyway and most likely
removed soon so it doesn't really matter.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231012135854.3473332-2-kvalo@kernel.org
11 months agowifi: brcmfmac: fix format-truncation warnings
Kalle Valo [Thu, 12 Oct 2023 13:58:52 +0000 (16:58 +0300)]
wifi: brcmfmac: fix format-truncation warnings

On v6.6-rc4 with GCC 13.2 I see:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:52: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:46: note: directive argument in the range [0, 65535]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:262:9: note: 'snprintf' output between 9 and 17 bytes into a destination of size 9
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:55: warning: '%d' directive output may be truncated writing between 1 and 5 bytes into a region of size 4 [-Wformat-truncation=]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:48: note: directive argument in the range [0, 65535]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:265:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:50: warning: '/' directive output may be truncated writing 1 byte into a region of size between 0 and 4 [-Wformat-truncation=]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:42: note: directive argument in the range [0, 65535]
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c:342:9: note: 'snprintf' output between 10 and 18 bytes into a destination of size 10

Fix these by increasing the buffer sizes to 20 bytes to make sure there's enough space.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231012135854.3473332-1-kvalo@kernel.org
11 months agowifi: mac80211: drop robust action frames before assoc
Johannes Berg [Sun, 1 Oct 2023 10:01:09 +0000 (13:01 +0300)]
wifi: mac80211: drop robust action frames before assoc

To be able to more easily understand the code, drop robust
action frames before being associated, even if there's no
MFP in the end, as they are Class 3 Frames and shouldn't
be transmitted in the first place.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231001125722.b2fd37083371.Ie9f4906e2f6c698989bce6681956ed2f9454f27c@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient
Vinayak Yadawad [Tue, 26 Sep 2023 10:32:22 +0000 (16:02 +0530)]
wifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient

In 4way handshake offload, cfg80211_port_authorized enables driver
to indicate successful 4way handshake to cfg80211 layer. Currently
this path of port authorization is restricted to interface type
NL80211_IFTYPE_STATION and NL80211_IFTYPE_P2P_CLIENT. This patch
extends the support for NL80211_IFTYPE_AP and NL80211_IFTYPE_P2P_GO
interfaces to authorize peer STA/P2P_CLIENT, whenever authentication
is offloaded on the AP/P2P_GO interface.

Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
Link: https://lore.kernel.org/r/dee3b0a2b4f617e932c90bff4504a89389273632.1695721435.git.vinayak.yadawad@broadcom.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: drop NULL pointer check in iwl_mvm_tzone_set_trip_temp()
Dmitry Antipov [Tue, 3 Oct 2023 09:20:46 +0000 (12:20 +0300)]
wifi: iwlwifi: drop NULL pointer check in iwl_mvm_tzone_set_trip_temp()

Since 'tz_device' is an in-place member of 'struct iwl_mvm', it can't
be NULL and so relevant check may be dropped. Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231003092048.24998-1-dmantipov@yandex.ru
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: bump FW API to 86 for AX/BZ/SC devices
Gregory Greenman [Sun, 22 Oct 2023 14:55:56 +0000 (17:55 +0300)]
wifi: iwlwifi: bump FW API to 86 for AX/BZ/SC devices

Start supporting API version 86 for new devices.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.e2f720799600.I6e22188a47efe0cbb4e013259955c4019843799f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: read DSM func 2 for specific RF types
Daniel Gabay [Sun, 22 Oct 2023 14:55:55 +0000 (17:55 +0300)]
wifi: iwlwifi: read DSM func 2 for specific RF types

By definition, this DSM func is valid only for HR/JF RF types.
Until now firmware ignored this bit (if set) on other than the
above types, but in future firmware versions sending this bit
will lead to firmware 0x3426 assert.
Avoid that by verifying the HW in driver first.

Signed-off-by: Daniel Gabay <daniel.gabay@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.eec3b5d6152f.Ibc7ffe5ef1c156d878f1300c6059c6c91b374114@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: show dump even for pldr_sync
Johannes Berg [Sun, 22 Oct 2023 14:55:54 +0000 (17:55 +0300)]
wifi: iwlwifi: mvm: show dump even for pldr_sync

Worst case it's extra (garbage) data, best case we see why
things failed ... Seems the trade-off is better if we print
it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.30e614ecd540.I47324f555ebcf22d0dd0afa94e7ca0af53a9fdba@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: cycle FW link on chanctx removal
Johannes Berg [Sun, 22 Oct 2023 14:55:53 +0000 (17:55 +0300)]
wifi: iwlwifi: mvm: cycle FW link on chanctx removal

When the vif is in MLD mode, we'll get a vif links change from
non-zero to zero on disassociation, which removes all links in
the firmware and adds the 'deflink' the driver/mac80211 has.
This causes the firmware to clear some internal state.

However, in non-MLD mode, this doesn't happen, and causes some
state to be left around in firmware, which can particularly
cause trouble with the ref-BSSID in multi-BSSID, leading to an
assert later if immediately making a new multi-BSSID connection
with a different ref-BSSID.

Fix this by removing/re-adding the link in the non-MLD case
when the channel is removed from the vif. This way, all of the
state will get cleared out, even if we need the deflink, which
is more for software architecture purposes than otherwise.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.90c82837ba4d.I341fa30c480f7673b14b48a0e29a2241472c2e13@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: trace full frames with TX status request
Johannes Berg [Sun, 22 Oct 2023 14:55:52 +0000 (17:55 +0300)]
wifi: iwlwifi: trace full frames with TX status request

If upper layers requested a TX status, then the frames are
more important, so trace frames in that case.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.0dfb60a2eaec.I3c3e46ed0eb05700a4d05d293f80d727354a402f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: empty overflow queue during flush
Miri Korenblit [Sun, 22 Oct 2023 14:55:51 +0000 (17:55 +0300)]
wifi: iwlwifi: empty overflow queue during flush

If a TX queue has no space for new TX frames, the driver will keep
these frames in the overflow queue, and during reclaim flow it
will retry to send the frames from that queue.
But if the reclaim flow was invoked from TX queue flush, we will also
TX these frames, which is wrong as we don't want to TX anything
after flush.
This might also cause assert 0x125F when removing the queue,
saying that the driver removes a non-empty queue
Fix this by TXing the overflow queue's frames only if we are
not in flush queue flow.

Fixes: a44509805895 ("iwlwifi: move reclaim flows to the queue file")
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.caf06c8709d9.Ibf664ccb3f952e836f8fa461ea58fc08e5c46e88@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: fw: Add support for UATS table in UHB
Mukesh Sisodiya [Sun, 22 Oct 2023 14:55:50 +0000 (17:55 +0300)]
wifi: iwlwifi: fw: Add support for UATS table in UHB

Driver need to provide details of VLP, AFC
AP type supported for the specific MCC to firmware.
Driver will read the UATS (UHB AP type support) table
from BIOS and sent to firmware using UATS_TABLE_CMD.

Add the support for the same in the driver.

Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.eb6cf7be17b2.I8977a660564412056d9fd383d57b236cd4b22d00@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: add a print when sending RLC command
Miri Korenblit [Sun, 22 Oct 2023 14:55:49 +0000 (17:55 +0300)]
wifi: iwlwifi: mvm: add a print when sending RLC command

Expand RLC logging to simplify the debug.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.ec227229263f.Iea36e64d4092e04ad561beb87002c7bb8c52596f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: debugfs for fw system stats
Anjaneyulu [Sun, 22 Oct 2023 14:55:48 +0000 (17:55 +0300)]
wifi: iwlwifi: mvm: debugfs for fw system stats

Add debgufs handler for fw system statistics command.

Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.e77efee7cd85.I99f370f26f94f73e06aec2a8eaf21ebcc82f60a9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: implement new firmware API for statistics
Anjaneyulu [Sun, 22 Oct 2023 14:55:47 +0000 (17:55 +0300)]
wifi: iwlwifi: mvm: implement new firmware API for statistics

The new firmware API uses a new command and notification,
the command configures in which statistics types driver is
interested and the notification is sent periodically.
An additional change in the API is that most of the statistics
data is accumulated and reported by the firmware per MLO link.
Implement new command and notification handlers and adjust to
per-link statistics.

Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.8cc7df0ebff2.If1dcb57145841c5b3c68ed112bbfcd0201f7acc3@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: fix regdb initialization
Gregory Greenman [Tue, 17 Oct 2023 09:16:49 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: fix regdb initialization

In order to get regulatory domain, driver sends MCC_UPDATE_CMD to the
FW. One of the parameters in the response is the status which can tell
if the regdomain has changed or not.

When iwl_mvm_init_mcc() is called during iwl_op_mode_mvm_start(), then
sband is still NULL and channel parameters (i.e. chan->flags)  cannot be
initialized. When, further in the flow, iwl_mvm_update_mcc() is called
during iwl_mvm_up(), it first checks if the regdomain has changed and
then skips the update if it remains the same. But, since channel
parameters weren't initialized yet, the update should be forced in this
codepath. Fix that by adding a corresponding parameter to
iwl_mvm_init_fw_regd().

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.78b2c5b891b0.Iac49d52e0bfc0317372015607c63ea9276bbb188@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: update IGTK in mvmvif upon D3 resume
Yedidya Benshimol [Tue, 17 Oct 2023 09:16:48 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: update IGTK in mvmvif upon D3 resume

During the D3 resume flow, all new rekeys are passed from the FW.
Because the FW supports only one IGTK at a time, every IGTK rekey
update should be done by removing the last IGTK. The mvmvif holds a
pointer to the last IGTK for that reason and thus should be updated
when a new IGTK is passed upon resume.

Fixes: 04f78e242fff ("wifi: iwlwifi: mvm: Add support for IGTK in D3 resume flow")
Signed-off-by: Yedidya Benshimol <yedidya.ben.shimol@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.8ceaf7e5ece7.Ief444f6a2703ed76648b4d414f12bb4130bab36e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: simplify the reorder buffer
Emmanuel Grumbach [Tue, 17 Oct 2023 09:16:47 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: simplify the reorder buffer

The firmware / hardware of devices supporting RSS is able to report
duplicates and packets that time out inside the reoder buffer. We can
now remove all the complex logic that was implemented to keep all the Rx
queues more the less synchronized: we used to send a message to all the
queues through the firmware to teach the different queues about what is
the current SSN every 2048 packets.

Now that we rely on the firmware / hardware to detect duplicates, we can
completely remove the code that did that in the driver and it has been
reported that this code was spuriously dropping legit packets.

Suggested-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.54cf4d3d5956.Ic06a08c9fb1e1ec315a4b49d632b78b8474dab79@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: disable multi rx queue for 9000
Emmanuel Grumbach [Tue, 17 Oct 2023 09:16:46 +0000 (12:16 +0300)]
wifi: iwlwifi: disable multi rx queue for 9000

Multi rx queue allows to spread the load of the Rx streams on different
CPUs. 9000 series required complex synchronization mechanisms from the
driver side since the hardware / firmware is not able to provide
information about duplicate packets and timeouts inside the reordering
buffer.

Users have complained that for newer devices, all those synchronization
mechanisms have caused spurious packet drops. Those packet drops
disappeared if we simplify the code, but unfortunately, we can't have
RSS enabled on 9000 series without this complex code.

Remove support for RSS on 9000 so that we can make the code much simpler
for newer devices and fix the bugs for them.

The down side of this patch is a that all the Rx path will be routed to
a single CPU, but this has never been an issue, the modern CPUs are just
fast enough to cope with all the traffic.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.2917eb8b7af9.Iddd7dcf335387ba46fcbbb6067ef4ff9cd3755a7@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: Return success if link could not be removed
Benjamin Berg [Tue, 17 Oct 2023 09:16:45 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: Return success if link could not be removed

iwl_mvm_remove_link would return an error if the link could not be
removed. However, doing so prevents recovery if a link was not uploaded
to the FW in the first place and the link_info was not allocated or
fw_link_id is not set.

Returning success means that we can still try to continue with adding
new links in change_vif_links.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.f89bc05aadf6.Idc8fbd671362d962c02b1df87fa6258733631580@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: fix size check for fw_link_id
Gregory Greenman [Tue, 17 Oct 2023 09:16:44 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: fix size check for fw_link_id

Check that fw_link_id does not exceed the size of link_id_to_link_conf
array. There's no any codepath that can cause that, but it's still
safer to verify in case fw_link_id gets corrupted.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.3385bd11f423.I2d30fdb464f951c648217553c47901857a0046c7@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: pcie: synchronize IRQs before NAPI
Johannes Berg [Tue, 17 Oct 2023 09:16:43 +0000 (12:16 +0300)]
wifi: iwlwifi: pcie: synchronize IRQs before NAPI

When we want to synchronize the NAPI, which was added in
commit 5af2bb3168db ("wifi: iwlwifi: call napi_synchronize()
before freeing rx/tx queues"), we also need to make sure we
can't actually reschedule the NAPI. Yes, this happens while
interrupts are disabled, but interrupts may still be running
or pending. Also call iwl_pcie_synchronize_irqs() to ensure
we won't reschedule the NAPI.

Fixes: 4cf2f5904d97 ("iwlwifi: queue: avoid memory leak in reset flow")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.a0f4104b479a.Id5c50a944f709092aa6256e32d8c63b2b8d8d3ac@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: add support for SNPS DPHYIP region type
Daniel Gabay [Tue, 17 Oct 2023 09:16:42 +0000 (12:16 +0300)]
wifi: iwlwifi: add support for SNPS DPHYIP region type

Add the required logic for parsing and dumping this new region.

Signed-off-by: Daniel Gabay <daniel.gabay@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.c859539194e7.I965482de2871e28b09f4572f1aa87ae4e3b366be@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: fix netif csum flags
Johannes Berg [Tue, 17 Oct 2023 09:16:41 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: fix netif csum flags

We shouldn't advertise arbitrary checksum flags since we had
to remove support for it due to broken hardware.

Fixes: ec18e7d4d20d ("wifi: iwlwifi: mvm: use old checksum for Bz A-step")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.e37327f1a129.Iaee86b00db4db791cd90adaf15384b8c87d2ad49@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: remove set_tim callback for MLD ops
Johannes Berg [Tue, 17 Oct 2023 09:16:40 +0000 (12:16 +0300)]
wifi: iwlwifi: mvm: remove set_tim callback for MLD ops

In new firmware, we don't need this any more and it won't
be called any more by mac80211, since powersave handling
is all done by firmware. Remove it from the MLD ops.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.1a1ded96ffc2.Ie49d3004acdd6299fb84346c76b2b2b2f195196b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: api: fix center_freq label in PHY diagram
Johannes Berg [Tue, 17 Oct 2023 09:16:39 +0000 (12:16 +0300)]
wifi: iwlwifi: api: fix center_freq label in PHY diagram

Somehow I managed to put the EHT line in the wrong place and
also didn't indent the center_freq label correctly. Fix it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.08ac3cf524c0.I538f424e1ab30f73b0af8381224f377893e15526@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: support link id in SESSION_PROTECTION_NOTIF
Miri Korenblit [Tue, 17 Oct 2023 09:16:38 +0000 (12:16 +0300)]
wifi: iwlwifi: support link id in SESSION_PROTECTION_NOTIF

FW is introducing an API change in which link ID will be used
for session protection notif. Add support for it.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.4c59b149086e.I74fe93a6337f4ec9d1bd6f791d315411ac5b40da@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: support link_id in SESSION_PROTECTION cmd
Miri Korenblit [Tue, 17 Oct 2023 09:16:37 +0000 (12:16 +0300)]
wifi: iwlwifi: support link_id in SESSION_PROTECTION cmd

FW is introducing an API change in which link ID will be used
for session protection cmd. Add support for it.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.a3cb29ed0617.I85b8a85b0d9186d3dd4d704254e46775b0ccf7de@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: make time_events MLO aware
Miri Korenblit [Tue, 17 Oct 2023 09:16:36 +0000 (12:16 +0300)]
wifi: iwlwifi: make time_events MLO aware

As session protection API is moving to be per link instead of per mac,
move the time events to be per link too.

Since there is only one concurrent time event per mac, it feels
unnecessary to have the time_event as a member of iwl_mvm_link_info.
(That way we will have to iterate over all links each time we want to
clear a time event, and also we will need mac80211 to tell us the link
id when mgd_tx_complete() is called.)
So leave this as a member of iwl_mvm_vif, but add the link id to the
time_event structure.

The link id in time_event will only be maintained and used for:
1. When SESSION_PROTECTION_CMD is supported (before it, we don't have MLO)
2. For time_events of types SESSION_PROTECT_CONF_ASSOC,
   SESSION_PROTECT_CONF_P2P_DEVICE_DISCOV, and
   SESSION_PROTECT_CONF_P2P_GO_NEGOTIATION
   (not for aux roc/ Hot Spot time_events).

For P2P, non-MLO connections, and pre-MLD API, deflink id, meaning 0,
will be used

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231017115047.21496bcacb18.I79d037325b4fae4c12a22d9477e53fc9c537ad46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: mac80211: fix another key installation error path
Johannes Berg [Fri, 20 Oct 2023 07:38:28 +0000 (09:38 +0200)]
wifi: mac80211: fix another key installation error path

Due to overlapping changes and merges, another error
path ended up broken. Fix this one as well.

Reported-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: mac80211: rename struct cfg80211_rx_assoc_resp to cfg80211_rx_assoc_resp_data
Kalle Valo [Thu, 12 Oct 2023 11:42:29 +0000 (14:42 +0300)]
wifi: mac80211: rename struct cfg80211_rx_assoc_resp to cfg80211_rx_assoc_resp_data

make htmldocs warns:

Documentation/driver-api/80211/cfg80211:48: ./include/net/cfg80211.h:7290: WARNING: Duplicate C declaration, also defined at cfg80211:7251.
Declaration is '.. c:function:: void cfg80211_rx_assoc_resp (struct net_device *dev, struct cfg80211_rx_assoc_resp *data)'.

This is because there's a function named cfg80211_rx_assoc_resp() and a struct
named cfg80211_rx_assoc_resp, see previous patch for more info.

To workaround this rename the struct to cfg80211_rx_assoc_resp_data. The
parameter for the function is named 'data' anyway so the naming here is
consistent.

Compile tested only.

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231012114229.2931808-3-kvalo@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: mac80211: rename ieee80211_tx_status() to ieee80211_tx_status_skb()
Kalle Valo [Thu, 12 Oct 2023 11:42:28 +0000 (14:42 +0300)]
wifi: mac80211: rename ieee80211_tx_status() to ieee80211_tx_status_skb()

make htmldocs warns:

Documentation/driver-api/80211/mac80211:109: ./include/net/mac80211.h:5170: WARNING: Duplicate C declaration, also defined at mac80211:1117.
Declaration is '.. c:function:: void ieee80211_tx_status (struct ieee80211_hw *hw, struct sk_buff *skb)'.

This is because there's a function named ieee80211_tx_status() and a struct named
ieee80211_tx_status. This has been discussed previously but no solution found:

https://lore.kernel.org/all/20220521114629.6ee9fc06@coco.lan/

There's also a bug open for three years with no solution in sight:

https://github.com/sphinx-doc/sphinx/pull/8313

So I guess we have no other solution than to a workaround this in the code,
for example to rename the function to ieee80211_tx_status_skb() to avoid the
name conflict. I got the idea for the name from ieee80211_tx_status_noskb() in
which the skb is not provided as an argument, instead with
ieee80211_tx_status_skb() the skb is provided.

Compile tested only.

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20231012114229.2931808-2-kvalo@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: add support for activating UNII-1 in WW via BIOS
Miri Korenblit [Wed, 11 Oct 2023 10:07:31 +0000 (13:07 +0300)]
wifi: iwlwifi: add support for activating UNII-1 in WW via BIOS

There is a requirement from OEMs to support a new bit in DSM function 8,
which will indicate that this device is an indoor one, and that it
should activate UNII-1 (5.2GHz) sub band in the World Wide Geo Profile.
Add support for this by reading this bit from BIOS and sending it to the
FW.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.86d4ad178042.Ief40acc08b5482ff147fd17e74e36f1933e43def@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: remove TDLS stations from FW
Johannes Berg [Wed, 11 Oct 2023 10:07:30 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: remove TDLS stations from FW

When we remove TDLS stations, we need to remove them from FW
immediately, even while associated. Some previous refactoring
here lost the sta ID condition, add it back.

Fixes: 57974a55d995 ("wifi: iwlwifi: mvm: refactor iwl_mvm_mac_sta_state_common()")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.933011e710a9.I77c069c781e8b2b698b86cc3f43fc3c7e2dde114@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: fix iwl_mvm_mac_flush_sta()
Johannes Berg [Wed, 11 Oct 2023 10:07:29 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: fix iwl_mvm_mac_flush_sta()

When I implemented iwl_mvm_mac_flush_sta() I completely botched it;
it basically always happens after the iwl_mvm_sta_pre_rcu_remove()
call, and that already clears mvm->fw_id_to_mac_id[] entries, so we
cannot rely on those at iwl_mvm_mac_flush_sta() time. This means it
never did anything.

Fix this by just going through the station IDs and now with the new
API for iwl_mvm_flush_sta(), call those.

Fixes: a6cc6ccb1c8a ("wifi: iwlwifi: mvm: support new flush_sta method")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.0b5878e93118.I1093e60163052e7be64d2b01424097cd6a272979@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: change iwl_mvm_flush_sta() API
Johannes Berg [Wed, 11 Oct 2023 10:07:28 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: change iwl_mvm_flush_sta() API

This API is type unsafe and needs an extra parameter to know
what kind of station was passed, so it has two, but really it
only needs two values. Just pass the values instead of doing
this type-unsafe dance, which will also make it better to use
for multi-link.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.aeb3bf4204cd.I5b0e6d64a67455784bc8fbdaf9ceaf03699d9ce1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: extend alive timeout to 2 seconds
Haim Dreyfuss [Wed, 11 Oct 2023 10:07:27 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: extend alive timeout to 2 seconds

There are devices that need longer time to get the alive notification.

Signed-off-by: Haim Dreyfuss <haim.dreyfuss@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.f1f0aa1794e6.I34a06ef24b642a32af69c0bd109694de469d5177@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: fix the PHY context resolution for p2p device
Emmanuel Grumbach [Wed, 11 Oct 2023 10:07:26 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: fix the PHY context resolution for p2p device

We seem to have an issue in case we had a BSS and a P2P device on
channel 1 and then, the P2P device gets an ROC on channel 6. We would
change the channel of the PHY context to channel 6 even if the BSS was
using that same PHY context.

Revamp that code and don't try to change a PHY context, it doesn't mean
much for the firmware anyway. Just remove it and allocate a new one.
This makes the logic easier to follow.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.4bc8b90d7be0.I1232dca3fe007362ec0ae0cf1d96217f2544e0d2@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: fold the ref++ into iwl_mvm_phy_ctxt_add
Emmanuel Grumbach [Wed, 11 Oct 2023 10:07:25 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: fold the ref++ into iwl_mvm_phy_ctxt_add

When we want to add a phy_ctxt, we need to increase the ref.
Note that all the WARN_ONs are already in place:
* We check that we don't add a context with ref != 0
* We check that we don't modify a context with ref = 0

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.c19c07746b26.I5b0cbe0760811631a320218a10b88870b5bf0897@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: don't add dummy phy context
Emmanuel Grumbach [Wed, 11 Oct 2023 10:07:24 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: don't add dummy phy context

From its very first stages of development, iwlmvm added all the PHY
context immediately upon firmware boot. Then, all we needed to do is to
modify the contexts. This was fine if the addition of a PHY context that
we don't need is free. This was true until now. Newer devices will run
calibrations upon the addition of a PHY context.

Change the way we work with PHY context in iwlmvm. Fortunately, we
already have all the ref counting in place so that it is not very hard
to do.

Also, since we now remove the PHY context before the link is removed
(but after it has been de-activated of course), it'll confuse the
firmware if we put the late phy_id into the LINK command that removes
the link. Change this to put an invalid phy_id just like we do when we
add a link that has no PHY context yet.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.55a1a78719be.I2032a7d227b57f4fc4370a2793476d47538404fd@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: cleanup MLO and non-MLO unification code
Miri Korenblit [Wed, 11 Oct 2023 10:07:23 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: cleanup MLO and non-MLO unification code

bss_info_changed() callback of mac80211 was originally in both
MLD and non-MLD API. Therefore, we extracted the common part
to a function which receives a callback structure with the
mode-specific (non-MLO\MLO) ops. Eventually, for MLO API,
bss_info_changed() callback was split into 2 callbacks:
link_info_changed() and vif_cfg_changed() so it is no longer in use
for MLO, only for non-MLO.
Remove the code that uses the mode-specific callback structure.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.b65fbcdb9295.I2a64a6f1178ee0466755d728addc77acbb2ed6f4@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: implement ROC version 3
Shaul Triebitz [Wed, 11 Oct 2023 10:07:22 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: implement ROC version 3

Define the new API for ROC command and notification.
Use ROC version 3 command and notificaiton for hotspot.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.0cff02aecc16.If0a89ddc6b2339988ff51efa6709d4a883569969@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: send EDT table to FW
Alon Giladi [Wed, 11 Oct 2023 10:07:21 +0000 (13:07 +0300)]
wifi: iwlwifi: send EDT table to FW

Read the EDT (Energy detection threshold) optimization configuration
table from BIOS using DSM Function and send it to FW.

Signed-off-by: Alon Giladi <alon.giladi@intel.com>
Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.0b78ee48219a.I8ecbd39d258e2ee0514a7e28632f6c18fb798a83@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: Fix key flags for IGTK on AP interface
Ilan Peer [Wed, 11 Oct 2023 10:07:20 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: Fix key flags for IGTK on AP interface

When an IGTK is installed for an AP interface, there is no station
associated with it. However, the MFP flag must be set for the installed
key as otherwise the FW wouldn't use it.

Fix the security key flag to set the MFP flag also when the AP is
an AP interface and the key index matches that of an IGTK.

Fixes: 5c75a208c244 ("wifi: iwlwifi: mvm: support new key API")
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.f67005e2d4d2.I6832c6e87f3c79fff00689eb10a3a30810e1ee83@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlmvm: fw: Add new OEM vendor to tas approved list
Matt Chen [Wed, 11 Oct 2023 10:07:19 +0000 (13:07 +0300)]
wifi: iwlmvm: fw: Add new OEM vendor to tas approved list

Add new oem/odm pair to tas approved vendors list when specified by platform.

Signed-off-by: Matt Chen <matt.chen@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.a6f10aaae473.I65c3321535674bbc08d96200961a78fab5e7a09f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: Fix unreachable code path
Ilan Peer [Wed, 11 Oct 2023 10:07:18 +0000 (13:07 +0300)]
wifi: iwlwifi: mvm: Fix unreachable code path

Fix unreachable code path that was introduced in the P2P Device
linking refactoring.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.39d76eeea781.I2dc1fc6152a2cd4cf68827f4d3bf83e2293d3dfb@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: add new RF support for wifi7
Mukesh Sisodiya [Wed, 11 Oct 2023 10:07:17 +0000 (13:07 +0300)]
wifi: iwlwifi: add new RF support for wifi7

Add the support for new RF based on step-id.

Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231011130030.d902aa8cfd1b.I7c7b357ba41c00015d6c6255b45b3d17549948f0@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: fw: increase fw_version string size
Gregory Greenman [Thu, 12 Oct 2023 12:41:48 +0000 (15:41 +0300)]
wifi: iwlwifi: fw: increase fw_version string size

In reality 64 bytes are enough to hold fw version string,
but some compilers can complain (with W=1) that output may be
truncated when building this string with snprintf.
Increase the size to avoid this sort of warnings and state
explicitely that we want the size to be trancated to 32 bytes.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Tested-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231012153950.f4465b4b4e2b.Idced2e8d63c492872edcde1a3ce2cdd6cc0f8eb7@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: mac80211: fix change_address deadlock during unregister
Johannes Berg [Thu, 12 Oct 2023 10:34:47 +0000 (12:34 +0200)]
wifi: mac80211: fix change_address deadlock during unregister

When using e.g. bonding, and doing a sequence such as

 # iw wlan0 set type __ap
 # ip link add name bond1 type bond
 # ip link set wlan0 master bond1
 # iw wlan0 interface del

we deadlock, since the wlan0 interface removal will cause
bonding to reset the MAC address of wlan0.

The locking would be somewhat difficult to fix, but since
this only happens during removal, we can simply ignore the
MAC address change at this time.

Reported-by: syzbot+25b3a0b24216651bc2af@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20231012123447.9f9d7fd1f237.Ic3a5ef4391b670941a69cec5592aefc79d9c2890@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: mac80211: Add __counted_by for struct ieee802_11_elems and use struct_size()
Gustavo A. R. Silva [Mon, 9 Oct 2023 17:59:41 +0000 (11:59 -0600)]
wifi: mac80211: Add __counted_by for struct ieee802_11_elems and use struct_size()

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

While there, use struct_size() helper, instead of the open-coded
version, to calculate the size for the allocation of the whole
flexible structure including, of course, the flexible-array member.

This code was found with the help of Coccinelle, and audited and
fixed manually.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/ZSQ/jcmTAf/PKHg/@work
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: check for kmemdup() return value in iwl_parse_tlv_firmware()
Dmitry Antipov [Mon, 9 Oct 2023 17:04:49 +0000 (20:04 +0300)]
wifi: iwlwifi: check for kmemdup() return value in iwl_parse_tlv_firmware()

In 'iwl_parse_tlv_firmware()', check for 'kmemdup()' return value
when handling IWL_UCODE_TLV_CURRENT_PC and set the number of parsed
entries only if an allocation was successful (just like it does with
handling IWL_UCODE_TLV_CMD_VERSIONS above). Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231009170453.149905-1-dmantipov@yandex.ru
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: remove unused argument of ieee80211_get_tdls_action()
Dmitry Antipov [Wed, 4 Oct 2023 15:30:29 +0000 (18:30 +0300)]
wifi: remove unused argument of ieee80211_get_tdls_action()

Remove unused 'hdr_size' argument of 'ieee80211_get_tdls_action()'
and adjust 'ieee80211_report_used_skb()' accordingly.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20231004153032.206134-1-dmantipov@yandex.ru
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
11 months agowifi: iwlwifi: mvm: Correctly set link configuration
Ilan Peer [Wed, 4 Oct 2023 09:36:34 +0000 (12:36 +0300)]
wifi: iwlwifi: mvm: Correctly set link configuration

In case the link puncturing is changed such that the channel
is no longer punctured, configure the FW correctly indicating
the EHT parameters changed (with a 0 punctured map).

Allow EHT parameters configuration only when the link really
supports EHT.

Fixes: 55eb1c5fa4b2 ("wifi: iwlwifi: mvm: add support for the new LINK command")
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231004123422.2666ef86e032.I4b0e95722660acc5345ceefba7e8866a69572e8e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>