summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Kumar Dhanotiya <adhanoti@codeaurora.org>2017-11-17 20:00:29 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2017-12-14 04:39:27 -0800
commit04cc8a8a15a79676bda22ebb91e985e03eca2799 (patch)
treebd2161373e09cffa8b8a1bac619e484f41f44bd1
parentaf5fc8dba4b127dbc63e2601fa6825156b366149 (diff)
qcacld-3.0: Enable MAC provisioning from ini
Currently MAC addresses are generated by driver only. MAC addresses are queried from platform driver or wlan_mac.bin. If platform driver gives mac addresses, driver uses it, else it will use wlan_mac.bin to update MAC addresses. If wlan_mac.bin also don't have MAC addresses then random MAC addresses are generated using the HW address or using device serial number. Add an ini support to enable MAC provisioning. If MAC provisioning is enabled, ensure that platform driver provides atleast 2 provisioned MAC addresses. Query the derived addresses also from platform driver. Generate the remaining random MAC addresses. Change-Id: Ib943f9de70a78ba5d5e87d81c76b20341893f8e9 CRs-Fixed: 2153836
-rw-r--r--core/hdd/inc/wlan_hdd_cfg.h90
-rw-r--r--core/hdd/inc/wlan_hdd_main.h57
-rw-r--r--core/hdd/src/wlan_hdd_cfg.c74
-rw-r--r--core/hdd/src/wlan_hdd_cfg80211.c2
-rw-r--r--core/hdd/src/wlan_hdd_main.c409
-rw-r--r--core/hdd/src/wlan_hdd_nan_datapath.c27
-rw-r--r--core/hdd/src/wlan_hdd_ocb.c6
-rw-r--r--core/hdd/src/wlan_hdd_p2p.c4
-rw-r--r--core/hdd/src/wlan_hdd_stats.c8
-rw-r--r--core/pld/inc/pld_common.h26
10 files changed, 529 insertions, 174 deletions
diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h
index e58b7b51d4d6..5388f194f5d2 100644
--- a/core/hdd/inc/wlan_hdd_cfg.h
+++ b/core/hdd/inc/wlan_hdd_cfg.h
@@ -13794,6 +13794,92 @@ enum hw_filter_mode {
#define CFG_RX_CHAIN_MASK_5G_MAX (3)
#define CFG_RX_CHAIN_MASK_5G_DEFAULT (0)
+/*
+ * <ini>
+ * enable_mac_provision - Enable/disable MAC address provisioning feature
+ * @Min: 0
+ * @Max: 1
+ * @Default: 0
+ *
+ * This ini is used to enable/disable MAC address provisioning feature
+ *
+ * Supported Feature: STA/SAP/P2P
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_ENABLE_MAC_PROVISION_NAME "enable_mac_provision"
+#define CFG_ENABLE_MAC_PROVISION_MIN (0)
+#define CFG_ENABLE_MAC_PROVISION_MAX (1)
+#define CFG_ENABLE_MAC_PROVISION_DEFAULT (0)
+
+/*
+ * <ini>
+ * provisioned_intf_pool - It is bit mask value of Interfaces
+ * @Min: 0
+ * @Max: 0xffffffff
+ * @Default: 0xffffffff
+ *
+ * This ini will contain the bitmask of all the interfaces
+ * which can use addresses from provisioned list. Using enum tQDF_ADAPTER_MODE
+ * for deciding the bit positions corresponding to each interface.
+ * Bit 0 : QDF_STA_MODE
+ * Bit 1 : QDF_SAP_MODE
+ * Bit 2 : QDF_P2P_CLIENT_MODE
+ * Bit 3 : QDF_P2P_GO_MODE
+ * Bit 4 : QDF_FTM_MODE
+ * Bit 5 : QDF_IBSS_MODE
+ * Bit 6 : QDF_MONITOR_MODE
+ * Bit 7 : QDF_P2P_DEVICE_MODE
+ * Bit 8 : QDF_OCB_MODE
+ * Bit 9 : QDF_EPPING_MODE
+ * Bit 10 : QDF_QVIT_MODE
+ * Bit 11 : QDF_NDI_MODE
+ * Bit 12 : QDF_MAX_NO_OF_MODE
+ * For example :
+ * If Bit 0 represents STA
+ * Bit 1 represents SAP
+ * Bit 2 represents P2P_CLIENT_MODE
+ * If only STA and SAP can use addresses from provisioned list then the value
+ * of ini should be 0x3 (00000011) as Bit 0 and Bit 1 should be set.
+ * If only STA and P2P_CLIENT_MODE can use addresses from provisioned
+ * list then the value of ini should be 0x5 (00000101) as Bit 0 and Bit 2
+ * should be set.
+ * Similarly, for only SAP and P2P_CLIENT_MODE ini should be 0x6 (00000110)
+ *
+ * Supported Feature: STA/SAP/P2P
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_PROVISION_INTERFACE_POOL_NAME "provisioned_intf_pool"
+#define CFG_PROVISION_INTERFACE_POOL_MIN (0)
+#define CFG_PROVISION_INTERFACE_POOL_MAX (0xffffffff)
+#define CFG_PROVISION_INTERFACE_POOL_DEFAULT (0xffffffff)
+/*
+ * <ini>
+ * deriveded_intf_pool - It is bit mask value of Interfaces
+ * @Min: 0
+ * @Max: 0xffffffff
+ * @Default: 0xffffffff
+ *
+ * This ini will contain the bitmask of all the interfaces
+ * which can use addresses from derived list
+ *
+ *
+ * Supported Feature: STA/SAP/P2P
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_DERIVED_INTERFACE_POOL_NAME "derived_intf_pool"
+#define CFG_DERIVED_INTERFACE_POOL_MIN (0)
+#define CFG_DERIVED_INTERFACE_POOL_MAX (0xffffffff)
+#define CFG_DERIVED_INTERFACE_POOL_DEFAULT (0xffffffff)
+
/*---------------------------------------------------------------------------
Type declarations
-------------------------------------------------------------------------*/
@@ -13835,7 +13921,6 @@ struct hdd_config {
uint32_t AdHocChannel5G;
uint32_t AdHocChannel24G;
uint8_t intfAddrMask;
- struct qdf_mac_addr intfMacAddr[QDF_MAX_CONCURRENCY_PERSONA];
bool apUapsdEnabled;
bool apRandomBssidEnabled;
@@ -14680,6 +14765,9 @@ struct hdd_config {
uint8_t rx_chain_mask_2g;
uint8_t tx_chain_mask_5g;
uint8_t rx_chain_mask_5g;
+ bool mac_provision;
+ unsigned long provisioned_intf_pool;
+ unsigned long derived_intf_pool;
};
#define VAR_OFFSET(_Struct, _Var) (offsetof(_Struct, _Var))
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h
index 5606703a8af5..7df2e6013e57 100644
--- a/core/hdd/inc/wlan_hdd_main.h
+++ b/core/hdd/inc/wlan_hdd_main.h
@@ -1994,7 +1994,6 @@ struct hdd_context_s {
bool napi_enable;
bool stop_modules_in_progress;
bool start_modules_in_progress;
- bool update_mac_addr_to_fw;
struct acs_dfs_policy acs_policy;
uint16_t wmi_max_len;
struct suspend_resume_stats suspend_resume_stats;
@@ -2041,6 +2040,14 @@ struct hdd_context_s {
struct sta_ap_intf_check_work_ctx *sta_ap_intf_check_work_info;
qdf_wake_lock_t monitor_mode_wakelock;
bool lte_coex_ant_share;
+
+ struct qdf_mac_addr hw_macaddr;
+ struct qdf_mac_addr provisioned_mac_addr[QDF_MAX_CONCURRENCY_PERSONA];
+ struct qdf_mac_addr derived_mac_addr[QDF_MAX_CONCURRENCY_PERSONA];
+ uint32_t num_provisioned_addr;
+ uint32_t num_derived_addr;
+ unsigned long provisioned_intf_addr_mask;
+ unsigned long derived_intf_addr_mask;
};
int hdd_validate_channel_and_bandwidth(hdd_adapter_t *adapter,
@@ -2108,7 +2115,20 @@ void hdd_deinit_adapter(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
QDF_STATUS hdd_stop_adapter(hdd_context_t *pHddCtx, hdd_adapter_t *pAdapter,
const bool bCloseSession);
void hdd_set_station_ops(struct net_device *pWlanDev);
-uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *pHddCtx);
+
+/**
+ * wlan_hdd_get_intf_addr() - Get address for the interface
+ * @pHddCtx: Pointer to hdd context
+ * @interface_type: type of the interface for which address is queried
+ *
+ * This function is used to get mac address for every new interface
+ *
+ * Return: If addr is present then return pointer to MAC address
+ * else NULL
+ */
+
+uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *pHddCtx,
+ enum tQDF_ADAPTER_MODE interface_type);
void wlan_hdd_release_intf_addr(hdd_context_t *pHddCtx, uint8_t *releaseAddr);
uint8_t hdd_get_operating_channel(hdd_context_t *pHddCtx,
enum tQDF_ADAPTER_MODE mode);
@@ -2320,8 +2340,37 @@ void hdd_get_fw_version(hdd_context_t *hdd_ctx,
uint32_t *major_spid, uint32_t *minor_spid,
uint32_t *siid, uint32_t *crmid);
-void hdd_update_macaddr(struct hdd_config *config,
- struct qdf_mac_addr hw_macaddr);
+/**
+ * hdd_free_mac_address_lists() - Free both the MAC address lists
+ * @hdd_ctx: HDD context
+ *
+ * This API clears/memset provisioned address list and
+ * derived address list
+ *
+ */
+void hdd_free_mac_address_lists(hdd_context_t *hdd_ctx);
+
+/**
+ * hdd_update_macaddr() - update mac address
+ * @hdd_ctx: hdd contxt
+ * @hw_macaddr: mac address
+ * @generate_mac_auto: Indicates whether the first address is
+ * provisioned address or derived address.
+ *
+ * Mac address for multiple virtual interface is found as following
+ * i) The mac address of the first interface is just the actual hw mac address.
+ * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to
+ * define the mac address for the remaining interfaces and locally
+ * admistered bit is set. INTF_MACADDR_MASK is based on the number of
+ * supported virtual interfaces, right now this is 0x07 (meaning 8
+ * interface).
+ * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1,
+ * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc.
+ *
+ * Return: None
+ */
+void hdd_update_macaddr(hdd_context_t *hdd_ctx,
+ struct qdf_mac_addr hw_macaddr, bool generate_mac_auto);
void wlan_hdd_disable_roaming(hdd_adapter_t *pAdapter);
void wlan_hdd_enable_roaming(hdd_adapter_t *pAdapter);
diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c
index 6715a407590f..cd65c3704fc4 100644
--- a/core/hdd/src/wlan_hdd_cfg.c
+++ b/core/hdd/src/wlan_hdd_cfg.c
@@ -548,26 +548,6 @@ struct reg_table_entry g_registry_table[] = {
VAR_FLAGS_OPTIONAL,
(void *)CFG_IBSS_BSSID_DEFAULT),
- REG_VARIABLE_STRING(CFG_INTF0_MAC_ADDR_NAME, WLAN_PARAM_MacAddr,
- struct hdd_config, intfMacAddr[0],
- VAR_FLAGS_OPTIONAL,
- (void *)CFG_INTF0_MAC_ADDR_DEFAULT),
-
- REG_VARIABLE_STRING(CFG_INTF1_MAC_ADDR_NAME, WLAN_PARAM_MacAddr,
- struct hdd_config, intfMacAddr[1],
- VAR_FLAGS_OPTIONAL,
- (void *)CFG_INTF1_MAC_ADDR_DEFAULT),
-
- REG_VARIABLE_STRING(CFG_INTF2_MAC_ADDR_NAME, WLAN_PARAM_MacAddr,
- struct hdd_config, intfMacAddr[2],
- VAR_FLAGS_OPTIONAL,
- (void *)CFG_INTF2_MAC_ADDR_DEFAULT),
-
- REG_VARIABLE_STRING(CFG_INTF3_MAC_ADDR_NAME, WLAN_PARAM_MacAddr,
- struct hdd_config, intfMacAddr[3],
- VAR_FLAGS_OPTIONAL,
- (void *)CFG_INTF3_MAC_ADDR_DEFAULT),
-
REG_VARIABLE(CFG_AP_QOS_UAPSD_MODE_NAME, WLAN_PARAM_Integer,
struct hdd_config, apUapsdEnabled,
VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
@@ -5413,6 +5393,27 @@ struct reg_table_entry g_registry_table[] = {
CFG_RX_CHAIN_MASK_5G_DEFAULT,
CFG_RX_CHAIN_MASK_5G_MIN,
CFG_RX_CHAIN_MASK_5G_MAX),
+
+ REG_VARIABLE(CFG_ENABLE_MAC_PROVISION_NAME, WLAN_PARAM_Integer,
+ struct hdd_config, mac_provision,
+ VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+ CFG_ENABLE_MAC_PROVISION_DEFAULT,
+ CFG_ENABLE_MAC_PROVISION_MIN,
+ CFG_ENABLE_MAC_PROVISION_MAX),
+
+ REG_VARIABLE(CFG_PROVISION_INTERFACE_POOL_NAME, WLAN_PARAM_HexInteger,
+ struct hdd_config, provisioned_intf_pool,
+ VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+ CFG_PROVISION_INTERFACE_POOL_DEFAULT,
+ CFG_PROVISION_INTERFACE_POOL_MIN,
+ CFG_PROVISION_INTERFACE_POOL_MAX),
+
+ REG_VARIABLE(CFG_DERIVED_INTERFACE_POOL_NAME, WLAN_PARAM_HexInteger,
+ struct hdd_config, derived_intf_pool,
+ VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+ CFG_DERIVED_INTERFACE_POOL_DEFAULT,
+ CFG_DERIVED_INTERFACE_POOL_MIN,
+ CFG_DERIVED_INTERFACE_POOL_MAX),
};
/**
@@ -5693,8 +5694,8 @@ static void update_mac_from_string(hdd_context_t *pHddCtx,
break;
}
if (res == 0 && !qdf_is_macaddr_zero(&macaddr[i])) {
- qdf_mem_copy((uint8_t *) &pHddCtx->config->
- intfMacAddr[i].bytes[0],
+ qdf_mem_copy((uint8_t *)&pHddCtx->
+ provisioned_mac_addr[i].bytes[0],
(uint8_t *) &macaddr[i].bytes[0],
QDF_MAC_ADDR_SIZE);
}
@@ -6320,8 +6321,6 @@ static void hdd_wlm_cfg_log(hdd_context_t *pHddCtx)
*/
void hdd_cfg_print(hdd_context_t *pHddCtx)
{
- int i;
-
hdd_debug("*********Config values in HDD Adapter*******");
hdd_debug("Name = [RTSThreshold] Value = %u",
pHddCtx->config->RTSThreshold);
@@ -6336,11 +6335,6 @@ void hdd_cfg_print(hdd_context_t *pHddCtx)
hdd_debug("Name = [gIbssBssid] Value =[" MAC_ADDRESS_STR "]",
MAC_ADDR_ARRAY(pHddCtx->config->IbssBssid.bytes));
- for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) {
- hdd_debug("Name = [Intf%dMacAddress] Value =[" MAC_ADDRESS_STR "]",
- i, MAC_ADDR_ARRAY(pHddCtx->config->intfMacAddr[i].bytes));
- }
-
hdd_debug("Name = [gApEnableUapsd] value = [%u]",
pHddCtx->config->apUapsdEnabled);
hdd_debug("Name = [g_mark_indoor_as_disable] Value = [%u]",
@@ -7230,6 +7224,15 @@ void hdd_cfg_print(hdd_context_t *pHddCtx)
pHddCtx->config->chan_switch_hostapd_rate_enabled);
hdd_debug("Name = [%s] value = [0x%x]", CFG_VC_MODE_BITMAP,
pHddCtx->config->vc_mode_cfg_bitmap);
+ hdd_debug("Name = [%s] value = [0x%x]",
+ CFG_ENABLE_MAC_PROVISION_NAME,
+ pHddCtx->config->mac_provision);
+ hdd_debug("Name = [%s] value = [0x%lx]",
+ CFG_PROVISION_INTERFACE_POOL_NAME,
+ pHddCtx->config->provisioned_intf_pool);
+ hdd_debug("Name = [%s] value = [0x%lx]",
+ CFG_DERIVED_INTERFACE_POOL_NAME,
+ pHddCtx->config->derived_intf_pool);
}
/**
@@ -7324,13 +7327,20 @@ QDF_STATUS hdd_update_mac_config(hdd_context_t *pHddCtx)
}
update_mac_from_string(pHddCtx, &macTable[0], i);
+ pHddCtx->num_provisioned_addr = i;
hdd_debug("Populating remaining %d Mac addreses",
max_mac_addr - i);
hdd_populate_random_mac_addr(pHddCtx, max_mac_addr - i);
- qdf_mem_copy(&customMacAddr,
- &pHddCtx->config->intfMacAddr[0].bytes[0],
- sizeof(tSirMacAddr));
+ if (pHddCtx->num_provisioned_addr)
+ qdf_mem_copy(&customMacAddr,
+ &pHddCtx->provisioned_mac_addr[0].bytes[0],
+ sizeof(tSirMacAddr));
+ else
+ qdf_mem_copy(&customMacAddr,
+ &pHddCtx->derived_mac_addr[0].bytes[0],
+ sizeof(tSirMacAddr));
+
sme_set_custom_mac_addr(customMacAddr);
config_exit:
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 03f02298bd79..1cad40c5b7b1 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -8873,7 +8873,7 @@ int wlan_hdd_request_pre_cac(uint8_t channel)
return -EINVAL;
}
- mac_addr = wlan_hdd_get_intf_addr(hdd_ctx);
+ mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_SAP_MODE);
if (!mac_addr) {
hdd_err("can't add virtual intf: Not getting valid mac addr");
return -EINVAL;
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index c127cf18ebf4..9bb89a22bbbb 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -884,35 +884,39 @@ QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter)
#define INTF_MACADDR_MASK 0x7
-/**
- * hdd_update_macaddr() - update mac address
- * @config: hdd configuration
- * @hw_macaddr: mac address
- *
- * Mac address for multiple virtual interface is found as following
- * i) The mac address of the first interface is just the actual hw mac address.
- * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to
- * define the mac address for the remaining interfaces and locally
- * admistered bit is set. INTF_MACADDR_MASK is based on the number of
- * supported virtual interfaces, right now this is 0x07 (meaning 8
- * interface).
- * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1,
- * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc.
- *
- * Return: None
- */
-void hdd_update_macaddr(struct hdd_config *config,
- struct qdf_mac_addr hw_macaddr)
+void hdd_update_macaddr(hdd_context_t *hdd_ctx,
+ struct qdf_mac_addr hw_macaddr, bool generate_mac_auto)
{
int8_t i;
uint8_t macaddr_b3, tmp_br3;
- qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes,
- QDF_MAC_ADDR_SIZE);
+ /*
+ * If "generate_mac_auto" is true, it indicates that all the
+ * addresses are derived addresses, else the first addresses
+ * is not derived address (It is provided by fw).
+ */
+ if (!generate_mac_auto) {
+ qdf_mem_copy(hdd_ctx->provisioned_mac_addr[0].bytes,
+ hw_macaddr.bytes, QDF_MAC_ADDR_SIZE);
+ hdd_ctx->num_provisioned_addr++;
+ hdd_info("hdd_ctx->provisioned_mac_addr[0]: "
+ MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(hdd_ctx->
+ provisioned_mac_addr[0].bytes));
+ } else {
+ qdf_mem_copy(hdd_ctx->derived_mac_addr[0].bytes,
+ hw_macaddr.bytes,
+ QDF_MAC_ADDR_SIZE);
+ hdd_ctx->num_derived_addr++;
+ hdd_info("hdd_ctx->derived_mac_addr[0]: "
+ MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes));
+ }
for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) {
- qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes,
+ qdf_mem_copy(hdd_ctx->derived_mac_addr[i].bytes,
+ hw_macaddr.bytes,
QDF_MAC_ADDR_SIZE);
- macaddr_b3 = config->intfMacAddr[i].bytes[3];
+ macaddr_b3 = hdd_ctx->derived_mac_addr[i].bytes[3];
tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) &
INTF_MACADDR_MASK;
macaddr_b3 += tmp_br3;
@@ -923,11 +927,12 @@ void hdd_update_macaddr(struct hdd_config *config,
macaddr_b3 ^= (1 << 7);
/* Set locally administered bit */
- config->intfMacAddr[i].bytes[0] |= 0x02;
- config->intfMacAddr[i].bytes[3] = macaddr_b3;
- hdd_debug("config->intfMacAddr[%d]: "
- MAC_ADDRESS_STR, i,
- MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes));
+ hdd_ctx->derived_mac_addr[i].bytes[0] |= 0x02;
+ hdd_ctx->derived_mac_addr[i].bytes[3] = macaddr_b3;
+ hdd_err("hdd_ctx->derived_mac_addr[%d]: "
+ MAC_ADDRESS_STR, i,
+ MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes));
+ hdd_ctx->num_derived_addr++;
}
}
@@ -1540,7 +1545,7 @@ static int hdd_generate_macaddr_auto(hdd_context_t *hdd_ctx)
mac_addr.bytes[4] = (serialno >> 8) & 0xff;
mac_addr.bytes[5] = serialno & 0xff;
- hdd_update_macaddr(hdd_ctx->config, mac_addr);
+ hdd_update_macaddr(hdd_ctx, mac_addr, true);
return 0;
}
@@ -1613,29 +1618,11 @@ void hdd_update_tgt_cfg(void *context, void *param)
}
/* This can be extended to other configurations like ht, vht cap... */
-
- if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) {
- hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr);
- hdd_ctx->update_mac_addr_to_fw = false;
- } else {
- static struct qdf_mac_addr default_mac_addr = {
- {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF}
- };
- if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0],
- &default_mac_addr)) {
- if (hdd_generate_macaddr_auto(hdd_ctx) != 0)
- hdd_warn("Fail to auto-generate MAC, using MAC from ini file "
- MAC_ADDRESS_STR,
- MAC_ADDR_ARRAY(hdd_ctx->config->
- intfMacAddr[0].bytes));
- } else {
- hdd_warn("Invalid MAC passed from target, using MAC from ini file "
- MAC_ADDRESS_STR,
- MAC_ADDR_ARRAY(hdd_ctx->config->
- intfMacAddr[0].bytes));
- }
- hdd_ctx->update_mac_addr_to_fw = true;
- }
+ if (!qdf_is_macaddr_zero(&cfg->hw_macaddr))
+ qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr,
+ QDF_MAC_ADDR_SIZE);
+ else
+ hdd_info("hw_mac is zero");
hdd_ctx->target_fw_version = cfg->target_fw_version;
hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext;
@@ -2610,34 +2597,100 @@ static int hdd_set_mac_address(struct net_device *dev, void *addr)
return ret;
}
-uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx)
+static uint8_t *wlan_hdd_get_derived_intf_addr(hdd_context_t *hdd_ctx)
{
int i;
- for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) {
- if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i)))
+ for (i = 0; i < hdd_ctx->num_derived_addr; i++) {
+ if (!qdf_atomic_test_and_set_bit(
+ i, &hdd_ctx->derived_intf_addr_mask))
break;
}
+ if (hdd_ctx->num_derived_addr == i) {
+ hdd_err("No free derived Addresses");
+ return NULL;
+ }
+ hdd_info("Assigning MAC from derived list" MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes));
+ return &hdd_ctx->derived_mac_addr[i].bytes[0];
+}
+
+static uint8_t *wlan_hdd_get_provisioned_intf_addr(hdd_context_t *hdd_ctx)
+{
+ int i;
- if (QDF_MAX_CONCURRENCY_PERSONA == i)
+ for (i = 0; i < hdd_ctx->num_provisioned_addr; i++) {
+ if (!qdf_atomic_test_and_set_bit(
+ i, &hdd_ctx->provisioned_intf_addr_mask))
+ break;
+ }
+ if (hdd_ctx->num_provisioned_addr == i) {
+ hdd_err("No free provisioned Addresses");
return NULL;
+ }
+ hdd_info("Assigning MAC from provisioned list" MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes));
+ return &hdd_ctx->provisioned_mac_addr[i].bytes[0];
+}
- hdd_ctx->config->intfAddrMask |= (1 << i);
- return &hdd_ctx->config->intfMacAddr[i].bytes[0];
+uint8_t *wlan_hdd_get_intf_addr(hdd_context_t *hdd_ctx,
+ enum tQDF_ADAPTER_MODE interface_type)
+{
+ uint8_t *mac_addr = NULL;
+
+ if (qdf_atomic_test_bit(interface_type,
+ &hdd_ctx->config->provisioned_intf_pool))
+ mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx);
+
+ if ((!mac_addr) &&
+ (qdf_atomic_test_bit(interface_type,
+ &hdd_ctx->config->derived_intf_pool)))
+ mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx);
+
+ if (!mac_addr)
+ hdd_err("MAC is not available in both the lists");
+ return mac_addr;
}
void wlan_hdd_release_intf_addr(hdd_context_t *hdd_ctx, uint8_t *releaseAddr)
{
int i;
- for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) {
+ for (i = 0; i < hdd_ctx->num_provisioned_addr; i++) {
if (!memcmp(releaseAddr,
- &hdd_ctx->config->intfMacAddr[i].bytes[0],
+ &hdd_ctx->provisioned_mac_addr[i].bytes[0],
6)) {
- hdd_ctx->config->intfAddrMask &= ~(1 << i);
+ qdf_atomic_clear_bit(i, &hdd_ctx->
+ provisioned_intf_addr_mask);
+ hdd_info("Releasing MAC from provisioned list");
+ hdd_info(MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(hdd_ctx->
+ provisioned_mac_addr[i].bytes));
break;
}
}
+
+ if (i == hdd_ctx->num_provisioned_addr) {
+ for (i = 0; i < hdd_ctx->num_derived_addr; i++) {
+ if (!memcmp(releaseAddr,
+ &hdd_ctx->derived_mac_addr[i].bytes[0],
+ 6)) {
+ qdf_atomic_clear_bit(
+ i, &hdd_ctx->
+ derived_intf_addr_mask);
+ hdd_info("Releasing MAC from derived list");
+ hdd_info(MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(
+ hdd_ctx->
+ derived_mac_addr[i].bytes));
+ break;
+ }
+ }
+ if (i == hdd_ctx->num_derived_addr) {
+ hdd_err("Releasing non existing MAC" MAC_ADDRESS_STR,
+ MAC_ADDR_ARRAY(releaseAddr));
+ }
+ }
}
#ifdef WLAN_FEATURE_PACKET_FILTERING
@@ -3885,10 +3938,14 @@ hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type,
switch (session_type) {
case QDF_STA_MODE:
- /* Reset locally administered bit if the device mode is STA */
- WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr);
- hdd_info("locally administered bit reset in sta mode: "
- MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
+ if (!hdd_ctx->config->mac_provision) {
+ /* Reset locally administered bit if the device mode is
+ * STA
+ */
+ WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr);
+ hdd_info("locally administered bit reset in sta mode: "
+ MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
+ }
/* fall through */
case QDF_P2P_CLIENT_MODE:
case QDF_P2P_DEVICE_MODE:
@@ -8330,28 +8387,46 @@ static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held)
{
hdd_adapter_t *adapter;
uint8_t *p2p_dev_addr;
+ bool is_p2p_locally_administered = false;
- if (hdd_ctx->config->isP2pDeviceAddrAdministrated &&
- !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) {
- qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes,
- hdd_ctx->config->intfMacAddr[0].bytes,
- sizeof(tSirMacAddr));
+ if (hdd_ctx->config->isP2pDeviceAddrAdministrated) {
+ if (hdd_ctx->num_provisioned_addr &&
+ !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) {
+ qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes,
+ hdd_ctx->provisioned_mac_addr[0].bytes,
+ sizeof(tSirMacAddr));
- /*
- * Generate the P2P Device Address. This consists of
- * the device's primary MAC address with the locally
- * administered bit set.
- */
- hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02;
- } else {
- p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx);
- if (p2p_dev_addr == NULL) {
+ /*
+ * Generate the P2P Device Address. This consists of
+ * the device's primary MAC address with the locally
+ * administered bit set.
+ */
+ hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02;
+ is_p2p_locally_administered = true;
+ } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) {
+ qdf_mem_copy(hdd_ctx->p2pDeviceAddress.bytes,
+ hdd_ctx->derived_mac_addr[0].bytes,
+ sizeof(tSirMacAddr));
+ /*
+ * Generate the P2P Device Address. This consists of
+ * the device's primary MAC address with the locally
+ * administered bit set.
+ */
+ hdd_ctx->p2pDeviceAddress.bytes[0] |= 0x02;
+ is_p2p_locally_administered = true;
+ }
+ }
+ if (!is_p2p_locally_administered) {
+ p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx,
+ QDF_P2P_DEVICE_MODE);
+ if (!p2p_dev_addr) {
hdd_err("Failed to allocate mac_address for p2p_device");
return -ENOSPC;
}
qdf_mem_copy(&hdd_ctx->p2pDeviceAddress.bytes[0], p2p_dev_addr,
- QDF_MAC_ADDR_SIZE);
+ QDF_MAC_ADDR_SIZE);
+
}
adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d",
@@ -8362,7 +8437,6 @@ static int hdd_open_p2p_interface(hdd_context_t *hdd_ctx, bool rtnl_held)
hdd_err("Failed to do hdd_open_adapter for P2P Device Interface");
return -ENOSPC;
}
-
return 0;
}
#else
@@ -8379,7 +8453,8 @@ static int hdd_open_ocb_interface(hdd_context_t *hdd_ctx, bool rtnl_held)
int ret = 0;
adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d",
- wlan_hdd_get_intf_addr(hdd_ctx),
+ wlan_hdd_get_intf_addr(hdd_ctx,
+ QDF_OCB_MODE),
NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL) {
hdd_err("Failed to open 802.11p interface");
@@ -8479,9 +8554,10 @@ static int hdd_open_concurrent_interface(hdd_context_t *hdd_ctx, bool rtnl_held)
hdd_adapter_t *adapter;
adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE,
- hdd_ctx->config->enableConcurrentSTA,
- wlan_hdd_get_intf_addr(hdd_ctx),
- NET_NAME_UNKNOWN, rtnl_held);
+ hdd_ctx->config->enableConcurrentSTA,
+ wlan_hdd_get_intf_addr(hdd_ctx,
+ QDF_STA_MODE),
+ NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL)
return -ENOSPC;
@@ -8508,7 +8584,8 @@ static int hdd_open_interfaces(hdd_context_t *hdd_ctx, bool rtnl_held)
return hdd_open_ocb_interface(hdd_ctx, rtnl_held);
adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d",
- wlan_hdd_get_intf_addr(hdd_ctx),
+ wlan_hdd_get_intf_addr(hdd_ctx,
+ QDF_STA_MODE),
NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL)
@@ -9060,6 +9137,19 @@ QDF_STATUS hdd_register_for_sap_restart_with_channel_switch(void)
}
#endif
+void hdd_free_mac_address_lists(hdd_context_t *hdd_ctx)
+{
+ hdd_info("Resetting MAC address lists");
+ qdf_mem_set(hdd_ctx->provisioned_mac_addr,
+ sizeof(hdd_ctx->provisioned_mac_addr), 0);
+ qdf_mem_set(hdd_ctx->derived_mac_addr,
+ sizeof(hdd_ctx->derived_mac_addr), 0);
+ hdd_ctx->num_provisioned_addr = 0;
+ hdd_ctx->num_derived_addr = 0;
+ hdd_ctx->provisioned_intf_addr_mask = 0;
+ hdd_ctx->derived_intf_addr_mask = 0;
+}
+
/**
* hdd_get_platform_wlan_mac_buff() - API to query platform driver
* for MAC address
@@ -9075,6 +9165,20 @@ static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev,
}
/**
+ * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver
+ * for derived MAC address
+ * @dev: Device Pointer
+ * @num: Number of Valid Mac address
+ *
+ * Return: Pointer to MAC address buffer
+ */
+static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev,
+ uint32_t *num)
+{
+ return pld_get_wlan_derived_mac_address(dev, num);
+}
+
+/**
* hdd_populate_random_mac_addr() - API to populate random mac addresses
* @hdd_ctx: HDD Context
* @num: Number of random mac addresses needed
@@ -9085,24 +9189,29 @@ static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev,
*/
void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num)
{
- uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num;
+ uint32_t idx = hdd_ctx->num_derived_addr;
uint32_t iter;
- struct hdd_config *ini = hdd_ctx->config;
uint8_t *buf = NULL;
uint8_t macaddr_b3, tmp_br3;
- uint8_t *src = ini->intfMacAddr[0].bytes;
+ /*
+ * Consider first provisioned mac address as source address to derive
+ * remaining addresses
+ */
+
+ uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes;
- for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) {
- buf = ini->intfMacAddr[iter].bytes;
+ for (iter = 0; iter < num; ++iter, ++idx) {
+ buf = hdd_ctx->derived_mac_addr[idx].bytes;
qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE);
macaddr_b3 = buf[3];
- tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) &
+ tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) &
INTF_MACADDR_MASK;
macaddr_b3 += tmp_br3;
macaddr_b3 ^= (1 << INTF_MACADDR_MASK);
buf[0] |= 0x02;
buf[3] = macaddr_b3;
hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf));
+ hdd_ctx->num_derived_addr++;
}
}
@@ -9121,36 +9230,65 @@ static int hdd_platform_wlan_mac(hdd_context_t *hdd_ctx)
uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE;
uint8_t *addr, *buf;
struct device *dev = hdd_ctx->parent_dev;
- struct hdd_config *ini = hdd_ctx->config;
tSirMacAddr mac_addr;
QDF_STATUS status;
addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr);
- if (no_of_mac_addr == 0 || !addr) {
- hdd_warn("Platform Driver Doesn't have wlan mac addresses");
+ if (no_of_mac_addr == 0 || !addr ||
+ (hdd_ctx->config->mac_provision && (no_of_mac_addr < 2))) {
+ hdd_err("Platform Driver doesn't have provisioned mac addr");
return -EINVAL;
}
+ hdd_free_mac_address_lists(hdd_ctx);
+
if (no_of_mac_addr > max_mac_addr)
no_of_mac_addr = max_mac_addr;
qdf_mem_copy(&mac_addr, addr, mac_addr_size);
for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) {
- buf = ini->intfMacAddr[iter].bytes;
+ buf = hdd_ctx->provisioned_mac_addr[iter].bytes;
qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE);
- hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf));
+ hdd_info("provisioned MAC Addr [%d]" MAC_ADDRESS_STR, iter,
+ MAC_ADDR_ARRAY(buf));
}
- status = sme_set_custom_mac_addr(mac_addr);
- if (!QDF_IS_STATUS_SUCCESS(status))
- return -EAGAIN;
+ hdd_ctx->num_provisioned_addr = no_of_mac_addr;
+
+ if (hdd_ctx->config->mac_provision) {
+ addr = hdd_get_platform_wlan_derived_mac_buff(dev,
+ &no_of_mac_addr);
+
+ if (no_of_mac_addr == 0 || !addr)
+ hdd_warn("No derived address from platform driver");
+ else if (no_of_mac_addr >
+ (max_mac_addr - hdd_ctx->num_provisioned_addr))
+ no_of_mac_addr = (max_mac_addr -
+ hdd_ctx->num_provisioned_addr);
+ for (iter = 0; iter < no_of_mac_addr; ++iter,
+ addr += mac_addr_size) {
+ buf = hdd_ctx->derived_mac_addr[iter].bytes;
+ qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE);
+ hdd_info("derived MAC Addr [%d]" MAC_ADDRESS_STR, iter,
+ MAC_ADDR_ARRAY(buf));
+ }
+ hdd_ctx->num_derived_addr = no_of_mac_addr;
+ }
+
+ no_of_mac_addr = hdd_ctx->num_provisioned_addr +
+ hdd_ctx->num_derived_addr;
if (no_of_mac_addr < max_mac_addr)
hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr -
no_of_mac_addr);
+
+ status = sme_set_custom_mac_addr(mac_addr);
+ if (!QDF_IS_STATUS_SUCCESS(status))
+ return -EAGAIN;
+
return 0;
}
@@ -9169,9 +9307,14 @@ static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx)
tSirMacAddr customMacAddr;
QDF_STATUS status;
- qdf_mem_copy(&customMacAddr,
- &hdd_ctx->config->intfMacAddr[0].bytes[0],
- sizeof(tSirMacAddr));
+ if (hdd_ctx->num_provisioned_addr)
+ qdf_mem_copy(&customMacAddr,
+ &hdd_ctx->provisioned_mac_addr[0].bytes[0],
+ sizeof(tSirMacAddr));
+ else
+ qdf_mem_copy(&customMacAddr,
+ &hdd_ctx->derived_mac_addr[0].bytes[0],
+ sizeof(tSirMacAddr));
status = sme_set_custom_mac_addr(customMacAddr);
if (!QDF_IS_STATUS_SUCCESS(status))
return -EAGAIN;
@@ -9188,14 +9331,18 @@ static int hdd_update_mac_addr_to_fw(hdd_context_t *hdd_ctx)
*
* Return: None
*/
-static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx)
+static int hdd_initialize_mac_address(hdd_context_t *hdd_ctx)
{
QDF_STATUS status;
int ret;
+ bool update_mac_addr_to_fw = true;
ret = hdd_platform_wlan_mac(hdd_ctx);
+ if (hdd_ctx->config->mac_provision)
+ return ret;
+
if (ret == 0)
- return;
+ return ret;
hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin",
ret);
@@ -9203,18 +9350,36 @@ static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx)
status = hdd_update_mac_config(hdd_ctx);
if (QDF_IS_STATUS_SUCCESS(status))
- return;
+ return 0;
hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC",
status);
- if (hdd_ctx->update_mac_addr_to_fw) {
+ /* Use fw provided MAC */
+ if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) {
+ hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false);
+ update_mac_addr_to_fw = false;
+ } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) {
+ struct qdf_mac_addr mac_addr;
+
+ hdd_err("MAC failure from device serial no.");
+ cds_rand_get_bytes(0, (uint8_t *)(&mac_addr), sizeof(mac_addr));
+ /*
+ * Reset multicast bit (bit-0) and set
+ * locally-administered bit
+ */
+ mac_addr.bytes[0] = 0x2;
+ hdd_update_macaddr(hdd_ctx, mac_addr, true);
+ }
+
+ if (update_mac_addr_to_fw) {
ret = hdd_update_mac_addr_to_fw(hdd_ctx);
if (ret != 0) {
hdd_err("MAC address out-of-sync, ret:%d", ret);
QDF_ASSERT(ret);
}
}
+ return 0;
}
static int hdd_set_smart_chainmask_enabled(hdd_context_t *hdd_ctx)
@@ -9297,7 +9462,6 @@ static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx)
{
int ret;
QDF_STATUS status;
- tSirRetStatus hal_status;
ol_txrx_register_pause_cb(wlan_hdd_txrx_pause_cb);
@@ -9376,21 +9540,6 @@ static int hdd_pre_enable_configure(hdd_context_t *hdd_ctx)
goto out;
}
- /*
- * Set the MAC Address Currently this is used by HAL to add self sta.
- * Remove this once self sta is added as part of session open.
- */
- hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID,
- hdd_ctx->config->intfMacAddr[0].bytes,
- sizeof(hdd_ctx->config->intfMacAddr[0]));
-
- if (!IS_SIR_STATUS_SUCCESS(hal_status)) {
- hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]",
- hal_status, hal_status);
- ret = -EINVAL;
- goto out;
- }
-
hdd_init_channel_avoidance(hdd_ctx);
/* update enable sap mandatory chan list */
@@ -10379,7 +10528,11 @@ int hdd_wlan_startup(struct device *dev)
if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE)
goto err_wiphy_unregister;
- hdd_initialize_mac_address(hdd_ctx);
+ ret = hdd_initialize_mac_address(hdd_ctx);
+ if (ret) {
+ hdd_err("MAC initializtion failed: %d", ret);
+ goto err_ipa_cleanup;
+ }
ret = register_netdevice_notifier(&hdd_netdev_notifier);
if (ret) {
@@ -12055,14 +12208,18 @@ static int hdd_register_req_mode(hdd_context_t *hdd_ctx,
break;
case QDF_GLOBAL_FTM_MODE:
adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d",
- wlan_hdd_get_intf_addr(hdd_ctx),
+ wlan_hdd_get_intf_addr(
+ hdd_ctx,
+ QDF_FTM_MODE),
NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL)
ret = -EINVAL;
break;
case QDF_GLOBAL_MONITOR_MODE:
adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d",
- wlan_hdd_get_intf_addr(hdd_ctx),
+ wlan_hdd_get_intf_addr(
+ hdd_ctx,
+ QDF_MONITOR_MODE),
NET_NAME_UNKNOWN, rtnl_held);
if (adapter == NULL)
ret = -EINVAL;
diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c
index 900042668027..ec03e08bb911 100644
--- a/core/hdd/src/wlan_hdd_nan_datapath.c
+++ b/core/hdd/src/wlan_hdd_nan_datapath.c
@@ -302,8 +302,10 @@ static int hdd_get_random_nan_mac_addr(hdd_context_t *hdd_ctx,
{
hdd_adapter_t *adapter;
uint8_t i, attempts, max_attempt = 16;
+ bool found;
for (attempts = 0; attempts < max_attempt; attempts++) {
+ found = false;
cds_rand_get_bytes(0, (uint8_t *)mac_addr, sizeof(*mac_addr));
/*
@@ -317,12 +319,27 @@ static int hdd_get_random_nan_mac_addr(hdd_context_t *hdd_ctx,
*/
mac_addr->bytes[5] &= 0xFE;
- for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) {
- if (!qdf_mem_cmp(hdd_ctx->config->intfMacAddr[i].bytes,
- mac_addr, sizeof(*mac_addr)))
- continue;
+ for (i = 0; i < hdd_ctx->num_provisioned_addr; i++) {
+ if ((!qdf_mem_cmp(hdd_ctx->
+ provisioned_mac_addr[i].bytes,
+ mac_addr, sizeof(*mac_addr))))
+ found = true;
+ break;
}
+ if (found)
+ continue;
+
+ for (i = 0; i < hdd_ctx->num_derived_addr; i++) {
+ if ((!qdf_mem_cmp(hdd_ctx->
+ derived_mac_addr[i].bytes,
+ mac_addr, sizeof(*mac_addr))))
+ found = true;
+ break;
+ }
+ if (found)
+ continue;
+
adapter = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr->bytes);
if (!adapter)
return 0;
@@ -383,7 +400,7 @@ static int hdd_ndi_create_req_handler(hdd_context_t *hdd_ctx,
}
ndi_mac_addr = &random_ndi_mac.bytes[0];
} else {
- ndi_mac_addr = wlan_hdd_get_intf_addr(hdd_ctx);
+ ndi_mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_NDI_MODE);
if (!ndi_mac_addr) {
hdd_err("get intf address failed");
return -EINVAL;
diff --git a/core/hdd/src/wlan_hdd_ocb.c b/core/hdd/src/wlan_hdd_ocb.c
index 12614bdff176..80ef8ffb97d8 100644
--- a/core/hdd/src/wlan_hdd_ocb.c
+++ b/core/hdd/src/wlan_hdd_ocb.c
@@ -546,7 +546,8 @@ static int __iw_set_dot11p_channel_sched(struct net_device *dev,
qdf_copy_macaddr(&curr_chan->mac_address,
&adapter->macAddressCurrent);
} else {
- mac_addr = wlan_hdd_get_intf_addr(adapter->pHddCtx);
+ mac_addr = wlan_hdd_get_intf_addr(adapter->pHddCtx,
+ adapter->device_mode);
if (mac_addr == NULL) {
hdd_err("Cannot obtain mac address");
rc = -EINVAL;
@@ -912,7 +913,8 @@ static int __wlan_hdd_cfg80211_ocb_set_config(struct wiphy *wiphy,
qdf_copy_macaddr(&config->channels[i].mac_address,
&adapter->macAddressCurrent);
} else {
- mac_addr = wlan_hdd_get_intf_addr(adapter->pHddCtx);
+ mac_addr = wlan_hdd_get_intf_addr(adapter->pHddCtx,
+ adapter->device_mode);
if (mac_addr == NULL) {
hdd_err("Cannot obtain mac address");
goto fail;
diff --git a/core/hdd/src/wlan_hdd_p2p.c b/core/hdd/src/wlan_hdd_p2p.c
index 88290b1d9ef6..d9545d1679c3 100644
--- a/core/hdd/src/wlan_hdd_p2p.c
+++ b/core/hdd/src/wlan_hdd_p2p.c
@@ -2803,7 +2803,9 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy,
pAdapter = hdd_open_adapter(pHddCtx,
session_type,
name,
- wlan_hdd_get_intf_addr(pHddCtx),
+ wlan_hdd_get_intf_addr(
+ pHddCtx,
+ session_type),
name_assign_type,
true);
}
diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c
index 519befcb2f99..1e6bbd46a50e 100644
--- a/core/hdd/src/wlan_hdd_stats.c
+++ b/core/hdd/src/wlan_hdd_stats.c
@@ -4630,8 +4630,12 @@ static int __wlan_hdd_cfg80211_dump_station(struct wiphy *wiphy,
hdd_debug("%s: idx %d", __func__, idx);
if (idx != 0)
return -ENOENT;
- qdf_mem_copy(mac, hdd_ctx->config->intfMacAddr[0].bytes,
- QDF_MAC_ADDR_SIZE);
+ if (hdd_ctx->num_provisioned_addr)
+ qdf_mem_copy(mac, hdd_ctx->provisioned_mac_addr[0].bytes,
+ QDF_MAC_ADDR_SIZE);
+ else
+ qdf_mem_copy(mac, hdd_ctx->derived_mac_addr[0].bytes,
+ QDF_MAC_ADDR_SIZE);
return __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
}
diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h
index e682835ba0d0..d18bfa429047 100644
--- a/core/pld/inc/pld_common.h
+++ b/core/pld/inc/pld_common.h
@@ -444,6 +444,24 @@ static inline uint8_t *pld_get_wlan_mac_address(struct device *dev,
{
return cnss_utils_get_wlan_mac_address(dev, num);
}
+
+/**
+ * pld_get_wlan_derived_mac_address() - API to query derived MAC address
+ * from platform Driver
+ * @dev: Device Structure
+ * @num: Pointer to number of MAC address supported
+ *
+ * Platform Driver can have MAC address stored. This API needs to be used
+ * to get those MAC address
+ *
+ * Return: Pointer to the list of MAC address
+ */
+static inline uint8_t *pld_get_wlan_derived_mac_address(struct device *dev,
+ uint32_t *num)
+{
+ return cnss_utils_get_wlan_derived_mac_address(dev, num);
+}
+
/**
* pld_increment_driver_load_cnt() - Maintain driver load count
* @dev: device
@@ -498,6 +516,14 @@ static inline uint8_t *pld_get_wlan_mac_address(struct device *dev,
*num = 0;
return NULL;
}
+
+static inline uint8_t *pld_get_wlan_derived_mac_address(struct device *dev,
+ uint32_t *num)
+{
+ *num = 0;
+ return NULL;
+}
+
static inline void pld_increment_driver_load_cnt(struct device *dev) {}
static inline int pld_get_driver_load_cnt(struct device *dev)
{