From patchwork Fri Jun 25 22:34:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 94876 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 68ACDA034F; Sat, 26 Jun 2021 00:34:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5757E40E6E; Sat, 26 Jun 2021 00:34:17 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 3949540E25 for ; Sat, 26 Jun 2021 00:34:16 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id 21so8597895pfp.3 for ; Fri, 25 Jun 2021 15:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version; bh=++G++r8HCIkGszb4XBxtn3rfpyU5eD9UD1qmqkz7r3k=; b=EU+zjWkR6Roub8x9F9IOVnd2EERAM3gRXjoSNrmkVVHCgfDWg1GrepDSt75hTb0h31 HjG22/Ukg44Rt6oJhzGtACsFKJ9XfEbD2r752yWr4YL5IELMje7ay8uh0jWhoi8+XQWc tBn3c6k7TJswxYPDgDg40Z583x52gO6bkm0Cc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version; bh=++G++r8HCIkGszb4XBxtn3rfpyU5eD9UD1qmqkz7r3k=; b=J4Utr3hZQlo9/Joom4vEV4NYvHRLeTJO9xVwo7+MLKuoPRx9AZvPMgwPV2eaQ2KNWh QNz6sQPUjntEkO2yuIYdRCfcD35MZUv6zHrIC+FJMC6IQYAbEG47ErwJj5GK1IkPwPhP j7WFwjfrm+QyW6fw5DRtv7mwrwkOPV1dZGGIZSEXIM/1fF5ddTx8+aBS2kYuXt2MQ7ZZ 5cErqgQFhYiahGTPuygi9O0tnej/DeVaum17kcopmz2l1Ra5YnGDgC+2uWJOEQzPpQTK oRpr3vVV7YkAlO2hDCHUaZvFrljhdTNmmAsGt0pWd4WUF6QRjykMNuC2thuju90huoFP ExHQ== X-Gm-Message-State: AOAM530bXXgjW5LMf9LSC8W5VVb4TkOp+OBuGDt1b935MXU4PU/0ywPW FZR4lD+TSNI0mPjzfXZL8UrdXRQGmwjk2Gzzhj/6HX89DxTi9vMHO3JNS660L77eskl+5NS1onj 3vYw7M7Gq0vjmbP8MMY5dmy3pAnpx2DcGqdDQDb9KAD/CXqbOqZEKGGvSOUjuv2E= X-Google-Smtp-Source: ABdhPJxpTk/4hUkfjo+PlaNs6btiQKWqG1ZQDS9ChhJFYc7B7yzsuy3Bq+lx5Lwobne8mHnSq7kOmQ== X-Received: by 2002:a63:5118:: with SMTP id f24mr11466310pgb.34.1624660454782; Fri, 25 Jun 2021 15:34:14 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id u8sm10111943pjg.1.2021.06.25.15.34.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jun 2021 15:34:14 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Date: Fri, 25 Jun 2021 15:34:00 -0700 Message-Id: <20210625223401.45505-2-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20210625223401.45505-1-ajit.khaparde@broadcom.com> References: <20210625223401.45505-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH 1/2] net/bnxt: add support for runtime queue setup 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" Add support for runtime Rx and Tx queue setup. This will allow Rx/Tx queue setup after the interface is started. Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 2 ++ drivers/net/bnxt/bnxt_hwrm.c | 46 ++++++++++++++++++++++++------ drivers/net/bnxt/bnxt_hwrm.h | 3 ++ drivers/net/bnxt/bnxt_ring.c | 51 ++++++++++++++++++++++++++++++++++ drivers/net/bnxt/bnxt_rxq.c | 12 ++------ drivers/net/bnxt/bnxt_txq.c | 2 ++ drivers/net/bnxt/bnxt_txr.c | 6 ++++ 7 files changed, 105 insertions(+), 17 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4d51a209f9..495c6cd21e 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -987,6 +987,8 @@ static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, dev_info->flow_type_rss_offloads = BNXT_ETH_RSS_SUPPORT; dev_info->speed_capa = bnxt_get_speed_capabilities(bp); + dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | + RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; dev_info->default_rxconf = (struct rte_eth_rxconf) { .rx_thresh = { diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 6c4f83ee3b..1a4968abe6 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1917,7 +1917,7 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) return rc; } -static int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) +int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) { int rc; struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 }; @@ -2637,10 +2637,11 @@ int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) cpr = rxq->cp_ring; } - rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr); - - if (rc) - return rc; + if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE) { + rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr); + if (rc) + return rc; + } } return rc; } @@ -2720,6 +2721,12 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID; } + + if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { + bnxt_hwrm_stat_ctx_free(bp, cpr); + cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; + } + if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) bnxt_free_cp_ring(bp, cpr); @@ -5093,7 +5100,6 @@ static int bnxt_vnic_rss_configure_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic) { struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr; - uint8_t *rx_queue_state = bp->eth_dev->data->rx_queue_state; struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 }; struct bnxt_rx_queue **rxqs = bp->rx_queues; uint16_t *ring_tbl = vnic->rss_table; @@ -5127,8 +5133,7 @@ bnxt_vnic_rss_configure_p5(struct bnxt *bp, struct bnxt_vnic_info *vnic) /* Find next active ring. */ for (cnt = 0; cnt < max_rings; cnt++) { - if (rx_queue_state[k] != - RTE_ETH_QUEUE_STATE_STOPPED) + if (rxqs[k]->rx_started) break; if (++k == max_rings) k = 0; @@ -6194,3 +6199,28 @@ int bnxt_hwrm_read_sfp_module_eeprom_info(struct bnxt *bp, uint16_t i2c_addr, return rc; } + +void bnxt_free_hwrm_tx_ring(struct bnxt *bp, int queue_index) +{ + struct bnxt_tx_queue *txq = bp->tx_queues[queue_index]; + struct bnxt_tx_ring_info *txr = txq->tx_ring; + struct bnxt_ring *ring = txr->tx_ring_struct; + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + + if (ring->fw_ring_id != INVALID_HW_RING_ID) { + bnxt_hwrm_ring_free(bp, ring, + HWRM_RING_FREE_INPUT_RING_TYPE_TX, + cpr->cp_ring_struct->fw_ring_id); + ring->fw_ring_id = INVALID_HW_RING_ID; + } + + if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { + bnxt_hwrm_stat_ctx_free(bp, cpr); + cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; + } + + if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) { + bnxt_free_cp_ring(bp, cpr); + cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID; + } +} diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 057f7f94d0..ec3414f0c6 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -304,4 +304,7 @@ int bnxt_hwrm_ring_stats(struct bnxt *bp, uint32_t cid, int idx, int bnxt_hwrm_read_sfp_module_eeprom_info(struct bnxt *bp, uint16_t i2c_addr, uint16_t page_number, uint16_t start_addr, uint16_t data_length, uint8_t *buf); +int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); +void bnxt_free_hwrm_tx_ring(struct bnxt *bp, int queue_index); +int bnxt_alloc_hwrm_tx_ring(struct bnxt *bp, int queue_index); #endif diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index cb18dfba7f..9ec0c10911 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -599,6 +599,10 @@ int bnxt_alloc_hwrm_rx_ring(struct bnxt *bp, int queue_index) if (rc) goto err_out; + rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr); + if (rc) + goto err_out; + if (BNXT_HAS_RING_GRPS(bp)) { bp->grp_info[queue_index].fw_stats_ctx = cpr->hw_stats_ctx_id; bp->grp_info[queue_index].cp_fw_ring_id = cp_ring->fw_ring_id; @@ -837,3 +841,50 @@ int bnxt_alloc_async_ring_struct(struct bnxt *bp) return bnxt_alloc_rings(bp, bp->eth_dev->device->numa_node, 0, NULL, NULL, bp->async_cp_ring, NULL, "def_cp"); } + +int bnxt_alloc_hwrm_tx_ring(struct bnxt *bp, int queue_index) +{ + struct bnxt_tx_queue *txq = bp->tx_queues[queue_index]; + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + struct bnxt_ring *cp_ring = cpr->cp_ring_struct; + struct bnxt_tx_ring_info *txr = txq->tx_ring; + struct bnxt_ring *ring = txr->tx_ring_struct; + unsigned int idx = queue_index + bp->rx_cp_nr_rings; + uint16_t tx_cosq_id = 0; + struct bnxt_coal coal; + int rc = 0; + + rc = bnxt_alloc_cmpl_ring(bp, idx, cpr); + if (rc) + goto err_out; + + bnxt_init_dflt_coal(&coal); + bnxt_hwrm_set_ring_coal(bp, &coal, cp_ring->fw_ring_id); + + rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr); + if (rc) + goto err_out; + + if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) + tx_cosq_id = bp->tx_cosq_id[queue_index < bp->max_lltc ? queue_index : 0]; + else + tx_cosq_id = bp->tx_cosq_id[0]; + + rc = bnxt_hwrm_ring_alloc(bp, ring, + HWRM_RING_ALLOC_INPUT_RING_TYPE_TX, + queue_index, cpr->hw_stats_ctx_id, + cp_ring->fw_ring_id, + tx_cosq_id); + if (rc) + goto err_out; + + bnxt_set_db(bp, &txr->tx_db, HWRM_RING_ALLOC_INPUT_RING_TYPE_TX, + queue_index, ring->fw_ring_id, + ring->ring_mask); + txq->index = idx; + + return rc; +err_out: + bnxt_free_hwrm_tx_ring(bp, queue_index); + return rc; +} diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index 44b09e9c61..bbcb3b06e7 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -248,6 +248,7 @@ void bnxt_rx_queue_release_op(void *rx_queue) if (is_bnxt_in_error(rxq->bp)) return; + bnxt_free_hwrm_rx_ring(rxq->bp, rxq->queue_id); bnxt_rx_queue_release_mbufs(rxq); /* Free RX ring hardware descriptors */ @@ -286,7 +287,6 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads; struct bnxt_rx_queue *rxq; int rc = 0; - uint8_t queue_state; rc = is_bnxt_in_error(bp); if (rc) @@ -360,14 +360,8 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, else rxq->rx_deferred_start = rx_conf->rx_deferred_start; - if (rxq->rx_deferred_start) { - queue_state = RTE_ETH_QUEUE_STATE_STOPPED; - rxq->rx_started = false; - } else { - queue_state = RTE_ETH_QUEUE_STATE_STARTED; - rxq->rx_started = true; - } - eth_dev->data->rx_queue_state[queue_idx] = queue_state; + rxq->rx_started = rxq->rx_deferred_start ? false : true; + rxq->vnic = BNXT_GET_DEFAULT_VNIC(bp); /* Configure mtu if it is different from what was configured before */ if (!queue_idx) diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index bc789224d2..830416af3d 100644 --- a/drivers/net/bnxt/bnxt_txq.c +++ b/drivers/net/bnxt/bnxt_txq.c @@ -8,6 +8,7 @@ #include #include "bnxt.h" +#include "bnxt_hwrm.h" #include "bnxt_ring.h" #include "bnxt_txq.h" #include "bnxt_txr.h" @@ -61,6 +62,7 @@ void bnxt_tx_queue_release_op(void *tx_queue) return; /* Free TX ring hardware descriptors */ + bnxt_free_hwrm_tx_ring(txq->bp, txq->queue_id); bnxt_tx_queue_release_mbufs(txq); if (txq->tx_ring) { bnxt_free_ring(txq->tx_ring->tx_ring_struct); diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c index 8eb9493997..9a6b96e04a 100644 --- a/drivers/net/bnxt/bnxt_txr.c +++ b/drivers/net/bnxt/bnxt_txr.c @@ -9,6 +9,7 @@ #include #include "bnxt.h" +#include "bnxt_hwrm.h" #include "bnxt_ring.h" #include "bnxt_txq.h" #include "bnxt_txr.h" @@ -547,6 +548,11 @@ int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) if (rc) return rc; + bnxt_free_hwrm_tx_ring(bp, tx_queue_id); + rc = bnxt_alloc_hwrm_tx_ring(bp, tx_queue_id); + if (rc) + return rc; + dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; txq->tx_started = true; PMD_DRV_LOG(DEBUG, "Tx queue started\n"); From patchwork Fri Jun 25 22:34:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 94877 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 7A783A034F; Sat, 26 Jun 2021 00:34:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6FB09410E4; Sat, 26 Jun 2021 00:34:19 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id C1DB9410E2 for ; Sat, 26 Jun 2021 00:34:18 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id d12so879514pfj.2 for ; Fri, 25 Jun 2021 15:34:18 -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=hIyIuPqlxlm1J7f9Y44bvbTkWhJeVuhpUlnt65tlx1Y=; b=cHrcHs74stfiaCQpmCnUTkcUuNkMK3fwLA+pLMViN1VB5HKTBFeizwD/izjqW6dh7q Xn+TKFC4EPaPlz6SgfFtbWzSIGSlgerbQdHLDvkxLxN9CwO3RzVd8TWHzkfVcgnyKBVu dCfkrJzhEwaUUsPhFjA/yNfIRrVRsSDYAq558= 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=hIyIuPqlxlm1J7f9Y44bvbTkWhJeVuhpUlnt65tlx1Y=; b=APFfRMFLtruL1elwCgS+Z4hycEwQSJ6ibPaehbqDgmRK2vWOZgfxjP4/bggBAyux6R fBpnSsy73J41TSCRI+Xjbd1SvkNpFHbMLMrcT99s2SdJGddkFOs4RutDiHb5JRhpklYe rn7x5R+sqti/hLGvWNp2nYwYWZlzrDsRRZFBl1owUc4/4OVw7WDlLsAb9M7Kfk1JBUdV brxHxrT0LzXR64vyux54mGYo6xBVKy9AkjjLXabzEl5nrXKcgU9MOsNsu4LF7GejpbW3 Qa+B4zztInh9e9B4PCKYmv5CvJLF1kYiX7X8azSEx7ZVzePCbzaVOHa5Vt2e67k+8qYW U3Fg== X-Gm-Message-State: AOAM531V+kiv+sZniVti0q8M3ymxPYpGNVyVU2SWX20rt0/hZfEVV30V L1WSHd60AdkMY0DI5AECXVtQW1ncaSsTpURI61ZPSsfOdMRf0W0taUVJclMfe1N7QuhvxCOU/Wf v8We/RmqtnjT4Iudmf0JhKH7CGrIAsU0cdZq771ofUiRy+F/a40xve38trYEepeI= X-Google-Smtp-Source: ABdhPJy5K6kR2l5s6I4H3fzWqe4REI3ZwEDARcblsP4p9r5pMUj+w5y6Vcau9j6tr3E9S6jY6d1V5w== X-Received: by 2002:a65:6642:: with SMTP id z2mr11522044pgv.388.1624660457526; Fri, 25 Jun 2021 15:34:17 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id u8sm10111943pjg.1.2021.06.25.15.34.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jun 2021 15:34:16 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Somnath Kotur Date: Fri, 25 Jun 2021 15:34:01 -0700 Message-Id: <20210625223401.45505-3-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20210625223401.45505-1-ajit.khaparde@broadcom.com> References: <20210625223401.45505-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: fix ring alloc and free logic 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 handling of ring alloc and free logic to fix check for invalid ring and context IDs. This also avoids code duplication. Fixes: 6133f207970c ("net/bnxt: add Rx queue create/destroy") Fixes: 51c87ebafc7d ("net/bnxt: add Tx queue create/destroy") Signed-off-by: Ajit Khaparde Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_hwrm.c | 173 +++++++++++++++-------------------- drivers/net/bnxt/bnxt_ring.c | 30 +----- 2 files changed, 78 insertions(+), 125 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 1a4968abe6..4593991af8 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1810,6 +1810,9 @@ int bnxt_hwrm_ring_free(struct bnxt *bp, struct hwrm_ring_free_input req = {.req_type = 0 }; struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr; + if (ring->fw_ring_id == INVALID_HW_RING_ID) + return -EINVAL; + HWRM_PREP(&req, HWRM_RING_FREE, BNXT_USE_CHIMP_MB); req.ring_type = ring_type; @@ -1817,6 +1820,7 @@ int bnxt_hwrm_ring_free(struct bnxt *bp, req.cmpl_ring = rte_cpu_to_le_16(cp_ring_id); rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); + ring->fw_ring_id = INVALID_HW_RING_ID; if (rc || resp->error_code) { if (rc == 0 && resp->error_code) @@ -1902,7 +1906,7 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) struct hwrm_stat_ctx_clr_stats_input req = {.req_type = 0 }; struct hwrm_stat_ctx_clr_stats_output *resp = bp->hwrm_cmd_resp_addr; - if (cpr->hw_stats_ctx_id == (uint32_t)HWRM_NA_SIGNATURE) + if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE) return rc; HWRM_PREP(&req, HWRM_STAT_CTX_CLR_STATS, BNXT_USE_CHIMP_MB); @@ -1923,6 +1927,9 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 }; struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr; + if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) + return 0; + HWRM_PREP(&req, HWRM_STAT_CTX_ALLOC, BNXT_USE_CHIMP_MB); req.update_period_ms = rte_cpu_to_le_32(0); @@ -1946,6 +1953,9 @@ static int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, struct bnxt_cp_ring_info *cp struct hwrm_stat_ctx_free_input req = {.req_type = 0 }; struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr; + if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE) + return 0; + HWRM_PREP(&req, HWRM_STAT_CTX_FREE, BNXT_USE_CHIMP_MB); req.stat_ctx_id = rte_cpu_to_le_32(cpr->hw_stats_ctx_id); @@ -1955,6 +1965,8 @@ static int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, struct bnxt_cp_ring_info *cp HWRM_CHECK_RESULT(); HWRM_UNLOCK(); + cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; + return rc; } @@ -2600,49 +2612,54 @@ bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp) unsigned int i; struct bnxt_cp_ring_info *cpr; - for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { + for (i = 0; i < bp->rx_cp_nr_rings; i++) { - if (i >= bp->rx_cp_nr_rings) { - cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring; - } else { - cpr = bp->rx_queues[i]->cp_ring; - if (BNXT_HAS_RING_GRPS(bp)) - bp->grp_info[i].fw_stats_ctx = -1; - } - if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { - rc = bnxt_hwrm_stat_ctx_free(bp, cpr); - cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; - if (rc) - return rc; - } + cpr = bp->rx_queues[i]->cp_ring; + if (BNXT_HAS_RING_GRPS(bp)) + bp->grp_info[i].fw_stats_ctx = -1; + rc = bnxt_hwrm_stat_ctx_free(bp, cpr); + if (rc) + return rc; + } + + for (i = 0; i < bp->tx_cp_nr_rings; i++) { + cpr = bp->tx_queues[i]->cp_ring; + rc = bnxt_hwrm_stat_ctx_free(bp, cpr); + if (rc) + return rc; } + return 0; } int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) { + struct bnxt_cp_ring_info *cpr; unsigned int i; int rc = 0; - for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { - struct bnxt_tx_queue *txq; - struct bnxt_rx_queue *rxq; - struct bnxt_cp_ring_info *cpr; + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + struct bnxt_rx_queue *rxq = bp->rx_queues[i]; - if (i >= bp->rx_cp_nr_rings) { - txq = bp->tx_queues[i - bp->rx_cp_nr_rings]; - cpr = txq->cp_ring; - } else { - rxq = bp->rx_queues[i]; - cpr = rxq->cp_ring; + cpr = rxq->cp_ring; + if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE) { + rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr); + if (rc) + return rc; } + } + + for (i = 0; i < bp->tx_cp_nr_rings; i++) { + struct bnxt_tx_queue *txq = bp->tx_queues[i]; + cpr = txq->cp_ring; if (cpr->hw_stats_ctx_id == HWRM_NA_SIGNATURE) { rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr); if (rc) return rc; } } + return rc; } @@ -2675,9 +2692,8 @@ void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) bnxt_hwrm_ring_free(bp, cp_ring, HWRM_RING_FREE_INPUT_RING_TYPE_NQ, INVALID_HW_RING_ID); - cp_ring->fw_ring_id = INVALID_HW_RING_ID; - memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size * - sizeof(*cpr->cp_desc_ring)); + memset(cpr->cp_desc_ring, 0, + cpr->cp_ring_struct->ring_size * sizeof(*cpr->cp_desc_ring)); cpr->cp_raw_cons = 0; } @@ -2686,11 +2702,10 @@ void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) struct bnxt_ring *cp_ring = cpr->cp_ring_struct; bnxt_hwrm_ring_free(bp, cp_ring, - HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL, - INVALID_HW_RING_ID); - cp_ring->fw_ring_id = INVALID_HW_RING_ID; - memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size * - sizeof(*cpr->cp_desc_ring)); + HWRM_RING_FREE_INPUT_RING_TYPE_L2_CMPL, + INVALID_HW_RING_ID); + memset(cpr->cp_desc_ring, 0, + cpr->cp_ring_struct->ring_size * sizeof(*cpr->cp_desc_ring)); cpr->cp_raw_cons = 0; } @@ -2701,34 +2716,24 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index) struct bnxt_ring *ring = rxr->rx_ring_struct; struct bnxt_cp_ring_info *cpr = rxq->cp_ring; - if (ring->fw_ring_id != INVALID_HW_RING_ID) { - bnxt_hwrm_ring_free(bp, ring, - HWRM_RING_FREE_INPUT_RING_TYPE_RX, - cpr->cp_ring_struct->fw_ring_id); - ring->fw_ring_id = INVALID_HW_RING_ID; - if (BNXT_HAS_RING_GRPS(bp)) - bp->grp_info[queue_index].rx_fw_ring_id = - INVALID_HW_RING_ID; - } + bnxt_hwrm_ring_free(bp, ring, + HWRM_RING_FREE_INPUT_RING_TYPE_RX, + cpr->cp_ring_struct->fw_ring_id); + if (BNXT_HAS_RING_GRPS(bp)) + bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID; + ring = rxr->ag_ring_struct; - if (ring->fw_ring_id != INVALID_HW_RING_ID) { - bnxt_hwrm_ring_free(bp, ring, - BNXT_CHIP_P5(bp) ? - HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG : - HWRM_RING_FREE_INPUT_RING_TYPE_RX, - cpr->cp_ring_struct->fw_ring_id); - if (BNXT_HAS_RING_GRPS(bp)) - bp->grp_info[queue_index].ag_fw_ring_id = - INVALID_HW_RING_ID; - } + bnxt_hwrm_ring_free(bp, ring, + BNXT_CHIP_P5(bp) ? + HWRM_RING_FREE_INPUT_RING_TYPE_RX_AGG : + HWRM_RING_FREE_INPUT_RING_TYPE_RX, + cpr->cp_ring_struct->fw_ring_id); + if (BNXT_HAS_RING_GRPS(bp)) + bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID; - if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { - bnxt_hwrm_stat_ctx_free(bp, cpr); - cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; - } + bnxt_hwrm_stat_ctx_free(bp, cpr); - if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) - bnxt_free_cp_ring(bp, cpr); + bnxt_free_cp_ring(bp, cpr); if (BNXT_HAS_RING_GRPS(bp)) bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID; @@ -2758,31 +2763,8 @@ bnxt_free_all_hwrm_rings(struct bnxt *bp) { unsigned int i; - for (i = 0; i < bp->tx_cp_nr_rings; i++) { - struct bnxt_tx_queue *txq = bp->tx_queues[i]; - struct bnxt_tx_ring_info *txr = txq->tx_ring; - struct bnxt_ring *ring = txr->tx_ring_struct; - struct bnxt_cp_ring_info *cpr = txq->cp_ring; - - if (ring->fw_ring_id != INVALID_HW_RING_ID) { - bnxt_hwrm_ring_free(bp, ring, - HWRM_RING_FREE_INPUT_RING_TYPE_TX, - cpr->cp_ring_struct->fw_ring_id); - ring->fw_ring_id = INVALID_HW_RING_ID; - memset(txr->tx_desc_ring, 0, - txr->tx_ring_struct->ring_size * - sizeof(*txr->tx_desc_ring)); - memset(txr->tx_buf_ring, 0, - txr->tx_ring_struct->ring_size * - sizeof(*txr->tx_buf_ring)); - txr->tx_raw_prod = 0; - txr->tx_raw_cons = 0; - } - if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) { - bnxt_free_cp_ring(bp, cpr); - cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID; - } - } + for (i = 0; i < bp->tx_cp_nr_rings; i++) + bnxt_free_hwrm_tx_ring(bp, i); for (i = 0; i < bp->rx_cp_nr_rings; i++) bnxt_free_hwrm_rx_ring(bp, i); @@ -6207,20 +6189,17 @@ void bnxt_free_hwrm_tx_ring(struct bnxt *bp, int queue_index) struct bnxt_ring *ring = txr->tx_ring_struct; struct bnxt_cp_ring_info *cpr = txq->cp_ring; - if (ring->fw_ring_id != INVALID_HW_RING_ID) { - bnxt_hwrm_ring_free(bp, ring, - HWRM_RING_FREE_INPUT_RING_TYPE_TX, - cpr->cp_ring_struct->fw_ring_id); - ring->fw_ring_id = INVALID_HW_RING_ID; - } + bnxt_hwrm_ring_free(bp, ring, + HWRM_RING_FREE_INPUT_RING_TYPE_TX, + cpr->cp_ring_struct->fw_ring_id); + txr->tx_raw_prod = 0; + txr->tx_raw_cons = 0; + memset(txr->tx_desc_ring, 0, + txr->tx_ring_struct->ring_size * sizeof(*txr->tx_desc_ring)); + memset(txr->tx_buf_ring, 0, + txr->tx_ring_struct->ring_size * sizeof(*txr->tx_buf_ring)); - if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { - bnxt_hwrm_stat_ctx_free(bp, cpr); - cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; - } + bnxt_hwrm_stat_ctx_free(bp, cpr); - if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) { - bnxt_free_cp_ring(bp, cpr); - cpr->cp_ring_struct->fw_ring_id = INVALID_HW_RING_ID; - } + bnxt_free_cp_ring(bp, cpr); } diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index 9ec0c10911..b05c470766 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -700,7 +700,6 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) { struct bnxt_coal coal; unsigned int i; - uint8_t ring_type; int rc = 0; bnxt_init_dflt_coal(&coal); @@ -712,36 +711,11 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) goto err_out; } + /* If something is wrong with Rx ring alloc, skip Tx ring alloc */ for (i = 0; i < bp->tx_cp_nr_rings; i++) { - struct bnxt_tx_queue *txq = bp->tx_queues[i]; - struct bnxt_cp_ring_info *cpr = txq->cp_ring; - struct bnxt_ring *cp_ring = cpr->cp_ring_struct; - struct bnxt_tx_ring_info *txr = txq->tx_ring; - struct bnxt_ring *ring = txr->tx_ring_struct; - unsigned int idx = i + bp->rx_cp_nr_rings; - uint16_t tx_cosq_id = 0; - - if (bnxt_alloc_cmpl_ring(bp, idx, cpr)) - goto err_out; - - if (bp->vnic_cap_flags & BNXT_VNIC_CAP_COS_CLASSIFY) - tx_cosq_id = bp->tx_cosq_id[i < bp->max_lltc ? i : 0]; - else - tx_cosq_id = bp->tx_cosq_id[0]; - /* Tx ring */ - ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_TX; - rc = bnxt_hwrm_ring_alloc(bp, ring, - ring_type, - i, cpr->hw_stats_ctx_id, - cp_ring->fw_ring_id, - tx_cosq_id); + rc = bnxt_alloc_hwrm_tx_ring(bp, i); if (rc) goto err_out; - - bnxt_set_db(bp, &txr->tx_db, ring_type, i, ring->fw_ring_id, - ring->ring_mask); - txq->index = idx; - bnxt_hwrm_set_ring_coal(bp, &coal, cp_ring->fw_ring_id); } err_out: