On 12/3/26 1:35 PM, A. Sverdlin wrote:
> From: Alexander Sverdlin <alex…@siemens.com> > > In dual-MAC mode the ALE is VLAN-aware and the Unknown VLAN register is > left at its reset value, so frames tagged with a VID the ALE doesn't know > are dropped even if the interface is promiscuous. ALE_P0_UNI_FLOOD only > helps with unknown unicast in known VLANs.
Would just the following diff also work? (given that the issue seems to be with dropping packets of unknown VLANs) diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 9ea7b6ffc992..af38711770f7 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -79,6 +79,7 @@ static bool cpsw_is_switch_en(struct cpsw_common *cpsw) static void cpsw_set_promiscious(struct net_device *ndev, bool enable) { struct cpsw_common *cpsw = ndev_to_cpsw(ndev); + struct cpsw_priv *priv = netdev_priv(ndev); bool enable_uni = false; int i; @@ -100,12 +101,16 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable) } if (enable) { + cpsw_ale_control_set(cpsw->ale, priv->emac_port, + ALE_PORT_DROP_UNKNOWN_VLAN, 0); /* Enable unknown unicast, reg/unreg mcast */ cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 1); dev_dbg(cpsw->dev, "promiscuity enabled\n"); } else { + cpsw_ale_control_set(cpsw->ale, priv->emac_port, + ALE_PORT_DROP_UNKNOWN_VLAN, 1); /* Disable unknown unicast */ cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_P0_UNI_FLOOD, 0); Regards, Siddharth.
> > This breaks DSA switches with VLAN-based tagging protocols, like LAN9303, > which encodes the source port in the VID: DSA puts the conduit into > promiscuous mode, but the ALE drops the frames coming from the switch. > > Bypass the ALE in promiscuous mode, as the legacy cpsw driver does in > dual_emac mode. In dual-MAC mode the ALE never forwards between external > ports and bypass delivers all received frames to the host port only, so > the port separation is preserved. When leaving promiscuous mode restore > the bypass setting configured via devlink. > > Switch mode changes reset ALE_BYPASS, re-apply the rx mode of the running > ports afterwards so that the promiscuous state isn't lost. > > Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac") > Tested-by: Lukas Stockmann <luka…@siemens.com> > Signed-off-by: Alexander Sverdlin <alex…@siemens.com> > --- > drivers/net/ethernet/ti/cpsw_new.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c > index 9ea7b6ffc992b..5f0fe96814f0c 100644 > --- a/drivers/net/ethernet/ti/cpsw_new.c > +++ b/drivers/net/ethernet/ti/cpsw_new.c > @@ -100,15 +100,13 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable) > } > if (enable) { > - /* Enable unknown unicast, reg/unreg mcast */ > - cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, > - ALE_P0_UNI_FLOOD, 1); > + /* Bypass also delivers frames of VLANs unknown to the ALE */ > + cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_BYPASS, 1); > dev_dbg(cpsw->dev, "promiscuity enabled\n"); > } else { > - /* Disable unknown unicast */ > - cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, > - ALE_P0_UNI_FLOOD, 0); > + cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_BYPASS, > + cpsw->ale_bypass); > dev_dbg(cpsw->dev, "promiscuity disabled\n"); > } > } > @@ -1769,6 +1767,14 @@ static int cpsw_dl_switch_mode_set(struct devlink *dl, u32 id, > cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0); > cpsw->data.dual_emac = true; > } > + > + /* ALE_BYPASS has been reset above, re-apply promiscuity */ > + for (i = 0; i < cpsw->data.slaves; i++) { > + struct net_device *sl_ndev = cpsw->slaves[i].ndev; > + > + if (sl_ndev && netif_running(sl_ndev)) > + cpsw_ndo_set_rx_mode(sl_ndev); > + } > exit: > rtnl_unlock(); >