From 6c40b112ce0804374675f62abb8e2d2e0f0501bf Mon Sep 17 00:00:00 2001 From: Tushnim Bhattacharyya Date: Wed, 30 Oct 2019 11:39:25 -0700 Subject: [PATCH] qcacld-3.0: Replace channel id with frequency in ecsa indication Replace channel ID with channel frequency in ecsa indication flow. Change-Id: I1dd3148566e1da37a6f3fa71f1887e66f87f5d1c CRs-Fixed: 2555384 --- core/hdd/inc/wlan_hdd_main.h | 14 ++- core/hdd/src/wlan_hdd_cfg80211.c | 10 +- core/hdd/src/wlan_hdd_hostapd.c | 53 +++------ core/hdd/src/wlan_hdd_hostapd.h | 28 ++++- core/hdd/src/wlan_hdd_hostapd_wext.c | 6 +- core/hdd/src/wlan_hdd_ioctl.c | 4 +- core/hdd/src/wlan_hdd_main.c | 102 +++--------------- core/mac/inc/sir_api.h | 4 +- .../mac/src/pe/lim/lim_process_action_frame.c | 16 +-- core/sap/inc/sap_api.h | 4 +- core/sap/src/sap_fsm.c | 4 +- core/sme/inc/csr_api.h | 2 +- core/sme/src/common/sme_api.c | 2 +- 13 files changed, 90 insertions(+), 159 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 9708c93e0f..e236652336 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1946,9 +1946,19 @@ struct hdd_channel_info { * Function declarations and documentation */ +/** + * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo + * @adapter: HDD adapter + * @chan_freq: Channel frequency + * @chan_bw: Bandwidth + * + * Checks if the given bandwidth is valid for the given channel number. + * + * Return: 0 for success, non-zero for failure + */ int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, - uint32_t chan_number, - enum phy_ch_width chan_bw); + uint32_t chan_freq, + enum phy_ch_width chan_bw); /** * hdd_get_front_adapter() - Get the first adapter from the adapter list diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 604d60195c..ffb2d6a188 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -22666,8 +22666,6 @@ static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, { struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); struct hdd_context *hdd_ctx; - uint8_t channel; - uint16_t freq; int ret; enum phy_ch_width ch_width; @@ -22689,12 +22687,12 @@ static int __wlan_hdd_cfg80211_channel_switch(struct wiphy *wiphy, wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id, CSA_REASON_USER_INITIATED); - freq = csa_params->chandef.chan->center_freq; - channel = cds_freq_to_chan(freq); - ch_width = hdd_map_nl_chan_width(csa_params->chandef.width); - ret = hdd_softap_set_channel_change(dev, channel, ch_width, false); + ret = + hdd_softap_set_channel_change(dev, + csa_params->chandef.chan->center_freq, + ch_width, false); return ret; } diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index e246bd9c34..4cea508bff 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -1147,8 +1147,7 @@ static void __wlan_hdd_sap_pre_cac_success(struct hdd_adapter *adapter) wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, ap_adapter->vdev_id, CSA_REASON_PRE_CAC_SUCCESS); i = hdd_softap_set_channel_change(ap_adapter->dev, - wlan_reg_freq_to_chan(hdd_ctx->pdev, - ap_adapter->pre_cac_freq), + ap_adapter->pre_cac_freq, CH_WIDTH_MAX, false); if (0 != i) { hdd_err("failed to change channel"); @@ -2615,12 +2614,12 @@ QDF_STATUS hdd_hostapd_sap_event_cb(struct sap_event *sap_event, return QDF_STATUS_SUCCESS; case eSAP_ECSA_CHANGE_CHAN_IND: - hdd_debug("Channel change indication from peer for channel %d", - sap_event->sapevt.sap_chan_cng_ind.new_chan); + hdd_debug("Channel change indication from peer for channel freq %d", + sap_event->sapevt.sap_chan_cng_ind.new_chan_freq); wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id, CSA_REASON_PEER_ACTION_FRAME); if (hdd_softap_set_channel_change(dev, - sap_event->sapevt.sap_chan_cng_ind.new_chan, + sap_event->sapevt.sap_chan_cng_ind.new_chan_freq, CH_WIDTH_MAX, false)) return QDF_STATUS_E_FAILURE; else @@ -2896,21 +2895,8 @@ static bool hdd_is_any_sta_connecting(struct hdd_context *hdd_ctx) return false; } -/** - * hdd_softap_set_channel_change() - - * This function to support SAP channel change with CSA IE - * set in the beacons. - * - * @dev: pointer to the net device. - * @target_channel: target channel number. - * @target_bw: Target bandwidth to move. - * If no bandwidth is specified, the value is CH_WIDTH_MAX - * @forced: Force to switch channel, ignore SCC/MCC check - * - * Return: 0 for success, non zero for failure - */ -int hdd_softap_set_channel_change(struct net_device *dev, int target_channel, - enum phy_ch_width target_bw, bool forced) +int hdd_softap_set_channel_change(struct net_device *dev, int target_chan_freq, + enum phy_ch_width target_bw, bool forced) { QDF_STATUS status; int ret = 0; @@ -2946,7 +2932,7 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_channel, } ret = hdd_validate_channel_and_bandwidth(adapter, - target_channel, target_bw); + target_chan_freq, target_bw); if (ret) { hdd_err("Invalid CH and BW combo"); return ret; @@ -2998,7 +2984,7 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_channel, hdd_ctx->psoc, policy_mgr_convert_device_mode_to_qdf_type( adapter->device_mode), - wlan_chan_to_freq(target_channel), + target_chan_freq, adapter->vdev_id, forced, sap_ctx->csa_reason)) { @@ -3046,13 +3032,13 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_channel, status = wlansap_set_channel_change_with_csa( WLAN_HDD_GET_SAP_CTX_PTR(adapter), - wlan_reg_chan_to_freq(hdd_ctx->pdev, target_channel), + target_chan_freq, target_bw, (forced && !scc_on_lte_coex) || is_p2p_go_session); if (QDF_STATUS_SUCCESS != status) { - hdd_err("SAP set channel failed for channel: %d, bw: %d", - target_channel, target_bw); + hdd_err("SAP set channel failed for channel freq: %d, bw: %d", + target_chan_freq, target_bw); /* * If channel change command fails then clear the * radar found flag and also restart the netif @@ -3074,19 +3060,8 @@ int hdd_softap_set_channel_change(struct net_device *dev, int target_channel, } #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH -/** - * hdd_sap_restart_with_channel_switch() - SAP channel change with E/CSA - * @ap_adapter: HDD adapter - * @target_channel: Channel to which switch must happen - * @target_bw: Bandwidth of the target channel - * @forced: Force to switch channel, ignore SCC/MCC check - * - * Invokes the necessary API to perform channel switch for the SAP or GO - * - * Return: None - */ void hdd_sap_restart_with_channel_switch(struct hdd_adapter *ap_adapter, - uint32_t target_channel, + uint32_t target_chan_freq, uint32_t target_bw, bool forced) { @@ -3100,7 +3075,7 @@ void hdd_sap_restart_with_channel_switch(struct hdd_adapter *ap_adapter, return; } - ret = hdd_softap_set_channel_change(dev, target_channel, + ret = hdd_softap_set_channel_change(dev, target_chan_freq, target_bw, forced); if (ret) { hdd_err("channel switch failed"); @@ -3121,7 +3096,7 @@ void hdd_sap_restart_chan_switch_cb(struct wlan_objmgr_psoc *psoc, return; } hdd_sap_restart_with_channel_switch(ap_adapter, - wlan_freq_to_chan(ch_freq), + ch_freq, channel_bw, forced); } diff --git a/core/hdd/src/wlan_hdd_hostapd.h b/core/hdd/src/wlan_hdd_hostapd.h index cd052157ed..e4c435fd7f 100644 --- a/core/hdd/src/wlan_hdd_hostapd.h +++ b/core/hdd/src/wlan_hdd_hostapd.h @@ -43,14 +43,38 @@ struct hdd_adapter *hdd_wlan_create_ap_dev(struct hdd_context *hdd_ctx, enum csr_akm_type hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4]); +/** + * hdd_softap_set_channel_change() - + * This function to support SAP channel change with CSA IE + * set in the beacons. + * + * @dev: pointer to the net device. + * @target_chan_freq: target channel frequency. + * @target_bw: Target bandwidth to move. + * If no bandwidth is specified, the value is CH_WIDTH_MAX + * @forced: Force to switch channel, ignore SCC/MCC check + * + * Return: 0 for success, non zero for failure + */ int hdd_softap_set_channel_change(struct net_device *dev, - int target_channel, + int target_chan_freq, enum phy_ch_width target_bw, bool forced); #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH +/** + * hdd_sap_restart_with_channel_switch() - SAP channel change with E/CSA + * @ap_adapter: HDD adapter + * @target_chan_freq: Channel frequency to which switch must happen + * @target_bw: Bandwidth of the target channel + * @forced: Force to switch channel, ignore SCC/MCC check + * + * Invokes the necessary API to perform channel switch for the SAP or GO + * + * Return: None + */ void hdd_sap_restart_with_channel_switch(struct hdd_adapter *adapter, - uint32_t target_channel, + uint32_t target_chan_freq, uint32_t target_bw, bool forced); /** diff --git a/core/hdd/src/wlan_hdd_hostapd_wext.c b/core/hdd/src/wlan_hdd_hostapd_wext.c index a066d4d630..bd8310bc22 100644 --- a/core/hdd/src/wlan_hdd_hostapd_wext.c +++ b/core/hdd/src/wlan_hdd_hostapd_wext.c @@ -398,9 +398,9 @@ static __iw_softap_setparam(struct net_device *dev, CSA_REASON_USER_INITIATED); hdd_debug("SET Channel Change to new channel= %d", set_value); - ret = hdd_softap_set_channel_change(dev, set_value, - CH_WIDTH_MAX, - false); + ret = hdd_softap_set_channel_change(dev, + wlan_reg_legacy_chan_to_freq(hdd_ctx->pdev, set_value), + CH_WIDTH_MAX, false); } else { hdd_err("Channel Change Failed, Device in test mode"); ret = -EINVAL; diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 71403ccc15..b031fb53b2 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -7145,7 +7145,9 @@ static int drv_cmd_set_channel_switch(struct hdd_adapter *adapter, wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id, CSA_REASON_USER_INITIATED); - status = hdd_softap_set_channel_change(dev, chan_number, width, true); + status = hdd_softap_set_channel_change(dev, + wlan_reg_legacy_chan_to_freq(hdd_ctx->pdev, chan_number), + width, true); if (status) { hdd_err("Set channel change fail"); return status; diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 4eefe3d71e..12454e220b 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -778,76 +778,11 @@ uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBU uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR; #endif -/** - * hdd_get_valid_chan() - return current chan list from regulatory. - * @hdd_ctx: HDD context - * @chan_list: buf hold returned chan list - * @chan_num: input buf size and output returned chan num - * - * This function helps get current available chan list from regulatory - * module. It excludes the "disabled" and "invalid" channels. - * - * Return: 0 for success. - */ -static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, - uint8_t *chan_list, - uint32_t *chan_num) -{ - int i = 0, j = 0; - struct regulatory_channel *cur_chan_list; - struct wlan_objmgr_pdev *pdev; - - if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) - return -EINVAL; - - pdev = hdd_ctx->pdev; - cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * - sizeof(struct regulatory_channel)); - if (!cur_chan_list) - return -ENOMEM; - - if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != - QDF_STATUS_SUCCESS) { - qdf_mem_free(cur_chan_list); - return -EINVAL; - } - - for (i = 0; i < NUM_CHANNELS; i++) { - uint32_t ch = cur_chan_list[i].chan_num; - enum channel_state state = wlan_reg_get_channel_state(pdev, - ch); - - if (state != CHANNEL_STATE_DISABLE && - state != CHANNEL_STATE_INVALID && - j < *chan_num) { - chan_list[j] = (uint8_t)ch; - j++; - } - } - *chan_num = j; - qdf_mem_free(cur_chan_list); - return 0; -} - -/** - * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo - * @adapter: HDD adapter - * @chan_number: Channel number - * @chan_bw: Bandwidth - * - * Checks if the given bandwidth is valid for the given channel number. - * - * Return: 0 for success, non-zero for failure - */ int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, - uint32_t chan_number, - enum phy_ch_width chan_bw) + uint32_t chan_freq, + enum phy_ch_width chan_bw) { - uint8_t chan[NUM_CHANNELS]; - uint32_t len = NUM_CHANNELS, i; - bool found = false; mac_handle_t mac_handle; - int ret; mac_handle = hdd_adapter_get_mac_handle(adapter); if (!mac_handle) { @@ -855,39 +790,26 @@ int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, return -EINVAL; } - ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, - &len); - if (ret) { - hdd_err("error %d in getting valid channel list", ret); - return ret; - } - - for (i = 0; i < len; i++) { - if (chan[i] == chan_number) { - found = true; - break; - } - } - - if (found == false) { - hdd_err("Channel not in driver's valid channel list"); + if (INVALID_CHANNEL == wlan_reg_get_chan_enum_for_freq(chan_freq)) { + hdd_err("Channel freq %d not in driver's valid channel list", chan_freq); return -EOPNOTSUPP; } - if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && - (!WLAN_REG_IS_5GHZ_CH(chan_number))) { - hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); + if ((!WLAN_REG_IS_24GHZ_CH_FREQ(chan_freq)) && + (!WLAN_REG_IS_5GHZ_CH_FREQ(chan_freq)) && + (!WLAN_REG_IS_6GHZ_CHAN_FREQ(chan_freq))) { + hdd_err("CH %d is not in 2.4GHz or 5GHz or 6GHz", chan_freq); return -EINVAL; } - if (WLAN_REG_IS_24GHZ_CH(chan_number)) { + if (WLAN_REG_IS_24GHZ_CH_FREQ(chan_freq)) { if (chan_bw == CH_WIDTH_80MHZ) { hdd_err("BW80 not possible in 2.4GHz band"); return -EINVAL; } - if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && - (chan_bw != CH_WIDTH_MAX)) { - hdd_err("Only BW20 possible on channel 14"); + if ((chan_bw != CH_WIDTH_20MHZ) && (chan_freq == 2484) && + (chan_bw != CH_WIDTH_MAX)) { + hdd_err("Only BW20 possible on channel freq 2484"); return -EINVAL; } } diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index d96626180b..56a4f5e960 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -4427,11 +4427,11 @@ struct sir_sme_ext_cng_chan_req { /** * struct sir_sme_ext_change_chan_ind. * @session_id: session id - * @new_channel: new channel to change + * @new_chan_freq: new channel frequency to change to */ struct sir_sme_ext_cng_chan_ind { uint8_t session_id; - uint8_t new_channel; + uint32_t new_chan_freq; }; /** diff --git a/core/mac/src/pe/lim/lim_process_action_frame.c b/core/mac/src/pe/lim/lim_process_action_frame.c index 3e8224b37f..d80903dc36 100644 --- a/core/mac/src/pe/lim/lim_process_action_frame.c +++ b/core/mac/src/pe/lim/lim_process_action_frame.c @@ -333,7 +333,6 @@ lim_process_ext_channel_switch_action_frame(struct mac_context *mac_ctx, tDot11fext_channel_switch_action_frame *ext_channel_switch_frame; uint32_t frame_len; uint32_t status; - uint8_t target_channel; uint32_t target_freq; hdr = WMA_GET_RX_MAC_HEADER(rx_packet_info); @@ -361,9 +360,10 @@ lim_process_ext_channel_switch_action_frame(struct mac_context *mac_ctx, status, frame_len); } - target_channel = - ext_channel_switch_frame->ext_chan_switch_ann_action.new_channel; - target_freq = wlan_reg_chan_to_freq(mac_ctx->pdev, target_channel); + target_freq = + wlan_reg_chan_opclass_to_freq(ext_channel_switch_frame->ext_chan_switch_ann_action.new_channel, + ext_channel_switch_frame->ext_chan_switch_ann_action.op_class, + false); /* Free ext_channel_switch_frame here as its no longer needed */ qdf_mem_free(ext_channel_switch_frame); /* @@ -372,13 +372,13 @@ lim_process_ext_channel_switch_action_frame(struct mac_context *mac_ctx, * and no concurrent session is running. */ if (!(session_entry->curr_op_freq != target_freq && - ((wlan_reg_get_channel_state(mac_ctx->pdev, target_channel) == + ((wlan_reg_get_channel_state_for_freq(mac_ctx->pdev, target_freq) == CHANNEL_STATE_ENABLE) || - (wlan_reg_get_channel_state(mac_ctx->pdev, target_channel) == + (wlan_reg_get_channel_state_for_freq(mac_ctx->pdev, target_freq) == CHANNEL_STATE_DFS && !policy_mgr_concurrent_open_sessions_running( mac_ctx->psoc))))) { - pe_err("Channel: %d is not valid", target_channel); + pe_err("Channel freq: %d is not valid", target_freq); return; } @@ -397,7 +397,7 @@ lim_process_ext_channel_switch_action_frame(struct mac_context *mac_ctx, /* No need to extract op mode as BW will be decided in * in SAP FSM depending on previous BW. */ - ext_cng_chan_ind->new_channel = target_channel; + ext_cng_chan_ind->new_chan_freq = target_freq; mmh_msg.type = eWNI_SME_EXT_CHANGE_CHANNEL_IND; mmh_msg.bodyptr = ext_cng_chan_ind; diff --git a/core/sap/inc/sap_api.h b/core/sap/inc/sap_api.h index e1959cbf91..be81f55430 100644 --- a/core/sap/inc/sap_api.h +++ b/core/sap/inc/sap_api.h @@ -369,10 +369,10 @@ struct sap_acs_scan_complete_event { /** * struct sap_ch_change_ind - channel change indication - * @new_chan: channel to change + * @new_chan_freq: channel frequency to change to */ struct sap_ch_change_ind { - uint16_t new_chan; + uint32_t new_chan_freq; }; /* diff --git a/core/sap/src/sap_fsm.c b/core/sap/src/sap_fsm.c index 54b33bbd1a..43f486d35c 100644 --- a/core/sap/src/sap_fsm.c +++ b/core/sap/src/sap_fsm.c @@ -1767,8 +1767,8 @@ QDF_STATUS sap_signal_hdd_event(struct sap_context *sap_ctx, "In %s, SAP event callback event = %s", __func__, "eSAP_ECSA_CHANGE_CHAN_IND"); sap_ap_event.sapHddEventCode = eSAP_ECSA_CHANGE_CHAN_IND; - sap_ap_event.sapevt.sap_chan_cng_ind.new_chan = - csr_roaminfo->target_channel; + sap_ap_event.sapevt.sap_chan_cng_ind.new_chan_freq = + csr_roaminfo->target_chan_freq; break; case eSAP_DFS_NEXT_CHANNEL_REQ: QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, diff --git a/core/sme/inc/csr_api.h b/core/sme/inc/csr_api.h index 5516185879..441033cc2c 100644 --- a/core/sme/inc/csr_api.h +++ b/core/sme/inc/csr_api.h @@ -1083,7 +1083,7 @@ struct csr_roam_info { uint8_t subnet_change_status; #endif struct oem_channel_info chan_info; - uint8_t target_channel; + uint32_t target_chan_freq; #ifdef WLAN_FEATURE_NAN union { diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 79b2ade392..f72847306e 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -1395,7 +1395,7 @@ static QDF_STATUS sme_extended_change_channel_ind(struct mac_context *mac_ctx, if (!roam_info) return QDF_STATUS_E_NOMEM; session_id = ext_chan_ind->session_id; - roam_info->target_channel = ext_chan_ind->new_channel; + roam_info->target_chan_freq = ext_chan_ind->new_chan_freq; roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND; roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND; sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",