From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, gospo@broadcom.com,
Andy Gospodarek <andrew.gospodarek@broadcom.com>
Subject: [PATCH net-next 05/13] bnxt_en: Remove BNXT_RX_HDL and BNXT_TX_HDL
Date: Fri, 27 Oct 2023 16:22:44 -0700 [thread overview]
Message-ID: <20231027232252.36111-6-michael.chan@broadcom.com> (raw)
In-Reply-To: <20231027232252.36111-1-michael.chan@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 5678 bytes --]
These 2 constants were used for the one RX and one TX completion
ring pointer in the cpr->cp_ring_arr fixed array. Now that we've
changed to allocating the array for the exact number of entries to
support more TX rings, we no longer use these constants.
The array index as well as the type of completion ring (RX/TX) are
now encoded in the handle for the completion ring. This will allow
us to locate the completion ring during NAPI for any number of
completion rings sharing the same MSIX. In the following patches,
we'll be adding support for more TX rings associated with the same
MSIX vector.
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 51 +++++++++++++----------
drivers/net/ethernet/broadcom/bnxt/bnxt.h | 17 +++++++-
2 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 11a85cb28517..a4f7fa17daf8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -2906,12 +2906,15 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
if (nqcmp->type == cpu_to_le16(NQ_CN_TYPE_CQ_NOTIFICATION)) {
u32 idx = le32_to_cpu(nqcmp->cq_handle_low);
+ u32 cq_type = BNXT_NQ_HDL_TYPE(idx);
struct bnxt_cp_ring_info *cpr2;
/* No more budget for RX work */
- if (budget && work_done >= budget && idx == BNXT_RX_HDL)
+ if (budget && work_done >= budget &&
+ cq_type == BNXT_NQ_HDL_TYPE_RX)
break;
+ idx = BNXT_NQ_HDL_IDX(idx);
cpr2 = &cpr->cp_ring_arr[idx];
work_done += __bnxt_poll_work(bp, cpr2,
budget - work_done);
@@ -2927,8 +2930,9 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
BNXT_DB_NQ_P5(&cpr->cp_db, raw_cons);
}
poll_done:
- cpr_rx = &cpr->cp_ring_arr[BNXT_RX_HDL];
- if (cpr_rx->bnapi && (bp->flags & BNXT_FLAG_DIM)) {
+ cpr_rx = &cpr->cp_ring_arr[0];
+ if (cpr_rx->cp_ring_type == BNXT_NQ_HDL_TYPE_RX &&
+ (bp->flags & BNXT_FLAG_DIM)) {
struct dim_sample dim_sample = {};
dim_update_sample(cpr->event_ctr,
@@ -3592,6 +3596,7 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr, *cpr2;
struct bnxt_ring_struct *ring;
+ int cp_count = 0, k;
if (!bnapi)
continue;
@@ -3612,30 +3617,32 @@ static int bnxt_alloc_cp_rings(struct bnxt *bp)
if (!(bp->flags & BNXT_FLAG_CHIP_P5))
continue;
- cpr->cp_ring_count = 2;
- cpr->cp_ring_arr = kcalloc(cpr->cp_ring_count, sizeof(*cpr),
+ if (i < bp->rx_nr_rings)
+ cp_count++;
+ if ((sh && i < bp->tx_nr_rings) ||
+ (!sh && i >= bp->rx_nr_rings))
+ cp_count++;
+
+ cpr->cp_ring_arr = kcalloc(cp_count, sizeof(*cpr),
GFP_KERNEL);
- if (!cpr->cp_ring_arr) {
- cpr->cp_ring_count = 0;
+ if (!cpr->cp_ring_arr)
return -ENOMEM;
- }
+ cpr->cp_ring_count = cp_count;
- if (i < bp->rx_nr_rings) {
- cpr2 = &cpr->cp_ring_arr[BNXT_RX_HDL];
- rc = bnxt_alloc_cp_sub_ring(bp, cpr2);
- if (rc)
- return rc;
- cpr2->bnapi = bnapi;
- bp->rx_ring[i].rx_cpr = cpr2;
- }
- if ((sh && i < bp->tx_nr_rings) ||
- (!sh && i >= bp->rx_nr_rings)) {
- cpr2 = &cpr->cp_ring_arr[BNXT_TX_HDL];
+ for (k = 0; k < cp_count; k++) {
+ cpr2 = &cpr->cp_ring_arr[k];
rc = bnxt_alloc_cp_sub_ring(bp, cpr2);
if (rc)
return rc;
cpr2->bnapi = bnapi;
- bp->tx_ring[j++].tx_cpr = cpr2;
+ cpr2->cp_idx = k;
+ if (!k && i < bp->rx_nr_rings) {
+ bp->rx_ring[i].rx_cpr = cpr2;
+ cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_RX;
+ } else {
+ bp->tx_ring[j++].tx_cpr = cpr2;
+ cpr2->cp_ring_type = BNXT_NQ_HDL_TYPE_TX;
+ }
}
}
return 0;
@@ -6023,7 +6030,7 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
u32 type2 = HWRM_RING_ALLOC_CMPL;
ring = &cpr2->cp_ring_struct;
- ring->handle = BNXT_TX_HDL;
+ ring->handle = BNXT_SET_NQ_HDL(cpr2);
map_idx = bnapi->index;
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
if (rc)
@@ -6060,7 +6067,7 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
u32 type2 = HWRM_RING_ALLOC_CMPL;
ring = &cpr2->cp_ring_struct;
- ring->handle = BNXT_RX_HDL;
+ ring->handle = BNXT_SET_NQ_HDL(cpr2);
rc = hwrm_ring_alloc_send_msg(bp, ring, type2, map_idx);
if (rc)
goto err_out;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index c04089e7ac39..efb0db54575b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -543,6 +543,19 @@ struct nqe_cn {
__le32 cq_handle_high;
};
+#define BNXT_NQ_HDL_IDX_MASK 0x00ffffff
+#define BNXT_NQ_HDL_TYPE_MASK 0xff000000
+#define BNXT_NQ_HDL_TYPE_SHIFT 24
+#define BNXT_NQ_HDL_TYPE_RX 0x00
+#define BNXT_NQ_HDL_TYPE_TX 0x01
+
+#define BNXT_NQ_HDL_IDX(hdl) ((hdl) & BNXT_NQ_HDL_IDX_MASK)
+#define BNXT_NQ_HDL_TYPE(hdl) (((hdl) & BNXT_NQ_HDL_TYPE_MASK) >> \
+ BNXT_NQ_HDL_TYPE_SHIFT)
+
+#define BNXT_SET_NQ_HDL(cpr) \
+ (((cpr)->cp_ring_type << BNXT_NQ_HDL_TYPE_SHIFT) | (cpr)->cp_idx)
+
#define DB_IDX_MASK 0xffffff
#define DB_IDX_VALID (0x1 << 26)
#define DB_IRQ_DIS (0x1 << 27)
@@ -997,6 +1010,8 @@ struct bnxt_cp_ring_info {
u8 had_work_done:1;
u8 has_more_work:1;
+ u8 cp_ring_type;
+ u8 cp_idx;
u32 last_cp_raw_cons;
@@ -1023,8 +1038,6 @@ struct bnxt_cp_ring_info {
int cp_ring_count;
struct bnxt_cp_ring_info *cp_ring_arr;
-#define BNXT_RX_HDL 0
-#define BNXT_TX_HDL 1
};
struct bnxt_napi {
--
2.30.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
next prev parent reply other threads:[~2023-10-27 23:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-27 23:22 [PATCH net-next 00/13] bnxt_en: TX path improvements Michael Chan
2023-10-27 23:22 ` [PATCH net-next 01/13] bnxt_en: Put the TX producer information in the TX BD opaque field Michael Chan
2023-10-27 23:22 ` [PATCH net-next 02/13] bnxt_en: Add completion ring pointer in TX and RX ring structures Michael Chan
2023-10-27 23:22 ` [PATCH net-next 03/13] bnxt_en: Restructure cp_ring_arr in struct bnxt_cp_ring_info Michael Chan
2023-10-27 23:22 ` [PATCH net-next 04/13] bnxt_en: Add completion ring pointer in TX and RX ring structures Michael Chan
2023-10-27 23:22 ` Michael Chan [this message]
2023-10-27 23:22 ` [PATCH net-next 06/13] bnxt_en: Refactor bnxt_tx_int() Michael Chan
2023-10-27 23:22 ` [PATCH net-next 07/13] bnxt_en: New encoding for the TX opaque field Michael Chan
2023-10-27 23:22 ` [PATCH net-next 08/13] bnxt_en: Refactor bnxt_hwrm_set_coal() Michael Chan
2023-10-27 23:22 ` [PATCH net-next 09/13] bnxt_en: Support up to 8 TX rings per MSIX Michael Chan
2023-10-27 23:22 ` [PATCH net-next 10/13] bnxt_en: Add helper to get the number of CP rings required for TX rings Michael Chan
2023-10-27 23:22 ` [PATCH net-next 11/13] bnxt_en: Add macros related to TC and " Michael Chan
2023-10-27 23:22 ` [PATCH net-next 12/13] bnxt_en: Use existing MSIX vectors for all mqprio " Michael Chan
2023-10-27 23:22 ` [PATCH net-next 13/13] bnxt_en: Optimize xmit_more TX path Michael Chan
2023-10-30 6:33 ` [PATCH net-next 00/13] bnxt_en: TX path improvements Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231027232252.36111-6-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gospo@broadcom.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.