Cleanup in brport flags switchdev offload for DSA
Subsystems (14)
Vladimir Oltean
maintainerv4 cover Cleanup in brport flags switchdev offload for DSA
From: Vladimir Oltean <[email protected]>
The initial goal of this series was to have better support for standalone ports mode on the DSA drivers like ocelot/felix and sja1105. This turned out to require some API adjustments in both directions:
to the information presented to and by the switchdev notifier, and to the API presented to the switch drivers by the DSA layer.
Vladimir Oltean (9):
net: switchdev: propagate extack to port attributes
net: bridge: offload all port flags at once in br_setport
net: bridge: don't print in br_switchdev_set_port_flag
net: dsa: configure better brport flags when ports leave the bridge
net: switchdev: pass flags and mask to both {PRE_,}BRIDGE_FLAGS
attributes
net: dsa: act as ass passthrough for bridge port flags
net: mscc: ocelot: use separate flooding PGID for broadcast
net: mscc: ocelot: offload bridge port flags to device
net: dsa: sja1105: offload bridge port flags to device
drivers/net/dsa/b53/b53_common.c | 91 ++++--- drivers/net/dsa/b53/b53_priv.h | 2 - drivers/net/dsa/mv88e6xxx/chip.c | 163 ++++++++++--- drivers/net/dsa/mv88e6xxx/chip.h | 6 +- drivers/net/dsa/mv88e6xxx/port.c | 52 ++-- drivers/net/dsa/mv88e6xxx/port.h | 19 +- drivers/net/dsa/ocelot/felix.c | 22 ++ drivers/net/dsa/sja1105/sja1105.h | 2 + drivers/net/dsa/sja1105/sja1105_main.c | 222 +++++++++++++++++- drivers/net/dsa/sja1105/sja1105_spi.c | 6 + .../marvell/prestera/prestera_switchdev.c | 26 +- .../mellanox/mlxsw/spectrum_switchdev.c | 53 +++-- drivers/net/ethernet/mscc/ocelot.c | 100 +++++++- drivers/net/ethernet/mscc/ocelot_net.c | 52 +++- drivers/net/ethernet/rocker/rocker_main.c | 10 +- drivers/net/ethernet/ti/cpsw_switchdev.c | 27 ++- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 34 ++- include/net/dsa.h | 10 +- include/net/switchdev.h | 13 +- include/soc/mscc/ocelot.h | 20 +- net/bridge/br_netlink.c | 116 +++------ net/bridge/br_private.h | 6 +- net/bridge/br_switchdev.c | 23 +- net/bridge/br_sysfs_if.c | 7 +- net/dsa/dsa_priv.h | 11 +- net/dsa/port.c | 76 ++++-- net/dsa/slave.c | 10 +- net/switchdev/switchdev.c | 11 +- 28 files changed, 870 insertions(+), 320 deletions(-)
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 1/9 net: switchdev: propagate extack to port attributes
From: Vladimir Oltean <[email protected]>
When a struct switchdev_attr is notified through switchdev, there is no way to report informational messages, unlike for struct switchdev_obj.
---
Changes in v3:
None.
Changes in v2:
Patch is new.
.../ethernet/marvell/prestera/prestera_switchdev.c | 3 ++- .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 ++- drivers/net/ethernet/mscc/ocelot_net.c | 3 ++- drivers/net/ethernet/ti/cpsw_switchdev.c | 3 ++- include/net/switchdev.h | 6 ++++-- net/dsa/slave.c | 3 ++- net/switchdev/switchdev.c | 11 ++++++++--- 7 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +2 -1
@@ -695,7 +695,8 @@ static int prestera_port_attr_stp_state_set(struct prestera_port *port, }static int prestera_port_obj_attr_set (struct net_device *dev, -const struct switchdev_attr *attr) +const struct switchdev_attr *attr, +struct netlink_ext_ack *extack) {struct prestera_port *port =netdev_priv (dev);int err =0 ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +2 -1
@@ -887,7 +887,8 @@ mlxsw_sp_port_attr_br_mrouter_set(struct mlxsw_sp_port *mlxsw_sp_port, }static int mlxsw_sp_port_attr_set (struct net_device *dev, -const struct switchdev_attr *attr) +const struct switchdev_attr *attr, +struct netlink_ext_ack *extack) {struct mlxsw_sp_port *mlxsw_sp_port =netdev_priv (dev);int err;
drivers/net/ethernet/mscc/ocelot_net.c +2 -1
@@ -1005,7 +1005,8 @@ static void ocelot_port_attr_mc_set(struct ocelot *ocelot, int port, bool mc) }static int ocelot_port_attr_set (struct net_device *dev, -const struct switchdev_attr *attr) +const struct switchdev_attr *attr, +struct netlink_ext_ack *extack) {struct ocelot_port_private *priv =netdev_priv (dev);struct ocelot *ocelot = priv->port.ocelot;
drivers/net/ethernet/ti/cpsw_switchdev.c +2 -1
@@ -83,7 +83,8 @@ static int cpsw_port_attr_br_flags_pre_set(struct net_device *netdev, }static int cpsw_port_attr_set (struct net_device *ndev, -const struct switchdev_attr *attr) +const struct switchdev_attr *attr, +struct netlink_ext_ack *extack) {struct cpsw_priv *priv =netdev_priv (ndev);int ret;
include/net/switchdev.h +4 -2
@@ -281,7 +281,8 @@ int switchdev_handle_port_attr_set(struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info, bool (*check_cb)(const struct net_device *dev), int (*set_cb)(struct net_device *dev, - const struct switchdev_attr *attr)); +const struct switchdev_attr *attr, + struct netlink_ext_ack *extack));#else static inline void switchdev_deferred_process (void )
@@ -372,7 +373,8 @@ switchdev_handle_port_attr_set(struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info, bool (*check_cb)(const struct net_device *dev), int (*set_cb)(struct net_device *dev, - const struct switchdev_attr *attr)) +const struct switchdev_attr *attr, + struct netlink_ext_ack *extack)) { return 0; }
net/dsa/slave.c +2 -1
@@ -271,7 +271,8 @@ static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) }static int dsa_slave_port_attr_set (struct net_device *dev, -const struct switchdev_attr *attr) +const struct switchdev_attr *attr, +struct netlink_ext_ack *extack) {struct dsa_port *dp =dsa_slave_to_port (dev);int ret;
net/switchdev/switchdev.c +8 -3
@@ -488,14 +488,18 @@ static int __switchdev_handle_port_attr_set(struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info, bool (*check_cb)(const struct net_device *dev), int (*set_cb)(struct net_device *dev, - const struct switchdev_attr *attr)) + const struct switchdev_attr *attr, + struct netlink_ext_ack *extack)) { + struct netlink_ext_ack *extack;struct net_device *lower_dev;struct list_head *iter;int err = -EOPNOTSUPP ; + extack =switchdev_notifier_info_to_extack (&port_attr_info->info); +if (check_cb (dev)) { - err =set_cb (dev, port_attr_info->attr); + err =set_cb (dev, port_attr_info->attr, extack);if (err != -EOPNOTSUPP ) port_attr_info->handled = true;return err;
@@ -525,7 +529,8 @@ int switchdev_handle_port_attr_set(struct net_device *dev, struct switchdev_notifier_port_attr_info *port_attr_info, bool (*check_cb)(const struct net_device *dev), int (*set_cb)(struct net_device *dev, - const struct switchdev_attr *attr)) + const struct switchdev_attr *attr, + struct netlink_ext_ack *extack)) { int err;
Signature · 1 line
2.25.1
Re: [PATCH v4 net-next 1/9] net: switchdev: propagate extack to port attributes
Quoted 7 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
When a struct
switchdev_attris notified through switchdev, there is no way to report informational messages, unlike for structswitchdev_obj.Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Ido Schimmel <[email protected]>
Signature · 1 line
Florian
Vladimir Oltean
maintainerPATCH v4 2/9 net: bridge: offload all port flags at once in br_setport
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
If for example this command:
ip link set swp0 type bridge_slave flood off mcast_flood off learning off
succeeded at configuring BR_FLOOD and BR_MCAST_FLOOD but not at BR_LEARNING, there would be no attempt to revert the partial state in any way. Arguably, if the user changes more than one flag through the same netlink command, this one _should_ be all or nothing, which means it should be passed through switchdev as all or nothing.
---
Changes in v4:
Leave br->lock alone completely.
Changes in v3:
Don't attempt to drop br->lock around br_switchdev_set_port_flag now, move that part to a later patch.
Changes in v2:
Patch is new.
Changes in v2:
Patch is new.
net/bridge/br_netlink.c | 109 ++++++++++++-------------------------- net/bridge/br_switchdev.c | 6 ++- 2 files changed, 39 insertions(+), 76 deletions(-)
net/bridge/br_netlink.c +35 -74
@@ -853,87 +853,58 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state) }/* Set/clear or port flags based on attribute */ -static int br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], -int attrtype,unsigned long mask) +static void br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], +int attrtype,unsigned long mask) { -unsigned long flags; -int err; -if (!tb[attrtype]) -return 0 ; +return ;if (nla_get_u8 (tb[attrtype])) - flags = p->flags | mask; + p->flags |= mask;else - flags = p->flags & ~mask; - - err =br_switchdev_set_port_flag (p, flags, mask); -if (err) -return err; - - p->flags = flags; -return 0 ; + p->flags &= ~mask; }/* Process bridge protocol info on port */ static int br_setport (struct net_bridge_port *p,struct nlattr *tb[]) { -unsigned long old_flags = p->flags; -bool br_vlan_tunnel_old = false; +unsigned long old_flags, changed_mask; +bool br_vlan_tunnel_old;int err; - err =br_set_port_flag (p, tb,IFLA_BRPORT_MODE ,BR_HAIRPIN_MODE ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_GUARD ,BR_BPDU_GUARD ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_FAST_LEAVE ,BR_MULTICAST_FAST_LEAVE ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_PROTECT ,BR_ROOT_BLOCK ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_LEARNING ,BR_LEARNING ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_UNICAST_FLOOD ,BR_FLOOD ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_MCAST_FLOOD ,BR_MCAST_FLOOD ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_MCAST_TO_UCAST ,BR_MULTICAST_TO_UNICAST ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_BCAST_FLOOD ,BR_BCAST_FLOOD ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_PROXYARP ,BR_PROXYARP ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_PROXYARP_WIFI ,BR_PROXYARP_WIFI ); -if (err) -return err; - - br_vlan_tunnel_old = (p->flags &BR_VLAN_TUNNEL ) ? true : false; - err =br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); -if (err) + old_flags = p->flags; + br_vlan_tunnel_old = (old_flags &BR_VLAN_TUNNEL ) ? true : false; + +br_set_port_flag (p, tb,IFLA_BRPORT_MODE ,BR_HAIRPIN_MODE ); +br_set_port_flag (p, tb,IFLA_BRPORT_GUARD ,BR_BPDU_GUARD ); +br_set_port_flag (p, tb,IFLA_BRPORT_FAST_LEAVE , +BR_MULTICAST_FAST_LEAVE ); +br_set_port_flag (p, tb,IFLA_BRPORT_PROTECT ,BR_ROOT_BLOCK ); +br_set_port_flag (p, tb,IFLA_BRPORT_LEARNING ,BR_LEARNING ); +br_set_port_flag (p, tb,IFLA_BRPORT_UNICAST_FLOOD ,BR_FLOOD ); +br_set_port_flag (p, tb,IFLA_BRPORT_MCAST_FLOOD ,BR_MCAST_FLOOD ); +br_set_port_flag (p, tb,IFLA_BRPORT_MCAST_TO_UCAST , +BR_MULTICAST_TO_UNICAST ); +br_set_port_flag (p, tb,IFLA_BRPORT_BCAST_FLOOD ,BR_BCAST_FLOOD ); +br_set_port_flag (p, tb,IFLA_BRPORT_PROXYARP ,BR_PROXYARP ); +br_set_port_flag (p, tb,IFLA_BRPORT_PROXYARP_WIFI ,BR_PROXYARP_WIFI ); +br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); +br_set_port_flag (p, tb,IFLA_BRPORT_NEIGH_SUPPRESS ,BR_NEIGH_SUPPRESS ); +br_set_port_flag (p, tb,IFLA_BRPORT_ISOLATED ,BR_ISOLATED ); + + changed_mask = old_flags ^ p->flags; + + err =br_switchdev_set_port_flag (p, p->flags, changed_mask); +if (err) { + p->flags = old_flags;return err; + }if (br_vlan_tunnel_old && !(p->flags &BR_VLAN_TUNNEL ))nbp_vlan_tunnel_info_flush (p); +br_port_flags_change (p, changed_mask); +if (tb[IFLA_BRPORT_COST ]) { err =br_stp_set_path_cost (p,nla_get_u32 (tb[IFLA_BRPORT_COST ]));if (err)
@@ -982,15 +953,6 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[]) p->group_fwd_mask = fwd_mask; } - err =br_set_port_flag (p, tb,IFLA_BRPORT_NEIGH_SUPPRESS , -BR_NEIGH_SUPPRESS ); -if (err) -return err; - - err =br_set_port_flag (p, tb,IFLA_BRPORT_ISOLATED ,BR_ISOLATED ); -if (err) -return err; -if (tb[IFLA_BRPORT_BACKUP_PORT ]) {struct net_device *backup_dev =NULL ;u32 backup_ifindex;
@@ -1008,7 +970,6 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])return err; } -br_port_flags_change (p, old_flags ^ p->flags);return 0 ; }
net/bridge/br_switchdev.c +4 -2
@@ -65,16 +65,18 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,struct switchdev_attr attr = { .orig_dev = p->dev, .id =SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS , - .u.brport_flags = mask, };struct switchdev_notifier_port_attr_info info = { .attr = &attr, };int err; -if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD ) + mask &=BR_PORT_FLAGS_HW_OFFLOAD ; +if (!mask)return 0 ; + attr.u.brport_flags = mask; +/* We run from atomic context here */ err =call_switchdev_notifiers (SWITCHDEV_PORT_ATTR_SET , p->dev, &info.info,NULL );
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 3/9 net: bridge: don't print in br_switchdev_set_port_flag
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
For the netlink interface, propagate errors through extack rather than simply printing them to the console. For the sysfs interface, we still print to the console, but at least that's one layer higher than in switchdev, which also allows us to silently ignore the offloading of flags if that is ever needed in the future.
---
Changes in v4:
- Adjust the commit message now that we aren't notifying initial and final port flags from the bridge any longer.
Changes in v3:
- Deal with the br_switchdev_set_port_flag call from sysfs too.
Changes in v2:
- br_set_port_flag now returns void, so no extack there.
- don't overwrite extack in br_switchdev_set_port_flag if already populated.
net/bridge/br_netlink.c | 9 +++++---- net/bridge/br_private.h | 6 ++++-- net/bridge/br_switchdev.c | 13 +++++++------ net/bridge/br_sysfs_if.c | 7 +++++-- 4 files changed, 21 insertions(+), 14 deletions(-)
net/bridge/br_netlink.c +5 -4
@@ -866,7 +866,8 @@ static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[], }/* Process bridge protocol info on port */ -static int br_setport (struct net_bridge_port *p,struct nlattr *tb[]) +static int br_setport (struct net_bridge_port *p,struct nlattr *tb[], +struct netlink_ext_ack *extack) {unsigned long old_flags, changed_mask;bool br_vlan_tunnel_old;
@@ -894,7 +895,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[]) changed_mask = old_flags ^ p->flags; - err =br_switchdev_set_port_flag (p, p->flags, changed_mask); + err =br_switchdev_set_port_flag (p, p->flags, changed_mask, extack);if (err) { p->flags = old_flags;return err;
@@ -1007,7 +1008,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags,return err;spin_lock_bh (&p->br->lock); - err =br_setport (p, tb); + err =br_setport (p, tb, extack);spin_unlock_bh (&p->br->lock); }else {/* Binary compatibility with old RSTP */
@@ -1102,7 +1103,7 @@ static int br_port_slave_changelink(struct net_device *brdev,return 0 ;spin_lock_bh (&br->lock); - ret =br_setport (br_port_get_rtnl (dev), data); + ret =br_setport (br_port_get_rtnl (dev), data, extack);spin_unlock_bh (&br->lock);return ret;
net/bridge/br_private.h +4 -2
@@ -1575,7 +1575,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, const struct sk_buff *skb);int br_switchdev_set_port_flag (struct net_bridge_port *p,unsigned long flags, -unsigned long mask); +unsigned long mask, +struct netlink_ext_ack *extack);void br_switchdev_fdb_notify (const struct net_bridge_fdb_entry *fdb,int type); int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
@@ -1605,7 +1606,8 @@ static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,static inline int br_switchdev_set_port_flag (struct net_bridge_port *p,unsigned long flags, -unsigned long mask) +unsigned long mask, +struct netlink_ext_ack *extack) {return 0 ; }
net/bridge/br_switchdev.c +7 -6
@@ -60,7 +60,8 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,int br_switchdev_set_port_flag (struct net_bridge_port *p,unsigned long flags, -unsigned long mask) +unsigned long mask, +struct netlink_ext_ack *extack) {struct switchdev_attr attr = { .orig_dev = p->dev,
@@ -79,14 +80,15 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,/* We run from atomic context here */ err =call_switchdev_notifiers (SWITCHDEV_PORT_ATTR_SET , p->dev, - &info.info,NULL ); + &info.info, extack); err =notifier_to_errno (err);if (err == -EOPNOTSUPP )return 0 ;if (err) { -br_warn (p->br,"bridge flag offload is not supported %u(%s)\n" , - (unsigned int )p->port_no, p->dev->name); +if (extack && !extack->_msg) +NL_SET_ERR_MSG_MOD (extack, +"bridge flag offload is not supported" );return -EOPNOTSUPP ; }
@@ -96,8 +98,7 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p, err =switchdev_port_attr_set (p->dev, &attr);if (err) { -br_warn (p->br,"error setting offload flag on port %u(%s)\n" , - (unsigned int )p->port_no, p->dev->name); +NL_SET_ERR_MSG_MOD (extack,"error setting offload flag on port" );return err; }
net/bridge/br_sysfs_if.c +5 -2
@@ -59,6 +59,7 @@ static BRPORT_ATTR(_name, 0644, \static int store_flag (struct net_bridge_port *p,unsigned long v,unsigned long mask) { +struct netlink_ext_ack extack = {0 };unsigned long flags = p->flags;int err;
@@ -68,9 +69,11 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, flags &= ~mask;if (flags != p->flags) { - err =br_switchdev_set_port_flag (p, flags, mask); -if (err) + err =br_switchdev_set_port_flag (p, flags, mask, &extack); +if (err) { +netdev_err (p->dev,"%s\n" , extack._msg);return err; + } p->flags = flags;br_port_flags_change (p, mask);
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 4/9 net: dsa: configure better brport flags when ports leave the bridge
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
For a DSA switch port operating in standalone mode, address learning doesn't make much sense since that is a bridge function. In fact, address learning even breaks setups such as this one:
+---------------------------------------------+
| |
| +-------------------+ |
| | br0 | send receive |
| +--------+-+--------+ +--------+ +--------+ |
| | | | | | | | | |
| | swp0 | | swp1 | | swp2 | | swp3 | |
| | | | | | | | | |
+-+--------+-+--------+-+--------+-+--------+-+
| ^ | ^
| | | |
| +-----------+ |
| |
+--------------------------------+because if the switch has a single FDB (can offload a single bridge) then source address learning on swp3 can "steal" the source MAC address of swp2 from br0's FDB, because learning frames coming from swp2 will be done twice: first on the swp1 ingress port, second on the swp3 ingress port. So the hardware FDB will become out of sync with the software bridge, and when swp2 tries to send one more packet towards swp1, the ASIC will attempt to short-circuit the forwarding path and send it directly to swp3 (since that's the last port it learned that address on), which it obviously can't, because swp3 operates in standalone mode.
So DSA drivers operating in standalone mode should still configure a list of bridge port flags even when they are standalone. Currently DSA attempts to call dsa_port_bridge_flags with 0, which disables egress flooding of unknown unicast and multicast, something which doesn't make much sense. For the switches that implement .port_egress_floods - b53 and mv88e6xxx, it probably doesn't matter too much either, since they can possibly inject traffic from the CPU into a standalone port, regardless of MAC DA, even if egress flooding is turned off for that port, but certainly not all DSA switches can do that - sja1105, for example, can't. So it makes sense to use a better common default there, such as "flood everything".
It should also be noted that what DSA calls "dsa_port_bridge_flags()" is a degenerate name for just calling .port_egress_floods(), since nothing else is implemented - not learning, in particular. But disabling address learning, something that this driver is also coding up for, will be supported by individual drivers once .port_egress_floods is replaced with a more generic .port_bridge_flags.
Previous attempts to code up this logic have been in the common bridge layer, but as pointed out by Ido Schimmel, there are corner cases that are missed when doing that:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
So, at least for now, let's leave DSA in charge of setting port flags before and after the bridge join and leave.
---
Changes in v4:
None.
Changes in v3:
Patch is new, logically it was moved from the bridge layer to the DSA layer.
net/dsa/port.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-)
net/dsa/port.c +38 -7
@@ -122,6 +122,27 @@ void dsa_port_disable(struct dsa_port *dp)rtnl_unlock (); } +static void dsa_port_change_brport_flags (struct dsa_port *dp, +bool bridge_offload) +{ +unsigned long mask, flags; +int flag, err; + + mask =BR_LEARNING |BR_FLOOD |BR_MCAST_FLOOD |BR_BCAST_FLOOD ; +if (bridge_offload) + flags = mask; +else + flags = mask & ~BR_LEARNING ; + +for_each_set_bit (flag, &mask,32 ) { + err =dsa_port_pre_bridge_flags (dp,BIT (flag)); +if (err) +continue ; + +dsa_port_bridge_flags (dp, flags &BIT (flag)); + } +} +int dsa_port_bridge_join (struct dsa_port *dp,struct net_device *br) {struct dsa_notifier_bridge_info info = {
@@ -132,10 +153,10 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br) };int err; -/* Set the flooding mode before joining the port in the switch */ - err =dsa_port_bridge_flags (dp,BR_FLOOD |BR_MCAST_FLOOD ); -if (err) -return err; +/* Notify the port driver to set its configurable flags in a way that +* matches the initial settings of a bridge port. +*/ +dsa_port_change_brport_flags (dp, true);/* Here the interface is already bridged. Reflect the current * configuration so that drivers can program their chips accordingly.
@@ -146,7 +167,7 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br)/* The bridging is rolled back on error */ if (err) { -dsa_port_bridge_flags (dp,0 ); +dsa_port_change_brport_flags (dp, false); dp->bridge_dev =NULL ; }
@@ -172,8 +193,18 @@ void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)if (err)pr_err ("DSA: failed to notify DSA_NOTIFIER_BRIDGE_LEAVE\n" ); -/* Port is leaving the bridge, disable flooding */ -dsa_port_bridge_flags (dp,0 ); +/* Configure the port for standalone mode (no address learning, +* flood everything). +* The bridge only emits SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS events +* when the user requests it through netlink or sysfs, but not +* automatically at port join or leave, so we need to handle resetting +* the brport flags ourselves. But we even prefer it that way, because +* otherwise, some setups might never get the notification they need, +* for example, when a port leaves a LAG that offloads the bridge, +* it becomes standalone, but as far as the bridge is concerned, no +* port ever left. +*/ +dsa_port_change_brport_flags (dp, false);/* Port left the bridge, put in BR_STATE_DISABLED by the bridge layer, * so allow it to be in BR_STATE_FORWARDING to be kept functional
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 5/9 net: switchdev: pass flags and mask to both {PRE_,}BRIDGE_FLAGS attributes
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
This switchdev attribute offers a counterproductive API for a driver writer, because although br_switchdev_set_port_flag gets passed a "flags" and a "mask", those are passed piecemeal to the driver, so while the PRE_BRIDGE_FLAGS listener knows what changed because it has the "mask", the BRIDGE_FLAGS listener doesn't, because it only has the final value. But certain drivers can offload only certain combinations of settings, like for example they cannot change unicast flooding independently of multicast flooding - they must be both on or both off. The way the information is passed to switchdev makes drivers not expressive enough, and unable to reject this request ahead of time, in the PRE_BRIDGE_FLAGS notifier, so they are forced to reject it during the deferred BRIDGE_FLAGS attribute, where the rejection is currently ignored.
This patch also changes drivers to make use of the "mask" field for edge detection when possible.
--- .../marvell/prestera/prestera_switchdev.c | 23 +++++---- .../mellanox/mlxsw/spectrum_switchdev.c | 50 +++++++++++-------- drivers/net/ethernet/rocker/rocker_main.c | 10 ++-- drivers/net/ethernet/ti/cpsw_switchdev.c | 24 +++++---- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 34 ++++++++----- include/net/switchdev.h | 7 ++- net/bridge/br_switchdev.c | 6 +-- net/dsa/dsa_priv.h | 6 ++- net/dsa/port.c | 34 +++++++------ 9 files changed, 115 insertions(+), 79 deletions(-)
drivers/net/ethernet/marvell/prestera/prestera_switchdev.c +14 -9
@@ -581,7 +581,7 @@ int prestera_bridge_port_event(struct net_device *dev, unsigned long event,static int prestera_port_attr_br_flags_set (struct prestera_port *port,struct net_device *dev, -unsigned long flags) +struct switchdev_brport_flags flags) {struct prestera_bridge_port *br_port;int err;
@@ -590,15 +590,20 @@ static int prestera_port_attr_br_flags_set(struct prestera_port *port,if (!br_port)return 0 ; - err =prestera_hw_port_flood_set (port, flags &BR_FLOOD ); -if (err) -return err; +if (flags.mask &BR_FLOOD ) { + err =prestera_hw_port_flood_set (port, flags.val &BR_FLOOD ); +if (err) +return err; + } - err =prestera_hw_port_learning_set (port, flags &BR_LEARNING ); -if (err) -return err; +if (flags.mask &BR_LEARNING ) { + err =prestera_hw_port_learning_set (port, + flags.val &BR_LEARNING ); +if (err) +return err; + } -memcpy (&br_port->flags, &flags,sizeof (flags)); +memcpy (&br_port->flags, &flags.val,sizeof (flags.val));return 0 ; }
@@ -707,7 +712,7 @@ static int prestera_port_obj_attr_set(struct net_device *dev, attr->u.stp_state);break ;case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS : -if (attr->u.brport_flags & +if (attr->u.brport_flags.mask & ~(BR_LEARNING |BR_FLOOD |BR_MCAST_FLOOD )) err = -EINVAL ;break ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +29 -21
76 lines not on this page · raw message
drivers/net/ethernet/rocker/rocker_main.c +5 -5
@@ -1576,7 +1576,7 @@ rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *static int rocker_world_port_attr_pre_bridge_flags_set (struct rocker_port *rocker_port, -unsigned long brport_flags) +struct switchdev_brport_flags flags) {struct rocker_world_ops *wops = rocker_port->rocker->wops;unsigned long brport_flags_s;
@@ -1590,7 +1590,7 @@ rocker_world_port_attr_pre_bridge_flags_set(struct rocker_port *rocker_port,if (err)return err; -if (brport_flags & ~brport_flags_s) +if (flags.mask & ~brport_flags_s)return -EINVAL ;return 0 ;
@@ -1598,14 +1598,14 @@ rocker_world_port_attr_pre_bridge_flags_set(struct rocker_port *rocker_port,static int rocker_world_port_attr_bridge_flags_set (struct rocker_port *rocker_port, -unsigned long brport_flags) +struct switchdev_brport_flags flags) {struct rocker_world_ops *wops = rocker_port->rocker->wops;if (!wops->port_attr_bridge_flags_set)return -EOPNOTSUPP ; -return wops->port_attr_bridge_flags_set (rocker_port, brport_flags); +return wops->port_attr_bridge_flags_set (rocker_port, flags.val); } static int
@@ -2058,7 +2058,7 @@ static int rocker_port_attr_set(struct net_device *dev,break ;case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS : err =rocker_world_port_attr_pre_bridge_flags_set (rocker_port, - attr->u.brport_flags); + attr->u.brport_flags);break ;case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS : err = rocker_world_port_attr_bridge_flags_set(rocker_port,
drivers/net/ethernet/ti/cpsw_switchdev.c +14 -10
@@ -57,26 +57,30 @@ static int cpsw_port_stp_state_set(struct cpsw_priv *priv, u8 state)static int cpsw_port_attr_br_flags_set (struct cpsw_priv *priv,struct net_device *orig_dev, -unsigned long brport_flags) +struct switchdev_brport_flags flags) {struct cpsw_common *cpsw = priv->cpsw; -bool unreg_mcast_add = false; -if (brport_flags &BR_MCAST_FLOOD ) - unreg_mcast_add = true; -dev_dbg (priv->dev,"BR_MCAST_FLOOD: %d port %u\n" , - unreg_mcast_add, priv->emac_port); +if (flags.mask &BR_MCAST_FLOOD ) { +bool unreg_mcast_add = false; -cpsw_ale_set_unreg_mcast (cpsw->ale,BIT (priv->emac_port), - unreg_mcast_add); +if (flags.val &BR_MCAST_FLOOD ) + unreg_mcast_add = true; + +dev_dbg (priv->dev,"BR_MCAST_FLOOD: %d port %u\n" , + unreg_mcast_add, priv->emac_port); + +cpsw_ale_set_unreg_mcast (cpsw->ale,BIT (priv->emac_port), + unreg_mcast_add); + }return 0 ; }static int cpsw_port_attr_br_flags_pre_set (struct net_device *netdev, -unsigned long flags) +struct switchdev_brport_flags flags) { -if (flags & ~(BR_LEARNING |BR_MCAST_FLOOD )) +if (flags.mask & ~(BR_LEARNING |BR_MCAST_FLOOD ))return -EINVAL ;return 0 ;
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +21 -13
@@ -908,31 +908,39 @@ static int dpaa2_switch_port_attr_stp_state_set(struct net_device *netdev,return dpaa2_switch_port_set_stp_state (port_priv, state); } -static int dpaa2_switch_port_attr_br_flags_pre_set (struct net_device *netdev, -unsigned long flags) +static int +dpaa2_switch_port_attr_br_flags_pre_set (struct net_device *netdev, +struct switchdev_brport_flags flags) { -if (flags & ~(BR_LEARNING |BR_FLOOD )) +if (flags.mask & ~(BR_LEARNING |BR_FLOOD ))return -EINVAL ;return 0 ; } -static int dpaa2_switch_port_attr_br_flags_set (struct net_device *netdev, -unsigned long flags) +static int +dpaa2_switch_port_attr_br_flags_set (struct net_device *netdev, +struct switchdev_brport_flags flags) {struct ethsw_port_priv *port_priv =netdev_priv (netdev);int err =0 ; -/* Learning is enabled per switch */ - err =dpaa2_switch_set_learning (port_priv->ethsw_data, - !!(flags &BR_LEARNING )); -if (err) - goto exit; +if (flags.mask &BR_LEARNING ) { +/* Learning is enabled per switch */ + err =dpaa2_switch_set_learning (port_priv->ethsw_data, + !!(flags.val &BR_LEARNING )); +if (err) +return err; + } - err =dpaa2_switch_port_set_flood (port_priv, !!(flags &BR_FLOOD )); +if (flags.mask &BR_FLOOD ) { + err =dpaa2_switch_port_set_flood (port_priv, + !!(flags.val &BR_FLOOD )); +if (err) +return err; + } -exit: -return err; +return 0 ; } static int dpaa2_switch_port_attr_set(struct net_device *netdev,
include/net/switchdev.h +6 -1
@@ -32,6 +32,11 @@ enum switchdev_attr_id {#endif }; +struct switchdev_brport_flags { +unsigned long val; +unsigned long mask; +}; +struct switchdev_attr {struct net_device *orig_dev;enum switchdev_attr_id id;
@@ -40,7 +45,7 @@ struct switchdev_attr {void (*complete)(struct net_device *dev,int err,void *priv);union {u8 stp_state;/* PORT_STP_STATE */ -unsigned long brport_flags;/* PORT_{PRE}_BRIDGE_FLAGS */ +struct switchdev_brport_flags brport_flags;/* PORT_BRIDGE_FLAGS */ bool mrouter;/* PORT_MROUTER */ clock_t ageing_time;/* BRIDGE_AGEING_TIME */ bool vlan_filtering;/* BRIDGE_VLAN_FILTERING */
net/bridge/br_switchdev.c +3 -3
@@ -65,7 +65,6 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p, {struct switchdev_attr attr = { .orig_dev = p->dev, - .id =SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS , };struct switchdev_notifier_port_attr_info info = { .attr = &attr,
@@ -76,7 +75,9 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,if (!mask)return 0 ; - attr.u.brport_flags = mask; + attr.id =SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS ; + attr.u.brport_flags.val = flags; + attr.u.brport_flags.mask = mask;/* We run from atomic context here */ err = call_switchdev_notifiers(SWITCHDEV_PORT_ATTR_SET, p->dev,
@@ -94,7 +95,6 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p, attr.id =SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS ; attr.flags =SWITCHDEV_F_DEFER ; - attr.u.brport_flags = flags; err =switchdev_port_attr_set (p->dev, &attr);if (err) {
net/dsa/dsa_priv.h +4 -2
@@ -174,8 +174,10 @@ int dsa_port_mdb_add(const struct dsa_port *dp, const struct switchdev_obj_port_mdb *mdb);int dsa_port_mdb_del (const struct dsa_port *dp,const struct switchdev_obj_port_mdb *mdb); -int dsa_port_pre_bridge_flags (const struct dsa_port *dp,unsigned long flags); -int dsa_port_bridge_flags (const struct dsa_port *dp,unsigned long flags); +int dsa_port_pre_bridge_flags (const struct dsa_port *dp, +struct switchdev_brport_flags flags); +int dsa_port_bridge_flags (const struct dsa_port *dp, +struct switchdev_brport_flags flags);int dsa_port_mrouter (struct dsa_port *dp,bool mrouter);int dsa_port_vlan_add (struct dsa_port *dp,const struct switchdev_obj_port_vlan *vlan);
net/dsa/port.c +19 -15
@@ -125,21 +125,22 @@ void dsa_port_disable(struct dsa_port *dp)static void dsa_port_change_brport_flags (struct dsa_port *dp,bool bridge_offload) { -unsigned long mask, flags; -int flag, err; +struct switchdev_brport_flags flags; +int flag; - mask =BR_LEARNING |BR_FLOOD |BR_MCAST_FLOOD |BR_BCAST_FLOOD ; + flags.mask =BR_LEARNING |BR_FLOOD |BR_MCAST_FLOOD |BR_BCAST_FLOOD ;if (bridge_offload) - flags = mask; + flags.val = flags.mask;else - flags = mask & ~BR_LEARNING ; + flags.val = flags.mask & ~BR_LEARNING ; -for_each_set_bit (flag, &mask,32 ) { - err =dsa_port_pre_bridge_flags (dp,BIT (flag)); -if (err) -continue ; +for_each_set_bit (flag, &flags.mask,32 ) { +struct switchdev_brport_flags tmp; + + tmp.val = flags.val &BIT (flag); + tmp.mask =BIT (flag); -dsa_port_bridge_flags (dp, flags &BIT (flag)); +dsa_port_bridge_flags (dp, tmp); } }
@@ -423,26 +424,29 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock)return 0 ; } -int dsa_port_pre_bridge_flags (const struct dsa_port *dp,unsigned long flags) +int dsa_port_pre_bridge_flags (const struct dsa_port *dp, +struct switchdev_brport_flags flags) {struct dsa_switch *ds = dp->ds;if (!ds->ops->port_egress_floods || - (flags & ~(BR_FLOOD |BR_MCAST_FLOOD ))) + (flags.mask & ~(BR_FLOOD |BR_MCAST_FLOOD )))return -EINVAL ;return 0 ; } -int dsa_port_bridge_flags (const struct dsa_port *dp,unsigned long flags) +int dsa_port_bridge_flags (const struct dsa_port *dp, +struct switchdev_brport_flags flags) {struct dsa_switch *ds = dp->ds;int port = dp->index;int err =0 ;if (ds->ops->port_egress_floods) - err = ds->ops->port_egress_floods (ds, port, flags &BR_FLOOD , - flags &BR_MCAST_FLOOD ); + err = ds->ops->port_egress_floods (ds, port, + flags.val &BR_FLOOD , + flags.val &BR_MCAST_FLOOD );return err; }
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 6/9 net: dsa: act as ass passthrough for bridge port flags
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
There are multiple ways in which a PORT_BRIDGE_FLAGS attribute can be expressed by the bridge through switchdev, and not all of them can be emulated by DSA mid-layer API at the same time.
One possible configuration is when the bridge offloads the port flags using a mask that has a single bit set - therefore only one feature should change. However, DSA currently groups together unicast and multicast flooding in the .port_egress_floods method, which limits our options when we try to add support for turning off broadcast flooding:
do we extend .port_egress_floods with a third parameter which b53 and mv88e6xxx will ignore? But that means that the DSA layer, which currently implements the PRE_BRIDGE_FLAGS attribute all by itself, will see that .port_egress_floods is implemented, and will report that all 3 types of flooding are supported - not necessarily true.
Another configuration is when the user specifies more than one flag at the same time, in the same netlink message. If we were to create one individual function per offloadable bridge port flag, we would limit the expressiveness of the switch driver of refusing certain combinations of flag values. For example, a switch may not have an explicit knob for flooding of unknown multicast, just for flooding in general. In that case, the only correct thing to do is to allow changes to BR_FLOOD and BR_MCAST_FLOOD in tandem, and never allow mismatched values. But having a separate .port_set_unicast_flood and .port_set_multicast_flood would not allow the driver to possibly reject that.
Also, DSA doesn't consider it necessary to inform the driver that a SWITCHDEV_ATTR_ID_BRIDGE_MROUTER attribute was offloaded, because it just calls .port_egress_floods for the CPU port. When we'll add support for the plain SWITCHDEV_ATTR_ID_PORT_MROUTER, that will become a real problem because the flood settings will need to be held statefully in the DSA middle layer, otherwise changing the mrouter port attribute will impact the flooding attribute. And that's _assuming_ that the underlying hardware doesn't have anything else to do when a multicast router attaches to a port than flood unknown traffic to it. If it does, there will need to be a dedicated .port_set_mrouter anyway.
So we need to let the DSA drivers see the exact form that the bridge passes this switchdev attribute in, otherwise we are standing in the way. Therefore we also need to use this form of language when communicating to the driver that it needs to configure its initial (before bridge join) and final (after bridge leave) port flags.
The b53 and mv88e6xxx drivers are converted to the passthrough API and their implementation of .port_egress_floods is split into two: a function that configures unicast flooding and another for multicast. The mv88e6xxx implementation is quite hairy, and it turns out that the implementations of unknown unicast flooding are actually the same for 6185 and for 6352:
behind the confusing names actually lie two individual bits:NO_UNKNOWN_MC -> FLOOD_UC = 0x4 = BIT(2) NO_UNKNOWN_UC -> FLOOD_MC = 0x8 = BIT(3)
so there was no reason to entangle them in the first place.
Whereas the 6185 writes to MV88E6185_PORT_CTL0_FORWARD_UNKNOWN of PORT_CTL0, which has the exact same bit index. I have left the implementations separate though, for the only reason that the names are different enough to confuse me, since I am not able to double-check with a user manual. The multicast flooding setting for 6185 is in a different register than for 6352 though.
---
Changes in v4:
- Adjust commit title and message.
- Reintroduce the .port_pre_bridge_flags method.
- Split the unicast and multicast flooding settings in mv88e6xxx and b53.
Changes in v3:
- Pass extack through the newly introduce dsa_port_change_brport_flags.
Changes in v2:
- Reordered with previous patch such that we don't need to introduce .port_pre_bridge_flags
- Pass extack to drivers.
drivers/net/dsa/b53/b53_common.c | 91 ++++++++++++----- drivers/net/dsa/b53/b53_priv.h | 2 - drivers/net/dsa/mv88e6xxx/chip.c | 163 ++++++++++++++++++++++++------- drivers/net/dsa/mv88e6xxx/chip.h | 6 +- drivers/net/dsa/mv88e6xxx/port.c | 52 +++++----- drivers/net/dsa/mv88e6xxx/port.h | 19 ++-- include/net/dsa.h | 10 +- net/dsa/dsa_priv.h | 9 +- net/dsa/port.c | 31 +++--- net/dsa/slave.c | 7 +- 10 files changed, 263 insertions(+), 127 deletions(-)
drivers/net/dsa/b53/b53_common.c +64 -27
@@ -510,6 +510,39 @@ void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port) }EXPORT_SYMBOL (b53_imp_vlan_setup); +static void b53_port_set_ucast_flood (struct b53_device *dev,int port, +bool unicast) +{ +u16 uc; + +b53_read16 (dev,B53_CTRL_PAGE ,B53_UC_FLOOD_MASK , &uc); +if (unicast) + uc |=BIT (port); +else + uc &= ~BIT (port); +b53_write16 (dev,B53_CTRL_PAGE ,B53_UC_FLOOD_MASK , uc); +} + +static void b53_port_set_mcast_flood (struct b53_device *dev,int port, +bool multicast) +{ +u16 mc; + +b53_read16 (dev,B53_CTRL_PAGE ,B53_MC_FLOOD_MASK , &mc); +if (multicast) + mc |=BIT (port); +else + mc &= ~BIT (port); +b53_write16 (dev,B53_CTRL_PAGE ,B53_MC_FLOOD_MASK , mc); + +b53_read16 (dev,B53_CTRL_PAGE ,B53_IPMC_FLOOD_MASK , &mc); +if (multicast) + mc |=BIT (port); +else + mc &= ~BIT (port); +b53_write16 (dev,B53_CTRL_PAGE ,B53_IPMC_FLOOD_MASK , mc); +} +int b53_enable_port (struct dsa_switch *ds,int port,struct phy_device *phy) {struct b53_device *dev = ds->priv;
@@ -522,7 +555,8 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) cpu_port =dsa_to_port (ds, port)->cpu_dp->index; -b53_br_egress_floods (ds, port, true, true); +b53_port_set_ucast_flood (dev, port, true); +b53_port_set_mcast_flood (dev, port, true);if (dev->ops->irq_enable) ret = dev->ops->irq_enable (dev, port);
@@ -655,7 +689,8 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)b53_brcm_hdr_setup (dev->ds, port); -b53_br_egress_floods (dev->ds, port, true, true); +b53_port_set_ucast_flood (dev, port, true); +b53_port_set_mcast_flood (dev, port, true); }static void b53_enable_mib (struct b53_device *dev)
@@ -1916,37 +1951,37 @@ void b53_br_fast_age(struct dsa_switch *ds, int port) }EXPORT_SYMBOL (b53_br_fast_age); -int b53_br_egress_floods (struct dsa_switch *ds,int port, -bool unicast,bool multicast) +static int b53_br_flags_pre (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) { -struct b53_device *dev = ds->priv; -u16 uc, mc; - -b53_read16 (dev,B53_CTRL_PAGE ,B53_UC_FLOOD_MASK , &uc); -if (unicast) - uc |=BIT (port); -else - uc &= ~BIT (port); -b53_write16 (dev,B53_CTRL_PAGE ,B53_UC_FLOOD_MASK , uc); +if (flags.mask & ~(BR_FLOOD |BR_MCAST_FLOOD )) +return -EINVAL ; -b53_read16 (dev,B53_CTRL_PAGE ,B53_MC_FLOOD_MASK , &mc); -if (multicast) - mc |=BIT (port); -else - mc &= ~BIT (port); -b53_write16 (dev,B53_CTRL_PAGE ,B53_MC_FLOOD_MASK , mc); +return 0 ; +} -b53_read16 (dev,B53_CTRL_PAGE ,B53_IPMC_FLOOD_MASK , &mc); -if (multicast) - mc |=BIT (port); -else - mc &= ~BIT (port); -b53_write16 (dev,B53_CTRL_PAGE ,B53_IPMC_FLOOD_MASK , mc); +static int b53_br_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) +{ +if (flags.mask &BR_FLOOD ) +b53_port_set_ucast_flood (ds->priv, port, + !!(flags.val &BR_FLOOD )); +if (flags.mask &BR_MCAST_FLOOD ) +b53_port_set_mcast_flood (ds->priv, port, + !!(flags.val &BR_MCAST_FLOOD ));return 0 ; +} +static int b53_set_mrouter (struct dsa_switch *ds,int port,bool mrouter, +struct netlink_ext_ack *extack) +{ +b53_port_set_mcast_flood (ds->priv, port, mrouter); + +return 0 ; } -EXPORT_SYMBOL (b53_br_egress_floods);static bool b53_possible_cpu_port (struct dsa_switch *ds,int port) {
@@ -2187,9 +2222,11 @@ static const struct dsa_switch_ops b53_switch_ops = { .set_mac_eee = b53_set_mac_eee, .port_bridge_join = b53_br_join, .port_bridge_leave = b53_br_leave, + .port_pre_bridge_flags = b53_br_flags_pre, + .port_bridge_flags = b53_br_flags, + .port_set_mrouter = b53_set_mrouter, .port_stp_state_set = b53_br_set_stp_state, .port_fast_age = b53_br_fast_age, - .port_egress_floods = b53_br_egress_floods, .port_vlan_filtering = b53_vlan_filtering, .port_vlan_add = b53_vlan_add, .port_vlan_del = b53_vlan_del,
drivers/net/dsa/b53/b53_priv.h +0 -2
@@ -326,8 +326,6 @@ int b53_br_join(struct dsa_switch *ds, int port, struct net_device *bridge);void b53_br_leave (struct dsa_switch *ds,int port,struct net_device *bridge);void b53_br_set_stp_state (struct dsa_switch *ds,int port,u8 state);void b53_br_fast_age (struct dsa_switch *ds,int port); -int b53_br_egress_floods (struct dsa_switch *ds,int port, -bool unicast,bool multicast);int b53_setup_devlink_resources (struct dsa_switch *ds);void b53_port_event (struct dsa_switch *ds,int port); void b53_phylink_validate(struct dsa_switch *ds, int port,
drivers/net/dsa/mv88e6xxx/chip.c +127 -36
345 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/chip.h +4 -2
@@ -454,8 +454,10 @@ struct mv88e6xxx_ops {int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip,int port,enum mv88e6xxx_frame_mode mode); -int (*port_set_egress_floods)(struct mv88e6xxx_chip *chip,int port, -bool unicast,bool multicast); +int (*port_set_ucast_flood)(struct mv88e6xxx_chip *chip,int port, +bool unicast); +int (*port_set_mcast_flood)(struct mv88e6xxx_chip *chip,int port, +bool multicast);int (*port_set_ether_type)(struct mv88e6xxx_chip *chip,int port,u16 etype); int (*port_set_jumbo_size)(struct mv88e6xxx_chip *chip, int port,
drivers/net/dsa/mv88e6xxx/port.c +26 -26
84 lines not on this page · raw message
drivers/net/dsa/mv88e6xxx/port.h +10 -9
@@ -154,11 +154,8 @@#define MV88E6185_PORT_CTL0_USE_IP 0x0020#define MV88E6185_PORT_CTL0_USE_TAG 0x0010#define MV88E6185_PORT_CTL0_FORWARD_UNKNOWN 0x0004 -#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_MASK 0x000c -#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_NO_UNKNOWN_DA 0x0000 -#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_NO_UNKNOWN_MC_DA 0x0004 -#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_NO_UNKNOWN_UC_DA 0x0008 -#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_ALL_UNKNOWN_DA 0x000c +#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_UC 0x0004 +#define MV88E6352_PORT_CTL0_EGRESS_FLOODS_MC 0x0008#define MV88E6XXX_PORT_CTL0_STATE_MASK 0x0003#define MV88E6XXX_PORT_CTL0_STATE_DISABLED 0x0000#define MV88E6XXX_PORT_CTL0_STATE_BLOCKING 0x0001
@@ -343,10 +340,14 @@ int mv88e6085_port_set_frame_mode(struct mv88e6xxx_chip *chip, int port, enum mv88e6xxx_frame_mode mode);int mv88e6351_port_set_frame_mode (struct mv88e6xxx_chip *chip,int port,enum mv88e6xxx_frame_mode mode); -int mv88e6185_port_set_egress_floods (struct mv88e6xxx_chip *chip,int port, -bool unicast,bool multicast); -int mv88e6352_port_set_egress_floods (struct mv88e6xxx_chip *chip,int port, -bool unicast,bool multicast); +int mv88e6185_port_set_forward_unknown (struct mv88e6xxx_chip *chip, +int port,bool unicast); +int mv88e6185_port_set_default_forward (struct mv88e6xxx_chip *chip, +int port,bool multicast); +int mv88e6352_port_set_ucast_flood (struct mv88e6xxx_chip *chip,int port, +bool unicast); +int mv88e6352_port_set_mcast_flood (struct mv88e6xxx_chip *chip,int port, +bool multicast);int mv88e6352_port_set_policy (struct mv88e6xxx_chip *chip,int port,enum mv88e6xxx_policy_mapping mapping,enum mv88e6xxx_policy_action action);
include/net/dsa.h +8 -2
@@ -621,8 +621,14 @@ struct dsa_switch_ops {void (*port_stp_state_set)(struct dsa_switch *ds,int port,u8 state);void (*port_fast_age)(struct dsa_switch *ds,int port); -int (*port_egress_floods)(struct dsa_switch *ds,int port, -bool unicast,bool multicast); +int (*port_pre_bridge_flags)(struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int (*port_bridge_flags)(struct dsa_switch *ds,int port, +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int (*port_set_mrouter)(struct dsa_switch *ds,int port,bool mrouter, +struct netlink_ext_ack *extack);/* * VLAN support
net/dsa/dsa_priv.h +6 -3
@@ -175,10 +175,13 @@ int dsa_port_mdb_add(const struct dsa_port *dp,int dsa_port_mdb_del (const struct dsa_port *dp,const struct switchdev_obj_port_mdb *mdb);int dsa_port_pre_bridge_flags (const struct dsa_port *dp, -struct switchdev_brport_flags flags); +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack);int dsa_port_bridge_flags (const struct dsa_port *dp, -struct switchdev_brport_flags flags); -int dsa_port_mrouter (struct dsa_port *dp,bool mrouter); +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack); +int dsa_port_mrouter (struct dsa_port *dp,bool mrouter, +struct netlink_ext_ack *extack);int dsa_port_vlan_add (struct dsa_port *dp,const struct switchdev_obj_port_vlan *vlan); int dsa_port_vlan_del(struct dsa_port *dp,
net/dsa/port.c +14 -17
@@ -140,7 +140,7 @@ static void dsa_port_change_brport_flags(struct dsa_port *dp, tmp.val = flags.val &BIT (flag); tmp.mask =BIT (flag); -dsa_port_bridge_flags (dp, tmp); +dsa_port_bridge_flags (dp, tmp,NULL ); } }
@@ -425,41 +425,38 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock) }int dsa_port_pre_bridge_flags (const struct dsa_port *dp, -struct switchdev_brport_flags flags) +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) {struct dsa_switch *ds = dp->ds; -if (!ds->ops->port_egress_floods || - (flags.mask & ~(BR_FLOOD |BR_MCAST_FLOOD ))) +if (!ds->ops->port_pre_bridge_flags)return -EINVAL ; -return 0 ; +return ds->ops->port_pre_bridge_flags (ds, dp->index, flags, extack); }int dsa_port_bridge_flags (const struct dsa_port *dp, -struct switchdev_brport_flags flags) +struct switchdev_brport_flags flags, +struct netlink_ext_ack *extack) {struct dsa_switch *ds = dp->ds; -int port = dp->index; -int err =0 ; -if (ds->ops->port_egress_floods) - err = ds->ops->port_egress_floods (ds, port, - flags.val &BR_FLOOD , - flags.val &BR_MCAST_FLOOD ); +if (!ds->ops->port_bridge_flags) +return -EINVAL ; -return err; +return ds->ops->port_bridge_flags (ds, dp->index, flags, extack); } -int dsa_port_mrouter (struct dsa_port *dp,bool mrouter) +int dsa_port_mrouter (struct dsa_port *dp,bool mrouter, +struct netlink_ext_ack *extack) {struct dsa_switch *ds = dp->ds; -int port = dp->index; -if (!ds->ops->port_egress_floods) +if (!ds->ops->port_set_mrouter)return -EOPNOTSUPP ; -return ds->ops->port_egress_floods (ds, port, true, mrouter); +return ds->ops->port_set_mrouter (ds, dp->index, mrouter, extack); } int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu,
net/dsa/slave.c +4 -3
@@ -291,13 +291,14 @@ static int dsa_slave_port_attr_set(struct net_device *dev, ret =dsa_port_ageing_time (dp, attr->u.ageing_time);break ;case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS : - ret =dsa_port_pre_bridge_flags (dp, attr->u.brport_flags); + ret =dsa_port_pre_bridge_flags (dp, attr->u.brport_flags, + extack);break ;case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS : - ret =dsa_port_bridge_flags (dp, attr->u.brport_flags); + ret =dsa_port_bridge_flags (dp, attr->u.brport_flags, extack);break ;case SWITCHDEV_ATTR_ID_BRIDGE_MROUTER : - ret =dsa_port_mrouter (dp->cpu_dp, attr->u.mrouter); + ret =dsa_port_mrouter (dp->cpu_dp, attr->u.mrouter, extack);break ;default : ret = -EOPNOTSUPP ;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v4 net-next 6/9] net: dsa: act as ass passthrough for bridge port flags
Quoted 5 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
There are multiple ways in which a
PORT_BRIDGE_FLAGSattribute can be expressed by the bridge through switchdev, and not all of them can be emulated by DSA mid-layer API at the same time.
Oops, odd typo in the commit title. I only remember something was not right, I had noticed the "as" word was missing so I added it, but I apparently did not notice why it was missing...
Vladimir Oltean
maintainerPATCH v4 7/9 net: mscc: ocelot: use separate flooding PGID for broadcast
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
In preparation of offloading the bridge port flags which have independent settings for unknown multicast and for broadcast, we should also start reserving one destination Port Group ID for the flooding of broadcast packets, to allow configuring it individually.
---
Changes in v4:
None.
Changes in v3:
None.
Changes in v2:
None.
drivers/net/ethernet/mscc/ocelot.c | 13 ++++++++----- include/soc/mscc/ocelot.h | 15 ++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +8 -5
@@ -1716,7 +1716,7 @@ int ocelot_init(struct ocelot *ocelot)/* Setup flooding PGIDs */ for (i =0 ; i < ocelot->num_flooding_pgids; i++)ocelot_write_rix (ocelot,ANA_FLOODING_FLD_MULTICAST (PGID_MC ) | -ANA_FLOODING_FLD_BROADCAST (PGID_MC ) | +ANA_FLOODING_FLD_BROADCAST (PGID_BC ) |ANA_FLOODING_FLD_UNICAST (PGID_UC ),ANA_FLOODING , i); ocelot_write(ocelot, ANA_FLOODING_IPMC_FLD_MC6_DATA(PGID_MCIPV6) |
@@ -1737,15 +1737,18 @@ int ocelot_init(struct ocelot *ocelot)ocelot_write_rix (ocelot,0 ,ANA_PGID_PGID ,PGID_SRC + port); } -/* Allow broadcast MAC frames. */ for_each_nonreserved_multicast_dest_pgid (ocelot, i) {u32 val =ANA_PGID_PGID_PGID (GENMASK (ocelot->num_phys_ports -1 ,0 ));ocelot_write_rix (ocelot, val,ANA_PGID_PGID , i); } -ocelot_write_rix (ocelot, -ANA_PGID_PGID_PGID (GENMASK (ocelot->num_phys_ports,0 )), -ANA_PGID_PGID ,PGID_MC ); +/* Allow broadcast and unknown L2 multicast to the CPU. */ +ocelot_rmw_rix (ocelot,ANA_PGID_PGID_PGID (BIT (ocelot->num_phys_ports)), +ANA_PGID_PGID_PGID (BIT (ocelot->num_phys_ports)), +ANA_PGID_PGID ,PGID_MC ); +ocelot_rmw_rix (ocelot,ANA_PGID_PGID_PGID (BIT (ocelot->num_phys_ports)), +ANA_PGID_PGID_PGID (BIT (ocelot->num_phys_ports)), +ANA_PGID_PGID ,PGID_BC );ocelot_write_rix (ocelot,0 ,ANA_PGID_PGID ,PGID_MCIPV4 );ocelot_write_rix (ocelot,0 ,ANA_PGID_PGID ,PGID_MCIPV6 );
include/soc/mscc/ocelot.h +8 -7
@@ -54,16 +54,17 @@* PGID_CPU: used for whitelisting certain MAC addresses, such as the addresses * of the switch port net devices, towards the CPU port module. * PGID_UC: the flooding destinations for unknown unicast traffic. -* PGID_MC: the flooding destinations for broadcast and non-IP multicast -* traffic. +* PGID_MC: the flooding destinations for non-IP multicast traffic. * PGID_MCIPV4: the flooding destinations for IPv4 multicast traffic. * PGID_MCIPV6: the flooding destinations for IPv6 multicast traffic. +* PGID_BC: the flooding destinations for broadcast traffic. */ -#define PGID_CPU 59 -#define PGID_UC 60 -#define PGID_MC 61 -#define PGID_MCIPV4 62 -#define PGID_MCIPV6 63 +#define PGID_CPU 58 +#define PGID_UC 59 +#define PGID_MC 60 +#define PGID_MCIPV4 61 +#define PGID_MCIPV6 62 +#define PGID_BC 63#define for_each_unicast_dest_pgid (ocelot, pgid) \ for ((pgid) = 0; \
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v4 net-next 7/9] net: mscc: ocelot: use separate flooding PGID for broadcast
Quoted 10 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
In preparation of offloading the bridge port flags which have independent settings for unknown multicast and for broadcast, we should also start reserving one destination Port Group ID for the flooding of broadcast packets, to allow configuring it individually.
Signed-off-by Vladimir Oltean <[email protected]>Reviewed-by Florian Fainelli <[email protected]>---
After more testing with the ocelot-8021q tagger too, not just the default NPI-based one, I noticed that I introduced a regression.
devlink-sb tells me that broadcast packets remain stuck in the ingress queues of the front-panel ports instead of being forwarded to the CPU. This is because I forgot this:
-----------------------------[cut here]-----------------------------
drivers/net/dsa/ocelot/felix.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/dsa/ocelot/felix.c +1 -0
@@ -299,6 +299,7 @@ static int felix_setup_tag_8021q(struct dsa_switch *ds, int cpu) cpu_flood =ANA_PGID_PGID_PGID (BIT (ocelot->num_phys_ports));ocelot_rmw_rix (ocelot,0 , cpu_flood,ANA_PGID_PGID ,PGID_UC );ocelot_rmw_rix (ocelot,0 , cpu_flood,ANA_PGID_PGID ,PGID_MC ); +ocelot_rmw_rix (ocelot,0 , cpu_flood,ANA_PGID_PGID ,PGID_BC ); felix->dsa_8021q_ctx =kzalloc (sizeof (*felix->dsa_8021q_ctx),GFP_KERNEL );
-----------------------------[cut here]-----------------------------
If there is no other feedback on this series, can I send this as a follow-up fixup? Thanks.
Vladimir Oltean
maintainerPATCH v4 8/9 net: mscc: ocelot: offload bridge port flags to device
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
We should not be unconditionally enabling address learning, since doing that is actively detrimential when a port is standalone and not offloading a bridge. Namely, if a port in the switch is standalone and others are offloading the bridge, then we could enter a situation where we learn an address towards the standalone port, but the bridged ports could not forward the packet there, because the CPU is the only path between the standalone and the bridged ports. The solution of course is to not enable address learning unless the bridge asks for it.
We need to set up the initial port flags for no learning and flooding everything, and also when the port joins and leaves the bridge. The flood configuration was already configured ok for standalone mode in ocelot_init, we just need to disable learning in ocelot_init_port.
---
Changes in v4:
- Applying the bridge port flags by hand at bridge join and leave, like DSA and other switchdev drivers.
- Put every bridge port flag in a separate function.
- Export ocelot_port_pre_bridge_flags for felix DSA to use.
Changes in v3:
None.
Changes in v2:
- Disable learning in ocelot_init_port.
- Keep a single bool ocelot_port->learn_ena instead of ocelot_port->brport_flags.
- Stop touching the brport_flags from ocelot_port_bridge_leave (which was a leftover).
drivers/net/dsa/ocelot/felix.c | 22 +++++++ drivers/net/ethernet/mscc/ocelot.c | 87 +++++++++++++++++++++++++- drivers/net/ethernet/mscc/ocelot_net.c | 49 +++++++++++++-- include/soc/mscc/ocelot.h | 5 ++ 4 files changed, 158 insertions(+), 5 deletions(-)
drivers/net/dsa/ocelot/felix.c +22 -0
@@ -553,6 +553,26 @@ static void felix_bridge_stp_state_set(struct dsa_switch *ds, int port,return ocelot_bridge_stp_state_set (ocelot, port, state); } +static int felix_pre_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags val, +struct netlink_ext_ack *extack) +{ +struct ocelot *ocelot = ds->priv; + +return ocelot_port_pre_bridge_flags (ocelot, port, val); +} + +static int felix_bridge_flags (struct dsa_switch *ds,int port, +struct switchdev_brport_flags val, +struct netlink_ext_ack *extack) +{ +struct ocelot *ocelot = ds->priv; + +ocelot_port_bridge_flags (ocelot, port, val); + +return 0 ; +} +static int felix_bridge_join (struct dsa_switch *ds,int port,struct net_device *br) {
@@ -1373,6 +1393,8 @@ const struct dsa_switch_ops felix_switch_ops = { .port_fdb_del = felix_fdb_del, .port_mdb_add = felix_mdb_add, .port_mdb_del = felix_mdb_del, + .port_pre_bridge_flags = felix_pre_bridge_flags, + .port_bridge_flags = felix_bridge_flags, .port_bridge_join = felix_bridge_join, .port_bridge_leave = felix_bridge_leave, .port_lag_join = felix_lag_join,
drivers/net/ethernet/mscc/ocelot.c +86 -1
111 lines not on this page · raw message
drivers/net/ethernet/mscc/ocelot_net.c +45 -4
68 lines not on this page · raw message
include/soc/mscc/ocelot.h +5 -0
@@ -612,6 +612,7 @@ struct ocelot_port {u8 *xmit_template;bool is_dsa_8021q_cpu; +bool learn_ena;struct net_device *bond;bool lag_tx_active;
@@ -766,6 +767,10 @@ void ocelot_adjust_link(struct ocelot *ocelot, int port,int ocelot_port_vlan_filtering (struct ocelot *ocelot,int port,bool enabled);void ocelot_bridge_stp_state_set (struct ocelot *ocelot,int port,u8 state);void ocelot_apply_bridge_fwd_mask (struct ocelot *ocelot); +int ocelot_port_pre_bridge_flags (struct ocelot *ocelot,int port, +struct switchdev_brport_flags val); +void ocelot_port_bridge_flags (struct ocelot *ocelot,int port, +struct switchdev_brport_flags val);int ocelot_port_bridge_join (struct ocelot *ocelot,int port,struct net_device *bridge); int ocelot_port_bridge_leave(struct ocelot *ocelot, int port,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerPATCH v4 9/9 net: dsa: sja1105: offload bridge port flags to device
In reply to Vladimir OlteanFrom: Vladimir Oltean <[email protected]>
The chip can configure unicast flooding, broadcast flooding and learning. Learning is per port, while flooding is per {ingress, egress} port pair and we need to configure the same value for all possible ingress ports towards the requested one.
While multicast flooding is not officially supported, we can hack it by using a feature of the second generation (P/Q/R/S) devices, which is that FDB entries are maskable, and multicast addresses always have an odd first octet. So by putting a match-all for 00:01:00:00:00:00 addr and 00:01:00:00:00:00 mask at the end of the FDB, we make sure that it is always checked last, and does not take precedence in front of any other MDB. So it behaves effectively as an unknown multicast entry.
For the first generation switches, this feature is not available, so unknown multicast will always be treated the same as unknown unicast. So the only thing we can do is request the user to offload the settings for these 2 flags in tandem, i.e.
ip link set swp2 type bridge_slave flood off
Error: sja1105: This chip cannot configure multicast flooding independently of unicast. ip link set swp2 type bridge_slave flood off mcast_flood off
ip link set swp2 type bridge_slave mcast_flood on
Error: sja1105: This chip cannot configure multicast flooding independently of unicast.
---
Changes in v4:
Move the restrictions to .port_pre_bridge_flags.
Changes in v3:
None.
Changes in v2:
Patch is new.
drivers/net/dsa/sja1105/sja1105.h | 2 + drivers/net/dsa/sja1105/sja1105_main.c | 222 +++++++++++++++++++++++-- drivers/net/dsa/sja1105/sja1105_spi.c | 6 + 3 files changed, 219 insertions(+), 11 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +2 -0
@@ -94,6 +94,7 @@ struct sja1105_info {* pop it when it's equal to TPID2. */ u16 qinq_tpid; +bool can_limit_mcast_flood;int (*reset_cmd)(struct dsa_switch *ds);int (*setup_rgmii_delay)(const void *ctx,int port);/* Prototypes from include/net/dsa.h */
@@ -204,6 +205,7 @@ struct sja1105_private {bool rgmii_rx_delay[SJA1105_NUM_PORTS ];bool rgmii_tx_delay[SJA1105_NUM_PORTS ];bool best_effort_vlan_filtering; +unsigned long learn_ena;const struct sja1105_info *info;struct gpio_desc *reset_gpio;struct spi_device *spidev;
drivers/net/dsa/sja1105/sja1105_main.c +211 -11
285 lines not on this page · raw message
drivers/net/dsa/sja1105/sja1105_spi.c +6 -0
@@ -512,6 +512,7 @@ const struct sja1105_info sja1105e_info = { .static_ops = sja1105e_table_ops, .dyn_ops = sja1105et_dyn_ops, .qinq_tpid = ETH_P_8021Q, + .can_limit_mcast_flood = false, .ptp_ts_bits = 24, .ptpegr_ts_bytes = 4, .num_cbs_shapers = SJA1105ET_MAX_CBS_COUNT,
@@ -529,6 +530,7 @@ const struct sja1105_info sja1105t_info = { .static_ops = sja1105t_table_ops, .dyn_ops = sja1105et_dyn_ops, .qinq_tpid = ETH_P_8021Q, + .can_limit_mcast_flood = false, .ptp_ts_bits = 24, .ptpegr_ts_bytes = 4, .num_cbs_shapers = SJA1105ET_MAX_CBS_COUNT,
@@ -546,6 +548,7 @@ const struct sja1105_info sja1105p_info = { .static_ops = sja1105p_table_ops, .dyn_ops = sja1105pqrs_dyn_ops, .qinq_tpid = ETH_P_8021AD, + .can_limit_mcast_flood = true, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT,
@@ -564,6 +567,7 @@ const struct sja1105_info sja1105q_info = { .static_ops = sja1105q_table_ops, .dyn_ops = sja1105pqrs_dyn_ops, .qinq_tpid = ETH_P_8021AD, + .can_limit_mcast_flood = true, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT,
@@ -582,6 +586,7 @@ const struct sja1105_info sja1105r_info = { .static_ops = sja1105r_table_ops, .dyn_ops = sja1105pqrs_dyn_ops, .qinq_tpid = ETH_P_8021AD, + .can_limit_mcast_flood = true, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT,
@@ -601,6 +606,7 @@ const struct sja1105_info sja1105s_info = { .dyn_ops = sja1105pqrs_dyn_ops, .regs = &sja1105pqrs_regs, .qinq_tpid = ETH_P_8021AD, + .can_limit_mcast_flood = true, .ptp_ts_bits = 32, .ptpegr_ts_bytes = 8, .num_cbs_shapers = SJA1105PQRS_MAX_CBS_COUNT,
Signature · 1 line
2.25.1
Quoted 41 lines · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
The initial goal of this series was to have better support for standalone ports mode on the DSA drivers like ocelot/felix and sja1105. This turned out to require some API adjustments in both directions:
to the information presented to and by the switchdev notifier, and to the API presented to the switch drivers by the DSA layer.Vladimir Oltean (9):
net: switchdev: propagate extack to port attributes
net: bridge: offload all port flags at once inbr_setport
net: bridge: don't print inbr_switchdev_set_port_flag
net: dsa: configure better brport flags when ports leave the bridge
net: switchdev: pass flags and mask to both {PRE_,}BRIDGE_FLAGS
attributes
net: dsa: act as ass passthrough for bridge port flags
net: mscc: ocelot: use separate flooding PGID for broadcast
net: mscc: ocelot: offload bridge port flags to device
net: dsa: sja1105: offload bridge port flags to devicedrivers/net/dsa/b53/b53_common.c | 91 ++++--- drivers/net/dsa/b53/b53_priv.h | 2 - drivers/net/dsa/mv88e6xxx/chip.c | 163 ++++++++++--- drivers/net/dsa/mv88e6xxx/chip.h | 6 +- drivers/net/dsa/mv88e6xxx/port.c | 52 ++-- drivers/net/dsa/mv88e6xxx/port.h | 19 +- drivers/net/dsa/ocelot/felix.c | 22 ++ drivers/net/dsa/sja1105/sja1105.h | 2 + drivers/net/dsa/sja1105/sja1105_main.c | 222 +++++++++++++++++- drivers/net/dsa/sja1105/sja1105_spi.c | 6 + .../marvell/prestera/prestera_switchdev.c | 26 +- .../mellanox/mlxsw/spectrum_switchdev.c | 53 +++-- drivers/net/ethernet/mscc/ocelot.c | 100 +++++++- drivers/net/ethernet/mscc/ocelot_net.c | 52 +++- drivers/net/ethernet/rocker/rocker_main.c | 10 +- drivers/net/ethernet/ti/cpsw_switchdev.c | 27 ++- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 34 ++- include/net/dsa.h | 10 +- include/net/switchdev.h | 13 +- include/soc/mscc/ocelot.h | 20 +- net/bridge/br_netlink.c | 116 +++------
Quoted 9 lines
net/bridge/br_private.h | 6 +- net/bridge/br_switchdev.c | 23 +- net/bridge/br_sysfs_if.c | 7 +- net/dsa/dsa_priv.h | 11 +- net/dsa/port.c | 76 ++++-- net/dsa/slave.c | 10 +- net/switchdev/switchdev.c | 11 +- 28 files changed, 870 insertions(+), 320 deletions(-)
Sorry, but we seems just added more work for you.
https://lore.kernel.org/patchwork/cover/1379380/
Signature · 2 lines
Best regards, grygorii
Hi Vladimir,
Quoted 4 lines · Grygorii Strashko
Quoted 1 line · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
[...]
Quoted 4 lines
Sorry, but we seems just added more work for you.
https://lore.kernel.org/patchwork/cover/1379380/
Could you squash these when you post new version:
Sorry for not noticing earlier.
-- >8 --
From 69f3a1ff1ea0777f5deceefdb0e79ce625e6488a Mon Sep 17 00:00:00 2001
From: Vignesh Raghavendra <[email protected]>
Date: Fri, 12 Feb 2021 19:34:46 +0530
Subject: [PATCH 1/2] fixup! net: switchdev: propagate extack to port
attributes
--- drivers/net/ethernet/ti/am65-cpsw-switchdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/am65-cpsw-switchdev.c +2 -1
@@ -81,7 +81,8 @@ static int am65_cpsw_port_attr_br_flags_pre_set(struct net_device *netdev, }static int am65_cpsw_port_attr_set (struct net_device *ndev, -const struct switchdev_attr *attr) +const struct switchdev_attr *attr, +struct netlink_ext_ack *extack) {struct am65_cpsw_port *port =am65_ndev_to_port (ndev);int ret;
-- >8 --
From 7d7fdb79a8b255a1e9fe5d205b0ff1824a16ce56 Mon Sep 17 00:00:00 2001
From: Vignesh Raghavendra <[email protected]>
Date: Fri, 12 Feb 2021 19:40:48 +0530
Subject: [PATCH 2/2] fixup! net: switchdev: pass flags and mask to both
{PRE_,}BRIDGE_FLAGS attributes
--- drivers/net/ethernet/ti/am65-cpsw-switchdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-switchdev.c +4 -4
@@ -55,12 +55,12 @@ static int am65_cpsw_port_stp_state_set(struct am65_cpsw_port *port, u8 state)static int am65_cpsw_port_attr_br_flags_set (struct am65_cpsw_port *port,struct net_device *orig_dev, -unsigned long brport_flags) +struct switchdev_brport_flags flags) {struct am65_cpsw_common *cpsw = port->common;bool unreg_mcast_add = false; -if (brport_flags &BR_MCAST_FLOOD ) +if (flags.mask &BR_MCAST_FLOOD ) unreg_mcast_add = true;netdev_dbg (port->ndev,"BR_MCAST_FLOOD: %d port %u\n" , unreg_mcast_add, port->port_id);
@@ -72,9 +72,9 @@ static int am65_cpsw_port_attr_br_flags_set(struct am65_cpsw_port *port, }static int am65_cpsw_port_attr_br_flags_pre_set (struct net_device *netdev, -unsigned long flags) +struct switchdev_brport_flags flags) { -if (flags & ~(BR_LEARNING |BR_MCAST_FLOOD )) +if (flags.mask & ~(BR_LEARNING |BR_MCAST_FLOOD ))return -EINVAL ;return 0 ;
Signature · 1 line
2.30.0
Vladimir Oltean
maintainerQuoted 7 lines · Vignesh Raghavendra
Hi Vladimir,
Quoted 4 lines · Grygorii Strashko
Quoted 1 line · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
Quoted 8 lines
[...]
Quoted 4 lines
Sorry, but we seems just added more work for you.
https://lore.kernel.org/patchwork/cover/1379380/Could you squash these when you post new version:
Sorry for not noticing earlier.
Hey, thanks for the fixup patch and congrats on the new driver support for the AM65 NUSS! What's functionally different compared to the other CPSW instantiations?
Also, do I get it right that you also tested the bridge port flags passed in the new format and that they still work ok? May I add your Tested-by tag?
Hi,
Quoted 14 lines · Vladimir Oltean
Quoted 13 lines · Vignesh Raghavendra
Hi Vladimir,
Quoted 4 lines · Grygorii Strashko
Quoted 1 line · Vladimir Oltean
From: Vladimir Oltean <[email protected]>
[...]
Quoted 4 lines
Sorry, but we seems just added more work for you.
https://lore.kernel.org/patchwork/cover/1379380/
Quoted 7 lines
Quoted 2 lines
Could you squash these when you post new version:
Sorry for not noticing earlier.Hey, thanks for the fixup patch and congrats on the new driver support for the AM65 NUSS! What's functionally different compared to the other CPSW instantiations?
CPSW is mostly present on older TI's 32 bit SoCs and can support upto 2 external ports.
AM65 NUSS is next generation multi port switch IP (up to 8 external
ports) present on TI's newer 64 bit platform. It also has different DMA integration and has native HW support to work as both Multi Mac and Switch mode.
Quoted 4 lines
Also, do I get it right that you also tested the bridge port flags passed in the new format and that they still work ok? May I add your Tested-by tag?
Sorry, I have not done extensive testing but tried couple of cmds. Those worked as expected:
root@evm:~# ip link set eth0 type bridge_slave flood off mcast_flood off learning off Error: bridge: bridge flag offload is not supported.
root@evm:~# ip link set eth0 type bridge_slave mcast_flood off [ 65.025285] am65-cpsw-nuss 8000000.ethernet eth0: BR_MCAST_FLOOD: 0 port 1
Regards
Vignesh