From ca3471eeecc659be6174ce29a26665f7ce0fb515 Mon Sep 17 00:00:00 2001 From: Priyadarshnee Srinivasan Date: Fri, 9 Apr 2021 12:02:19 +0530 Subject: [PATCH] qcacmn: Avoid mem copy for different structure types The regulatory wireless modes are populated by FW in wlan_psoc_hal_reg_capability during service ready. This is copied to the host regulatory data structure reg_cap. To accommodate the 802.11BE wireless modes, data type of wireless_modes in reg_cap is changed from uint32_t to uint64_t, though FW still advertises as a 32 bit flag. As the wireless mode data type of host and FW are different, structure copy using qdf_mem_copy does not work as expected and it corrupts the adjacent elements. Hence copy the elements individually from wlan_psoc_hal_reg_capability to wlan_psoc_host_hal_reg_capabilities_ext structure. Also, typecast the wireless_modes to 64 bit before storing in the host structure. CRs-Fixed: 2901260 Change-Id: I42c8de831f97ec691c9b8cb50b8982662e39e7d9 --- .../init_deinit/src/service_ready_util.c | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/target_if/init_deinit/src/service_ready_util.c b/target_if/init_deinit/src/service_ready_util.c index 222d6fb977..b393073eb8 100644 --- a/target_if/init_deinit/src/service_ready_util.c +++ b/target_if/init_deinit/src/service_ready_util.c @@ -625,6 +625,33 @@ static void init_deinit_update_phy_reg_cap(struct wlan_objmgr_psoc *psoc, } #endif +/** + * init_deinit_fill_host_reg_cap() - Fill the host regulatory cap + * with target hal reg capabilities. + * @cap: Pointer to wlan_psoc_hal_reg_capability where FW capabilities + * are extracted. + * @reg_cap: Pointer to wlan_psoc_host_hal_reg_capabilities_ext, host reg + * capabilities to be filled. + * + * Return - None + */ +static void +init_deinit_fill_host_reg_cap(struct wlan_psoc_hal_reg_capability *cap, + struct wlan_psoc_host_hal_reg_capabilities_ext + *reg_cap) +{ + reg_cap->phy_id = 0; + reg_cap->eeprom_reg_domain = cap->eeprom_rd; + reg_cap->eeprom_reg_domain_ext = cap->eeprom_rd_ext; + reg_cap->regcap1 = cap->regcap1; + reg_cap->regcap2 = cap->regcap2; + reg_cap->wireless_modes = (uint64_t)cap->wireless_modes; + reg_cap->low_2ghz_chan = cap->low_2ghz_chan; + reg_cap->high_2ghz_chan = cap->high_2ghz_chan; + reg_cap->low_5ghz_chan = cap->low_5ghz_chan; + reg_cap->high_5ghz_chan = cap->high_5ghz_chan; +} + int init_deinit_populate_phy_reg_cap(struct wlan_objmgr_psoc *psoc, wmi_unified_t handle, uint8_t *event, struct tgt_info *info, @@ -645,10 +672,8 @@ int init_deinit_populate_phy_reg_cap(struct wlan_objmgr_psoc *psoc, } info->service_ext_param.num_phy = 1; num_phy_reg_cap = 1; - reg_cap[0].phy_id = 0; - qdf_mem_copy(&(reg_cap[0].eeprom_reg_domain), &cap, - sizeof(struct wlan_psoc_hal_reg_capability)); - target_if_debug("FW wireless modes 0x%x", + init_deinit_fill_host_reg_cap(&cap, ®_cap[0]); + target_if_debug("FW wireless modes 0x%llx", reg_cap[0].wireless_modes); } else { num_phy_reg_cap = info->service_ext_param.num_phy;