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 06/11] bnge: add ethtool support to manage RSS contexts
Date: Fri, 14 Aug 2026 06:44:30 +0530 [thread overview]
Message-ID: <20260814011435.194631-7-vikas.gupta@broadcom.com> (raw)
In-Reply-To: <20260814011435.194631-1-vikas.gupta@broadcom.com>
Introduce ethtool callbacks to manage RSS contexts.
Each context allocates a dedicated VNIC with its own RSS indirection
table and hash key, configured with TPA settings matching those of the
default VNIC.
Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Reviewed-by: Dharmender Garg <dharmender.garg@broadcom.com>
---
.../net/ethernet/broadcom/bnge/bnge_ethtool.c | 129 ++++++++++++++++++
.../net/ethernet/broadcom/bnge/bnge_netdev.c | 5 +
.../net/ethernet/broadcom/bnge/bnge_resc.c | 2 +-
.../net/ethernet/broadcom/bnge/bnge_vnic.c | 22 ++-
.../net/ethernet/broadcom/bnge/bnge_vnic.h | 14 +-
5 files changed, 167 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
index c6f564045647..a12948087338 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c
@@ -1012,6 +1012,132 @@ static u32 bnge_get_rx_ring_count(struct net_device *dev)
return bd->rx_nr_rings;
}
+static int bnge_rxfh_context_check(struct bnge_net *bn,
+ const struct ethtool_rxfh_param *rxfh,
+ struct netlink_ext_ack *extack)
+{
+ if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) {
+ NL_SET_ERR_MSG_MOD(extack, "RSS hash function not supported");
+ return -EOPNOTSUPP;
+ }
+
+ if (!netif_running(bn->netdev)) {
+ NL_SET_ERR_MSG_MOD(extack, "Unable to set RSS contexts when interface is down");
+ return -EAGAIN;
+ }
+
+ return 0;
+}
+
+static int bnge_create_rxfh_context(struct net_device *dev,
+ struct ethtool_rxfh_context *ctx,
+ const struct ethtool_rxfh_param *rxfh,
+ struct netlink_ext_ack *extack)
+{
+ struct bnge_net *bn = netdev_priv(dev);
+ struct bnge_rss_ctx *rss_ctx;
+ struct bnge_vnic_info *vnic;
+ int rc;
+
+ rc = bnge_rxfh_context_check(bn, rxfh, extack);
+ if (rc)
+ return rc;
+
+ if (bn->num_rss_ctx >= BNGE_MAX_ETH_RSS_CTX) {
+ NL_SET_ERR_MSG_FMT_MOD(extack, "Out of RSS contexts, maximum %u",
+ BNGE_MAX_ETH_RSS_CTX);
+ return -EINVAL;
+ }
+
+ if (!bnge_arfs_capable(bn->bd, true)) {
+ NL_SET_ERR_MSG_MOD(extack, "Out of hardware resources");
+ return -ENOMEM;
+ }
+
+ rss_ctx = ethtool_rxfh_context_priv(ctx);
+
+ bn->num_rss_ctx++;
+
+ vnic = &rss_ctx->vnic;
+
+ bnge_init_vnic_mem(vnic);
+
+ vnic->rss_ctx = ctx;
+ vnic->flags |= BNGE_VNIC_RSSCTX_FLAG;
+ rc = bnge_alloc_vnic_rss_table(bn, vnic);
+ if (rc)
+ goto err_del_rss_ctx;
+
+ /* Populate defaults in the context */
+ bnge_set_dflt_rss_indir_tbl(bn->bd, ctx);
+ ctx->hfunc = ETH_RSS_HASH_TOP;
+ memcpy(vnic->rss_hash_key, bn->rss_hash_key, HW_HASH_KEY_SIZE);
+ memcpy(ethtool_rxfh_context_key(ctx),
+ bn->rss_hash_key, HW_HASH_KEY_SIZE);
+
+ rc = bnge_hwrm_vnic_alloc(bn->bd, vnic, bn->bd->rx_nr_rings);
+ if (rc) {
+ NL_SET_ERR_MSG_MOD(extack, "Unable to allocate VNIC");
+ goto err_del_rss_ctx;
+ }
+
+ rc = bnge_hwrm_vnic_set_tpa(bn->bd, vnic,
+ bn->priv_flags & BNGE_NET_EN_TPA);
+ if (rc) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Unable to set TPA settings to vnic");
+ goto err_del_rss_ctx;
+ }
+ bnge_modify_rss(bn, ctx, rss_ctx, rxfh);
+
+ rc = bnge_setup_vnic(bn, vnic);
+ if (rc) {
+ NL_SET_ERR_MSG_MOD(extack, "Unable to setup vnic");
+ goto err_del_rss_ctx;
+ }
+
+ rss_ctx->index = rxfh->rss_context;
+ return 0;
+
+err_del_rss_ctx:
+ bnge_del_one_rss_ctx(bn, rss_ctx, true);
+ return rc;
+}
+
+static int bnge_modify_rxfh_context(struct net_device *dev,
+ struct ethtool_rxfh_context *ctx,
+ const struct ethtool_rxfh_param *rxfh,
+ struct netlink_ext_ack *extack)
+{
+ struct bnge_net *bn = netdev_priv(dev);
+ struct bnge_rss_ctx *rss_ctx;
+ int rc;
+
+ rc = bnge_rxfh_context_check(bn, rxfh, extack);
+ if (rc)
+ return rc;
+
+ rss_ctx = ethtool_rxfh_context_priv(ctx);
+
+ bnge_modify_rss(bn, ctx, rss_ctx, rxfh);
+
+ return bnge_hwrm_vnic_rss_cfg(bn, &rss_ctx->vnic);
+}
+
+static int bnge_remove_rxfh_context(struct net_device *dev,
+ struct ethtool_rxfh_context *ctx,
+ u32 rss_context,
+ struct netlink_ext_ack *extack)
+{
+ struct bnge_net *bn = netdev_priv(dev);
+ struct bnge_rss_ctx *rss_ctx;
+
+ rss_ctx = ethtool_rxfh_context_priv(ctx);
+
+ bnge_del_one_rss_ctx(bn, rss_ctx, true);
+ return 0;
+}
+
static const struct ethtool_ops bnge_ethtool_ops = {
.cap_link_lanes_supported = 1,
.get_link_ksettings = bnge_get_link_ksettings,
@@ -1041,6 +1167,9 @@ static const struct ethtool_ops bnge_ethtool_ops = {
.set_rxfh = bnge_set_rxfh,
.get_rxfh_fields = bnge_get_rxfh_fields,
.set_rxfh_fields = bnge_set_rxfh_fields,
+ .create_rxfh_context = bnge_create_rxfh_context,
+ .modify_rxfh_context = bnge_modify_rxfh_context,
+ .remove_rxfh_context = bnge_remove_rxfh_context,
};
void bnge_set_ethtool_ops(struct net_device *dev)
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
index 1a55c2fe4532..3c2cb9571af1 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
@@ -2785,6 +2785,8 @@ int bnge_open_core(struct bnge_net *bn)
/* Poll link status and check for SFP+ module status */
bnge_get_port_module_status(bn);
+ bnge_hwrm_realloc_rss_ctx_vnic(bn);
+
return 0;
err_free_irq:
@@ -3002,7 +3004,10 @@ void bnge_close_core(struct bnge_net *bn)
clear_bit(BNGE_STATE_OPEN, &bd->state);
timer_delete_sync(&bn->timer);
+
+ bnge_clear_rss_ctxs(bn);
bnge_shutdown_nic(bn);
+
bnge_disable_napi(bn);
/* Save ring stats before shutdown */
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
index 9604bd05ba37..2fa7e829eef2 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_resc.c
@@ -353,7 +353,7 @@ int bnge_reserve_rings(struct bnge_dev *bd)
return -ENOMEM;
if (old_rx_rings != bd->hw_resc.resv_rx_rings)
- bnge_set_dflt_rss_indir_tbl(bd);
+ bnge_set_dflt_rss_indir_tbl(bd, NULL);
if (!bnge_aux_registered(bd)) {
u16 resv_msix, resv_ctx, aux_ctxs;
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c
index 417abc7e8c74..40a6abcafce8 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.c
@@ -12,14 +12,19 @@
#include "bnge_filter.h"
#include "bnge_ethtool.h"
-void bnge_set_dflt_rss_indir_tbl(struct bnge_dev *bd)
+void bnge_set_dflt_rss_indir_tbl(struct bnge_dev *bd,
+ struct ethtool_rxfh_context *rss_ctx)
{
u16 max_entries, pad;
u32 *rss_indir_tbl;
u16 i;
max_entries = bnge_get_rxfh_indir_size(bd);
- rss_indir_tbl = &bd->rss_indir_tbl[0];
+
+ if (rss_ctx)
+ rss_indir_tbl = ethtool_rxfh_context_indir(rss_ctx);
+ else
+ rss_indir_tbl = &bd->rss_indir_tbl[0];
for (i = 0; i < max_entries; i++)
rss_indir_tbl[i] = ethtool_rxfh_indir_default(i,
@@ -44,6 +49,8 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic)
if (vnic->flags & BNGE_VNIC_NTUPLE_FLAG)
j = ethtool_rxfh_indir_default(i, bd->rx_nr_rings);
+ else if (vnic->flags & BNGE_VNIC_RSSCTX_FLAG)
+ j = ethtool_rxfh_context_indir(vnic->rss_ctx)[i];
else
j = bd->rss_indir_tbl[i];
@@ -238,3 +245,14 @@ int bnge_alloc_vnic_rss_table(struct bnge_net *bn,
vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size;
return 0;
}
+
+void bnge_init_vnic_mem(struct bnge_vnic_info *vnic)
+{
+ int i;
+
+ vnic->fw_vnic_id = INVALID_HW_RING_ID;
+ vnic->vnic_id = BNGE_VNIC_ID_INVALID;
+
+ for (i = 0; i < BNGE_MAX_CTX_PER_VNIC; i++)
+ vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID;
+}
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.h b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.h
index b2a1d8332a5f..3954c450315d 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_vnic.h
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_vnic.h
@@ -21,6 +21,11 @@ struct bnge_l2_filter;
#define BNGE_MAX_MC_ADDRS 16
#define BNGE_MAX_UC_ADDRS 4
+#define BNGE_VNIC_ID_INVALID 0xffffffff
+
+struct ethtool_rxfh_context;
+struct ethtool_rxfh_param;
+
enum {
BNGE_VNIC_DEFAULT = 0,
BNGE_VNIC_NTUPLE = 1
@@ -30,7 +35,8 @@ enum {
BNGE_VNIC_RSS_FLAG = BIT(0),
BNGE_VNIC_MCAST_FLAG = BIT(1),
BNGE_VNIC_UCAST_FLAG = BIT(2),
- BNGE_VNIC_NTUPLE_FLAG = BIT(3)
+ BNGE_VNIC_NTUPLE_FLAG = BIT(3),
+ BNGE_VNIC_RSSCTX_FLAG = BIT(4)
};
struct bnge_vnic_info {
@@ -55,6 +61,8 @@ struct bnge_vnic_info {
u32 flags;
u32 vnic_id;
+
+ struct ethtool_rxfh_context *rss_ctx;
};
struct bnge_rss_ctx {
@@ -66,7 +74,8 @@ void bnge_fill_hw_rss_tbl(struct bnge_net *bn, struct bnge_vnic_info *vnic);
int bnge_hwrm_vnic_rss_cfg(struct bnge_net *bn,
struct bnge_vnic_info *vnic);
int bnge_setup_vnic(struct bnge_net *bn, struct bnge_vnic_info *vnic);
-void bnge_set_dflt_rss_indir_tbl(struct bnge_dev *bd);
+void bnge_set_dflt_rss_indir_tbl(struct bnge_dev *bd,
+ struct ethtool_rxfh_context *ctx);
int bnge_alloc_rfs_vnic(struct bnge_net *bn);
int bnge_alloc_vnic_rss_table(struct bnge_net *bn,
struct bnge_vnic_info *vnic);
@@ -78,4 +87,5 @@ void bnge_del_one_rss_ctx(struct bnge_net *bn, struct bnge_rss_ctx *rss_ctx,
bool all);
void bnge_hwrm_realloc_rss_ctx_vnic(struct bnge_net *bn);
void bnge_clear_rss_ctxs(struct bnge_net *bn);
+void bnge_init_vnic_mem(struct bnge_vnic_info *vnic);
#endif /* _BNGE_VNIC_H_ */
--
2.47.1
next prev parent reply other threads:[~2026-08-14 1:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 1:14 [PATCH net-next 00/11] add features to bnge Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 01/11] bnge: update HSI Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 02/11] bnge: restructure VNIC and filter code Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 03/11] bnge: add NTUPLE/ARFS VNIC Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 04/11] bnge: add helper functions for multi RSS contexts Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 05/11] bnge: add RXFH ethtool support Vikas Gupta
2026-08-14 1:14 ` Vikas Gupta [this message]
2026-08-14 1:14 ` [PATCH net-next 07/11] bnge: remove refcount from L2 filter Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 08/11] bnge: add NTUPLE filter infrastructure Vikas Gupta
2026-08-17 23:35 ` Jakub Kicinski
2026-08-14 1:14 ` [PATCH net-next 09/11] bnge: add NTUPLE filter support in ethtool Vikas Gupta
2026-08-14 1:14 ` [PATCH net-next 10/11] bnge: add aRFS flow steering ndo support Vikas Gupta
2026-08-17 23:36 ` Jakub Kicinski
2026-08-14 1:14 ` [PATCH net-next 11/11] bnge: add cpu_rmap support for IRQ affinity Vikas Gupta
2026-08-17 23:38 ` [PATCH net-next 00/11] add features to bnge 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=20260814011435.194631-7-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®