Sfoglia il codice sorgente

qcacld-3.0: Add 320MHz support in HDD

As part of 11BE 320MHZ bandwidth support, add 320MHz
in HDD layer.

Change-Id: Ibf39b8ff314d9b3a9a2c8ccc0739374c2caeb82a
CRs-Fixed: 2935883
Jia Ding 4 anni fa
parent
commit
b3b2f0a498

+ 62 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -2287,6 +2287,25 @@ struct hdd_channel_info {
 	u_int8_t vht_center_freq_seg1;
 };
 
+/**
+ * struct hdd_chwidth_info - channel width related info
+ * @sir_chwidth_valid: If nl_chan_width is valid in Sir
+ * @sir_chwidth: enum eSirMacHTChannelWidth
+ * @ch_bw: enum hw_mode_bandwidth
+ * @ch_bw_str: ch_bw in string format
+ * @phy_chwidth: enum phy_ch_width
+ * @bonding mode: WNI_CFG_CHANNEL_BONDING_MODE_DISABLE or
+ *		  WNI_CFG_CHANNEL_BONDING_MODE_ENABLE
+ */
+struct hdd_chwidth_info {
+	bool sir_chwidth_valid;
+	enum eSirMacHTChannelWidth sir_chwidth;
+	enum hw_mode_bandwidth ch_bw;
+	char *ch_bw_str;
+	enum phy_ch_width phy_chwidth;
+	int bonding_mode;
+};
+
 /*
  * Function declarations and documentation
  */
