qcacld-3.0: Fix read current country code

In populate_dot_11_f_ext_chann_switch_ann API, will read current country
code from mac context which is not have the updated country code.

So, read the current country code directly from regulatory API,
wlan_reg_read_current_country.

Remove unused variables mac->scan.countryCodeCurrent,
mac_ptr->scan.countryCodeDefault and tagCsr11dinfo->countryCode.

Change-Id: Ice64ef1be5b775125ff3bcacfcab7684c6833cad
CRs-Fixed: 3529808
This commit is contained in:
Vinod Kumar Myadam 2023-06-14 11:12:28 +05:30 • committed by Rahul Choudhary
commit 5dd1ccf148
12 changed files with 51 additions and 68 deletions

View file

@ -9696,7 +9696,6 @@ void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason)
QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx)
{
return sme_init_chan_list(hdd_ctx->mac_handle,
hdd_ctx->reg.alpha2,
hdd_ctx->reg.cc_src);
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -205,6 +205,7 @@ static void populate_dot11f_tdls_offchannel_params(
uint8_t nss_2g;
uint8_t nss_5g;
qdf_freq_t ch_freq;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
numChans = mac->mlme_cfg->reg.valid_channel_list_num;
@ -270,13 +271,14 @@ static void populate_dot11f_tdls_offchannel_params(
break;
}
wlan_reg_read_current_country(mac->psoc, reg_cc);
op_class = wlan_reg_dmn_get_opclass_from_channel(
mac->scan.countryCodeCurrent,
reg_cc,
wlan_reg_freq_to_chan(mac->pdev, pe_session->curr_op_freq),
chanOffset);
pe_debug("countryCodeCurrent: %s, curr_op_freq: %d, htSecondaryChannelOffset: %d, chanOffset: %d op class: %d",
mac->scan.countryCodeCurrent,
reg_cc,
pe_session->curr_op_freq,
pe_session->htSecondaryChannelOffset,
chanOffset, op_class);

View file

@ -4288,6 +4288,7 @@ lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
uint8_t vdev_id = 0;
uint8_t ch_spacing;
tLimWiderBWChannelSwitchInfo *wide_bw_ie;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
if (!session_entry) {
pe_err("Session entry is NULL!!!");
@ -4306,9 +4307,9 @@ lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
frm.ext_chan_switch_ann_action.new_channel = new_channel;
frm.ext_chan_switch_ann_action.switch_count = count;
wlan_reg_read_current_country(mac_ctx->psoc, reg_cc);
ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
mac_ctx->scan.countryCodeCurrent, new_channel,
new_op_class);
reg_cc, new_channel, new_op_class);
if ((ch_spacing == 80) || (ch_spacing == 160)) {
wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -477,6 +478,7 @@ QDF_STATUS lim_send_ht40_obss_scanind(struct mac_context *mac_ctx,
uint32_t channelnum, chan_freq;
struct scheduler_msg msg = {0};
uint8_t channel24gnum, count;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
ht40_obss_scanind = qdf_mem_malloc(sizeof(struct obss_ht40_scanind));
if (!ht40_obss_scanind)
@ -485,6 +487,7 @@ QDF_STATUS lim_send_ht40_obss_scanind(struct mac_context *mac_ctx,
"OBSS Scan Indication bssid " QDF_MAC_ADDR_FMT,
QDF_MAC_ADDR_REF(session->bssId));
wlan_reg_read_current_country(mac_ctx->psoc, reg_cc);
ht40_obss_scanind->cmd = HT40_OBSS_SCAN_PARAM_START;
ht40_obss_scanind->scan_type = eSIR_ACTIVE_SCAN;
ht40_obss_scanind->obss_passive_dwelltime =
@ -503,7 +506,7 @@ QDF_STATUS lim_send_ht40_obss_scanind(struct mac_context *mac_ctx,
session->obss_ht40_scanparam.obss_activity_threshold;
ht40_obss_scanind->current_operatingclass =
wlan_reg_dmn_get_opclass_from_channel(
mac_ctx->scan.countryCodeCurrent,
reg_cc,
wlan_reg_freq_to_chan(
mac_ctx->pdev, session->curr_op_freq),
session->ch_width);

View file

@ -185,6 +185,7 @@ void populate_dot_11_f_ext_chann_switch_ann(struct mac_context *mac_ptr,
uint32_t sw_target_freq;
uint8_t primary_channel;
enum phy_ch_width ch_width;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
ch_width = session_entry->gLimChannelSwitch.ch_width;
ch_offset = session_entry->gLimChannelSwitch.sec_ch_offset;
@ -201,8 +202,9 @@ void populate_dot_11_f_ext_chann_switch_ann(struct mac_context *mac_ptr,
session_entry->gLimChannelSwitch.switchCount;
dot_11_ptr->present = 1;
wlan_reg_read_current_country(mac_ptr->psoc, reg_cc);
pe_debug("country:%s chan:%d freq %d width:%d reg:%d off:%d",
mac_ptr->scan.countryCodeCurrent,
reg_cc,
session_entry->gLimChannelSwitch.primaryChannel,
sw_target_freq,
session_entry->gLimChannelSwitch.ch_width,

View file

@ -274,7 +274,6 @@ typedef struct sCsrChnPower_ {
typedef struct tagCsr11dinfo {
sCsrChannel Channels;
uint8_t countryCode[REG_ALPHA2_LEN + 1];
/* max power channel list */
sCsrChnPower ChnPower[CFG_VALID_CHANNEL_LIST_LEN];
} tCsr11dinfo;

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -399,8 +399,6 @@ struct csr_scanstruct {
tDblLinkList channelPowerInfoList5G;
uint32_t nLastAgeTimeOut;
uint32_t nAgingCountDown;
uint8_t countryCodeDefault[REG_ALPHA2_LEN + 1];
uint8_t countryCodeCurrent[REG_ALPHA2_LEN + 1];
uint8_t countryCode11d[REG_ALPHA2_LEN + 1];
v_REGDOMAIN_t domainIdDefault; /* default regulatory domain */
v_REGDOMAIN_t domainIdCurrent; /* current regulatory domain */
@ -895,7 +893,7 @@ QDF_STATUS csr_change_default_config_param(struct mac_context *mac,
struct csr_config_params *pParam);
QDF_STATUS csr_msg_processor(struct mac_context *mac, void *msg_buf);
QDF_STATUS csr_open(struct mac_context *mac);
QDF_STATUS csr_init_chan_list(struct mac_context *mac, uint8_t *alpha2);
QDF_STATUS csr_init_chan_list(struct mac_context *mac);
QDF_STATUS csr_close(struct mac_context *mac);
QDF_STATUS csr_start(struct mac_context *mac);
QDF_STATUS csr_stop(struct mac_context *mac);

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -256,8 +257,7 @@ enum {
Function declarations and documenation
------------------------------------------------------------------------*/
QDF_STATUS sme_open(mac_handle_t mac_handle);
QDF_STATUS sme_init_chan_list(mac_handle_t mac_handle, uint8_t *alpha2,
enum country_src cc_src);
QDF_STATUS sme_init_chan_list(mac_handle_t mac_handle, enum country_src cc_src);
QDF_STATUS sme_close(mac_handle_t mac_handle);
QDF_STATUS sme_start(mac_handle_t mac_handle);

View file

@ -861,8 +861,7 @@ QDF_STATUS sme_open(mac_handle_t mac_handle)
/*
* sme_init_chan_list, triggers channel setup based on country code.
*/
QDF_STATUS sme_init_chan_list(mac_handle_t mac_handle, uint8_t *alpha2,
enum country_src cc_src)
QDF_STATUS sme_init_chan_list(mac_handle_t mac_handle, enum country_src cc_src)
{
struct mac_context *pmac = MAC_CONTEXT(mac_handle);
@ -871,7 +870,7 @@ QDF_STATUS sme_init_chan_list(mac_handle_t mac_handle, uint8_t *alpha2,
pmac->mlme_cfg->gen.enabled_11d = false;
}
return csr_init_chan_list(pmac, alpha2);
return csr_init_chan_list(pmac);
}
/*
@ -13090,7 +13089,9 @@ void sme_get_opclass(mac_handle_t mac_handle, uint8_t channel,
uint8_t bw_offset, uint8_t *opclass)
{
struct mac_context *mac_ctx = MAC_CONTEXT(mac_handle);
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
wlan_reg_read_current_country(mac_ctx->psoc, reg_cc);
/* redgm opclass table contains opclass for 40MHz low primary,
* 40MHz high primary and 20MHz. No support for 80MHz yet. So
* first we will check if bit for 40MHz is set and if so find
@ -13100,21 +13101,17 @@ void sme_get_opclass(mac_handle_t mac_handle, uint8_t channel,
*/
if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
*opclass = wlan_reg_dmn_get_opclass_from_channel(
mac_ctx->scan.countryCodeCurrent,
channel, BW40_LOW_PRIMARY);
reg_cc, channel, BW40_LOW_PRIMARY);
if (!(*opclass)) {
*opclass = wlan_reg_dmn_get_opclass_from_channel(
mac_ctx->scan.countryCodeCurrent,
channel, BW40_HIGH_PRIMARY);
reg_cc, channel, BW40_HIGH_PRIMARY);
}
} else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
*opclass = wlan_reg_dmn_get_opclass_from_channel(
mac_ctx->scan.countryCodeCurrent,
channel, BW20);
reg_cc, channel, BW20);
} else {
*opclass = wlan_reg_dmn_get_opclass_from_channel(
mac_ctx->scan.countryCodeCurrent,
channel, BWALL);
reg_cc, channel, BWALL);
}
}
#endif

View file

@ -637,23 +637,19 @@ QDF_STATUS csr_open(struct mac_context *mac)
return status;
}
QDF_STATUS csr_init_chan_list(struct mac_context *mac, uint8_t *alpha2)
QDF_STATUS csr_init_chan_list(struct mac_context *mac)
{
QDF_STATUS status;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
mac->scan.countryCodeDefault[0] = alpha2[0];
mac->scan.countryCodeDefault[1] = alpha2[1];
mac->scan.countryCodeDefault[2] = alpha2[2];
sme_debug("init time country code %.2s", mac->scan.countryCodeDefault);
wlan_reg_read_current_country(mac->psoc, reg_cc);
sme_debug("init time country code %.2s", reg_cc);
mac->scan.domainIdDefault = 0;
mac->scan.domainIdCurrent = 0;
qdf_mem_copy(mac->scan.countryCodeCurrent,
mac->scan.countryCodeDefault, REG_ALPHA2_LEN + 1);
qdf_mem_copy(mac->scan.countryCodeElected,
mac->scan.countryCodeDefault, REG_ALPHA2_LEN + 1);
reg_cc, REG_ALPHA2_LEN + 1);
status = csr_get_channel_and_power_list(mac);
return status;
@ -665,8 +661,6 @@ QDF_STATUS csr_set_channels(struct mac_context *mac,
QDF_STATUS status = QDF_STATUS_SUCCESS;
uint8_t index = 0;
qdf_mem_copy(pParam->Csr11dinfo.countryCode,
mac->scan.countryCodeCurrent, REG_ALPHA2_LEN + 1);
for (index = 0; index < mac->scan.base_channels.numChannels;
index++) {
pParam->Csr11dinfo.Channels.channel_freq_list[index] =
@ -2796,8 +2790,7 @@ QDF_STATUS csr_apply_channel_and_power_list(struct mac_context *mac)
csr_save_channel_power_for_band(mac, false);
csr_save_channel_power_for_band(mac, true);
csr_apply_channel_power_info_to_fw(mac,
&mac->scan.base_channels,
mac->scan.countryCodeCurrent);
&mac->scan.base_channels);
csr_init_operating_classes(mac);
return status;
@ -2829,17 +2822,6 @@ static QDF_STATUS csr_init11d_info(struct mac_context *mac, tCsr11dinfo *ps11din
}
/* legacy maintenance */
qdf_mem_copy(mac->scan.countryCodeDefault, ps11dinfo->countryCode,
REG_ALPHA2_LEN + 1);
/* Tush: at csropen get this initialized with default,
* during csr reset if this already set with some value
* no need initilaize with default again
*/
if (0 == mac->scan.countryCodeCurrent[0]) {
qdf_mem_copy(mac->scan.countryCodeCurrent,
ps11dinfo->countryCode, REG_ALPHA2_LEN + 1);
}
/* need to add the max power channel list */
pChanInfo =
qdf_mem_malloc(sizeof(tSirMacChanInfo) *
@ -2881,9 +2863,7 @@ static QDF_STATUS csr_init11d_info(struct mac_context *mac, tCsr11dinfo *ps11din
*/
csr_apply_channel_power_info_to_fw(mac,
&mac->scan.
base_channels,
mac->scan.
countryCodeCurrent);
base_channels);
}
}
return status;
@ -15050,6 +15030,7 @@ QDF_STATUS csr_send_join_req_msg(struct mac_context *mac, uint32_t sessionId,
uint8_t programmed_country[REG_ALPHA2_LEN + 1];
enum reg_6g_ap_type power_type_6g;
bool ctry_code_match;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
if (!pSession) {
sme_err("session %d not found", sessionId);
@ -15136,8 +15117,9 @@ QDF_STATUS csr_send_join_req_msg(struct mac_context *mac, uint32_t sessionId,
qdf_mem_copy(&csr_join_req->self_mac_addr,
&pSession->self_mac_addr,
sizeof(tSirMacAddr));
wlan_reg_read_current_country(mac->psoc, reg_cc);
sme_nofl_info("vdev-%d: Connecting to %.*s " QDF_MAC_ADDR_FMT
" rssi: %d freq: %d akm %d cipher: uc %d mc %d, CC: %c%c",
" rssi: %d freq: %d akm %d cipher: uc %d mc %d, CC: %s",
sessionId, csr_join_req->ssId.length,
csr_join_req->ssId.ssId,
QDF_MAC_ADDR_REF(pBssDescription->bssId),
@ -15145,8 +15127,7 @@ QDF_STATUS csr_send_join_req_msg(struct mac_context *mac, uint32_t sessionId,
pProfile->negotiatedAuthType,
pProfile->negotiatedUCEncryptionType,
pProfile->negotiatedMCEncryptionType,
mac->scan.countryCodeCurrent[0],
mac->scan.countryCodeCurrent[1]);
reg_cc);
wlan_rec_conn_info(sessionId, DEBUG_CONN_CONNECTING,
pBssDescription->bssId,
pProfile->negotiatedAuthType,
@ -20311,10 +20292,10 @@ static void csr_init_operating_classes(struct mac_context *mac)
uint8_t swap = 0;
uint8_t numClasses = 0;
uint8_t opClasses[REG_MAX_SUPP_OPER_CLASSES] = {0,};
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
sme_debug("Current Country = %c%c",
mac->scan.countryCodeCurrent[0],
mac->scan.countryCodeCurrent[1]);
wlan_reg_read_current_country(mac->psoc, reg_cc);
sme_debug("Current Country = %s", reg_cc);
csr_update_op_class_array(mac, opClasses,
&mac->scan.base_channels, "20MHz", &i);

View file

@ -566,8 +566,7 @@ void csr_apply_power2_current(struct mac_context *mac)
}
void csr_apply_channel_power_info_to_fw(struct mac_context *mac_ctx,
struct csr_channel *ch_lst,
uint8_t *countryCode)
struct csr_channel *ch_lst)
{
int i;
uint8_t num_ch = 0;
@ -598,6 +597,7 @@ static void csr_diag_reset_country_information(struct mac_context *mac)
host_log_802_11d_pkt_type *p11dLog;
int Index;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
WLAN_HOST_DIAG_LOG_ALLOC(p11dLog, host_log_802_11d_pkt_type,
LOG_WLAN_80211D_C);
@ -605,7 +605,8 @@ static void csr_diag_reset_country_information(struct mac_context *mac)
return;
p11dLog->eventId = WLAN_80211D_EVENT_RESET;
qdf_mem_copy(p11dLog->countryCode, mac->scan.countryCodeCurrent, 3);
wlan_reg_read_current_country(mac->psoc, reg_cc);
qdf_mem_copy(p11dLog->countryCode, reg_cc, 3);
p11dLog->numChannel = mac->scan.base_channels.numChannels;
if (p11dLog->numChannel <= HOST_LOG_MAX_NUM_CHANNEL) {
for (Index = 0;
@ -640,8 +641,7 @@ void csr_apply_channel_power_info_wrapper(struct mac_context *mac)
csr_save_channel_power_for_band(mac, false);
csr_save_channel_power_for_band(mac, true);
/* apply the channel list, power settings, and the country code. */
csr_apply_channel_power_info_to_fw(mac,
&mac->scan.base_channels, mac->scan.countryCodeCurrent);
csr_apply_channel_power_info_to_fw(mac, &mac->scan.base_channels);
/* clear the 11d channel list */
qdf_mem_zero(&mac->scan.channels11d, sizeof(mac->scan.channels11d));
}
@ -846,6 +846,7 @@ bool csr_learn_11dcountry_information(struct mac_context *mac,
v_REGDOMAIN_t domainId;
tDot11fBeaconIEs *pIesLocal = pIes;
bool useVoting = false;
uint8_t reg_cc[REG_ALPHA2_LEN + 1];
if ((!pSirBssDesc) && (!pIes))
useVoting = true;
@ -877,10 +878,11 @@ bool csr_learn_11dcountry_information(struct mac_context *mac,
else
pCountryCodeSelected = mac->scan.countryCodeElected;
if (qdf_mem_cmp(pCountryCodeSelected, mac->scan.countryCodeCurrent,
wlan_reg_read_current_country(mac->psoc, reg_cc);
if (qdf_mem_cmp(pCountryCodeSelected, reg_cc,
CDS_COUNTRY_CODE_LEN) == 0) {
qdf_mem_copy(mac->scan.countryCode11d,
mac->scan.countryCodeCurrent,
reg_cc,
CDS_COUNTRY_CODE_LEN);
goto free_ie;
}

View file

@ -337,8 +337,7 @@ uint32_t csr_translate_to_wni_cfg_dot11_mode(struct mac_context *mac,
enum csr_cfgdot11mode csrDot11Mode);
void csr_save_channel_power_for_band(struct mac_context *mac, bool fPopulate5GBand);
void csr_apply_channel_power_info_to_fw(struct mac_context *mac,
struct csr_channel *pChannelList,
uint8_t *countryCode);
struct csr_channel *pChannelList);
void csr_apply_power2_current(struct mac_context *mac);
/* return a bool to indicate whether roaming completed or continue. */