diff options
| author | Srinivas Girigowda <sgirigow@qca.qualcomm.com> | 2016-03-23 15:42:31 -0700 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2016-03-24 13:35:26 +0530 |
| commit | 5f30b05b42548ed6db54bd02a66cdb883ecee05d (patch) | |
| tree | 4424984fb427f9fad136748f80eece38c58b0802 | |
| parent | 9c2bff0f35d24c063a662e7ee95a7207e2ddcd1d (diff) | |
qcacld-2.0: Add cfg.ini support to read OTP MAC address
Reading the MAC address has priorities:
1. Read the provisioned MAC from cnss platform driver (configured by OEM)
2. Read from provisioned MAC from /persist/wlan_mac.bin (configured by OEM)
3. Read the default MAC address (otp.bin)
Setting g_use_otpmac = 1 means if any of the higher priority
provisioned MAC reading fails, use the default otp MAC address.
Setting g_use_otpmac = 0 means Do not use the otp MAC address even if
higher priority provisioned MAC reading fails, instead
trigger driver load failure.
Change-Id: I645998a1467375be9c46fb20b6975e0e0056029c
CRs-Fixed: 994079
| -rw-r--r-- | CORE/HDD/inc/wlan_hdd_cfg.h | 19 | ||||
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_cfg.c | 9 | ||||
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_main.c | 25 |
3 files changed, 45 insertions, 8 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_cfg.h b/CORE/HDD/inc/wlan_hdd_cfg.h index 8c592a245b6a..b085f29c0fe2 100644 --- a/CORE/HDD/inc/wlan_hdd_cfg.h +++ b/CORE/HDD/inc/wlan_hdd_cfg.h @@ -3681,6 +3681,24 @@ enum dot11p_mode { #define CFG_OPTIMIZE_CA_EVENT_ENABLE (1) #define CFG_OPTIMIZE_CA_EVENT_DEFAULT (0) +/** + * Reading the MAC address has priorities: + * 1. Read the provisioned MAC from cnss platform driver (configured by OEM) + * 2. Read from provisioned MAC from /persist/wlan_mac.bin (configured by OEM) + * 3. Read the default MAC address (otp.bin) + * + * Setting g_use_otpmac = 1 means if any of the higher priority + * provisioned MAC reading fails, use the default otp MAC address. + * + * Setting g_use_otpmac = 0 means Do not use the otp MAC address even if + * higher priority provisioned MAC reading fails, instead + * trigger driver load failure. + */ +#define CFG_USE_OTP_MAC "g_use_otpmac" +#define CFG_USE_OTP_MAC_MIN (0) +#define CFG_USE_OTP_MAC_MAX (1) +#define CFG_USE_OTP_MAC_DEFAULT (1) + /*--------------------------------------------------------------------------- Type declarations -------------------------------------------------------------------------*/ @@ -4417,6 +4435,7 @@ struct hdd_config { uint8_t nan_datapath_ndi_channel; #endif bool goptimize_chan_avoid_event; + bool g_use_otpmac; }; typedef struct hdd_config hdd_config_t; diff --git a/CORE/HDD/src/wlan_hdd_cfg.c b/CORE/HDD/src/wlan_hdd_cfg.c index 2efdb22be5ac..d6a2c7ff1bdb 100644 --- a/CORE/HDD/src/wlan_hdd_cfg.c +++ b/CORE/HDD/src/wlan_hdd_cfg.c @@ -4423,6 +4423,13 @@ REG_TABLE_ENTRY g_registry_table[] = CFG_OPTIMIZE_CA_EVENT_DEFAULT, CFG_OPTIMIZE_CA_EVENT_DISABLE, CFG_OPTIMIZE_CA_EVENT_ENABLE ), + + REG_VARIABLE(CFG_USE_OTP_MAC, WLAN_PARAM_Integer, + hdd_config_t, g_use_otpmac, + VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, + CFG_USE_OTP_MAC_DEFAULT, + CFG_USE_OTP_MAC_MIN, + CFG_USE_OTP_MAC_MAX), }; @@ -5180,6 +5187,8 @@ void print_hdd_cfg(hdd_context_t *pHddCtx) pHddCtx->cfg_ini->min_rest_time_conc); hddLog(LOG2, "Name = [gIdleTimeConc] Value = [%u]", pHddCtx->cfg_ini->idle_time_conc); + hddLog(LOG2, "Name = [%s] Value = [%u]", + CFG_USE_OTP_MAC, pHddCtx->cfg_ini->g_use_otpmac); hdd_ndp_print_ini_config(pHddCtx); } diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c index c7ec91de01c0..a7f75d6a1556 100644 --- a/CORE/HDD/src/wlan_hdd_main.c +++ b/CORE/HDD/src/wlan_hdd_main.c @@ -14013,9 +14013,9 @@ static int hdd_cnss_wlan_mac(hdd_context_t *hdd_ctx) * provisioned with mac addresses, driver uses it, else it will use wlan_mac.bin * to update HW MAC addresses. * - * Return: None + * Return: 0 if success, errno otherwise */ -static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) +static int hdd_initialize_mac_address(hdd_context_t *hdd_ctx) { VOS_STATUS status; int ret; @@ -14023,15 +14023,18 @@ static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) ret = hdd_cnss_wlan_mac(hdd_ctx); if (ret == 0) - return; + return ret; - hddLog(LOGW, FL("Can't update mac config via platform driver ret:%d"), - ret); + hddLog(LOGW, FL("Can't update MAC via platform driver ret: %d"), ret); status = hdd_update_mac_config(hdd_ctx); - if (status != VOS_STATUS_SUCCESS) + if (status != VOS_STATUS_SUCCESS) { hddLog(LOGW, - FL("can't update mac config, using MAC from ini file")); + FL("Failed to update MAC from %s status: %d"), + WLAN_MAC_FILE, status); + return -EIO; + } + return 0; } /**--------------------------------------------------------------------------- @@ -14443,7 +14446,13 @@ int hdd_wlan_startup(struct device *dev, v_VOID_t *hif_sc) goto err_wiphy_unregister; } - hdd_initialize_mac_address(pHddCtx); + ret = hdd_initialize_mac_address(pHddCtx); + if (!pHddCtx->cfg_ini->g_use_otpmac && ret) { + hddLog(LOGE, + FL("Failed to read MAC from platform driver or %s (driver load failed)"), + WLAN_MAC_FILE); + goto err_wiphy_unregister; + } { eHalStatus halStatus; |
