From yuanjilin at cdjrlc.com  Sat Jul  9 05:43:56 2022
From: yuanjilin at cdjrlc.com (Jilin Yuan)
Date: Sat,  9 Jul 2022 20:43:56 +0800
Subject: [PATCH] wifi: wcn36xx: fix repeated words in comments
Message-ID: <20220709124356.52543-1-yuanjilin@cdjrlc.com>

 Delete the redundant word 'the'.

Signed-off-by: Jilin Yuan <yuanjilin at cdjrlc.com>
---
 drivers/net/wireless/ath/wcn36xx/hal.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 46a49f0a51b3..a1afe1f85f0e 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -1961,7 +1961,7 @@ struct wcn36xx_hal_config_bss_params {
 
 	/* HAL should update the existing BSS entry, if this flag is set.
 	 * UMAC will set this flag in case of reassoc, where we want to
-	 * resue the the old BSSID and still return success 0 = Add, 1 =
+	 * resue the old BSSID and still return success 0 = Add, 1 =
 	 * Update */
 	u8 action;
 
@@ -2098,7 +2098,7 @@ struct wcn36xx_hal_config_bss_params_v1 {
 
 	/* HAL should update the existing BSS entry, if this flag is set.
 	 * UMAC will set this flag in case of reassoc, where we want to
-	 * resue the the old BSSID and still return success 0 = Add, 1 =
+	 * resue the old BSSID and still return success 0 = Add, 1 =
 	 * Update */
 	u8 action;
 
@@ -4142,7 +4142,7 @@ struct wcn36xx_hal_dump_cmd_rsp_msg {
 	/* Length of the responce message */
 	u32 rsp_length;
 
-	/* FIXME: Currently considering the the responce will be less than
+	/* FIXME: Currently considering the responce will be less than
 	 * 100bytes */
 	u8 rsp_buffer[DUMPCMD_RSP_BUFFER];
 } __packed;
-- 
2.36.1



From joe at perches.com  Sat Jul  9 12:07:10 2022
From: joe at perches.com (Joe Perches)
Date: Sat, 09 Jul 2022 12:07:10 -0700
Subject: [PATCH] wifi: wcn36xx: fix repeated words in comments
In-Reply-To: <20220709124356.52543-1-yuanjilin@cdjrlc.com>
References: <20220709124356.52543-1-yuanjilin@cdjrlc.com>
Message-ID: <b47293b4b8874c0ae32868533bd0df94e08b8706.camel@perches.com>

On Sat, 2022-07-09 at 20:43 +0800, Jilin Yuan wrote:
>  Delete the redundant word 'the'.
[]
> diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
[]
> @@ -1961,7 +1961,7 @@ struct wcn36xx_hal_config_bss_params {
>  
>  	/* HAL should update the existing BSS entry, if this flag is set.
>  	 * UMAC will set this flag in case of reassoc, where we want to
> -	 * resue the the old BSSID and still return success 0 = Add, 1 =
> +	 * resue the old BSSID and still return success 0 = Add, 1 =


s/resue/reuse/

>  	 * Update */
>  	u8 action;
>  
> @@ -2098,7 +2098,7 @@ struct wcn36xx_hal_config_bss_params_v1 {
>  
>  	/* HAL should update the existing BSS entry, if this flag is set.
>  	 * UMAC will set this flag in case of reassoc, where we want to
> -	 * resue the the old BSSID and still return success 0 = Add, 1 =
> +	 * resue the old BSSID and still return success 0 = Add, 1 =

here too

>  	 * Update */
>  	u8 action;
>  
> @@ -4142,7 +4142,7 @@ struct wcn36xx_hal_dump_cmd_rsp_msg {
>  	/* Length of the responce message */
>  	u32 rsp_length;
>  
> -	/* FIXME: Currently considering the the responce will be less than
> +	/* FIXME: Currently considering the responce will be less than

s/responce/response/

>  	 * 100bytes */
>  	u8 rsp_buffer[DUMPCMD_RSP_BUFFER];
>  } __packed;



From kvalo at kernel.org  Mon Jul 18 03:05:58 2022
From: kvalo at kernel.org (Kalle Valo)
Date: Mon, 18 Jul 2022 10:05:58 +0000 (UTC)
Subject: [PATCH] wifi: wcn36xx: fix repeated words in comments
In-Reply-To: <20220709124356.52543-1-yuanjilin@cdjrlc.com>
References: <20220709124356.52543-1-yuanjilin@cdjrlc.com>
Message-ID: <165813874770.12812.3009375369162457082.kvalo@kernel.org>

Jilin Yuan <yuanjilin at cdjrlc.com> wrote:

> Delete the redundant word 'the'.
> 
> Signed-off-by: Jilin Yuan <yuanjilin at cdjrlc.com>
> Signed-off-by: Kalle Valo <quic_kvalo at quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

ec65e0e9acf7 wifi: wcn36xx: fix repeated words in comments

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220709124356.52543-1-yuanjilin at cdjrlc.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



From bryan.odonoghue at linaro.org  Tue Jul 19 05:15:56 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 13:15:56 +0100
Subject: [PATCH 0/4] wcn36xx: Add in debugfs export of firmware feature bits
Message-ID: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>

This series tidies up the code to get/set/clear discovered firmware feature
bits and adds a new debugfs entry to read the feature bits as strings.

cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps

wcn3680b:
FW Cap = MCC
FW Cap = P2P
FW Cap = DOT11AC
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = MU_MIMO
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

wcn3620:
FW Cap = MCC
FW Cap = P2P
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

This is a handy way of debugging WiFi on different platforms without
necessarily having to recompile to see the debug printout on firmware boot.

Bryan O'Donoghue (4):
  wcn36xx: Rename clunky firmware feature bit enum
  wcn36xx: Move firmware feature bit storage to dedicated firmware.c
    file
  wcn36xx: Move capability bitmap to string translation function to
    firmware.c
  wcn36xx: Add debugfs entry to read firmware feature strings

 drivers/net/wireless/ath/wcn36xx/Makefile   |   3 +-
 drivers/net/wireless/ath/wcn36xx/debug.c    |  37 ++++++
 drivers/net/wireless/ath/wcn36xx/debug.h    |   1 +
 drivers/net/wireless/ath/wcn36xx/firmware.c | 125 ++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h |  84 +++++++++++++
 drivers/net/wireless/ath/wcn36xx/hal.h      |  68 -----------
 drivers/net/wireless/ath/wcn36xx/main.c     |  86 ++------------
 drivers/net/wireless/ath/wcn36xx/smd.c      |  57 ++-------
 drivers/net/wireless/ath/wcn36xx/smd.h      |   3 -
 9 files changed, 264 insertions(+), 200 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h

-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 05:15:57 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 13:15:57 +0100
Subject: [PATCH 1/4] wcn36xx: Rename clunky firmware feature bit enum
In-Reply-To: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
References: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719121600.1847440-2-bryan.odonoghue@linaro.org>

The enum name "place_holder_in_cap_bitmap" is self descriptively asking to
be changed to something else.

Rename place_holder_in_cap_bitmap to wcn36xx_firmware_feat_caps so that the
contents and intent of the enum is obvious.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/hal.h  | 2 +-
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 drivers/net/wireless/ath/wcn36xx/smd.c  | 6 +++---
 drivers/net/wireless/ath/wcn36xx/smd.h  | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 46a49f0a51b3..5e48c97682c2 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4760,7 +4760,7 @@ struct wcn36xx_hal_set_power_params_resp {
 
 /* Capability bitmap exchange definitions and macros starts */
 
-enum place_holder_in_cap_bitmap {
+enum wcn36xx_firmware_feat_caps {
 	MCC = 0,
 	P2P = 1,
 	DOT11AC = 2,
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index e34d3d0b7082..efd776b20e60 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -260,7 +260,7 @@ static const char * const wcn36xx_caps_names[] = {
 
 #undef DEFINE
 
-static const char *wcn36xx_get_cap_name(enum place_holder_in_cap_bitmap x)
+static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
 {
 	if (x >= ARRAY_SIZE(wcn36xx_caps_names))
 		return "UNKNOWN";
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 7ac9a1e6f768..88ee92be8562 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2431,7 +2431,7 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 	return ret;
 }
 
-void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
@@ -2445,7 +2445,7 @@ void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
 	bitmap[arr_idx] |= (1 << bit_idx);
 }
 
-int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
@@ -2460,7 +2460,7 @@ int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
 	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
 }
 
-void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 3fd598ac2a27..186dad4fe80e 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -125,9 +125,9 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
 int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 			     u32 arg3, u32 arg4, u32 arg5);
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
-void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
-int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
-void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
+void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
+int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
+void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
 
 int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
 		struct ieee80211_sta *sta,
-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 05:15:58 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 13:15:58 +0100
Subject: [PATCH 2/4] wcn36xx: Move firmware feature bit storage to dedicated firmware.c file
In-Reply-To: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
References: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719121600.1847440-3-bryan.odonoghue@linaro.org>

The naming of the get/set/clear firmware feature capability bits doesn't
really follow the established namespace pattern of
wcn36xx_logicalblock_do_something();

The feature bits are accessed by smd.c and main.c. It would be nice to
display the found feature bits in debugfs. To do so though we should tidy
up the namespace a bit.

Move the firmware feature exchange API to its own file - firmware.c giving
us the opportunity to functionally decompose other firmware related
accessors as appropriate in future.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/Makefile   |  3 +-
 drivers/net/wireless/ath/wcn36xx/firmware.c | 50 +++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h | 82 +++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/hal.h      | 68 -----------------
 drivers/net/wireless/ath/wcn36xx/main.c     |  7 +-
 drivers/net/wireless/ath/wcn36xx/smd.c      | 57 ++------------
 drivers/net/wireless/ath/wcn36xx/smd.h      |  3 -
 7 files changed, 146 insertions(+), 124 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h

diff --git a/drivers/net/wireless/ath/wcn36xx/Makefile b/drivers/net/wireless/ath/wcn36xx/Makefile
index 27413703ad69..26bec795b372 100644
--- a/drivers/net/wireless/ath/wcn36xx/Makefile
+++ b/drivers/net/wireless/ath/wcn36xx/Makefile
@@ -5,6 +5,7 @@ wcn36xx-y +=   main.o \
                txrx.o \
                smd.o \
                pmc.o \
-               debug.o
+               debug.o \
+               firmware.o
 
 wcn36xx-$(CONFIG_NL80211_TESTMODE) += testmode.o
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
new file mode 100644
index 000000000000..03b93d2bdcf9
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include "wcn36xx.h"
+#include "firmware.h"
+
+void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
+				    enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+	bitmap[arr_idx] |= (1 << bit_idx);
+}
+
+int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
+				   enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return -EINVAL;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+
+	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
+}
+
+void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
+				      enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+	bitmap[arr_idx] &= ~(1 << bit_idx);
+}
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
new file mode 100644
index 000000000000..552c0e9325e1
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _FIRMWARE_H_
+#define _FIRMWARE_H_
+
+/* Capability bitmap exchange definitions and macros starts */
+
+enum wcn36xx_firmware_feat_caps {
+	MCC = 0,
+	P2P = 1,
+	DOT11AC = 2,
+	SLM_SESSIONIZATION = 3,
+	DOT11AC_OPMODE = 4,
+	SAP32STA = 5,
+	TDLS = 6,
+	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
+	WLANACTIVE_OFFLOAD = 8,
+	BEACON_OFFLOAD = 9,
+	SCAN_OFFLOAD = 10,
+	ROAM_OFFLOAD = 11,
+	BCN_MISS_OFFLOAD = 12,
+	STA_POWERSAVE = 13,
+	STA_ADVANCED_PWRSAVE = 14,
+	AP_UAPSD = 15,
+	AP_DFS = 16,
+	BLOCKACK = 17,
+	PHY_ERR = 18,
+	BCN_FILTER = 19,
+	RTT = 20,
+	RATECTRL = 21,
+	WOW = 22,
+	WLAN_ROAM_SCAN_OFFLOAD = 23,
+	SPECULATIVE_PS_POLL = 24,
+	SCAN_SCH = 25,
+	IBSS_HEARTBEAT_OFFLOAD = 26,
+	WLAN_SCAN_OFFLOAD = 27,
+	WLAN_PERIODIC_TX_PTRN = 28,
+	ADVANCE_TDLS = 29,
+	BATCH_SCAN = 30,
+	FW_IN_TX_PATH = 31,
+	EXTENDED_NSOFFLOAD_SLOT = 32,
+	CH_SWITCH_V1 = 33,
+	HT40_OBSS_SCAN = 34,
+	UPDATE_CHANNEL_LIST = 35,
+	WLAN_MCADDR_FLT = 36,
+	WLAN_CH144 = 37,
+	NAN = 38,
+	TDLS_SCAN_COEXISTENCE = 39,
+	LINK_LAYER_STATS_MEAS = 40,
+	MU_MIMO = 41,
+	EXTENDED_SCAN = 42,
+	DYNAMIC_WMM_PS = 43,
+	MAC_SPOOFED_SCAN = 44,
+	BMU_ERROR_GENERIC_RECOVERY = 45,
+	DISA = 46,
+	FW_STATS = 47,
+	WPS_PRBRSP_TMPL = 48,
+	BCN_IE_FLT_DELTA = 49,
+	TDLS_OFF_CHANNEL = 51,
+	RTT3 = 52,
+	MGMT_FRAME_LOGGING = 53,
+	ENHANCED_TXBD_COMPLETION = 54,
+	LOGGING_ENHANCEMENT = 55,
+	EXT_SCAN_ENHANCED = 56,
+	MEMORY_DUMP_SUPPORTED = 57,
+	PER_PKT_STATS_SUPPORTED = 58,
+	EXT_LL_STAT = 60,
+	WIFI_CONFIG = 61,
+	ANTENNA_DIVERSITY_SELECTION = 62,
+
+	MAX_FEATURE_SUPPORTED = 128,
+};
+
+void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
+				    enum wcn36xx_firmware_feat_caps cap);
+int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
+				   enum wcn36xx_firmware_feat_caps cap);
+void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
+				      enum wcn36xx_firmware_feat_caps cap);
+
+#endif /* _FIRMWARE_H_ */
+
diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 5e48c97682c2..5c45b23c7880 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4758,74 +4758,6 @@ struct wcn36xx_hal_set_power_params_resp {
 	u32 status;
 } __packed;
 
-/* Capability bitmap exchange definitions and macros starts */
-
-enum wcn36xx_firmware_feat_caps {
-	MCC = 0,
-	P2P = 1,
-	DOT11AC = 2,
-	SLM_SESSIONIZATION = 3,
-	DOT11AC_OPMODE = 4,
-	SAP32STA = 5,
-	TDLS = 6,
-	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
-	WLANACTIVE_OFFLOAD = 8,
-	BEACON_OFFLOAD = 9,
-	SCAN_OFFLOAD = 10,
-	ROAM_OFFLOAD = 11,
-	BCN_MISS_OFFLOAD = 12,
-	STA_POWERSAVE = 13,
-	STA_ADVANCED_PWRSAVE = 14,
-	AP_UAPSD = 15,
-	AP_DFS = 16,
-	BLOCKACK = 17,
-	PHY_ERR = 18,
-	BCN_FILTER = 19,
-	RTT = 20,
-	RATECTRL = 21,
-	WOW = 22,
-	WLAN_ROAM_SCAN_OFFLOAD = 23,
-	SPECULATIVE_PS_POLL = 24,
-	SCAN_SCH = 25,
-	IBSS_HEARTBEAT_OFFLOAD = 26,
-	WLAN_SCAN_OFFLOAD = 27,
-	WLAN_PERIODIC_TX_PTRN = 28,
-	ADVANCE_TDLS = 29,
-	BATCH_SCAN = 30,
-	FW_IN_TX_PATH = 31,
-	EXTENDED_NSOFFLOAD_SLOT = 32,
-	CH_SWITCH_V1 = 33,
-	HT40_OBSS_SCAN = 34,
-	UPDATE_CHANNEL_LIST = 35,
-	WLAN_MCADDR_FLT = 36,
-	WLAN_CH144 = 37,
-	NAN = 38,
-	TDLS_SCAN_COEXISTENCE = 39,
-	LINK_LAYER_STATS_MEAS = 40,
-	MU_MIMO = 41,
-	EXTENDED_SCAN = 42,
-	DYNAMIC_WMM_PS = 43,
-	MAC_SPOOFED_SCAN = 44,
-	BMU_ERROR_GENERIC_RECOVERY = 45,
-	DISA = 46,
-	FW_STATS = 47,
-	WPS_PRBRSP_TMPL = 48,
-	BCN_IE_FLT_DELTA = 49,
-	TDLS_OFF_CHANNEL = 51,
-	RTT3 = 52,
-	MGMT_FRAME_LOGGING = 53,
-	ENHANCED_TXBD_COMPLETION = 54,
-	LOGGING_ENHANCEMENT = 55,
-	EXT_SCAN_ENHANCED = 56,
-	MEMORY_DUMP_SUPPORTED = 57,
-	PER_PKT_STATS_SUPPORTED = 58,
-	EXT_LL_STAT = 60,
-	WIFI_CONFIG = 61,
-	ANTENNA_DIVERSITY_SELECTION = 62,
-
-	MAX_FEATURE_SUPPORTED = 128,
-};
-
 #define WCN36XX_HAL_CAPS_SIZE 4
 
 struct wcn36xx_hal_feat_caps_msg {
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index efd776b20e60..af62911a4659 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -28,6 +28,7 @@
 #include <net/ipv6.h>
 #include "wcn36xx.h"
 #include "testmode.h"
+#include "firmware.h"
 
 unsigned int wcn36xx_dbg_mask;
 module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
@@ -272,7 +273,7 @@ static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
 	int i;
 
 	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
-		if (get_feat_caps(wcn->fw_feat_caps, i))
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
 			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
 	}
 }
@@ -705,7 +706,7 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
 {
 	struct wcn36xx *wcn = hw->priv;
 
-	if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+	if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
 		/* fallback to mac80211 software scan */
 		return 1;
 	}
@@ -743,7 +744,7 @@ static void wcn36xx_cancel_hw_scan(struct ieee80211_hw *hw,
 	wcn->scan_aborted = true;
 	mutex_unlock(&wcn->scan_lock);
 
-	if (get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+	if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
 		/* ieee80211_scan_completed will be called on FW scan
 		 * indication */
 		wcn36xx_smd_stop_hw_scan(wcn);
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 88ee92be8562..d2a994fee812 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -22,6 +22,7 @@
 #include <linux/bitops.h>
 #include <linux/rpmsg.h>
 #include "smd.h"
+#include "firmware.h"
 
 struct wcn36xx_cfg_val {
 	u32 cfg_id;
@@ -295,7 +296,7 @@ static void wcn36xx_smd_set_sta_vht_params(struct wcn36xx *wcn,
 		sta_params->vht_capable = sta->deflink.vht_cap.vht_supported;
 		sta_params->vht_ldpc_enabled =
 			is_cap_supported(caps, IEEE80211_VHT_CAP_RXLDPC);
-		if (get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
 			sta_params->vht_tx_mu_beamformee_capable =
 				is_cap_supported(caps, IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
 			if (sta_params->vht_tx_mu_beamformee_capable)
@@ -2431,49 +2432,6 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 	return ret;
 }
 
-void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-	bitmap[arr_idx] |= (1 << bit_idx);
-}
-
-int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return -EINVAL;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-
-	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
-}
-
-void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-	bitmap[arr_idx] &= ~(1 << bit_idx);
-}
-
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
 {
 	struct wcn36xx_hal_feat_caps_msg msg_body, *rsp;
@@ -2482,11 +2440,12 @@ int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
 	mutex_lock(&wcn->hal_mutex);
 	INIT_HAL_MSG(msg_body, WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_REQ);
 
-	set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
+	wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
 	if (wcn->rf_id == RF_IRIS_WCN3680) {
-		set_feat_caps(msg_body.feat_caps, DOT11AC);
-		set_feat_caps(msg_body.feat_caps, WLAN_CH144);
-		set_feat_caps(msg_body.feat_caps, ANTENNA_DIVERSITY_SELECTION);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, DOT11AC);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, WLAN_CH144);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps,
+					       ANTENNA_DIVERSITY_SELECTION);
 	}
 
 	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
