Netdev List
 help / color / mirror / Atom feed
* [net-next, v2 0/3] bnge: add more functionality
@ 2026-07-31 16:37 Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 1/3] bnge: refactor rx mode helpers to accept explicit address lists Vikas Gupta
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vikas Gupta @ 2026-07-31 16:37 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: netdev, linux-kernel, bhargava.marreddy, rahul-rg.gupta,
	vsrama-krishna.nemani, rajashekar.hudumula, dharmender.garg,
	ajit.khaparde, Vikas Gupta

Hi,

This patch series adds a few functionality for bnge driver:

Patch 1-2: Implements ndo_set_rx_mode_async().

Patch 3: Adds a dedicated HWRM (Hardware Resource Management) command
         sequence to handle explicit interface down and up transitions cleanly.

Thanks,
Vikas

v1->v2:
1)  Addressed review comments from Sashiko.
    https://sashiko.dev/#/patchset/20260724142954.3101980-2-vikas.gupta@broadcom.com
    https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260724142954.3101980-2-vikas.gupta@broadcom.com

2) Removed a patch (bnge shutdown callback implementation) from the series, bringing
   the patch count down to 3. The implementation shall be pushed in a separate series.

Vikas Gupta (3):
  bnge: refactor rx mode helpers to accept explicit address lists
  bnge: add ndo_set_rx_mode_async support
  bnge: send hwrm for interface down/up transitions

 .../net/ethernet/broadcom/bnge/bnge_netdev.c  | 132 ++++++++++++++----
 .../net/ethernet/broadcom/bnge/bnge_netdev.h  |   6 +
 2 files changed, 112 insertions(+), 26 deletions(-)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [net-next, v2 1/3] bnge: refactor rx mode helpers to accept explicit address lists
  2026-07-31 16:37 [net-next, v2 0/3] bnge: add more functionality Vikas Gupta
