qcacld-3.0: Cleanup legacy ini x-macro and parsing infra in HDD

Before CFG/INI convergence to the new cfg module, hdd maintained
the infrastructure to parse ini items from WCNSS_qcom_cfg.ini and
push the value to hdd_config members. With all the cfg/ini moved
to the new converged CFG component, this infra is not required.

So cleanup the legacy ini infrastructure in HDD.

Change-Id: Ia028edd10682a0ac8ed6a663c20ba5f67b962f1d
CRs-Fixed: 2445314
This commit is contained in:
Pragaspathi Thilagaraj 2019-05-01 23:30:28 +05:30 committed by nshrivas
parent 4e17ae7520
commit c248c9e3ae
4 changed files with 0 additions and 500 deletions

View File

@ -212,68 +212,6 @@ struct hdd_config {
uint32_t sar_version;
};
#define VAR_OFFSET(_Struct, _Var) (offsetof(_Struct, _Var))
#define VAR_SIZE(_Struct, _Var) (sizeof(((_Struct *)0)->_Var))
#define VAR_FLAGS_NONE (0)
/* bit 0 is Required or Optional */
#define VAR_FLAGS_REQUIRED (1 << 0)
#define VAR_FLAGS_OPTIONAL (0 << 0)
/*
* bit 1 tells if range checking is required.
* If less than MIN, assume MIN.
* If greater than MAX, assume MAX.
*/
#define VAR_FLAGS_RANGE_CHECK (1 << 1)
#define VAR_FLAGS_RANGE_CHECK_ASSUME_MINMAX (VAR_FLAGS_RANGE_CHECK)
/*
* bit 2 is range checking that assumes the DEFAULT value
* If less than MIN, assume DEFAULT,
* If greater than MAX, assume DEFAULT.
*/
#define VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT (1 << 2)
enum wlan_parameter_type {
WLAN_PARAM_Integer,
WLAN_PARAM_SignedInteger,
WLAN_PARAM_HexInteger,
WLAN_PARAM_String,
WLAN_PARAM_MacAddr,
};
#define REG_VARIABLE(_Name, _Type, _Struct, _VarName, \
_Flags, _Default, _Min, _Max) \
{ \
(_Name), \
(_Type), \
(_Flags), \
0, \
VAR_OFFSET(_Struct, _VarName), \
VAR_SIZE(_Struct, _VarName), \
(_Default), \
(_Min), \
(_Max), \
NULL \
}
struct reg_table_entry {
char *RegName; /* variable name in the qcom_cfg.ini file */
unsigned char RegType; /* variable type in hdd_config struct */
unsigned char Flags; /* Specify optional parms and if RangeCheck is performed */
unsigned char notifyId; /* Dynamic modification identifier */
unsigned short VarOffset; /* offset to field from the base address of the structure */
unsigned short VarSize; /* size (in bytes) of the field */
unsigned long VarDefault; /* default value to use */
unsigned long VarMin; /* minimum value, for range checking */
unsigned long VarMax; /* maximum value, for range checking */
/* Dynamic modification notifier */
void (*pfnDynamicnotify)(struct hdd_context *hdd_ctx,
unsigned long notifyId);
};
/**
* hdd_to_csr_wmm_mode() - Utility function to convert HDD to CSR WMM mode
*
@ -283,9 +221,6 @@ struct reg_table_entry {
*/
eCsrRoamWmmUserModeType hdd_to_csr_wmm_mode(uint8_t mode);
/* Function declarations and documenation */
QDF_STATUS hdd_parse_config_ini(struct hdd_context *hdd_ctx);
QDF_STATUS hdd_update_mac_config(struct hdd_context *hdd_ctx);
QDF_STATUS hdd_set_sme_config(struct hdd_context *hdd_ctx);
QDF_STATUS hdd_set_policy_mgr_user_cfg(struct hdd_context *hdd_ctx);

View File

