[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240502045410.3524155-7-dw@davidwei.uk>
Date: Wed, 1 May 2024 21:54:07 -0700
From: David Wei <dw@...idwei.uk>
To: netdev@...r.kernel.org,
Michael Chan <michael.chan@...adcom.com>,
Pavan Chebbi <pavan.chebbi@...adcom.com>,
Andy Gospodarek <andrew.gospodarek@...adcom.com>,
Adrian Alvarado <adrian.alvarado@...adcom.com>,
Mina Almasry <almasrymina@...gle.com>,
Shailend Chand <shailend@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>
Subject: [RFC PATCH net-next v2 6/9] bnxt: add __bnxt_init_rx_ring_struct() helper
Move the initialisation of rx ring and rx agg ring structs into a helper
function.
Signed-off-by: David Wei <dw@...idwei.uk>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 +++++++++++++----------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index bda49e7f6c3d..b0a8d14b7319 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3997,6 +3997,31 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
return 0;
}
+static void __bnxt_init_rx_ring_struct(struct bnxt *bp,
+ struct bnxt_rx_ring_info *rxr)
+{
+ struct bnxt_ring_mem_info *rmem;
+ struct bnxt_ring_struct *ring;
+
+ ring = &rxr->rx_ring_struct;
+ rmem = &ring->ring_mem;
+ rmem->nr_pages = bp->rx_nr_pages;
+ rmem->page_size = HW_RXBD_RING_SIZE;
+ rmem->pg_arr = (void **)rxr->rx_desc_ring;
+ rmem->dma_arr = rxr->rx_desc_mapping;
+ rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages;
+ rmem->vmem = (void **)&rxr->rx_buf_ring;
+
+ ring = &rxr->rx_agg_ring_struct;
+ rmem = &ring->ring_mem;
+ rmem->nr_pages = bp->rx_agg_nr_pages;
+ rmem->page_size = HW_RXBD_RING_SIZE;
+ rmem->pg_arr = (void **)rxr->rx_agg_desc_ring;
+ rmem->dma_arr = rxr->rx_agg_desc_mapping;
+ rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages;
+ rmem->vmem = (void **)&rxr->rx_agg_ring;
+}
+
static void bnxt_init_ring_struct(struct bnxt *bp)
{
int i, j;
@@ -4024,24 +4049,7 @@ static void bnxt_init_ring_struct(struct bnxt *bp)
rxr = bnapi->rx_ring;
if (!rxr)
goto skip_rx;
-
- ring = &rxr->rx_ring_struct;
- rmem = &ring->ring_mem;
- rmem->nr_pages = bp->rx_nr_pages;
- rmem->page_size = HW_RXBD_RING_SIZE;
- rmem->pg_arr = (void **)rxr->rx_desc_ring;
- rmem->dma_arr = rxr->rx_desc_mapping;
- rmem->vmem_size = SW_RXBD_RING_SIZE * bp->rx_nr_pages;
- rmem->vmem = (void **)&rxr->rx_buf_ring;
-
- ring = &rxr->rx_agg_ring_struct;
- rmem = &ring->ring_mem;
- rmem->nr_pages = bp->rx_agg_nr_pages;
- rmem->page_size = HW_RXBD_RING_SIZE;
- rmem->pg_arr = (void **)rxr->rx_agg_desc_ring;
- rmem->dma_arr = rxr->rx_agg_desc_mapping;
- rmem->vmem_size = SW_RXBD_AGG_RING_SIZE * bp->rx_agg_nr_pages;
- rmem->vmem = (void **)&rxr->rx_agg_ring;
+ __bnxt_init_rx_ring_struct(bp, rxr);
skip_rx:
bnxt_for_each_napi_tx(j, bnapi, txr) {
--
2.43.0
Powered by blists - more mailing lists