@ 2026-07-31 16:37 ` Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 2/3] bnge: add ndo_set_rx_mode_async support Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 3/3] bnge: send hwrm for interface down/up transitions Vikas Gupta
  2 siblings, 0 replies; 4+ messages in thread
From: Vikas Gupta @ 2026-07-31 16:37 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: netdev, linux-kernel, bhargava.marreddy, rahul-rg.gupta,
	vsrama-krishna.nemani, rajashekar.hudumula, dharmender.garg,
	ajit.khaparde, Vikas Gupta

Rename bnge_cfg_def_vnic() to bnge_cfg_rx_mode() and update
bnge_mc_list_updated() and bnge_uc_list_updated() to accept
explicit netdev_hw_addr_list pointers rather than deriving
them from the netdev.

Add a snapshot parameter to bnge_cfg_rx_mode() to skip
netif_addr_lock_bh() when the caller provides a pre-snapshotted
list. On the open path (snapshot=false), the live netdev UC list
is passed and the addr lock is taken as before.

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Dharmender Garg <dharmender.garg@broadcom.com>
Reviewed-by: Rahul Gupta <rahul-rg.gupta@broadcom.com>
---
 .../net/ethernet/broadcom/bnge/bnge_netdev.c  | 39 +++++++++++--------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
index 6f7ef506d4e1..db0e616fc46c 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
@@ -2144,16 +2144,16 @@ static int bnge_hwrm_set_vnic_filter(struct bnge_net *bn, u16 vnic_id, u16 idx,
 	return rc;
 }
 
-static bool bnge_mc_list_updated(struct bnge_net *bn, u32 *rx_mask)
+static bool bnge_mc_list_updated(struct bnge_net *bn, u32 *rx_mask,
+				 const struct netdev_hw_addr_list *mc)
 {
 	struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT];
-	struct net_device *dev = bn->netdev;
 	struct netdev_hw_addr *ha;
 	int mc_count = 0, off = 0;
 	bool update = false;
 	u8 *haddr;
 
-	netdev_for_each_mc_addr(ha, dev) {
+	netdev_hw_addr_list_for_each(ha, mc) {
 		if (mc_count >= BNGE_MAX_MC_ADDRS) {
 			*rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST;
 			vnic->mc_list_count = 0;
@@ -2177,17 +2177,17 @@ static bool bnge_mc_list_updated(struct bnge_net *bn, u32 *rx_mask)
 	return update;
 }
 
-static bool bnge_uc_list_updated(struct bnge_net *bn)
+static bool bnge_uc_list_updated(struct bnge_net *bn,
+				 const struct netdev_hw_addr_list *uc)
 {
 	struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT];
-	struct net_device *dev = bn->netdev;
 	struct netdev_hw_addr *ha;
 	int off = 0;
 
-	if (netdev_uc_count(dev) != (vnic->uc_filter_count - 1))
+	if (netdev_hw_addr_list_count(uc) != (vnic->uc_filter_count - 1))
 		return true;
 
-	netdev_for_each_uc_addr(ha, dev) {
+	netdev_hw_addr_list_for_each(ha, uc) {
 		if (!ether_addr_equal(ha->addr, vnic->uc_list + off))
 			return true;
 
@@ -2201,7 +2201,8 @@ static bool bnge_promisc_ok(struct bnge_net *bn)
 	return true;
 }
 
-static int bnge_cfg_def_vnic(struct bnge_net *bn)
+static int bnge_cfg_rx_mode(struct bnge_net *bn, struct netdev_hw_addr_list *uc,
+			    bool snapshot)
 {
 	struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT];
 	struct net_device *dev = bn->netdev;
@@ -2211,7 +2212,7 @@ static int bnge_cfg_def_vnic(struct bnge_net *bn)
 	bool uc_update;
 
 	netif_addr_lock_bh(dev);
-	uc_update = bnge_uc_list_updated(bn);
+	uc_update = bnge_uc_list_updated(bn, uc);
 	netif_addr_unlock_bh(dev);
 
 	if (!uc_update)
@@ -2226,22 +2227,28 @@ static int bnge_cfg_def_vnic(struct bnge_net *bn)
 
 	vnic->uc_filter_count = 1;
 
-	netif_addr_lock_bh(dev);
-	if (netdev_uc_count(dev) > (BNGE_MAX_UC_ADDRS - 1)) {
+	if (!snapshot)
+		netif_addr_lock_bh(dev);
+	if (netdev_hw_addr_list_count(uc) > (BNGE_MAX_UC_ADDRS - 1)) {
 		vnic->rx_mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS;
 	} else {
-		netdev_for_each_uc_addr(ha, dev) {
+		netdev_hw_addr_list_for_each(ha, uc) {
 			memcpy(vnic->uc_list + off, ha->addr, ETH_ALEN);
 			off += ETH_ALEN;
 			vnic->uc_filter_count++;
 		}
 	}
-	netif_addr_unlock_bh(dev);
+	if (!snapshot)
+		netif_addr_unlock_bh(dev);
 
 	for (i = 1, off = 0; i < vnic->uc_filter_count; i++, off += ETH_ALEN) {
 		rc = bnge_hwrm_set_vnic_filter(bn, 0, i, vnic->uc_list + off);
 		if (rc) {
-			netdev_err(dev, "HWRM vnic filter failure rc: %d\n", rc);
+			if (rc == -EAGAIN)
+				netdev_warn(dev, "FW busy while setting vnic filter, will retry\n");
+			else
+				netdev_err(dev, "HWRM vnic filter failure rc: %d\n",
+					   rc);
 			vnic->uc_filter_count = i;
 			return rc;
 		}
@@ -2695,11 +2702,11 @@ static int bnge_init_chip(struct bnge_net *bn)
 	} else if (bn->netdev->flags & IFF_MULTICAST) {
 		u32 mask = 0;
 
-		bnge_mc_list_updated(bn, &mask);
+		bnge_mc_list_updated(bn, &mask, &bn->netdev->mc);
 		vnic->rx_mask |= mask;
 	}
 
-	rc = bnge_cfg_def_vnic(bn);
+	rc = bnge_cfg_rx_mode(bn, &bn->netdev->uc, false);
 	if (rc)
 		goto err_out;
 	return 0;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net-next, v2 2/3] bnge: add ndo_set_rx_mode_async support
  2026-07-31 16:37 [net-next, v2 0/3] bnge: add more functionality Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 1/3] bnge: refactor rx mode helpers to accept explicit address lists Vikas Gupta
@ 2026-07-31 16:37 ` Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 3/3] bnge: send hwrm for interface down/up transitions Vikas Gupta
  2 siblings, 0 replies; 4+ messages in thread
