diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 4bc370764040..802f9ebb8208 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -3197,4 +3197,32 @@ void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool disconnecting); int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, uint32_t bandwidth); +/** + * hdd_wlan_get_version() - Get version information + * @hdd_ctx: Global HDD context + * @version_len: length of the version buffer size + * @version: the buffer to the version string + * + * This function is used to get Wlan Driver, Firmware, Hardware Version + * & the Board related information. + * + * Return: the length of the version string + */ +uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, + const size_t version_len, uint8_t *version); + +/** + * hdd_update_hw_sw_info() - API to update the HW/SW information + * @hdd_ctx: Global HDD context + * + * API to update the HW and SW information in the driver + * + * Note: + * All the version/revision information would only be retrieved after + * firmware download + * + * Return: None + */ +void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx); + #endif /* end #if !defined(WLAN_HDD_MAIN_H) */ diff --git a/core/hdd/inc/wlan_hdd_wext.h b/core/hdd/inc/wlan_hdd_wext.h index 88f762185b2d..5ae4bdbde59b 100644 --- a/core/hdd/inc/wlan_hdd_wext.h +++ b/core/hdd/inc/wlan_hdd_wext.h @@ -197,9 +197,6 @@ void hdd_unregister_wext(struct net_device *dev); */ void hdd_register_wext(struct net_device *dev); -void hdd_wlan_get_version(struct hdd_context *hdd_ctx, - union iwreq_data *wrqu, char *extra); - void hdd_wlan_get_stats(struct hdd_adapter *adapter, uint16_t *length, char *buffer, uint16_t buf_len); void hdd_wlan_list_fw_profile(uint16_t *length, diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 7009996eb5d1..3a329b57c0ed 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -4983,7 +4983,8 @@ __iw_softap_version(struct net_device *dev, if (0 != ret) return ret; - hdd_wlan_get_version(hdd_ctx, wrqu, extra); + wrqu->data.length = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, + extra); hdd_exit(); return 0; } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index df6c10b52205..7d1856378925 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2354,18 +2354,13 @@ static void hdd_disable_power_management(void) hif_disable_power_management(hif_ctx); } -/** - * hdd_update_hw_sw_info() - API to update the HW/SW information - * - * API to update the HW and SW information in the driver - * - * Return: None - */ -static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) +void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) { void *hif_sc; size_t target_hw_name_len; const char *target_hw_name; + uint8_t *buf; + uint32_t buf_len; hif_sc = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_sc) { @@ -2373,12 +2368,7 @@ static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) return; } - /* - * target hw version/revision would only be retrieved after firmware - * download - */ - hif_get_hw_info(hif_sc, - &hdd_ctx->target_hw_version, + hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, &hdd_ctx->target_hw_revision, &target_hw_name); @@ -2391,8 +2381,12 @@ static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, target_hw_name_len); - /* Get the wlan hw/fw version */ - hdd_wlan_get_version(hdd_ctx, NULL, NULL); + buf = qdf_mem_malloc(WE_MAX_STR_LEN); + if (buf) { + buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); + hdd_info("%s", buf); + qdf_mem_free(buf); + } } /** @@ -2467,6 +2461,37 @@ hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) } } +uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, + const size_t version_len, uint8_t *version) +{ + uint32_t size; + uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; + + if (!hdd_ctx) { + hdd_err("Invalid context, HDD context is null"); + return 0; + } + + if (!version && version_len == 0) { + hdd_err("Invalid buffer pointr or buffer len\n"); + return 0; + } + + msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; + mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; + siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; + crmid = hdd_ctx->target_fw_version & 0x7fff; + sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; + + size = scnprintf(version, version_len, + "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s", + QWLAN_VERSIONSTR, + msp_id, mspid, siid, crmid, sub_id, + hdd_ctx->target_hw_name); + + return size; +} + #ifdef IPA_OFFLOAD /** * hdd_update_ipa_component_config() - update ipa config diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index e9cb4c8a089f..3ceeac715436 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -1386,7 +1386,7 @@ QDF_STATUS hdd_wlan_re_init(void) goto err_re_init; } - hdd_wlan_get_version(hdd_ctx, NULL, NULL); + hdd_update_hw_sw_info(hdd_ctx); wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, WLAN_SVC_FW_CRASHED_IND, NULL, 0); diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index 3b889049f44b..37967862c060 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -3288,60 +3288,6 @@ int hdd_wlan_dump_stats(struct hdd_adapter *adapter, int value) return ret; } -/** - * hdd_wlan_get_version() - Get driver version information - * @hdd_ctx: Global HDD context - * @wrqu: Pointer to IOCTL REQUEST Data. - * @extra: Pointer to destination buffer - * - * This function is used to get Wlan Driver, Firmware, & Hardware - * Version information. If @wrqu and @extra are specified, then the - * version string is returned. Otherwise it is simply printed to the - * kernel log. - * - * Return: none - */ -void hdd_wlan_get_version(struct hdd_context *hdd_ctx, union iwreq_data *wrqu, - char *extra) -{ - tSirVersionString wcnss_sw_version; - const char *swversion; - const char *hwversion; - uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; - - if (!hdd_ctx) { - hdd_err("Invalid context, HDD context is null"); - goto error; - } - - snprintf(wcnss_sw_version, sizeof(wcnss_sw_version), "%08x", - hdd_ctx->target_fw_version); - - swversion = wcnss_sw_version; - msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; - mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; - siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; - crmid = hdd_ctx->target_fw_version & 0x7fff; - sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; - - hwversion = hdd_ctx->target_hw_name; - - if (wrqu && extra) { - wrqu->data.length = - scnprintf(extra, WE_MAX_STR_LEN, - "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s", - QWLAN_VERSIONSTR, - msp_id, mspid, siid, crmid, - sub_id, hwversion); - } else { - pr_info("Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s\n", - QWLAN_VERSIONSTR, - msp_id, mspid, siid, crmid, sub_id, hwversion); - } -error: - return; -} - /** * hdd_wlan_get_ibss_peer_info() - Print IBSS peer information * @adapter: Adapter upon which the IBSS client is active @@ -6358,7 +6304,8 @@ static int __iw_get_char_setnone(struct net_device *dev, switch (sub_cmd) { case WE_WLAN_VERSION: { - hdd_wlan_get_version(hdd_ctx, wrqu, extra); + wrqu->data.length = hdd_wlan_get_version(hdd_ctx, + WE_MAX_STR_LEN, extra); break; }