From 5c1e9aeb3dde14d8731af1654090350e7d094258 Mon Sep 17 00:00:00 2001 From: Manikandan Mohan Date: Wed, 23 Oct 2019 15:45:35 -0700 Subject: [PATCH] qcacld-3.0: Update HDD for using channel frequency for STA connection Due to channel number ambiguity with 6ghz, update channel references in HDD STA connection path to use channel frequency. Change-Id: I81f3449c9087030e4d98c17a5b12c731f99b39ab CRs-fixed: 2552009 --- core/hdd/inc/wlan_hdd_assoc.h | 4 +- core/hdd/inc/wlan_hdd_main.h | 14 +++++- core/hdd/src/wlan_hdd_cfg80211.c | 83 +++++++++++++++----------------- core/hdd/src/wlan_hdd_cfg80211.h | 2 +- core/hdd/src/wlan_hdd_ioctl.c | 38 +++++---------- core/hdd/src/wlan_hdd_main.c | 3 +- 6 files changed, 69 insertions(+), 75 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_assoc.h b/core/hdd/inc/wlan_hdd_assoc.h index c5111410d5..7b691c5552 100644 --- a/core/hdd/inc/wlan_hdd_assoc.h +++ b/core/hdd/inc/wlan_hdd_assoc.h @@ -441,7 +441,7 @@ QDF_STATUS hdd_roam_deregister_sta(struct hdd_adapter *adapter, #ifdef WLAN_FEATURE_ROAM_OFFLOAD QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, - const tSirMacAddr bssid, int channel); + const tSirMacAddr bssid, uint32_t ch_freq); /** * hdd_save_gtk_params() - Save GTK offload params * @adapter: HDD adapter @@ -455,7 +455,7 @@ void hdd_save_gtk_params(struct hdd_adapter *adapter, #else static inline QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, - const tSirMacAddr bssid, int channel) + const tSirMacAddr bssid, uint32_t ch_freq) { return QDF_STATUS_SUCCESS; } diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index b621e69712..43c9467ad3 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -2906,8 +2906,20 @@ QDF_STATUS hdd_sme_open_session_callback(uint8_t vdev_id, QDF_STATUS qdf_status); QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id); +/** + * hdd_reassoc() - perform a userspace-directed reassoc + * @adapter: Adapter upon which the command was received + * @bssid: BSSID with which to reassociate + * @ch_freq: channel upon which to reassociate + * @src: The source for the trigger of this action + * + * This function performs a userspace-directed reassoc operation + * + * Return: 0 for success non-zero for failure + */ int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, - uint8_t channel, const handoff_src src); + uint32_t ch_freq, const handoff_src src); + int hdd_register_cb(struct hdd_context *hdd_ctx); void hdd_deregister_cb(struct hdd_context *hdd_ctx); int hdd_start_station_adapter(struct hdd_adapter *adapter); diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index c778d85150..e7f74dae47 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -17559,32 +17559,31 @@ void hdd_mon_select_cbmode(struct hdd_adapter *adapter, * * Return: none */ -void hdd_select_cbmode(struct hdd_adapter *adapter, uint8_t op_chan, +void hdd_select_cbmode(struct hdd_adapter *adapter, uint32_t oper_freq, struct ch_params *ch_params) { - uint8_t sec_ch = 0; + uint32_t sec_ch_freq = 0; struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); struct hdd_station_ctx *station_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); eConnectionState connstate; bool cbmode_select = false; - uint32_t op_freq = wlan_reg_chan_to_freq(hdd_ctx->pdev, op_chan); /* * CDS api expects secondary channel for calculating * the channel params */ if ((ch_params->ch_width == CH_WIDTH_40MHZ) && - (WLAN_REG_IS_24GHZ_CH(op_chan))) { - if (op_chan >= 1 && op_chan <= 5) - sec_ch = op_chan + 4; - else if (op_chan >= 6 && op_chan <= 13) - sec_ch = op_chan - 4; + (WLAN_REG_IS_24GHZ_CH_FREQ(oper_freq))) { + if (oper_freq >= 2412 && oper_freq <= 2432) + sec_ch_freq = oper_freq + 20; + else if (oper_freq >= 2437 && oper_freq <= 2472) + sec_ch_freq = oper_freq - 20; } /* This call decides required channel bonding mode */ - wlan_reg_set_channel_params(hdd_ctx->pdev, op_chan, - sec_ch, ch_params); + wlan_reg_set_channel_params_for_freq(hdd_ctx->pdev, oper_freq, + sec_ch_freq, ch_params); if (adapter->device_mode == QDF_STA_MODE && ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc)) { @@ -17596,7 +17595,7 @@ void hdd_select_cbmode(struct hdd_adapter *adapter, uint8_t op_chan, } if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE || cbmode_select) - hdd_mon_select_cbmode(adapter, op_freq, ch_params); + hdd_mon_select_cbmode(adapter, oper_freq, ch_params); } /** @@ -17771,7 +17770,7 @@ int wlan_hdd_cfg80211_check_pmf_valid(struct csr_roam_profile *roam_profile) static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, const u8 *ssid, size_t ssid_len, const u8 *bssid, const u8 *bssid_hint, - u8 operatingChannel, + uint32_t oper_freq, enum nl80211_chan_width ch_width) { int status = 0; @@ -17787,7 +17786,6 @@ static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, uint8_t value = 0; struct wlan_objmgr_vdev *vdev; uint32_t channel_bonding_mode; - uint32_t oper_freq; hdd_enter(); @@ -17914,11 +17912,9 @@ static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, bssid_hint); } - hdd_debug("vdevid %d: Connect to SSID: %.*s operating Channel: %u", - adapter->vdev_id, + hdd_debug("Connect to SSID: %.*s operating Ch freq: %u", roam_profile->SSIDs.SSIDList->SSID.length, - roam_profile->SSIDs.SSIDList->SSID.ssId, - operatingChannel); + roam_profile->SSIDs.SSIDList->SSID.ssId, oper_freq); if (hdd_sta_ctx->wpa_versions) { hdd_set_genie_to_csr(adapter, &rsn_auth_type); @@ -17971,17 +17967,14 @@ static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, hdd_objmgr_put_vdev(vdev); roam_profile->csrPersona = adapter->device_mode; - if (operatingChannel) { - oper_freq = wlan_reg_chan_to_freq(hdd_ctx->pdev, - operatingChannel); + if (oper_freq) { roam_profile->ChannelInfo.freq_list = &oper_freq; roam_profile->ChannelInfo.numOfChannels = 1; } else { roam_profile->ChannelInfo.freq_list = NULL; roam_profile->ChannelInfo.numOfChannels = 0; } - if ((QDF_IBSS_MODE == adapter->device_mode) - && operatingChannel) { + if (QDF_IBSS_MODE == adapter->device_mode && oper_freq) { /* * Need to post the IBSS power save parameters * to WMA. WMA will configure this parameters @@ -18001,10 +17994,10 @@ static int wlan_hdd_cfg80211_connect_start(struct hdd_adapter *adapter, * In IBSS mode while operating in 2.4 GHz, * the device supports only 20 MHz. */ - if (WLAN_REG_IS_24GHZ_CH(operatingChannel)) + if (WLAN_REG_IS_24GHZ_CH_FREQ(oper_freq)) roam_profile->ch_params.ch_width = CH_WIDTH_20MHZ; - hdd_select_cbmode(adapter, operatingChannel, + hdd_select_cbmode(adapter, oper_freq, &roam_profile->ch_params); } @@ -20132,7 +20125,7 @@ static int wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, { int status = -EINVAL; const uint8_t *bssid = NULL; - uint16_t channel = 0; + uint32_t ch_freq = 0; struct hdd_station_ctx *sta_ctx; if (req->bssid) @@ -20141,13 +20134,13 @@ static int wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, bssid = req->bssid_hint; if (req->channel) - channel = req->channel->hw_value; + ch_freq = req->channel->center_freq; else if (req->channel_hint) - channel = req->channel_hint->hw_value; + ch_freq = req->channel_hint->center_freq; - if (bssid && channel && req->prev_bssid) { - hdd_debug("REASSOC Attempt on channel %d to " QDF_MAC_ADDR_STR, - channel, QDF_MAC_ADDR_ARRAY(bssid)); + if (bssid && ch_freq && req->prev_bssid) { + hdd_debug("REASSOC Attempt on ch freq %d to " QDF_MAC_ADDR_STR, + ch_freq, QDF_MAC_ADDR_ARRAY(bssid)); /* * Save BSSID in a separate variable as * roam_profile's BSSID is getting zeroed out in the @@ -20158,8 +20151,8 @@ static int wlan_hdd_reassoc_bssid_hint(struct hdd_adapter *adapter, qdf_mem_copy(sta_ctx->requested_bssid.bytes, bssid, QDF_MAC_ADDR_SIZE); - status = hdd_reassoc(adapter, bssid, channel, - CONNECT_CMD_USERSPACE); + status = hdd_reassoc(adapter, bssid, ch_freq, + CONNECT_CMD_USERSPACE); hdd_debug("hdd_reassoc: status: %d", status); } return status; @@ -20239,7 +20232,7 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, struct cfg80211_connect_params *req) { int status; - u16 channel, sap_cnt, sta_cnt; + uint32_t ch_freq, sap_cnt, sta_cnt; const u8 *bssid = NULL; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)) const u8 *bssid_hint = req->bssid_hint; @@ -20370,12 +20363,12 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, if (req->channel) { bool ok = false; - if (req->channel->hw_value && policy_mgr_is_chan_ok_for_dnbs( + if (req->channel->center_freq && policy_mgr_is_chan_ok_for_dnbs( hdd_ctx->psoc, req->channel->center_freq, &ok)) { - hdd_warn("Unable to get channel:%d eligibility for DNBS", - req->channel->hw_value); + hdd_warn("Unable to get ch freq:%d eligibility for DNBS", + req->channel->center_freq); return -EINVAL; } /** @@ -20383,13 +20376,12 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, * blacklist us. */ if (!ok) { - struct ieee80211_channel *chan = - ieee80211_get_channel(wiphy, - wlan_chan_to_freq(req->channel->hw_value)); + struct ieee80211_channel *chan = ieee80211_get_channel( + wiphy, req->channel->center_freq); struct cfg80211_bss *bss; - hdd_warn("Channel:%d not OK for DNBS", - req->channel->hw_value); + hdd_warn("Ch freq:%d not OK for DNBS", + req->channel->center_freq); if (chan) { bss = wlan_cfg80211_get_bss(wiphy, chan, req->bssid, @@ -20422,15 +20414,15 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, } if (req->channel) - channel = req->channel->hw_value; + ch_freq = req->channel->center_freq; else - channel = 0; + ch_freq = 0; wlan_hdd_check_ht20_ht40_ind(hdd_ctx, adapter, req); status = wlan_hdd_cfg80211_connect_start(adapter, req->ssid, req->ssid_len, req->bssid, - bssid_hint, channel, 0); + bssid_hint, ch_freq, 0); if (0 > status) hdd_err("connect failed"); @@ -22777,7 +22769,8 @@ static int __wlan_hdd_cfg80211_set_mon_ch(struct wiphy *wiphy, roam_profile.ChannelInfo.numOfChannels = 1; roam_profile.phyMode = ch_info->phy_mode; roam_profile.ch_params.ch_width = hdd_map_nl_chan_width(chandef->width); - hdd_select_cbmode(adapter, chan_num, &roam_profile.ch_params); + hdd_select_cbmode(adapter, chandef->chan->center_freq, + &roam_profile.ch_params); qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, QDF_MAC_ADDR_SIZE); diff --git a/core/hdd/src/wlan_hdd_cfg80211.h b/core/hdd/src/wlan_hdd_cfg80211.h index df69c60a36..b6c0054ca5 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.h +++ b/core/hdd/src/wlan_hdd_cfg80211.h @@ -318,7 +318,7 @@ void hdd_reg_notifier(struct wiphy *wiphy, QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_adapter *adapter, uint32_t ch_freq); -void hdd_select_cbmode(struct hdd_adapter *adapter, uint8_t op_chan, +void hdd_select_cbmode(struct hdd_adapter *adapter, uint32_t oper_freq, struct ch_params *ch_params); /** diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index bfe4ad0fb6..83cd4306db 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -1297,7 +1297,7 @@ static int hdd_parse_reassoc_command_v1_data(const uint8_t *command, #ifdef WLAN_FEATURE_ROAM_OFFLOAD QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, const tSirMacAddr bssid, - int channel) + uint32_t ch_freq) { struct hdd_station_ctx *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); @@ -1308,24 +1308,13 @@ QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, qdf_mem_copy(connected_bssid, hdd_sta_ctx->conn_info.bssid.bytes, ETH_ALEN); return sme_fast_reassoc(adapter->hdd_ctx->mac_handle, - roam_profile, bssid, channel, + roam_profile, bssid, ch_freq, adapter->vdev_id, connected_bssid); } #endif -/** - * hdd_reassoc() - perform a userspace-directed reassoc - * @adapter: Adapter upon which the command was received - * @bssid: BSSID with which to reassociate - * @channel: channel upon which to reassociate - * @src: The source for the trigger of this action - * - * This function performs a userspace-directed reassoc operation - * - * Return: 0 for success non-zero for failure - */ int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, - uint8_t channel, const handoff_src src) + uint32_t ch_freq, const handoff_src src) { struct hdd_station_ctx *sta_ctx; struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); @@ -1368,24 +1357,21 @@ int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, * use the current connections's channel. */ if (!memcmp(bssid, sta_ctx->conn_info.bssid.bytes, - QDF_MAC_ADDR_SIZE)) { + QDF_MAC_ADDR_SIZE)) { hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); - channel = wlan_reg_freq_to_chan(hdd_ctx->pdev, - sta_ctx->conn_info.chan_freq); + ch_freq = sta_ctx->conn_info.chan_freq; } - /* Check channel number is a valid channel number */ if (QDF_STATUS_SUCCESS != - wlan_hdd_validate_operation_channel(adapter, channel)) { - hdd_err("Invalid Channel: %d", channel); + wlan_hdd_validate_operation_channel(adapter, ch_freq)) { + hdd_err("Invalid Ch freq: %d", ch_freq); ret = -EINVAL; goto exit; } /* Proceed with reassoc */ if (roaming_offload_enabled(hdd_ctx)) { - status = hdd_wma_send_fastreassoc_cmd(adapter, - bssid, (int)channel); + status = hdd_wma_send_fastreassoc_cmd(adapter, bssid, ch_freq); if (status != QDF_STATUS_SUCCESS) { hdd_err("Failed to send fast reassoc cmd"); ret = -EINVAL; @@ -1393,7 +1379,7 @@ int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, } else { tCsrHandoffRequest handoff; - handoff.ch_freq = wlan_reg_chan_to_freq(hdd_ctx->pdev, channel); + handoff.ch_freq = ch_freq; handoff.src = src; qdf_mem_copy(handoff.bssid.bytes, bssid, QDF_MAC_ADDR_SIZE); sme_handoff_request(hdd_ctx->mac_handle, adapter->vdev_id, @@ -1430,7 +1416,8 @@ static int hdd_parse_reassoc_v1(struct hdd_adapter *adapter, const char *command if (ret) hdd_err("Failed to parse reassoc command data"); else - ret = hdd_reassoc(adapter, bssid, channel, REASSOC); + ret = hdd_reassoc(adapter, bssid, + wlan_chan_to_freq(channel), REASSOC); return ret; } @@ -1468,7 +1455,8 @@ static int hdd_parse_reassoc_v2(struct hdd_adapter *adapter, hdd_err("MAC address parsing failed"); ret = -EINVAL; } else { - ret = hdd_reassoc(adapter, bssid, params.channel, REASSOC); + ret = hdd_reassoc(adapter, bssid, + wlan_chan_to_freq(params.channel), REASSOC); } return ret; } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index f96ed92233..c8ae1a8676 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -6892,7 +6892,8 @@ int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, roam_profile.ChannelInfo.numOfChannels = 1; roam_profile.phyMode = ch_info->phy_mode; roam_profile.ch_params.ch_width = bandwidth; - hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); + hdd_select_cbmode(adapter, wlan_chan_to_freq(chan), + &roam_profile.ch_params); if (ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc) && (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { status = sme_create_mon_session(mac_handle,