From d5e1f78aa826fc4b4b9dfbc9787f0ca999b1dad7 Mon Sep 17 00:00:00 2001 From: Lincoln Tran Date: Thu, 2 Jul 2020 16:59:28 -0700 Subject: [PATCH] qcacld-3.0: Introduce getband vendor command Update calls from reg_get_curr_band to reg_get_band since they provide the same functionality. Update calls to reg_get_band to expect a bitmap since the API has been updated. Update getband driver command to convert the bitmap to the old values. Also add the new vendor command getband. Change-Id: I069489ebf4826f8f4bfcb974b74e4d0591d5b33f CRs-fixed: 2726361 --- components/tdls/core/src/wlan_tdls_peer.c | 4 +- core/hdd/src/wlan_hdd_cfg80211.c | 111 ++++++++++++++++++++++ core/hdd/src/wlan_hdd_regulatory.c | 2 +- core/hdd/src/wlan_hdd_tdls.c | 7 +- core/sap/src/sap_module.c | 7 +- core/sme/src/common/sme_api.c | 4 +- 6 files changed, 124 insertions(+), 11 deletions(-) diff --git a/components/tdls/core/src/wlan_tdls_peer.c b/components/tdls/core/src/wlan_tdls_peer.c index 43ce1e8d8df7..6320583122ea 100644 --- a/components/tdls/core/src/wlan_tdls_peer.c +++ b/components/tdls/core/src/wlan_tdls_peer.c @@ -477,7 +477,7 @@ void tdls_extract_peer_state_param(struct tdls_peer_update_state *peer_param, enum channel_state ch_state; struct wlan_objmgr_pdev *pdev; uint8_t chan_id; - enum band_info cur_band = BAND_ALL; + uint32_t cur_band; qdf_freq_t ch_freq; vdev_obj = peer->vdev_priv; @@ -513,7 +513,7 @@ void tdls_extract_peer_state_param(struct tdls_peer_update_state *peer_param, return; } - if (BAND_2G == cur_band) { + if (BIT(REG_BAND_2G) == cur_band) { tdls_err("sending the offchannel value as 0 as only 2g is supported"); peer_param->peer_cap.pref_off_channum = 0; peer_param->peer_cap.opclass_for_prefoffchan = 0; diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 85d4c1863b31..280d438c30b3 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -12861,6 +12861,108 @@ static int wlan_hdd_cfg80211_setband(struct wiphy *wiphy, return errno; } +static uint32_t +wlan_reg_wifi_band_bitmap_to_vendor_bitmap(uint32_t reg_wifi_band_bitmap) +{ + uint32_t vendor_mask = 0; + + if (reg_wifi_band_bitmap & BIT(REG_BAND_2G)) + vendor_mask |= QCA_SETBAND_2G; + if (reg_wifi_band_bitmap & BIT(REG_BAND_5G)) + vendor_mask |= QCA_SETBAND_5G; + if (reg_wifi_band_bitmap & BIT(REG_BAND_6G)) + vendor_mask |= QCA_SETBAND_6G; + + return vendor_mask; +} + +/** + *__wlan_hdd_cfg80211_getband() - get band + * @wiphy: Pointer to wireless phy + * @wdev: Pointer to wireless device + * @data: Pointer to data + * @data_len: Length of @data + * + * Return: 0 on success, negative errno on failure + */ +static int __wlan_hdd_cfg80211_getband(struct wiphy *wiphy, + struct wireless_dev *wdev, + const void *data, int data_len) +{ + struct hdd_context *hdd_ctx = wiphy_priv(wiphy); + struct sk_buff *skb; + QDF_STATUS status = QDF_STATUS_SUCCESS; + int ret; + uint32_t reg_wifi_band_bitmap, vendor_band_mask; + + hdd_enter(); + + ret = wlan_hdd_validate_context(hdd_ctx); + if (ret) + return ret; + + skb = cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy, + sizeof(uint32_t) + + NLA_HDRLEN); + + if (!skb) { + hdd_err("cfg80211_vendor_event_alloc failed"); + return -ENOMEM; + } + + status = ucfg_reg_get_band(hdd_ctx->pdev, ®_wifi_band_bitmap); + if (!QDF_IS_STATUS_SUCCESS(status)) { + hdd_err("failed to get band"); + goto failure; + } + + vendor_band_mask = wlan_reg_wifi_band_bitmap_to_vendor_bitmap( + reg_wifi_band_bitmap); + + if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_SETBAND_MASK, + vendor_band_mask)) { + hdd_err("nla put failure"); + goto failure; + } + + cfg80211_vendor_cmd_reply(skb); + + hdd_exit(); + + return 0; + +failure: + kfree_skb(skb); + return -EINVAL; +} + +/** + * wlan_hdd_cfg80211_getband() - Wrapper to getband + * @wiphy: wiphy structure pointer + * @wdev: Wireless device structure pointer + * @data: Pointer to the data received + * @data_len: Length of @data + * + * Return: 0 on success; errno on failure + */ +static int wlan_hdd_cfg80211_getband(struct wiphy *wiphy, + struct wireless_dev *wdev, + const void *data, int data_len) +{ + int errno; + struct osif_vdev_sync *vdev_sync; + + errno = osif_vdev_sync_op_start(wdev->netdev, &vdev_sync); + if (errno) + return errno; + + errno = __wlan_hdd_cfg80211_getband(wiphy, wdev, data, data_len); + + osif_vdev_sync_op_stop(vdev_sync); + + return errno; +} + static const struct nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] = { [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = {.type = NLA_U32}, @@ -15128,6 +15230,15 @@ const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] = { .doit = wlan_hdd_cfg80211_setband, vendor_command_policy(setband_policy, QCA_WLAN_VENDOR_ATTR_MAX) }, + { + .info.vendor_id = QCA_NL80211_VENDOR_ID, + .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GETBAND, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV | + WIPHY_VENDOR_CMD_NEED_NETDEV | + WIPHY_VENDOR_CMD_NEED_RUNNING, + .doit = wlan_hdd_cfg80211_getband, + vendor_command_policy(VENDOR_CMD_RAW_DATA, 0) + }, { .info.vendor_id = QCA_NL80211_VENDOR_ID, .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING, diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c index 4cd8a72adf57..3726a558b2d4 100644 --- a/core/hdd/src/wlan_hdd_regulatory.c +++ b/core/hdd/src/wlan_hdd_regulatory.c @@ -786,7 +786,7 @@ int hdd_reg_set_band(struct net_device *dev, uint32_t band_bitmap) hdd_debug("change band to %u", band_bitmap); - if (ucfg_reg_get_curr_band(hdd_ctx->pdev, ¤t_band) != + if (ucfg_reg_get_band(hdd_ctx->pdev, ¤t_band) != QDF_STATUS_SUCCESS) { hdd_debug("Failed to get current band config"); return -EIO; diff --git a/core/hdd/src/wlan_hdd_tdls.c b/core/hdd/src/wlan_hdd_tdls.c index b5020ff44b99..8eb44f6da1c9 100644 --- a/core/hdd/src/wlan_hdd_tdls.c +++ b/core/hdd/src/wlan_hdd_tdls.c @@ -875,7 +875,7 @@ void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx) { struct wlan_objmgr_vdev *tdls_obj_vdev; int offchmode; - enum band_info current_band; + uint32_t current_band; bool tdls_off_ch; if (!hdd_ctx) { @@ -883,7 +883,7 @@ void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx) return; } - if (ucfg_reg_get_curr_band(hdd_ctx->pdev, ¤t_band) != + if (ucfg_reg_get_band(hdd_ctx->pdev, ¤t_band) != QDF_STATUS_SUCCESS) { hdd_err("Failed to get current band config"); return; @@ -898,7 +898,8 @@ void hdd_config_tdls_with_band_switch(struct hdd_context *hdd_ctx) * If 2g or 5g is not supported. Disable tdls off channel only when * tdls off channel is enabled currently. */ - if (current_band == BAND_ALL) { + if ((current_band & BIT(REG_BAND_2G)) && + (current_band & BIT(REG_BAND_5G))) { if (cfg_tdls_get_off_channel_enable_orig( hdd_ctx->psoc, &tdls_off_ch) != QDF_STATUS_SUCCESS) { diff --git a/core/sap/src/sap_module.c b/core/sap/src/sap_module.c index 67670a9557f3..431b8d7fdfe3 100644 --- a/core/sap/src/sap_module.c +++ b/core/sap/src/sap_module.c @@ -3004,14 +3004,14 @@ qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) return 0; } - if (ucfg_reg_get_curr_band(mac->pdev, &band) != QDF_STATUS_SUCCESS) { + if (ucfg_reg_get_band(mac->pdev, &band) != QDF_STATUS_SUCCESS) { sap_err("Failed to get current band config"); return 0; } sap_band = wlan_reg_freq_to_band(sap_ctx->chan_freq); sap_debug("SAP/Go current band: %d, pdev band capability: %d", sap_band, band); - if (sap_band == REG_BAND_5G && band == BAND_2G) { + if (sap_band == REG_BAND_5G && band == BIT(REG_BAND_2G)) { sap_ctx->chan_freq_before_switch_band = sap_ctx->chan_freq; sap_ctx->chan_width_before_switch_band = sap_ctx->ch_params.ch_width; @@ -3027,8 +3027,7 @@ qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx) sap_debug("set 40M when switch SAP to 2G"); restart_ch_width = CH_WIDTH_40MHZ; } - } else if (sap_band == REG_BAND_2G && - (band == BAND_ALL || band == BAND_5G)) { + } else if (sap_band == REG_BAND_2G && (band & BIT(REG_BAND_5G))) { if (sap_ctx->chan_freq_before_switch_band == 0) return 0; restart_freq = sap_ctx->chan_freq_before_switch_band; diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 5fbed0c3f86b..a43bad1aae9b 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -1764,6 +1764,7 @@ QDF_STATUS sme_set_ese_roam_scan_channel_list(mac_handle_t mac_handle, uint8_t newChannelList[CFG_VALID_CHANNEL_LIST_LEN * 5] = { 0 }; uint8_t i = 0, j = 0; enum band_info band = -1; + uint32_t band_bitmap; if (sessionId >= WLAN_MAX_VDEVS) { QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, @@ -1786,7 +1787,8 @@ QDF_STATUS sme_set_ese_roam_scan_channel_list(mac_handle_t mac_handle, curchnl_list_info->freq_list[i]); } } - ucfg_reg_get_band(mac->pdev, &band); + ucfg_reg_get_band(mac->pdev, &band_bitmap); + band = wlan_reg_band_bitmap_to_band_info(band_bitmap); status = csr_create_roam_scan_channel_list(mac, sessionId, chan_freq_list, numChannels, band);