From 566c81ba4d70840af048c56ea349b414039ae8a7 Mon Sep 17 00:00:00 2001 From: gaurank kathpalia Date: Wed, 20 Feb 2019 14:31:45 +0530 Subject: [PATCH] qcacld-3.0: Refactor ini CFG_DHCP_SERVER_IP_NAME Refactor ini CFG_DHCP_SERVER_IP_NAME to hdd config file Change-Id: Iabaae01d3abfdada8a68606627cd96f959d05b07 --- core/hdd/inc/hdd_config.h | 27 +++++++++++++++++++++++++++ core/hdd/inc/wlan_hdd_cfg.h | 12 +----------- core/hdd/src/wlan_hdd_cfg.c | 8 -------- core/hdd/src/wlan_hdd_hostapd.c | 21 +++++++++------------ core/hdd/src/wlan_hdd_main.c | 25 +++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 31 deletions(-) diff --git a/core/hdd/inc/hdd_config.h b/core/hdd/inc/hdd_config.h index 05b9449eaf..3fa83a69d0 100644 --- a/core/hdd/inc/hdd_config.h +++ b/core/hdd/inc/hdd_config.h @@ -517,6 +517,33 @@ enum hdd_dot11_mode { CFG_VALUE_OR_DEFAULT, \ "Default Operating Channel") +#ifdef DHCP_SERVER_OFFLOAD +#define IPADDR_NUM_ENTRIES (4) +#define IPADDR_STRING_LENGTH (16) +#define CFG_DHCP_SERVER_IP_DEFAULT "" + +/* + * struct wlan_mlme_chainmask - All chainmask related cfg items + * @dhcpServerIP: Dhcp server IP address + * @is_dhcp_server_ip_valid: is dhcp server valid + */ +struct dhcp_server { + uint8_t dhcp_server_ip[IPADDR_NUM_ENTRIES]; + bool is_dhcp_server_ip_valid; +} + +/* + * + * gDHCPServerIP - Dhcp server Ip name + * @Default: + * + * This ini is used to give the DHCP IP server name + */ +#define CFG_DHCP_SERVER_IP_NAME \ + CFG_INI_STRING("gDHCPServerIP", \ + 0, IPADDR_STRING_LENGTH, CFG_DHCP_SERVER_IP_DEFAULT, "DHCP Server IP") +#endif /* DHCP_SERVER_OFFLOAD */ + /* * * gNumVdevs - max number of VDEVs supported diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h index b5f30dc07e..4779e8c218 100644 --- a/core/hdd/inc/wlan_hdd_cfg.h +++ b/core/hdd/inc/wlan_hdd_cfg.h @@ -47,11 +47,6 @@ struct hdd_context; #define FW_MODULE_LOG_LEVEL_STRING_LENGTH (512) #define TX_SCHED_WRR_PARAMS_NUM (5) -#ifdef DHCP_SERVER_OFFLOAD -#define IPADDR_NUM_ENTRIES (4) -#define IPADDR_STRING_LENGTH (16) -#endif - /* Number of items that can be configured */ #define MAX_CFG_INI_ITEMS 1024 @@ -103,11 +98,6 @@ struct hdd_context; #define CFG_ENABLE_SNR_MONITORING_MAX (1) #define CFG_ENABLE_SNR_MONITORING_DEFAULT (0) -#ifdef DHCP_SERVER_OFFLOAD -#define CFG_DHCP_SERVER_IP_NAME "gDHCPServerIP" -#define CFG_DHCP_SERVER_IP_DEFAULT "" -#endif /* DHCP_SERVER_OFFLOAD */ - #ifdef CONFIG_DP_TRACE /* Max length of gDptraceConfig string. e.g.- "1, 6, 1, 62" */ #define DP_TRACE_CONFIG_STRING_LENGTH (20) @@ -176,7 +166,7 @@ struct hdd_config { bool fEnableSNRMonitoring; bool advertiseConcurrentOperation; #ifdef DHCP_SERVER_OFFLOAD - uint8_t dhcpServerIP[IPADDR_STRING_LENGTH]; + struct dhcp_server dhcp_server_ip; #endif /* DHCP_SERVER_OFFLOAD */ bool apf_enabled; uint16_t sap_tx_leakage_threshold; diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index 1b574720e5..18603034c2 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -62,14 +62,6 @@ struct reg_table_entry g_registry_table[] = { CFG_ENABLE_SNR_MONITORING_DEFAULT, CFG_ENABLE_SNR_MONITORING_MIN, CFG_ENABLE_SNR_MONITORING_MAX), - -#ifdef DHCP_SERVER_OFFLOAD - REG_VARIABLE_STRING(CFG_DHCP_SERVER_IP_NAME, WLAN_PARAM_String, - struct hdd_config, dhcpServerIP, - VAR_FLAGS_OPTIONAL, - (void *)CFG_DHCP_SERVER_IP_DEFAULT), -#endif /* DHCP_SERVER_OFFLOAD */ - }; diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 11815934bb..bf52d75446 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -4721,13 +4721,17 @@ static void wlan_hdd_set_dhcp_server_offload(struct hdd_adapter *adapter) struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); struct dhcp_offload_info_params dhcp_srv_info; uint8_t num_entries = 0; - uint8_t srv_ip[IPADDR_NUM_ENTRIES]; + uint8_t *srv_ip; uint8_t num; uint32_t temp; uint32_t dhcp_max_num_clients; mac_handle_t mac_handle; QDF_STATUS status; + if (!hdd_ctx->config->dhcp_server_ip.is_dhcp_server_ip_valid) + return; + + srv_ip = hdd_ctx->config->dhcp_server_ip.dhcp_server_ip; dhcp_srv_info.vdev_id = adapter->vdev_id; dhcp_srv_info.dhcp_offload_enabled = true; @@ -4737,23 +4741,16 @@ static void wlan_hdd_set_dhcp_server_offload(struct hdd_adapter *adapter) return; dhcp_srv_info.dhcp_client_num = dhcp_max_num_clients; - hdd_string_to_u8_array(hdd_ctx->config->dhcpServerIP, - srv_ip, &num_entries, IPADDR_NUM_ENTRIES); - if (num_entries != IPADDR_NUM_ENTRIES) { - hdd_err("Incorrect IP address (%s) assigned for DHCP server!", - hdd_ctx->config->dhcpServerIP); - return; - } if ((srv_ip[0] >= 224) && (srv_ip[0] <= 239)) { - hdd_err("Invalid IP address (%s)! It could NOT be multicast IP address!", - hdd_ctx->config->dhcpServerIP); + hdd_err("Invalid IP address (%d)! It could NOT be multicast IP address!", + srv_ip[0]); return; } if (srv_ip[IPADDR_NUM_ENTRIES - 1] >= 100) { - hdd_err("Invalid IP address (%s)! The last field must be less than 100!", - hdd_ctx->config->dhcpServerIP); + hdd_err("Invalid IP address (%d)! The last field must be less than 100!", + srv_ip[IPADDR_NUM_ENTRIES - 1]); return; } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 4a79d03c07..0a2f1c2b66 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -9448,6 +9448,30 @@ static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, } #endif +#ifdef DHCP_SERVER_OFFLOAD +static void +hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) +{ + uint8_t num_entries; + + hdd_ctx->config->dhcp_server_ip.is_dhcp_server_ip_valid = true; + hdd_string_to_u8_array(cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME), + hdd_ctx->config->dhcp_server_ip.dhcp_server_ip, + &num_entries, IPADDR_NUM_ENTRIES); + + if (num_entries != IPADDR_NUM_ENTRIES) { + hdd_err("Incorrect IP address (%s) assigned for DHCP server!", + cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME)); + hdd_config->dhcp_server_ip.is_dhcp_server_ip_valid = false; + } +} +#else +static void +hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) +{ +} +#endif + /** * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture * @hdd_ctx - Pointer to HDD context @@ -9535,6 +9559,7 @@ static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) hdd_init_wlan_logging_params(config, psoc); hdd_init_packet_log(config, psoc); hdd_init_mtrace_log(config, psoc); + hdd_init_dhcp_server_ip(hdd_ctx); hdd_dp_cfg_update(psoc, hdd_ctx); }