Commit 37de943d authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Kalle Valo
Browse files

wifi: wcn36xx: Move firmware feature bit storage to dedicated firmware.c file



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: default avatarLoic Poulain <loic.poulain@linaro.org>
Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220727161655.2286867-3-bryan.odonoghue@linaro.org
parent 5b7fc772
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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
+50 −0
Original line number Diff line number Diff line
// 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);
}
+82 −0
Original line number Diff line number Diff line
/* 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_ */
+0 −68
Original line number Diff line number Diff line
@@ -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 {
+4 −3
Original line number Diff line number Diff line
@@ -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);
Loading