@@ -3300,7 +3259,7 @@ int wcn36xx_smd_add_beacon_filter(struct wcn36xx *wcn,
 	size_t payload_size;
 	int ret;
 
-	if (!get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
+	if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&wcn->hal_mutex);
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 186dad4fe80e..cf15cde2a364 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -125,9 +125,6 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
 int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 			     u32 arg3, u32 arg4, u32 arg5);
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
-void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
-int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
-void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
 
 int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
 		struct ieee80211_sta *sta,
-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 05:15:59 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 13:15:59 +0100
Subject: [PATCH 3/4] wcn36xx: Move capability bitmap to string translation function to firmware.c
In-Reply-To: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
References: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719121600.1847440-4-bryan.odonoghue@linaro.org>

Move wcn36xx_get_cap_name() function in main.c into firmware.c as
wcn36xx_firmware_get_cap_name().

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/firmware.c | 75 +++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h |  2 +
 drivers/net/wireless/ath/wcn36xx/main.c     | 81 +--------------------
 3 files changed, 81 insertions(+), 77 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
index 03b93d2bdcf9..4b7f439e4db5 100644
--- a/drivers/net/wireless/ath/wcn36xx/firmware.c
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
@@ -3,6 +3,81 @@
 #include "wcn36xx.h"
 #include "firmware.h"
 
+#define DEFINE(s)[s] = #s
+
+static const char * const wcn36xx_firmware_caps_names[] = {
+	DEFINE(MCC),
+	DEFINE(P2P),
+	DEFINE(DOT11AC),
+	DEFINE(SLM_SESSIONIZATION),
+	DEFINE(DOT11AC_OPMODE),
+	DEFINE(SAP32STA),
+	DEFINE(TDLS),
+	DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
+	DEFINE(WLANACTIVE_OFFLOAD),
+	DEFINE(BEACON_OFFLOAD),
+	DEFINE(SCAN_OFFLOAD),
+	DEFINE(ROAM_OFFLOAD),
+	DEFINE(BCN_MISS_OFFLOAD),
+	DEFINE(STA_POWERSAVE),
+	DEFINE(STA_ADVANCED_PWRSAVE),
+	DEFINE(AP_UAPSD),
+	DEFINE(AP_DFS),
+	DEFINE(BLOCKACK),
+	DEFINE(PHY_ERR),
+	DEFINE(BCN_FILTER),
+	DEFINE(RTT),
+	DEFINE(RATECTRL),
+	DEFINE(WOW),
+	DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
+	DEFINE(SPECULATIVE_PS_POLL),
+	DEFINE(SCAN_SCH),
+	DEFINE(IBSS_HEARTBEAT_OFFLOAD),
+	DEFINE(WLAN_SCAN_OFFLOAD),
+	DEFINE(WLAN_PERIODIC_TX_PTRN),
+	DEFINE(ADVANCE_TDLS),
+	DEFINE(BATCH_SCAN),
+	DEFINE(FW_IN_TX_PATH),
+	DEFINE(EXTENDED_NSOFFLOAD_SLOT),
+	DEFINE(CH_SWITCH_V1),
+	DEFINE(HT40_OBSS_SCAN),
+	DEFINE(UPDATE_CHANNEL_LIST),
+	DEFINE(WLAN_MCADDR_FLT),
+	DEFINE(WLAN_CH144),
+	DEFINE(NAN),
+	DEFINE(TDLS_SCAN_COEXISTENCE),
+	DEFINE(LINK_LAYER_STATS_MEAS),
+	DEFINE(MU_MIMO),
+	DEFINE(EXTENDED_SCAN),
+	DEFINE(DYNAMIC_WMM_PS),
+	DEFINE(MAC_SPOOFED_SCAN),
+	DEFINE(BMU_ERROR_GENERIC_RECOVERY),
+	DEFINE(DISA),
+	DEFINE(FW_STATS),
+	DEFINE(WPS_PRBRSP_TMPL),
+	DEFINE(BCN_IE_FLT_DELTA),
+	DEFINE(TDLS_OFF_CHANNEL),
+	DEFINE(RTT3),
+	DEFINE(MGMT_FRAME_LOGGING),
+	DEFINE(ENHANCED_TXBD_COMPLETION),
+	DEFINE(LOGGING_ENHANCEMENT),
+	DEFINE(EXT_SCAN_ENHANCED),
+	DEFINE(MEMORY_DUMP_SUPPORTED),
+	DEFINE(PER_PKT_STATS_SUPPORTED),
+	DEFINE(EXT_LL_STAT),
+	DEFINE(WIFI_CONFIG),
+	DEFINE(ANTENNA_DIVERSITY_SELECTION),
+};
+
+#undef DEFINE
+
+const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x)
+{
+	if (x >= ARRAY_SIZE(wcn36xx_firmware_caps_names))
+		return "UNKNOWN";
+	return wcn36xx_firmware_caps_names[x];
+}
+
 void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
 				    enum wcn36xx_firmware_feat_caps cap)
 {
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
index 552c0e9325e1..f991cf959f82 100644
--- a/drivers/net/wireless/ath/wcn36xx/firmware.h
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
@@ -78,5 +78,7 @@ int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
 void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
 				      enum wcn36xx_firmware_feat_caps cap);
 
+const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x);
+
 #endif /* _FIRMWARE_H_ */
 
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index af62911a4659..fec85e89a02f 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -193,88 +193,15 @@ static inline u8 get_sta_index(struct ieee80211_vif *vif,
 	       sta_priv->sta_index;
 }
 
-#define DEFINE(s) [s] = #s
-
-static const char * const wcn36xx_caps_names[] = {
-	DEFINE(MCC),
-	DEFINE(P2P),
-	DEFINE(DOT11AC),
-	DEFINE(SLM_SESSIONIZATION),
-	DEFINE(DOT11AC_OPMODE),
-	DEFINE(SAP32STA),
-	DEFINE(TDLS),
-	DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
-	DEFINE(WLANACTIVE_OFFLOAD),
-	DEFINE(BEACON_OFFLOAD),
-	DEFINE(SCAN_OFFLOAD),
-	DEFINE(ROAM_OFFLOAD),
-	DEFINE(BCN_MISS_OFFLOAD),
-	DEFINE(STA_POWERSAVE),
-	DEFINE(STA_ADVANCED_PWRSAVE),
-	DEFINE(AP_UAPSD),
-	DEFINE(AP_DFS),
-	DEFINE(BLOCKACK),
-	DEFINE(PHY_ERR),
-	DEFINE(BCN_FILTER),
-	DEFINE(RTT),
-	DEFINE(RATECTRL),
-	DEFINE(WOW),
-	DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
-	DEFINE(SPECULATIVE_PS_POLL),
-	DEFINE(SCAN_SCH),
-	DEFINE(IBSS_HEARTBEAT_OFFLOAD),
-	DEFINE(WLAN_SCAN_OFFLOAD),
-	DEFINE(WLAN_PERIODIC_TX_PTRN),
-	DEFINE(ADVANCE_TDLS),
-	DEFINE(BATCH_SCAN),
-	DEFINE(FW_IN_TX_PATH),
-	DEFINE(EXTENDED_NSOFFLOAD_SLOT),
-	DEFINE(CH_SWITCH_V1),
-	DEFINE(HT40_OBSS_SCAN),
-	DEFINE(UPDATE_CHANNEL_LIST),
-	DEFINE(WLAN_MCADDR_FLT),
-	DEFINE(WLAN_CH144),
-	DEFINE(NAN),
-	DEFINE(TDLS_SCAN_COEXISTENCE),
-	DEFINE(LINK_LAYER_STATS_MEAS),
-	DEFINE(MU_MIMO),
-	DEFINE(EXTENDED_SCAN),
-	DEFINE(DYNAMIC_WMM_PS),
-	DEFINE(MAC_SPOOFED_SCAN),
-	DEFINE(BMU_ERROR_GENERIC_RECOVERY),
-	DEFINE(DISA),
-	DEFINE(FW_STATS),
-	DEFINE(WPS_PRBRSP_TMPL),
-	DEFINE(BCN_IE_FLT_DELTA),
-	DEFINE(TDLS_OFF_CHANNEL),
-	DEFINE(RTT3),
-	DEFINE(MGMT_FRAME_LOGGING),
-	DEFINE(ENHANCED_TXBD_COMPLETION),
-	DEFINE(LOGGING_ENHANCEMENT),
-	DEFINE(EXT_SCAN_ENHANCED),
-	DEFINE(MEMORY_DUMP_SUPPORTED),
-	DEFINE(PER_PKT_STATS_SUPPORTED),
-	DEFINE(EXT_LL_STAT),
-	DEFINE(WIFI_CONFIG),
-	DEFINE(ANTENNA_DIVERSITY_SELECTION),
-};
-
-#undef DEFINE
-
-static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
-{
-	if (x >= ARRAY_SIZE(wcn36xx_caps_names))
-		return "UNKNOWN";
-	return wcn36xx_caps_names[x];
-}
-
 static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
 {
 	int i;
 
 	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
-		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
-			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
+			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n",
+				    wcn36xx_firmware_get_cap_name(i));
+		}
 	}
 }
 
-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 05:16:00 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 13:16:00 +0100
Subject: [PATCH 4/4] wcn36xx: Add debugfs entry to read firmware feature strings
In-Reply-To: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
References: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719121600.1847440-5-bryan.odonoghue@linaro.org>

Add in the ability to easily find the firmware feature bits reported in the
get feature exchange without having to compile-in debug prints.

root at linaro-alip:~# cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps
FW Cap = MCC
FW Cap = P2P
FW Cap = DOT11AC
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = MU_MIMO
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/debug.c | 37 ++++++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/debug.h |  1 +
 2 files changed, 38 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
index 6af306ae41ad..ca6f22a00f75 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.c
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -21,6 +21,7 @@
 #include "wcn36xx.h"
 #include "debug.h"
 #include "pmc.h"
+#include "firmware.h"
 
 #ifdef CONFIG_WCN36XX_DEBUGFS
 
@@ -136,6 +137,40 @@ static const struct file_operations fops_wcn36xx_dump = {
 	.write =       write_file_dump,
 };
 
+static ssize_t read_file_firmware_feature_caps(struct file *file,
+					       char __user *user_buf,
+					       size_t count, loff_t *ppos)
+{
+	struct wcn36xx *wcn = file->private_data;
+	unsigned long page = get_zeroed_page(GFP_KERNEL);
+	char *p = (char *)page;
+	int i;
+	int ret;
+
+	if (!p)
+		return -ENOMEM;
+
+	mutex_lock(&wcn->hal_mutex);
+	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
+			p += sprintf(p, "FW Cap = %s\n",
+				     wcn36xx_firmware_get_cap_name(i));
+		}
+	}
+	mutex_unlock(&wcn->hal_mutex);
+
+	ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
+				      (unsigned long)p - page);
+
+	free_page(page);
+	return ret;
+}
+
+static const struct file_operations fops_wcn36xx_firmware_feat_caps = {
+	.open = simple_open,
+	.read = read_file_firmware_feature_caps,
+};
+
 #define ADD_FILE(name, mode, fop, priv_data)		\
 	do {							\
 		struct dentry *d;				\
@@ -163,6 +198,8 @@ void wcn36xx_debugfs_init(struct wcn36xx *wcn)
 
 	ADD_FILE(bmps_switcher, 0600, &fops_wcn36xx_bmps, wcn);
 	ADD_FILE(dump, 0200, &fops_wcn36xx_dump, wcn);
+	ADD_FILE(firmware_feat_caps, 0200,
+		 &fops_wcn36xx_firmware_feat_caps, wcn);
 }
 
 void wcn36xx_debugfs_exit(struct wcn36xx *wcn)
diff --git a/drivers/net/wireless/ath/wcn36xx/debug.h b/drivers/net/wireless/ath/wcn36xx/debug.h
index 46307aa562d3..7116d96e0543 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.h
+++ b/drivers/net/wireless/ath/wcn36xx/debug.h
@@ -31,6 +31,7 @@ struct wcn36xx_dfs_entry {
 	struct dentry *rootdir;
 	struct wcn36xx_dfs_file file_bmps_switcher;
 	struct wcn36xx_dfs_file file_dump;
+	struct wcn36xx_dfs_file file_firmware_feat_caps;
 };
 
 void wcn36xx_debugfs_init(struct wcn36xx *wcn);
-- 
2.36.1



From loic.poulain at linaro.org  Tue Jul 19 06:06:45 2022
From: loic.poulain at linaro.org (Loic Poulain)
Date: Tue, 19 Jul 2022 15:06:45 +0200
Subject: [PATCH 0/4] wcn36xx: Add in debugfs export of firmware feature bits
In-Reply-To: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
References: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
Message-ID: <CAMZdPi-TUafosjJ_pwQ4F-N3WnnM5_0P7snB1qmgmzBeqkZu3A@mail.gmail.com>

On Tue, 19 Jul 2022 at 14:16, Bryan O'Donoghue
<bryan.odonoghue at linaro.org> wrote:
>
> This series tidies up the code to get/set/clear discovered firmware feature
> bits and adds a new debugfs entry to read the feature bits as strings.
>
> cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps
>
> wcn3680b:
> FW Cap = MCC

Nice, but why prepending with 'FW Cap = ' string, we already know it's
a list of firmware features.


> FW Cap = P2P
> FW Cap = DOT11AC
> FW Cap = SLM_SESSIONIZATION
> FW Cap = DOT11AC_OPMODE
> FW Cap = SAP32STA
> FW Cap = TDLS


From bryan.odonoghue at linaro.org  Tue Jul 19 06:39:30 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 14:39:30 +0100
Subject: [PATCH 0/4] wcn36xx: Add in debugfs export of firmware feature
 bits
In-Reply-To: <CAMZdPi-TUafosjJ_pwQ4F-N3WnnM5_0P7snB1qmgmzBeqkZu3A@mail.gmail.com>
References: <20220719121600.1847440-1-bryan.odonoghue@linaro.org>
 <CAMZdPi-TUafosjJ_pwQ4F-N3WnnM5_0P7snB1qmgmzBeqkZu3A@mail.gmail.com>
Message-ID: <6a20c273-d6f3-4e69-3de6-9d6b44a1b29d@linaro.org>

On 19/07/2022 14:06, Loic Poulain wrote:
> Nice, but why prepending with 'FW Cap = ' string, we already know it's
> a list of firmware features.

I literally just copied the debug printout which also prefixes with FW Cap..

I can drop


From bryan.odonoghue at linaro.org  Tue Jul 19 07:32:58 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 15:32:58 +0100
Subject: [PATCH v2 0/4] wcn36xx: Add in debugfs export of firmware feature bits
Message-ID: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>

V2:
Drops "FW Cap = " prefix from each feature item - Loic

cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps 
MCC
P2P
DOT11AC
SLM_SESSIONIZATION
DOT11AC_OPMODE
SAP32STA
TDLS
P2P_GO_NOA_DECOUPLE_INIT_SCAN
WLANACTIVE_OFFLOAD
BEACON_OFFLOAD
SCAN_OFFLOAD
BCN_MISS_OFFLOAD
STA_POWERSAVE
STA_ADVANCED_PWRSAVE
BCN_FILTER
RTT
RATECTRL
WOW
WLAN_ROAM_SCAN_OFFLOAD
SPECULATIVE_PS_POLL
IBSS_HEARTBEAT_OFFLOAD
WLAN_SCAN_OFFLOAD
WLAN_PERIODIC_TX_PTRN
ADVANCE_TDLS
BATCH_SCAN
FW_IN_TX_PATH
EXTENDED_NSOFFLOAD_SLOT
CH_SWITCH_V1
HT40_OBSS_SCAN
UPDATE_CHANNEL_LIST
WLAN_MCADDR_FLT
WLAN_CH144
TDLS_SCAN_COEXISTENCE
LINK_LAYER_STATS_MEAS
MU_MIMO
EXTENDED_SCAN
DYNAMIC_WMM_PS
MAC_SPOOFED_SCAN
FW_STATS
WPS_PRBRSP_TMPL
BCN_IE_FLT_DELTA

V1:
This series tidies up the code to get/set/clear discovered firmware feature
bits and adds a new debugfs entry to read the feature bits as strings.

cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps

wcn3680b:
FW Cap = MCC
FW Cap = P2P
FW Cap = DOT11AC
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = MU_MIMO
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

wcn3620:
FW Cap = MCC
FW Cap = P2P
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

This is a handy way of debugging WiFi on different platforms without
necessarily having to recompile to see the debug printout on firmware boot.

Bryan O'Donoghue (4):
  wcn36xx: Rename clunky firmware feature bit enum
  wcn36xx: Move firmware feature bit storage to dedicated firmware.c
    file
  wcn36xx: Move capability bitmap to string translation function to
    firmware.c
  wcn36xx: Add debugfs entry to read firmware feature strings

 drivers/net/wireless/ath/wcn36xx/Makefile   |   3 +-
 drivers/net/wireless/ath/wcn36xx/debug.c    |  37 ++++++
 drivers/net/wireless/ath/wcn36xx/debug.h    |   1 +
 drivers/net/wireless/ath/wcn36xx/firmware.c | 125 ++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h |  84 +++++++++++++
 drivers/net/wireless/ath/wcn36xx/hal.h      |  68 -----------
 drivers/net/wireless/ath/wcn36xx/main.c     |  86 ++------------
 drivers/net/wireless/ath/wcn36xx/smd.c      |  57 ++-------
 drivers/net/wireless/ath/wcn36xx/smd.h      |   3 -
 9 files changed, 264 insertions(+), 200 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h

-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 07:32:59 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 15:32:59 +0100
Subject: [PATCH v2 1/4] wcn36xx: Rename clunky firmware feature bit enum
In-Reply-To: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719143302.2071223-2-bryan.odonoghue@linaro.org>

The enum name "place_holder_in_cap_bitmap" is self descriptively asking to
be changed to something else.

