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, pavan.chebbi@broadcom.com,
andrew.gospodarek@broadcom.com, horms@kernel.org,
helgaas@kernel.org, Hongguang Gao <hongguang.gao@broadcom.com>,
Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [PATCH net-next v2 9/9] bnxt_en: Support dynamic MSIX
Date: Fri, 16 Aug 2024 14:28:32 -0700 [thread overview]
Message-ID: <20240816212832.185379-10-michael.chan@broadcom.com> (raw)
In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com>
A range of MSIX vectors are allocated at initialization for the number
needed for RocE and L2. During run-time, if the user increases or
decreases the number of L2 rings, all the MSIX vectors have to be
freed and a new range has to be allocated. This is not optimal and
causes disruptions to RoCE traffic every time there is a change in L2
MSIX.
If the system supports dynamic MSIX allocations, use dynamic
allocation to add new L2 MSIX vectors or free unneeded L2 MSIX
vectors. RoCE traffic is not affected using this scheme.
Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
v2: Fix typo in changelog
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 57 +++++++++++++++++++++--
1 file changed, 54 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index b969ace6b4d1..d702fc1d9ed5 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -10624,6 +10624,43 @@ static void bnxt_setup_msix(struct bnxt *bp)
static int bnxt_init_int_mode(struct bnxt *bp);
+static int bnxt_add_msix(struct bnxt *bp, int total)
+{
+ int i;
+
+ if (bp->total_irqs >= total)
+ return total;
+
+ for (i = bp->total_irqs; i < total; i++) {
+ struct msi_map map;
+
+ map = pci_msix_alloc_irq_at(bp->pdev, i, NULL);
+ if (map.index < 0)
+ break;
+ bp->irq_tbl[i].vector = map.virq;
+ bp->total_irqs++;
+ }
+ return bp->total_irqs;
+}
+
+static int bnxt_trim_msix(struct bnxt *bp, int total)
+{
+ int i;
+
+ if (bp->total_irqs <= total)
+ return total;
+
+ for (i = bp->total_irqs; i > total; i--) {
+ struct msi_map map;
+
+ map.index = i - 1;
+ map.virq = bp->irq_tbl[i - 1].vector;
+ pci_msix_free_irq(bp->pdev, map);
+ bp->total_irqs--;
+ }
+ return bp->total_irqs;
+}
+
static int bnxt_setup_int_mode(struct bnxt *bp)
{
int rc;
@@ -10790,6 +10827,7 @@ static void bnxt_clear_int_mode(struct bnxt *bp)
int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
{
bool irq_cleared = false;
+ bool irq_change = false;
int tcs = bp->num_tc;
int irqs_required;
int rc;
@@ -10808,15 +10846,28 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
}
if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) {
- bnxt_ulp_irq_stop(bp);
- bnxt_clear_int_mode(bp);
- irq_cleared = true;
+ irq_change = true;
+ if (!pci_msix_can_alloc_dyn(bp->pdev)) {
+ bnxt_ulp_irq_stop(bp);
+ bnxt_clear_int_mode(bp);
+ irq_cleared = true;
+ }
}
rc = __bnxt_reserve_rings(bp);
if (irq_cleared) {
if (!rc)
rc = bnxt_init_int_mode(bp);
bnxt_ulp_irq_restart(bp, rc);
+ } else if (irq_change && !rc) {
+ int total;
+
+ if (irqs_required > bp->total_irqs)
+ total = bnxt_add_msix(bp, irqs_required);
+ else
+ total = bnxt_trim_msix(bp, irqs_required);
+
+ if (total != irqs_required)
+ rc = -ENOSPC;
}
if (rc) {
netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc);
--
2.30.1
next prev parent reply other threads:[~2024-08-16 21:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 21:28 [PATCH net-next v2 0/9] bnxt_en: Update for net-next Michael Chan
2024-08-16 21:28 ` [PATCH net-next v2 1/9] bnxt_en: add support for storing crash dump into host memory Michael Chan
2024-08-19 10:00 ` Przemek Kitszel
2024-08-20 18:09 ` Michael Chan
2024-08-16 21:28 ` [PATCH net-next v2 2/9] bnxt_en: add support for retrieving crash dump using ethtool Michael Chan
2024-08-19 10:12 ` Przemek Kitszel
2024-08-20 1:41 ` Jakub Kicinski
2024-08-16 21:28 ` [PATCH net-next v2 3/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Michael Chan
2024-08-16 21:28 ` [PATCH net-next v2 4/9] bnxt_en: Deprecate support for legacy INTX mode Michael Chan
2024-08-19 9:17 ` Simon Horman
2024-08-16 21:28 ` [PATCH net-next v2 5/9] bnxt_en: Remove BNXT_FLAG_USING_MSIX flag Michael Chan
2024-08-16 21:28 ` [PATCH net-next v2 6/9] bnxt_en: Remove register mapping to support INTX Michael Chan
2024-08-16 21:28 ` [PATCH net-next v2 7/9] bnxt_en: Replace deprecated PCI MSIX APIs Michael Chan
2024-08-19 10:20 ` Przemek Kitszel
2024-08-16 21:28 ` [PATCH net-next v2 8/9] bnxt_en: Allocate the max bp->irq_tbl size for dynamic msix allocation Michael Chan
2024-08-19 10:31 ` Przemek Kitszel
2024-08-16 21:28 ` Michael Chan [this message]
2024-08-19 10:33 ` [PATCH net-next v2 9/9] bnxt_en: Support dynamic MSIX Przemek Kitszel
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=20240816212832.185379-10-michael.chan@broadcom.com \
--to=michael.chan@broadcom.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=helgaas@kernel.org \
--cc=hongguang.gao@broadcom.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=somnath.kotur@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).