@ -48,10 +48,6 @@
#include "cfg_ucfg_api.h"
#include "hdd_dp_cfg.h"
struct reg_table_entry g_registry_table[] = {
};
/**
* get_next_line() - find and locate the new line pointer
* @str: pointer to string
@ -138,53 +134,6 @@ struct hdd_cfg_entry {
char *value;
};
/**
* find_cfg_item() - find the configuration item
* @iniTable: pointer to configuration table
* @entries: number fo the configuration entries
* @name: the interested configuration to find
* @value: the value to read back
*
* Return: QDF_STATUS_SUCCESS if the interested configuration is found,
* otherwise QDF_STATUS_E_FAILURE
*/
static QDF_STATUS find_cfg_item(struct hdd_cfg_entry *iniTable,
unsigned long entries,
char *name, char **value)
{
QDF_STATUS status = QDF_STATUS_E_FAILURE;
unsigned long i;
for (i = 0; i < entries; i++) {
if (strcmp(iniTable[i].name, name) == 0) {
*value = iniTable[i].value;
hdd_debug("Found %s entry for Name=[%s] Value=[%s] ",
WLAN_INI_FILE, name, *value);
return QDF_STATUS_SUCCESS;
}
}
return status;
}
/**
* parse_hex_digit() - conversion to hex value
* @c: the character to convert
*
* Return: the hex value, otherwise 0
*/
static int parse_hex_digit(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
return 0;
}
/**
* update_mac_from_string() - convert string to 6 bytes mac address
* @hdd_ctx: the pointer to hdd context
@ -228,247 +177,6 @@ static QDF_STATUS update_mac_from_string(struct hdd_context *hdd_ctx,
return status;
}
/**
* hdd_apply_cfg_ini() - apply the ini configuration file
* @hdd_ctx: the pointer to hdd context
* @iniTable: pointer to configuration table
* @entries: number fo the configuration entries
* It overwrites the MAC address if config file exist.
*
* Return: QDF_STATUS_SUCCESS if the ini configuration file is correctly parsed,
* otherwise QDF_STATUS_E_INVAL
*/
static QDF_STATUS hdd_apply_cfg_ini(struct hdd_context *hdd_ctx,
struct hdd_cfg_entry *iniTable,
unsigned long entries)
{
QDF_STATUS match_status = QDF_STATUS_E_FAILURE;
QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
unsigned int idx;
void *pField;
char *value_str = NULL;
unsigned long len_value_str;
char *candidate;
uint32_t value;
int32_t svalue;
void *pStructBase = hdd_ctx->config;
struct reg_table_entry *pRegEntry = g_registry_table;
unsigned long cRegTableEntries = QDF_ARRAY_SIZE(g_registry_table);
uint32_t cbOutString;
int i;
int rv;
BUILD_BUG_ON(MAX_CFG_INI_ITEMS < cRegTableEntries);
for (idx = 0; idx < cRegTableEntries; idx++, pRegEntry++) {
/* Calculate the address of the destination field in the structure. */
pField = ((uint8_t *) pStructBase) + pRegEntry->VarOffset;
match_status =
find_cfg_item(iniTable, entries, pRegEntry->RegName,
&value_str);
if ((match_status != QDF_STATUS_SUCCESS)
&& (pRegEntry->Flags & VAR_FLAGS_REQUIRED)) {
/* If we could not read the cfg item and it is required, this is an error. */
hdd_err("Failed to read required config parameter %s", pRegEntry->RegName);
ret_status = QDF_STATUS_E_FAILURE;
break;
}
if ((WLAN_PARAM_Integer == pRegEntry->RegType) ||
(WLAN_PARAM_HexInteger == pRegEntry->RegType)) {
/* If successfully read from the registry, use the value read.
* If not, use the default value.
*/
if (match_status == QDF_STATUS_SUCCESS
&& (WLAN_PARAM_Integer == pRegEntry->RegType)) {
rv = kstrtou32(value_str, 10, &value);
if (rv < 0) {
hdd_warn("Reg Parameter %s invalid. Enforcing default", pRegEntry->RegName);
value = pRegEntry->VarDefault;
}
} else if (match_status == QDF_STATUS_SUCCESS
&& (WLAN_PARAM_HexInteger ==
pRegEntry->RegType)) {
rv = kstrtou32(value_str, 16, &value);
if (rv < 0) {
hdd_warn("Reg parameter %s invalid. Enforcing default", pRegEntry->RegName);
value = pRegEntry->VarDefault;
}
} else {
value = pRegEntry->VarDefault;
}
/* Only if the parameter is set in the ini file, do the range check here */
if (match_status == QDF_STATUS_SUCCESS &&
pRegEntry->Flags & VAR_FLAGS_RANGE_CHECK) {
if (value > pRegEntry->VarMax) {
hdd_warn("Reg Parameter %s > allowed Maximum [%u > %lu]. Enforcing Maximum", pRegEntry->RegName,
value, pRegEntry->VarMax);
value = pRegEntry->VarMax;
}
if (value < pRegEntry->VarMin) {
hdd_warn("Reg Parameter %s < allowed Minimum [%u < %lu]. Enforcing Minimum", pRegEntry->RegName,
value, pRegEntry->VarMin);
value = pRegEntry->VarMin;
}
}
/* Only if the parameter is set in the ini file, do the range check here */
else if (match_status == QDF_STATUS_SUCCESS &&
pRegEntry->Flags &
VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT) {
if (value > pRegEntry->VarMax) {
hdd_warn("Reg Parameter %s > allowed Maximum [%u > %lu]. Enforcing Default: %lu", pRegEntry->RegName,
value, pRegEntry->VarMax,
pRegEntry->VarDefault);
value = pRegEntry->VarDefault;
}
if (value < pRegEntry->VarMin) {
hdd_warn("Reg Parameter %s < allowed Minimum [%u < %lu]. Enforcing Default: %lu", pRegEntry->RegName,
value, pRegEntry->VarMin,
pRegEntry->VarDefault);
value = pRegEntry->VarDefault;
}
}
/* Move the variable into the output field. */
memcpy(pField, &value, pRegEntry->VarSize);
} else if (WLAN_PARAM_SignedInteger == pRegEntry->RegType) {
/* If successfully read from the registry, use the value read.
* If not, use the default value.
*/
if (QDF_STATUS_SUCCESS == match_status) {
rv = kstrtos32(value_str, 10, &svalue);
if (rv < 0) {
hdd_warn("Reg Parameter %s invalid. Enforcing Default", pRegEntry->RegName);
svalue =
(int32_t) pRegEntry->VarDefault;
}
} else {
svalue = (int32_t) pRegEntry->VarDefault;
}
/* Only if the parameter is set in the ini file, do the range check here */
if (match_status == QDF_STATUS_SUCCESS &&
pRegEntry->Flags & VAR_FLAGS_RANGE_CHECK) {
if (svalue > (int32_t) pRegEntry->VarMax) {
hdd_warn("Reg Parameter %s > allowed Maximum "
"[%d > %d]. Enforcing Maximum", pRegEntry->RegName,
svalue, (int)pRegEntry->VarMax);
svalue = (int32_t) pRegEntry->VarMax;
}
if (svalue < (int32_t) pRegEntry->VarMin) {
hdd_warn("Reg Parameter %s < allowed Minimum "
"[%d < %d]. Enforcing Minimum", pRegEntry->RegName,
svalue, (int)pRegEntry->VarMin);
svalue = (int32_t) pRegEntry->VarMin;
}
}
/* Only if the parameter is set in the ini file, do the range check here */
else if (match_status == QDF_STATUS_SUCCESS &&
pRegEntry->Flags &
VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT) {
if (svalue > (int32_t) pRegEntry->VarMax) {
hdd_warn("Reg Parameter %s > allowed Maximum "
"[%d > %d]. Enforcing Default: %d", pRegEntry->RegName,
svalue, (int)pRegEntry->VarMax,
(int)pRegEntry->VarDefault);
svalue =
(int32_t) pRegEntry->VarDefault;
}
if (svalue < (int32_t) pRegEntry->VarMin) {
hdd_warn("Reg Parameter %s < allowed Minimum "
"[%d < %d]. Enforcing Default: %d", pRegEntry->RegName,
svalue, (int)pRegEntry->VarMin,
(int)pRegEntry->VarDefault);
svalue = pRegEntry->VarDefault;
}
}
/* Move the variable into the output field. */
memcpy(pField, &svalue, pRegEntry->VarSize);
}
/* Handle string parameters */
else if (WLAN_PARAM_String == pRegEntry->RegType) {
#ifdef WLAN_CFG_DEBUG
hdd_debug("RegName = %s, VarOffset %u VarSize %u VarDefault %s",
pRegEntry->RegName, pRegEntry->VarOffset,
pRegEntry->VarSize,
(char *)pRegEntry->VarDefault);
#endif
if (match_status == QDF_STATUS_SUCCESS) {
len_value_str = strlen(value_str);
if (len_value_str > (pRegEntry->VarSize - 1)) {
hdd_err("Invalid Value=[%s] specified for Name=[%s] in %s", value_str,
pRegEntry->RegName,
WLAN_INI_FILE);
cbOutString =
QDF_MIN(strlen
((char *)pRegEntry->
VarDefault),
pRegEntry->VarSize - 1);
memcpy(pField,
(void *)(pRegEntry->VarDefault),
cbOutString);
((uint8_t *) pField)[cbOutString] =
'\0';
} else {
memcpy(pField, (void *)(value_str),
len_value_str);
((uint8_t *) pField)[len_value_str] =
'\0';
}
} else {
/* Failed to read the string parameter from the registry. Use the default. */
cbOutString =
QDF_MIN(strlen((char *)pRegEntry->VarDefault),
pRegEntry->VarSize - 1);
memcpy(pField, (void *)(pRegEntry->VarDefault),
cbOutString);
((uint8_t *) pField)[cbOutString] = '\0';
}
} else if (WLAN_PARAM_MacAddr == pRegEntry->RegType) {
if (pRegEntry->VarSize != QDF_MAC_ADDR_SIZE) {
hdd_warn("Invalid VarSize %u for Name=[%s]", pRegEntry->VarSize,
pRegEntry->RegName);
continue;
}
candidate = (char *)pRegEntry->VarDefault;
if (match_status == QDF_STATUS_SUCCESS) {
len_value_str = strlen(value_str);
if (len_value_str != (QDF_MAC_ADDR_SIZE * 2)) {
hdd_err("Invalid MAC addr [%s] specified for Name=[%s] in %s", value_str,
pRegEntry->RegName,
WLAN_INI_FILE);
} else
candidate = value_str;
}
/* parse the string and store it in the byte array */
for (i = 0; i < QDF_MAC_ADDR_SIZE; i++) {
((char *)pField)[i] =
(char)(parse_hex_digit(candidate[i * 2]) *
16 +
parse_hex_digit(candidate[i * 2 + 1]));
}
} else {
hdd_warn("Unknown param type for name[%s] in registry table", pRegEntry->RegName);
}
/* did we successfully parse a cfg item for this parameter? */
if ((match_status == QDF_STATUS_SUCCESS) &&
(idx < MAX_CFG_INI_ITEMS)) {
set_bit(idx, (void *)&hdd_ctx->config->bExplicitCfg);
}
}
return ret_status;
}
/**
* hdd_set_power_save_offload_config() - set power save offload configuration
* @hdd_ctx: the pointer to hdd context
@ -673,124 +381,6 @@ void hdd_override_all_ps(struct hdd_context *hdd_ctx)
hdd_disable_auto_shutdown(cfg_ini);
}
/**
* hdd_parse_config_ini() - parse the ini configuration file
* @hdd_ctx: the pointer to hdd context
*
* This function reads the qcom_cfg.ini file and
* parses each 'Name=Value' pair in the ini file
*
* Return: QDF_STATUS_SUCCESS if the qcom_cfg.ini is correctly read,
* otherwise QDF_STATUS_E_INVAL
*/
QDF_STATUS hdd_parse_config_ini(struct hdd_context *hdd_ctx)
{
int status = 0;
int i = 0;
int retry = 0;
/** Pointer for firmware image data */
const struct firmware *fw = NULL;
char *buffer, *line, *pTemp = NULL;
size_t size;
char *name, *value;
struct hdd_cfg_entry *cfg_ini_table;
QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
size = MAX_CFG_INI_ITEMS * sizeof(*cfg_ini_table);
cfg_ini_table = qdf_mem_malloc(size);
if (!cfg_ini_table) {
hdd_err("Failed to alloc %zu bytes for cfg_ini_table", size);
return QDF_STATUS_E_NOMEM;
}
do {
if (status == -EAGAIN)
msleep(HDD_CFG_REQUEST_FIRMWARE_DELAY);
status = request_firmware(&fw, WLAN_INI_FILE,
hdd_ctx->parent_dev);
retry++;
} while ((retry < HDD_CFG_REQUEST_FIRMWARE_RETRIES) &&
(status == -EAGAIN));
if (status) {
hdd_alert("request_firmware failed %d", status);
qdf_status = QDF_STATUS_E_FAILURE;
goto config_exit;
}
if (!fw || !fw->data || !fw->size) {
hdd_alert("%s download failed", WLAN_INI_FILE);
qdf_status = QDF_STATUS_E_FAILURE;
goto config_exit;
}
hdd_debug("qcom_cfg.ini Size %zu", fw->size);
buffer = (char *)qdf_mem_malloc(fw->size);
if (!buffer) {
hdd_err("qdf_mem_malloc failure");
qdf_status = QDF_STATUS_E_NOMEM;
goto config_exit;
}
pTemp = buffer;
qdf_mem_copy((void *)buffer, (void *)fw->data, fw->size);
size = fw->size;
while (buffer) {
line = get_next_line(buffer);
buffer = i_trim(buffer);
hdd_debug("%s: item", buffer);
if (strlen((char *)buffer) == 0 || *buffer == '#') {
buffer = line;
continue;
}
if (strncmp(buffer, "END", 3) == 0)
break;
name = buffer;
while (*buffer != '=' && *buffer != '\0')
buffer++;
if (*buffer != '\0') {
*buffer++ = '\0';
i_trim(name);
if (strlen(name) != 0) {
buffer = i_trim(buffer);
if (strlen(buffer) > 0) {
value = buffer;
while (*buffer != '\0')
buffer++;
*buffer = '\0';
cfg_ini_table[i].name = name;
cfg_ini_table[i++].value = value;
if (i >= MAX_CFG_INI_ITEMS) {
hdd_err("Number of items in %s > %d",
WLAN_INI_FILE,
MAX_CFG_INI_ITEMS);
break;
}
}
}
}
buffer = line;
}
/* Loop through the registry table and apply all these configs */
qdf_status = hdd_apply_cfg_ini(hdd_ctx, cfg_ini_table, i);
config_exit:
release_firmware(fw);
qdf_mem_free(pTemp);
qdf_mem_free(cfg_ini_table);
return qdf_status;
}
/**
* hdd_cfg_xlate_to_csr_phy_mode() - convert PHY mode
* @dot11Mode: the mode to convert

View File

@ -9065,8 +9065,6 @@ static void hdd_set_trace_level_for_each(struct hdd_context *hdd_ctx)
hdd_qdf_trace_enable(QDF_MODULE_ID_CRYPTO, 0xffff);
hdd_set_mtrace_for_each(hdd_ctx);
hdd_cfg_print_global_config(hdd_ctx);
}
/**
@ -9467,15 +9465,6 @@ struct hdd_context *hdd_context_create(struct device *dev)
goto err_free_hdd_context;
}
/* Read and parse the qcom_cfg.ini file */
status = hdd_parse_config_ini(hdd_ctx);
if (QDF_STATUS_SUCCESS != status) {
hdd_err("Error (status: %d) parsing INI file: %s", status,
WLAN_INI_FILE);
ret = -EINVAL;
goto err_free_config;
}
status = cfg_parse(WLAN_INI_FILE);
if (QDF_IS_STATUS_ERROR(status))
hdd_err("Failed to parse cfg %s; status:%d\n",
@ -10443,14 +10432,11 @@ static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx)
goto out;
}
/* Apply the cfg.ini to cfg.dat */
if (!hdd_update_config_cfg(hdd_ctx)) {
hdd_err("config update failed");
ret = -EINVAL;
goto out;
}
hdd_init_channel_avoidance(hdd_ctx);
out:

View File

@ -19,17 +19,6 @@
#ifndef __WNICFG_H
#define __WNICFG_H
/*
* Configuration Parameter ID for STA
*/
enum {
WNI_CFG_VALID_CHANNEL_LIST,
WNI_CFG_COUNTRY_CODE,
WNI_CFG_REMOVE_TIME_SYNC_CMD,
/* Any new items to be added should be above this strictly */
CFG_PARAM_MAX_NUM
};
/*
* String parameter lengths
*/