From patchwork Wed Feb 9 05:58:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 107084 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 81D15A034E; Wed, 9 Feb 2022 06:58:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7538E41144; Wed, 9 Feb 2022 06:58:16 +0100 (CET) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 6F3FD410F3 for ; Wed, 9 Feb 2022 06:58:15 +0100 (CET) Received: by mail-pj1-f41.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso4112287pjt.4 for ; Tue, 08 Feb 2022 21:58:15 -0800 (PST) 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=mOH/x4DSWZaprSqa2VNooyyMYNNjNxOCbM3k7IQM3lw=; b=KNGwfHOADAyOLuUtga8+WDzp0Zm+l9ow3tq5g6zdFo6cbP72uHAO7R4fttdKz+hQUK AdKEnUl9HOSR9J2YvvLveLyLFXLFHJHBDUZRJZLIcVA7yxgTLStlWf0FxzZtgi3jHgxk dKHABfOiRfFRTJu9ZXlPBSr0GhmWCZQhW3R1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=mOH/x4DSWZaprSqa2VNooyyMYNNjNxOCbM3k7IQM3lw=; b=1mDk8W1N7visan15Iba8L/FjAr/emBsNbhriCnOIVtxTUlp2x5731dmVAVBkzSZot1 83p/1fwMyq1YKlo/OBNcRVKntxov16hotnXXRIHmedCLTUOVzPQIdwfFksG4OHUpHfqq rMx3HzmItgsBCUcKr0wusTxfQGhmtPntxssyc4B2mVO6hBT1xORr3it3U1BxMmAiiE7n 4VYbWxsRQwhv/a7Y5FTYycUknxL2LbixvU4C4WmaPbfnjCpNhD1P8uEBnFT61x7VTMyQ m6XcjrSysAeP6DVT7qhtwwKBXULssVApQkkXk4z1f2pvB4rRBywWG5xi6RvjojoXhwAp 0oFA== X-Gm-Message-State: AOAM531j80wz2tQL6MpcN972mJnvg4b7zyXzIkxubewoKbVjLZpNK+3l 4P279hrUU53tPSkpw5on9MGAfIOFreYqU2bJvtrkmRLQcB1aTr5k6/XgvbsLRUGs/zkWvpLSnP3 LsRz6C9PWneYTwZhbUs4Qv2vs65oKNGdQ2oAFuYWRBG5BRMV3bNpfAZkC8XpqqnZaaw== X-Google-Smtp-Source: ABdhPJwRX37G25YFvxx3r0Bg4gL62NaOxs8OIzUKrd3QkBR3gaWLYGo228YOD6ojP9enuUJxYXIynA== X-Received: by 2002:a17:90b:3eca:: with SMTP id rm10mr1656020pjb.211.1644386294369; Tue, 08 Feb 2022 21:58:14 -0800 (PST) Received: from localhost.localdomain ([136.52.99.246]) by smtp.gmail.com with ESMTPSA id k16sm18092199pfu.140.2022.02.08.21.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 21:58:14 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: stable@dpdk.org, Somnath Kotur , Kalesh AP Subject: [PATCH] net/bnxt: fix ring calculation for representors Date: Tue, 8 Feb 2022 21:58:11 -0800 Message-Id: <20220209055811.88850-1-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 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 Currently the Tx and Rx ring count for representors is fixed. It does not consider the number of rings created for the parent function. And that can cause issues not only during initialization but while running traffic. Instead check the number of rings created for the parent function while configuring the ring resources for representors. Fixes: 322bd6e70272 ("net/bnxt: add port representor infrastructure") Cc: stable@dpdk.org Signed-off-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Kalesh AP --- drivers/net/bnxt/bnxt.h | 2 +- drivers/net/bnxt/bnxt_reps.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 433f1c80be..0cbb58b2cf 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -831,7 +831,7 @@ struct bnxt { uint16_t max_tx_rings; uint16_t max_rx_rings; #define MAX_STINGRAY_RINGS 236U -#define BNXT_MAX_VF_REP_RINGS 8 +#define BNXT_MAX_VF_REP_RINGS 8U uint16_t max_nq_rings; uint16_t max_l2_ctx; diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index 5e140f0cdb..9ae8848382 100644 --- a/drivers/net/bnxt/bnxt_reps.c +++ b/drivers/net/bnxt/bnxt_reps.c @@ -548,7 +548,8 @@ int bnxt_rep_dev_info_get_op(struct rte_eth_dev *eth_dev, dev_info->max_mac_addrs = parent_bp->max_l2_ctx; dev_info->max_hash_mac_addrs = 0; - max_rx_rings = BNXT_MAX_VF_REP_RINGS; + max_rx_rings = RTE_MIN(parent_bp->rx_nr_rings, BNXT_MAX_VF_REP_RINGS); + /* For the sake of symmetry, max_rx_queues = max_tx_queues */ dev_info->max_rx_queues = max_rx_rings; dev_info->max_tx_queues = max_rx_rings; @@ -629,10 +630,10 @@ int bnxt_rep_rx_queue_setup_op(struct rte_eth_dev *eth_dev, struct rte_mbuf **buf_ring; int rc = 0; - if (queue_idx >= BNXT_MAX_VF_REP_RINGS) { + if (queue_idx >= rep_bp->rx_nr_rings) { PMD_DRV_LOG(ERR, "Cannot create Rx ring %d. %d rings available\n", - queue_idx, BNXT_MAX_VF_REP_RINGS); + queue_idx, rep_bp->rx_nr_rings); return -EINVAL; } @@ -729,10 +730,10 @@ int bnxt_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev, struct bnxt_tx_queue *parent_txq, *txq; struct bnxt_vf_rep_tx_queue *vfr_txq; - if (queue_idx >= BNXT_MAX_VF_REP_RINGS) { + if (queue_idx >= rep_bp->rx_nr_rings) { PMD_DRV_LOG(ERR, "Cannot create Tx rings %d. %d rings available\n", - queue_idx, BNXT_MAX_VF_REP_RINGS); + queue_idx, rep_bp->rx_nr_rings); return -EINVAL; } @@ -805,10 +806,10 @@ int bnxt_rep_stats_get_op(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { struct bnxt_representor *rep_bp = eth_dev->data->dev_private; - int i; + unsigned int i; memset(stats, 0, sizeof(*stats)); - for (i = 0; i < BNXT_MAX_VF_REP_RINGS; i++) { + for (i = 0; i < rep_bp->rx_nr_rings; i++) { stats->obytes += rep_bp->tx_bytes[i]; stats->opackets += rep_bp->tx_pkts[i]; stats->ibytes += rep_bp->rx_bytes[i]; @@ -828,9 +829,9 @@ int bnxt_rep_stats_get_op(struct rte_eth_dev *eth_dev, int bnxt_rep_stats_reset_op(struct rte_eth_dev *eth_dev) { struct bnxt_representor *rep_bp = eth_dev->data->dev_private; - int i; + unsigned int i; - for (i = 0; i < BNXT_MAX_VF_REP_RINGS; i++) { + for (i = 0; i < rep_bp->rx_nr_rings; i++) { rep_bp->tx_pkts[i] = 0; rep_bp->tx_bytes[i] = 0; rep_bp->rx_pkts[i] = 0;