Rename place_holder_in_cap_bitmap to wcn36xx_firmware_feat_caps so that the
contents and intent of the enum is obvious.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/hal.h  | 2 +-
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 drivers/net/wireless/ath/wcn36xx/smd.c  | 6 +++---
 drivers/net/wireless/ath/wcn36xx/smd.h  | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 46a49f0a51b3..5e48c97682c2 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4760,7 +4760,7 @@ struct wcn36xx_hal_set_power_params_resp {
 
 /* Capability bitmap exchange definitions and macros starts */
 
-enum place_holder_in_cap_bitmap {
+enum wcn36xx_firmware_feat_caps {
 	MCC = 0,
 	P2P = 1,
 	DOT11AC = 2,
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index e34d3d0b7082..efd776b20e60 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -260,7 +260,7 @@ static const char * const wcn36xx_caps_names[] = {
 
 #undef DEFINE
 
-static const char *wcn36xx_get_cap_name(enum place_holder_in_cap_bitmap x)
+static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
 {
 	if (x >= ARRAY_SIZE(wcn36xx_caps_names))
 		return "UNKNOWN";
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 7ac9a1e6f768..88ee92be8562 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2431,7 +2431,7 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 	return ret;
 }
 
-void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
@@ -2445,7 +2445,7 @@ void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
 	bitmap[arr_idx] |= (1 << bit_idx);
 }
 
-int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
@@ -2460,7 +2460,7 @@ int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
 	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
 }
 
-void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 3fd598ac2a27..186dad4fe80e 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -125,9 +125,9 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
 int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 			     u32 arg3, u32 arg4, u32 arg5);
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
-void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
-int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
-void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
+void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
+int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
+void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
 
 int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
 		struct ieee80211_sta *sta,
-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 07:33:02 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 15:33:02 +0100
Subject: [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware feature strings
In-Reply-To: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719143302.2071223-5-bryan.odonoghue@linaro.org>

Add in the ability to easily find the firmware feature bits reported in the
get feature exchange without having to compile-in debug prints.

root at linaro-alip:~# cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps
MCC
P2P
DOT11AC
SLM_SESSIONIZATION
DOT11AC_OPMODE
SAP32STA
TDLS
P2P_GO_NOA_DECOUPLE_INIT_SCAN
WLANACTIVE_OFFLOAD
BEACON_OFFLOAD
SCAN_OFFLOAD
BCN_MISS_OFFLOAD
STA_POWERSAVE
STA_ADVANCED_PWRSAVE
BCN_FILTER
RTT
RATECTRL
WOW
WLAN_ROAM_SCAN_OFFLOAD
SPECULATIVE_PS_POLL
IBSS_HEARTBEAT_OFFLOAD
WLAN_SCAN_OFFLOAD
WLAN_PERIODIC_TX_PTRN
ADVANCE_TDLS
BATCH_SCAN
FW_IN_TX_PATH
EXTENDED_NSOFFLOAD_SLOT
CH_SWITCH_V1
HT40_OBSS_SCAN
UPDATE_CHANNEL_LIST
WLAN_MCADDR_FLT
WLAN_CH144
TDLS_SCAN_COEXISTENCE
LINK_LAYER_STATS_MEAS
MU_MIMO
EXTENDED_SCAN
DYNAMIC_WMM_PS
MAC_SPOOFED_SCAN
FW_STATS
WPS_PRBRSP_TMPL
BCN_IE_FLT_DELTA

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/debug.c | 37 ++++++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/debug.h |  1 +
 2 files changed, 38 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
index 6af306ae41ad..220f338045bd 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.c
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -21,6 +21,7 @@
 #include "wcn36xx.h"
 #include "debug.h"
 #include "pmc.h"
+#include "firmware.h"
 
 #ifdef CONFIG_WCN36XX_DEBUGFS
 
@@ -136,6 +137,40 @@ static const struct file_operations fops_wcn36xx_dump = {
 	.write =       write_file_dump,
 };
 
+static ssize_t read_file_firmware_feature_caps(struct file *file,
+					       char __user *user_buf,
+					       size_t count, loff_t *ppos)
+{
+	struct wcn36xx *wcn = file->private_data;
+	unsigned long page = get_zeroed_page(GFP_KERNEL);
+	char *p = (char *)page;
+	int i;
+	int ret;
+
+	if (!p)
+		return -ENOMEM;
+
+	mutex_lock(&wcn->hal_mutex);
+	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
+			p += sprintf(p, "%s\n",
+				     wcn36xx_firmware_get_cap_name(i));
+		}
+	}
+	mutex_unlock(&wcn->hal_mutex);
+
+	ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
+				      (unsigned long)p - page);
+
+	free_page(page);
+	return ret;
+}
+
+static const struct file_operations fops_wcn36xx_firmware_feat_caps = {
+	.open = simple_open,
+	.read = read_file_firmware_feature_caps,
+};
+
 #define ADD_FILE(name, mode, fop, priv_data)		\
 	do {							\
 		struct dentry *d;				\
@@ -163,6 +198,8 @@ void wcn36xx_debugfs_init(struct wcn36xx *wcn)
 
 	ADD_FILE(bmps_switcher, 0600, &fops_wcn36xx_bmps, wcn);
 	ADD_FILE(dump, 0200, &fops_wcn36xx_dump, wcn);
+	ADD_FILE(firmware_feat_caps, 0200,
+		 &fops_wcn36xx_firmware_feat_caps, wcn);
 }
 
 void wcn36xx_debugfs_exit(struct wcn36xx *wcn)
diff --git a/drivers/net/wireless/ath/wcn36xx/debug.h b/drivers/net/wireless/ath/wcn36xx/debug.h
index 46307aa562d3..7116d96e0543 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.h
+++ b/drivers/net/wireless/ath/wcn36xx/debug.h
@@ -31,6 +31,7 @@ struct wcn36xx_dfs_entry {
 	struct dentry *rootdir;
 	struct wcn36xx_dfs_file file_bmps_switcher;
 	struct wcn36xx_dfs_file file_dump;
+	struct wcn36xx_dfs_file file_firmware_feat_caps;
 };
 
 void wcn36xx_debugfs_init(struct wcn36xx *wcn);
-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 07:33:00 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 15:33:00 +0100
Subject: [PATCH v2 2/4] wcn36xx: Move firmware feature bit storage to dedicated firmware.c file
In-Reply-To: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719143302.2071223-3-bryan.odonoghue@linaro.org>

The naming of the get/set/clear firmware feature capability bits doesn't
really follow the established namespace pattern of
wcn36xx_logicalblock_do_something();

The feature bits are accessed by smd.c and main.c. It would be nice to
display the found feature bits in debugfs. To do so though we should tidy
up the namespace a bit.

Move the firmware feature exchange API to its own file - firmware.c giving
us the opportunity to functionally decompose other firmware related
accessors as appropriate in future.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/Makefile   |  3 +-
 drivers/net/wireless/ath/wcn36xx/firmware.c | 50 +++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h | 82 +++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/hal.h      | 68 -----------------
 drivers/net/wireless/ath/wcn36xx/main.c     |  7 +-
 drivers/net/wireless/ath/wcn36xx/smd.c      | 57 ++------------
 drivers/net/wireless/ath/wcn36xx/smd.h      |  3 -
 7 files changed, 146 insertions(+), 124 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h

diff --git a/drivers/net/wireless/ath/wcn36xx/Makefile b/drivers/net/wireless/ath/wcn36xx/Makefile
index 27413703ad69..26bec795b372 100644
--- a/drivers/net/wireless/ath/wcn36xx/Makefile
+++ b/drivers/net/wireless/ath/wcn36xx/Makefile
@@ -5,6 +5,7 @@ wcn36xx-y +=   main.o \
                txrx.o \
                smd.o \
                pmc.o \
-               debug.o
+               debug.o \
+               firmware.o
 
 wcn36xx-$(CONFIG_NL80211_TESTMODE) += testmode.o
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
new file mode 100644
index 000000000000..03b93d2bdcf9
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include "wcn36xx.h"
+#include "firmware.h"
+
+void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
+				    enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+	bitmap[arr_idx] |= (1 << bit_idx);
+}
+
+int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
+				   enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return -EINVAL;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+
+	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
+}
+
+void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
+				      enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+	bitmap[arr_idx] &= ~(1 << bit_idx);
+}
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
new file mode 100644
index 000000000000..552c0e9325e1
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _FIRMWARE_H_
+#define _FIRMWARE_H_
+
+/* Capability bitmap exchange definitions and macros starts */
+
+enum wcn36xx_firmware_feat_caps {
+	MCC = 0,
+	P2P = 1,
+	DOT11AC = 2,
+	SLM_SESSIONIZATION = 3,
+	DOT11AC_OPMODE = 4,
+	SAP32STA = 5,
+	TDLS = 6,
+	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
+	WLANACTIVE_OFFLOAD = 8,
+	BEACON_OFFLOAD = 9,
+	SCAN_OFFLOAD = 10,
+	ROAM_OFFLOAD = 11,
+	BCN_MISS_OFFLOAD = 12,
+	STA_POWERSAVE = 13,
+	STA_ADVANCED_PWRSAVE = 14,
+	AP_UAPSD = 15,
+	AP_DFS = 16,
+	BLOCKACK = 17,
+	PHY_ERR = 18,
+	BCN_FILTER = 19,
+	RTT = 20,
+	RATECTRL = 21,
+	WOW = 22,
+	WLAN_ROAM_SCAN_OFFLOAD = 23,
+	SPECULATIVE_PS_POLL = 24,
+	SCAN_SCH = 25,
+	IBSS_HEARTBEAT_OFFLOAD = 26,
+	WLAN_SCAN_OFFLOAD = 27,
+	WLAN_PERIODIC_TX_PTRN = 28,
+	ADVANCE_TDLS = 29,
+	BATCH_SCAN = 30,
+	FW_IN_TX_PATH = 31,
+	EXTENDED_NSOFFLOAD_SLOT = 32,
+	CH_SWITCH_V1 = 33,
+	HT40_OBSS_SCAN = 34,
+	UPDATE_CHANNEL_LIST = 35,
+	WLAN_MCADDR_FLT = 36,
+	WLAN_CH144 = 37,
+	NAN = 38,
+	TDLS_SCAN_COEXISTENCE = 39,
+	LINK_LAYER_STATS_MEAS = 40,
+	MU_MIMO = 41,
+	EXTENDED_SCAN = 42,
+	DYNAMIC_WMM_PS = 43,
+	MAC_SPOOFED_SCAN = 44,
+	BMU_ERROR_GENERIC_RECOVERY = 45,
+	DISA = 46,
+	FW_STATS = 47,
+	WPS_PRBRSP_TMPL = 48,
+	BCN_IE_FLT_DELTA = 49,
+	TDLS_OFF_CHANNEL = 51,
+	RTT3 = 52,
+	MGMT_FRAME_LOGGING = 53,
+	ENHANCED_TXBD_COMPLETION = 54,
+	LOGGING_ENHANCEMENT = 55,
+	EXT_SCAN_ENHANCED = 56,
+	MEMORY_DUMP_SUPPORTED = 57,
+	PER_PKT_STATS_SUPPORTED = 58,
+	EXT_LL_STAT = 60,
+	WIFI_CONFIG = 61,
+	ANTENNA_DIVERSITY_SELECTION = 62,
+
+	MAX_FEATURE_SUPPORTED = 128,
+};
+
+void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
+				    enum wcn36xx_firmware_feat_caps cap);
+int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
+				   enum wcn36xx_firmware_feat_caps cap);
+void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
+				      enum wcn36xx_firmware_feat_caps cap);
+
+#endif /* _FIRMWARE_H_ */
+
diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 5e48c97682c2..5c45b23c7880 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4758,74 +4758,6 @@ struct wcn36xx_hal_set_power_params_resp {
 	u32 status;
 } __packed;
 
-/* Capability bitmap exchange definitions and macros starts */
-
-enum wcn36xx_firmware_feat_caps {
-	MCC = 0,
-	P2P = 1,
-	DOT11AC = 2,
-	SLM_SESSIONIZATION = 3,
-	DOT11AC_OPMODE = 4,
-	SAP32STA = 5,
-	TDLS = 6,
-	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
-	WLANACTIVE_OFFLOAD = 8,
-	BEACON_OFFLOAD = 9,
-	SCAN_OFFLOAD = 10,
-	ROAM_OFFLOAD = 11,
-	BCN_MISS_OFFLOAD = 12,
-	STA_POWERSAVE = 13,
-	STA_ADVANCED_PWRSAVE = 14,
-	AP_UAPSD = 15,
-	AP_DFS = 16,
-	BLOCKACK = 17,
-	PHY_ERR = 18,
-	BCN_FILTER = 19,
-	RTT = 20,
-	RATECTRL = 21,
-	WOW = 22,
-	WLAN_ROAM_SCAN_OFFLOAD = 23,
-	SPECULATIVE_PS_POLL = 24,
-	SCAN_SCH = 25,
-	IBSS_HEARTBEAT_OFFLOAD = 26,
-	WLAN_SCAN_OFFLOAD = 27,
-	WLAN_PERIODIC_TX_PTRN = 28,
-	ADVANCE_TDLS = 29,
-	BATCH_SCAN = 30,
-	FW_IN_TX_PATH = 31,
-	EXTENDED_NSOFFLOAD_SLOT = 32,
-	CH_SWITCH_V1 = 33,
-	HT40_OBSS_SCAN = 34,
-	UPDATE_CHANNEL_LIST = 35,
-	WLAN_MCADDR_FLT = 36,
-	WLAN_CH144 = 37,
-	NAN = 38,
-	TDLS_SCAN_COEXISTENCE = 39,
-	LINK_LAYER_STATS_MEAS = 40,
-	MU_MIMO = 41,
-	EXTENDED_SCAN = 42,
-	DYNAMIC_WMM_PS = 43,
-	MAC_SPOOFED_SCAN = 44,
-	BMU_ERROR_GENERIC_RECOVERY = 45,
-	DISA = 46,
-	FW_STATS = 47,
-	WPS_PRBRSP_TMPL = 48,
-	BCN_IE_FLT_DELTA = 49,
-	TDLS_OFF_CHANNEL = 51,
-	RTT3 = 52,
-	MGMT_FRAME_LOGGING = 53,
-	ENHANCED_TXBD_COMPLETION = 54,
-	LOGGING_ENHANCEMENT = 55,
-	EXT_SCAN_ENHANCED = 56,
-	MEMORY_DUMP_SUPPORTED = 57,
-	PER_PKT_STATS_SUPPORTED = 58,
-	EXT_LL_STAT = 60,
-	WIFI_CONFIG = 61,
-	ANTENNA_DIVERSITY_SELECTION = 62,
-
-	MAX_FEATURE_SUPPORTED = 128,
-};
-
 #define WCN36XX_HAL_CAPS_SIZE 4
 
 struct wcn36xx_hal_feat_caps_msg {
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index efd776b20e60..af62911a4659 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -28,6 +28,7 @@
 #include <net/ipv6.h>
 #include "wcn36xx.h"
 #include "testmode.h"
+#include "firmware.h"
 
 unsigned int wcn36xx_dbg_mask;
 module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
@@ -272,7 +273,7 @@ static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
 	int i;
 
 	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
-		if (get_feat_caps(wcn->fw_feat_caps, i))
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
 			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
 	}
 }
@@ -705,7 +706,7 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
 {
 	struct wcn36xx *wcn = hw->priv;
 
-	if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+	if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
 		/* fallback to mac80211 software scan */
 		return 1;
 	}
@@ -743,7 +744,7 @@ static void wcn36xx_cancel_hw_scan(struct ieee80211_hw *hw,
 	wcn->scan_aborted = true;
 	mutex_unlock(&wcn->scan_lock);
 
-	if (get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+	if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
 		/* ieee80211_scan_completed will be called on FW scan
 		 * indication */
 		wcn36xx_smd_stop_hw_scan(wcn);
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 88ee92be8562..d2a994fee812 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -22,6 +22,7 @@
 #include <linux/bitops.h>
 #include <linux/rpmsg.h>
 #include "smd.h"
+#include "firmware.h"
 
 struct wcn36xx_cfg_val {
 	u32 cfg_id;
@@ -295,7 +296,7 @@ static void wcn36xx_smd_set_sta_vht_params(struct wcn36xx *wcn,
 		sta_params->vht_capable = sta->deflink.vht_cap.vht_supported;
 		sta_params->vht_ldpc_enabled =
 			is_cap_supported(caps, IEEE80211_VHT_CAP_RXLDPC);
-		if (get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
 			sta_params->vht_tx_mu_beamformee_capable =
 				is_cap_supported(caps, IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
 			if (sta_params->vht_tx_mu_beamformee_capable)
@@ -2431,49 +2432,6 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 	return ret;
 }
 
-void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-	bitmap[arr_idx] |= (1 << bit_idx);
-}
-
-int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return -EINVAL;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-
-	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
-}
-
-void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-	bitmap[arr_idx] &= ~(1 << bit_idx);
-}
-
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
 {
 	struct wcn36xx_hal_feat_caps_msg msg_body, *rsp;
@@ -2482,11 +2440,12 @@ int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
 	mutex_lock(&wcn->hal_mutex);
 	INIT_HAL_MSG(msg_body, WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_REQ);
 
-	set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
+	wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
 	if (wcn->rf_id == RF_IRIS_WCN3680) {
-		set_feat_caps(msg_body.feat_caps, DOT11AC);
-		set_feat_caps(msg_body.feat_caps, WLAN_CH144);
-		set_feat_caps(msg_body.feat_caps, ANTENNA_DIVERSITY_SELECTION);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, DOT11AC);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, WLAN_CH144);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps,
+					       ANTENNA_DIVERSITY_SELECTION);
 	}
 
 	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
@@ -3300,7 +3259,7 @@ int wcn36xx_smd_add_beacon_filter(struct wcn36xx *wcn,
 	size_t payload_size;
 	int ret;
 
-	if (!get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
+	if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&wcn->hal_mutex);
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 186dad4fe80e..cf15cde2a364 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -125,9 +125,6 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
 int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 			     u32 arg3, u32 arg4, u32 arg5);
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
-void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
-int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
-void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
 
 int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
 		struct ieee80211_sta *sta,
-- 
2.36.1



From bryan.odonoghue at linaro.org  Tue Jul 19 07:33:01 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Tue, 19 Jul 2022 15:33:01 +0100
Subject: [PATCH v2 3/4] wcn36xx: Move capability bitmap to string translation function to firmware.c
In-Reply-To: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
Message-ID: <20220719143302.2071223-4-bryan.odonoghue@linaro.org>

Move wcn36xx_get_cap_name() function in main.c into firmware.c as
wcn36xx_firmware_get_cap_name().

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/firmware.c | 75 +++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h |  2 +
 drivers/net/wireless/ath/wcn36xx/main.c     | 81 +--------------------
 3 files changed, 81 insertions(+), 77 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
index 03b93d2bdcf9..4b7f439e4db5 100644
--- a/drivers/net/wireless/ath/wcn36xx/firmware.c
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
@@ -3,6 +3,81 @@
 #include "wcn36xx.h"
 #include "firmware.h"
 
