From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BEBF6A0A0A for ; Thu, 20 May 2021 11:55:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B90BE40041; Thu, 20 May 2021 11:55:29 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvacalvio01.broadcom.com [192.19.229.182]) by mails.dpdk.org (Postfix) with ESMTP id 3360D40041 for ; Thu, 20 May 2021 11:55:28 +0200 (CEST) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id DB08924328 for ; Thu, 20 May 2021 02:55:26 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com DB08924328 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1621504527; bh=sYPlnB+NYwxovf1nQLBWTC9CS9hQKAViMG7pMmvih7Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F1wHT/1ner+pj0tpt6evZAKnnDOzHF61TBVVO/zVIs8qVLv0b98Cn8qN9zXp+dEDG h6sGedP8NCSPgGD+ZSXudY6b7pi6HK7GJKkwMXXyrRjXljh4kxz7KgybLheb34fi3H AW4TW7CCHuvTprVeAvIPcC8SiBdfFxeA3Os9zIIQ= From: Kalesh A P To: stable@dpdk.org Date: Thu, 20 May 2021 15:46:50 +0530 Message-Id: <20210520101654.3214-6-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20210520101654.3214-1-kalesh-anakkur.purayil@broadcom.com> References: <20210520101654.3214-1-kalesh-anakkur.purayil@broadcom.com> Subject: [dpdk-stable] [PATCH 19.11 5/9] net/bnxt: fix memory allocation for command response X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Kalesh AP [ upstream commit 4f1d8fdc3f4234857c1e78af564fcfd92f602f70 ] Driver re-allocates memory for the command response buffer when the installed firmware version is newer (and has a larger max response length) than the version of HWRM that was used to build the PMD. This change helps to avoid the re-allocation by allocating the memory for the command response buffer with PAGE_SIZE. Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF") Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde Reviewed-by: Lance Richardson --- drivers/net/bnxt/bnxt_ethdev.c | 2 +- drivers/net/bnxt/bnxt_hwrm.c | 27 ++++----------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 32c4eed..ed02cf0 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -5026,7 +5026,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) rc = bnxt_alloc_hwrm_resources(bp); if (rc) { PMD_DRV_LOG(ERR, - "Failed to allocate hwrm resource rc: %x\n", rc); + "Failed to allocate response buffer rc: %x\n", rc); goto error_free; } rc = bnxt_init_resources(bp, false); diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 12f8107..4e3dfff 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1053,28 +1053,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp, uint32_t timeout) max_resp_len = rte_le_to_cpu_16(resp->max_resp_len); dev_caps_cfg = rte_le_to_cpu_32(resp->dev_caps_cfg); - if (bp->max_resp_len != max_resp_len) { - sprintf(type, "bnxt_hwrm_%04x:%02x:%02x:%02x", - bp->pdev->addr.domain, bp->pdev->addr.bus, - bp->pdev->addr.devid, bp->pdev->addr.function); - - rte_free(bp->hwrm_cmd_resp_addr); - - bp->hwrm_cmd_resp_addr = rte_malloc(type, max_resp_len, 0); - if (bp->hwrm_cmd_resp_addr == NULL) { - rc = -ENOMEM; - goto error; - } - bp->hwrm_cmd_resp_dma_addr = - rte_malloc_virt2iova(bp->hwrm_cmd_resp_addr); - if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) { - PMD_DRV_LOG(ERR, - "Unable to map response buffer to physical memory.\n"); - rc = -ENOMEM; - goto error; - } - bp->max_resp_len = max_resp_len; - } + RTE_VERIFY(max_resp_len <= bp->max_resp_len); + bp->max_resp_len = max_resp_len; if ((dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) && @@ -2484,7 +2464,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp) sprintf(type, "bnxt_hwrm_%04x:%02x:%02x:%02x", pdev->addr.domain, pdev->addr.bus, pdev->addr.devid, pdev->addr.function); - bp->max_resp_len = HWRM_MAX_RESP_LEN; + bp->max_resp_len = BNXT_PAGE_SIZE; bp->hwrm_cmd_resp_addr = rte_malloc(type, bp->max_resp_len, 0); if (bp->hwrm_cmd_resp_addr == NULL) return -ENOMEM; @@ -5106,6 +5086,7 @@ int bnxt_hwrm_poll_ver_get(struct bnxt *bp) int rc = 0; bp->max_req_len = HWRM_MAX_REQ_LEN; + bp->max_resp_len = BNXT_PAGE_SIZE; bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT; HWRM_PREP(req, VER_GET, BNXT_USE_CHIMP_MB); -- 2.10.1