From: Vikas Gupta <vikas.gupta@broadcom.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bhargava.marreddy@broadcom.com, rahul-rg.gupta@broadcom.com,
vsrama-krishna.nemani@broadcom.com,
rajashekar.hudumula@broadcom.com, dharmender.garg@broadcom.com,
ajit.khaparde@broadcom.com,
Vikas Gupta <vikas.gupta@broadcom.com>
Subject: [PATCH net-next v5 10/10] bnge: add cpu_rmap support for IRQ affinity
Date: Tue, 3 Nov 2026 18:06:50 +0530 [thread overview]
Message-ID: <20261103123651.442893-11-vikas.gupta@broadcom.com> (raw)
In-Reply-To: <20261103123651.442893-1-vikas.gupta@broadcom.com>
When CONFIG_RFS_ACCEL is enabled, allocate and populate a cpu_rmap
for the RX IRQ vectors so that the kernel's aRFS infrastructure can
correctly map flows to the RX queues serviced by the nearest CPU.
This ensures that NTUPLE rules created by the kernel steer packets
to the optimal queue based on CPU/IRQ affinity.
Also, This is the patch that turns aRFS on. Before it dev->rx_cpu_rmap
was never set, so set_rps_cpu() took its early exit and
bnge_rx_flow_steer() from the previous patch was never called.
A failed rmap allocation does not fail the open; aRFS stays off.
If adding an IRQ to the rmap fails for one ring, aRFS is turned off
for all rings, because a later ring would otherwise take the free slot
and map to the wrong RX queue.
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Dharmender Garg <dharmender.garg@broadcom.com>
---
.../net/ethernet/broadcom/bnge/bnge_netdev.c | 57 ++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
index 835619604dc2..afdd00ff4944 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
@@ -18,6 +18,7 @@
#include <net/ip.h>
#include <linux/skbuff.h>
#include <net/page_pool/helpers.h>
+#include <linux/cpu_rmap.h>
#include "bnge.h"
#include "bnge_hwrm.h"
@@ -2460,10 +2461,23 @@ static int bnge_setup_interrupts(struct bnge_net *bn)
{
struct net_device *dev = bn->netdev;
struct bnge_dev *bd = bn->bd;
+ int rc;
bnge_setup_msix(bn);
- return netif_set_real_num_queues(dev, bd->tx_nr_rings, bd->rx_nr_rings);
+ rc = netif_set_real_num_queues(dev, bd->tx_nr_rings, bd->rx_nr_rings);
+ if (rc)
+ return rc;
+
+#ifdef CONFIG_RFS_ACCEL
+ if (bn->priv_flags & BNGE_NET_EN_NTUPLE) {
+ dev->rx_cpu_rmap = alloc_irq_cpu_rmap(bd->rx_nr_rings);
+ if (!dev->rx_cpu_rmap)
+ netdev_warn(dev, "Unable to allocate the CPU rmap, aRFS disabled\n");
+ }
+#endif
+
+ return rc;
}
static void bnge_hwrm_resource_free(struct bnge_net *bn, bool close_path)
@@ -2473,12 +2487,35 @@ static void bnge_hwrm_resource_free(struct bnge_net *bn, bool close_path)
bnge_hwrm_stat_ctx_free(bn);
}
+#ifdef CONFIG_RFS_ACCEL
+/* set_rps_cpu() reads rx_cpu_rmap under rcu_read_lock(). Hide the pointer and
+ * wait for readers that already loaded it before the rmap is freed.
+ */
+static void bnge_free_cpu_rmap(struct bnge_net *bn)
+{
+ struct cpu_rmap *rmap = bn->netdev->rx_cpu_rmap;
+
+ if (!rmap)
+ return;
+
+ WRITE_ONCE(bn->netdev->rx_cpu_rmap, NULL);
+ synchronize_net();
+ free_irq_cpu_rmap(rmap);
+}
+#else
+static inline void bnge_free_cpu_rmap(struct bnge_net *bn)
+{
+}
+#endif
+
static void bnge_free_irq(struct bnge_net *bn)
{
struct bnge_dev *bd = bn->bd;
struct bnge_irq *irq;
int i;
+ bnge_free_cpu_rmap(bn);
+
for (i = 0; i < bd->nq_nr_rings; i++) {
int map_idx = bnge_cp_num_to_irq_num(bn, i);
@@ -2498,6 +2535,7 @@ static void bnge_free_irq(struct bnge_net *bn)
static int bnge_request_irq(struct bnge_net *bn)
{
+ struct cpu_rmap *rmap = NULL;
struct bnge_dev *bd = bn->bd;
int i, rc;
@@ -2506,10 +2544,27 @@ static int bnge_request_irq(struct bnge_net *bn)
netdev_err(bn->netdev, "bnge_setup_interrupts err: %d\n", rc);
return rc;
}
+
+#ifdef CONFIG_RFS_ACCEL
+ rmap = bn->netdev->rx_cpu_rmap;
+#endif
+
for (i = 0; i < bd->nq_nr_rings; i++) {
int map_idx = bnge_cp_num_to_irq_num(bn, i);
struct bnge_irq *irq = &bd->irq_tbl[map_idx];
+ if (IS_ENABLED(CONFIG_RFS_ACCEL) &&
+ rmap && bn->bnapi[i]->rx_ring) {
+ rc = irq_cpu_rmap_add(rmap, irq->vector);
+ if (rc) {
+ netdev_warn(bn->netdev,
+ "failed adding irq rmap for ring %d, disabling aRFS\n",
+ i);
+ bnge_free_cpu_rmap(bn);
+ rmap = NULL;
+ }
+ }
+
rc = request_irq(irq->vector, irq->handler, 0, irq->name,
bn->bnapi[i]);
if (rc)
--
2.52.0
prev parent reply other threads:[~2026-11-03 12:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 12:36 [PATCH net-next v5 00/10] add features to bnge Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 01/10] bnge: restructure VNIC and filter code Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 02/10] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 03/10] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 04/10] bnge: add RXFH ethtool support Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 05/10] bnge: add ethtool support to manage RSS contexts Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 06/10] bnge: remove refcount from L2 filter Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 07/10] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 08/10] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-11-03 12:36 ` [PATCH net-next v5 09/10] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-11-03 12:36 ` Vikas Gupta [this message]
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=20261103123651.442893-11-vikas.gupta@broadcom.com \
--to=vikas.gupta@broadcom.com \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=bhargava.marreddy@broadcom.com \
--cc=davem@davemloft.net \
--cc=dharmender.garg@broadcom.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rahul-rg.gupta@broadcom.com \
--cc=rajashekar.hudumula@broadcom.com \
--cc=vsrama-krishna.nemani@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
all inboxes | Powered by JetHome®