From patchwork Tue Nov 14 00:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13454645 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDAEC4696 for ; Tue, 14 Nov 2023 00:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ghrVQPE+" Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396C6D4A for ; Mon, 13 Nov 2023 16:17:05 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5bd33abbb90so3257631a12.2 for ; Mon, 13 Nov 2023 16:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1699921025; x=1700525825; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=iE1M7kh9mwYYRxePO0T5PMJgTtP6BzJvXIKmkr1SzuQ=; b=ghrVQPE+TyjIokWHeHmFkDIv4IiiLeB19LzB4PMV9MYDmuCwTnw4x7FBg4qkSIocps 3KkmomxXXxccDv/1SX4/N1gkxYCXheD0ag9H/IxKf8nRtSrMmq8QjfWiA776Att1g3D1 OKDdcKkkKq9VHuKn1VkKtSoN3eV2qkfu6KjLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699921025; x=1700525825; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iE1M7kh9mwYYRxePO0T5PMJgTtP6BzJvXIKmkr1SzuQ=; b=becw4BeYeolJi1OV4SrraRBel0RiIP98RY3/QOXgDTWUtY56zvS7Ux8a4LTpDobWK5 UdDpS+Ba9f7SuMMtEcgcVtOlmUwwRK6q6OpKNtgKOvU3RozncCdMP0ssUNX6Pc9z0qG0 /RVMh83mYSjFFnNo1MvtDHwIN3siS0neyirrtwvxC3du6uXyq0pVtN5/PU+n1a4kvbIO ihX4U7IiVQA3vzi11ssfDIUIJAxI/YW0lThOkLQ+QlHmD98m4Dm6LjXqZTcIQFq0C3c5 tOz2WrDcUQnZHNMBPLkCHO5xwiIpnNOnaWoKobCjDKGX11HEeVHEFPp63yeXLJF/JPOY OiLg== X-Gm-Message-State: AOJu0Ywd+QqOolmOUrXcf2eQXoyQ+c6BYxO/dn8tTUvUeARXvZ0Skyxr X1FwyReVXsFqH/RFcfFRMGL4yQ== X-Google-Smtp-Source: AGHT+IF0zZHUg3WTl/z0aJYWPHgF+CPTMJkB0yyikUcjUXSGvWrumOq4BFhLOGbvixKhaFd5zlClZw== X-Received: by 2002:a17:90a:6883:b0:280:2422:d2b4 with SMTP id a3-20020a17090a688300b002802422d2b4mr6240431pjd.22.1699921024313; Mon, 13 Nov 2023 16:17:04 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id p6-20020a17090a680600b0027ffff956bcsm4063478pjj.47.2023.11.13.16.17.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Nov 2023 16:17:03 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Andy Gospodarek Subject: [PATCH net-next v2 09/13] bnxt_en: Support up to 8 TX rings per MSIX Date: Mon, 13 Nov 2023 16:16:17 -0800 Message-Id: <20231114001621.101284-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231114001621.101284-1-michael.chan@broadcom.com> References: <20231114001621.101284-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org For each mqprio TC, we allocate a set of TX rings to map to the new hardware CoS queue. Expand the tx_ring pointer in struct bnxt_napi to an array of 8 to support up to 8 TX rings, one for each TC. Only array entry 0 is used at this time. The rest of the array entries will be used in later patches. Reviewed-by: Andy Gospodarek Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 78 +++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 12 ++- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 +- 3 files changed, 55 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c84a72b666aa..6002b834e898 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -758,9 +758,13 @@ static void __bnxt_tx_int(struct bnxt *bp, struct bnxt_tx_ring_info *txr, static void bnxt_tx_int(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) { - struct bnxt_tx_ring_info *txr = bnapi->tx_ring; + struct bnxt_tx_ring_info *txr; + int i; - __bnxt_tx_int(bp, txr, budget); + bnxt_for_each_napi_tx(i, bnapi, txr) { + if (txr->tx_hw_cons != txr->tx_cons) + __bnxt_tx_int(bp, txr, budget); + } bnapi->events &= ~BNXT_TX_CMP_EVENT; } @@ -2596,7 +2600,6 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, { struct bnxt_napi *bnapi = cpr->bnapi; u32 raw_cons = cpr->cp_raw_cons; - struct bnxt_tx_ring_info *txr; u32 cons; int rx_pkts = 0; u8 event = 0; @@ -2604,7 +2607,6 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, cpr->has_more_work = 0; cpr->had_work_done = 1; - txr = bnapi->tx_ring; while (1) { int rc; @@ -2620,8 +2622,10 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, dma_rmb(); if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) { u32 opaque = txcmp->tx_cmp_opaque; + struct bnxt_tx_ring_info *txr; u16 tx_freed; + txr = bnapi->tx_ring[TX_OPAQUE_RING(opaque)]; event |= BNXT_TX_CMP_EVENT; txr->tx_hw_cons = TX_OPAQUE_PROD(bp, opaque); tx_freed = (txr->tx_hw_cons - txr->tx_cons) & @@ -2671,7 +2675,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, xdp_do_flush(); if (event & BNXT_TX_EVENT) { - struct bnxt_tx_ring_info *txr = bnapi->tx_ring; + struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0]; u16 prod = txr->tx_prod; /* Sync BD data before updating doorbell */ @@ -3657,7 +3661,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp) static void bnxt_init_ring_struct(struct bnxt *bp) { - int i; + int i, j; for (i = 0; i < bp->cp_nr_rings; i++) { struct bnxt_napi *bnapi = bp->bnapi[i]; @@ -3702,18 +3706,16 @@ static void bnxt_init_ring_struct(struct bnxt *bp) rmem->vmem = (void **)&rxr->rx_agg_ring; skip_rx: - txr = bnapi->tx_ring; - if (!txr) - continue; - - ring = &txr->tx_ring_struct; - rmem = &ring->ring_mem; - rmem->nr_pages = bp->tx_nr_pages; - rmem->page_size = HW_RXBD_RING_SIZE; - rmem->pg_arr = (void **)txr->tx_desc_ring; - rmem->dma_arr = txr->tx_desc_mapping; - rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; - rmem->vmem = (void **)&txr->tx_buf_ring; + bnxt_for_each_napi_tx(j, bnapi, txr) { + ring = &txr->tx_ring_struct; + rmem = &ring->ring_mem; + rmem->nr_pages = bp->tx_nr_pages; + rmem->page_size = HW_TXBD_RING_SIZE; + rmem->pg_arr = (void **)txr->tx_desc_ring; + rmem->dma_arr = txr->tx_desc_mapping; + rmem->vmem_size = SW_TXBD_RING_SIZE * bp->tx_nr_pages; + rmem->vmem = (void **)&txr->tx_buf_ring; + } } } @@ -4512,7 +4514,7 @@ static int bnxt_alloc_stats(struct bnxt *bp) static void bnxt_clear_ring_indices(struct bnxt *bp) { - int i; + int i, j; if (!bp->bnapi) return; @@ -4529,8 +4531,7 @@ static void bnxt_clear_ring_indices(struct bnxt *bp) cpr = &bnapi->cp_ring; cpr->cp_raw_cons = 0; - txr = bnapi->tx_ring; - if (txr) { + bnxt_for_each_napi_tx(j, bnapi, txr) { txr->tx_prod = 0; txr->tx_cons = 0; txr->tx_hw_cons = 0; @@ -4703,7 +4704,7 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool irq_re_init) else txr->tx_cpr = &bp->bnapi[i]->cp_ring; txr->bnapi = bp->bnapi[j]; - bp->bnapi[j]->tx_ring = txr; + bp->bnapi[j]->tx_ring[0] = txr; bp->tx_ring_map[i] = bp->tx_nr_rings_xdp + i; if (i >= bp->tx_nr_rings_xdp) { txr->txq_index = i - bp->tx_nr_rings_xdp; @@ -6910,10 +6911,21 @@ static int bnxt_hwrm_set_tx_coal(struct bnxt *bp, struct bnxt_napi *bnapi, struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req) { - u16 ring_id = bnxt_cp_ring_for_tx(bp, bnapi->tx_ring); + struct bnxt_tx_ring_info *txr; + int i, rc; - req->ring_id = cpu_to_le16(ring_id); - return hwrm_req_send(bp, req); + bnxt_for_each_napi_tx(i, bnapi, txr) { + u16 ring_id; + + ring_id = bnxt_cp_ring_for_tx(bp, txr); + req->ring_id = cpu_to_le16(ring_id); + rc = hwrm_req_send(bp, req); + if (rc) + return rc; + if (!(bp->flags & BNXT_FLAG_CHIP_P5)) + return 0; + } + return 0; } int bnxt_hwrm_set_coal(struct bnxt *bp) @@ -6950,7 +6962,7 @@ int bnxt_hwrm_set_coal(struct bnxt *bp) if (!(bp->flags & BNXT_FLAG_CHIP_P5)) continue; - if (bnapi->rx_ring && bnapi->tx_ring) { + if (bnapi->rx_ring && bnapi->tx_ring[0]) { rc = bnxt_hwrm_set_tx_coal(bp, bnapi, req_tx); if (rc) break; @@ -11575,15 +11587,13 @@ static int bnxt_dbg_hwrm_ring_info_get(struct bnxt *bp, u8 ring_type, static void bnxt_dump_tx_sw_state(struct bnxt_napi *bnapi) { - struct bnxt_tx_ring_info *txr = bnapi->tx_ring; - int i = bnapi->index; - - if (!txr) - return; + struct bnxt_tx_ring_info *txr; + int i = bnapi->index, j; - netdev_info(bnapi->bp->dev, "[%d]: tx{fw_ring: %d prod: %x cons: %x}\n", - i, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, - txr->tx_cons); + bnxt_for_each_napi_tx(j, bnapi, txr) + netdev_info(bnapi->bp->dev, "[%d.%d]: tx{fw_ring: %d prod: %x cons: %x}\n", + i, j, txr->tx_ring_struct.fw_ring_id, txr->tx_prod, + txr->tx_cons); } static void bnxt_dump_rx_sw_state(struct bnxt_napi *bnapi) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 430538844178..2028233c0561 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1046,6 +1046,14 @@ struct bnxt_cp_ring_info { struct bnxt_cp_ring_info *cp_ring_arr; }; +#define BNXT_MAX_QUEUE 8 +#define BNXT_MAX_TXR_PER_NAPI BNXT_MAX_QUEUE + +#define bnxt_for_each_napi_tx(iter, bnapi, txr) \ + for (iter = 0, txr = (bnapi)->tx_ring[0]; txr; \ + txr = (iter < BNXT_MAX_TXR_PER_NAPI - 1) ? \ + (bnapi)->tx_ring[++iter] : NULL) + struct bnxt_napi { struct napi_struct napi; struct bnxt *bp; @@ -1053,7 +1061,7 @@ struct bnxt_napi { int index; struct bnxt_cp_ring_info cp_ring; struct bnxt_rx_ring_info *rx_ring; - struct bnxt_tx_ring_info *tx_ring; + struct bnxt_tx_ring_info *tx_ring[BNXT_MAX_TXR_PER_NAPI]; void (*tx_int)(struct bnxt *, struct bnxt_napi *, int budget); @@ -1391,8 +1399,6 @@ struct bnxt_link_info { (PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE74_DISABLE | \ BNXT_FEC_RS_OFF(link_info)) -#define BNXT_MAX_QUEUE 8 - struct bnxt_queue_info { u8 queue_id; u8 queue_profile; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c index 3515a12a6fea..52b75108e130 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c @@ -127,7 +127,7 @@ static void __bnxt_xmit_xdp_redirect(struct bnxt *bp, void bnxt_tx_int_xdp(struct bnxt *bp, struct bnxt_napi *bnapi, int budget) { - struct bnxt_tx_ring_info *txr = bnapi->tx_ring; + struct bnxt_tx_ring_info *txr = bnapi->tx_ring[0]; struct bnxt_rx_ring_info *rxr = bnapi->rx_ring; u16 tx_hw_cons = txr->tx_hw_cons; bool rx_doorbell_needed = false; @@ -249,7 +249,7 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons, pdev = bp->pdev; offset = bp->rx_offset; - txr = rxr->bnapi->tx_ring; + txr = rxr->bnapi->tx_ring[0]; /* BNXT_RX_PAGE_MODE(bp) when XDP enabled */ orig_data = xdp.data;