diff --git a/core/cds/inc/cds_reg_service.h b/core/cds/inc/cds_reg_service.h index 02a6965c5c..d69c877d1a 100644 --- a/core/cds/inc/cds_reg_service.h +++ b/core/cds/inc/cds_reg_service.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -206,10 +206,6 @@ typedef struct { tPowerdBm pwrLimit; } sRegulatoryChannel; -typedef struct { - sRegulatoryChannel channels[NUM_RF_CHANNELS]; -} sRegulatoryDomain; - typedef struct { uint16_t targetFreq; uint16_t channelNum; @@ -220,6 +216,27 @@ typedef struct { tPowerdBm pwr; } tChannelListWithPower; +typedef enum { + COUNTRY_CODE_SET_BY_CORE, + COUNTRY_CODE_SET_BY_DRIVER, + COUNTRY_CODE_SET_BY_USER +} COUNTRY_CODE_SOURCE; + + +struct regulatory { + uint32_t reg_domain; + uint32_t eeprom_rd_ext; + uint16_t country_code; + uint8_t alpha2[3]; + uint8_t def_country[3]; + uint8_t dfs_region; + uint8_t ctl_2g; + uint8_t ctl_5g; + const void *regpair; + COUNTRY_CODE_SOURCE cc_src; + uint32_t reg_flags; +}; + typedef enum { COUNTRY_INIT, COUNTRY_IE, @@ -255,11 +272,6 @@ enum channel_width { */ typedef uint8_t country_code_t[CDS_COUNTRY_CODE_LEN + 1]; -typedef struct { - sRegulatoryDomain regDomains[REGDOMAIN_COUNT]; - country_code_t default_country; -} t_reg_table; - CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *pRegDomain, const country_code_t countryCode, @@ -278,6 +290,15 @@ CDF_STATUS cds_set_reg_domain(void *clientCtxt, v_REGDOMAIN_t regId); CHANNEL_STATE cds_get_channel_state(uint32_t rfChannel); +CDF_STATUS cds_regulatory_init(void); +CDF_STATUS cds_get_dfs_region(uint8_t *dfs_region); +CDF_STATUS cds_set_dfs_region(uint8_t dfs_region); +bool cds_is_dsrc_channel(uint16_t); +CHANNEL_STATE cds_get_bonded_channel_state(uint32_t chan_num, + enum channel_width ch_width); +enum channel_width cds_get_max_channel_bw(uint32_t chan_num); + + #define CDS_IS_DFS_CH(channel) (cds_get_channel_state((channel)) == \ CHANNEL_STATE_DFS) @@ -299,12 +320,4 @@ CHANNEL_STATE cds_get_channel_state(uint32_t rfChannel); (ch1 && ch2 && \ (CDS_IS_CHANNEL_5GHZ(ch1) == CDS_IS_CHANNEL_5GHZ(ch2))) -CDF_STATUS cds_regulatory_init(void); -CDF_STATUS cds_get_dfs_region(uint8_t *dfs_region); -CDF_STATUS cds_set_dfs_region(uint8_t dfs_region); -bool cds_is_dsrc_channel(uint16_t); -CHANNEL_STATE cds_get_bonded_channel_state(uint32_t chan_num, - enum channel_width ch_width); -enum channel_width cds_get_max_channel_bw(uint32_t chan_num); - #endif /* __CDS_REG_SERVICE_H */ diff --git a/core/cds/inc/cds_regdomain.h b/core/cds/inc/cds_regdomain.h index 28a2290402..7f40344e46 100644 --- a/core/cds/inc/cds_regdomain.h +++ b/core/cds/inc/cds_regdomain.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014 The Linux Foundation. All rights reserved. + * Copyright (c) 2011, 2014-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -301,24 +301,6 @@ typedef struct { uint8_t pwrlvl; } COMMON_MODE_POWER; -typedef enum { - COUNTRY_CODE_SET_BY_CORE, - COUNTRY_CODE_SET_BY_DRIVER, - COUNTRY_CODE_SET_BY_USER -} COUNTRY_CODE_SOURCE; - -struct regulatory { - uint32_t reg_domain; - uint32_t eeprom_rd_ext; - uint16_t country_code; - uint8_t alpha2[3]; - uint8_t dfs_region; - uint8_t ctl_2g; - uint8_t ctl_5g; - const void *regpair; - COUNTRY_CODE_SOURCE cc_src; - uint32_t reg_flags; -}; /* Multi-Device RegDomain Support */ typedef struct ath_hal_reg_dmn_tables { /* regDomainPairs: Map of 8-bit regdomain values to unitary reg domain */ diff --git a/core/cds/src/cds_reg_service.c b/core/cds/src/cds_reg_service.c index 0e0b10ee5c..ddbec514f1 100644 --- a/core/cds/src/cds_reg_service.c +++ b/core/cds/src/cds_reg_service.c @@ -49,20 +49,13 @@ #define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)) -#define IEEE80211_CHAN_NO_20MHZ (1<<11) -#define IEEE80211_CHAN_NO_10MHZ (1<<12) -#endif - -static v_REGDOMAIN_t temp_reg_domain = REGDOMAIN_COUNT; - /* true if init happens thru init time driver hint */ static bool init_by_driver = false; /* true if init happens thru init time callback from regulatory core. this should be set to true during driver reload */ static bool init_by_reg_core = false; -#define REG_WAIT_TIME 50 +#define REG_WAIT_TIME 50 #define REG_RULE_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0) @@ -70,7 +63,7 @@ static bool init_by_reg_core = false; NL80211_RRF_PASSIVE_SCAN) #define REG_RULE_2484 REG_RULE(2484-10, 2484+10, 40, 0, 20, \ - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM) + NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM) #define REG_RULE_5180_5320 REG_RULE(5180-10, 5320+10, 80, 0, 20, \ NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS) @@ -138,161 +131,6 @@ static const struct ieee80211_regdomain cds_world_regdom_67_68_6A_6C = { } }; -typedef struct { - uint8_t regDomain; - country_code_t countryCode; -} CountryInfo_t; - -typedef struct { - uint16_t countryCount; - CountryInfo_t countryInfo[MAX_COUNTRY_COUNT]; -} CountryInfoTable_t; - -static CountryInfoTable_t country_info_table = { - /* the first entry in the table is always the world domain */ - 138, - { - {REGDOMAIN_WORLD, {'0', '0'}}, /* WORLD DOMAIN */ - {REGDOMAIN_FCC, {'A', 'D'}}, /* ANDORRA */ - {REGDOMAIN_ETSI, {'A', 'E'}}, /* UAE */ - {REGDOMAIN_ETSI, {'A', 'L'}}, /* ALBANIA */ - {REGDOMAIN_ETSI, {'A', 'M'}}, /* ARMENIA */ - {REGDOMAIN_ETSI, {'A', 'N'}}, /* NETHERLANDS ANTILLES */ - {REGDOMAIN_FCC, {'A', 'R'}}, /* ARGENTINA */ - {REGDOMAIN_FCC, {'A', 'S'}}, /* AMERICAN SOMOA */ - {REGDOMAIN_ETSI, {'A', 'T'}}, /* AUSTRIA */ - {REGDOMAIN_FCC, {'A', 'U'}}, /* AUSTRALIA */ - {REGDOMAIN_ETSI, {'A', 'W'}}, /* ARUBA */ - {REGDOMAIN_ETSI, {'A', 'Z'}}, /* AZERBAIJAN */ - {REGDOMAIN_ETSI, {'B', 'A'}}, /* BOSNIA AND HERZEGOVINA */ - {REGDOMAIN_FCC, {'B', 'B'}}, /* BARBADOS */ - {REGDOMAIN_ETSI, {'B', 'D'}}, /* BANGLADESH */ - {REGDOMAIN_ETSI, {'B', 'E'}}, /* BELGIUM */ - {REGDOMAIN_ETSI, {'B', 'G'}}, /* BULGARIA */ - {REGDOMAIN_ETSI, {'B', 'H'}}, /* BAHRAIN */ - {REGDOMAIN_ETSI, {'B', 'L'}}, /* */ - {REGDOMAIN_FCC, {'B', 'M'}}, /* BERMUDA */ - {REGDOMAIN_ETSI, {'B', 'N'}}, /* BRUNEI DARUSSALAM */ - {REGDOMAIN_ETSI, {'B', 'O'}}, /* BOLIVIA */ - {REGDOMAIN_ETSI, {'B', 'R'}}, /* BRAZIL */ - {REGDOMAIN_FCC, {'B', 'S'}}, /* BAHAMAS */ - {REGDOMAIN_ETSI, {'B', 'Y'}}, /* BELARUS */ - {REGDOMAIN_ETSI, {'B', 'Z'}}, /* BELIZE */ - {REGDOMAIN_FCC, {'C', 'A'}}, /* CANADA */ - {REGDOMAIN_ETSI, {'C', 'H'}}, /* SWITZERLAND */ - {REGDOMAIN_ETSI, {'C', 'L'}}, /* CHILE */ - {REGDOMAIN_FCC, {'C', 'N'}}, /* CHINA */ - {REGDOMAIN_FCC, {'C', 'O'}}, /* COLOMBIA */ - {REGDOMAIN_ETSI, {'C', 'R'}}, /* COSTA RICA */ - {REGDOMAIN_ETSI, {'C', 'S'}}, - {REGDOMAIN_ETSI, {'C', 'Y'}}, /* CYPRUS */ - {REGDOMAIN_ETSI, {'C', 'Z'}}, /* CZECH REPUBLIC */ - {REGDOMAIN_ETSI, {'D', 'E'}}, /* GERMANY */ - {REGDOMAIN_ETSI, {'D', 'K'}}, /* DENMARK */ - {REGDOMAIN_FCC, {'D', 'O'}}, /* DOMINICAN REPUBLIC */ - {REGDOMAIN_ETSI, {'D', 'Z'}}, /* ALGERIA */ - {REGDOMAIN_ETSI, {'E', 'C'}}, /* ECUADOR */ - {REGDOMAIN_ETSI, {'E', 'E'}}, /* ESTONIA */ - {REGDOMAIN_ETSI, {'E', 'G'}}, /* EGYPT */ - {REGDOMAIN_ETSI, {'E', 'S'}}, /* SPAIN */ - {REGDOMAIN_ETSI, {'F', 'I'}}, /* FINLAND */ - {REGDOMAIN_ETSI, {'F', 'R'}}, /* FRANCE */ - {REGDOMAIN_ETSI, {'G', 'B'}}, /* UNITED KINGDOM */ - {REGDOMAIN_FCC, {'G', 'D'}}, /* GRENADA */ - {REGDOMAIN_ETSI, {'G', 'E'}}, /* GEORGIA */ - {REGDOMAIN_ETSI, {'G', 'F'}}, /* FRENCH GUIANA */ - {REGDOMAIN_ETSI, {'G', 'L'}}, /* GREENLAND */ - {REGDOMAIN_ETSI, {'G', 'P'}}, /* GUADELOUPE */ - {REGDOMAIN_ETSI, {'G', 'R'}}, /* GREECE */ - {REGDOMAIN_FCC, {'G', 'T'}}, /* GUATEMALA */ - {REGDOMAIN_FCC, {'G', 'U'}}, /* GUAM */ - {REGDOMAIN_ETSI, {'H', 'U'}}, /* HUNGARY */ - {REGDOMAIN_FCC, {'I', 'D'}}, /* INDONESIA */ - {REGDOMAIN_ETSI, {'I', 'E'}}, /* IRELAND */ - {REGDOMAIN_ETSI, {'I', 'L'}}, /* ISRAEL */ - {REGDOMAIN_ETSI, {'I', 'N'}}, /* INDIA */ - {REGDOMAIN_ETSI, {'I', 'R'}}, /* IRAN, ISLAMIC REPUBLIC OF */ - {REGDOMAIN_ETSI, {'I', 'S'}}, /* ICELNAD */ - {REGDOMAIN_ETSI, {'I', 'T'}}, /* ITALY */ - {REGDOMAIN_FCC, {'J', 'M'}}, /* JAMAICA */ - {REGDOMAIN_JAPAN, {'J', 'P'}}, /* JAPAN */ - {REGDOMAIN_ETSI, {'J', 'O'}}, /* JORDAN */ - {REGDOMAIN_ETSI, {'K', 'E'}}, /* KENYA */ - {REGDOMAIN_ETSI, {'K', 'H'}}, /* CAMBODIA */ - {REGDOMAIN_ETSI, {'K', 'P'}}, /* KOREA, DEMOCRATIC PEOPLE's REPUBLIC OF */ - {REGDOMAIN_ETSI, {'K', 'R'}}, /* KOREA, REPUBLIC OF */ - {REGDOMAIN_ETSI, {'K', 'W'}}, /* KUWAIT */ - {REGDOMAIN_ETSI, {'K', 'Z'}}, /* KAZAKHSTAN */ - {REGDOMAIN_ETSI, {'L', 'B'}}, /* LEBANON */ - {REGDOMAIN_ETSI, {'L', 'I'}}, /* LIECHTENSTEIN */ - {REGDOMAIN_ETSI, {'L', 'K'}}, /* SRI-LANKA */ - {REGDOMAIN_ETSI, {'L', 'T'}}, /* LITHUANIA */ - {REGDOMAIN_ETSI, {'L', 'U'}}, /* LUXEMBOURG */ - {REGDOMAIN_ETSI, {'L', 'V'}}, /* LATVIA */ - {REGDOMAIN_ETSI, {'M', 'A'}}, /* MOROCCO */ - {REGDOMAIN_ETSI, {'M', 'C'}}, /* MONACO */ - {REGDOMAIN_ETSI, {'M', 'K'}}, /* MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF */ - {REGDOMAIN_FCC, {'M', 'N'}}, /* MONGOLIA */ - {REGDOMAIN_FCC, {'M', 'O'}}, /* MACAO */ - {REGDOMAIN_FCC, {'M', 'P'}}, /* NORTHERN MARIANA ISLANDS */ - {REGDOMAIN_ETSI, {'M', 'Q'}}, /* MARTINIQUE */ - {REGDOMAIN_FCC, {'M', 'T'}}, /* MALTA */ - {REGDOMAIN_ETSI, {'M', 'U'}}, /* MAURITIUS */ - {REGDOMAIN_ETSI, {'M', 'W'}}, /* MALAWI */ - {REGDOMAIN_FCC, {'M', 'X'}}, /* MEXICO */ - {REGDOMAIN_ETSI, {'M', 'Y'}}, /* MALAYSIA */ - {REGDOMAIN_ETSI, {'N', 'G'}}, /* NIGERIA */ - {REGDOMAIN_FCC, {'N', 'I'}}, /* NICARAGUA */ - {REGDOMAIN_ETSI, {'N', 'L'}}, /* NETHERLANDS */ - {REGDOMAIN_ETSI, {'N', 'O'}}, /* NORWAY */ - {REGDOMAIN_ETSI, {'N', 'P'}}, /* NEPAL */ - {REGDOMAIN_FCC, {'N', 'Z'}}, /* NEW-ZEALAND */ - {REGDOMAIN_FCC, {'O', 'M'}}, /* OMAN */ - {REGDOMAIN_FCC, {'P', 'A'}}, /* PANAMA */ - {REGDOMAIN_ETSI, {'P', 'E'}}, /* PERU */ - {REGDOMAIN_ETSI, {'P', 'F'}}, /* FRENCH POLYNESIA */ - {REGDOMAIN_ETSI, {'P', 'G'}}, /* PAPUA NEW GUINEA */ - {REGDOMAIN_FCC, {'P', 'H'}}, /* PHILIPPINES */ - {REGDOMAIN_ETSI, {'P', 'K'}}, /* PAKISTAN */ - {REGDOMAIN_ETSI, {'P', 'L'}}, /* POLAND */ - {REGDOMAIN_FCC, {'P', 'R'}}, /* PUERTO RICO */ - {REGDOMAIN_FCC, {'P', 'S'}}, /* PALESTINIAN TERRITORY, OCCUPIED */ - {REGDOMAIN_ETSI, {'P', 'T'}}, /* PORTUGAL */ - {REGDOMAIN_FCC, {'P', 'Y'}}, /* PARAGUAY */ - {REGDOMAIN_ETSI, {'Q', 'A'}}, /* QATAR */ - {REGDOMAIN_ETSI, {'R', 'E'}}, /* REUNION */ - {REGDOMAIN_ETSI, {'R', 'O'}}, /* ROMAINIA */ - {REGDOMAIN_ETSI, {'R', 'S'}}, /* SERBIA */ - {REGDOMAIN_ETSI, {'R', 'U'}}, /* RUSSIA */ - {REGDOMAIN_FCC, {'R', 'W'}}, /* RWANDA */ - {REGDOMAIN_ETSI, {'S', 'A'}}, /* SAUDI ARABIA */ - {REGDOMAIN_ETSI, {'S', 'E'}}, /* SWEDEN */ - {REGDOMAIN_ETSI, {'S', 'G'}}, /* SINGAPORE */ - {REGDOMAIN_ETSI, {'S', 'I'}}, /* SLOVENNIA */ - {REGDOMAIN_ETSI, {'S', 'K'}}, /* SLOVAKIA */ - {REGDOMAIN_ETSI, {'S', 'V'}}, /* EL SALVADOR */ - {REGDOMAIN_ETSI, {'S', 'Y'}}, /* SYRIAN ARAB REPUBLIC */ - {REGDOMAIN_ETSI, {'T', 'H'}}, /* THAILAND */ - {REGDOMAIN_ETSI, {'T', 'N'}}, /* TUNISIA */ - {REGDOMAIN_ETSI, {'T', 'R'}}, /* TURKEY */ - {REGDOMAIN_ETSI, {'T', 'T'}}, /* TRINIDAD AND TOBAGO */ - {REGDOMAIN_FCC, {'T', 'W'}}, /* TAIWAN, PRIVINCE OF CHINA */ - {REGDOMAIN_FCC, {'T', 'Z'}}, /* TANZANIA, UNITED REPUBLIC OF */ - {REGDOMAIN_ETSI, {'U', 'A'}}, /* UKRAINE */ - {REGDOMAIN_ETSI, {'U', 'G'}}, /* UGANDA */ - {REGDOMAIN_FCC, {'U', 'S'}}, /* USA */ - {REGDOMAIN_ETSI, {'U', 'Y'}}, /* URUGUAY */ - {REGDOMAIN_FCC, {'U', 'Z'}}, /* UZBEKISTAN */ - {REGDOMAIN_ETSI, {'V', 'E'}}, /* VENEZUELA */ - {REGDOMAIN_FCC, {'V', 'I'}}, /* VIRGIN ISLANDS, US */ - {REGDOMAIN_ETSI, {'V', 'N'}}, /* VIETNAM */ - {REGDOMAIN_ETSI, {'Y', 'E'}}, /* YEMEN */ - {REGDOMAIN_ETSI, {'Y', 'T'}}, /* MAYOTTE */ - {REGDOMAIN_ETSI, {'Z', 'A'}}, /* SOUTH AFRICA */ - {REGDOMAIN_ETSI, {'Z', 'W'}}, /* ZIMBABWE */ - } -}; - const tRfChannelProps rf_channels[NUM_RF_CHANNELS] = { {2412, 1}, {2417, 2}, @@ -390,14 +228,10 @@ const tRfChannelProps rf_channels[NUM_RF_CHANNELS] = { {5755, 151}, {5775, 155}, {5795, 159}, - {5815, 163, }, + {5815, 163}, }; -static t_reg_table reg_table; - -const sRegulatoryChannel *reg_channels = - reg_table.regDomains[0].channels; - +sRegulatoryChannel reg_channels[NUM_RF_CHANNELS]; /** * cds_is_wwr_sku() - is regdomain world sku @@ -616,17 +450,25 @@ CDF_STATUS cds_get_channel_list_with_power(tChannelListWithPower * */ CDF_STATUS cds_read_default_country(country_code_t default_country) { - CDF_STATUS status = CDF_STATUS_SUCCESS; + hdd_context_t *hdd_ctx; + + hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); + if (!hdd_ctx) { + CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, + "invalid hdd_ctx pointer"); + return CDF_STATUS_E_FAULT; + } memcpy(default_country, - reg_table.default_country, + hdd_ctx->reg.def_country, sizeof(country_code_t)); - pr_info("DefaultCountry is %c%c\n", - default_country[0], - default_country[1]); + CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_INFO, + "default country is %c%c\n", + default_country[0], + default_country[1]); - return status; + return CDF_STATUS_SUCCESS; } /** @@ -791,31 +633,31 @@ static int cds_bw20_ch_index_to_bw40_ch_index(int k) */ CDF_STATUS cds_set_dfs_region(uint8_t dfs_region) { - hdd_context_t *hdd_ctx_ptr = NULL; + hdd_context_t *hdd_ctx; - hdd_ctx_ptr = cds_get_context(CDF_MODULE_ID_HDD); + hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); - if (NULL == hdd_ctx_ptr) + if (NULL == hdd_ctx) return CDF_STATUS_E_EXISTS; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS) - hdd_ctx_ptr->reg.dfs_region = dfs_region; + hdd_ctx->reg.dfs_region = dfs_region; #else /* remap the ctl code to dfs region code */ - switch (hdd_ctx_ptr->reg.ctl_5g) { + switch (hdd_ctx->reg.ctl_5g) { case FCC: - hdd_ctx_ptr->reg.dfs_region = DFS_FCC_DOMAIN; + hdd_ctx->reg.dfs_region = DFS_FCC_DOMAIN; break; case ETSI: - hdd_ctx_ptr->reg.dfs_region = DFS_ETSI_DOMAIN; + hdd_ctx->reg.dfs_region = DFS_ETSI_DOMAIN; break; case MKK: - hdd_ctx_ptr->reg.dfs_region = DFS_MKK4_DOMAIN; + hdd_ctx->reg.dfs_region = DFS_MKK4_DOMAIN; break; default: /* set default dfs_region to FCC */ - hdd_ctx_ptr->reg.dfs_region = DFS_FCC_DOMAIN; + hdd_ctx->reg.dfs_region = DFS_FCC_DOMAIN; break; } #endif @@ -831,14 +673,14 @@ CDF_STATUS cds_set_dfs_region(uint8_t dfs_region) */ CDF_STATUS cds_get_dfs_region(uint8_t *dfs_region) { - hdd_context_t *hdd_ctx_ptr = NULL; + hdd_context_t *hdd_ctx; - hdd_ctx_ptr = cds_get_context(CDF_MODULE_ID_HDD); + hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); - if (NULL == hdd_ctx_ptr) + if (NULL == hdd_ctx) return CDF_STATUS_E_EXISTS; - *dfs_region = hdd_ctx_ptr->reg.dfs_region; + *dfs_region = hdd_ctx->reg.dfs_region; return CDF_STATUS_SUCCESS; } @@ -856,10 +698,8 @@ CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, country_code, v_CountryInfoSource_t source) { - v_CONTEXT_t cds_context = NULL; hdd_context_t *hdd_ctx = NULL; struct wiphy *wiphy = NULL; - int i; if (NULL == reg_domain_ptr) { CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, @@ -867,7 +707,10 @@ CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, return CDF_STATUS_E_FAULT; } - *reg_domain_ptr = REGDOMAIN_COUNT; + *reg_domain_ptr = 0; + + if (COUNTRY_QUERY == source) + return CDF_STATUS_SUCCESS; if (NULL == country_code) { CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, @@ -875,18 +718,13 @@ CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, return CDF_STATUS_E_FAULT; } - if (0 == country_info_table.countryCount) { + if (cds_is_driver_recovering()) { CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, - ("Reg domain table is empty")); - return CDF_STATUS_E_EMPTY; + "SSR in progress, return"); + return CDF_STATUS_SUCCESS; } - cds_context = cds_get_global_context(); - - if (NULL != cds_context) - hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); - else - return CDF_STATUS_E_EXISTS; + hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); if (NULL == hdd_ctx) { CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, @@ -896,37 +734,6 @@ CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, wiphy = hdd_ctx->wiphy; - if (cds_is_driver_recovering()) { - CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, - "SSR in progress, return"); - *reg_domain_ptr = temp_reg_domain; - return CDF_STATUS_SUCCESS; - } - - temp_reg_domain = REGDOMAIN_COUNT; - for (i = 0; i < country_info_table.countryCount && - REGDOMAIN_COUNT == temp_reg_domain; i++) { - if (memcmp(country_code, - country_info_table.countryInfo[i].countryCode, - CDS_COUNTRY_CODE_LEN) == 0) { - - temp_reg_domain = - country_info_table.countryInfo[i].regDomain; - break; - } - } - - if (REGDOMAIN_COUNT == temp_reg_domain) { - CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, - ("Country does not map to any Regulatory domain")); - temp_reg_domain = REGDOMAIN_WORLD; - } - - if (COUNTRY_QUERY == source) { - *reg_domain_ptr = temp_reg_domain; - return CDF_STATUS_SUCCESS; - } - if ((COUNTRY_INIT == source) && (false == init_by_reg_core)) { init_by_driver = true; if (('0' != country_code[0]) || ('0' != country_code[1])) { @@ -940,7 +747,6 @@ CDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr, NL80211_USER_REG_HINT_USER); } - *reg_domain_ptr = temp_reg_domain; return CDF_STATUS_SUCCESS; } @@ -981,7 +787,8 @@ bool cds_is_dsrc_channel(uint16_t center_freq) * Return: int */ static int cds_process_regulatory_data(struct wiphy *wiphy, - uint8_t band_capability, bool reset) + uint8_t band_capability, + bool reset) { int i, j, m; int k = 0, n = 0; @@ -1028,13 +835,8 @@ static int cds_process_regulatory_data(struct wiphy *wiphy, n = cds_bw20_ch_index_to_bw40_ch_index(k); chan = &(wiphy->bands[i]->channels[j]); - temp_chan_k = - &(reg_table.regDomains[temp_reg_domain]. - channels[k]); - - temp_chan_n = - &(reg_table.regDomains[temp_reg_domain]. - channels[n]); + temp_chan_k = &(reg_channels[k]); + temp_chan_n = &(reg_channels[n]); if ((!reset) && #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS) @@ -1173,8 +975,7 @@ static int cds_process_regulatory_data(struct wiphy *wiphy, if (0 == (hdd_ctx->reg.eeprom_rd_ext & (1 << WHAL_REG_EXT_FCC_CH_144))) { - temp_chan = &(reg_table.regDomains[temp_reg_domain]. - channels[RF_CHAN_144]); + temp_chan = &(reg_channels[RF_CHAN_144]); temp_chan->enabled = CHANNEL_STATE_DISABLE; } @@ -1225,8 +1026,6 @@ void __hdd_reg_notifier(struct wiphy *wiphy, { hdd_context_t *hdd_ctx = wiphy_priv(wiphy); eCsrBand band_capability = eCSR_BAND_ALL; - country_code_t country_code; - int i; bool vht80_allowed; bool reset = false; @@ -1288,9 +1087,9 @@ void __hdd_reg_notifier(struct wiphy *wiphy, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS) if (wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) #else - if (wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) + if (wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) #endif - reset = true; + reset = true; } else if (NL80211_REGDOM_SET_BY_DRIVER == request->initiator) hdd_ctx->reg.cc_src = COUNTRY_CODE_SET_BY_DRIVER; else { @@ -1305,31 +1104,11 @@ void __hdd_reg_notifier(struct wiphy *wiphy, #endif } - /* first lookup the country in the local database */ - country_code[0] = request->alpha2[0]; - country_code[1] = request->alpha2[1]; - hdd_ctx->reg.alpha2[0] = request->alpha2[0]; hdd_ctx->reg.alpha2[1] = request->alpha2[1]; cds_update_regulatory_info(hdd_ctx); - temp_reg_domain = REGDOMAIN_COUNT; - for (i = 0; i < country_info_table.countryCount && - REGDOMAIN_COUNT == temp_reg_domain; i++) { - if (memcmp(country_code, - country_info_table.countryInfo[i].countryCode, - CDS_COUNTRY_CODE_LEN) == 0) { - - temp_reg_domain = - country_info_table.countryInfo[i].regDomain; - break; - } - } - - if (REGDOMAIN_COUNT == temp_reg_domain) - temp_reg_domain = REGDOMAIN_WORLD; - vht80_allowed = hdd_ctx->isVHT80Allowed; if (cds_process_regulatory_data(wiphy, band_capability, reset) == 0) { @@ -1342,16 +1121,8 @@ void __hdd_reg_notifier(struct wiphy *wiphy, if (NL80211_REGDOM_SET_BY_DRIVER == request->initiator) complete(&hdd_ctx->reg_init); - if (request->alpha2[0] == '0' - && request->alpha2[1] == '0') { - sme_generic_change_country_code(hdd_ctx->hHal, - country_code, - REGDOMAIN_COUNT); - } else { - sme_generic_change_country_code(hdd_ctx->hHal, - country_code, - temp_reg_domain); - } + sme_generic_change_country_code(hdd_ctx->hHal, + hdd_ctx->reg.alpha2); cds_fill_and_send_ctl_to_fw(&hdd_ctx->reg); @@ -1386,21 +1157,15 @@ void hdd_reg_notifier(struct wiphy *wiphy, */ CDF_STATUS cds_regulatory_init(void) { - v_CONTEXT_t cds_context = NULL; hdd_context_t *hdd_ctx = NULL; struct wiphy *wiphy = NULL; int ret_val = 0; struct regulatory *reg_info; - cds_context = cds_get_global_context(); - - if (!cds_context) - return CDF_STATUS_E_FAULT; - hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); if (!hdd_ctx) { CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_ERROR, - ("Invalid pHddCtx pointer")); + "invalid hdd_ctx pointer"); return CDF_STATUS_E_FAULT; } @@ -1410,8 +1175,6 @@ CDF_STATUS cds_regulatory_init(void) cds_regulatory_wiphy_init(hdd_ctx, reg_info, wiphy); - temp_reg_domain = REGDOMAIN_WORLD; - if (cds_process_regulatory_data(wiphy, hdd_ctx->config-> nBandCapability, true) != 0) { @@ -1428,8 +1191,8 @@ CDF_STATUS cds_regulatory_init(void) return ret_val; } - reg_table.default_country[0] = reg_info->alpha2[0]; - reg_table.default_country[1] = reg_info->alpha2[1]; + hdd_ctx->reg.def_country[0] = reg_info->alpha2[0]; + hdd_ctx->reg.def_country[1] = reg_info->alpha2[1]; init_completion(&hdd_ctx->reg_init); @@ -1454,8 +1217,6 @@ CDF_STATUS cds_set_reg_domain(void *client_ctxt, v_REGDOMAIN_t reg_domain) return CDF_STATUS_E_INVAL; } - reg_channels = reg_table.regDomains[reg_domain].channels; - return CDF_STATUS_SUCCESS; } diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 7118f800ed..93c71024a2 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -1823,11 +1823,9 @@ struct ani_roc_req { /* generic country code change request MSG structure */ typedef struct sAniGenericChangeCountryCodeReq { - /* Common for all types are requests */ uint16_t msgType; /* message type is same as the request type */ uint16_t msgLen; /* length of the entire request */ uint8_t countryCode[WNI_CFG_COUNTRY_CODE_LEN]; /* 3 char country code */ - uint16_t domain_index; } tAniGenericChangeCountryCodeReq, *tpAniGenericChangeCountryCodeReq; /** diff --git a/core/sap/src/sap_internal.h b/core/sap/src/sap_internal.h index 1e88ffccf5..3ba7b0a410 100644 --- a/core/sap/src/sap_internal.h +++ b/core/sap/src/sap_internal.h @@ -76,7 +76,7 @@ extern "C" { #define SAP_CHAN_PREFERRED_INDOOR 1 #define SAP_CHAN_PREFERRED_OUTDOOR 2 -extern const sRegulatoryChannel *reg_channels; +extern const sRegulatoryChannel reg_channels[NUM_RF_CHANNELS]; /*---------------------------------------------------------------------------- * Typedefs diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 7cc219d01c..7b69bbeaf2 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -404,9 +404,7 @@ CDF_STATUS sme_change_country_code(tHalHandle hHal, tAniBool countryFromUserSpace, tAniBool sendRegHint); CDF_STATUS sme_generic_change_country_code(tHalHandle hHal, - uint8_t *pCountry, - v_REGDOMAIN_t reg_domain); - + uint8_t *pCountry); CDF_STATUS sme_dhcp_start_ind(tHalHandle hHal, uint8_t device_mode, uint8_t *macAddr, uint8_t sessionId); diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index b61de77347..41d15b960a 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -5042,8 +5042,7 @@ CDF_STATUS sme_change_country_code(tHalHandle hHal, -----------------------------------------------------------------------------*/ CDF_STATUS sme_generic_change_country_code(tHalHandle hHal, - uint8_t *pCountry, - v_REGDOMAIN_t reg_domain) + uint8_t *pCountry) { CDF_STATUS status = CDF_STATUS_E_FAILURE; tpAniSirGlobal pMac = PMAC_STRUCT(hHal); @@ -5072,8 +5071,7 @@ CDF_STATUS sme_generic_change_country_code(tHalHandle hHal, pMsg->msgLen = (uint16_t) sizeof(tAniGenericChangeCountryCodeReq); cdf_mem_copy(pMsg->countryCode, pCountry, 2); - pMsg->domain_index = reg_domain; - pMsg->countryCode[2] = ' '; /* For ASCII space */ + pMsg->countryCode[2] = ' '; msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE; msg.bodyptr = pMsg; @@ -7051,7 +7049,7 @@ CDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf) } /** - * sme_handle_change_country_code_by_user() - handles country ch req + * sme_handle_generic_change_country_code() - handles country ch req * @mac_ctx: mac global context * @msg: request msg packet * @@ -7063,17 +7061,18 @@ CDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf) * Return: status of operation */ CDF_STATUS -sme_handle_change_country_code_by_user(tpAniSirGlobal mac_ctx, - tAniGenericChangeCountryCodeReq *msg) +sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx, + void *pMsgBuf) { CDF_STATUS status = CDF_STATUS_SUCCESS; - v_REGDOMAIN_t reg_domain_id; + v_REGDOMAIN_t reg_domain_id = 0; bool is_11d_country = false; bool supplicant_priority = mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority; + tAniGenericChangeCountryCodeReq *msg = pMsgBuf; sms_log(mac_ctx, LOG1, FL(" called")); - reg_domain_id = (v_REGDOMAIN_t) msg->domain_index; + if (memcmp(msg->countryCode, mac_ctx->scan.countryCode11d, CDS_COUNTRY_CODE_LEN) == 0) { is_11d_country = true; @@ -7106,6 +7105,7 @@ sme_handle_change_country_code_by_user(tpAniSirGlobal mac_ctx, return CDF_STATUS_E_FAILURE; } + /* if Supplicant country code has priority, disable 11d */ if (!is_11d_country && supplicant_priority) mac_ctx->roam.configParam.Is11dSupportEnabled = false; @@ -7162,64 +7162,6 @@ sme_handle_change_country_code_by_user(tpAniSirGlobal mac_ctx, return CDF_STATUS_SUCCESS; } -/* --------------------------------------------------------------------------- - - \fn sme_handle_change_country_code_by_core - - \brief Update Country code in the driver if set by kernel as world - - If 11D is enabled, we update the country code after every scan & notify kernel. - This is to make sure kernel & driver are in sync in case of CC found in - driver but not in kernel database - - \param pMac - The handle returned by mac_open. - \param pMsg - Carrying new CC set in kernel - - \return CDF_STATUS - - -------------------------------------------------------------------------------*/ -CDF_STATUS sme_handle_change_country_code_by_core(tpAniSirGlobal pMac, - tAniGenericChangeCountryCodeReq * - pMsg) -{ - CDF_STATUS status; - - sms_log(pMac, LOG1, FL(" called")); - - /* this is to make sure kernel & driver are in sync in case of CC found in */ - /* driver but not in kernel database */ - if (('0' == pMsg->countryCode[0]) && ('0' == pMsg->countryCode[1])) { - sms_log(pMac, LOGW, - FL - ("Setting countryCode11d & countryCodeCurrent to world CC")); - cdf_mem_copy(pMac->scan.countryCode11d, pMsg->countryCode, - WNI_CFG_COUNTRY_CODE_LEN); - cdf_mem_copy(pMac->scan.countryCodeCurrent, pMsg->countryCode, - WNI_CFG_COUNTRY_CODE_LEN); - } - - status = wma_set_reg_domain(pMac, REGDOMAIN_WORLD); - - if (status != CDF_STATUS_SUCCESS) { - sms_log(pMac, LOGE, FL(" fail to set regId")); - return status; - } else { - status = csr_get_channel_and_power_list(pMac); - if (status != CDF_STATUS_SUCCESS) { - sms_log(pMac, LOGE, FL(" fail to get Channels ")); - } else { - csr_apply_channel_and_power_list(pMac); - } - } - /* Country code Changed, Purge Only scan result - * which does not have channel number belong to 11d - * channel list - */ - csr_scan_filter_results(pMac); - sms_log(pMac, LOG1, FL(" returned")); - return CDF_STATUS_SUCCESS; -} - static bool sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch) { @@ -7273,42 +7215,6 @@ void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx) } } -/* --------------------------------------------------------------------------- - - \fn sme_handle_generic_change_country_code - - \brief Change Country code, Reg Domain and channel list - - If Supplicant country code is priority than 11d is disabled. - If 11D is enabled, we update the country code after every scan. - Hence when Supplicant country code is priority, we don't need 11D info. - Country code from kernel is set as current country code. - - \param pMac - The handle returned by mac_open. - \param pMsgBuf - message buffer - - \return CDF_STATUS - - -------------------------------------------------------------------------------*/ -CDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac, - void *pMsgBuf) -{ - tAniGenericChangeCountryCodeReq *pMsg; - v_REGDOMAIN_t reg_domain_id; - - sms_log(pMac, LOG1, FL(" called")); - pMsg = (tAniGenericChangeCountryCodeReq *) pMsgBuf; - reg_domain_id = (v_REGDOMAIN_t) pMsg->domain_index; - - if (REGDOMAIN_COUNT == reg_domain_id) { - sme_handle_change_country_code_by_core(pMac, pMsg); - } else { - sme_handle_change_country_code_by_user(pMac, pMsg); - } - sms_log(pMac, LOG1, FL(" returned")); - return CDF_STATUS_SUCCESS; -} - #ifdef WLAN_FEATURE_PACKET_FILTERING CDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId, tpSirRcvFltMcAddrList pMulticastAddrs)