@@ -4979,4 +4998,47 @@ void wlan_hdd_set_pm_qos_request(struct hdd_context *hdd_ctx,
 {
 }
 #endif
+
+/**
+ * hdd_nl80211_chwidth_to_chwidth - Get sir chan width from nl chan width
+ * @nl80211_chwidth: enum nl80211_chan_width
+ *
+ * Return: enum eSirMacHTChannelWidth or -INVAL for unsupported nl chan width
+ */
+enum eSirMacHTChannelWidth
+hdd_nl80211_chwidth_to_chwidth(uint8_t nl80211_chwidth);
+
+/**
+ * hdd_chwidth_to_nl80211_chwidth - Get nl chan width from sir chan width
+ * @chwidth: enum eSirMacHTChannelWidth
+ *
+ * Return: enum nl80211_chan_width or 0xFF for unsupported sir chan width
+ */
+uint8_t hdd_chwidth_to_nl80211_chwidth(enum eSirMacHTChannelWidth chwidth);
+
+/**
+ * wlan_hdd_get_channel_bw() - get channel bandwidth
+ * @width: input channel width in nl80211_chan_width value
+ *
+ * Return: channel width value defined by driver
+ */
+enum hw_mode_bandwidth wlan_hdd_get_channel_bw(enum nl80211_chan_width width);
+
+/**
+ * hdd_ch_width_str() - Get string for channel width
+ * @ch_width: channel width from connect info
+ *
+ * Return: User readable string for channel width
+ */
+uint8_t *hdd_ch_width_str(enum phy_ch_width ch_width);
+
+/**
+ * hdd_we_set_ch_width - Function to update channel width
+ * @adapter: hdd_adapter pointer
+ * @ch_width: enum eSirMacHTChannelWidth
+ *
+ * Return: 0 for success otherwise failure
+ */
+int hdd_we_set_ch_width(struct hdd_adapter *adapter, int ch_width);
+
 #endif /* end #if !defined(WLAN_HDD_MAIN_H) */

+ 51 - 62
core/hdd/src/wlan_hdd_cfg80211.c

@@ -2975,6 +2975,45 @@ static void wlan_hdd_handle_zero_acs_list(struct hdd_context *hdd_ctx,
 	hdd_debug("retore acs chan list to single freq %d", acs_chan_default);
 }
 
+#ifdef WLAN_FEATURE_11BE
+static void wlan_hdd_set_sap_acs_ch_width_320(struct sap_config *sap_config)
+{
+	sap_config->acs_cfg.ch_width = CH_WIDTH_320MHZ;
+}
+
+static bool wlan_hdd_is_sap_acs_ch_width_320(struct sap_config *sap_config)
+{
+	return sap_config->acs_cfg.ch_width == CH_WIDTH_320MHZ;
+}
+
+static void wlan_hdd_set_chandef(struct wlan_objmgr_vdev *vdev,
+				 struct cfg80211_chan_def *chandef)
+{
+	if (vdev->vdev_mlme.des_chan->ch_width != CH_WIDTH_320MHZ)
+		return;
+
+	chandef->width = NL80211_CHAN_WIDTH_320;
+	/* Set center_freq1 to center frequency of complete 320MHz */
+	chandef->center_freq1 = vdev->vdev_mlme.des_chan->ch_cfreq2;
+}
+#else /* !WLAN_FEATURE_11BE */
+static inline
+void wlan_hdd_set_sap_acs_ch_width_320(struct sap_config *sap_config)
+{
+}
+
+static inline
+bool wlan_hdd_is_sap_acs_ch_width_320(struct sap_config *sap_config)
+{
+	return false;
+}
+
+static inline void wlan_hdd_set_chandef(struct wlan_objmgr_vdev *vdev,
+					struct cfg80211_chan_def *chandef)
+{
+}
+#endif /* WLAN_FEATURE_11BE */
+
 /**
  * __wlan_hdd_cfg80211_do_acs(): CFG80211 handler function for DO_ACS Vendor CMD
  * @wiphy:  Linux wiphy struct pointer
@@ -2999,7 +3038,7 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy,
 	int ret, i;
 	struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_ACS_MAX + 1];
 	bool ht_enabled, ht40_enabled, vht_enabled;
-	uint8_t ch_width;
+	uint16_t ch_width;
 	enum qca_wlan_vendor_acs_hw_mode hw_mode;
 	enum policy_mgr_con_mode pm_mode;
 	QDF_STATUS qdf_status;
@@ -3009,6 +3048,7 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy,
 	bool go_force_11n_for_11ac = 0;
 	bool go_11ac_override = 0;
 	bool sap_11ac_override = 0;
+	uint8_t vht_ch_width;
 
 	/* ***Note*** Donot set SME config related to ACS operation here because
 	 * ACS operation is not synchronouse and ACS for Second AP may come when
@@ -3122,7 +3162,9 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy,
 
 	qdf_mem_zero(&sap_config->acs_cfg, sizeof(struct sap_acs_cfg));
 
-	if (ch_width == 160)
+	if (ch_width == 320)
+		wlan_hdd_set_sap_acs_ch_width_320(sap_config);
+	else if (ch_width == 160)
 		sap_config->acs_cfg.ch_width = CH_WIDTH_160MHZ;
 	else if (ch_width == 80)
 		sap_config->acs_cfg.ch_width = CH_WIDTH_80MHZ;
@@ -3299,7 +3341,8 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy,
 		sap_config->acs_cfg.hw_mode = eCSR_DOT11_MODE_11ac;
 		qdf_status =
 			ucfg_mlme_get_vht_channel_width(hdd_ctx->psoc,
-							&ch_width);
+							&vht_ch_width);
+		ch_width = vht_ch_width;
 		sap_config->acs_cfg.ch_width = ch_width;
 	}
 
@@ -3579,7 +3622,9 @@ void wlan_hdd_cfg80211_acs_ch_select_evt(struct hdd_adapter *adapter)
 		return;
 	}
 
-	if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_160MHZ)
+	if (wlan_hdd_is_sap_acs_ch_width_320(sap_cfg))
+		ch_width = 320;
+	else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_160MHZ)
 		ch_width = 160;
 	else if (sap_cfg->acs_cfg.ch_width == CH_WIDTH_80MHZ)
 		ch_width = 80;
@@ -8825,64 +8870,6 @@ static int hdd_set_elna_bypass(struct hdd_adapter *adapter,
 }
 #endif
 
-static enum eSirMacHTChannelWidth
-hdd_nl80211_chwidth_to_chwidth(uint8_t nl80211_chwidth)
-{
-	int chwidth;
-
-	switch (nl80211_chwidth) {
-	case NL80211_CHAN_WIDTH_20:
-		chwidth = eHT_CHANNEL_WIDTH_20MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_40:
-		chwidth = eHT_CHANNEL_WIDTH_40MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_80:
-		chwidth = eHT_CHANNEL_WIDTH_80MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_80P80:
-		chwidth = eHT_CHANNEL_WIDTH_80P80MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_160:
-		chwidth = eHT_CHANNEL_WIDTH_160MHZ;
-		break;
-	default:
-		hdd_err("Unsupported channel width %d", nl80211_chwidth);
-		chwidth = -EINVAL;
-	}
-
-	return chwidth;
-}
-
-static uint8_t
-hdd_chwidth_to_nl80211_chwidth(enum eSirMacHTChannelWidth chwidth)
-{
-	uint8_t nl80211_chwidth;
-
-	switch (chwidth) {
-	case eHT_CHANNEL_WIDTH_20MHZ:
-		nl80211_chwidth = NL80211_CHAN_WIDTH_20;
-		break;
-	case eHT_CHANNEL_WIDTH_40MHZ:
-		nl80211_chwidth = NL80211_CHAN_WIDTH_40;
-		break;
-	case eHT_CHANNEL_WIDTH_80MHZ:
-		nl80211_chwidth = NL80211_CHAN_WIDTH_80;
-		break;
-	case eHT_CHANNEL_WIDTH_80P80MHZ:
-		nl80211_chwidth = NL80211_CHAN_WIDTH_80P80;
-		break;
-	case eHT_CHANNEL_WIDTH_160MHZ:
-		nl80211_chwidth = NL80211_CHAN_WIDTH_160;
-		break;
-	default:
-		hdd_err("Unsupported channel width %d", chwidth);
-		nl80211_chwidth = 0xFF;
-	}
-
-	return nl80211_chwidth;
-}
-
 static uint32_t hdd_nl80211_chwidth_to_bonding_mode(uint8_t nl80211_chwidth)
 {
 	uint32_t bonding_mode;
@@ -24761,6 +24748,8 @@ static int __wlan_hdd_cfg80211_get_channel(struct wiphy *wiphy,
 		break;
 	}
 
+	wlan_hdd_set_chandef(vdev, chandef);
+
 	hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_ID);
 	hdd_debug("primary_freq:%d, ch_width:%d, center_freq1:%d, center_freq2:%d",
 		  chan_freq, chandef->width, chandef->center_freq1,

+ 49 - 37
core/hdd/src/wlan_hdd_hostapd.c

@@ -818,6 +818,48 @@ static int hdd_stop_bss_link(struct hdd_adapter *adapter)
 	return errno;
 }
 
+#ifdef WLAN_FEATURE_11BE
+static void
+wlan_hdd_set_chandef_320mhz(struct cfg80211_chan_def *chandef,
+			    struct hdd_chan_change_params chan_change)
+{
+	if (chan_change.chan_params.ch_width != CH_WIDTH_320MHZ)
+		return;
+
+	chandef->width = NL80211_CHAN_WIDTH_320;
+	if (chan_change.chan_params.mhz_freq_seg1)
+		chandef->center_freq1 = chan_change.chan_params.mhz_freq_seg1;
+}
+
+static void wlan_hdd_set_chandef_width(struct cfg80211_chan_def *chandef,
+				       enum phy_ch_width width)
+{
+	if (width == CH_WIDTH_320MHZ)
+		chandef->width = NL80211_CHAN_WIDTH_320;
+}
+
+static inline bool wlan_hdd_is_chwidth_320mhz(enum phy_ch_width ch_width)
+{
+	return ch_width == CH_WIDTH_320MHZ;
+}
+#else /* !WLAN_FEATURE_11BE */
+static inline
+void wlan_hdd_set_chandef_320mhz(struct cfg80211_chan_def *chandef,
+				 struct hdd_chan_change_params chan_change)
+{
+}
+
+static inline void wlan_hdd_set_chandef_width(struct cfg80211_chan_def *chandef,
+					      enum phy_ch_width width)
+{
+}
+
+static inline bool wlan_hdd_is_chwidth_320mhz(enum phy_ch_width ch_width)
+{
+	return false;
+}
+#endif /* WLAN_FEATURE_11BE */
+
 QDF_STATUS hdd_chan_change_notify(struct hdd_adapter *adapter,
 		struct net_device *dev,
 		struct hdd_chan_change_params chan_change,
@@ -889,6 +931,8 @@ QDF_STATUS hdd_chan_change_notify(struct hdd_adapter *adapter,
 		break;
 	}
 
+	wlan_hdd_set_chandef_320mhz(&chandef, chan_change);
+
 	if ((chan_change.chan_params.ch_width == CH_WIDTH_80MHZ) ||
 	    (chan_change.chan_params.ch_width == CH_WIDTH_80P80MHZ)) {
 		if (chan_change.chan_params.mhz_freq_seg0)
@@ -6170,42 +6214,6 @@ exit:
 	return 0;
 }
 
-/**
- * wlan_hdd_get_channel_bw() - get channel bandwidth
- * @width: input channel width in nl80211_chan_width value
- *
- * Return: channel width value defined by driver
- */
-static enum hw_mode_bandwidth wlan_hdd_get_channel_bw(
-					enum nl80211_chan_width width)
-{
-	enum hw_mode_bandwidth ch_bw = HW_MODE_20_MHZ;
-
-	switch (width) {
-	case NL80211_CHAN_WIDTH_20_NOHT:
-	case NL80211_CHAN_WIDTH_20:
-		ch_bw = HW_MODE_20_MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_40:
-		ch_bw = HW_MODE_40_MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_80:
-		ch_bw = HW_MODE_80_MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_80P80:
-		ch_bw = HW_MODE_80_PLUS_80_MHZ;
-		break;
-	case NL80211_CHAN_WIDTH_160:
-		ch_bw = HW_MODE_160_MHZ;
-		break;
-	default:
-		hdd_err("Invalid width: %d, using default 20MHz", width);
-		break;
-	}
-
-	return ch_bw;
-}
-
 /**
  * wlan_hdd_cfg80211_stop_ap() - stop sap
  * @wiphy: Pointer to wiphy
@@ -6452,9 +6460,13 @@ wlan_hdd_ap_ap_force_scc_override(struct hdd_adapter *adapter,
 	default:
 		break;
 	}
+
+	wlan_hdd_set_chandef_width(new_chandef, ch_params.ch_width);
+
 	if ((ch_params.ch_width == CH_WIDTH_80MHZ) ||
 	    (ch_params.ch_width == CH_WIDTH_80P80MHZ) ||
-	    (ch_params.ch_width == CH_WIDTH_160MHZ)) {
+	    (ch_params.ch_width == CH_WIDTH_160MHZ) ||
+	    wlan_hdd_is_chwidth_320mhz(ch_params.ch_width)) {
 		if (ch_params.mhz_freq_seg0)
 			new_chandef->center_freq1 = ch_params.mhz_freq_seg0;
 	}

+ 203 - 3
core/hdd/src/wlan_hdd_main.c

@@ -1102,6 +1102,67 @@ static int pcie_gen_speed;
 /* Variable to hold connection mode including module parameter con_mode */
 static int curr_con_mode;
 
+#ifdef WLAN_FEATURE_11BE
+static enum phy_ch_width hdd_get_eht_phy_ch_width_from_target(void)
+{
+	uint32_t max_fw_bw = sme_get_eht_ch_width();
+
+	if (max_fw_bw == WNI_CFG_EHT_CHANNEL_WIDTH_320MHZ)
+		return CH_WIDTH_320MHZ;
+	else if (max_fw_bw == WNI_CFG_EHT_CHANNEL_WIDTH_160MHZ)
+		return CH_WIDTH_160MHZ;
+	else
+		return CH_WIDTH_80MHZ;
+}
+
+static bool hdd_is_target_eht_phy_ch_width_supported(enum phy_ch_width width)
+{
+	enum phy_ch_width max_fw_bw = hdd_get_eht_phy_ch_width_from_target();
+
+	if (width <= max_fw_bw)
+		return true;
+
+	hdd_err("FW does not support this BW %d max BW supported %d",
+		width, max_fw_bw);
+	return false;
+}
+
+static bool hdd_is_target_eht_160mhz_capable(void)
+{
+	return hdd_is_target_eht_phy_ch_width_supported(CH_WIDTH_160MHZ);
+}
+
+static enum phy_ch_width
+wlan_hdd_map_nl_chan_width(enum nl80211_chan_width width)
+{
+	if (width == NL80211_CHAN_WIDTH_320) {
+		return hdd_get_eht_phy_ch_width_from_target();
+	} else {
+		hdd_err("Invalid channel width %d, setting to default", width);
+		return CH_WIDTH_INVALID;
+	}
+}
+
+#else /* !WLAN_FEATURE_11BE */
+static inline bool
+hdd_is_target_eht_phy_ch_width_supported(enum phy_ch_width width)
+{
+	return true;
+}
+
+static inline bool hdd_is_target_eht_160mhz_capable(void)
+{
+	return false;
+}
+
+static enum phy_ch_width
+wlan_hdd_map_nl_chan_width(enum nl80211_chan_width width)
+{
+	hdd_err("Invalid channel width %d, setting to default", width);
+	return CH_WIDTH_INVALID;
+}
+#endif /* WLAN_FEATURE_11BE */
+
 /**
  * hdd_map_nl_chan_width() - Map NL channel width to internal representation
  * @ch_width: NL channel width
@@ -1132,6 +1193,9 @@ enum phy_ch_width hdd_map_nl_chan_width(enum nl80211_chan_width ch_width)
 		else
 			return CH_WIDTH_80MHZ;
 	case NL80211_CHAN_WIDTH_160:
+		if (hdd_is_target_eht_160mhz_capable())
+			return CH_WIDTH_160MHZ;
+
 		if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ)
 			return CH_WIDTH_160MHZ;
 		else
@@ -1141,9 +1205,7 @@ enum phy_ch_width hdd_map_nl_chan_width(enum nl80211_chan_width ch_width)
 	case NL80211_CHAN_WIDTH_10:
 		return CH_WIDTH_10MHZ;
 	default:
-		hdd_err("Invalid channel width %d, setting to default",
-				ch_width);
-		return CH_WIDTH_INVALID;
+		return wlan_hdd_map_nl_chan_width(ch_width);
 	}
 }
 
@@ -8442,6 +8504,9 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, qdf_freq_t freq,
 		return -EINVAL;
 	}
 
+	if (!hdd_is_target_eht_phy_ch_width_supported(ch_width))
+		return -EINVAL;
+
 	ret = hdd_validate_channel_and_bandwidth(adapter, freq, bandwidth);
 	if (ret) {
 		hdd_err("Invalid CH and BW combo");
@@ -19140,6 +19205,141 @@ int hdd_crash_inject(struct hdd_adapter *adapter, uint32_t v1, uint32_t v2)
 }
 #endif
 
+static const struct hdd_chwidth_info chwidth_info[] = {
+	[NL80211_CHAN_WIDTH_20_NOHT] = {
+		.ch_bw = HW_MODE_20_MHZ,
+		.ch_bw_str = "20MHz",
+		.phy_chwidth = CH_WIDTH_20MHZ,
+	},
+	[NL80211_CHAN_WIDTH_20] = {
+		.sir_chwidth_valid = true,
+		.sir_chwidth = eHT_CHANNEL_WIDTH_20MHZ,
+		.ch_bw = HW_MODE_20_MHZ,
+		.ch_bw_str = "20MHz",
+		.phy_chwidth = CH_WIDTH_20MHZ,
+		.bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE,
+	},
+	[NL80211_CHAN_WIDTH_40] = {
+		.sir_chwidth_valid = true,
+		.sir_chwidth = eHT_CHANNEL_WIDTH_40MHZ,
+		.ch_bw = HW_MODE_40_MHZ,
+		.ch_bw_str = "40MHz",
+		.phy_chwidth = CH_WIDTH_40MHZ,
+		.bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE,
+	},
+	[NL80211_CHAN_WIDTH_80] = {
+		.sir_chwidth_valid = true,
+		.sir_chwidth = eHT_CHANNEL_WIDTH_80MHZ,
+		.ch_bw = HW_MODE_80_MHZ,
+		.ch_bw_str = "80MHz",
+		.phy_chwidth = CH_WIDTH_80MHZ,
+		.bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE,
+	},
+	[NL80211_CHAN_WIDTH_80P80] = {
+		.sir_chwidth_valid = true,
+		.sir_chwidth = eHT_CHANNEL_WIDTH_80P80MHZ,
+		.ch_bw = HW_MODE_80_PLUS_80_MHZ,
+		.ch_bw_str = "(80 + 80)MHz",
+		.phy_chwidth = CH_WIDTH_80P80MHZ,
+		.bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE,
+	},
+	[NL80211_CHAN_WIDTH_160] = {
+		.sir_chwidth_valid = true,
+		.sir_chwidth = eHT_CHANNEL_WIDTH_160MHZ,
+		.ch_bw = HW_MODE_160_MHZ,
+		.ch_bw_str = "160MHz",
+		.phy_chwidth = CH_WIDTH_160MHZ,
+		.bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE,
+	},
+	[NL80211_CHAN_WIDTH_5] = {
+		.ch_bw = HW_MODE_5_MHZ,
+		.ch_bw_str = "5MHz",
+		.phy_chwidth = CH_WIDTH_5MHZ,
+	},
+	[NL80211_CHAN_WIDTH_10] = {
+		.ch_bw = HW_MODE_10_MHZ,
+		.ch_bw_str = "10MHz",
+		.phy_chwidth = CH_WIDTH_10MHZ,
+	},
+#ifdef WLAN_FEATURE_11BE
+	[NL80211_CHAN_WIDTH_320] = {
+		.sir_chwidth_valid = true,
+		.sir_chwidth = eHT_CHANNEL_WIDTH_320MHZ,
+		.ch_bw = HW_MODE_320_MHZ,
+		.ch_bw_str = "320MHz",
+		.phy_chwidth = CH_WIDTH_320MHZ,
+		.bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE,
+	},
+#endif
+};
+
+enum eSirMacHTChannelWidth
+hdd_nl80211_chwidth_to_chwidth(uint8_t nl80211_chwidth)
+{
+	if (nl80211_chwidth >= ARRAY_SIZE(chwidth_info) ||
+	    !chwidth_info[nl80211_chwidth].sir_chwidth_valid) {
+		hdd_err("Unsupported channel width %d", nl80211_chwidth);
+		return -EINVAL;
+	}
+
+	return chwidth_info[nl80211_chwidth].sir_chwidth;
+}
+
+uint8_t hdd_chwidth_to_nl80211_chwidth(enum eSirMacHTChannelWidth chwidth)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(chwidth_info); i++) {
+		if (chwidth_info[i].sir_chwidth_valid &&
+		    chwidth_info[i].sir_chwidth == chwidth)
+			return i;
+	}
+
+	hdd_err("Unsupported channel width %d", chwidth);
+	return 0xFF;
+}
+
+enum hw_mode_bandwidth wlan_hdd_get_channel_bw(enum nl80211_chan_width width)
+{
+	if (width >= ARRAY_SIZE(chwidth_info)) {
+		hdd_err("Invalid width: %d, using default 20MHz", width);
+		return HW_MODE_20_MHZ;
+	}
+
+	return chwidth_info[width].ch_bw;
+}
+
+uint8_t *hdd_ch_width_str(enum phy_ch_width ch_width)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(chwidth_info); i++) {
+		if (chwidth_info[i].phy_chwidth == ch_width)
+			return chwidth_info[i].ch_bw_str;
+	}
+
+	return "UNKNOWN";
+}
+
+int hdd_we_set_ch_width(struct hdd_adapter *adapter, int ch_width)
+{
+	int i;
+
+	/* updating channel bonding only on 5Ghz */
+	hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d", ch_width);
+
+	for (i = 0; i < ARRAY_SIZE(chwidth_info); i++) {
+		if (chwidth_info[i].sir_chwidth_valid &&
+		    chwidth_info[i].sir_chwidth == ch_width)
+			return hdd_update_channel_width(
+					adapter, ch_width,
+					chwidth_info[i].bonding_mode);
+	}
+
+	hdd_err("Invalid ch_width %d", ch_width);
+	return -EINVAL;
+}
+
 /* Register the module init/exit functions */
 module_init(hdd_module_init);
 module_exit(hdd_module_exit);

+ 17 - 0
core/hdd/src/wlan_hdd_regulatory.c

@@ -1090,6 +1090,21 @@ void hdd_reg_notifier(struct wiphy *wiphy,
 #endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+#ifdef WLAN_FEATURE_11BE
+static void fill_wiphy_channel_320mhz(struct ieee80211_channel *wiphy_chan,
+				      uint16_t max_bw)
+{
+	if (max_bw < 320)
+		wiphy_chan->flags |= IEEE80211_CHAN_NO_320MHZ;
+}
+#else
+static inline
+void fill_wiphy_channel_320mhz(struct ieee80211_channel *wiphy_chan,
+			       uint16_t max_bw)
+{
+}
+#endif
+
 static void fill_wiphy_channel(struct ieee80211_channel *wiphy_chan,
 			       struct regulatory_channel *cur_chan)
 {
@@ -1119,6 +1134,8 @@ static void fill_wiphy_channel(struct ieee80211_channel *wiphy_chan,
 	if (cur_chan->max_bw < 160)
 		wiphy_chan->flags |= IEEE80211_CHAN_NO_160MHZ;
 
+	fill_wiphy_channel_320mhz(wiphy_chan, cur_chan->max_bw);
+
 	wiphy_chan->orig_flags = wiphy_chan->flags;
 }
 

+ 0 - 33
core/hdd/src/wlan_hdd_sysfs_connect_info.c

@@ -290,39 +290,6 @@ uint8_t *hdd_dot11_mode_str(uint32_t dot11mode)
 	return "UNKNOWN";
 }
 
-/**
- * hdd_ch_width_str() - Get string for channel width
- * @ch_width: channel width from connect info
- *
- * Return: User readable string for channel width
- */
-static
-uint8_t *hdd_ch_width_str(enum phy_ch_width ch_width)
-{
-	switch (ch_width) {
-	case CH_WIDTH_20MHZ:
-		return "20MHz";
-	case CH_WIDTH_40MHZ:
-		return "40MHz";
-	case CH_WIDTH_80MHZ:
-		return "80MHz";
-	case CH_WIDTH_160MHZ:
-		return "160MHz";
-	case CH_WIDTH_80P80MHZ:
-		return "(80 + 80)MHz";
-	case CH_WIDTH_5MHZ:
-		return "5MHz";
-	case CH_WIDTH_10MHZ:
-		return "10MHz";
-	case CH_WIDTH_INVALID:
-		/* Fallthrough */
-	case CH_WIDTH_MAX:
-		/* Fallthrough */
-	default:
-		return "UNKNOWN";
-	}
-}
-
 /**
  * wlan_hdd_connect_info() - Populate connect info
  * @adapter: pointer to sta adapter for which connect info is required

+ 0 - 27
core/hdd/src/wlan_hdd_wext.c

@@ -3566,33 +3566,6 @@ static int hdd_handle_pdev_reset(struct hdd_adapter *adapter, int value)
 	return ret;
 }
 
-static int hdd_we_set_ch_width(struct hdd_adapter *adapter, int ch_width)
-{
-	uint32_t bonding_mode;
-
-	/* updating channel bonding only on 5Ghz */
-	hdd_debug("WMI_VDEV_PARAM_CHWIDTH val %d", ch_width);
-
-	switch (ch_width) {
-	case eHT_CHANNEL_WIDTH_20MHZ:
-		bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
-		break;
-
-	case eHT_CHANNEL_WIDTH_40MHZ:
-	case eHT_CHANNEL_WIDTH_80MHZ:
-	case eHT_CHANNEL_WIDTH_80P80MHZ:
-	case eHT_CHANNEL_WIDTH_160MHZ:
-		bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
-		break;
-
-	default:
-		hdd_err("Invalid channel width 0->20 1->40 2->80");
-		return -EINVAL;
-	}
-
-	return hdd_update_channel_width(adapter, ch_width, bonding_mode);
-}
-
 static int hdd_we_set_11d_state(struct hdd_adapter *adapter, int state_11d)
 {
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);