+#define DEFINE(s)[s] = #s
+
+static const char * const wcn36xx_firmware_caps_names[] = {
+	DEFINE(MCC),
+	DEFINE(P2P),
+	DEFINE(DOT11AC),
+	DEFINE(SLM_SESSIONIZATION),
+	DEFINE(DOT11AC_OPMODE),
+	DEFINE(SAP32STA),
+	DEFINE(TDLS),
+	DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
+	DEFINE(WLANACTIVE_OFFLOAD),
+	DEFINE(BEACON_OFFLOAD),
+	DEFINE(SCAN_OFFLOAD),
+	DEFINE(ROAM_OFFLOAD),
+	DEFINE(BCN_MISS_OFFLOAD),
+	DEFINE(STA_POWERSAVE),
+	DEFINE(STA_ADVANCED_PWRSAVE),
+	DEFINE(AP_UAPSD),
+	DEFINE(AP_DFS),
+	DEFINE(BLOCKACK),
+	DEFINE(PHY_ERR),
+	DEFINE(BCN_FILTER),
+	DEFINE(RTT),
+	DEFINE(RATECTRL),
+	DEFINE(WOW),
+	DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
+	DEFINE(SPECULATIVE_PS_POLL),
+	DEFINE(SCAN_SCH),
+	DEFINE(IBSS_HEARTBEAT_OFFLOAD),
+	DEFINE(WLAN_SCAN_OFFLOAD),
+	DEFINE(WLAN_PERIODIC_TX_PTRN),
+	DEFINE(ADVANCE_TDLS),
+	DEFINE(BATCH_SCAN),
+	DEFINE(FW_IN_TX_PATH),
+	DEFINE(EXTENDED_NSOFFLOAD_SLOT),
+	DEFINE(CH_SWITCH_V1),
+	DEFINE(HT40_OBSS_SCAN),
+	DEFINE(UPDATE_CHANNEL_LIST),
+	DEFINE(WLAN_MCADDR_FLT),
+	DEFINE(WLAN_CH144),
+	DEFINE(NAN),
+	DEFINE(TDLS_SCAN_COEXISTENCE),
+	DEFINE(LINK_LAYER_STATS_MEAS),
+	DEFINE(MU_MIMO),
+	DEFINE(EXTENDED_SCAN),
+	DEFINE(DYNAMIC_WMM_PS),
+	DEFINE(MAC_SPOOFED_SCAN),
+	DEFINE(BMU_ERROR_GENERIC_RECOVERY),
+	DEFINE(DISA),
+	DEFINE(FW_STATS),
+	DEFINE(WPS_PRBRSP_TMPL),
+	DEFINE(BCN_IE_FLT_DELTA),
+	DEFINE(TDLS_OFF_CHANNEL),
+	DEFINE(RTT3),
+	DEFINE(MGMT_FRAME_LOGGING),
+	DEFINE(ENHANCED_TXBD_COMPLETION),
+	DEFINE(LOGGING_ENHANCEMENT),
+	DEFINE(EXT_SCAN_ENHANCED),
+	DEFINE(MEMORY_DUMP_SUPPORTED),
+	DEFINE(PER_PKT_STATS_SUPPORTED),
+	DEFINE(EXT_LL_STAT),
+	DEFINE(WIFI_CONFIG),
+	DEFINE(ANTENNA_DIVERSITY_SELECTION),
+};
+
+#undef DEFINE
+
+const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x)
+{
+	if (x >= ARRAY_SIZE(wcn36xx_firmware_caps_names))
+		return "UNKNOWN";
+	return wcn36xx_firmware_caps_names[x];
+}
+
 void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
 				    enum wcn36xx_firmware_feat_caps cap)
 {
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
index 552c0e9325e1..f991cf959f82 100644
--- a/drivers/net/wireless/ath/wcn36xx/firmware.h
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
@@ -78,5 +78,7 @@ int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
 void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
 				      enum wcn36xx_firmware_feat_caps cap);
 
+const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x);
+
 #endif /* _FIRMWARE_H_ */
 
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index af62911a4659..fec85e89a02f 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -193,88 +193,15 @@ static inline u8 get_sta_index(struct ieee80211_vif *vif,
 	       sta_priv->sta_index;
 }
 
-#define DEFINE(s) [s] = #s
-
-static const char * const wcn36xx_caps_names[] = {
-	DEFINE(MCC),
-	DEFINE(P2P),
-	DEFINE(DOT11AC),
-	DEFINE(SLM_SESSIONIZATION),
-	DEFINE(DOT11AC_OPMODE),
-	DEFINE(SAP32STA),
-	DEFINE(TDLS),
-	DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
-	DEFINE(WLANACTIVE_OFFLOAD),
-	DEFINE(BEACON_OFFLOAD),
-	DEFINE(SCAN_OFFLOAD),
-	DEFINE(ROAM_OFFLOAD),
-	DEFINE(BCN_MISS_OFFLOAD),
-	DEFINE(STA_POWERSAVE),
-	DEFINE(STA_ADVANCED_PWRSAVE),
-	DEFINE(AP_UAPSD),
-	DEFINE(AP_DFS),
-	DEFINE(BLOCKACK),
-	DEFINE(PHY_ERR),
-	DEFINE(BCN_FILTER),
-	DEFINE(RTT),
-	DEFINE(RATECTRL),
-	DEFINE(WOW),
-	DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
-	DEFINE(SPECULATIVE_PS_POLL),
-	DEFINE(SCAN_SCH),
-	DEFINE(IBSS_HEARTBEAT_OFFLOAD),
-	DEFINE(WLAN_SCAN_OFFLOAD),
-	DEFINE(WLAN_PERIODIC_TX_PTRN),
-	DEFINE(ADVANCE_TDLS),
-	DEFINE(BATCH_SCAN),
-	DEFINE(FW_IN_TX_PATH),
-	DEFINE(EXTENDED_NSOFFLOAD_SLOT),
-	DEFINE(CH_SWITCH_V1),
-	DEFINE(HT40_OBSS_SCAN),
-	DEFINE(UPDATE_CHANNEL_LIST),
-	DEFINE(WLAN_MCADDR_FLT),
-	DEFINE(WLAN_CH144),
-	DEFINE(NAN),
-	DEFINE(TDLS_SCAN_COEXISTENCE),
-	DEFINE(LINK_LAYER_STATS_MEAS),
-	DEFINE(MU_MIMO),
-	DEFINE(EXTENDED_SCAN),
-	DEFINE(DYNAMIC_WMM_PS),
-	DEFINE(MAC_SPOOFED_SCAN),
-	DEFINE(BMU_ERROR_GENERIC_RECOVERY),
-	DEFINE(DISA),
-	DEFINE(FW_STATS),
-	DEFINE(WPS_PRBRSP_TMPL),
-	DEFINE(BCN_IE_FLT_DELTA),
-	DEFINE(TDLS_OFF_CHANNEL),
-	DEFINE(RTT3),
-	DEFINE(MGMT_FRAME_LOGGING),
-	DEFINE(ENHANCED_TXBD_COMPLETION),
-	DEFINE(LOGGING_ENHANCEMENT),
-	DEFINE(EXT_SCAN_ENHANCED),
-	DEFINE(MEMORY_DUMP_SUPPORTED),
-	DEFINE(PER_PKT_STATS_SUPPORTED),
-	DEFINE(EXT_LL_STAT),
-	DEFINE(WIFI_CONFIG),
-	DEFINE(ANTENNA_DIVERSITY_SELECTION),
-};
-
-#undef DEFINE
-
-static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
-{
-	if (x >= ARRAY_SIZE(wcn36xx_caps_names))
-		return "UNKNOWN";
-	return wcn36xx_caps_names[x];
-}
-
 static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
 {
 	int i;
 
 	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
-		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
-			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
+			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n",
+				    wcn36xx_firmware_get_cap_name(i));
+		}
 	}
 }
 
-- 
2.36.1



From loic.poulain at linaro.org  Wed Jul 20 00:14:22 2022
From: loic.poulain at linaro.org (Loic Poulain)
Date: Wed, 20 Jul 2022 09:14:22 +0200
Subject: [PATCH v2 1/4] wcn36xx: Rename clunky firmware feature bit enum
In-Reply-To: <20220719143302.2071223-2-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org> <20220719143302.2071223-2-bryan.odonoghue@linaro.org>
Message-ID: <CAMZdPi8RpNvycWx7rMMSY31FDkW2Dcyw0jC-eQKKL+rzzit2Gw@mail.gmail.com>

On Tue, 19 Jul 2022 at 16:33, Bryan O'Donoghue
<bryan.odonoghue at linaro.org> wrote:
>
> The enum name "place_holder_in_cap_bitmap" is self descriptively asking to
> be changed to something else.
>
> Rename place_holder_in_cap_bitmap to wcn36xx_firmware_feat_caps so that the
> contents and intent of the enum is obvious.
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>

Reviewed-by: Loic Poulain <loic.poulain at linaro.org>

