* [PATCH 1/8] wifi: ath12k: eliminate redundant debug mask check in ath12k_dbg()
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:35 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 2/8] wifi: ath12k: introduce ath12k_generic_dbg() Aditya Kumar Singh
` (7 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
The current implementation includes a debug mask check both in the macro
expansion and in the function __ath12k_dbg(), which is unnecessary.
Simplify the code by removing the redundant check from the helper function
__ath12k_dbg().
While at this, rename the first argument in macro from ar to ab since the
first argument name in the function __ath12k_dbg() is ab.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/debug.c | 5 ++---
drivers/net/wireless/ath/ath12k/debug.h | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/debug.c b/drivers/net/wireless/ath/ath12k/debug.c
index ff6eaeafa092cd12e572430ed0f1c7aa21b78377..fd9796b5ad3b9feea5c7e78e8a88d361049e08df 100644
--- a/drivers/net/wireless/ath/ath12k/debug.c
+++ b/drivers/net/wireless/ath/ath12k/debug.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/vmalloc.h>
@@ -63,8 +63,7 @@ void __ath12k_dbg(struct ath12k_base *ab, enum ath12k_debug_mask mask,
vaf.fmt = fmt;
vaf.va = &args;
- if (ath12k_debug_mask & mask)
- dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
+ dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
/* TODO: trace log */
diff --git a/drivers/net/wireless/ath/ath12k/debug.h b/drivers/net/wireless/ath/ath12k/debug.h
index 0aa7c8ccb14ccb9de28a78ca3d2b2a7bf6e481c1..ba0e4da3bb761a49fb81e3efcb61557df8ad1942 100644
--- a/drivers/net/wireless/ath/ath12k/debug.h
+++ b/drivers/net/wireless/ath/ath12k/debug.h
@@ -62,11 +62,11 @@ static inline void ath12k_dbg_dump(struct ath12k_base *ab,
}
#endif /* CONFIG_ATH12K_DEBUG */
-#define ath12k_dbg(ar, dbg_mask, fmt, ...) \
+#define ath12k_dbg(ab, dbg_mask, fmt, ...) \
do { \
typeof(dbg_mask) mask = (dbg_mask); \
if (ath12k_debug_mask & mask) \
- __ath12k_dbg(ar, mask, fmt, ##__VA_ARGS__); \
+ __ath12k_dbg(ab, mask, fmt, ##__VA_ARGS__); \
} while (0)
#endif /* _ATH12K_DEBUG_H_ */
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 1/8] wifi: ath12k: eliminate redundant debug mask check in ath12k_dbg()
2025-02-04 4:23 ` [PATCH 1/8] wifi: ath12k: eliminate redundant debug mask check in ath12k_dbg() Aditya Kumar Singh
@ 2025-02-04 7:35 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:35 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> The current implementation includes a debug mask check both in the macro
> expansion and in the function __ath12k_dbg(), which is unnecessary.
>
> Simplify the code by removing the redundant check from the helper function
> __ath12k_dbg().
>
> While at this, rename the first argument in macro from ar to ab since the
> first argument name in the function __ath12k_dbg() is ab.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/8] wifi: ath12k: introduce ath12k_generic_dbg()
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
2025-02-04 4:23 ` [PATCH 1/8] wifi: ath12k: eliminate redundant debug mask check in ath12k_dbg() Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:35 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 3/8] wifi: ath12k: remove redundant vif settings during link interface creation Aditya Kumar Singh
` (6 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
There might be instances where ath12k_dbg() is needed, but access to
struct ath12k_base (ab) is not readily available. To address this, add
support to print the debug message using printk() when ab is not present.
To avoid the need to explicitly pass NULL each time, introduce a new macro
ath12k_generic_dbg() which resolves to ath12k_dbg() with ab set to NULL.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/debug.c | 5 ++++-
drivers/net/wireless/ath/ath12k/debug.h | 3 +++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath12k/debug.c b/drivers/net/wireless/ath/ath12k/debug.c
index fd9796b5ad3b9feea5c7e78e8a88d361049e08df..5ce100cd9a9d16f7fcc2dc0a5522b341ebbff8a3 100644
--- a/drivers/net/wireless/ath/ath12k/debug.c
+++ b/drivers/net/wireless/ath/ath12k/debug.c
@@ -63,7 +63,10 @@ void __ath12k_dbg(struct ath12k_base *ab, enum ath12k_debug_mask mask,
vaf.fmt = fmt;
vaf.va = &args;
- dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
+ if (likely(ab))
+ dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
+ else
+ printk(KERN_DEBUG "ath12k: %pV", &vaf);
/* TODO: trace log */
diff --git a/drivers/net/wireless/ath/ath12k/debug.h b/drivers/net/wireless/ath/ath12k/debug.h
index ba0e4da3bb761a49fb81e3efcb61557df8ad1942..48916e4e1f6014055bbd56d5c71ef9182c78f3b6 100644
--- a/drivers/net/wireless/ath/ath12k/debug.h
+++ b/drivers/net/wireless/ath/ath12k/debug.h
@@ -69,4 +69,7 @@ do { \
__ath12k_dbg(ab, mask, fmt, ##__VA_ARGS__); \
} while (0)
+#define ath12k_generic_dbg(dbg_mask, fmt, ...) \
+ ath12k_dbg(NULL, dbg_mask, fmt, ##__VA_ARGS__)
+
#endif /* _ATH12K_DEBUG_H_ */
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 2/8] wifi: ath12k: introduce ath12k_generic_dbg()
2025-02-04 4:23 ` [PATCH 2/8] wifi: ath12k: introduce ath12k_generic_dbg() Aditya Kumar Singh
@ 2025-02-04 7:35 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:35 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> There might be instances where ath12k_dbg() is needed, but access to
> struct ath12k_base (ab) is not readily available. To address this, add
> support to print the debug message using printk() when ab is not present.
>
> To avoid the need to explicitly pass NULL each time, introduce a new macro
> ath12k_generic_dbg() which resolves to ath12k_dbg() with ab set to NULL.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/8] wifi: ath12k: remove redundant vif settings during link interface creation
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
2025-02-04 4:23 ` [PATCH 1/8] wifi: ath12k: eliminate redundant debug mask check in ath12k_dbg() Aditya Kumar Singh
2025-02-04 4:23 ` [PATCH 2/8] wifi: ath12k: introduce ath12k_generic_dbg() Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:35 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 4/8] wifi: ath12k: remove redundant logic for initializing arvif Aditya Kumar Singh
` (5 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, vif level settings are done in ath12k_mac_assign_link_vif() as
well as in ath12k_mac_op_add_interface(). Since it is vif level settings,
doing this on per link does not make sense and it contributes to redundant
code. Get rid of this redundant code from ath12k_mac_assign_link_vif().
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 16e6f2fae943d3fa6a46ab1ba6780c9070418279..7defc2b20fb61dcaec06d0e332c48a1b6cd2f5d6 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -4022,13 +4022,6 @@ static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
sizeof(arvif->bitrate_mask.control[i].vht_mcs));
}
- /* Allocate Default Queue now and reassign during actual vdev create */
- vif->cab_queue = ATH12K_HW_DEFAULT_QUEUE;
- for (i = 0; i < ARRAY_SIZE(vif->hw_queue); i++)
- vif->hw_queue[i] = ATH12K_HW_DEFAULT_QUEUE;
-
- vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD;
-
rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
ahvif->links_map |= BIT(link_id);
synchronize_rcu();
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 3/8] wifi: ath12k: remove redundant vif settings during link interface creation
2025-02-04 4:23 ` [PATCH 3/8] wifi: ath12k: remove redundant vif settings during link interface creation Aditya Kumar Singh
@ 2025-02-04 7:35 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:35 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> Currently, vif level settings are done in ath12k_mac_assign_link_vif() as
> well as in ath12k_mac_op_add_interface(). Since it is vif level settings,
> doing this on per link does not make sense and it contributes to redundant
> code. Get rid of this redundant code from ath12k_mac_assign_link_vif().
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 4/8] wifi: ath12k: remove redundant logic for initializing arvif
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
` (2 preceding siblings ...)
2025-02-04 4:23 ` [PATCH 3/8] wifi: ath12k: remove redundant vif settings during link interface creation Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:35 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 5/8] wifi: ath12k: use arvif instead of link_conf in ath12k_mac_set_key() Aditya Kumar Singh
` (4 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
The current logic for initializing arvif is present in both the add
interface operation callback and ath12k_mac_assign_link_vif(). The former
handles deflink initialization, while the latter is responsible for other
links. This redundancy could be avoided by using a common helper function.
Hence, add a new helper ath12k_mac_init_arvif() which initializes a
given arvif.
Since synchronizing rcu is not required after adding a rcu pointer, remove
that now.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 80 +++++++++++++++++++++--------------
1 file changed, 49 insertions(+), 31 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 7defc2b20fb61dcaec06d0e332c48a1b6cd2f5d6..5f0388002e16c38a834d6c7c6c020b7afa7044f0 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -3973,13 +3973,59 @@ static void ath12k_mac_op_link_info_changed(struct ieee80211_hw *hw,
ath12k_mac_bss_info_changed(ar, arvif, info, changed);
}
+static void ath12k_mac_init_arvif(struct ath12k_vif *ahvif,
+ struct ath12k_link_vif *arvif, int link_id)
+{
+ struct ath12k_hw *ah = ahvif->ah;
+ u8 _link_id;
+ int i;
+
+ lockdep_assert_wiphy(ah->hw->wiphy);
+
+ if (WARN_ON(!arvif))
+ return;
+
+ if (WARN_ON(link_id >= ATH12K_NUM_MAX_LINKS))
+ return;
+
+ if (link_id < 0)
+ _link_id = 0;
+ else
+ _link_id = link_id;
+
+ arvif->ahvif = ahvif;
+ arvif->link_id = _link_id;
+
+ INIT_LIST_HEAD(&arvif->list);
+ INIT_DELAYED_WORK(&arvif->connection_loss_work,
+ ath12k_mac_vif_sta_connection_loss_work);
+
+ for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
+ arvif->bitrate_mask.control[i].legacy = 0xffffffff;
+ memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
+ sizeof(arvif->bitrate_mask.control[i].ht_mcs));
+ memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
+ sizeof(arvif->bitrate_mask.control[i].vht_mcs));
+ }
+
+ /* Handle MLO related assignments */
+ if (link_id >= 0) {
+ rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
+ ahvif->links_map |= BIT(_link_id);
+ }
+
+ ath12k_generic_dbg(ATH12K_DBG_MAC,
+ "mac init link arvif (link_id %d%s) for vif %pM. links_map 0x%x",
+ _link_id, (link_id < 0) ? " deflink" : "", ahvif->vif->addr,
+ ahvif->links_map);
+}
+
static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
struct ieee80211_vif *vif,
u8 link_id)
{
struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
struct ath12k_link_vif *arvif;
- int i;
lockdep_assert_wiphy(ah->hw->wiphy);
@@ -4006,25 +4052,8 @@ static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
}
}
- arvif->ahvif = ahvif;
- arvif->link_id = link_id;
- ahvif->links_map |= BIT(link_id);
-
- INIT_LIST_HEAD(&arvif->list);
- INIT_DELAYED_WORK(&arvif->connection_loss_work,
- ath12k_mac_vif_sta_connection_loss_work);
-
- for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
- arvif->bitrate_mask.control[i].legacy = 0xffffffff;
- memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].ht_mcs));
- memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].vht_mcs));
- }
+ ath12k_mac_init_arvif(ahvif, arvif, link_id);
- rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
- ahvif->links_map |= BIT(link_id);
- synchronize_rcu();
return arvif;
}
@@ -8312,19 +8341,8 @@ static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw,
ahvif->ah = ah;
ahvif->vif = vif;
arvif = &ahvif->deflink;
- arvif->ahvif = ahvif;
-
- INIT_LIST_HEAD(&arvif->list);
- INIT_DELAYED_WORK(&arvif->connection_loss_work,
- ath12k_mac_vif_sta_connection_loss_work);
- for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
- arvif->bitrate_mask.control[i].legacy = 0xffffffff;
- memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].ht_mcs));
- memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].vht_mcs));
- }
+ ath12k_mac_init_arvif(ahvif, arvif, -1);
/* Allocate Default Queue now and reassign during actual vdev create */
vif->cab_queue = ATH12K_HW_DEFAULT_QUEUE;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 4/8] wifi: ath12k: remove redundant logic for initializing arvif
2025-02-04 4:23 ` [PATCH 4/8] wifi: ath12k: remove redundant logic for initializing arvif Aditya Kumar Singh
@ 2025-02-04 7:35 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:35 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> The current logic for initializing arvif is present in both the add
> interface operation callback and ath12k_mac_assign_link_vif(). The former
> handles deflink initialization, while the latter is responsible for other
> links. This redundancy could be avoided by using a common helper function.
>
> Hence, add a new helper ath12k_mac_init_arvif() which initializes a
> given arvif.
>
> Since synchronizing rcu is not required after adding a rcu pointer, remove
> that now.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/8] wifi: ath12k: use arvif instead of link_conf in ath12k_mac_set_key()
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
` (3 preceding siblings ...)
2025-02-04 4:23 ` [PATCH 4/8] wifi: ath12k: remove redundant logic for initializing arvif Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:36 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 6/8] wifi: ath12k: relocate a few functions in mac.c Aditya Kumar Singh
` (3 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, in ath12k_mac_set_key(), if sta is not present, the address is
retrieved from link_conf's bssid or addr member, depending on the interface
type.
When operating as an ML station and during shutdown, link_conf will not be
available. This can result in the following error:
ath12k_pci 0004:01:00.0: unable to access bss link conf in set key for vif AA:BB:CC:DD:EE:FF link 1
The primary purpose of accessing link_conf is to obtain the address for
finding the peer. However, since arvif is always valid in this call, it can
be used instead.
Add change to use arvif instead of link_conf.
A subsequent change will expose this issue but since tear down will give
error, this is included first.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 5f0388002e16c38a834d6c7c6c020b7afa7044f0..db866c1419a613103f119037b19e24b7edaa6c24 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -4667,9 +4667,6 @@ static int ath12k_mac_set_key(struct ath12k *ar, enum set_key_cmd cmd,
struct ath12k_link_sta *arsta,
struct ieee80211_key_conf *key)
{
- struct ath12k_vif *ahvif = arvif->ahvif;
- struct ieee80211_vif *vif = ath12k_ahvif_to_vif(ahvif);
- struct ieee80211_bss_conf *link_conf;
struct ieee80211_sta *sta = NULL;
struct ath12k_base *ab = ar->ab;
struct ath12k_peer *peer;
@@ -4686,19 +4683,10 @@ static int ath12k_mac_set_key(struct ath12k *ar, enum set_key_cmd cmd,
if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags))
return 1;
- link_conf = ath12k_mac_get_link_bss_conf(arvif);
- if (!link_conf) {
- ath12k_warn(ab, "unable to access bss link conf in set key for vif %pM link %u\n",
- vif->addr, arvif->link_id);
- return -ENOLINK;
- }
-
if (sta)
peer_addr = arsta->addr;
- else if (ahvif->vdev_type == WMI_VDEV_TYPE_STA)
- peer_addr = link_conf->bssid;
else
- peer_addr = link_conf->addr;
+ peer_addr = arvif->bssid;
key->hw_key_idx = key->keyidx;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 5/8] wifi: ath12k: use arvif instead of link_conf in ath12k_mac_set_key()
2025-02-04 4:23 ` [PATCH 5/8] wifi: ath12k: use arvif instead of link_conf in ath12k_mac_set_key() Aditya Kumar Singh
@ 2025-02-04 7:36 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:36 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> Currently, in ath12k_mac_set_key(), if sta is not present, the address is
> retrieved from link_conf's bssid or addr member, depending on the interface
> type.
>
> When operating as an ML station and during shutdown, link_conf will not be
> available. This can result in the following error:
>
> ath12k_pci 0004:01:00.0: unable to access bss link conf in set key for vif AA:BB:CC:DD:EE:FF link 1
>
> The primary purpose of accessing link_conf is to obtain the address for
> finding the peer. However, since arvif is always valid in this call, it can
> be used instead.
>
> Add change to use arvif instead of link_conf.
>
> A subsequent change will expose this issue but since tear down will give
> error, this is included first.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6/8] wifi: ath12k: relocate a few functions in mac.c
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
` (4 preceding siblings ...)
2025-02-04 4:23 ` [PATCH 5/8] wifi: ath12k: use arvif instead of link_conf in ath12k_mac_set_key() Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:36 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 7/8] wifi: ath12k: allocate new links in change_vif_links() Aditya Kumar Singh
` (2 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
An upcoming change will invoke ath12k_mac_init_arvif(),
ath12k_mac_assign_link_vif(), and ath12k_mac_unassign_link_vif() from a
line located above their current definition. Hence, relocate these
functions to above so that these can be invoked later on.
No functionality changes. Compile tested only.
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 202 +++++++++++++++++-----------------
1 file changed, 101 insertions(+), 101 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index db866c1419a613103f119037b19e24b7edaa6c24..5d80bbb664ea6a710eedd7b57db3523df9c893e6 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -3469,6 +3469,107 @@ static void ath12k_recalculate_mgmt_rate(struct ath12k *ar,
ath12k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret);
}
+static void ath12k_mac_init_arvif(struct ath12k_vif *ahvif,
+ struct ath12k_link_vif *arvif, int link_id)
+{
+ struct ath12k_hw *ah = ahvif->ah;
+ u8 _link_id;
+ int i;
+
+ lockdep_assert_wiphy(ah->hw->wiphy);
+
+ if (WARN_ON(!arvif))
+ return;
+
+ if (WARN_ON(link_id >= ATH12K_NUM_MAX_LINKS))
+ return;
+
+ if (link_id < 0)
+ _link_id = 0;
+ else
+ _link_id = link_id;
+
+ arvif->ahvif = ahvif;
+ arvif->link_id = _link_id;
+
+ INIT_LIST_HEAD(&arvif->list);
+ INIT_DELAYED_WORK(&arvif->connection_loss_work,
+ ath12k_mac_vif_sta_connection_loss_work);
+
+ for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
+ arvif->bitrate_mask.control[i].legacy = 0xffffffff;
+ memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
+ sizeof(arvif->bitrate_mask.control[i].ht_mcs));
+ memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
+ sizeof(arvif->bitrate_mask.control[i].vht_mcs));
+ }
+
+ /* Handle MLO related assignments */
+ if (link_id >= 0) {
+ rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
+ ahvif->links_map |= BIT(_link_id);
+ }
+
+ ath12k_generic_dbg(ATH12K_DBG_MAC,
+ "mac init link arvif (link_id %d%s) for vif %pM. links_map 0x%x",
+ _link_id, (link_id < 0) ? " deflink" : "", ahvif->vif->addr,
+ ahvif->links_map);
+}
+
+static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
+ struct ieee80211_vif *vif,
+ u8 link_id)
+{
+ struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
+ struct ath12k_link_vif *arvif;
+
+ lockdep_assert_wiphy(ah->hw->wiphy);
+
+ arvif = wiphy_dereference(ah->hw->wiphy, ahvif->link[link_id]);
+ if (arvif)
+ return arvif;
+
+ if (!vif->valid_links) {
+ /* Use deflink for Non-ML VIFs and mark the link id as 0
+ */
+ link_id = 0;
+ arvif = &ahvif->deflink;
+ } else {
+ /* If this is the first link arvif being created for an ML VIF
+ * use the preallocated deflink memory except for scan arvifs
+ */
+ if (!ahvif->links_map && link_id != ATH12K_DEFAULT_SCAN_LINK) {
+ arvif = &ahvif->deflink;
+ } else {
+ arvif = (struct ath12k_link_vif *)
+ kzalloc(sizeof(struct ath12k_link_vif), GFP_KERNEL);
+ if (!arvif)
+ return NULL;
+ }
+ }
+
+ ath12k_mac_init_arvif(ahvif, arvif, link_id);
+
+ return arvif;
+}
+
+static void ath12k_mac_unassign_link_vif(struct ath12k_link_vif *arvif)
+{
+ struct ath12k_vif *ahvif = arvif->ahvif;
+ struct ath12k_hw *ah = ahvif->ah;
+
+ lockdep_assert_wiphy(ah->hw->wiphy);
+
+ rcu_assign_pointer(ahvif->link[arvif->link_id], NULL);
+ synchronize_rcu();
+ ahvif->links_map &= ~BIT(arvif->link_id);
+
+ if (arvif != &ahvif->deflink)
+ kfree(arvif);
+ else
+ memset(arvif, 0, sizeof(*arvif));
+}
+
static int
ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
@@ -3973,107 +4074,6 @@ static void ath12k_mac_op_link_info_changed(struct ieee80211_hw *hw,
ath12k_mac_bss_info_changed(ar, arvif, info, changed);
}
-static void ath12k_mac_init_arvif(struct ath12k_vif *ahvif,
- struct ath12k_link_vif *arvif, int link_id)
-{
- struct ath12k_hw *ah = ahvif->ah;
- u8 _link_id;
- int i;
-
- lockdep_assert_wiphy(ah->hw->wiphy);
-
- if (WARN_ON(!arvif))
- return;
-
- if (WARN_ON(link_id >= ATH12K_NUM_MAX_LINKS))
- return;
-
- if (link_id < 0)
- _link_id = 0;
- else
- _link_id = link_id;
-
- arvif->ahvif = ahvif;
- arvif->link_id = _link_id;
-
- INIT_LIST_HEAD(&arvif->list);
- INIT_DELAYED_WORK(&arvif->connection_loss_work,
- ath12k_mac_vif_sta_connection_loss_work);
-
- for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) {
- arvif->bitrate_mask.control[i].legacy = 0xffffffff;
- memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].ht_mcs));
- memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff,
- sizeof(arvif->bitrate_mask.control[i].vht_mcs));
- }
-
- /* Handle MLO related assignments */
- if (link_id >= 0) {
- rcu_assign_pointer(ahvif->link[arvif->link_id], arvif);
- ahvif->links_map |= BIT(_link_id);
- }
-
- ath12k_generic_dbg(ATH12K_DBG_MAC,
- "mac init link arvif (link_id %d%s) for vif %pM. links_map 0x%x",
- _link_id, (link_id < 0) ? " deflink" : "", ahvif->vif->addr,
- ahvif->links_map);
-}
-
-static struct ath12k_link_vif *ath12k_mac_assign_link_vif(struct ath12k_hw *ah,
- struct ieee80211_vif *vif,
- u8 link_id)
-{
- struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
- struct ath12k_link_vif *arvif;
-
- lockdep_assert_wiphy(ah->hw->wiphy);
-
- arvif = wiphy_dereference(ah->hw->wiphy, ahvif->link[link_id]);
- if (arvif)
- return arvif;
-
- if (!vif->valid_links) {
- /* Use deflink for Non-ML VIFs and mark the link id as 0
- */
- link_id = 0;
- arvif = &ahvif->deflink;
- } else {
- /* If this is the first link arvif being created for an ML VIF
- * use the preallocated deflink memory except for scan arvifs
- */
- if (!ahvif->links_map && link_id != ATH12K_DEFAULT_SCAN_LINK) {
- arvif = &ahvif->deflink;
- } else {
- arvif = (struct ath12k_link_vif *)
- kzalloc(sizeof(struct ath12k_link_vif), GFP_KERNEL);
- if (!arvif)
- return NULL;
- }
- }
-
- ath12k_mac_init_arvif(ahvif, arvif, link_id);
-
- return arvif;
-}
-
-static void ath12k_mac_unassign_link_vif(struct ath12k_link_vif *arvif)
-{
- struct ath12k_vif *ahvif = arvif->ahvif;
- struct ath12k_hw *ah = ahvif->ah;
-
- lockdep_assert_wiphy(ah->hw->wiphy);
-
- rcu_assign_pointer(ahvif->link[arvif->link_id], NULL);
- synchronize_rcu();
- ahvif->links_map &= ~BIT(arvif->link_id);
-
- if (arvif != &ahvif->deflink)
- kfree(arvif);
- else
- memset(arvif, 0, sizeof(*arvif));
-}
-
static void ath12k_mac_remove_link_interface(struct ieee80211_hw *hw,
struct ath12k_link_vif *arvif)
{
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 6/8] wifi: ath12k: relocate a few functions in mac.c
2025-02-04 4:23 ` [PATCH 6/8] wifi: ath12k: relocate a few functions in mac.c Aditya Kumar Singh
@ 2025-02-04 7:36 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:36 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> An upcoming change will invoke ath12k_mac_init_arvif(),
> ath12k_mac_assign_link_vif(), and ath12k_mac_unassign_link_vif() from a
> line located above their current definition. Hence, relocate these
> functions to above so that these can be invoked later on.
>
> No functionality changes. Compile tested only.
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 7/8] wifi: ath12k: allocate new links in change_vif_links()
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
` (5 preceding siblings ...)
2025-02-04 4:23 ` [PATCH 6/8] wifi: ath12k: relocate a few functions in mac.c Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:36 ` Vasanthakumar Thiagarajan
2025-02-04 4:23 ` [PATCH 8/8] wifi: ath12k: handle link removal " Aditya Kumar Singh
2025-02-04 10:02 ` [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Nicolas Escande
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, links in an interface are allocated during channel assignment
via assign_vif_chanctx(). Conversely, links are deleted during channel
unassignment via unassign_vif_chanctx(). However, deleting links during
channel unassignment does not comply with mac80211 link handling.
Therefore, this process should be managed within change_vif_links(). To
maintain symmetry, link addition should also be handled in
change_vif_links().
Hence, add changes to allocate link arvif in change_vif_links(). Creating
the link interface on firmware will still be done during channel
assignment.
And since link will be created but channel might not be assigned, there is
a need now to test is_created flag in ath12k_mac_mlo_get_vdev_args() before
accessing link_conf or else link bring up will fail.
A subsequent change will handle link removal part.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 5d80bbb664ea6a710eedd7b57db3523df9c893e6..b9017002f3efb27d917f0aa35a0ecc66af18ec99 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -3576,6 +3576,31 @@ ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
u16 old_links, u16 new_links,
struct ieee80211_bss_conf *ol[IEEE80211_MLD_MAX_NUM_LINKS])
{
+ struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
+ unsigned long to_add = ~old_links & new_links;
+ struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
+ struct ath12k_link_vif *arvif;
+ u8 link_id;
+
+ lockdep_assert_wiphy(hw->wiphy);
+
+ ath12k_generic_dbg(ATH12K_DBG_MAC,
+ "mac vif link changed for MLD %pM old_links 0x%x new_links 0x%x\n",
+ vif->addr, old_links, new_links);
+
+ for_each_set_bit(link_id, &to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
+ arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
+ /* mac80211 wants to add link but driver already has the
+ * link. This should not happen ideally.
+ */
+ if (WARN_ON(arvif))
+ return -EINVAL;
+
+ arvif = ath12k_mac_assign_link_vif(ah, vif, link_id);
+ if (WARN_ON(!arvif))
+ return -EINVAL;
+ }
+
return 0;
}
@@ -8765,6 +8790,9 @@ ath12k_mac_mlo_get_vdev_args(struct ath12k_link_vif *arvif,
if (arvif == arvif_p)
continue;
+ if (!arvif_p->is_created)
+ continue;
+
link_conf = wiphy_dereference(ahvif->ah->hw->wiphy,
ahvif->vif->link_conf[arvif_p->link_id]);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 7/8] wifi: ath12k: allocate new links in change_vif_links()
2025-02-04 4:23 ` [PATCH 7/8] wifi: ath12k: allocate new links in change_vif_links() Aditya Kumar Singh
@ 2025-02-04 7:36 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:36 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> Currently, links in an interface are allocated during channel assignment
> via assign_vif_chanctx(). Conversely, links are deleted during channel
> unassignment via unassign_vif_chanctx(). However, deleting links during
> channel unassignment does not comply with mac80211 link handling.
> Therefore, this process should be managed within change_vif_links(). To
> maintain symmetry, link addition should also be handled in
> change_vif_links().
>
> Hence, add changes to allocate link arvif in change_vif_links(). Creating
> the link interface on firmware will still be done during channel
> assignment.
>
> And since link will be created but channel might not be assigned, there is
> a need now to test is_created flag in ath12k_mac_mlo_get_vdev_args() before
> accessing link_conf or else link bring up will fail.
>
> A subsequent change will handle link removal part.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 8/8] wifi: ath12k: handle link removal in change_vif_links()
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
` (6 preceding siblings ...)
2025-02-04 4:23 ` [PATCH 7/8] wifi: ath12k: allocate new links in change_vif_links() Aditya Kumar Singh
@ 2025-02-04 4:23 ` Aditya Kumar Singh
2025-02-04 7:37 ` Vasanthakumar Thiagarajan
2025-02-04 10:02 ` [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Nicolas Escande
8 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 4:23 UTC (permalink / raw)
To: Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel, Aditya Kumar Singh
Currently, the link interface is deleted during channel unassignment, which
does not align with mac80211 link handling. Therefore, add changes to only
perform vdev down during channel unassignment. The actual vdev deletion
will occur in change_vif_links().
Additionally, since the link arvif is currently allocated in
change_vif_links(), to maintain symmetry, add changes to deallocate the
link arvif in change_vif_links() as well.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 53 +++++++++++++++++++++++++++--------
1 file changed, 42 insertions(+), 11 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index b9017002f3efb27d917f0aa35a0ecc66af18ec99..d965ae2e755821ea5bfa366a5d74263020e5dee5 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -3577,10 +3577,12 @@ ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *ol[IEEE80211_MLD_MAX_NUM_LINKS])
{
struct ath12k_vif *ahvif = ath12k_vif_to_ahvif(vif);
+ unsigned long to_remove = old_links & ~new_links;
unsigned long to_add = ~old_links & new_links;
struct ath12k_hw *ah = ath12k_hw_to_ah(hw);
struct ath12k_link_vif *arvif;
u8 link_id;
+ int ret;
lockdep_assert_wiphy(hw->wiphy);
@@ -3601,6 +3603,31 @@ ath12k_mac_op_change_vif_links(struct ieee80211_hw *hw,
return -EINVAL;
}
+ for_each_set_bit(link_id, &to_remove, IEEE80211_MLD_MAX_NUM_LINKS) {
+ arvif = wiphy_dereference(hw->wiphy, ahvif->link[link_id]);
+ if (WARN_ON(!arvif))
+ return -EINVAL;
+
+ if (!arvif->is_created)
+ continue;
+
+ if (WARN_ON(!arvif->ar))
+ return -EINVAL;
+
+ ath12k_dbg(arvif->ar->ab, ATH12K_DBG_MAC,
+ "mac remove link interface (vdev %d link id %d)",
+ arvif->vdev_id, arvif->link_id);
+
+ ret = ath12k_mac_vdev_delete(arvif->ar, arvif);
+ if (ret)
+ /* No need of error prints here since already inside the above
+ * call, in error path, prints are there.
+ */
+ return ret;
+
+ ath12k_mac_unassign_link_vif(arvif);
+ }
+
return 0;
}
@@ -4100,7 +4127,8 @@ static void ath12k_mac_op_link_info_changed(struct ieee80211_hw *hw,
}
static void ath12k_mac_remove_link_interface(struct ieee80211_hw *hw,
- struct ath12k_link_vif *arvif)
+ struct ath12k_link_vif *arvif,
+ bool delete_vdev)
{
struct ath12k_vif *ahvif = arvif->ahvif;
struct ath12k_hw *ah = hw->priv;
@@ -4111,7 +4139,9 @@ static void ath12k_mac_remove_link_interface(struct ieee80211_hw *hw,
cancel_delayed_work_sync(&arvif->connection_loss_work);
- ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac remove link interface (vdev %d link id %d)",
+ ath12k_dbg(ar->ab, ATH12K_DBG_MAC,
+ "mac remove link interface %s(vdev %d link id %d)",
+ delete_vdev ? "" : "partially ",
arvif->vdev_id, arvif->link_id);
if (ahvif->vdev_type == WMI_VDEV_TYPE_AP) {
@@ -4120,7 +4150,9 @@ static void ath12k_mac_remove_link_interface(struct ieee80211_hw *hw,
ath12k_warn(ar->ab, "failed to submit AP self-peer removal on vdev %d link id %d: %d",
arvif->vdev_id, arvif->link_id, ret);
}
- ath12k_mac_vdev_delete(ar, arvif);
+
+ if (delete_vdev)
+ ath12k_mac_vdev_delete(ar, arvif);
}
static struct ath12k*
@@ -4300,7 +4332,7 @@ static void ath12k_scan_vdev_clean_work(struct wiphy *wiphy, struct wiphy_work *
ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac clean scan vdev (link id %u)",
arvif->link_id);
- ath12k_mac_remove_link_interface(ah->hw, arvif);
+ ath12k_mac_remove_link_interface(ah->hw, arvif, true);
ath12k_mac_unassign_link_vif(arvif);
work_complete:
@@ -4436,7 +4468,7 @@ static int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw,
return -EINVAL;
if (ar != arvif->ar) {
- ath12k_mac_remove_link_interface(hw, arvif);
+ ath12k_mac_remove_link_interface(hw, arvif, true);
ath12k_mac_unassign_link_vif(arvif);
} else {
create = false;
@@ -8274,7 +8306,7 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
ahvif->link[ATH12K_DEFAULT_SCAN_LINK]);
if (scan_arvif && scan_arvif->ar == ar) {
ar->scan.arvif = NULL;
- ath12k_mac_remove_link_interface(hw, scan_arvif);
+ ath12k_mac_remove_link_interface(hw, scan_arvif, true);
ath12k_mac_unassign_link_vif(scan_arvif);
}
}
@@ -8297,7 +8329,7 @@ static struct ath12k *ath12k_mac_assign_vif_to_vdev(struct ieee80211_hw *hw,
if (WARN_ON(arvif->is_started))
return NULL;
- ath12k_mac_remove_link_interface(hw, arvif);
+ ath12k_mac_remove_link_interface(hw, arvif, true);
ath12k_mac_unassign_link_vif(arvif);
}
}
@@ -8502,7 +8534,7 @@ static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw,
spin_unlock_bh(&ar->data_lock);
}
- ath12k_mac_remove_link_interface(hw, arvif);
+ ath12k_mac_remove_link_interface(hw, arvif, true);
ath12k_mac_unassign_link_vif(arvif);
}
}
@@ -9439,8 +9471,7 @@ ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
ar->num_started_vdevs == 1 && ar->monitor_vdev_created)
ath12k_mac_monitor_stop(ar);
- ath12k_mac_remove_link_interface(hw, arvif);
- ath12k_mac_unassign_link_vif(arvif);
+ ath12k_mac_remove_link_interface(hw, arvif, false);
}
static int
@@ -10293,7 +10324,7 @@ static int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
return -EBUSY;
if (ar != arvif->ar) {
- ath12k_mac_remove_link_interface(hw, arvif);
+ ath12k_mac_remove_link_interface(hw, arvif, true);
ath12k_mac_unassign_link_vif(arvif);
} else {
create = false;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH 8/8] wifi: ath12k: handle link removal in change_vif_links()
2025-02-04 4:23 ` [PATCH 8/8] wifi: ath12k: handle link removal " Aditya Kumar Singh
@ 2025-02-04 7:37 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 21+ messages in thread
From: Vasanthakumar Thiagarajan @ 2025-02-04 7:37 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/2025 9:53 AM, Aditya Kumar Singh wrote:
> Currently, the link interface is deleted during channel unassignment, which
> does not align with mac80211 link handling. Therefore, add changes to only
> perform vdev down during channel unassignment. The actual vdev deletion
> will occur in change_vif_links().
>
> Additionally, since the link arvif is currently allocated in
> change_vif_links(), to maintain symmetry, add changes to deallocate the
> link arvif in change_vif_links() as well.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback
2025-02-04 4:23 [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Aditya Kumar Singh
` (7 preceding siblings ...)
2025-02-04 4:23 ` [PATCH 8/8] wifi: ath12k: handle link removal " Aditya Kumar Singh
@ 2025-02-04 10:02 ` Nicolas Escande
2025-02-04 10:23 ` Aditya Kumar Singh
8 siblings, 1 reply; 21+ messages in thread
From: Nicolas Escande @ 2025-02-04 10:02 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On Tue Feb 4, 2025 at 5:23 AM CET, Aditya Kumar Singh wrote:
> Currently, links in an interface are allocated during channel assignment
> via assign_vif_chanctx(). Conversely, links are deleted during channel
> unassignment via unassign_vif_chanctx(). However, deleting links during
> channel unassignment does not comply with mac80211 link handling.
> Therefore, this process should be managed within change_vif_links().
>
> This series aims to add support to handle links in change_vif_links()
> callback.
>
> Patches 1-2 are making debug infra to work without device info.
>
> Patches 3-8 are the ones changing the code to handle as mentioned above.
>
> NOTE:
> * A new ath12k-check warning comes which probably needs to be added to
> ignore list
>
> drivers/net/wireless/ath/ath12k/debug.c:69: Prefer [subsystem eg: netdev]_dbg([subsystem]dev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ...
>
> This is because, since device info is not known can not use netdev_ or dev_
> dbg family. pr_debug() is an option but that will require DYNAMIC_DEBUG
> and then ath12k needs to be probed with dyndbg=+p which we don't want in
> ath. Hence, only option left is to use printk() directly.
>
Hello,
When applying this series I am no longer able to start an AP on a DFS channel.
(I don't know specifically which patch though)
After the initial CAC period I get the following kernel message:
[ 45.248441] ath12k_pci 0003:01:00.0: cannot install key for non-existent peer 3a:07:16:d8:00:08
And then hostapd goes in failed state:
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
ACS: Automatic channel selection started, this may take a bit
wlan0: interface state COUNTRY_UPDATE->ACS
wlan0: ACS-STARTED
wlan0: ACS-COMPLETED freq=5620 channel=124
wlan0: interface state ACS->DFS
wlan0: DFS-CAC-START freq=5620 chan=124 sec_chan=1, width=2, seg0=114, seg1=0, cac_time=5s
wlan0: DFS-CAC-COMPLETED success=1 freq=5620 ht_enabled=0 chan_offset=0 chan_width=5 cf1=5570 cf2=0 radar_detected=0
wlan0: nl80211: kernel reports: key addition failed
Interface initialization failed
wlan0: interface state DFS->DISABLED
wlan0: AP-DISABLED
Maybe I missed something ? Is there another series this one depends upon that I
should have applied before ?
Thanks
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback
2025-02-04 10:02 ` [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback Nicolas Escande
@ 2025-02-04 10:23 ` Aditya Kumar Singh
2025-02-04 10:44 ` Nicolas Escande
0 siblings, 1 reply; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 10:23 UTC (permalink / raw)
To: Nicolas Escande, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/25 15:32, Nicolas Escande wrote:
> Hello,
>
> When applying this series I am no longer able to start an AP on a DFS channel.
> (I don't know specifically which patch though)
>
Thanks for reporting this. I think non-DFS channel should be working
fine right?
Anyways, I'm able to repro the issue locally. Let me investigate further
and come back.
> After the initial CAC period I get the following kernel message:
> [ 45.248441] ath12k_pci 0003:01:00.0: cannot install key for non-existent peer 3a:07:16:d8:00:08
> And then hostapd goes in failed state:
> wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
> ACS: Automatic channel selection started, this may take a bit
> wlan0: interface state COUNTRY_UPDATE->ACS
> wlan0: ACS-STARTED
> wlan0: ACS-COMPLETED freq=5620 channel=124
> wlan0: interface state ACS->DFS
> wlan0: DFS-CAC-START freq=5620 chan=124 sec_chan=1, width=2, seg0=114, seg1=0, cac_time=5s
> wlan0: DFS-CAC-COMPLETED success=1 freq=5620 ht_enabled=0 chan_offset=0 chan_width=5 cf1=5570 cf2=0 radar_detected=0
> wlan0: nl80211: kernel reports: key addition failed
> Interface initialization failed
> wlan0: interface state DFS->DISABLED
> wlan0: AP-DISABLED
>
> Maybe I missed something ? Is there another series this one depends upon that I
> should have applied before ?
No known dependency as such.
--
Aditya
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback
2025-02-04 10:23 ` Aditya Kumar Singh
@ 2025-02-04 10:44 ` Nicolas Escande
2025-02-04 17:19 ` Aditya Kumar Singh
0 siblings, 1 reply; 21+ messages in thread
From: Nicolas Escande @ 2025-02-04 10:44 UTC (permalink / raw)
To: Aditya Kumar Singh, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On Tue Feb 4, 2025 at 11:23 AM CET, Aditya Kumar Singh wrote:
> On 2/4/25 15:32, Nicolas Escande wrote:
>> Hello,
>>
>> When applying this series I am no longer able to start an AP on a DFS channel.
>> (I don't know specifically which patch though)
>>
>
> Thanks for reporting this. I think non-DFS channel should be working
> fine right?
Right non DFS channels are ok, only DFS ones, and not from the get go but after
the initial CAC, when they switch to operational mode.
>
> Anyways, I'm able to repro the issue locally. Let me investigate further
> and come back.
I'll happily test what you can throw at me.
>
>> After the initial CAC period I get the following kernel message:
>> [ 45.248441] ath12k_pci 0003:01:00.0: cannot install key for non-existent peer 3a:07:16:d8:00:08
>> And then hostapd goes in failed state:
>> wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
>> ACS: Automatic channel selection started, this may take a bit
>> wlan0: interface state COUNTRY_UPDATE->ACS
>> wlan0: ACS-STARTED
>> wlan0: ACS-COMPLETED freq=5620 channel=124
>> wlan0: interface state ACS->DFS
>> wlan0: DFS-CAC-START freq=5620 chan=124 sec_chan=1, width=2, seg0=114, seg1=0, cac_time=5s
>> wlan0: DFS-CAC-COMPLETED success=1 freq=5620 ht_enabled=0 chan_offset=0 chan_width=5 cf1=5570 cf2=0 radar_detected=0
>> wlan0: nl80211: kernel reports: key addition failed
>> Interface initialization failed
>> wlan0: interface state DFS->DISABLED
>> wlan0: AP-DISABLED
>>
>> Maybe I missed something ? Is there another series this one depends upon that I
>> should have applied before ?
>
> No known dependency as such.
Good, as I have a few other series applied in my tree I was affraid it might be
something on my side.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/8] wifi: ath12k: handle change_vif_links() callback
2025-02-04 10:44 ` Nicolas Escande
@ 2025-02-04 17:19 ` Aditya Kumar Singh
0 siblings, 0 replies; 21+ messages in thread
From: Aditya Kumar Singh @ 2025-02-04 17:19 UTC (permalink / raw)
To: Nicolas Escande, Kalle Valo, Jeff Johnson
Cc: linux-wireless, ath12k, linux-kernel
On 2/4/25 16:14, Nicolas Escande wrote:
> On Tue Feb 4, 2025 at 11:23 AM CET, Aditya Kumar Singh wrote:
>> On 2/4/25 15:32, Nicolas Escande wrote:
>>> Hello,
>>>
>>> When applying this series I am no longer able to start an AP on a DFS channel.
>>> (I don't know specifically which patch though)
>>>
>>
>> Thanks for reporting this. I think non-DFS channel should be working
>> fine right?
> Right non DFS channels are ok, only DFS ones, and not from the get go but after
> the initial CAC, when they switch to operational mode.
>>
>> Anyways, I'm able to repro the issue locally. Let me investigate further
>> and come back.
> I'll happily test what you can throw at me.
:)
I have posted v2 [1] fixing the reported DFS issue as well. When you
have time, could you test and confirm? Locally I'm able to see
DFS/non-DFS working fine now.
[1]:
https://lore.kernel.org/linux-wireless/20250204-unlink_link_arvif_from_chanctx-v2-0-764fb5973c1a@oss.qualcomm.com/
--
Aditya
^ permalink raw reply [flat|nested] 21+ messages in thread