eee0bf0fb5a93bcb1e0c76669c05115b6deaa190
[openwrt/staging/ansuel.git] /
1 From 69fcb525905600a151997cd16367bb92c34a2b14 Mon Sep 17 00:00:00 2001
2 From: Aditya Kumar Singh <quic_adisi@quicinc.com>
3 Date: Tue, 3 Oct 2023 17:26:54 +0300
4 Subject: [PATCH] wifi: ath11k: fix CAC running state during virtual interface
5 start
6
7 Currently channel definition's primary channel's DFS CAC time
8 as well as primary channel's state i.e usable are used to set
9 the CAC_RUNNING flag for the ath11k radio structure. However,
10 this is wrong since certain channel definition are possbile
11 where primary channel may not be a DFS channel but, secondary
12 channel is a DFS channel. For example - channel 36 with 160 MHz
13 bandwidth.
14 In such cases, the flag will not be set which is wrong.
15
16 Fix this issue by using cfg80211_chandef_dfs_usable() function
17 from cfg80211 which return trues if at least one channel is in
18 usable state.
19
20 While at it, modify the CAC running debug log message to print
21 the CAC time as well in milli-seconds.
22
23 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
24
25 Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
26 Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
27 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
28 Link: https://lore.kernel.org/r/20230912051857.2284-3-quic_adisi@quicinc.com
29 ---
30 drivers/net/wireless/ath/ath11k/mac.c | 19 +++++++++++--------
31 1 file changed, 11 insertions(+), 8 deletions(-)
32
33 --- a/drivers/net/wireless/ath/ath11k/mac.c
34 +++ b/drivers/net/wireless/ath/ath11k/mac.c
35 @@ -5,6 +5,7 @@
36 */
37
38 #include <net/mac80211.h>
39 +#include <net/cfg80211.h>
40 #include <linux/etherdevice.h>
41 #include <linux/bitfield.h>
42 #include <linux/inetdevice.h>
43 @@ -7196,6 +7197,7 @@ ath11k_mac_vdev_start_restart(struct ath
44 struct wmi_vdev_start_req_arg arg = {};
45 const struct cfg80211_chan_def *chandef = &ctx->def;
46 int ret = 0;
47 + unsigned int dfs_cac_time;
48
49 lockdep_assert_held(&ar->conf_mutex);
50
51 @@ -7275,20 +7277,21 @@ ath11k_mac_vdev_start_restart(struct ath
52 ath11k_dbg(ab, ATH11K_DBG_MAC, "vdev %pM started, vdev_id %d\n",
53 arvif->vif->addr, arvif->vdev_id);
54
55 - /* Enable CAC Flag in the driver by checking the channel DFS cac time,
56 - * i.e dfs_cac_ms value which will be valid only for radar channels
57 - * and state as NL80211_DFS_USABLE which indicates CAC needs to be
58 + /* Enable CAC Flag in the driver by checking the all sub-channel's DFS
59 + * state as NL80211_DFS_USABLE which indicates CAC needs to be
60 * done before channel usage. This flags is used to drop rx packets.
61 * during CAC.
62 */
63 /* TODO Set the flag for other interface types as required */
64 - if (arvif->vdev_type == WMI_VDEV_TYPE_AP &&
65 - chandef->chan->dfs_cac_ms &&
66 - chandef->chan->dfs_state == NL80211_DFS_USABLE) {
67 + if (arvif->vdev_type == WMI_VDEV_TYPE_AP && ctx->radar_enabled &&
68 + cfg80211_chandef_dfs_usable(ar->hw->wiphy, chandef)) {
69 set_bit(ATH11K_CAC_RUNNING, &ar->dev_flags);
70 + dfs_cac_time = cfg80211_chandef_dfs_cac_time(ar->hw->wiphy,
71 + chandef);
72 ath11k_dbg(ab, ATH11K_DBG_MAC,
73 - "CAC Started in chan_freq %d for vdev %d\n",
74 - arg.channel.freq, arg.vdev_id);
75 + "cac started dfs_cac_time %u center_freq %d center_freq1 %d for vdev %d\n",
76 + dfs_cac_time, arg.channel.freq, chandef->center_freq1,
77 + arg.vdev_id);
78 }
79
80 ret = ath11k_mac_set_txbf_conf(arvif);