Browse Source

qcacmn: APIs to convert phy_ch_width to nl80211_chan_width and vice-versa

Add Spectral APIs to convert channel width values
from enum phy_ch_width to nl80211_chan_width and
vice-versa.

CRs-Fixed: 3029184
Change-Id: I60fb7fb04b943b0d70c569ff6587e5e8efd7722b
Jhalak Naik 3 years ago
parent
commit
b65b4ae703

+ 20 - 0
os_if/linux/spectral/inc/wlan_cfg80211_spectral.h

@@ -48,6 +48,26 @@ extern const struct nla_policy
 	QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_REQUEST_TYPE_SCAN_AND_CONFIG) || \
 	(type == QCA_WLAN_VENDOR_ATTR_SPECTRAL_SCAN_REQUEST_TYPE_SCAN))
 
+/**
+ * wlan_spectral_get_nl80211_chwidth() - Get nl80211_chan_width value for
+ * channel width from enum phy_ch_width
+ * @phy_chwidth: enum phy_ch_width channel width value
+ *
+ * Return: channel width converted to nl80211_chan_width
+ */
+int
+wlan_spectral_get_nl80211_chwidth(uint8_t phy_chwidth);
+
+/**
+ * wlan_spectral_get_phy_ch_width() - Convert channel width from
+ * nl80211_chan_width to enum phy_ch_width
+ * @nl_chwidth: nl80211 channel width value
+ *
+ * Return: channel width converted to phy_ch_width
+ */
+uint8_t
+wlan_spectral_get_phy_ch_width(uint8_t nl_chwidth);
+
 /**
  * wlan_cfg80211_register_spectral_cmd_handler() - Registration api for spectral
  * @pdev:    Pointer to pdev

+ 3 - 0
os_if/linux/spectral/src/os_if_spectral_netlink.c

@@ -18,6 +18,7 @@
  */
 
 #include <os_if_spectral_netlink.h>
+#include <wlan_cfg80211_spectral.h>
 #include <spectral_cmn_api_i.h>
 #include <spectral_defs_i.h>
 #include <wlan_nlink_srv.h>
@@ -600,6 +601,8 @@ os_if_spectral_netlink_init(struct wlan_objmgr_pdev *pdev)
 	nl_cb.send_nl_bcast = os_if_spectral_nl_bcast_msg;
 	nl_cb.send_nl_unicast = os_if_spectral_nl_unicast_msg;
 	nl_cb.free_sbuff = os_if_spectral_free_skb;
+	nl_cb.convert_to_phy_ch_width = wlan_spectral_get_phy_ch_width;
+	nl_cb.convert_to_nl_ch_width = wlan_spectral_get_nl80211_chwidth;
 
 	if (sptrl_ctx->sptrlc_register_netlink_cb)
 		sptrl_ctx->sptrlc_register_netlink_cb(pdev, &nl_cb);

+ 106 - 0
os_if/linux/spectral/src/wlan_cfg80211_spectral.c

@@ -201,6 +201,112 @@ convert_spectral_err_code_internal_to_nl
 	return QDF_STATUS_SUCCESS;
 }
 
