diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h index b27d9dd8bc03..fcdd34287d54 100644 --- a/core/hdd/inc/wlan_hdd_cfg.h +++ b/core/hdd/inc/wlan_hdd_cfg.h @@ -379,11 +379,13 @@ int hdd_vendor_mode_to_phymode(enum qca_wlan_vendor_phy_mode vendor_phy_mode, /** * hdd_vendor_mode_to_band() - Get band_info according to vendor phy mode * @vendor_phy_mode: vendor phy mode + * @supported_band: supported band bitmap + * @is_6ghz_supported: whether 6ghz is supported * - * Return: band_info on success, BAND_UNKNOWN on error + * Return: 0 on success, negative errno value on error */ -enum band_info -hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode); +int hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode, + uint8_t *supported_band, bool is_6ghz_supported); /** * hdd_vendor_mode_to_bonding_mode() - Get channel bonding mode according to @@ -401,7 +403,7 @@ hdd_vendor_mode_to_bonding_mode(enum qca_wlan_vendor_phy_mode vendor_phy_mode, * hdd_update_phymode() - update the PHY mode of the adapter * @adapter: adapter being modified * @phymode: new PHY mode for the adapter - * @band: new band for the adapter + * @supported_band: supported band bitmap for the adapter * @bonding_mode: new channel bonding mode for the adapter * * This function is called when the adapter is set to a new PHY mode. @@ -413,7 +415,7 @@ hdd_vendor_mode_to_bonding_mode(enum qca_wlan_vendor_phy_mode vendor_phy_mode, * Return: 0 on success, negative errno value on error */ int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, - enum band_info band, uint32_t bonding_mode); + uint8_t supported_band, uint32_t bonding_mode); /** * hdd_get_ldpc() - Get adapter LDPC diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index bec17b75dcaf..7836994bbff9 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -1334,11 +1334,9 @@ int hdd_vendor_mode_to_phymode(enum qca_wlan_vendor_phy_mode vendor_phy_mode, return 0; } -enum band_info -hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode) +int hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode, + uint8_t *supported_band, bool is_6ghz_supported) { - enum band_info band; - switch (vendor_phy_mode) { case QCA_WLAN_VENDOR_PHY_MODE_AUTO: case QCA_WLAN_VENDOR_PHY_MODE_11AC_VHT20: @@ -1348,6 +1346,8 @@ hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode) case QCA_WLAN_VENDOR_PHY_MODE_11AC_VHT80: case QCA_WLAN_VENDOR_PHY_MODE_11AC_VHT80P80: case QCA_WLAN_VENDOR_PHY_MODE_11AC_VHT160: + *supported_band = BIT(REG_BAND_2G) | BIT(REG_BAND_5G); + break; case QCA_WLAN_VENDOR_PHY_MODE_11AX_HE20: case QCA_WLAN_VENDOR_PHY_MODE_11AX_HE40: case QCA_WLAN_VENDOR_PHY_MODE_11AX_HE40PLUS: @@ -1356,7 +1356,10 @@ hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode) case QCA_WLAN_VENDOR_PHY_MODE_11AX_HE80P80: case QCA_WLAN_VENDOR_PHY_MODE_11AX_HE160: case QCA_WLAN_VENDOR_PHY_MODE_11AGN: - band = BAND_ALL; + if (is_6ghz_supported) + *supported_band = REG_BAND_MASK_ALL; + else + *supported_band = BIT(REG_BAND_2G) | BIT(REG_BAND_5G); break; case QCA_WLAN_VENDOR_PHY_MODE_11A: case QCA_WLAN_VENDOR_PHY_MODE_11NA_HT20: @@ -1364,7 +1367,7 @@ hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode) case QCA_WLAN_VENDOR_PHY_MODE_11NA_HT40PLUS: case QCA_WLAN_VENDOR_PHY_MODE_11NA_HT40MINUS: case QCA_WLAN_VENDOR_PHY_MODE_5G_AUTO: - band = BAND_5G; + *supported_band = BIT(REG_BAND_5G); break; case QCA_WLAN_VENDOR_PHY_MODE_11B: case QCA_WLAN_VENDOR_PHY_MODE_11G: @@ -1373,14 +1376,14 @@ hdd_vendor_mode_to_band(enum qca_wlan_vendor_phy_mode vendor_phy_mode) case QCA_WLAN_VENDOR_PHY_MODE_11NG_HT40PLUS: case QCA_WLAN_VENDOR_PHY_MODE_11NG_HT40MINUS: case QCA_WLAN_VENDOR_PHY_MODE_2G_AUTO: - band = BAND_2G; + *supported_band = BIT(REG_BAND_2G); break; default: hdd_err("Not supported mode %d", vendor_phy_mode); - band = BAND_UNKNOWN; + return -EINVAL; } - return band; + return 0; } int @@ -1495,7 +1498,7 @@ hdd_set_ht2040_mode(struct hdd_adapter *adapter, #endif int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, - enum band_info band, uint32_t bonding_mode) + uint8_t supported_band, uint32_t bonding_mode) { struct net_device *net = adapter->dev; struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); @@ -1503,7 +1506,6 @@ int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, struct csr_config_params *csr_config; eCsrPhyMode old_phymode; enum hdd_dot11_mode hdd_dot11mode; - uint8_t ui_band; int ret = 0; QDF_STATUS status; @@ -1515,29 +1517,14 @@ int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, if (ret < 0) return ret; - hdd_debug("phymode=%d bonding_mode=%d band=%d", - phymode, bonding_mode, band); + hdd_debug("phymode=%d bonding_mode=%d supported_band=%d", + phymode, bonding_mode, supported_band); old_phymode = sme_get_phy_mode(hdd_ctx->mac_handle); sme_set_phy_mode(hdd_ctx->mac_handle, phymode); - switch (band) { - case BAND_ALL: - ui_band = WLAN_HDD_UI_BAND_AUTO; - break; - case BAND_5G: - ui_band = WLAN_HDD_UI_BAND_5_GHZ; - break; - case BAND_2G: - ui_band = WLAN_HDD_UI_BAND_2_4_GHZ; - break; - default: - hdd_err("Invalid band %d", band); - return -EINVAL; - } - - if (hdd_reg_set_band(net, ui_band)) { + if (hdd_reg_set_band(net, supported_band)) { sme_set_phy_mode(hdd_ctx->mac_handle, old_phymode); return -EIO; } @@ -1557,14 +1544,14 @@ int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, goto free; } - status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band); + status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, supported_band); if (QDF_IS_STATUS_ERROR(status)) { hdd_err("failed to set MLME band capability"); ret = -EIO; goto free; } - if (band == BAND_2G) { + if (supported_band == BIT(REG_BAND_2G)) { status = ucfg_mlme_set_11h_enabled(hdd_ctx->psoc, 0); if (!QDF_IS_STATUS_SUCCESS(status)) { hdd_err("Failed to set 11h_enable flag"); @@ -1572,14 +1559,12 @@ int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, goto free; } } - if (band == BAND_2G) { + if (supported_band & BIT(REG_BAND_2G)) csr_config->channelBondingMode24GHz = bonding_mode; - } else if (band == BAND_5G) { + + if (supported_band & BIT(REG_BAND_5G)) csr_config->channelBondingMode5GHz = bonding_mode; - } else { - csr_config->channelBondingMode24GHz = bonding_mode; - csr_config->channelBondingMode5GHz = bonding_mode; - } + sme_update_config(hdd_ctx->mac_handle, sme_config); hdd_ctx->config->dot11Mode = hdd_dot11mode; @@ -1593,7 +1578,7 @@ int hdd_update_phymode(struct hdd_adapter *adapter, eCsrPhyMode phymode, goto free; } - if (band == BAND_ALL || band == BAND_5G) { + if (supported_band & BIT(REG_BAND_5G)) { struct ieee80211_supported_band *ieee_band; uint32_t channel_bonding_mode; diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 4a91723d4483..e7a97f8ff2d3 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -7152,27 +7152,36 @@ static int wlan_hdd_cfg80211_wifi_set_rx_blocksize(struct hdd_adapter *adapter, static int hdd_config_phy_mode(struct hdd_adapter *adapter, const struct nlattr *attr) { + struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); + struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; enum qca_wlan_vendor_phy_mode vendor_phy_mode; eCsrPhyMode phymode; - enum band_info band; + uint8_t supported_band; uint32_t bonding_mode; int ret = 0; + if (!psoc) { + hdd_err("psoc is NULL"); + return -EINVAL; + } + vendor_phy_mode = nla_get_u32(attr); ret = hdd_vendor_mode_to_phymode(vendor_phy_mode, &phymode); if (ret < 0) return ret; - band = hdd_vendor_mode_to_band(vendor_phy_mode); - if (band == BAND_UNKNOWN) - return -EINVAL; + ret = hdd_vendor_mode_to_band(vendor_phy_mode, &supported_band, + wlan_reg_is_6ghz_supported(psoc)); + if (ret < 0) + return ret; ret = hdd_vendor_mode_to_bonding_mode(vendor_phy_mode, &bonding_mode); if (ret < 0) return ret; - return hdd_update_phymode(adapter, phymode, band, bonding_mode); + return hdd_update_phymode(adapter, phymode, supported_band, + bonding_mode); } /** diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index b314ffdef1ff..3f7c3cf07e9a 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -3415,82 +3415,76 @@ static int iw_get_wlm_stats(struct net_device *net_dev, } #endif /* FEATURE_WLM_STATS */ -static eCsrPhyMode hdd_we_ieee_to_phymode(int ieee_mode) +static int hdd_we_ieee_to_phymode(int ieee_mode, eCsrPhyMode *csr_phy_mode) { - eCsrPhyMode phymode; - switch (ieee_mode) { case IEEE80211_MODE_AUTO: case IEEE80211_MODE_2G_AUTO: case IEEE80211_MODE_5G_AUTO: - phymode = eCSR_DOT11_MODE_AUTO; + *csr_phy_mode = eCSR_DOT11_MODE_AUTO; break; case IEEE80211_MODE_11A: - phymode = eCSR_DOT11_MODE_11a; + *csr_phy_mode = eCSR_DOT11_MODE_11a; break; case IEEE80211_MODE_11B: - phymode = eCSR_DOT11_MODE_11b; + *csr_phy_mode = eCSR_DOT11_MODE_11b; break; case IEEE80211_MODE_11G: - phymode = eCSR_DOT11_MODE_11g; + *csr_phy_mode = eCSR_DOT11_MODE_11g; break; case IEEE80211_MODE_11NA_HT20: case IEEE80211_MODE_11NA_HT40: case IEEE80211_MODE_11NG_HT20: case IEEE80211_MODE_11NG_HT40: case IEEE80211_MODE_11AGN: - phymode = eCSR_DOT11_MODE_11n; + *csr_phy_mode = eCSR_DOT11_MODE_11n; break; case IEEE80211_MODE_11AC_VHT20: case IEEE80211_MODE_11AC_VHT40: case IEEE80211_MODE_11AC_VHT80: - phymode = eCSR_DOT11_MODE_11ac; + *csr_phy_mode = eCSR_DOT11_MODE_11ac; break; default: hdd_err("Not supported mode %d", ieee_mode); - phymode = -EINVAL; + return -EINVAL; } - return phymode; + return 0; } -static enum band_info hdd_we_ieee_to_band(int ieee_mode) +static int hdd_we_ieee_to_band(int ieee_mode, uint8_t *supported_band) { - enum band_info band; - switch (ieee_mode) { case IEEE80211_MODE_AUTO: case IEEE80211_MODE_11AC_VHT20: case IEEE80211_MODE_11AC_VHT40: case IEEE80211_MODE_11AC_VHT80: case IEEE80211_MODE_11AGN: - band = BAND_ALL; + *supported_band = BIT(REG_BAND_2G) | BIT(REG_BAND_5G); break; case IEEE80211_MODE_11A: case IEEE80211_MODE_11NA_HT20: case IEEE80211_MODE_11NA_HT40: case IEEE80211_MODE_5G_AUTO: - band = BAND_5G; + *supported_band = BIT(REG_BAND_5G); break; case IEEE80211_MODE_11B: case IEEE80211_MODE_11G: case IEEE80211_MODE_11NG_HT20: case IEEE80211_MODE_11NG_HT40: case IEEE80211_MODE_2G_AUTO: - band = BAND_2G; + *supported_band = BIT(REG_BAND_2G); break; default: hdd_err("Not supported mode %d", ieee_mode); - band = -EINVAL; + return -EINVAL; } - return band; + return 0; } -static uint32_t hdd_we_ieee_to_chwidth(int ieee_mode) +static int hdd_we_ieee_to_bonding_mode(int ieee_mode, uint32_t *bonding_mode) { - uint32_t chwidth; - switch (ieee_mode) { case IEEE80211_MODE_AUTO: case IEEE80211_MODE_11NA_HT40: @@ -3500,7 +3494,7 @@ static uint32_t hdd_we_ieee_to_chwidth(int ieee_mode) case IEEE80211_MODE_2G_AUTO: case IEEE80211_MODE_5G_AUTO: case IEEE80211_MODE_11AGN: - chwidth = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE; + *bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE; break; case IEEE80211_MODE_11A: case IEEE80211_MODE_11B: @@ -3508,35 +3502,37 @@ static uint32_t hdd_we_ieee_to_chwidth(int ieee_mode) case IEEE80211_MODE_11NA_HT20: case IEEE80211_MODE_11NG_HT20: case IEEE80211_MODE_11AC_VHT20: - chwidth = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE; + *bonding_mode = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE; break; default: hdd_err("Not supported mode %d", ieee_mode); - chwidth = -EINVAL; + return -EINVAL; } - return chwidth; + return 0; } int hdd_we_update_phymode(struct hdd_adapter *adapter, int new_phymode) { eCsrPhyMode phymode; - enum band_info band; - uint32_t chwidth; + uint8_t supported_band; + uint32_t bonding_mode; + int ret; - phymode = hdd_we_ieee_to_phymode(new_phymode); - if (phymode < 0) + ret = hdd_we_ieee_to_phymode(new_phymode, &phymode); + if (ret < 0) return -EINVAL; - band = hdd_we_ieee_to_band(new_phymode); - if (band < 0) - return -EINVAL; + ret = hdd_we_ieee_to_band(new_phymode, &supported_band); + if (ret < 0) + return ret; - chwidth = hdd_we_ieee_to_chwidth(new_phymode); - if (chwidth < 0) - return -EINVAL; + ret = hdd_we_ieee_to_bonding_mode(new_phymode, &bonding_mode); + if (ret < 0) + return ret; - return hdd_update_phymode(adapter, phymode, band, chwidth); + return hdd_update_phymode(adapter, phymode, supported_band, + bonding_mode); } static int hdd_validate_pdev_reset(int value)