From: Vikas Gupta @ 2026-07-31 16:37 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: netdev, linux-kernel, bhargava.marreddy, rahul-rg.gupta,
	vsrama-krishna.nemani, rajashekar.hudumula, dharmender.garg,
	ajit.khaparde, Vikas Gupta

Register bnge_set_rx_mode() as ndo_set_rx_mode_async to handle
unicast, multicast, broadcast, and promiscuous filter updates via
CFA_L2_SET_RX_MASK. The async variant receives pre-snapshotted address
lists from the kernel, allowing the driver to issue sleepable HWRM
firmware commands without holding the addr lock.

Move uc_update detection to the caller so the async path can compute
it directly from the snapshotted UC list before calling
bnge_cfg_rx_mode().

Handle -EAGAIN from bnge_hwrm_set_vnic_filter() and
bnge_hwrm_cfa_l2_set_rx_mask() on the open path by scheduling a retry
via netif_rx_mode_schedule_retry() rather than failing the open.

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Dharmender Garg <dharmender.garg@broadcom.com>
Reviewed-by: Rahul Gupta <rahul-rg.gupta@broadcom.com>
---
 .../net/ethernet/broadcom/bnge/bnge_netdev.c  | 67 ++++++++++++++++---
 .../net/ethernet/broadcom/bnge/bnge_netdev.h  |  6 ++
 2 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
index db0e616fc46c..d47eb9bc5b8d 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
@@ -2202,18 +2202,13 @@ static bool bnge_promisc_ok(struct bnge_net *bn)
 }
 
 static int bnge_cfg_rx_mode(struct bnge_net *bn, struct netdev_hw_addr_list *uc,
-			    bool snapshot)
+			    bool uc_update, bool snapshot)
 {
 	struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT];
 	struct net_device *dev = bn->netdev;
 	struct bnge_dev *bd = bn->bd;
 	struct netdev_hw_addr *ha;
 	int i, off = 0, rc;
-	bool uc_update;
-
-	netif_addr_lock_bh(dev);
-	uc_update = bnge_uc_list_updated(bn, uc);
-	netif_addr_unlock_bh(dev);
 
 	if (!uc_update)
 		goto skip_uc;
@@ -2267,13 +2262,58 @@ static int bnge_cfg_rx_mode(struct bnge_net *bn, struct netdev_hw_addr_list *uc,
 		vnic->mc_list_count = 0;
 		rc = bnge_hwrm_cfa_l2_set_rx_mask(bd, vnic);
 	}
-	if (rc)
-		netdev_err(dev, "HWRM cfa l2 rx mask failure rc: %d\n",
-			   rc);
+	if (rc) {
+		if (rc == -EAGAIN) {
+			netdev_warn(dev, "FW busy while setting l2 rx mask in CFA, will retry\n");
+			vnic->rx_mask &= ~BNGE_RX_MASK_CFG_FLAGS;
+		} else {
+			netdev_err(dev, "HWRM CFA L2 rx mask failure rc: %d\n",
+				   rc);
+		}
+	}
 
 	return rc;
 }
 
