From patchwork Mon Apr 19 19:28:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 91784 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E9BF1A0548; Mon, 19 Apr 2021 21:28:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 231254145F; Mon, 19 Apr 2021 21:28:50 +0200 (CEST) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by mails.dpdk.org (Postfix) with ESMTP id 3BD9B413DE for ; Mon, 19 Apr 2021 21:28:48 +0200 (CEST) Received: by mail-pg1-f181.google.com with SMTP id m12so4249109pgr.9 for ; Mon, 19 Apr 2021 12:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:mime-version; bh=iupnIU0NbOkqMGogWOXZcVtlY5on6N4lV7C9BpLaMqs=; b=Df4yx/qmW+LiRxvt8l4FUk7f6SvIVq6r+5Lf/AT8L5Q06RQAJqQGYz0NRY5+l/C7Am 6gpbpTNIRpBXHbHBY+AiWJmc7i9JYIkriJZlmDn77AfAvSgynSfToqzQrOYUJL08qQZP 1jgMZIqHU/vnzc0auC65sUy30l1wMojUf9Spo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=iupnIU0NbOkqMGogWOXZcVtlY5on6N4lV7C9BpLaMqs=; b=B31eaAJXr9Hw3hE3bgva1G+Oqyca8zUGbm3WtkWaSzNY+NgcFvOgJQsxmIS1c5Kqo5 94fAlfaUKTqhR1VQ3gfWer+RDNAyhtabpNh45zjgMZelUaI7h3x6Pp9pN8AF5EE++/p9 4rtxC8PLWHMg1CrLle0E/qeka2HI46yi38a7tYGuI8lJQJgK31u5ioFMkd2RVzymZYae wJv92moKweUvPa6P/cZVb4FndofEQ2XxRBqP/MXKwYpz+WwwXEoeefJjY8s3BVUt5qrg TSjJxEVzb9URK0vkA/ap0wIX0tbTB/Sq67sJLJ1KACj3vparOmMvGv8B5IW2hjd2Ulut ewLg== X-Gm-Message-State: AOAM530xwwd8tTz/ktodUkBdzZfIIY0EoF486SoRIauE4hk5nn7LIskR 6iGkPqhMftfpEiCqXdhen2uF0mVWrENFMrEB6gCto1QmVqY4OezU/+VlVdPS6xBUGVmSOtEDHWa CvynXf3DkH5rNr4RNxFKdbjZ90ZbNPY6BeF8vjALVvd3KrW7t8sFfGD8sd7hgbvI= X-Google-Smtp-Source: ABdhPJweanUFYAK4q1wAI7d1+HiVx4cHVQR4thLvzfnTEMcp1TwI/3VlS+K4ujrzb6YhNfxbAgxuxg== X-Received: by 2002:a62:cf83:0:b029:24a:935:e2f1 with SMTP id b125-20020a62cf830000b029024a0935e2f1mr21120250pfg.8.1618860526754; Mon, 19 Apr 2021 12:28:46 -0700 (PDT) Received: from C02VPB22HTD6.wifi.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id u6sm12561589pfn.168.2021.04.19.12.28.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Apr 2021 12:28:46 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: stable@dpdk.org Date: Mon, 19 Apr 2021 12:28:37 -0700 Message-Id: <20210419192838.45708-1-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH 1/2] net/bnxt: fix resource cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Fix resource cleanup in port close. Once the pointers are freed, set them to NULL. Make sure access to the pointers is validated before use. Fixes: bb81e07323bb ("net/bnxt: support LED on/off") Fixes: 804e746c7b73 ("net/bnxt: add hardware resource manager init code") Fixes: 1d0704f4d793 ("net/bnxt: add device configure operation") Fixes: 698aa7e95325 ("net/bnxt: add code to determine the Tx COS queue") Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure") Fixes: 0bf5a0b5ebb8 ("net/bnxt: add a failure log") Cc: stable@dpdk.org Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 39 +++++++++++++++++++++++++--------- drivers/net/bnxt/bnxt_hwrm.c | 3 +++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 20ca57eae5..dc3b04110f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -219,16 +219,19 @@ uint16_t bnxt_rss_hash_tbl_size(const struct bnxt *bp) static void bnxt_free_parent_info(struct bnxt *bp) { rte_free(bp->parent); + bp->parent = NULL; } static void bnxt_free_pf_info(struct bnxt *bp) { rte_free(bp->pf); + bp->pf = NULL; } static void bnxt_free_link_info(struct bnxt *bp) { rte_free(bp->link_info); + bp->link_info = NULL; } static void bnxt_free_leds_info(struct bnxt *bp) @@ -249,7 +252,9 @@ static void bnxt_free_flow_stats_info(struct bnxt *bp) static void bnxt_free_cos_queues(struct bnxt *bp) { rte_free(bp->rx_cos_queue); + bp->rx_cos_queue = NULL; rte_free(bp->tx_cos_queue); + bp->tx_cos_queue = NULL; } static void bnxt_free_mem(struct bnxt *bp, bool reconfig) @@ -849,9 +854,14 @@ static int bnxt_shutdown_nic(struct bnxt *bp) uint32_t bnxt_get_speed_capabilities(struct bnxt *bp) { - uint32_t link_speed = bp->link_info->support_speeds; + uint32_t link_speed = 0; uint32_t speed_capa = 0; + if (bp->link_info == NULL) + return 0; + + link_speed = bp->link_info->support_speeds; + /* If PAM4 is configured, use PAM4 supported speed */ if (link_speed == 0 && bp->link_info->support_pam4_speeds > 0) link_speed = bp->link_info->support_pam4_speeds; @@ -1293,12 +1303,13 @@ static void bnxt_free_switch_domain(struct bnxt *bp) { int rc = 0; - if (bp->switch_domain_id) { - rc = rte_eth_switch_domain_free(bp->switch_domain_id); - if (rc) - PMD_DRV_LOG(ERR, "free switch domain:%d fail: %d\n", - bp->switch_domain_id, rc); - } + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) + return; + + rc = rte_eth_switch_domain_free(bp->switch_domain_id); + if (rc) + PMD_DRV_LOG(ERR, "free switch domain:%d fail: %d\n", + bp->switch_domain_id, rc); } static void bnxt_ptp_get_current_time(void *arg) @@ -1545,11 +1556,9 @@ bnxt_uninit_locks(struct bnxt *bp) static void bnxt_drv_uninit(struct bnxt *bp) { - bnxt_free_switch_domain(bp); bnxt_free_leds_info(bp); bnxt_free_cos_queues(bp); bnxt_free_link_info(bp); - bnxt_free_pf_info(bp); bnxt_free_parent_info(bp); bnxt_uninit_locks(bp); @@ -1559,6 +1568,7 @@ static void bnxt_drv_uninit(struct bnxt *bp) bp->rx_mem_zone = NULL; bnxt_free_vf_info(bp); + bnxt_free_pf_info(bp); rte_free(bp->grp_info); bp->grp_info = NULL; @@ -1720,6 +1730,10 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) return rc; memset(&new, 0, sizeof(new)); + + if (bp->link_info == NULL) + goto out; + do { /* Retrieve link info from hardware */ rc = bnxt_get_hwrm_link_config(bp, &new); @@ -5748,7 +5762,10 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) bnxt_free_mem(bp, reconfig_dev); bnxt_hwrm_func_buf_unrgtr(bp); - rte_free(bp->pf->vf_req_buf); + if (bp->pf != NULL) { + rte_free(bp->pf->vf_req_buf); + bp->pf->vf_req_buf = NULL; + } rc = bnxt_hwrm_func_driver_unregister(bp, 0); bp->flags &= ~BNXT_FLAG_REGISTERED; @@ -5761,6 +5778,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) bnxt_uninit_ctx_mem(bp); bnxt_free_flow_stats_info(bp); + if (bp->rep_info != NULL) + bnxt_free_switch_domain(bp); bnxt_free_rep_info(bp); rte_free(bp->ptp_cfg); bp->ptp_cfg = NULL; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index a119fc3a0b..242493982c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -795,6 +795,9 @@ void bnxt_free_vf_info(struct bnxt *bp) if (bp->pf->vf_info == NULL) return; + if (bp->pf == NULL) + return; + for (i = 0; i < bp->pf->max_vfs; i++) { rte_free(bp->pf->vf_info[i].vlan_table); bp->pf->vf_info[i].vlan_table = NULL; From patchwork Mon Apr 19 19:28:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 91785 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D0D35A0548; Mon, 19 Apr 2021 21:28:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 27FBA41464; Mon, 19 Apr 2021 21:28:52 +0200 (CEST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 7EDF041462 for ; Mon, 19 Apr 2021 21:28:50 +0200 (CEST) Received: by mail-pl1-f170.google.com with SMTP id v13so4724034ple.9 for ; Mon, 19 Apr 2021 12:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=RJiRoIst12c5Ts9dyJSXQcGaCW9tNnyjBop4WuAh864=; b=BWDFIAdSISfEB55es4KLuaZnjsI00RAFwgImTTGZ22R2caiU8BMUnQA7n0D6JEfx2T 9jLucrW8l4B4iq6MAWyqiKT7OMN88UiMa1ZWPpTPP7W6VnUGop+HSOz0Hdl6222H9jlI N135+TpKf9iwcZ52dTZeVtDH6/8Jjyt5CXXiY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=RJiRoIst12c5Ts9dyJSXQcGaCW9tNnyjBop4WuAh864=; b=QqJV33FNSI+qTHVD7IvBXu8bTNyIr8lykkTG/gdaJTqA8fs5VAlNmha0xaAGlYtR80 rtAutSGMwR6cuwbZ1GthSi5uFw+Ac864r1R0jowX2qd61fvMUvD/DHfG8Gdpn4kbCUSk GIOCZ/WbI4IFbqiciYsnA0p1IWIUimPh056FJ7l7ui4YuQEd1RWtYe0yWz6rSLIIDDoL hWQGZH/H05ssBcHntj8LwIE6yad7sRjJ0BVnVSSQkrRYNJdZ0+DwWqICLHMPQKJ0Bw5l adAwuqARVZdGGNLWKbGNkgdqEpVL0q9RyjVRwxvfEnPxeu/1zVkvCRqidrBDR6D9rVVP sxhA== X-Gm-Message-State: AOAM532gj6mh+NKtkQDWYhtZNDr2XjBbTcWeM2GTSeA+uhQzdfWfhVXX Z3dSoM7fjQlBYpqolD+VI7FPkYoMYJTl5/Bf++AC1AyhaiulH+/PTiSPVUifpvivV1+V/TCXWhe iolfD68dE0FwzbK+k5Z10FD4Dalp3XzuabepuTubVU25bj1LIZxWrZZq34W7DQRQ= X-Google-Smtp-Source: ABdhPJwWOtmk5oe5S3RXcACUErYvGyo5SOCcgaABKM4xP/FBK24xdVQV79C6Nb3+im3mVIhBD5cx5g== X-Received: by 2002:a17:90b:b0e:: with SMTP id bf14mr744155pjb.140.1618860529265; Mon, 19 Apr 2021 12:28:49 -0700 (PDT) Received: from C02VPB22HTD6.wifi.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id u6sm12561589pfn.168.2021.04.19.12.28.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Apr 2021 12:28:48 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Lance Richardson Date: Mon, 19 Apr 2021 12:28:38 -0700 Message-Id: <20210419192838.45708-2-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20210419192838.45708-1-ajit.khaparde@broadcom.com> References: <20210419192838.45708-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH 2/2] net/bnxt: cap max Rx rings for Thor X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" For Thor devices, RSS table can only accommodate 512 Rx queues. When RSS is enabled, Cap the max Rx rings to 512. For non-RSS case, the number will be limited by number of VNICs. Signed-off-by: Ajit Khaparde Reviewed-by: Lance Richardson --- drivers/net/bnxt/bnxt.h | 13 +++++++++++++ drivers/net/bnxt/bnxt_ethdev.c | 7 ++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 05f8804274..263ea86590 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -844,6 +844,7 @@ struct bnxt { static inline uint16_t bnxt_max_rings(struct bnxt *bp) { + struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; uint16_t max_tx_rings = bp->max_tx_rings; uint16_t max_rx_rings = bp->max_rx_rings; uint16_t max_cp_rings = bp->max_cp_rings; @@ -861,6 +862,18 @@ inline uint16_t bnxt_max_rings(struct bnxt *bp) bp->max_stat_ctx / 2U); } + if (BNXT_CHIP_P5(bp)) { + /* RSS table size in Thor is 512. + * Cap max Rx rings to the same value for RSS. + * For non-RSS case cap it to the max VNIC count. + */ + if(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) + max_rx_rings = RTE_MIN(max_rx_rings, + BNXT_RSS_TBL_SIZE_P5); + else + max_rx_rings = RTE_MIN(max_rx_rings, bp->max_vnics); + } + max_tx_rings = RTE_MIN(max_tx_rings, max_rx_rings); if (max_cp_rings > BNXT_NUM_ASYNC_CPR(bp)) max_cp_rings -= BNXT_NUM_ASYNC_CPR(bp); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index dc3b04110f..9da817f487 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -422,12 +422,13 @@ static int bnxt_setup_one_vnic(struct bnxt *bp, uint16_t vnic_id) if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) { int j, nr_ctxs = bnxt_rss_ctxts(bp); + /* RSS table size in Thor is 512. + * Cap max Rx rings to same value + */ if (bp->rx_nr_rings > BNXT_RSS_TBL_SIZE_P5) { PMD_DRV_LOG(ERR, "RxQ cnt %d > reta_size %d\n", bp->rx_nr_rings, BNXT_RSS_TBL_SIZE_P5); - PMD_DRV_LOG(ERR, - "Only queues 0-%d will be in RSS table\n", - BNXT_RSS_TBL_SIZE_P5 - 1); + goto err_out; } rc = 0;