[PATCH net] net: bcmgenet: restore the hardware filters on open

Xiang Mei posted 1 patch 1 week, 2 days ago
.../net/ethernet/broadcom/genet/bcmgenet.c    | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
[PATCH net] net: bcmgenet: restore the hardware filters on open
Posted by Xiang Mei 1 week, 2 days ago
From: Nicolai Buchwitz <nb@tipi-net.de>

bcmgenet_hfb_init() runs INIT_LIST_HEAD() on priv->rxnfc_list, which drops
every rule off the list, and bcmgenet_open() calls it on each ifup. Every
rule the user configured is silently lost:

  # ethtool -N eth0 flow-type ether dst $MAC action 0
  Added rule with ID 0
  # ethtool -n eth0 | grep -c Filter:
  1
  # ip link set eth0 down && ip link set eth0 up
  # ethtool -n eth0 | grep -c Filter:
  0

Initialise the lists once at probe and restore the rules on open, as
bcmgenet_resume() already does.

Fixes: 3e370952287c ("net: bcmgenet: add support for ethtool rxnfc flows")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Justin Chen <justin.chen@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20260913190052.939955-1-nb@tipi-net.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../net/ethernet/broadcom/genet/bcmgenet.c    | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index a2305e6428d1..b916080f4ff1 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -749,8 +749,17 @@ static void bcmgenet_hfb_init(struct bcmgenet_priv *priv)
 		INIT_LIST_HEAD(&priv->rxnfc_rules[i].list);
 		priv->rxnfc_rules[i].state = BCMGENET_RXNFC_STATE_UNUSED;
 	}
+}
+
+static void bcmgenet_hfb_restore(struct bcmgenet_priv *priv)
+{
+	struct bcmgenet_rxnfc_rule *rule;
 
 	bcmgenet_hfb_clear(priv);
+
+	list_for_each_entry(rule, &priv->rxnfc_list, list)
+		if (rule->state != BCMGENET_RXNFC_STATE_UNUSED)
+			bcmgenet_hfb_create_rxnfc_filter(priv, rule);
 }
 
 static int bcmgenet_begin(struct net_device *dev)
@@ -3376,8 +3385,8 @@ static int bcmgenet_open(struct net_device *dev)
 
 	bcmgenet_set_hw_addr(priv, dev->dev_addr);
 
-	/* HFB init */
-	bcmgenet_hfb_init(priv);
+	/* Restore the filters, the MAC was reset above */
+	bcmgenet_hfb_restore(priv);
 
 	/* Reinitialize TDMA and RDMA and SW housekeeping */
 	ret = bcmgenet_init_dma(priv, true);
@@ -4075,6 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
 
 	/* Mii wait queue */
 	init_waitqueue_head(&priv->wq);
+	bcmgenet_hfb_init(priv);
 	INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
 
 	priv->clk_wol = devm_clk_get_optional(&priv->pdev->dev, "enet-wol");
@@ -4272,10 +4282,7 @@ static int bcmgenet_resume(struct device *d)
 	bcmgenet_set_hw_addr(priv, dev->dev_addr);
 
 	/* Restore hardware filters */
-	bcmgenet_hfb_clear(priv);
-	list_for_each_entry(rule, &priv->rxnfc_list, list)
-		if (rule->state != BCMGENET_RXNFC_STATE_UNUSED)
-			bcmgenet_hfb_create_rxnfc_filter(priv, rule);
+	bcmgenet_hfb_restore(priv);
 
 	/* Reinitialize TDMA and RDMA and SW housekeeping */
 	ret = bcmgenet_init_dma(priv, false);
-- 
2.43.0
Re: [PATCH net] net: bcmgenet: restore the hardware filters on open
Posted by Xiang Mei 1 week, 2 days ago
Please ignore this email. It's an email sent by mistake.

I got this patch for testing and wrongly sent it out. Sorry about that.

Xiang


On Tue, Sep 15, 2026 at 1:24 AM Xiang Mei <xmei5@asu.edu> wrote:
>
> From: Nicolai Buchwitz <nb@tipi-net.de>
>
> bcmgenet_hfb_init() runs INIT_LIST_HEAD() on priv->rxnfc_list, which drops
> every rule off the list, and bcmgenet_open() calls it on each ifup. Every
> rule the user configured is silently lost:
>
>   # ethtool -N eth0 flow-type ether dst $MAC action 0
>   Added rule with ID 0
>   # ethtool -n eth0 | grep -c Filter:
>   1
>   # ip link set eth0 down && ip link set eth0 up
>   # ethtool -n eth0 | grep -c Filter:
>   0
>
> Initialise the lists once at probe and restore the rules on open, as
> bcmgenet_resume() already does.
>
> Fixes: 3e370952287c ("net: bcmgenet: add support for ethtool rxnfc flows")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
> Reviewed-by: Justin Chen <justin.chen@broadcom.com>
> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Link: https://patch.msgid.link/20260913190052.939955-1-nb@tipi-net.de
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  .../net/ethernet/broadcom/genet/bcmgenet.c    | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index a2305e6428d1..b916080f4ff1 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -749,8 +749,17 @@ static void bcmgenet_hfb_init(struct bcmgenet_priv *priv)
>                 INIT_LIST_HEAD(&priv->rxnfc_rules[i].list);
>                 priv->rxnfc_rules[i].state = BCMGENET_RXNFC_STATE_UNUSED;
>         }
> +}
> +
> +static void bcmgenet_hfb_restore(struct bcmgenet_priv *priv)
> +{
> +       struct bcmgenet_rxnfc_rule *rule;
>
>         bcmgenet_hfb_clear(priv);
> +
> +       list_for_each_entry(rule, &priv->rxnfc_list, list)
> +               if (rule->state != BCMGENET_RXNFC_STATE_UNUSED)
> +                       bcmgenet_hfb_create_rxnfc_filter(priv, rule);
>  }
>
>  static int bcmgenet_begin(struct net_device *dev)
> @@ -3376,8 +3385,8 @@ static int bcmgenet_open(struct net_device *dev)
>
>         bcmgenet_set_hw_addr(priv, dev->dev_addr);
>
> -       /* HFB init */
> -       bcmgenet_hfb_init(priv);
> +       /* Restore the filters, the MAC was reset above */
> +       bcmgenet_hfb_restore(priv);
>
>         /* Reinitialize TDMA and RDMA and SW housekeeping */
>         ret = bcmgenet_init_dma(priv, true);
> @@ -4075,6 +4084,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
>
>         /* Mii wait queue */
>         init_waitqueue_head(&priv->wq);
> +       bcmgenet_hfb_init(priv);
>         INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
>
>         priv->clk_wol = devm_clk_get_optional(&priv->pdev->dev, "enet-wol");
> @@ -4272,10 +4282,7 @@ static int bcmgenet_resume(struct device *d)
>         bcmgenet_set_hw_addr(priv, dev->dev_addr);
>
>         /* Restore hardware filters */
> -       bcmgenet_hfb_clear(priv);
> -       list_for_each_entry(rule, &priv->rxnfc_list, list)
> -               if (rule->state != BCMGENET_RXNFC_STATE_UNUSED)
> -                       bcmgenet_hfb_create_rxnfc_filter(priv, rule);
> +       bcmgenet_hfb_restore(priv);
>
>         /* Reinitialize TDMA and RDMA and SW housekeeping */
>         ret = bcmgenet_init_dma(priv, false);
> --
> 2.43.0
>