]> git.baikalelectronics.ru Git - kernel.git/commitdiff
wifi: wcn36xx: Move firmware feature bit storage to dedicated firmware.c file
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Wed, 27 Jul 2022 16:16:53 +0000 (17:16 +0100)
committerKalle Valo <quic_kvalo@quicinc.com>
Fri, 29 Jul 2022 13:24:38 +0000 (16:24 +0300)
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@linaro.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220727161655.2286867-3-bryan.odonoghue@linaro.org
drivers/net/wireless/ath/wcn36xx/Makefile
drivers/net/wireless/ath/wcn36xx/firmware.c [new file with mode: 0644]
drivers/net/wireless/ath/wcn36xx/firmware.h [new file with mode: 0644]
drivers/net/wireless/ath/wcn36xx/hal.h
drivers/net/wireless/ath/wcn36xx/main.c
drivers/net/wireless/ath/wcn36xx/smd.c
drivers/net/wireless/ath/wcn36xx/smd.h

index 27413703ad69bff163ab227dbc0b785bb8bc4387..26bec795b3726d79530972ba5efa37c51604531e 100644 (file)
@@ -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 (file)
index 0000000..03b93d2
--- /dev/null
@@ -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 (file)
index 0000000..552c0e9
--- /dev/null
@@ -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_ */
+
index 555226a440f878eb789f4c05fb49f835605377a1..f1a43fd1d957dfcd324e7723fbff5f564ef23b50 100644 (file)
@@ -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 {
index e7c3cef060b89eb62979905704b9377a1d4c4250..da56ac1c2d9ea22d89d95a2146073b595ccfba04 100644 (file)
@@ -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);
index c9e9dd011e7155146a9e4fd897a021baaecb4e5a..566f0b9c15841efabc101bc29fd6c52b3a49a8a7 100644 (file)
@@ -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 @@ out:
        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);
index 186dad4fe80eb58e7bc00dff39ffbcb7a018c2ec..cf15cde2a364572e6ae4167319b59e9d7f276839 100644 (file)
@@ -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,