+static int bnge_set_rx_mode(struct net_device *dev,
+			    struct netdev_hw_addr_list *uc,
+			    struct netdev_hw_addr_list *mc)
+{
+	struct bnge_net *bn = netdev_priv(dev);
+	struct bnge_vnic_info *vnic;
+	bool mc_update = false;
+	bool uc_update;
+	u32 mask;
+
+	if (!test_bit(BNGE_STATE_OPEN, &bn->bd->state))
+		return 0;
+
+	vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT];
+	mask = vnic->rx_mask;
+	mask &= ~BNGE_RX_MASK_CFG_FLAGS;
+
+	if (dev->flags & IFF_PROMISC)
+		mask |= CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS;
+
+	uc_update = bnge_uc_list_updated(bn, uc);
+
+	if (dev->flags & IFF_BROADCAST)
+		mask |= CFA_L2_SET_RX_MASK_REQ_MASK_BCAST;
+	if (dev->flags & IFF_ALLMULTI) {
+		mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST;
+		vnic->mc_list_count = 0;
+	} else if (dev->flags & IFF_MULTICAST) {
+		mc_update = bnge_mc_list_updated(bn, &mask, mc);
+	}
+
+	if (mask != vnic->rx_mask || uc_update || mc_update) {
+		vnic->rx_mask = mask;
+		return bnge_cfg_rx_mode(bn, uc, uc_update, true);
+	}
+
+	return 0;
+}
+
 static void bnge_disable_int(struct bnge_net *bn)
 {
 	struct bnge_dev *bd = bn->bd;
@@ -2706,9 +2746,13 @@ static int bnge_init_chip(struct bnge_net *bn)
 		vnic->rx_mask |= mask;
 	}
 
-	rc = bnge_cfg_rx_mode(bn, &bn->netdev->uc, false);
-	if (rc)
+	rc = bnge_cfg_rx_mode(bn, &bn->netdev->uc, true, false);
+	if (rc == -EAGAIN) {
+		netif_rx_mode_schedule_retry(bn->netdev);
+		rc = 0;
+	} else if (rc) {
 		goto err_out;
+	}
 	return 0;
 
 err_out:
@@ -3202,6 +3246,7 @@ static const struct net_device_ops bnge_netdev_ops = {
 	.ndo_stop		= bnge_close,
 	.ndo_start_xmit		= bnge_start_xmit,
 	.ndo_get_stats64	= bnge_get_stats64,
+	.ndo_set_rx_mode_async	= bnge_set_rx_mode,
 	.ndo_features_check	= bnge_features_check,
 };
 
diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h
index d177919c2e11..476b5bab96fe 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.h
@@ -561,6 +561,12 @@ struct bnge_napi {
 #define BNGE_VNIC_DEFAULT	0
 #define BNGE_MAX_UC_ADDRS	4
 
+#define BNGE_RX_MASK_CFG_FLAGS				\
+	(CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS |	\
+	 CFA_L2_SET_RX_MASK_REQ_MASK_MCAST |		\
+	 CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST |	\
+	 CFA_L2_SET_RX_MASK_REQ_MASK_BCAST)
+
 struct bnge_vnic_info {
 	u16		fw_vnic_id;
 #define BNGE_MAX_CTX_PER_VNIC	8
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net-next, v2 3/3] bnge: send hwrm for interface down/up transitions
  2026-07-31 16:37 [net-next, v2 0/3] bnge: add more functionality Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 1/3] bnge: refactor rx mode helpers to accept explicit address lists Vikas Gupta
  2026-07-31 16:37 ` [net-next, v2 2/3] bnge: add ndo_set_rx_mode_async support Vikas Gupta
@ 2026-07-31 16:37 ` Vikas Gupta
  2 siblings, 0 replies; 4+ messages in thread
From: Vikas Gupta @ 2026-07-31 16:37 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: netdev, linux-kernel, bhargava.marreddy, rahul-rg.gupta,
	vsrama-krishna.nemani, rajashekar.hudumula, dharmender.garg,
	ajit.khaparde, Vikas Gupta

