diff options
| author | Komal Seelam <kseelam@qti.qualcomm.com> | 2016-03-04 16:56:52 +0530 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2016-03-17 13:11:37 +0530 |
| commit | 3f62624aee0764428a3eeb1f7df2659c565d5835 (patch) | |
| tree | 1c97a8ed1a48ebf46ee0c69a874c843278d7e06f | |
| parent | 654854097605d0bd66d52819aa7e9925336ba4be (diff) | |
qcacld-2.0: Get WLAN MAC address from cnss platform driver
OEM's has provision to update cnss platform driver with the mac address.
Modify wlan functional driver to query cnss platform driver for the mac
address.
If the cnss platform driver is not populated with valid mac address,
driver will fallback to use the existing approach to update mac address
Change-Id: I0b4bb53047eba3af8b98aadfae22974558153cb5
CRs-Fixed: 985585
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_main.c | 117 | ||||
| -rw-r--r-- | CORE/VOSS/inc/vos_cnss.h | 18 |
2 files changed, 126 insertions, 9 deletions
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c index 9903263f678f..9dadcec35aaf 100644 --- a/CORE/HDD/src/wlan_hdd_main.c +++ b/CORE/HDD/src/wlan_hdd_main.c @@ -13893,6 +13893,116 @@ static void hdd_register_debug_callback(void) vos_register_debug_callback(VOS_MODULE_ID_HDD, &hdd_state_info_dump); } +/** + * hdd_populate_random_mac_addr() - API to populate random mac addresses + * @hdd_ctx: HDD Context + * @num: Number of random mac addresses needed + * + * Generate random addresses using bit manipulation on the base mac address + * + * Return: None + */ +static void hdd_populate_random_mac_addr(hdd_context_t *hdd_ctx, uint32_t num) +{ + uint32_t start_idx = VOS_MAX_CONCURRENCY_PERSONA - num; + uint32_t iter; + hdd_config_t *ini = hdd_ctx->cfg_ini; + u8 *buf = NULL; + u8 macaddr_b3, tmp_br3; + u8 *src = ini->intfMacAddr[0].bytes; + + for (iter = start_idx; iter < VOS_MAX_CONCURRENCY_PERSONA; ++iter) { + buf = ini->intfMacAddr[iter].bytes; + vos_mem_copy(buf, src, VOS_MAC_ADDR_SIZE); + macaddr_b3 = buf[3]; + tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & + INTF_MACADDR_MASK; + macaddr_b3 += tmp_br3; + macaddr_b3 ^= (1 << INTF_MACADDR_MASK); + buf[0] |= 0x02; + buf[3] = macaddr_b3; + hddLog(LOG1, FL(MAC_ADDRESS_STR), MAC_ADDR_ARRAY(buf)); + } +} + +/** + * hdd_cnss_wlan_mac() - API to get mac addresses from cnss platform driver + * @hdd_ctx: HDD Context + * + * API to get mac addresses from platform driver and update the driver + * structures and configure FW with the base mac address. + * + * Return: int + */ +static int hdd_cnss_wlan_mac(hdd_context_t *hdd_ctx) +{ + uint32_t no_of_mac_addr, iter; + uint32_t max_mac_addr = VOS_MAX_CONCURRENCY_PERSONA; + uint32_t mac_addr_size = VOS_MAC_ADDR_SIZE; + u8 *addr, *buf; + struct device *dev = hdd_ctx->parent_dev; + hdd_config_t *ini = hdd_ctx->cfg_ini; + tSirMacAddr customMacAddr; + VOS_STATUS status; + + addr = vos_get_cnss_wlan_mac_buff(dev, &no_of_mac_addr); + + if (no_of_mac_addr == 0 || !addr) { + hddLog(LOG1, + FL("Platform Driver Doesn't have wlan mac addresses")); + return -EINVAL; + } + + if (no_of_mac_addr > max_mac_addr) + no_of_mac_addr = max_mac_addr; + + vos_mem_copy(&customMacAddr, addr, mac_addr_size); + + for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { + buf = ini->intfMacAddr[iter].bytes; + vos_mem_copy(buf, addr, VOS_MAC_ADDR_SIZE); + hddLog(LOG1, FL(MAC_ADDRESS_STR), MAC_ADDR_ARRAY(buf)); + } + + status = sme_SetCustomMacAddr(customMacAddr); + + if (status != VOS_STATUS_SUCCESS) + return -EAGAIN; + + if (no_of_mac_addr < max_mac_addr) + hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - + no_of_mac_addr); + return 0; +} + +/** + * hdd_initialize_mac_address() - API to get wlan mac addresses + * @hdd_ctx: HDD Context + * + * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver is + * provisioned with mac addresses, driver uses it, else it will use wlan_mac.bin + * to update HW MAC addresses. + * + * Return: None + */ +static void hdd_initialize_mac_address(hdd_context_t *hdd_ctx) +{ + VOS_STATUS status; + int ret; + + ret = hdd_cnss_wlan_mac(hdd_ctx); + + if (ret == 0) + return; + + hddLog(LOGW, FL("Can't update mac config via platform driver ret:%d"), + ret); + + status = hdd_update_mac_config(hdd_ctx); + if (status != VOS_STATUS_SUCCESS) + hddLog(LOGW, + FL("can't update mac config, using MAC from ini file")); +} /**--------------------------------------------------------------------------- \brief hdd_wlan_startup() - HDD init function @@ -14303,12 +14413,7 @@ int hdd_wlan_startup(struct device *dev, v_VOID_t *hif_sc) goto err_wiphy_unregister; } - if ( VOS_STATUS_SUCCESS != hdd_update_mac_config( pHddCtx ) ) - { - hddLog(VOS_TRACE_LEVEL_WARN, - "%s: can't update mac config, using MAC from ini file", - __func__); - } + hdd_initialize_mac_address(pHddCtx); { eHalStatus halStatus; diff --git a/CORE/VOSS/inc/vos_cnss.h b/CORE/VOSS/inc/vos_cnss.h index 5978a8012e83..21fa7fab053d 100644 --- a/CORE/VOSS/inc/vos_cnss.h +++ b/CORE/VOSS/inc/vos_cnss.h @@ -44,6 +44,12 @@ enum cnss_bus_width_type { CNSS_BUS_WIDTH_HIGH }; +static inline u8 *vos_get_cnss_wlan_mac_buff(struct device *dev, uint32_t *num) +{ + *num = 0; + return NULL; +} + static inline void vos_init_work(struct work_struct *work, work_func_t func) { INIT_WORK(work, func); @@ -215,11 +221,17 @@ static inline int vos_unregister_oob_irq_handler(void *pm_oob) static inline void vos_dump_stack (struct task_struct *task) { } -#else +#else /* END WLAN_OPEN_SOURCE and !CONFIG_CNSS */ static inline void vos_dump_stack (struct task_struct *task) { cnss_dump_stack(task); } + +static inline u8 *vos_get_cnss_wlan_mac_buff(struct device *dev, uint32_t *num) +{ + return cnss_get_wlan_mac_address(dev, num); +} + static inline void vos_init_work(struct work_struct *work, work_func_t func) { cnss_init_work(work, func); @@ -551,7 +563,7 @@ static inline int vos_unregister_oob_irq_handler(void *pm_oob) { return -ENOSYS; } -#endif -#endif +#endif /*END CONFIG_CNSS_SDIO */ +#endif /* CONFIG_CNSS */ #endif/* _VOS_CNSS_H */ |