> ---
>  drivers/net/wireless/ath/wcn36xx/hal.h  | 2 +-
>  drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
>  drivers/net/wireless/ath/wcn36xx/smd.c  | 6 +++---
>  drivers/net/wireless/ath/wcn36xx/smd.h  | 6 +++---
>  4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
> index 46a49f0a51b3..5e48c97682c2 100644
> --- a/drivers/net/wireless/ath/wcn36xx/hal.h
> +++ b/drivers/net/wireless/ath/wcn36xx/hal.h
> @@ -4760,7 +4760,7 @@ struct wcn36xx_hal_set_power_params_resp {
>
>  /* Capability bitmap exchange definitions and macros starts */
>
> -enum place_holder_in_cap_bitmap {
> +enum wcn36xx_firmware_feat_caps {
>         MCC = 0,
>         P2P = 1,
>         DOT11AC = 2,
> diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
> index e34d3d0b7082..efd776b20e60 100644
> --- a/drivers/net/wireless/ath/wcn36xx/main.c
> +++ b/drivers/net/wireless/ath/wcn36xx/main.c
> @@ -260,7 +260,7 @@ static const char * const wcn36xx_caps_names[] = {
>
>  #undef DEFINE
>
> -static const char *wcn36xx_get_cap_name(enum place_holder_in_cap_bitmap x)
> +static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
>  {
>         if (x >= ARRAY_SIZE(wcn36xx_caps_names))
>                 return "UNKNOWN";
> diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
> index 7ac9a1e6f768..88ee92be8562 100644
> --- a/drivers/net/wireless/ath/wcn36xx/smd.c
> +++ b/drivers/net/wireless/ath/wcn36xx/smd.c
> @@ -2431,7 +2431,7 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
>         return ret;
>  }
>
> -void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
> +void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
>  {
>         int arr_idx, bit_idx;
>
> @@ -2445,7 +2445,7 @@ void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
>         bitmap[arr_idx] |= (1 << bit_idx);
>  }
>
> -int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
> +int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
>  {
>         int arr_idx, bit_idx;
>
> @@ -2460,7 +2460,7 @@ int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
>         return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
>  }
>
> -void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
> +void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
>  {
>         int arr_idx, bit_idx;
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
> index 3fd598ac2a27..186dad4fe80e 100644
> --- a/drivers/net/wireless/ath/wcn36xx/smd.h
> +++ b/drivers/net/wireless/ath/wcn36xx/smd.h
> @@ -125,9 +125,9 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
>  int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
>                              u32 arg3, u32 arg4, u32 arg5);
>  int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
> -void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
> -int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
> -void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
> +void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
> +int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
> +void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
>
>  int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
>                 struct ieee80211_sta *sta,
> --
> 2.36.1
>


From loic.poulain at linaro.org  Wed Jul 20 00:16:05 2022
From: loic.poulain at linaro.org (Loic Poulain)
Date: Wed, 20 Jul 2022 09:16:05 +0200
Subject: [PATCH v2 2/4] wcn36xx: Move firmware feature bit storage to
 dedicated firmware.c file
In-Reply-To: <20220719143302.2071223-3-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org> <20220719143302.2071223-3-bryan.odonoghue@linaro.org>
Message-ID: <CAMZdPi8FZmToCFVi88+qg1b12mkjL4z7iEDgnd_RbAFXEs-sCA@mail.gmail.com>

On Tue, 19 Jul 2022 at 16:33, Bryan O'Donoghue
<bryan.odonoghue at linaro.org> wrote:
>
> The naming of the get/set/clear firmware feature capability bits doesn't
> really follow the established namespace pattern of
> wcn36xx_logicalblock_do_something();
>
> The feature bits are accessed by smd.c and main.c. It would be nice to
> display the found feature bits in debugfs. To do so though we should tidy
> up the namespace a bit.
>
> Move the firmware feature exchange API to its own file - firmware.c giving
> us the opportunity to functionally decompose other firmware related
> accessors as appropriate in future.
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>

Reviewed-by: Loic Poulain <loic.poulain at linaro.org>

> ---
>  drivers/net/wireless/ath/wcn36xx/Makefile   |  3 +-
>  drivers/net/wireless/ath/wcn36xx/firmware.c | 50 +++++++++++++
>  drivers/net/wireless/ath/wcn36xx/firmware.h | 82 +++++++++++++++++++++
>  drivers/net/wireless/ath/wcn36xx/hal.h      | 68 -----------------
>  drivers/net/wireless/ath/wcn36xx/main.c     |  7 +-
>  drivers/net/wireless/ath/wcn36xx/smd.c      | 57 ++------------
>  drivers/net/wireless/ath/wcn36xx/smd.h      |  3 -
>  7 files changed, 146 insertions(+), 124 deletions(-)
>  create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
>  create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/Makefile b/drivers/net/wireless/ath/wcn36xx/Makefile
> index 27413703ad69..26bec795b372 100644
> --- a/drivers/net/wireless/ath/wcn36xx/Makefile
> +++ b/drivers/net/wireless/ath/wcn36xx/Makefile
> @@ -5,6 +5,7 @@ wcn36xx-y +=   main.o \
>                 txrx.o \
>                 smd.o \
>                 pmc.o \
> -               debug.o
> +               debug.o \
> +               firmware.o
>
>  wcn36xx-$(CONFIG_NL80211_TESTMODE) += testmode.o
> diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
> new file mode 100644
> index 000000000000..03b93d2bdcf9
> --- /dev/null
> +++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
> @@ -0,0 +1,50 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include "wcn36xx.h"
> +#include "firmware.h"
> +
> +void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
> +                                   enum wcn36xx_firmware_feat_caps cap)
> +{
> +       int arr_idx, bit_idx;
> +
> +       if (cap < 0 || cap > 127) {
> +               wcn36xx_warn("error cap idx %d\n", cap);
> +               return;
> +       }
> +
> +       arr_idx = cap / 32;
> +       bit_idx = cap % 32;
> +       bitmap[arr_idx] |= (1 << bit_idx);
> +}
> +
> +int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
> +                                  enum wcn36xx_firmware_feat_caps cap)
> +{
> +       int arr_idx, bit_idx;
> +
> +       if (cap < 0 || cap > 127) {
> +               wcn36xx_warn("error cap idx %d\n", cap);
> +               return -EINVAL;
> +       }
> +
> +       arr_idx = cap / 32;
> +       bit_idx = cap % 32;
> +
> +       return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
> +}
> +
> +void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
> +                                     enum wcn36xx_firmware_feat_caps cap)
> +{
> +       int arr_idx, bit_idx;
> +
> +       if (cap < 0 || cap > 127) {
> +               wcn36xx_warn("error cap idx %d\n", cap);
> +               return;
> +       }
> +
> +       arr_idx = cap / 32;
> +       bit_idx = cap % 32;
> +       bitmap[arr_idx] &= ~(1 << bit_idx);
> +}
> diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
> new file mode 100644
> index 000000000000..552c0e9325e1
> --- /dev/null
> +++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
> @@ -0,0 +1,82 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef _FIRMWARE_H_
> +#define _FIRMWARE_H_
> +
> +/* Capability bitmap exchange definitions and macros starts */
> +
> +enum wcn36xx_firmware_feat_caps {
> +       MCC = 0,
> +       P2P = 1,
> +       DOT11AC = 2,
> +       SLM_SESSIONIZATION = 3,
> +       DOT11AC_OPMODE = 4,
> +       SAP32STA = 5,
> +       TDLS = 6,
> +       P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
> +       WLANACTIVE_OFFLOAD = 8,
> +       BEACON_OFFLOAD = 9,
> +       SCAN_OFFLOAD = 10,
> +       ROAM_OFFLOAD = 11,
> +       BCN_MISS_OFFLOAD = 12,
> +       STA_POWERSAVE = 13,
> +       STA_ADVANCED_PWRSAVE = 14,
> +       AP_UAPSD = 15,
> +       AP_DFS = 16,
> +       BLOCKACK = 17,
> +       PHY_ERR = 18,
> +       BCN_FILTER = 19,
> +       RTT = 20,
> +       RATECTRL = 21,
> +       WOW = 22,
> +       WLAN_ROAM_SCAN_OFFLOAD = 23,
> +       SPECULATIVE_PS_POLL = 24,
> +       SCAN_SCH = 25,
> +       IBSS_HEARTBEAT_OFFLOAD = 26,
> +       WLAN_SCAN_OFFLOAD = 27,
> +       WLAN_PERIODIC_TX_PTRN = 28,
> +       ADVANCE_TDLS = 29,
> +       BATCH_SCAN = 30,
> +       FW_IN_TX_PATH = 31,
> +       EXTENDED_NSOFFLOAD_SLOT = 32,
> +       CH_SWITCH_V1 = 33,
> +       HT40_OBSS_SCAN = 34,
> +       UPDATE_CHANNEL_LIST = 35,
> +       WLAN_MCADDR_FLT = 36,
> +       WLAN_CH144 = 37,
> +       NAN = 38,
> +       TDLS_SCAN_COEXISTENCE = 39,
> +       LINK_LAYER_STATS_MEAS = 40,
> +       MU_MIMO = 41,
> +       EXTENDED_SCAN = 42,
> +       DYNAMIC_WMM_PS = 43,
> +       MAC_SPOOFED_SCAN = 44,
> +       BMU_ERROR_GENERIC_RECOVERY = 45,
> +       DISA = 46,
> +       FW_STATS = 47,
> +       WPS_PRBRSP_TMPL = 48,
> +       BCN_IE_FLT_DELTA = 49,
> +       TDLS_OFF_CHANNEL = 51,
> +       RTT3 = 52,
> +       MGMT_FRAME_LOGGING = 53,
> +       ENHANCED_TXBD_COMPLETION = 54,
> +       LOGGING_ENHANCEMENT = 55,
> +       EXT_SCAN_ENHANCED = 56,
> +       MEMORY_DUMP_SUPPORTED = 57,
> +       PER_PKT_STATS_SUPPORTED = 58,
> +       EXT_LL_STAT = 60,
> +       WIFI_CONFIG = 61,
> +       ANTENNA_DIVERSITY_SELECTION = 62,
> +
> +       MAX_FEATURE_SUPPORTED = 128,
> +};
> +
> +void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
> +                                   enum wcn36xx_firmware_feat_caps cap);
> +int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
> +                                  enum wcn36xx_firmware_feat_caps cap);
> +void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
> +                                     enum wcn36xx_firmware_feat_caps cap);
> +
> +#endif /* _FIRMWARE_H_ */
> +
> diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
> index 5e48c97682c2..5c45b23c7880 100644
> --- a/drivers/net/wireless/ath/wcn36xx/hal.h
> +++ b/drivers/net/wireless/ath/wcn36xx/hal.h
> @@ -4758,74 +4758,6 @@ struct wcn36xx_hal_set_power_params_resp {
>         u32 status;
>  } __packed;
>
> -/* Capability bitmap exchange definitions and macros starts */
> -
> -enum wcn36xx_firmware_feat_caps {
> -       MCC = 0,
> -       P2P = 1,
> -       DOT11AC = 2,
> -       SLM_SESSIONIZATION = 3,
> -       DOT11AC_OPMODE = 4,
> -       SAP32STA = 5,
> -       TDLS = 6,
> -       P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
> -       WLANACTIVE_OFFLOAD = 8,
> -       BEACON_OFFLOAD = 9,
> -       SCAN_OFFLOAD = 10,
> -       ROAM_OFFLOAD = 11,
> -       BCN_MISS_OFFLOAD = 12,
> -       STA_POWERSAVE = 13,
> -       STA_ADVANCED_PWRSAVE = 14,
> -       AP_UAPSD = 15,
> -       AP_DFS = 16,
> -       BLOCKACK = 17,
> -       PHY_ERR = 18,
> -       BCN_FILTER = 19,
> -       RTT = 20,
> -       RATECTRL = 21,
> -       WOW = 22,
> -       WLAN_ROAM_SCAN_OFFLOAD = 23,
> -       SPECULATIVE_PS_POLL = 24,
> -       SCAN_SCH = 25,
> -       IBSS_HEARTBEAT_OFFLOAD = 26,
> -       WLAN_SCAN_OFFLOAD = 27,
> -       WLAN_PERIODIC_TX_PTRN = 28,
> -       ADVANCE_TDLS = 29,
> -       BATCH_SCAN = 30,
> -       FW_IN_TX_PATH = 31,
> -       EXTENDED_NSOFFLOAD_SLOT = 32,
> -       CH_SWITCH_V1 = 33,
> -       HT40_OBSS_SCAN = 34,
> -       UPDATE_CHANNEL_LIST = 35,
> -       WLAN_MCADDR_FLT = 36,
> -       WLAN_CH144 = 37,
> -       NAN = 38,
> -       TDLS_SCAN_COEXISTENCE = 39,
> -       LINK_LAYER_STATS_MEAS = 40,
> -       MU_MIMO = 41,
> -       EXTENDED_SCAN = 42,
> -       DYNAMIC_WMM_PS = 43,
> -       MAC_SPOOFED_SCAN = 44,
> -       BMU_ERROR_GENERIC_RECOVERY = 45,
> -       DISA = 46,
> -       FW_STATS = 47,
> -       WPS_PRBRSP_TMPL = 48,
> -       BCN_IE_FLT_DELTA = 49,
> -       TDLS_OFF_CHANNEL = 51,
> -       RTT3 = 52,
> -       MGMT_FRAME_LOGGING = 53,
> -       ENHANCED_TXBD_COMPLETION = 54,
> -       LOGGING_ENHANCEMENT = 55,
> -       EXT_SCAN_ENHANCED = 56,
> -       MEMORY_DUMP_SUPPORTED = 57,
> -       PER_PKT_STATS_SUPPORTED = 58,
> -       EXT_LL_STAT = 60,
> -       WIFI_CONFIG = 61,
> -       ANTENNA_DIVERSITY_SELECTION = 62,
> -
> -       MAX_FEATURE_SUPPORTED = 128,
> -};
> -
>  #define WCN36XX_HAL_CAPS_SIZE 4
>
>  struct wcn36xx_hal_feat_caps_msg {
> diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
> index efd776b20e60..af62911a4659 100644
> --- a/drivers/net/wireless/ath/wcn36xx/main.c
> +++ b/drivers/net/wireless/ath/wcn36xx/main.c
> @@ -28,6 +28,7 @@
>  #include <net/ipv6.h>
>  #include "wcn36xx.h"
>  #include "testmode.h"
> +#include "firmware.h"
>
>  unsigned int wcn36xx_dbg_mask;
>  module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
> @@ -272,7 +273,7 @@ static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
>         int i;
>
>         for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
> -               if (get_feat_caps(wcn->fw_feat_caps, i))
> +               if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
>                         wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
>         }
>  }
> @@ -705,7 +706,7 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
>  {
>         struct wcn36xx *wcn = hw->priv;
>
> -       if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
> +       if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
>                 /* fallback to mac80211 software scan */
>                 return 1;
>         }
> @@ -743,7 +744,7 @@ static void wcn36xx_cancel_hw_scan(struct ieee80211_hw *hw,
>         wcn->scan_aborted = true;
>         mutex_unlock(&wcn->scan_lock);
>
> -       if (get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
> +       if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
>                 /* ieee80211_scan_completed will be called on FW scan
>                  * indication */
>                 wcn36xx_smd_stop_hw_scan(wcn);
> diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
> index 88ee92be8562..d2a994fee812 100644
> --- a/drivers/net/wireless/ath/wcn36xx/smd.c
> +++ b/drivers/net/wireless/ath/wcn36xx/smd.c
> @@ -22,6 +22,7 @@
>  #include <linux/bitops.h>
>  #include <linux/rpmsg.h>
>  #include "smd.h"
> +#include "firmware.h"
>
>  struct wcn36xx_cfg_val {
>         u32 cfg_id;
> @@ -295,7 +296,7 @@ static void wcn36xx_smd_set_sta_vht_params(struct wcn36xx *wcn,
>                 sta_params->vht_capable = sta->deflink.vht_cap.vht_supported;
>                 sta_params->vht_ldpc_enabled =
>                         is_cap_supported(caps, IEEE80211_VHT_CAP_RXLDPC);
> -               if (get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
> +               if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
>                         sta_params->vht_tx_mu_beamformee_capable =
>                                 is_cap_supported(caps, IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
>                         if (sta_params->vht_tx_mu_beamformee_capable)
> @@ -2431,49 +2432,6 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
>         return ret;
>  }
>
> -void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
> -{
> -       int arr_idx, bit_idx;
> -
> -       if (cap < 0 || cap > 127) {
> -               wcn36xx_warn("error cap idx %d\n", cap);
> -               return;
> -       }
> -
> -       arr_idx = cap / 32;
> -       bit_idx = cap % 32;
> -       bitmap[arr_idx] |= (1 << bit_idx);
> -}
> -
> -int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
> -{
> -       int arr_idx, bit_idx;
> -
> -       if (cap < 0 || cap > 127) {
> -               wcn36xx_warn("error cap idx %d\n", cap);
> -               return -EINVAL;
> -       }
> -
> -       arr_idx = cap / 32;
> -       bit_idx = cap % 32;
> -
> -       return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
> -}
> -
> -void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
> -{
> -       int arr_idx, bit_idx;
> -
> -       if (cap < 0 || cap > 127) {
> -               wcn36xx_warn("error cap idx %d\n", cap);
> -               return;
> -       }
> -
> -       arr_idx = cap / 32;
> -       bit_idx = cap % 32;
> -       bitmap[arr_idx] &= ~(1 << bit_idx);
> -}
> -
>  int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
>  {
>         struct wcn36xx_hal_feat_caps_msg msg_body, *rsp;
> @@ -2482,11 +2440,12 @@ int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
>         mutex_lock(&wcn->hal_mutex);
>         INIT_HAL_MSG(msg_body, WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_REQ);
>
> -       set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
> +       wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
>         if (wcn->rf_id == RF_IRIS_WCN3680) {
> -               set_feat_caps(msg_body.feat_caps, DOT11AC);
> -               set_feat_caps(msg_body.feat_caps, WLAN_CH144);
> -               set_feat_caps(msg_body.feat_caps, ANTENNA_DIVERSITY_SELECTION);
> +               wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, DOT11AC);
> +               wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, WLAN_CH144);
> +               wcn36xx_firmware_set_feat_caps(msg_body.feat_caps,
> +                                              ANTENNA_DIVERSITY_SELECTION);
>         }
>
>         PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
> @@ -3300,7 +3259,7 @@ int wcn36xx_smd_add_beacon_filter(struct wcn36xx *wcn,
>         size_t payload_size;
>         int ret;
>
> -       if (!get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
> +       if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
>                 return -EOPNOTSUPP;
>
>         mutex_lock(&wcn->hal_mutex);
> diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
> index 186dad4fe80e..cf15cde2a364 100644
> --- a/drivers/net/wireless/ath/wcn36xx/smd.h
> +++ b/drivers/net/wireless/ath/wcn36xx/smd.h
> @@ -125,9 +125,6 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
>  int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
>                              u32 arg3, u32 arg4, u32 arg5);
>  int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
> -void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
> -int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
> -void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
>
>  int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
>                 struct ieee80211_sta *sta,
> --
> 2.36.1
>


From loic.poulain at linaro.org  Wed Jul 20 00:21:49 2022
From: loic.poulain at linaro.org (Loic Poulain)
Date: Wed, 20 Jul 2022 09:21:49 +0200
Subject: [PATCH v2 3/4] wcn36xx: Move capability bitmap to string
 translation function to firmware.c
In-Reply-To: <20220719143302.2071223-4-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org> <20220719143302.2071223-4-bryan.odonoghue@linaro.org>
Message-ID: <CAMZdPi9VQ5-EhVyTH=zKzbji4vDD8wQuBcGyb5xPynqDysYBeQ@mail.gmail.com>

On Tue, 19 Jul 2022 at 16:33, Bryan O'Donoghue
<bryan.odonoghue at linaro.org> wrote:
>
> Move wcn36xx_get_cap_name() function in main.c into firmware.c as
> wcn36xx_firmware_get_cap_name().
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>

Reviewed-by: Loic Poulain <loic.poulain at linaro.org>

> ---
>  drivers/net/wireless/ath/wcn36xx/firmware.c | 75 +++++++++++++++++++
>  drivers/net/wireless/ath/wcn36xx/firmware.h |  2 +
>  drivers/net/wireless/ath/wcn36xx/main.c     | 81 +--------------------
>  3 files changed, 81 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
> index 03b93d2bdcf9..4b7f439e4db5 100644
> --- a/drivers/net/wireless/ath/wcn36xx/firmware.c
> +++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
> @@ -3,6 +3,81 @@
>  #include "wcn36xx.h"
>  #include "firmware.h"
>
> +#define DEFINE(s)[s] = #s
> +
> +static const char * const wcn36xx_firmware_caps_names[] = {
> +       DEFINE(MCC),
> +       DEFINE(P2P),
> +       DEFINE(DOT11AC),
> +       DEFINE(SLM_SESSIONIZATION),
> +       DEFINE(DOT11AC_OPMODE),
> +       DEFINE(SAP32STA),
> +       DEFINE(TDLS),
> +       DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
> +       DEFINE(WLANACTIVE_OFFLOAD),
> +       DEFINE(BEACON_OFFLOAD),
> +       DEFINE(SCAN_OFFLOAD),
> +       DEFINE(ROAM_OFFLOAD),
> +       DEFINE(BCN_MISS_OFFLOAD),
> +       DEFINE(STA_POWERSAVE),
> +       DEFINE(STA_ADVANCED_PWRSAVE),
> +       DEFINE(AP_UAPSD),
> +       DEFINE(AP_DFS),
> +       DEFINE(BLOCKACK),
> +       DEFINE(PHY_ERR),
> +       DEFINE(BCN_FILTER),
> +       DEFINE(RTT),
> +       DEFINE(RATECTRL),
> +       DEFINE(WOW),
> +       DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
> +       DEFINE(SPECULATIVE_PS_POLL),
> +       DEFINE(SCAN_SCH),
> +       DEFINE(IBSS_HEARTBEAT_OFFLOAD),
> +       DEFINE(WLAN_SCAN_OFFLOAD),
> +       DEFINE(WLAN_PERIODIC_TX_PTRN),
> +       DEFINE(ADVANCE_TDLS),
> +       DEFINE(BATCH_SCAN),
> +       DEFINE(FW_IN_TX_PATH),
> +       DEFINE(EXTENDED_NSOFFLOAD_SLOT),
> +       DEFINE(CH_SWITCH_V1),
> +       DEFINE(HT40_OBSS_SCAN),
> +       DEFINE(UPDATE_CHANNEL_LIST),
> +       DEFINE(WLAN_MCADDR_FLT),
> +       DEFINE(WLAN_CH144),
> +       DEFINE(NAN),
> +       DEFINE(TDLS_SCAN_COEXISTENCE),
> +       DEFINE(LINK_LAYER_STATS_MEAS),
> +       DEFINE(MU_MIMO),
> +       DEFINE(EXTENDED_SCAN),
> +       DEFINE(DYNAMIC_WMM_PS),
> +       DEFINE(MAC_SPOOFED_SCAN),
> +       DEFINE(BMU_ERROR_GENERIC_RECOVERY),
> +       DEFINE(DISA),
> +       DEFINE(FW_STATS),
> +       DEFINE(WPS_PRBRSP_TMPL),
> +       DEFINE(BCN_IE_FLT_DELTA),
> +       DEFINE(TDLS_OFF_CHANNEL),
> +       DEFINE(RTT3),
> +       DEFINE(MGMT_FRAME_LOGGING),
> +       DEFINE(ENHANCED_TXBD_COMPLETION),
> +       DEFINE(LOGGING_ENHANCEMENT),
> +       DEFINE(EXT_SCAN_ENHANCED),
> +       DEFINE(MEMORY_DUMP_SUPPORTED),
> +       DEFINE(PER_PKT_STATS_SUPPORTED),
> +       DEFINE(EXT_LL_STAT),
> +       DEFINE(WIFI_CONFIG),
> +       DEFINE(ANTENNA_DIVERSITY_SELECTION),
> +};
> +
> +#undef DEFINE
> +
> +const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x)
> +{
> +       if (x >= ARRAY_SIZE(wcn36xx_firmware_caps_names))
> +               return "UNKNOWN";
> +       return wcn36xx_firmware_caps_names[x];
> +}
> +
>  void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
>                                     enum wcn36xx_firmware_feat_caps cap)
>  {
> diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
> index 552c0e9325e1..f991cf959f82 100644
> --- a/drivers/net/wireless/ath/wcn36xx/firmware.h
> +++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
> @@ -78,5 +78,7 @@ int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
>  void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
>                                       enum wcn36xx_firmware_feat_caps cap);
>
> +const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x);
> +
>  #endif /* _FIRMWARE_H_ */
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
> index af62911a4659..fec85e89a02f 100644
> --- a/drivers/net/wireless/ath/wcn36xx/main.c
> +++ b/drivers/net/wireless/ath/wcn36xx/main.c
> @@ -193,88 +193,15 @@ static inline u8 get_sta_index(struct ieee80211_vif *vif,
>                sta_priv->sta_index;
>  }
>
> -#define DEFINE(s) [s] = #s
> -
> -static const char * const wcn36xx_caps_names[] = {
> -       DEFINE(MCC),
> -       DEFINE(P2P),
> -       DEFINE(DOT11AC),
> -       DEFINE(SLM_SESSIONIZATION),
> -       DEFINE(DOT11AC_OPMODE),
> -       DEFINE(SAP32STA),
> -       DEFINE(TDLS),
> -       DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
> -       DEFINE(WLANACTIVE_OFFLOAD),
> -       DEFINE(BEACON_OFFLOAD),
> -       DEFINE(SCAN_OFFLOAD),
> -       DEFINE(ROAM_OFFLOAD),
> -       DEFINE(BCN_MISS_OFFLOAD),
> -       DEFINE(STA_POWERSAVE),
> -       DEFINE(STA_ADVANCED_PWRSAVE),
> -       DEFINE(AP_UAPSD),
> -       DEFINE(AP_DFS),
> -       DEFINE(BLOCKACK),
> -       DEFINE(PHY_ERR),
> -       DEFINE(BCN_FILTER),
> -       DEFINE(RTT),
> -       DEFINE(RATECTRL),
> -       DEFINE(WOW),
> -       DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
> -       DEFINE(SPECULATIVE_PS_POLL),
> -       DEFINE(SCAN_SCH),
> -       DEFINE(IBSS_HEARTBEAT_OFFLOAD),
> -       DEFINE(WLAN_SCAN_OFFLOAD),
> -       DEFINE(WLAN_PERIODIC_TX_PTRN),
> -       DEFINE(ADVANCE_TDLS),
> -       DEFINE(BATCH_SCAN),
> -       DEFINE(FW_IN_TX_PATH),
> -       DEFINE(EXTENDED_NSOFFLOAD_SLOT),
> -       DEFINE(CH_SWITCH_V1),
> -       DEFINE(HT40_OBSS_SCAN),
> -       DEFINE(UPDATE_CHANNEL_LIST),
> -       DEFINE(WLAN_MCADDR_FLT),
> -       DEFINE(WLAN_CH144),
> -       DEFINE(NAN),
> -       DEFINE(TDLS_SCAN_COEXISTENCE),
> -       DEFINE(LINK_LAYER_STATS_MEAS),
> -       DEFINE(MU_MIMO),
> -       DEFINE(EXTENDED_SCAN),
> -       DEFINE(DYNAMIC_WMM_PS),
> -       DEFINE(MAC_SPOOFED_SCAN),
> -       DEFINE(BMU_ERROR_GENERIC_RECOVERY),
> -       DEFINE(DISA),
> -       DEFINE(FW_STATS),
> -       DEFINE(WPS_PRBRSP_TMPL),
> -       DEFINE(BCN_IE_FLT_DELTA),
> -       DEFINE(TDLS_OFF_CHANNEL),
> -       DEFINE(RTT3),
> -       DEFINE(MGMT_FRAME_LOGGING),
> -       DEFINE(ENHANCED_TXBD_COMPLETION),
> -       DEFINE(LOGGING_ENHANCEMENT),
> -       DEFINE(EXT_SCAN_ENHANCED),
> -       DEFINE(MEMORY_DUMP_SUPPORTED),
> -       DEFINE(PER_PKT_STATS_SUPPORTED),
> -       DEFINE(EXT_LL_STAT),
> -       DEFINE(WIFI_CONFIG),
> -       DEFINE(ANTENNA_DIVERSITY_SELECTION),
> -};
> -
> -#undef DEFINE
> -
> -static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
> -{
> -       if (x >= ARRAY_SIZE(wcn36xx_caps_names))
> -               return "UNKNOWN";
> -       return wcn36xx_caps_names[x];
> -}
> -
>  static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
>  {
>         int i;
>
>         for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
> -               if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
> -                       wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
> +               if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
> +                       wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n",
> +                                   wcn36xx_firmware_get_cap_name(i));
> +               }
>         }
>  }
>
> --
> 2.36.1
>


From loic.poulain at linaro.org  Wed Jul 20 00:24:01 2022
From: loic.poulain at linaro.org (Loic Poulain)
Date: Wed, 20 Jul 2022 09:24:01 +0200
Subject: [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware
 feature strings
In-Reply-To: <20220719143302.2071223-5-bryan.odonoghue@linaro.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org> <20220719143302.2071223-5-bryan.odonoghue@linaro.org>
Message-ID: <CAMZdPi9MBZQxiybohQT-cK9X6VEgqX1UOiGbba4APaL-dDBO8Q@mail.gmail.com>

On Tue, 19 Jul 2022 at 16:33, Bryan O'Donoghue
<bryan.odonoghue at linaro.org> wrote:
>
> Add in the ability to easily find the firmware feature bits reported in the
> get feature exchange without having to compile-in debug prints.
>
> root at linaro-alip:~# cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps
> MCC
> P2P
> DOT11AC
> SLM_SESSIONIZATION
> DOT11AC_OPMODE
> SAP32STA
> TDLS
> P2P_GO_NOA_DECOUPLE_INIT_SCAN
> WLANACTIVE_OFFLOAD
> BEACON_OFFLOAD
> SCAN_OFFLOAD
> BCN_MISS_OFFLOAD
> STA_POWERSAVE
> STA_ADVANCED_PWRSAVE
> BCN_FILTER
> RTT
> RATECTRL
> WOW
> WLAN_ROAM_SCAN_OFFLOAD
> SPECULATIVE_PS_POLL
> IBSS_HEARTBEAT_OFFLOAD
> WLAN_SCAN_OFFLOAD
> WLAN_PERIODIC_TX_PTRN
> ADVANCE_TDLS
> BATCH_SCAN
> FW_IN_TX_PATH
> EXTENDED_NSOFFLOAD_SLOT
> CH_SWITCH_V1
> HT40_OBSS_SCAN
> UPDATE_CHANNEL_LIST
> WLAN_MCADDR_FLT
> WLAN_CH144
> TDLS_SCAN_COEXISTENCE
> LINK_LAYER_STATS_MEAS
> MU_MIMO
> EXTENDED_SCAN
> DYNAMIC_WMM_PS
> MAC_SPOOFED_SCAN
> FW_STATS
> WPS_PRBRSP_TMPL
> BCN_IE_FLT_DELTA
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>


Reviewed-by: Loic Poulain <loic.poulain at linaro.org>

> ---
>  drivers/net/wireless/ath/wcn36xx/debug.c | 37 ++++++++++++++++++++++++
>  drivers/net/wireless/ath/wcn36xx/debug.h |  1 +
>  2 files changed, 38 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
> index 6af306ae41ad..220f338045bd 100644
> --- a/drivers/net/wireless/ath/wcn36xx/debug.c
> +++ b/drivers/net/wireless/ath/wcn36xx/debug.c
> @@ -21,6 +21,7 @@
>  #include "wcn36xx.h"
>  #include "debug.h"
>  #include "pmc.h"
> +#include "firmware.h"
>
>  #ifdef CONFIG_WCN36XX_DEBUGFS
>
> @@ -136,6 +137,40 @@ static const struct file_operations fops_wcn36xx_dump = {
>         .write =       write_file_dump,
>  };
>
> +static ssize_t read_file_firmware_feature_caps(struct file *file,
> +                                              char __user *user_buf,
> +                                              size_t count, loff_t *ppos)
> +{
> +       struct wcn36xx *wcn = file->private_data;
> +       unsigned long page = get_zeroed_page(GFP_KERNEL);
> +       char *p = (char *)page;
> +       int i;
> +       int ret;
> +
> +       if (!p)
> +               return -ENOMEM;
> +
> +       mutex_lock(&wcn->hal_mutex);
> +       for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
> +               if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
> +                       p += sprintf(p, "%s\n",
> +                                    wcn36xx_firmware_get_cap_name(i));
> +               }
> +       }
> +       mutex_unlock(&wcn->hal_mutex);
> +
> +       ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
> +                                     (unsigned long)p - page);
> +
> +       free_page(page);
> +       return ret;
> +}
> +
> +static const struct file_operations fops_wcn36xx_firmware_feat_caps = {
> +       .open = simple_open,
> +       .read = read_file_firmware_feature_caps,
> +};
> +
>  #define ADD_FILE(name, mode, fop, priv_data)           \
>         do {                                                    \
>                 struct dentry *d;                               \
> @@ -163,6 +198,8 @@ void wcn36xx_debugfs_init(struct wcn36xx *wcn)
>
>         ADD_FILE(bmps_switcher, 0600, &fops_wcn36xx_bmps, wcn);
>         ADD_FILE(dump, 0200, &fops_wcn36xx_dump, wcn);
> +       ADD_FILE(firmware_feat_caps, 0200,
> +                &fops_wcn36xx_firmware_feat_caps, wcn);
>  }
>
>  void wcn36xx_debugfs_exit(struct wcn36xx *wcn)
> diff --git a/drivers/net/wireless/ath/wcn36xx/debug.h b/drivers/net/wireless/ath/wcn36xx/debug.h
> index 46307aa562d3..7116d96e0543 100644
> --- a/drivers/net/wireless/ath/wcn36xx/debug.h
> +++ b/drivers/net/wireless/ath/wcn36xx/debug.h
> @@ -31,6 +31,7 @@ struct wcn36xx_dfs_entry {
>         struct dentry *rootdir;
>         struct wcn36xx_dfs_file file_bmps_switcher;
>         struct wcn36xx_dfs_file file_dump;
> +       struct wcn36xx_dfs_file file_firmware_feat_caps;
>  };
>
>  void wcn36xx_debugfs_init(struct wcn36xx *wcn);
> --
> 2.36.1
>