+#ifdef WLAN_FEATURE_11BE
+int
+wlan_spectral_get_nl80211_chwidth(uint8_t phy_chwidth)
+{
+	switch ((enum phy_ch_width)phy_chwidth) {
+	case CH_WIDTH_5MHZ:
+		return NL80211_CHAN_WIDTH_5;
+	case CH_WIDTH_10MHZ:
+		return NL80211_CHAN_WIDTH_10;
+	case CH_WIDTH_20MHZ:
+		return NL80211_CHAN_WIDTH_20;
+	case CH_WIDTH_40MHZ:
+		return NL80211_CHAN_WIDTH_40;
+	case CH_WIDTH_80MHZ:
+		return NL80211_CHAN_WIDTH_80;
+	case CH_WIDTH_160MHZ:
+		return NL80211_CHAN_WIDTH_160;
+	case CH_WIDTH_80P80MHZ:
+		return NL80211_CHAN_WIDTH_80P80;
+	case CH_WIDTH_320MHZ:
+	case CH_WIDTH_MAX:
+		return NL80211_CHAN_WIDTH_320;
+	case CH_WIDTH_INVALID:
+	default:
+		osif_err("Invalid spectral channel width %u", phy_chwidth);
+		return -EINVAL;
+	}
+}
+
+uint8_t
+wlan_spectral_get_phy_ch_width(uint8_t nl_chwidth)
+{
+	switch ((enum nl80211_chan_width)nl_chwidth) {
+	case NL80211_CHAN_WIDTH_5:
+		return CH_WIDTH_5MHZ;
+	case NL80211_CHAN_WIDTH_10:
+		return CH_WIDTH_10MHZ;
+	case NL80211_CHAN_WIDTH_20:
+		return CH_WIDTH_20MHZ;
+	case NL80211_CHAN_WIDTH_40:
+		return CH_WIDTH_40MHZ;
+	case NL80211_CHAN_WIDTH_80:
+		return CH_WIDTH_80MHZ;
+	case NL80211_CHAN_WIDTH_160:
+		return CH_WIDTH_160MHZ;
+	case NL80211_CHAN_WIDTH_80P80:
+		return CH_WIDTH_80P80MHZ;
+	case NL80211_CHAN_WIDTH_320:
+		return CH_WIDTH_320MHZ;
+	default:
+		osif_err("Invalid nl80211 channel width %u", nl_chwidth);
+		return CH_WIDTH_INVALID;
+	}
+}
+#else
+int
+wlan_spectral_get_nl80211_chwidth(uint8_t phy_chwidth)
+{
+	switch ((enum phy_ch_width)phy_chwidth) {
+	case CH_WIDTH_5MHZ:
+		return NL80211_CHAN_WIDTH_5;
+	case CH_WIDTH_10MHZ:
+		return NL80211_CHAN_WIDTH_10;
+	case CH_WIDTH_20MHZ:
+		return NL80211_CHAN_WIDTH_20;
+	case CH_WIDTH_40MHZ:
+		return NL80211_CHAN_WIDTH_40;
+	case CH_WIDTH_80MHZ:
+		return NL80211_CHAN_WIDTH_80;
+	case CH_WIDTH_160MHZ:
+	case CH_WIDTH_MAX:
+		return NL80211_CHAN_WIDTH_160;
+	case CH_WIDTH_80P80MHZ:
+		return NL80211_CHAN_WIDTH_80P80;
+	case CH_WIDTH_INVALID:
+	default:
+		osif_err("Invalid spectral channel width %u", phy_chwidth);
+		return -EINVAL;
+	}
+}
+
+uint8_t
+wlan_spectral_get_phy_ch_width(uint8_t nl_chwidth)
+{
+	switch ((enum nl80211_chan_width)nl_chwidth) {
+	case NL80211_CHAN_WIDTH_5:
+		return CH_WIDTH_5MHZ;
+	case NL80211_CHAN_WIDTH_10:
+		return CH_WIDTH_10MHZ;
+	case NL80211_CHAN_WIDTH_20:
+		return CH_WIDTH_20MHZ;
+	case NL80211_CHAN_WIDTH_40:
+		return CH_WIDTH_40MHZ;
+	case NL80211_CHAN_WIDTH_80:
+		return CH_WIDTH_80MHZ;
+	case NL80211_CHAN_WIDTH_160:
+		return CH_WIDTH_160MHZ;
+	case NL80211_CHAN_WIDTH_80P80:
+		return CH_WIDTH_80P80MHZ;
+	default:
+		osif_err("Invalid nl80211 channel width %u", nl_chwidth);
+		return CH_WIDTH_INVALID;
+	}
+}
+#endif /* WLAN_FEATURE_11BE */
+
 #ifdef DIRECT_BUF_RX_DEBUG
 QDF_STATUS wlan_cfg80211_spectral_scan_dma_debug_config(
 	struct wlan_objmgr_pdev *pdev,

+ 5 - 3
spectral/dispatcher/inc/spectral_ioctl.h

@@ -190,11 +190,9 @@ enum spectral_chan_width {
 	SPECTRAL_CH_WIDTH_80MHZ,
 	SPECTRAL_CH_WIDTH_160MHZ,
 	SPECTRAL_CH_WIDTH_80P80MHZ,
+	SPECTRAL_CH_WIDTH_320MHZ,
 	SPECTRAL_CH_WIDTH_5MHZ,
 	SPECTRAL_CH_WIDTH_10MHZ,
-#ifdef WLAN_FEATURE_11BE
-	SPECTRAL_CH_WIDTH_320MHZ,
-#endif
 	SPECTRAL_CH_WIDTH_MAX,
 	SPECTRAL_CH_WIDTH_INVALID,
 };
@@ -356,11 +354,13 @@ struct spectral_config {
  * @agile_spectral_cap: agile Spectral capability for 20/40/80
  * @agile_spectral_cap_160: agile Spectral capability for 160 MHz
  * @agile_spectral_cap_80p80: agile Spectral capability for 80p80
+ * @agile_spectral_cap_320: agile Spectral capability for 320
  * @num_detectors_20mhz: number of Spectral detectors in 20 MHz
  * @num_detectors_40mhz: number of Spectral detectors in 40 MHz
  * @num_detectors_80mhz: number of Spectral detectors in 80 MHz
  * @num_detectors_160mhz: number of Spectral detectors in 160 MHz
  * @num_detectors_80p80mhz: number of Spectral detectors in 80p80 MHz
+ * @num_detectors_320mhz: number of Spectral detectors in 320 MHz
  */
 struct spectral_caps {
 	uint8_t phydiag_cap;
@@ -377,11 +377,13 @@ struct spectral_caps {
 	bool agile_spectral_cap;
 	bool agile_spectral_cap_160;
 	bool agile_spectral_cap_80p80;
+	bool agile_spectral_cap_320;
 	uint32_t num_detectors_20mhz;
 	uint32_t num_detectors_40mhz;
 	uint32_t num_detectors_80mhz;
 	uint32_t num_detectors_160mhz;
 	uint32_t num_detectors_80p80mhz;
+	uint32_t num_detectors_320mhz;
 };
 
 #define SPECTRAL_IOCTL_PARAM_NOVAL (65535)

+ 2 - 0
spectral/dispatcher/inc/wlan_spectral_public_structs.h

@@ -356,6 +356,8 @@ struct spectral_nl_cb {
 			       enum spectral_msg_type smsg_type);
 	void (*free_sbuff)(struct wlan_objmgr_pdev *pdev,
 			   enum spectral_msg_type smsg_type);
+	int (*convert_to_nl_ch_width)(uint8_t phy_chwidth);
+	uint8_t (*convert_to_phy_ch_width)(uint8_t nl_chwidth);
 };
 
 /**

+ 14 - 2
target_if/spectral/target_if_spectral_netlink.c

@@ -274,13 +274,25 @@ target_if_spectral_fill_samp_msg(struct target_if_spectral *spectral,
 		spec_samp_msg->spectral_mode = spectral_mode;
 		spec_samp_msg->target_reset_count =
 				spectral->timestamp_war.target_reset_count;
-		spec_samp_msg->operating_bw = rpt_info->operating_bw;
+		spec_samp_msg->operating_bw = spectral->nl_cb.
+				convert_to_nl_ch_width(rpt_info->operating_bw);
+		if (spec_samp_msg->operating_bw < 0) {
+			spectral_err_rl("Invalid operating channel width %d",
+					rpt_info->operating_bw);
+			return QDF_STATUS_E_FAILURE;
+		}
 		spec_samp_msg->pri20_freq = rpt_info->pri20_freq;
 		spec_samp_msg->cfreq1 = rpt_info->cfreq1;
 		spec_samp_msg->cfreq2 = rpt_info->cfreq2;
 		spec_samp_msg->sscan_cfreq1 = rpt_info->sscan_cfreq1;
 		spec_samp_msg->sscan_cfreq2 = rpt_info->sscan_cfreq2;
-		spec_samp_msg->sscan_bw = rpt_info->sscan_bw;
+		spec_samp_msg->sscan_bw = spectral->nl_cb.
+				convert_to_nl_ch_width(rpt_info->sscan_bw);
+		if (spec_samp_msg->sscan_bw < 0) {
+			spectral_err_rl("Invalid sscan channel width %d",
+					rpt_info->sscan_bw);
+			return QDF_STATUS_E_FAILURE;
+		}
 		spec_samp_msg->fft_width = FFT_BIN_SIZE_1BYTE;
 		spec_samp_msg->num_freq_spans = rpt_info->num_spans;