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 3345CA09E9 for ; Tue, 8 Dec 2020 21:12:18 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 998BFC9F8; Tue, 8 Dec 2020 21:11:59 +0100 (CET) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 3EC96C9C4 for ; Tue, 8 Dec 2020 21:11:52 +0100 (CET) Received: by mail-pf1-f194.google.com with SMTP id b26so14951196pfi.3 for ; Tue, 08 Dec 2020 12:11:52 -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:in-reply-to:references :mime-version; bh=0Z81TN4HDoeoBkRjRPCc6n+I5T0kRR8gh9Sgp0NpjY0=; b=IXy236FDeqpCnibeCKAPhkDI3p4+eRZ5cIC9HsS8UPbR4Zn97lj3+s5fJhzcUHfReO OZHtjs+9C8F0KDus96L2kwmYVotFKH5gwP7kQAoONZiaxg1O1/lrjLrjz/Hpg2RHf5Zr l1EMCoam83doOZ3TtOsraUiS+spq84W5yLD9w= 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=0Z81TN4HDoeoBkRjRPCc6n+I5T0kRR8gh9Sgp0NpjY0=; b=JA6IGEkZ0iO2vtJh+DQP3d0nJmQMASIyMw7fuxG+4MVRy2rA0HhnZ232U4TX/xNk1G EDDyxaOnfAfE7L8o11a0KSKHbaFynlzUZoEFNI9rprbDDX36O9lmz0HDsmKIG1P1Q18d IVtIA6s7XvFdmtfxpdcph24NoeLuBYdzUg1A3GoouoL6OMR4fwOg0nkfhGpAyyKcsWx3 4T7FLXqTcevWNsJxQC3eS40t4tSALfEkSadqtqR8jhdjR7j0hpnyvMnH8dDxiTQJ2ZE8 73xBlIOa/cl/fNbsId/PsSRcjTg8p7K4CkUK0RSRcfKT6tiHWr+R26gJffz1ouP2rzS2 s3gA== X-Gm-Message-State: AOAM530jD4jHDPJV+Yy8QrDLQhN3SYUbEdQdTbrEwYQV+jUnZ8c4Ip3g t2TBica8VjEpk3aIXPZWk/JF3wyWG6ed3JWPFHmvPnOn61sJzfUoPyGnAHcVo+rsYmlmMzgPF16 8omNYrXkL X-Google-Smtp-Source: ABdhPJzA5xufxSe13+lMRXGhWMTFTipDMBpO7Ssv5nSNZuTDCZYTlOPEud4hagLlr+h7vgUq8w6bLg== X-Received: by 2002:a62:8fc7:0:b029:19d:dcf9:573e with SMTP id n190-20020a628fc70000b029019ddcf9573emr14092559pfd.61.1607458311379; Tue, 08 Dec 2020 12:11:51 -0800 (PST) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id x10sm5729187pfc.157.2020.12.08.12.11.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Dec 2020 12:11:50 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: Sriharsha Basavapatna , stable@dpdk.org, Somnath Kotur Date: Tue, 8 Dec 2020 12:11:26 -0800 Message-Id: <20201208201134.47844-10-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20201208201134.47844-1-ajit.khaparde@broadcom.com> References: <20201208201134.47844-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-stable] [PATCH 09/17] net/bnxt: fix max rings computation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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: Sriharsha Basavapatna The current max_rings computation does not take into account the case when max_nq_rings is <= num_async_cpr. This results in a wrong value like 0, when max_nq_rings is 1. Fix this by subtracting num_async_cpr only when max_cp_rings > num_async_cpr. Apart from this, the entire logic is currently spread across a few macros, making it hard to read and debug this code. Move this code into an inline function. max_msix is not used in the max_rings calculation. Apparently the max_msix field returned in HWRM_RESC_QCAPS is only valid for Thor and newer chips. On Wh+ it will be equal to min_compl_rings. Also, when a function reset is performed on an application quit, FW will not reset the VF resource pool as per design. This can lead to a strange condition wherein the max_msix field on Wh+ keeps changing on each application re-load thereby throwing throwing off the max_rings computation. Fixes: f03e66cb64ce ("net/bnxt: limit queue count for NS3/Stingray devices") Cc: stable@dpdk.org Signed-off-by: Sriharsha Basavapatna Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt.h | 41 +++++++++++++++++++++++----------- drivers/net/bnxt/bnxt_ethdev.c | 2 +- drivers/net/bnxt/bnxt_rxq.c | 7 +++--- drivers/net/bnxt/bnxt_txq.c | 2 +- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 9c1c87489..bc0935272 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -752,19 +752,6 @@ struct bnxt { uint16_t max_tx_rings; uint16_t max_rx_rings; #define MAX_STINGRAY_RINGS 128U -/* For sake of symmetry, max Tx rings == max Rx rings, one stat ctx for each */ -#define BNXT_MAX_RX_RINGS(bp) \ - (BNXT_STINGRAY(bp) ? RTE_MIN(RTE_MIN(bp->max_rx_rings / 2U, \ - MAX_STINGRAY_RINGS), \ - bp->max_stat_ctx / 2U) : \ - RTE_MIN(bp->max_rx_rings / 2U, \ - bp->max_stat_ctx / 2U)) -#define BNXT_MAX_TX_RINGS(bp) \ - (RTE_MIN((bp)->max_tx_rings, BNXT_MAX_RX_RINGS(bp))) - -#define BNXT_MAX_RINGS(bp) \ - (RTE_MIN((((bp)->max_cp_rings - BNXT_NUM_ASYNC_CPR(bp)) / 2U), \ - BNXT_MAX_TX_RINGS(bp))) #define BNXT_MAX_VF_REP_RINGS 8 @@ -822,6 +809,34 @@ struct bnxt { uint16_t tx_cfa_action; }; +static +inline uint16_t bnxt_max_rings(struct bnxt *bp) +{ + 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; + uint16_t max_rings; + + /* For the sake of symmetry: + * max Tx rings == max Rx rings, one stat ctx for each. + */ + if (BNXT_STINGRAY(bp)) { + max_rx_rings = RTE_MIN(RTE_MIN(max_rx_rings / 2U, + MAX_STINGRAY_RINGS), + bp->max_stat_ctx / 2U); + } else { + max_rx_rings = RTE_MIN(max_rx_rings / 2U, + bp->max_stat_ctx / 2U); + } + + 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); + max_rings = RTE_MIN(max_cp_rings / 2U, max_tx_rings); + + return max_rings; +} + #define BNXT_FC_TIMER 1 /* Timer freq in Sec Flow Counters */ /** diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 0b14ca234..bf8963577 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -920,7 +920,7 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, if (BNXT_PF(bp)) dev_info->max_vfs = pdev->max_vfs; - max_rx_rings = BNXT_MAX_RINGS(bp); + max_rx_rings = bnxt_max_rings(bp); /* 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; diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index 328cc994d..19e11e47b 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -311,7 +311,7 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, if (rc) return rc; - if (queue_idx >= BNXT_MAX_RINGS(bp)) { + if (queue_idx >= bnxt_max_rings(bp)) { PMD_DRV_LOG(ERR, "Cannot create Rx ring %d. Only %d rings available\n", queue_idx, bp->max_rx_rings); @@ -364,8 +364,9 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, eth_dev->data->rx_queues[queue_idx] = rxq; /* Allocate RX ring hardware descriptors */ - if (bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring, NULL, - "rxr")) { + rc = bnxt_alloc_rings(bp, queue_idx, NULL, rxq, rxq->cp_ring, NULL, + "rxr"); + if (rc) { PMD_DRV_LOG(ERR, "ring_dma_zone_reserve for rx_ring failed!\n"); goto err; diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index c9792a2af..99a31cef2 100644 --- a/drivers/net/bnxt/bnxt_txq.c +++ b/drivers/net/bnxt/bnxt_txq.c @@ -98,7 +98,7 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, if (rc) return rc; - if (queue_idx >= BNXT_MAX_RINGS(bp)) { + if (queue_idx >= bnxt_max_rings(bp)) { PMD_DRV_LOG(ERR, "Cannot create Tx ring %d. Only %d rings available\n", queue_idx, bp->max_tx_rings); -- 2.21.1 (Apple Git-122.3) -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.