From slark_xiao at 163.com  Fri Jul 22 01:26:53 2022
From: slark_xiao at 163.com (Slark Xiao)
Date: Fri, 22 Jul 2022 16:26:53 +0800
Subject: [PATCH] wireless: ath: Fix typo 'the the' in comment
Message-ID: <20220722082653.74553-1-slark_xiao@163.com>

Replace 'the the' with 'the' in the comment.

Signed-off-by: Slark Xiao <slark_xiao at 163.com>
---
 drivers/net/wireless/ath/ath6kl/hif.h       | 2 +-
 drivers/net/wireless/ath/ath6kl/sdio.c      | 2 +-
 drivers/net/wireless/ath/ath9k/ar9003_phy.c | 2 +-
 drivers/net/wireless/ath/wcn36xx/hal.h      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h
index f9d3f3a5edfe..ba16b98c872d 100644
--- a/drivers/net/wireless/ath/ath6kl/hif.h
+++ b/drivers/net/wireless/ath/ath6kl/hif.h
@@ -92,7 +92,7 @@ struct bus_request {
  *     emode - This indicates the whether the command is to be executed in a
  *             blocking or non-blocking fashion (HIF_SYNCHRONOUS/
  *             HIF_ASYNCHRONOUS). The read/write data paths in HTC have been
- *             implemented using the asynchronous mode allowing the the bus
+ *             implemented using the asynchronous mode allowing the bus
  *             driver to indicate the completion of operation through the
  *             registered callback routine. The requirement primarily comes
  *             from the contexts these operations get called from (a driver's
diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c
index 6b51a2dceadc..8a43c48ec1cf 100644
--- a/drivers/net/wireless/ath/ath6kl/sdio.c
+++ b/drivers/net/wireless/ath/ath6kl/sdio.c
@@ -1185,7 +1185,7 @@ static int ath6kl_sdio_bmi_read(struct ath6kl *ar, u8 *buf, u32 len)
 	 *        Wait for first 4 bytes to be in FIFO
 	 *        If CONSERVATIVE_BMI_READ is enabled, also wait for
 	 *        a BMI command credit, which indicates that the ENTIRE
-	 *        response is available in the the FIFO
+	 *        response is available in the FIFO
 	 *
 	 *  CASE 3: length > 128
 	 *        Wait for the first 4 bytes to be in FIFO
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index dc0e5ea25673..090ff0600c81 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1744,7 +1744,7 @@ static void ar9003_hw_spectral_scan_config(struct ath_hw *ah,
 	REG_SET_BIT(ah, AR_PHY_RADAR_0, AR_PHY_RADAR_0_FFT_ENA);
 	REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE);
 
-	/* on AR93xx and newer, count = 0 will make the the chip send
+	/* on AR93xx and newer, count = 0 will make the chip send
 	 * spectral samples endlessly. Check if this really was intended,
 	 * and fix otherwise.
 	 */
diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 874746b5993c..a1afe1f85f0e 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4142,7 +4142,7 @@ struct wcn36xx_hal_dump_cmd_rsp_msg {
 	/* Length of the responce message */
 	u32 rsp_length;
 
-	/* FIXME: Currently considering the the responce will be less than
+	/* FIXME: Currently considering the responce will be less than
 	 * 100bytes */
 	u8 rsp_buffer[DUMPCMD_RSP_BUFFER];
 } __packed;
-- 
2.25.1



From kvalo at kernel.org  Mon Jul 25 04:06:50 2022
From: kvalo at kernel.org (Kalle Valo)
Date: Mon, 25 Jul 2022 11:06:50 +0000 (UTC)
Subject: [PATCH] wireless: ath: Fix typo 'the the' in comment
In-Reply-To: <20220722082653.74553-1-slark_xiao@163.com>
References: <20220722082653.74553-1-slark_xiao@163.com>
Message-ID: <165874719705.30937.12813347117072714125.kvalo@kernel.org>

Slark Xiao <slark_xiao at 163.com> wrote:

> Replace 'the the' with 'the' in the comment.
> 
> Signed-off-by: Slark Xiao <slark_xiao at 163.com>

Fails to apply, please rebase on top my ath.git master branch.

error: patch failed: drivers/net/wireless/ath/ath6kl/hif.h:92
error: drivers/net/wireless/ath/ath6kl/hif.h: patch does not apply
error: patch failed: drivers/net/wireless/ath/ath6kl/sdio.c:1185
error: drivers/net/wireless/ath/ath6kl/sdio.c: patch does not apply
error: patch failed: drivers/net/wireless/ath/wcn36xx/hal.h:4142
error: drivers/net/wireless/ath/wcn36xx/hal.h: patch does not apply
stg import: Diff does not apply cleanly

Patch set to Changes Requested.

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220722082653.74553-1-slark_xiao at 163.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



From slark_xiao at 163.com  Mon Jul 25 19:31:31 2022
From: slark_xiao at 163.com (Slark Xiao)
Date: Tue, 26 Jul 2022 10:31:31 +0800 (CST)
Subject: [PATCH] wireless: ath: Fix typo 'the the' in comment
In-Reply-To: <165874719705.30937.12813347117072714125.kvalo@kernel.org>
References: <20220722082653.74553-1-slark_xiao@163.com>
 <165874719705.30937.12813347117072714125.kvalo@kernel.org>
Message-ID: <3621f4e.e19.18238585e4a.Coremail.slark_xiao@163.com>

















At 2022-07-25 19:06:50, "Kalle Valo" <kvalo at kernel.org> wrote:
>Slark Xiao <slark_xiao at 163.com> wrote:
>
>> Replace 'the the' with 'the' in the comment.
>> 
>> Signed-off-by: Slark Xiao <slark_xiao at 163.com>
>
>Fails to apply, please rebase on top my ath.git master branch.
>
>error: patch failed: drivers/net/wireless/ath/ath6kl/hif.h:92
>error: drivers/net/wireless/ath/ath6kl/hif.h: patch does not apply
>error: patch failed: drivers/net/wireless/ath/ath6kl/sdio.c:1185
>error: drivers/net/wireless/ath/ath6kl/sdio.c: patch does not apply
>error: patch failed: drivers/net/wireless/ath/wcn36xx/hal.h:4142
>error: drivers/net/wireless/ath/wcn36xx/hal.h: patch does not apply
>stg import: Diff does not apply cleanly
>
>Patch set to Changes Requested.
>
>-- 
>https://patchwork.kernel.org/project/linux-wireless/patch/20220722082653.74553-1-slark_xiao at 163.com/
>
>https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

Bad news, I can't get your ath code completely. 
ubuntu at VM-0-27-ubuntu:~/ath$ !142
git clone git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Cloning into 'ath'...
remote: Enumerating objects: 202, done.
remote: Counting objects: 100% (202/202), done.
remote: Compressing objects: 100% (83/83), done.
Receiving objects: 100% (8897606/8897606), 2.47 GiB | 11.99 MiB/s, done.
remote: Total 8897606 (delta 150), reused 133 (delta 119), pack-reused 8897404
error: index-pack died of signal 984000)
fatal: index-pack failed

ubuntu at VM-0-27-ubuntu:~/ath$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
Cloning into 'ath'...
remote: Enumerating objects: 202, done.
remote: Counting objects: 100% (202/202), done.
remote: Compressing objects: 100% (83/83), done.
remote: Total 8897606 (delta 150), reused 133 (delta 119), pack-reused 8897404
Receiving objects: 100% (8897606/8897606), 2.47 GiB | 11.88 MiB/s, done.
error: index-pack died of signal 984000)
fatal: index-pack failed

ubuntu at VM-0-27-ubuntu:~/ath$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/kvalo/ath.git
Cloning into 'ath'...
remote: Sending approximately 1.67 GiB ...
remote: Counting objects: 29323, done
remote: Finding sources: 100% (8897606/8897606)
remote: Total 8897606 (delta 7524073), reused 8897044 (delta 7524073)
Receiving objects: 100% (8897606/8897606), 1.67 GiB | 11.98 MiB/s, done.
error: index-pack died of signal 94073)
fatal: index-pack failed

I tried these 3 servers but all failed. Any other ideas?

From slark_xiao at 163.com  Mon Jul 25 20:40:13 2022
From: slark_xiao at 163.com (Slark Xiao)
Date: Tue, 26 Jul 2022 11:40:13 +0800 (CST)
Subject: [PATCH] wireless: ath: Fix typo 'the the' in comment
In-Reply-To: <3621f4e.e19.18238585e4a.Coremail.slark_xiao@163.com>
References: <20220722082653.74553-1-slark_xiao@163.com>
 <165874719705.30937.12813347117072714125.kvalo@kernel.org>
 <3621f4e.e19.18238585e4a.Coremail.slark_xiao@163.com>
Message-ID: <4f9a54ad.1551.1823897425b.Coremail.slark_xiao@163.com>

















At 2022-07-26 10:31:31, "Slark Xiao" <slark_xiao at 163.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>At 2022-07-25 19:06:50, "Kalle Valo" <kvalo at kernel.org> wrote:
>>Slark Xiao <slark_xiao at 163.com> wrote:
>>
>>> Replace 'the the' with 'the' in the comment.
>>> 
>>> Signed-off-by: Slark Xiao <slark_xiao at 163.com>
>>
>>Fails to apply, please rebase on top my ath.git master branch.
>>
>>error: patch failed: drivers/net/wireless/ath/ath6kl/hif.h:92
>>error: drivers/net/wireless/ath/ath6kl/hif.h: patch does not apply
>>error: patch failed: drivers/net/wireless/ath/ath6kl/sdio.c:1185
>>error: drivers/net/wireless/ath/ath6kl/sdio.c: patch does not apply
>>error: patch failed: drivers/net/wireless/ath/wcn36xx/hal.h:4142
>>error: drivers/net/wireless/ath/wcn36xx/hal.h: patch does not apply
>>stg import: Diff does not apply cleanly
>>
>>Patch set to Changes Requested.
>>
>>-- 
>>https://patchwork.kernel.org/project/linux-wireless/patch/20220722082653.74553-1-slark_xiao at 163.com/
>>
>>https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
>
>Bad news, I can't get your ath code completely. 
>ubuntu at VM-0-27-ubuntu:~/ath$ !142
>git clone git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
>Cloning into 'ath'...
>remote: Enumerating objects: 202, done.
>remote: Counting objects: 100% (202/202), done.
>remote: Compressing objects: 100% (83/83), done.
>Receiving objects: 100% (8897606/8897606), 2.47 GiB | 11.99 MiB/s, done.
>remote: Total 8897606 (delta 150), reused 133 (delta 119), pack-reused 8897404
>error: index-pack died of signal 984000)
>fatal: index-pack failed
>
>ubuntu at VM-0-27-ubuntu:~/ath$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git
>Cloning into 'ath'...
>remote: Enumerating objects: 202, done.
>remote: Counting objects: 100% (202/202), done.
>remote: Compressing objects: 100% (83/83), done.
>remote: Total 8897606 (delta 150), reused 133 (delta 119), pack-reused 8897404
>Receiving objects: 100% (8897606/8897606), 2.47 GiB | 11.88 MiB/s, done.
>error: index-pack died of signal 984000)
>fatal: index-pack failed
>
>ubuntu at VM-0-27-ubuntu:~/ath$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/kvalo/ath.git
>Cloning into 'ath'...
>remote: Sending approximately 1.67 GiB ...
>remote: Counting objects: 29323, done
>remote: Finding sources: 100% (8897606/8897606)
>remote: Total 8897606 (delta 7524073), reused 8897044 (delta 7524073)
>Receiving objects: 100% (8897606/8897606), 1.67 GiB | 11.98 MiB/s, done.
>error: index-pack died of signal 94073)
>fatal: index-pack failed
>
>I tried these 3 servers but all failed. Any other ideas?

I fix it by adding virtual memory in my VM. And version v2 has been sent for this changes.
Seems some files has been fixed already. 

Thanks

From kvalo at kernel.org  Wed Jul 27 03:31:15 2022
From: kvalo at kernel.org (Kalle Valo)
Date: Wed, 27 Jul 2022 13:31:15 +0300
Subject: [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware feature strings
In-Reply-To: <20220719143302.2071223-5-bryan.odonoghue@linaro.org> (Bryan
	O'Donoghue's message of "Tue, 19 Jul 2022 15:33:02 +0100")
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
	<20220719143302.2071223-5-bryan.odonoghue@linaro.org>
Message-ID: <87k07yq230.fsf@kernel.org>

Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:

> Add in the ability to easily find the firmware feature bits reported in the
> get feature exchange without having to compile-in debug prints.
>
> root at linaro-alip:~# cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps
> MCC
> P2P
> DOT11AC
> SLM_SESSIONIZATION
> DOT11AC_OPMODE
> SAP32STA
> TDLS
> P2P_GO_NOA_DECOUPLE_INIT_SCAN
> WLANACTIVE_OFFLOAD
> BEACON_OFFLOAD
> SCAN_OFFLOAD
> BCN_MISS_OFFLOAD
> STA_POWERSAVE
> STA_ADVANCED_PWRSAVE
> BCN_FILTER
> RTT
> RATECTRL
> WOW
> WLAN_ROAM_SCAN_OFFLOAD
> SPECULATIVE_PS_POLL
> IBSS_HEARTBEAT_OFFLOAD
> WLAN_SCAN_OFFLOAD
> WLAN_PERIODIC_TX_PTRN
> ADVANCE_TDLS
> BATCH_SCAN
> FW_IN_TX_PATH
> EXTENDED_NSOFFLOAD_SLOT
> CH_SWITCH_V1
> HT40_OBSS_SCAN
> UPDATE_CHANNEL_LIST
> WLAN_MCADDR_FLT
> WLAN_CH144
> TDLS_SCAN_COEXISTENCE
> LINK_LAYER_STATS_MEAS
> MU_MIMO
> EXTENDED_SCAN
> DYNAMIC_WMM_PS
> MAC_SPOOFED_SCAN
> FW_STATS
> WPS_PRBRSP_TMPL
> BCN_IE_FLT_DELTA
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>

[...]

> +static ssize_t read_file_firmware_feature_caps(struct file *file,
> +					       char __user *user_buf,
> +					       size_t count, loff_t *ppos)
> +{
> +	struct wcn36xx *wcn = file->private_data;
> +	unsigned long page = get_zeroed_page(GFP_KERNEL);
> +	char *p = (char *)page;
> +	int i;
> +	int ret;
> +
> +	if (!p)
> +		return -ENOMEM;
> +
> +	mutex_lock(&wcn->hal_mutex);
> +	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
> +		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
> +			p += sprintf(p, "%s\n",
> +				     wcn36xx_firmware_get_cap_name(i));
> +		}
> +	}
> +	mutex_unlock(&wcn->hal_mutex);
> +
> +	ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
> +				      (unsigned long)p - page);
> +
> +	free_page(page);
> +	return ret;
> +}

Why not use the normal use kzalloc() and kfree()? That way you would not
need a separate page variable. What's the benefit from
get_zeroed_page()?

Also I don't see any checks for a memory allocation failure.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


From bryan.odonoghue at linaro.org  Wed Jul 27 03:41:48 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Wed, 27 Jul 2022 11:41:48 +0100
Subject: [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware
 feature strings
In-Reply-To: <87k07yq230.fsf@kernel.org>
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
 <20220719143302.2071223-5-bryan.odonoghue@linaro.org>
 <87k07yq230.fsf@kernel.org>
Message-ID: <582e56e7-87d1-e6b3-ac7a-00fe07a10a14@linaro.org>

On 27/07/2022 11:31, Kalle Valo wrote:
> Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:

>> +static ssize_t read_file_firmware_feature_caps(struct file *file,
>> +					       char __user *user_buf,
>> +					       size_t count, loff_t *ppos)
>> +{
>> +	struct wcn36xx *wcn = file->private_data;
>> +	unsigned long page = get_zeroed_page(GFP_KERNEL);
>> +	char *p = (char *)page;
>> +	int i;
>> +	int ret;
>> +
>> +	if (!p)
>> +		return -ENOMEM;
>> +
>> +	mutex_lock(&wcn->hal_mutex);
>> +	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
>> +		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
>> +			p += sprintf(p, "%s\n",
>> +				     wcn36xx_firmware_get_cap_name(i));
>> +		}
>> +	}
>> +	mutex_unlock(&wcn->hal_mutex);
>> +
>> +	ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
>> +				      (unsigned long)p - page);
>> +
>> +	free_page(page);
>> +	return ret;
>> +}
> 
> Why not use the normal use kzalloc() and kfree()? That way you would not
> need a separate page variable. What's the benefit from
> get_zeroed_page()?


TBH I did a copy/paste here from another driver... I forget which
> 
> Also I don't see any checks for a memory allocation failure.
> 

its there

char *p = (char*) page;

if (!p)
     return -ENOMEM;

I can V2 this for kzalloc and kfree if you prefer though

---
bod