Firmware expects HWRM_FUNC_DRV_IF_CHANGE on interface down/up
transitions to coordinate resource management.
Add bnge_hwrm_if_change() to send this notification.

Signed-off-by: Vikas Gupta <vikas.gupta@broadcom.com>
Reviewed-by: Dharmender Garg <dharmender.garg@broadcom.com>
Reviewed-by: Rahul Gupta <rahul-rg.gupta@broadcom.com>
---
 .../net/ethernet/broadcom/bnge/bnge_netdev.c  | 32 +++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
index d47eb9bc5b8d..c2e865f8d9c4 100644
--- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
+++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
@@ -20,6 +20,7 @@
 #include <net/page_pool/helpers.h>
 
 #include "bnge.h"
+#include "bnge_hwrm.h"
 #include "bnge_hwrm_lib.h"
 #include "bnge_ethtool.h"
 #include "bnge_rmem.h"
@@ -2864,6 +2865,24 @@ static void bnge_tx_enable(struct bnge_net *bn)
 		netif_carrier_on(bn->netdev);
 }
 
+static int bnge_hwrm_if_change(struct bnge_dev *bd, bool up)
+{
+	struct hwrm_func_drv_if_change_input *req;
+	int rc;
+
+	if (!(bd->fw_cap & BNGE_FW_CAP_IF_CHANGE))
+		return 0;
+
+	rc = bnge_hwrm_req_init(bd, req, HWRM_FUNC_DRV_IF_CHANGE);
+	if (rc)
+		return rc;
+
+	if (up)
+		req->flags = cpu_to_le32(FUNC_DRV_IF_CHANGE_REQ_FLAGS_UP);
+
+	return bnge_hwrm_req_send(bd, req);
+}
+
 static int bnge_open_core(struct bnge_net *bn)
 {
 	struct bnge_dev *bd = bn->bd;
@@ -2871,16 +2890,22 @@ static int bnge_open_core(struct bnge_net *bn)
 
 	netif_carrier_off(bn->netdev);
 
+	rc = bnge_hwrm_if_change(bd, true);
+	if (rc) {
+		netdev_err(bn->netdev, "bnge_hwrm_if_change err: %d\n", rc);
+		return rc;
+	}
+
 	rc = bnge_reserve_rings(bd);
 	if (rc) {
 		netdev_err(bn->netdev, "bnge_reserve_rings err: %d\n", rc);
-		return rc;
+		goto err_if_change;
 	}
 
 	rc = bnge_alloc_core(bn);
 	if (rc) {
 		netdev_err(bn->netdev, "bnge_alloc_core err: %d\n", rc);
-		return rc;
+		goto err_if_change;
 	}
 
 	bnge_init_napi(bn);
@@ -2927,6 +2952,8 @@ static int bnge_open_core(struct bnge_net *bn)
 err_del_napi:
 	bnge_del_napi(bn);
 	bnge_free_core(bn);
+err_if_change:
+	bnge_hwrm_if_change(bd, false);
 	return rc;
 }
 
@@ -3157,6 +3184,7 @@ static int bnge_close(struct net_device *dev)
 
 	bnge_close_core(bn);
 	bnge_hwrm_shutdown_link(bn->bd);
+	bnge_hwrm_if_change(bn->bd, false);
 	bn->sp_event = 0;
 
 	return 0;
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-31 16:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 16:37 [net-next, v2 0/3] bnge: add more functionality Vikas Gupta
2026-07-31 16:37 ` [net-next, v2 1/3] bnge: refactor rx mode helpers to accept explicit address lists Vikas Gupta
2026-07-31 16:37 ` [net-next, v2 2/3] bnge: add ndo_set_rx_mode_async support Vikas Gupta
2026-07-31 16:37 ` [net-next, v2 3/3] bnge: send hwrm for interface down/up transitions Vikas Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox