From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B06B1A00C2; Sat, 25 Apr 2020 08:14:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C7CEF1C1C4; Sat, 25 Apr 2020 08:14:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 33EE81C1AF for ; Sat, 25 Apr 2020 08:14:07 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03P66IMt004691; Fri, 24 Apr 2020 23:14:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=i/UO7XltcdkL9T5mm8k/UOJ22SNXqCcLfqqe+EKO1Y8=; b=HhuqFTcnWeaDVwlwdMFt/Zgsy4GkcaUU9l92eGRgeeILXmrTjmuMrp0imrjc4dq5pJuv 865xab/nQvSelsRJrE4diCwIHrAFpe+R8WiYWm9oBIESuVO1X+9cX90B6pIFNbrSWWwJ +xAXo8Q4IVtAGxkeIKx0JpqAaKIqtaAGBSOGrNLHj3m3Z2mWdLXuN8LV35fNWBUxvHO4 3yR6CXc0X2TEuCheBRVjoHoAo4XRRzlz6yvoTGSIR1QhwQNxiuy5zq4eTz3LSVLkdJaK Ej6Vjd/QYcryDk8bQErc/h6GR9X9MwOq/dJhcmaGIOWOwfn2NLEJJo/cnC1NnSx1g+C+ mg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 30kvf7vkpx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 24 Apr 2020 23:14:06 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 24 Apr 2020 23:14:04 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 24 Apr 2020 23:14:04 -0700 Received: from irv1user08.caveonetworks.com (unknown [10.104.116.105]) by maili.marvell.com (Postfix) with ESMTP id 83B853F703F; Fri, 24 Apr 2020 23:14:04 -0700 (PDT) Received: (from rmody@localhost) by irv1user08.caveonetworks.com (8.14.4/8.14.4/Submit) id 03P6E4hD018652; Fri, 24 Apr 2020 23:14:04 -0700 X-Authentication-Warning: irv1user08.caveonetworks.com: rmody set sender to rmody@marvell.com using -f From: Rasesh Mody To: , , CC: Rasesh Mody , , "Yash Sharma" , Igor Russkikh Date: Fri, 24 Apr 2020 23:13:47 -0700 Message-ID: <20200425061347.18217-2-rmody@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200425061347.18217-1-rmody@marvell.com> References: <20200425061347.18217-1-rmody@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-25_01:2020-04-24, 2020-04-25 signatures=0 Subject: [dpdk-dev] [PATCH 2/2] net/qede: add support for get FW version X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for get firmware version operation. Get and dump multi boot image (MBI) version as part of get firmware version string along with Management fimrware (MFW) version. Use qede_fw_version_get() for PMD info logs. Signed-off-by: Yash Sharma Signed-off-by: Rasesh Mody Signed-off-by: Igor Russkikh --- --- drivers/net/qede/base/ecore_mcp.c | 37 +++++++++++ drivers/net/qede/base/ecore_mcp_api.h | 12 ++++ drivers/net/qede/qede_ethdev.c | 96 ++++++++++++++++++--------- drivers/net/qede/qede_if.h | 9 +++ drivers/net/qede/qede_main.c | 3 + 5 files changed, 126 insertions(+), 31 deletions(-) diff --git a/drivers/net/qede/base/ecore_mcp.c b/drivers/net/qede/base/ecore_mcp.c index 7518765a0..4dc22acd4 100644 --- a/drivers/net/qede/base/ecore_mcp.c +++ b/drivers/net/qede/base/ecore_mcp.c @@ -2245,6 +2245,43 @@ enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn, return ECORE_SUCCESS; } +int ecore_mcp_get_mbi_ver(struct ecore_hwfn *p_hwfn, + struct ecore_ptt *p_ptt, u32 *p_mbi_ver) +{ + u32 nvm_cfg_addr, nvm_cfg1_offset, mbi_ver_addr; + +#ifndef ASIC_ONLY + if (CHIP_REV_IS_EMUL(p_hwfn->p_dev) && !ecore_mcp_is_init(p_hwfn)) { + DP_INFO(p_hwfn, "Emulation: Can't get MBI version\n"); + return -EOPNOTSUPP; + } +#endif + + if (IS_VF(p_hwfn->p_dev)) + return -EINVAL; + + /* Read the address of the nvm_cfg */ + nvm_cfg_addr = ecore_rd(p_hwfn, p_ptt, MISC_REG_GEN_PURP_CR0); + if (!nvm_cfg_addr) { + DP_NOTICE(p_hwfn, false, "Shared memory not initialized\n"); + return -EINVAL; + } + + /* Read the offset of nvm_cfg1 */ + nvm_cfg1_offset = ecore_rd(p_hwfn, p_ptt, nvm_cfg_addr + 4); + + mbi_ver_addr = MCP_REG_SCRATCH + nvm_cfg1_offset + + offsetof(struct nvm_cfg1, glob) + offsetof(struct nvm_cfg1_glob, + mbi_version); + *p_mbi_ver = + ecore_rd(p_hwfn, p_ptt, + mbi_ver_addr) & (NVM_CFG1_GLOB_MBI_VERSION_0_MASK | + NVM_CFG1_GLOB_MBI_VERSION_1_MASK | + NVM_CFG1_GLOB_MBI_VERSION_2_MASK); + + return 0; +} + enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, u32 *p_media_type) diff --git a/drivers/net/qede/base/ecore_mcp_api.h b/drivers/net/qede/base/ecore_mcp_api.h index 7327074fd..b9ff0cd5d 100644 --- a/drivers/net/qede/base/ecore_mcp_api.h +++ b/drivers/net/qede/base/ecore_mcp_api.h @@ -587,6 +587,18 @@ enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn, u32 *p_mfw_ver, u32 *p_running_bundle_id); +/** + * @brief Get the MBI version value + * + * @param p_hwfn + * @param p_ptt + * @param p_mbi_ver - A pointer to a variable to be filled with the MBI version. + * + * @return int - 0 - operation was successful. + */ +int ecore_mcp_get_mbi_ver(struct ecore_hwfn *p_hwfn, + struct ecore_ptt *p_ptt, u32 *p_mbi_ver); + /** * @brief Get media type value of the port. * diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index 19d2e9619..3005495b4 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -232,6 +232,58 @@ static const struct rte_qede_xstats_name_off qede_rxq_xstats_strings[] = { offsetof(struct qede_rx_queue, rx_alloc_errors)} }; +/* Get FW version string based on fw_size */ +static int +qede_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size) +{ + struct qede_dev *qdev = dev->data->dev_private; + struct ecore_dev *edev = &qdev->edev; + struct qed_dev_info *info = &qdev->dev_info.common; + static char ver_str[QEDE_PMD_DRV_VER_STR_SIZE]; + size_t size; + + if (fw_ver == NULL) + return 0; + + if (IS_PF(edev)) + snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s", + QEDE_PMD_FW_VERSION); + else + snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%d.%d.%d.%d", + info->fw_major, info->fw_minor, + info->fw_rev, info->fw_eng); + size = strlen(ver_str); + if (size + 1 <= fw_size) /* Add 1 byte for "\0" */ + strlcpy(fw_ver, ver_str, fw_size); + else + return (size + 1); + + snprintf(ver_str + size, (QEDE_PMD_DRV_VER_STR_SIZE - size), + " MFW: %d.%d.%d.%d", + GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_3), + GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_2), + GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_1), + GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_0)); + size = strlen(ver_str); + if (size + 1 <= fw_size) + strlcpy(fw_ver, ver_str, fw_size); + + if (fw_size <= 32) + goto out; + + snprintf(ver_str + size, (QEDE_PMD_DRV_VER_STR_SIZE - size), + " MBI: %d.%d.%d", + GET_MFW_FIELD(info->mbi_version, QED_MBI_VERSION_2), + GET_MFW_FIELD(info->mbi_version, QED_MBI_VERSION_1), + GET_MFW_FIELD(info->mbi_version, QED_MBI_VERSION_0)); + size = strlen(ver_str); + if (size + 1 <= fw_size) + strlcpy(fw_ver, ver_str, fw_size); + +out: + return 0; +} + static void qede_interrupt_action(struct ecore_hwfn *p_hwfn) { ecore_int_sp_dpc((osal_int_ptr_t)(p_hwfn)); @@ -274,47 +326,27 @@ qede_alloc_etherdev(struct qede_dev *qdev, struct qed_dev_eth_info *info) qdev->ops = qed_ops; } -static void qede_print_adapter_info(struct qede_dev *qdev) +static void qede_print_adapter_info(struct rte_eth_dev *dev) { + struct qede_dev *qdev = dev->data->dev_private; struct ecore_dev *edev = &qdev->edev; - struct qed_dev_info *info = &qdev->dev_info.common; static char ver_str[QEDE_PMD_DRV_VER_STR_SIZE]; DP_INFO(edev, "**************************************************\n"); - DP_INFO(edev, " DPDK version\t\t\t: %s\n", rte_version()); - DP_INFO(edev, " Chip details\t\t\t: %s %c%d\n", + DP_INFO(edev, " %-20s: %s\n", "DPDK version", rte_version()); + DP_INFO(edev, " %-20s: %s %c%d\n", "Chip details", ECORE_IS_BB(edev) ? "BB" : "AH", 'A' + edev->chip_rev, (int)edev->chip_metal); snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s", QEDE_PMD_DRV_VERSION); - DP_INFO(edev, " Driver version\t\t\t: %s\n", ver_str); - + DP_INFO(edev, " %-20s: %s\n", "Driver version", ver_str); snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s", QEDE_PMD_BASE_VERSION); - DP_INFO(edev, " Base version\t\t\t: %s\n", ver_str); - - if (!IS_VF(edev)) - snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s", - QEDE_PMD_FW_VERSION); - else - snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%d.%d.%d.%d", - info->fw_major, info->fw_minor, - info->fw_rev, info->fw_eng); - DP_INFO(edev, " Firmware version\t\t\t: %s\n", ver_str); - - snprintf(ver_str, MCP_DRV_VER_STR_SIZE, - "%d.%d.%d.%d", - (info->mfw_rev & QED_MFW_VERSION_3_MASK) >> - QED_MFW_VERSION_3_OFFSET, - (info->mfw_rev & QED_MFW_VERSION_2_MASK) >> - QED_MFW_VERSION_2_OFFSET, - (info->mfw_rev & QED_MFW_VERSION_1_MASK) >> - QED_MFW_VERSION_1_OFFSET, - (info->mfw_rev & QED_MFW_VERSION_0_MASK) >> - QED_MFW_VERSION_0_OFFSET); - DP_INFO(edev, " Management Firmware version\t: %s\n", ver_str); - DP_INFO(edev, " Firmware file\t\t\t: %s\n", qede_fw_file); + DP_INFO(edev, " %-20s: %s\n", "Base version", ver_str); + qede_fw_version_get(dev, ver_str, sizeof(ver_str)); + DP_INFO(edev, " %-20s: %s\n", "Firmware version", ver_str); + DP_INFO(edev, " %-20s: %s\n", "Firmware file", qede_fw_file); DP_INFO(edev, "**************************************************\n"); } @@ -2351,6 +2383,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = { .filter_ctrl = qede_dev_filter_ctrl, .udp_tunnel_port_add = qede_udp_dst_port_add, .udp_tunnel_port_del = qede_udp_dst_port_del, + .fw_version_get = qede_fw_version_get, }; static const struct eth_dev_ops qede_eth_vf_dev_ops = { @@ -2391,6 +2424,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = { .mac_addr_add = qede_mac_addr_add, .mac_addr_remove = qede_mac_addr_remove, .mac_addr_set = qede_mac_addr_set, + .fw_version_get = qede_fw_version_get, }; static void qede_update_pf_params(struct ecore_dev *edev) @@ -2544,7 +2578,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) qede_alloc_etherdev(adapter, &dev_info); if (do_once) { - qede_print_adapter_info(adapter); + qede_print_adapter_info(eth_dev); do_once = false; } @@ -2652,7 +2686,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) err: if (do_once) { - qede_print_adapter_info(adapter); + qede_print_adapter_info(eth_dev); do_once = false; } return rc; diff --git a/drivers/net/qede/qede_if.h b/drivers/net/qede/qede_if.h index 02feaba16..858cd51d5 100644 --- a/drivers/net/qede/qede_if.h +++ b/drivers/net/qede/qede_if.h @@ -45,6 +45,15 @@ struct qed_dev_info { bool smart_an; + /* MBI version */ + uint32_t mbi_version; +#define QED_MBI_VERSION_0_MASK 0x000000FF +#define QED_MBI_VERSION_0_OFFSET 0 +#define QED_MBI_VERSION_1_MASK 0x0000FF00 +#define QED_MBI_VERSION_1_OFFSET 8 +#define QED_MBI_VERSION_2_MASK 0x00FF0000 +#define QED_MBI_VERSION_2_OFFSET 16 + /* Out param for qede */ bool vxlan_enable; bool gre_enable; diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c index 4eb79d0fb..257646e73 100644 --- a/drivers/net/qede/qede_main.c +++ b/drivers/net/qede/qede_main.c @@ -390,6 +390,9 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info) ecore_mcp_get_mfw_ver(ECORE_LEADING_HWFN(edev), ptt, &dev_info->mfw_rev, NULL); + ecore_mcp_get_mbi_ver(ECORE_LEADING_HWFN(edev), ptt, + &dev_info->mbi_version); + ecore_mcp_get_flash_size(ECORE_LEADING_HWFN(edev), ptt, &dev_info->flash_size); -- 2.18.1