From kvalo at kernel.org  Wed Jul 27 04:08:30 2022
From: kvalo at kernel.org (Kalle Valo)
Date: Wed, 27 Jul 2022 14:08:30 +0300
Subject: [PATCH v2 4/4] wcn36xx: Add debugfs entry to read firmware feature strings
In-Reply-To: <582e56e7-87d1-e6b3-ac7a-00fe07a10a14@linaro.org> (Bryan
	O'Donoghue's message of "Wed, 27 Jul 2022 11:41:48 +0100")
References: <20220719143302.2071223-1-bryan.odonoghue@linaro.org>
	<20220719143302.2071223-5-bryan.odonoghue@linaro.org>
	<87k07yq230.fsf@kernel.org>
	<582e56e7-87d1-e6b3-ac7a-00fe07a10a14@linaro.org>
Message-ID: <877d3yq0cx.fsf@kernel.org>

Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:

> On 27/07/2022 11:31, Kalle Valo wrote:
>> Bryan O'Donoghue <bryan.odonoghue at linaro.org> writes:
>
>>> +static ssize_t read_file_firmware_feature_caps(struct file *file,
>>> +					       char __user *user_buf,
>>> +					       size_t count, loff_t *ppos)
>>> +{
>>> +	struct wcn36xx *wcn = file->private_data;
>>> +	unsigned long page = get_zeroed_page(GFP_KERNEL);
>>> +	char *p = (char *)page;
>>> +	int i;
>>> +	int ret;
>>> +
>>> +	if (!p)
>>> +		return -ENOMEM;
>>> +
>>> +	mutex_lock(&wcn->hal_mutex);
>>> +	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
>>> +		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
>>> +			p += sprintf(p, "%s\n",
>>> +				     wcn36xx_firmware_get_cap_name(i));
>>> +		}
>>> +	}
>>> +	mutex_unlock(&wcn->hal_mutex);
>>> +
>>> +	ret = simple_read_from_buffer(user_buf, count, ppos, (char *)page,
>>> +				      (unsigned long)p - page);
>>> +
>>> +	free_page(page);
>>> +	return ret;
>>> +}
>>
>> Why not use the normal use kzalloc() and kfree()? That way you would not
>> need a separate page variable. What's the benefit from
>> get_zeroed_page()?
>
>
> TBH I did a copy/paste here from another driver... I forget which
>>
>> Also I don't see any checks for a memory allocation failure.
>>
>
> its there
>
> char *p = (char*) page;
>
> if (!p)
>     return -ENOMEM;

Ah, it's pretty evil to have the error handling so far away from the
actual call :)

> I can V2 this for kzalloc and kfree if you prefer though

Yes, please do that. We should use standard infrastructure as much as
possible.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


From bryan.odonoghue at linaro.org  Wed Jul 27 09:16:52 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Wed, 27 Jul 2022 17:16:52 +0100
Subject: [PATCH v3 1/4] wcn36xx: Rename clunky firmware feature bit enum
In-Reply-To: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
References: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
Message-ID: <20220727161655.2286867-2-bryan.odonoghue@linaro.org>

The enum name "place_holder_in_cap_bitmap" is self descriptively asking to
be changed to something else.

Rename place_holder_in_cap_bitmap to wcn36xx_firmware_feat_caps so that the
contents and intent of the enum is obvious.

Reviewed-by: Loic Poulain <loic.poulain at linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/hal.h  | 2 +-
 drivers/net/wireless/ath/wcn36xx/main.c | 2 +-
 drivers/net/wireless/ath/wcn36xx/smd.c  | 6 +++---
 drivers/net/wireless/ath/wcn36xx/smd.h  | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 46a49f0a51b34..5e48c97682c20 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4760,7 +4760,7 @@ struct wcn36xx_hal_set_power_params_resp {
 
 /* Capability bitmap exchange definitions and macros starts */
 
-enum place_holder_in_cap_bitmap {
+enum wcn36xx_firmware_feat_caps {
 	MCC = 0,
 	P2P = 1,
 	DOT11AC = 2,
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index e34d3d0b70820..efd776b20e608 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -260,7 +260,7 @@ static const char * const wcn36xx_caps_names[] = {
 
 #undef DEFINE
 
-static const char *wcn36xx_get_cap_name(enum place_holder_in_cap_bitmap x)
+static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
 {
 	if (x >= ARRAY_SIZE(wcn36xx_caps_names))
 		return "UNKNOWN";
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 7ac9a1e6f7686..88ee92be85625 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2431,7 +2431,7 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 	return ret;
 }
 
-void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
@@ -2445,7 +2445,7 @@ void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
 	bitmap[arr_idx] |= (1 << bit_idx);
 }
 
-int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
@@ -2460,7 +2460,7 @@ int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
 	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
 }
 
-void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap)
+void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
 {
 	int arr_idx, bit_idx;
 
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 3fd598ac2a27e..186dad4fe80eb 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -125,9 +125,9 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
 int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 			     u32 arg3, u32 arg4, u32 arg5);
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
-void set_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
-int get_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
-void clear_feat_caps(u32 *bitmap, enum place_holder_in_cap_bitmap cap);
+void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
+int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
+void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
 
 int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
 		struct ieee80211_sta *sta,
-- 
2.36.1



From bryan.odonoghue at linaro.org  Wed Jul 27 09:16:55 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Wed, 27 Jul 2022 17:16:55 +0100
Subject: [PATCH v3 4/4] wcn36xx: Add debugfs entry to read firmware feature strings
In-Reply-To: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
References: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
Message-ID: <20220727161655.2286867-5-bryan.odonoghue@linaro.org>

Add in the ability to easily find the firmware feature bits reported in the
get feature exchange without having to compile-in debug prints.

root at linaro-alip:~# cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps
MCC
P2P
DOT11AC
SLM_SESSIONIZATION
DOT11AC_OPMODE
SAP32STA
TDLS
P2P_GO_NOA_DECOUPLE_INIT_SCAN
WLANACTIVE_OFFLOAD
BEACON_OFFLOAD
SCAN_OFFLOAD
BCN_MISS_OFFLOAD
STA_POWERSAVE
STA_ADVANCED_PWRSAVE
BCN_FILTER
RTT
RATECTRL
WOW
WLAN_ROAM_SCAN_OFFLOAD
SPECULATIVE_PS_POLL
IBSS_HEARTBEAT_OFFLOAD
WLAN_SCAN_OFFLOAD
WLAN_PERIODIC_TX_PTRN
ADVANCE_TDLS
BATCH_SCAN
FW_IN_TX_PATH
EXTENDED_NSOFFLOAD_SLOT
CH_SWITCH_V1
HT40_OBSS_SCAN
UPDATE_CHANNEL_LIST
WLAN_MCADDR_FLT
WLAN_CH144
TDLS_SCAN_COEXISTENCE
LINK_LAYER_STATS_MEAS
MU_MIMO
EXTENDED_SCAN
DYNAMIC_WMM_PS
MAC_SPOOFED_SCAN
FW_STATS
WPS_PRBRSP_TMPL
BCN_IE_FLT_DELTA

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/debug.c | 39 ++++++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/debug.h |  1 +
 2 files changed, 40 insertions(+)

diff --git a/drivers/net/wireless/ath/wcn36xx/debug.c b/drivers/net/wireless/ath/wcn36xx/debug.c
index 6af306ae41ad9..58b3c0501bfde 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.c
+++ b/drivers/net/wireless/ath/wcn36xx/debug.c
@@ -21,6 +21,7 @@
 #include "wcn36xx.h"
 #include "debug.h"
 #include "pmc.h"
+#include "firmware.h"
 
 #ifdef CONFIG_WCN36XX_DEBUGFS
 
@@ -136,6 +137,42 @@ static const struct file_operations fops_wcn36xx_dump = {
 	.write =       write_file_dump,
 };
 
+static ssize_t read_file_firmware_feature_caps(struct file *file,
+					       char __user *user_buf,
+					       size_t count, loff_t *ppos)
+{
+	struct wcn36xx *wcn = file->private_data;
+	size_t len = 0, buf_len = 2048;
+	char *buf;
+	int i;
+	int ret;
+
+	buf = kzalloc(buf_len, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+
+	mutex_lock(&wcn->hal_mutex);
+	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
+			len += scnprintf(buf + len, buf_len - len, "%s\n",
+					 wcn36xx_firmware_get_cap_name(i));
+		}
+		if (len >= buf_len)
+			break;
+	}
+	mutex_unlock(&wcn->hal_mutex);
+
+	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	kfree(buf);
+
+	return ret;
+}
+
+static const struct file_operations fops_wcn36xx_firmware_feat_caps = {
+	.open = simple_open,
+	.read = read_file_firmware_feature_caps,
+};
+
 #define ADD_FILE(name, mode, fop, priv_data)		\
 	do {							\
 		struct dentry *d;				\
@@ -163,6 +200,8 @@ void wcn36xx_debugfs_init(struct wcn36xx *wcn)
 
 	ADD_FILE(bmps_switcher, 0600, &fops_wcn36xx_bmps, wcn);
 	ADD_FILE(dump, 0200, &fops_wcn36xx_dump, wcn);
+	ADD_FILE(firmware_feat_caps, 0200,
+		 &fops_wcn36xx_firmware_feat_caps, wcn);
 }
 
 void wcn36xx_debugfs_exit(struct wcn36xx *wcn)
diff --git a/drivers/net/wireless/ath/wcn36xx/debug.h b/drivers/net/wireless/ath/wcn36xx/debug.h
index 46307aa562d37..7116d96e0543d 100644
--- a/drivers/net/wireless/ath/wcn36xx/debug.h
+++ b/drivers/net/wireless/ath/wcn36xx/debug.h
@@ -31,6 +31,7 @@ struct wcn36xx_dfs_entry {
 	struct dentry *rootdir;
 	struct wcn36xx_dfs_file file_bmps_switcher;
 	struct wcn36xx_dfs_file file_dump;
+	struct wcn36xx_dfs_file file_firmware_feat_caps;
 };
 
 void wcn36xx_debugfs_init(struct wcn36xx *wcn);
-- 
2.36.1



From bryan.odonoghue at linaro.org  Wed Jul 27 09:16:54 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Wed, 27 Jul 2022 17:16:54 +0100
Subject: [PATCH v3 3/4] wcn36xx: Move capability bitmap to string translation function to firmware.c
In-Reply-To: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
References: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
Message-ID: <20220727161655.2286867-4-bryan.odonoghue@linaro.org>

Move wcn36xx_get_cap_name() function in main.c into firmware.c as
wcn36xx_firmware_get_cap_name().

Reviewed-by: Loic Poulain <loic.poulain at linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/firmware.c | 75 +++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h |  2 +
 drivers/net/wireless/ath/wcn36xx/main.c     | 81 +--------------------
 3 files changed, 81 insertions(+), 77 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
index 03b93d2bdcf96..4b7f439e4db58 100644
--- a/drivers/net/wireless/ath/wcn36xx/firmware.c
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
@@ -3,6 +3,81 @@
 #include "wcn36xx.h"
 #include "firmware.h"
 
+#define DEFINE(s)[s] = #s
+
+static const char * const wcn36xx_firmware_caps_names[] = {
+	DEFINE(MCC),
+	DEFINE(P2P),
+	DEFINE(DOT11AC),
+	DEFINE(SLM_SESSIONIZATION),
+	DEFINE(DOT11AC_OPMODE),
+	DEFINE(SAP32STA),
+	DEFINE(TDLS),
+	DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
+	DEFINE(WLANACTIVE_OFFLOAD),
+	DEFINE(BEACON_OFFLOAD),
+	DEFINE(SCAN_OFFLOAD),
+	DEFINE(ROAM_OFFLOAD),
+	DEFINE(BCN_MISS_OFFLOAD),
+	DEFINE(STA_POWERSAVE),
+	DEFINE(STA_ADVANCED_PWRSAVE),
+	DEFINE(AP_UAPSD),
+	DEFINE(AP_DFS),
+	DEFINE(BLOCKACK),
+	DEFINE(PHY_ERR),
+	DEFINE(BCN_FILTER),
+	DEFINE(RTT),
+	DEFINE(RATECTRL),
+	DEFINE(WOW),
+	DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
+	DEFINE(SPECULATIVE_PS_POLL),
+	DEFINE(SCAN_SCH),
+	DEFINE(IBSS_HEARTBEAT_OFFLOAD),
+	DEFINE(WLAN_SCAN_OFFLOAD),
+	DEFINE(WLAN_PERIODIC_TX_PTRN),
+	DEFINE(ADVANCE_TDLS),
+	DEFINE(BATCH_SCAN),
+	DEFINE(FW_IN_TX_PATH),
+	DEFINE(EXTENDED_NSOFFLOAD_SLOT),
+	DEFINE(CH_SWITCH_V1),
+	DEFINE(HT40_OBSS_SCAN),
+	DEFINE(UPDATE_CHANNEL_LIST),
+	DEFINE(WLAN_MCADDR_FLT),
+	DEFINE(WLAN_CH144),
+	DEFINE(NAN),
+	DEFINE(TDLS_SCAN_COEXISTENCE),
+	DEFINE(LINK_LAYER_STATS_MEAS),
+	DEFINE(MU_MIMO),
+	DEFINE(EXTENDED_SCAN),
+	DEFINE(DYNAMIC_WMM_PS),
+	DEFINE(MAC_SPOOFED_SCAN),
+	DEFINE(BMU_ERROR_GENERIC_RECOVERY),
+	DEFINE(DISA),
+	DEFINE(FW_STATS),
+	DEFINE(WPS_PRBRSP_TMPL),
+	DEFINE(BCN_IE_FLT_DELTA),
+	DEFINE(TDLS_OFF_CHANNEL),
+	DEFINE(RTT3),
+	DEFINE(MGMT_FRAME_LOGGING),
+	DEFINE(ENHANCED_TXBD_COMPLETION),
+	DEFINE(LOGGING_ENHANCEMENT),
+	DEFINE(EXT_SCAN_ENHANCED),
+	DEFINE(MEMORY_DUMP_SUPPORTED),
+	DEFINE(PER_PKT_STATS_SUPPORTED),
+	DEFINE(EXT_LL_STAT),
+	DEFINE(WIFI_CONFIG),
+	DEFINE(ANTENNA_DIVERSITY_SELECTION),
+};
+
+#undef DEFINE
+
+const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x)
+{
+	if (x >= ARRAY_SIZE(wcn36xx_firmware_caps_names))
+		return "UNKNOWN";
+	return wcn36xx_firmware_caps_names[x];
+}
+
 void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
 				    enum wcn36xx_firmware_feat_caps cap)
 {
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
index 552c0e9325e18..f991cf959f829 100644
--- a/drivers/net/wireless/ath/wcn36xx/firmware.h
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
@@ -78,5 +78,7 @@ int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
 void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
 				      enum wcn36xx_firmware_feat_caps cap);
 
+const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x);
+
 #endif /* _FIRMWARE_H_ */
 
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index af62911a4659f..fec85e89a02f7 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -193,88 +193,15 @@ static inline u8 get_sta_index(struct ieee80211_vif *vif,
 	       sta_priv->sta_index;
 }
 
-#define DEFINE(s) [s] = #s
-
-static const char * const wcn36xx_caps_names[] = {
-	DEFINE(MCC),
-	DEFINE(P2P),
-	DEFINE(DOT11AC),
-	DEFINE(SLM_SESSIONIZATION),
-	DEFINE(DOT11AC_OPMODE),
-	DEFINE(SAP32STA),
-	DEFINE(TDLS),
-	DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
-	DEFINE(WLANACTIVE_OFFLOAD),
-	DEFINE(BEACON_OFFLOAD),
-	DEFINE(SCAN_OFFLOAD),
-	DEFINE(ROAM_OFFLOAD),
-	DEFINE(BCN_MISS_OFFLOAD),
-	DEFINE(STA_POWERSAVE),
-	DEFINE(STA_ADVANCED_PWRSAVE),
-	DEFINE(AP_UAPSD),
-	DEFINE(AP_DFS),
-	DEFINE(BLOCKACK),
-	DEFINE(PHY_ERR),
-	DEFINE(BCN_FILTER),
-	DEFINE(RTT),
-	DEFINE(RATECTRL),
-	DEFINE(WOW),
-	DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
-	DEFINE(SPECULATIVE_PS_POLL),
-	DEFINE(SCAN_SCH),
-	DEFINE(IBSS_HEARTBEAT_OFFLOAD),
-	DEFINE(WLAN_SCAN_OFFLOAD),
-	DEFINE(WLAN_PERIODIC_TX_PTRN),
-	DEFINE(ADVANCE_TDLS),
-	DEFINE(BATCH_SCAN),
-	DEFINE(FW_IN_TX_PATH),
-	DEFINE(EXTENDED_NSOFFLOAD_SLOT),
-	DEFINE(CH_SWITCH_V1),
-	DEFINE(HT40_OBSS_SCAN),
-	DEFINE(UPDATE_CHANNEL_LIST),
-	DEFINE(WLAN_MCADDR_FLT),
-	DEFINE(WLAN_CH144),
-	DEFINE(NAN),
-	DEFINE(TDLS_SCAN_COEXISTENCE),
-	DEFINE(LINK_LAYER_STATS_MEAS),
-	DEFINE(MU_MIMO),
-	DEFINE(EXTENDED_SCAN),
-	DEFINE(DYNAMIC_WMM_PS),
-	DEFINE(MAC_SPOOFED_SCAN),
-	DEFINE(BMU_ERROR_GENERIC_RECOVERY),
-	DEFINE(DISA),
-	DEFINE(FW_STATS),
-	DEFINE(WPS_PRBRSP_TMPL),
-	DEFINE(BCN_IE_FLT_DELTA),
-	DEFINE(TDLS_OFF_CHANNEL),
-	DEFINE(RTT3),
-	DEFINE(MGMT_FRAME_LOGGING),
-	DEFINE(ENHANCED_TXBD_COMPLETION),
-	DEFINE(LOGGING_ENHANCEMENT),
-	DEFINE(EXT_SCAN_ENHANCED),
-	DEFINE(MEMORY_DUMP_SUPPORTED),
-	DEFINE(PER_PKT_STATS_SUPPORTED),
-	DEFINE(EXT_LL_STAT),
-	DEFINE(WIFI_CONFIG),
-	DEFINE(ANTENNA_DIVERSITY_SELECTION),
-};
-
-#undef DEFINE
-
-static const char *wcn36xx_get_cap_name(enum wcn36xx_firmware_feat_caps x)
-{
-	if (x >= ARRAY_SIZE(wcn36xx_caps_names))
-		return "UNKNOWN";
-	return wcn36xx_caps_names[x];
-}
-
 static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
 {
 	int i;
 
 	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
-		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
-			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i)) {
+			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n",
+				    wcn36xx_firmware_get_cap_name(i));
+		}
 	}
 }
 
-- 
2.36.1



From bryan.odonoghue at linaro.org  Wed Jul 27 09:16:51 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Wed, 27 Jul 2022 17:16:51 +0100
Subject: [PATCH v3 0/4] wcn36xx: Add in debugfs export of firmware feature bits
Message-ID: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>

V3:
- Adds RB from Loic for 3/4 patches - Loic
- Leaves RB from Loic out of patch 4/4 which has been updated since - bod
- Uses kzalloc/kfree for memory allocation - Kalle
- Co-locates memory check adjacent to memory allocation - Kalle
- Uses scnprintf instead of sprintf - bod

V2:
- Drops "FW Cap = " prefix from each feature item - Loic

V1:
This series tidies up the code to get/set/clear discovered firmware feature
bits and adds a new debugfs entry to read the feature bits as strings.

cat /sys/kernel/debug/ieee80211/phy0/wcn36xx/firmware_feat_caps

wcn3680b:
FW Cap = MCC
FW Cap = P2P
FW Cap = DOT11AC
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = MU_MIMO
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

wcn3620:
FW Cap = MCC
FW Cap = P2P
FW Cap = SLM_SESSIONIZATION
FW Cap = DOT11AC_OPMODE
FW Cap = SAP32STA
FW Cap = TDLS
FW Cap = P2P_GO_NOA_DECOUPLE_INIT_SCAN
FW Cap = WLANACTIVE_OFFLOAD
FW Cap = BEACON_OFFLOAD
FW Cap = SCAN_OFFLOAD
FW Cap = BCN_MISS_OFFLOAD
FW Cap = STA_POWERSAVE
FW Cap = STA_ADVANCED_PWRSAVE
FW Cap = BCN_FILTER
FW Cap = RTT
FW Cap = RATECTRL
FW Cap = WOW
FW Cap = WLAN_ROAM_SCAN_OFFLOAD
FW Cap = SPECULATIVE_PS_POLL
FW Cap = IBSS_HEARTBEAT_OFFLOAD
FW Cap = WLAN_SCAN_OFFLOAD
FW Cap = WLAN_PERIODIC_TX_PTRN
FW Cap = ADVANCE_TDLS
FW Cap = BATCH_SCAN
FW Cap = FW_IN_TX_PATH
FW Cap = EXTENDED_NSOFFLOAD_SLOT
FW Cap = CH_SWITCH_V1
FW Cap = HT40_OBSS_SCAN
FW Cap = UPDATE_CHANNEL_LIST
FW Cap = WLAN_MCADDR_FLT
FW Cap = WLAN_CH144
FW Cap = TDLS_SCAN_COEXISTENCE
FW Cap = LINK_LAYER_STATS_MEAS
FW Cap = EXTENDED_SCAN
FW Cap = DYNAMIC_WMM_PS
FW Cap = MAC_SPOOFED_SCAN
FW Cap = FW_STATS
FW Cap = WPS_PRBRSP_TMPL
FW Cap = BCN_IE_FLT_DELTA

This is a handy way of debugging WiFi on different platforms without
necessarily having to recompile to see the debug printout on firmware boot.

Bryan O'Donoghue (4):
  wcn36xx: Rename clunky firmware feature bit enum
  wcn36xx: Move firmware feature bit storage to dedicated firmware.c
    file
  wcn36xx: Move capability bitmap to string translation function to
    firmware.c
  wcn36xx: Add debugfs entry to read firmware feature strings

 drivers/net/wireless/ath/wcn36xx/Makefile   |   3 +-
 drivers/net/wireless/ath/wcn36xx/debug.c    |  40 +++++++
 drivers/net/wireless/ath/wcn36xx/debug.h    |   1 +
 drivers/net/wireless/ath/wcn36xx/firmware.c | 125 ++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h |  84 +++++++++++++
 drivers/net/wireless/ath/wcn36xx/hal.h      |  68 -----------
 drivers/net/wireless/ath/wcn36xx/main.c     |  86 ++------------
 drivers/net/wireless/ath/wcn36xx/smd.c      |  57 ++-------
 drivers/net/wireless/ath/wcn36xx/smd.h      |   3 -
 9 files changed, 267 insertions(+), 200 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h

-- 
2.36.1



From bryan.odonoghue at linaro.org  Wed Jul 27 09:16:53 2022
From: bryan.odonoghue at linaro.org (Bryan O'Donoghue)
Date: Wed, 27 Jul 2022 17:16:53 +0100
Subject: [PATCH v3 2/4] wcn36xx: Move firmware feature bit storage to dedicated firmware.c file
In-Reply-To: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
References: <20220727161655.2286867-1-bryan.odonoghue@linaro.org>
Message-ID: <20220727161655.2286867-3-bryan.odonoghue@linaro.org>

The naming of the get/set/clear firmware feature capability bits doesn't
really follow the established namespace pattern of
wcn36xx_logicalblock_do_something();

The feature bits are accessed by smd.c and main.c. It would be nice to
display the found feature bits in debugfs. To do so though we should tidy
up the namespace a bit.

Move the firmware feature exchange API to its own file - firmware.c giving
us the opportunity to functionally decompose other firmware related
accessors as appropriate in future.

Reviewed-by: Loic Poulain <loic.poulain at linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/Makefile   |  3 +-
 drivers/net/wireless/ath/wcn36xx/firmware.c | 50 +++++++++++++
 drivers/net/wireless/ath/wcn36xx/firmware.h | 82 +++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/hal.h      | 68 -----------------
 drivers/net/wireless/ath/wcn36xx/main.c     |  7 +-
 drivers/net/wireless/ath/wcn36xx/smd.c      | 57 ++------------
 drivers/net/wireless/ath/wcn36xx/smd.h      |  3 -
 7 files changed, 146 insertions(+), 124 deletions(-)
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.c
 create mode 100644 drivers/net/wireless/ath/wcn36xx/firmware.h

diff --git a/drivers/net/wireless/ath/wcn36xx/Makefile b/drivers/net/wireless/ath/wcn36xx/Makefile
index 27413703ad69b..26bec795b3726 100644
--- a/drivers/net/wireless/ath/wcn36xx/Makefile
+++ b/drivers/net/wireless/ath/wcn36xx/Makefile
@@ -5,6 +5,7 @@ wcn36xx-y +=   main.o \
                txrx.o \
                smd.o \
                pmc.o \
-               debug.o
+               debug.o \
+               firmware.o
 
 wcn36xx-$(CONFIG_NL80211_TESTMODE) += testmode.o
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.c b/drivers/net/wireless/ath/wcn36xx/firmware.c
new file mode 100644
index 0000000000000..03b93d2bdcf96
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include "wcn36xx.h"
+#include "firmware.h"
+
+void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
+				    enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+	bitmap[arr_idx] |= (1 << bit_idx);
+}
+
+int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
+				   enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return -EINVAL;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+
+	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
+}
+
+void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
+				      enum wcn36xx_firmware_feat_caps cap)
+{
+	int arr_idx, bit_idx;
+
+	if (cap < 0 || cap > 127) {
+		wcn36xx_warn("error cap idx %d\n", cap);
+		return;
+	}
+
+	arr_idx = cap / 32;
+	bit_idx = cap % 32;
+	bitmap[arr_idx] &= ~(1 << bit_idx);
+}
diff --git a/drivers/net/wireless/ath/wcn36xx/firmware.h b/drivers/net/wireless/ath/wcn36xx/firmware.h
new file mode 100644
index 0000000000000..552c0e9325e18
--- /dev/null
+++ b/drivers/net/wireless/ath/wcn36xx/firmware.h
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _FIRMWARE_H_
+#define _FIRMWARE_H_
+
+/* Capability bitmap exchange definitions and macros starts */
+
+enum wcn36xx_firmware_feat_caps {
+	MCC = 0,
+	P2P = 1,
+	DOT11AC = 2,
+	SLM_SESSIONIZATION = 3,
+	DOT11AC_OPMODE = 4,
+	SAP32STA = 5,
+	TDLS = 6,
+	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
+	WLANACTIVE_OFFLOAD = 8,
+	BEACON_OFFLOAD = 9,
+	SCAN_OFFLOAD = 10,
+	ROAM_OFFLOAD = 11,
+	BCN_MISS_OFFLOAD = 12,
+	STA_POWERSAVE = 13,
+	STA_ADVANCED_PWRSAVE = 14,
+	AP_UAPSD = 15,
+	AP_DFS = 16,
+	BLOCKACK = 17,
+	PHY_ERR = 18,
+	BCN_FILTER = 19,
+	RTT = 20,
+	RATECTRL = 21,
+	WOW = 22,
+	WLAN_ROAM_SCAN_OFFLOAD = 23,
+	SPECULATIVE_PS_POLL = 24,
+	SCAN_SCH = 25,
+	IBSS_HEARTBEAT_OFFLOAD = 26,
+	WLAN_SCAN_OFFLOAD = 27,
+	WLAN_PERIODIC_TX_PTRN = 28,
+	ADVANCE_TDLS = 29,
+	BATCH_SCAN = 30,
+	FW_IN_TX_PATH = 31,
+	EXTENDED_NSOFFLOAD_SLOT = 32,
+	CH_SWITCH_V1 = 33,
+	HT40_OBSS_SCAN = 34,
+	UPDATE_CHANNEL_LIST = 35,
+	WLAN_MCADDR_FLT = 36,
+	WLAN_CH144 = 37,
+	NAN = 38,
+	TDLS_SCAN_COEXISTENCE = 39,
+	LINK_LAYER_STATS_MEAS = 40,
+	MU_MIMO = 41,
+	EXTENDED_SCAN = 42,
+	DYNAMIC_WMM_PS = 43,
+	MAC_SPOOFED_SCAN = 44,
+	BMU_ERROR_GENERIC_RECOVERY = 45,
+	DISA = 46,
+	FW_STATS = 47,
+	WPS_PRBRSP_TMPL = 48,
+	BCN_IE_FLT_DELTA = 49,
+	TDLS_OFF_CHANNEL = 51,
+	RTT3 = 52,
+	MGMT_FRAME_LOGGING = 53,
+	ENHANCED_TXBD_COMPLETION = 54,
+	LOGGING_ENHANCEMENT = 55,
+	EXT_SCAN_ENHANCED = 56,
+	MEMORY_DUMP_SUPPORTED = 57,
+	PER_PKT_STATS_SUPPORTED = 58,
+	EXT_LL_STAT = 60,
+	WIFI_CONFIG = 61,
+	ANTENNA_DIVERSITY_SELECTION = 62,
+
+	MAX_FEATURE_SUPPORTED = 128,
+};
+
+void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
+				    enum wcn36xx_firmware_feat_caps cap);
+int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
+				   enum wcn36xx_firmware_feat_caps cap);
+void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
+				      enum wcn36xx_firmware_feat_caps cap);
+
+#endif /* _FIRMWARE_H_ */
+
diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 5e48c97682c20..5c45b23c78802 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -4758,74 +4758,6 @@ struct wcn36xx_hal_set_power_params_resp {
 	u32 status;
 } __packed;
 
-/* Capability bitmap exchange definitions and macros starts */
-
-enum wcn36xx_firmware_feat_caps {
-	MCC = 0,
-	P2P = 1,
-	DOT11AC = 2,
-	SLM_SESSIONIZATION = 3,
-	DOT11AC_OPMODE = 4,
-	SAP32STA = 5,
-	TDLS = 6,
-	P2P_GO_NOA_DECOUPLE_INIT_SCAN = 7,
-	WLANACTIVE_OFFLOAD = 8,
-	BEACON_OFFLOAD = 9,
-	SCAN_OFFLOAD = 10,
-	ROAM_OFFLOAD = 11,
-	BCN_MISS_OFFLOAD = 12,
-	STA_POWERSAVE = 13,
-	STA_ADVANCED_PWRSAVE = 14,
-	AP_UAPSD = 15,
-	AP_DFS = 16,
-	BLOCKACK = 17,
-	PHY_ERR = 18,
-	BCN_FILTER = 19,
-	RTT = 20,
-	RATECTRL = 21,
-	WOW = 22,
-	WLAN_ROAM_SCAN_OFFLOAD = 23,
-	SPECULATIVE_PS_POLL = 24,
-	SCAN_SCH = 25,
-	IBSS_HEARTBEAT_OFFLOAD = 26,
-	WLAN_SCAN_OFFLOAD = 27,
-	WLAN_PERIODIC_TX_PTRN = 28,
-	ADVANCE_TDLS = 29,
-	BATCH_SCAN = 30,
-	FW_IN_TX_PATH = 31,
-	EXTENDED_NSOFFLOAD_SLOT = 32,
-	CH_SWITCH_V1 = 33,
-	HT40_OBSS_SCAN = 34,
-	UPDATE_CHANNEL_LIST = 35,
-	WLAN_MCADDR_FLT = 36,
-	WLAN_CH144 = 37,
-	NAN = 38,
-	TDLS_SCAN_COEXISTENCE = 39,
-	LINK_LAYER_STATS_MEAS = 40,
-	MU_MIMO = 41,
-	EXTENDED_SCAN = 42,
-	DYNAMIC_WMM_PS = 43,
-	MAC_SPOOFED_SCAN = 44,
-	BMU_ERROR_GENERIC_RECOVERY = 45,
-	DISA = 46,
-	FW_STATS = 47,
-	WPS_PRBRSP_TMPL = 48,
-	BCN_IE_FLT_DELTA = 49,
-	TDLS_OFF_CHANNEL = 51,
-	RTT3 = 52,
-	MGMT_FRAME_LOGGING = 53,
-	ENHANCED_TXBD_COMPLETION = 54,
-	LOGGING_ENHANCEMENT = 55,
-	EXT_SCAN_ENHANCED = 56,
-	MEMORY_DUMP_SUPPORTED = 57,
-	PER_PKT_STATS_SUPPORTED = 58,
-	EXT_LL_STAT = 60,
-	WIFI_CONFIG = 61,
-	ANTENNA_DIVERSITY_SELECTION = 62,
-
-	MAX_FEATURE_SUPPORTED = 128,
-};
-
 #define WCN36XX_HAL_CAPS_SIZE 4
 
 struct wcn36xx_hal_feat_caps_msg {
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index efd776b20e608..af62911a4659f 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -28,6 +28,7 @@
 #include <net/ipv6.h>
 #include "wcn36xx.h"
 #include "testmode.h"
+#include "firmware.h"
 
 unsigned int wcn36xx_dbg_mask;
 module_param_named(debug_mask, wcn36xx_dbg_mask, uint, 0644);
@@ -272,7 +273,7 @@ static void wcn36xx_feat_caps_info(struct wcn36xx *wcn)
 	int i;
 
 	for (i = 0; i < MAX_FEATURE_SUPPORTED; i++) {
-		if (get_feat_caps(wcn->fw_feat_caps, i))
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, i))
 			wcn36xx_dbg(WCN36XX_DBG_MAC, "FW Cap %s\n", wcn36xx_get_cap_name(i));
 	}
 }
@@ -705,7 +706,7 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw,
 {
 	struct wcn36xx *wcn = hw->priv;
 
-	if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+	if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
 		/* fallback to mac80211 software scan */
 		return 1;
 	}
@@ -743,7 +744,7 @@ static void wcn36xx_cancel_hw_scan(struct ieee80211_hw *hw,
 	wcn->scan_aborted = true;
 	mutex_unlock(&wcn->scan_lock);
 
-	if (get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
+	if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) {
 		/* ieee80211_scan_completed will be called on FW scan
 		 * indication */
 		wcn36xx_smd_stop_hw_scan(wcn);
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 88ee92be85625..d2a994fee8123 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -22,6 +22,7 @@
 #include <linux/bitops.h>
 #include <linux/rpmsg.h>
 #include "smd.h"
+#include "firmware.h"
 
 struct wcn36xx_cfg_val {
 	u32 cfg_id;
@@ -295,7 +296,7 @@ static void wcn36xx_smd_set_sta_vht_params(struct wcn36xx *wcn,
 		sta_params->vht_capable = sta->deflink.vht_cap.vht_supported;
 		sta_params->vht_ldpc_enabled =
 			is_cap_supported(caps, IEEE80211_VHT_CAP_RXLDPC);
-		if (get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
+		if (wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, MU_MIMO)) {
 			sta_params->vht_tx_mu_beamformee_capable =
 				is_cap_supported(caps, IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE);
 			if (sta_params->vht_tx_mu_beamformee_capable)
@@ -2431,49 +2432,6 @@ int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 	return ret;
 }
 
-void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-	bitmap[arr_idx] |= (1 << bit_idx);
-}
-
-int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return -EINVAL;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-
-	return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
-}
-
-void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap)
-{
-	int arr_idx, bit_idx;
-
-	if (cap < 0 || cap > 127) {
-		wcn36xx_warn("error cap idx %d\n", cap);
-		return;
-	}
-
-	arr_idx = cap / 32;
-	bit_idx = cap % 32;
-	bitmap[arr_idx] &= ~(1 << bit_idx);
-}
-
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
 {
 	struct wcn36xx_hal_feat_caps_msg msg_body, *rsp;
@@ -2482,11 +2440,12 @@ int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn)
 	mutex_lock(&wcn->hal_mutex);
 	INIT_HAL_MSG(msg_body, WCN36XX_HAL_FEATURE_CAPS_EXCHANGE_REQ);
 
-	set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
+	wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, STA_POWERSAVE);
 	if (wcn->rf_id == RF_IRIS_WCN3680) {
-		set_feat_caps(msg_body.feat_caps, DOT11AC);
-		set_feat_caps(msg_body.feat_caps, WLAN_CH144);
-		set_feat_caps(msg_body.feat_caps, ANTENNA_DIVERSITY_SELECTION);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, DOT11AC);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps, WLAN_CH144);
+		wcn36xx_firmware_set_feat_caps(msg_body.feat_caps,
+					       ANTENNA_DIVERSITY_SELECTION);
 	}
 
 	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
@@ -3300,7 +3259,7 @@ int wcn36xx_smd_add_beacon_filter(struct wcn36xx *wcn,
 	size_t payload_size;
 	int ret;
 
-	if (!get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
+	if (!wcn36xx_firmware_get_feat_caps(wcn->fw_feat_caps, BCN_FILTER))
 		return -EOPNOTSUPP;
 
 	mutex_lock(&wcn->hal_mutex);
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 186dad4fe80eb..cf15cde2a3645 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -125,9 +125,6 @@ int wcn36xx_smd_keep_alive_req(struct wcn36xx *wcn,
 int wcn36xx_smd_dump_cmd_req(struct wcn36xx *wcn, u32 arg1, u32 arg2,
 			     u32 arg3, u32 arg4, u32 arg5);
 int wcn36xx_smd_feature_caps_exchange(struct wcn36xx *wcn);
-void set_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
-int get_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
-void clear_feat_caps(u32 *bitmap, enum wcn36xx_firmware_feat_caps cap);
 
 int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
 		struct ieee80211_sta *sta,
-- 
2.36.1



From kvalo at kernel.org  Fri Jul 29 06:24:52 2022
From: kvalo at kernel.org (Kalle Valo)
Date: Fri, 29 Jul 2022 13:24:52 +0000 (UTC)
Subject: [PATCH v3 1/4] wcn36xx: Rename clunky firmware feature bit enum
In-Reply-To: <20220727161655.2286867-2-bryan.odonoghue@linaro.org>
References: <20220727161655.2286867-2-bryan.odonoghue@linaro.org>
Message-ID: <165910108848.7985.3358974290537883596.kvalo@kernel.org>

Bryan O'Donoghue <bryan.odonoghue at linaro.org> wrote:

> The enum name "place_holder_in_cap_bitmap" is self descriptively asking to
> be changed to something else.
> 
> Rename place_holder_in_cap_bitmap to wcn36xx_firmware_feat_caps so that the
> contents and intent of the enum is obvious.
> 
> Reviewed-by: Loic Poulain <loic.poulain at linaro.org>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
> Signed-off-by: Kalle Valo <quic_kvalo at quicinc.com>

4 patches applied to ath-next branch of ath.git, thanks.

5b7fc772e657 wifi: wcn36xx: Rename clunky firmware feature bit enum
37de943d0153 wifi: wcn36xx: Move firmware feature bit storage to dedicated firmware.c file
75072b2970a8 wifi: wcn36xx: Move capability bitmap to string translation function to firmware.c
5cc8cc4406ed wifi: wcn36xx: Add debugfs entry to read firmware feature strings

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220727161655.2286867-2-bryan.odonoghue at linaro.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



