Remove support from bridge bypass for mlxsw/rocker drivers
Subsystems (8)
Jiri Pirko
maintainercover Remove support from bridge bypass for mlxsw/rocker drivers
From: Jiri Pirko <[email protected]>
Currently setting bridge port attributes and adding FDBs are done via setting the SELF flag which implies unconsistent offloading model. This patch-set fixes this behavior by making the bridge and drivers which are using it to be totally in sync.
This implies several changes:
- Offloading bridge flags from the bridge code.
- Sending notification about FDB add/del to the software bridge in a similiar way it is done for the hardware externally learned FDBs.
By making the offloading model more consistent a cleanup is done in the drivers supporting it. This is done in order to remove un-needed logic related to dump operation which is redundant.
First add missing functionality to bridge, then clean up the mlxsw/rocker drivers.
Arkadi Sharshevsky (19):
net: switchdev: Add support for querying supported bridge flags by
hardware
net: bridge: Add support for offloading port attributes
net: bridge: Add support for calling FDB external learning under rcu
net: switchdev: Change notifier chain to be atomic
net: bridge: Add support for notifying devices about FDB add/del
net: bridge: Receive notification about successful FDB offload
mlxsw: spectrum: Remove support for bridge FDB learning sync
mlxsw: spectrum_switchdev: Add support for querying supported bridge
flags
mlxsw: spectrum: Remove support for bypass bridge port attributes/vlan
set
mlxsw: spectrum_switchdev: Change switchdev notifier API
mlxsw: spectrum_switchdev: Add support for learning FDB through
notification
mlxsw: spectrum: Remove support for bridge bypass FDB add/del
net: Remove support for bridge bypass ndos from stacked devices
rocker: Remove support for bridge FDB learning sync
rocker: Add support for querying supported bridge flags
rocker: Change world_ops API and implementation to be switchdev
independant
rocker: Add support for learning FDB through notification
rocker: Remove support for bypass bridge port attributes/vlan set
rocker: Remove support bridge bypass FDB
drivers/net/bonding/bond_main.c | 6 - drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 8 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 + .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 360 +++++------- drivers/net/ethernet/rocker/rocker.h | 21 +- drivers/net/ethernet/rocker/rocker_main.c | 235 +++++--- drivers/net/ethernet/rocker/rocker_ofdpa.c | 610 ++++++++------------- drivers/net/team/team.c | 6 - include/net/switchdev.h | 9 +- include/uapi/linux/neighbour.h | 1 + net/8021q/vlan_dev.c | 6 - net/bridge/br.c | 19 +- net/bridge/br_fdb.c | 46 +- net/bridge/br_netlink.c | 112 +++- net/bridge/br_private.h | 23 +- net/bridge/br_switchdev.c | 13 + net/switchdev/switchdev.c | 30 +- 17 files changed, 714 insertions(+), 792 deletions(-)
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 1/19 net: switchdev: Add support for querying supported bridge flags by hardware
From: Arkadi Sharshevsky <[email protected]>
This is done as a preparation stage before setting the bridge port flags from the bridge code. Currently the device can be queried for the bridge flags state, but the querier cannot distinguish if the flag is disabled or if it is not supported at all. Thus, add new attr and a bit-mask which include information regarding the support on a per-flag basis.
Drivers that support bridge offload but not support bridge flags should return zeroed bitmask.
--- include/net/switchdev.h | 2 ++ 1 file changed, 2 insertions(+)
include/net/switchdev.h +2 -0
@@ -46,6 +46,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_PORT_PARENT_ID ,SWITCHDEV_ATTR_ID_PORT_STP_STATE ,SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS , +SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT ,SWITCHDEV_ATTR_ID_PORT_MROUTER ,SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME , SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,
@@ -62,6 +63,7 @@ struct switchdev_attr {struct netdev_phys_item_id ppid;/* PORT_PARENT_ID */ u8 stp_state;/* PORT_STP_STATE */ unsigned long brport_flags;/* PORT_BRIDGE_FLAGS */ +unsigned long brport_flags_support;/* PORT_BRIDGE_FLAGS_SUPPORT */ bool mrouter;/* PORT_MROUTER */ clock_t ageing_time;/* BRIDGE_AGEING_TIME */ bool vlan_filtering;/* BRIDGE_VLAN_FILTERING */
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 2/19 net: bridge: Add support for offloading port attributes
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Currently the flood, learning and learning_sync port attributes are offloaded by setting the SELF flag. Add support for offloading the flood and learning attribute through the bridge code. In case of setting an unsupported flag on a offloded port the operation will fail.
The learning_sync attribute doesn't have any software representation and cannot be offloaded through the bridge code.
--- net/bridge/br_netlink.c | 112 +++++++++++++++++++++++++++++++++++++++--------- net/bridge/br_private.h | 4 ++ 2 files changed, 96 insertions(+), 20 deletions(-)
net/bridge/br_netlink.c +92 -20
@@ -17,6 +17,7 @@#include <net/net_namespace.h> #include <net/sock.h> #include <uapi/linux/if_bridge.h> +#include <net/switchdev.h> #include "br_private.h" #include "br_private_stp.h"
@@ -662,16 +663,52 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state) }/* Set/clear or port flags based on attribute */ -static void br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], -int attrtype,unsigned long mask) +static int br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], +int attrtype,unsigned long mask) { -if (tb[attrtype]) { -u8 flag =nla_get_u8 (tb[attrtype]); -if (flag) - p->flags |= mask; -else - p->flags &= ~mask; +struct switchdev_attr attr = { + .orig_dev = p->dev, + .id =SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT , + }; +unsigned long flags; +int err; + +if (!tb[attrtype]) +return 0 ; + +if (nla_get_u8 (tb[attrtype])) + flags = p->flags | mask; +else + flags = p->flags & ~mask; + +if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD ) + goto out; + + err =switchdev_port_attr_get (p->dev, &attr); +if (err == -EOPNOTSUPP ) + goto out; +if (err) +return err; + +/* Check if specific bridge flag attribute offload is supported */ +if (!(attr.u.brport_flags_support & mask)) { +br_warn (p->br,"bridge flag offload is not supported %u(%s)\n" , + (unsigned int )p->port_no, p->dev->name); +return -EOPNOTSUPP ; + } + + 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) { +br_warn (p->br,"error setting offload FLAG on port %u(%s)\n" , + (unsigned int )p->port_no, p->dev->name); +return err; } +out: + p->flags = flags; +return 0 ; }/* Process bridge protocol info on port */
@@ -681,20 +718,55 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])bool br_vlan_tunnel_old = false;int err; -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 ); + 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; -br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); + err =br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); +if (err) +return err; +if (br_vlan_tunnel_old && !(p->flags &BR_VLAN_TUNNEL ))nbp_vlan_tunnel_info_flush (p);
net/bridge/br_private.h +4 -0
@@ -42,6 +42,10 @@/* Path to usermode spanning tree program */ #define BR_STP_PROG "/sbin/bridge-stp" +/* Flags that can be offloaded to hardware */ +#define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \ + BR_MCAST_FLOOD | BR_BCAST_FLOOD) +typedef struct bridge_id bridge_id ;typedef struct mac_addr mac_addr ;typedef __u16 port_id ;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 6/19 net: bridge: Receive notification about successful FDB offload
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
When a new static FDB is added to the bridge a notification is sent to the driver for offload. In case of successful offload the driver should notify the bridge back, which in turn should mark the FDB as offloaded.
Currently, externally learned is equivalent for being offloaded which is not correct due to the fact that FDBs which are added from user-space are also marked as externally learned. In order to specify if an FDB was successfully offloaded a new flag is introduced.
--- include/net/switchdev.h | 1 + include/uapi/linux/neighbour.h | 1 + net/bridge/br.c | 11 ++++++++++- net/bridge/br_fdb.c | 22 +++++++++++++++++++++- net/bridge/br_private.h | 5 ++++- 5 files changed, 37 insertions(+), 3 deletions(-)
include/net/switchdev.h +1 -0
@@ -159,6 +159,7 @@ enum switchdev_notifier_type {SWITCHDEV_FDB_DEL_TO_BRIDGE ,SWITCHDEV_FDB_ADD_TO_DEVICE ,SWITCHDEV_FDB_DEL_TO_DEVICE , + SWITCHDEV_FDB_OFFLOADED, }; struct switchdev_notifier_info {
include/uapi/linux/neighbour.h +1 -0
@@ -41,6 +41,7 @@ enum {#define NTF_MASTER 0x04#define NTF_PROXY 0x08/* == ATF_PUBL */ #define NTF_EXT_LEARNED 0x10 +#define NTF_OFFLOADED 0x20#define NTF_ROUTER 0x80/*
net/bridge/br.c +10 -1
@@ -142,8 +142,12 @@ static int br_switchdev_event(struct notifier_block *unused, fdb_info = ptr; err =br_fdb_external_learn_add (br, p, fdb_info->addr, fdb_info->vid); -if (err) +if (err) { err =notifier_from_errno (err); +break ; + } +br_fdb_offloaded_set (br, p, fdb_info->addr, + fdb_info->vid);break ;case SWITCHDEV_FDB_DEL_TO_BRIDGE : fdb_info = ptr;
@@ -152,6 +156,11 @@ static int br_switchdev_event(struct notifier_block *unused,if (err) err =notifier_from_errno (err);break ; +case SWITCHDEV_FDB_OFFLOADED : + fdb_info = ptr; +br_fdb_offloaded_set (br, p, fdb_info->addr, + fdb_info->vid); +break ; } out:
net/bridge/br_fdb.c +21 -1
@@ -511,6 +511,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct hlist_head *head, fdb->is_static = is_static; fdb->added_by_user =0 ; fdb->added_by_external_learn =0 ; + fdb->offloaded =0 ; fdb->updated = fdb->used = jiffies;hlist_add_head_rcu (&fdb->hlist, head); }
@@ -647,11 +648,16 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br, ndm->ndm_family =AF_BRIDGE ; ndm->ndm_pad1 =0 ; ndm->ndm_pad2 =0 ; - ndm->ndm_flags = fdb->added_by_external_learn ?NTF_EXT_LEARNED :0 ; + ndm->ndm_flags =0 ; ndm->ndm_type =0 ; ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex; ndm->ndm_state =fdb_to_nud (br, fdb); +if (fdb->offloaded) + ndm->ndm_flags |=NTF_OFFLOADED ; +if (fdb->added_by_external_learn) + ndm->ndm_flags |=NTF_EXT_LEARNED ; +if (nla_put (skb,NDA_LLADDR ,ETH_ALEN , &fdb->addr)) goto nla_put_failure;if (nla_put_u32 (skb,NDA_MASTER , br->dev->ifindex))
@@ -1143,3 +1149,17 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,return err; } + +void br_fdb_offloaded_set (struct net_bridge *br,struct net_bridge_port *p, +const unsigned char *addr,u16 vid) +{ +struct net_bridge_fdb_entry *fdb; + +spin_lock_bh (&br->hash_lock); + + fdb =br_fdb_find (br, addr, vid); +if (fdb) + fdb->offloaded =1 ; + +spin_unlock_bh (&br->hash_lock); +}
net/bridge/br_private.h +4 -1
@@ -173,7 +173,8 @@ struct net_bridge_fdb_entry { unsigned char is_local:1, is_static:1, added_by_user:1, - added_by_external_learn:1; + added_by_external_learn:1, + offloaded:1;/* write-heavy members should not affect lookups */ unsigned long updated____cacheline_aligned_in_smp ;
@@ -540,6 +541,8 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, const unsigned char *addr, u16 vid);int br_fdb_external_learn_del (struct net_bridge *br,struct net_bridge_port *p,const unsigned char *addr,u16 vid); +void br_fdb_offloaded_set (struct net_bridge *br,struct net_bridge_port *p, +const unsigned char *addr,u16 vid);/* br_forward.c */ enum br_pkt_type {
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 3/19 net: bridge: Add support for calling FDB external learning under rcu
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
This is done as a preparation to moving the switchdev notifier chain to be atomic. The FDB external learning should be called under rtnl or rcu.
--- net/bridge/br.c | 4 ++-- net/bridge/br_fdb.c | 2 -- net/bridge/br_private.h | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-)
net/bridge/br.c +2 -2
@@ -121,7 +121,7 @@ static struct notifier_block br_device_notifier = { .notifier_call = br_device_event }; -/* called with RTNL */ +/* called with RTNL or RCU */ static int br_switchdev_event (struct notifier_block *unused,unsigned long event,void *ptr) {
@@ -131,7 +131,7 @@ static int br_switchdev_event(struct notifier_block *unused,struct switchdev_notifier_fdb_info *fdb_info;int err =NOTIFY_DONE ; - p =br_port_get_rtnl (dev); + p =br_port_get_rtnl_rcu (dev);if (!p) goto out;
net/bridge/br_fdb.c +0 -2
@@ -1075,7 +1075,6 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,struct net_bridge_fdb_entry *fdb;int err =0 ; -ASSERT_RTNL ();spin_lock_bh (&br->hash_lock); head = &br->hash[br_mac_hash (addr, vid)];
@@ -1110,7 +1109,6 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,struct net_bridge_fdb_entry *fdb;int err =0 ; -ASSERT_RTNL ();spin_lock_bh (&br->hash_lock); fdb =br_fdb_find (br, addr, vid);
net/bridge/br_private.h +6 -0
@@ -288,6 +288,12 @@ static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device * rtnl_dereference(dev->rx_handler_data) : NULL; } +static inline struct net_bridge_port *br_port_get_rtnl_rcu (const struct net_device *dev) +{ +return br_port_exists (dev) ? +rcu_dereference_rtnl (dev->rx_handler_data) :NULL ; +} +struct net_bridge {spinlock_t lock;spinlock_t hash_lock;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 7/19 mlxsw: spectrum: Remove support for bridge FDB learning sync
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Currently the mlxsw driver supports an option for disabling syncing the hardware learned FDBs with the software bridge. This behavior breaks the bridge offload model and thus it is removed.
--- .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +9 -11
@@ -1857,19 +1857,17 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,mlxsw_sp_bridge_port_put (mlxsw_sp->bridge, bridge_port); } -static void mlxsw_sp_fdb_call_notifiers (bool learning_sync,bool adding, +static void mlxsw_sp_fdb_call_notifiers (bool adding,char *mac,u16 vid,struct net_device *dev) {struct switchdev_notifier_fdb_info info;unsigned long notifier_type; -if (learning_sync) { - info.addr = mac; - info.vid = vid; - notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ; -call_switchdev_notifiers (notifier_type, dev, &info.info); - } + info.addr = mac; + info.vid = vid; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ; +call_switchdev_notifiers (notifier_type, dev, &info.info); } static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
@@ -1918,8 +1916,8 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,if (!do_notification)return ; -mlxsw_sp_fdb_call_notifiers (bridge_port->flags &BR_LEARNING_SYNC , - adding, mac, vid, bridge_port->dev); +mlxsw_sp_fdb_call_notifiers (adding, mac, vid, bridge_port->dev); +return ; just_remove:
@@ -1976,8 +1974,8 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,if (!do_notification)return ; -mlxsw_sp_fdb_call_notifiers (bridge_port->flags &BR_LEARNING_SYNC , - adding, mac, vid, bridge_port->dev); +mlxsw_sp_fdb_call_notifiers (adding, mac, vid, bridge_port->dev); +return ; just_remove:
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 4/19 net: switchdev: Change notifier chain to be atomic
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
In order to use the switchdev notifier chain for FDB sync with the device it has to be changed to atomic. The is done because the bridge can learn new FDBs in atomic context.
--- net/switchdev/switchdev.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
net/switchdev/switchdev.c +6 -24
@@ -571,24 +571,17 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj, }EXPORT_SYMBOL_GPL (switchdev_port_obj_dump); -static RAW_NOTIFIER_HEAD (switchdev_notif_chain); +static ATOMIC_NOTIFIER_HEAD (switchdev_notif_chain);/** * register_switchdev_notifier - Register notifier * @nb: notifier_block * -* Register switch device notifier. This should be used by code -* which needs to monitor events happening in particular device. -* Return values are same as for atomic_notifier_chain_register(). +* Register switch device notifier. */ int register_switchdev_notifier (struct notifier_block *nb) { -int err; - -rtnl_lock (); - err =raw_notifier_chain_register (&switchdev_notif_chain, nb); -rtnl_unlock (); -return err; +return atomic_notifier_chain_register (&switchdev_notif_chain, nb); }EXPORT_SYMBOL_GPL (register_switchdev_notifier);
@@ -597,16 +590,10 @@ EXPORT_SYMBOL_GPL(register_switchdev_notifier);* @nb: notifier_block * * Unregister switch device notifier. -* Return values are same as for atomic_notifier_chain_unregister(). */ int unregister_switchdev_notifier (struct notifier_block *nb) { -int err; - -rtnl_lock (); - err =raw_notifier_chain_unregister (&switchdev_notif_chain, nb); -rtnl_unlock (); -return err; +return atomic_notifier_chain_unregister (&switchdev_notif_chain, nb); }EXPORT_SYMBOL_GPL (unregister_switchdev_notifier);
@@ -616,18 +603,13 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);* @dev: port device * @info: notifier information data * -* Call all network notifier blocks. This should be called by driver -* when it needs to propagate hardware event. -* Return values are same as for atomic_notifier_call_chain(). -* rtnl_lock must be held. +* Call all network notifier blocks. */ int call_switchdev_notifiers (unsigned long val,struct net_device *dev,struct switchdev_notifier_info *info) { -ASSERT_RTNL (); - info->dev = dev; -return raw_notifier_call_chain (&switchdev_notif_chain, val, info); +return atomic_notifier_call_chain (&switchdev_notif_chain, val, info); }EXPORT_SYMBOL_GPL (call_switchdev_notifiers);
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 8/19 mlxsw: spectrum_switchdev: Add support for querying supported bridge flags
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Add support for querying supported bridge flags.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +3 -0
@@ -456,6 +456,9 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,mlxsw_sp_port_bridge_flags_get (mlxsw_sp->bridge, attr->orig_dev, &attr->u.brport_flags);break ; +case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT : + attr->u.brport_flags_support =BR_LEARNING |BR_FLOOD ; +break ;default :return -EOPNOTSUPP ; }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 5/19 net: bridge: Add support for notifying devices about FDB add/del
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Currently the bridge doesn't notify the underlying devices about new FDBs learned. The FDB sync is placed on the switchdev notifier chain because devices may potentially learn FDB that are not directly related to their ports, for example:
1. Mixed SW/HW bridge - FDBs that point to the ASICs external devices should be offloaded as CPU traps in order to perform forwarding in slow path.
2. EVPN - Externally learned FDBs for the vtep device.
Notification is sent only about static FDB add/del. This is done due to fact that currently this is the only scenario supported by switch drivers.
--- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +- drivers/net/ethernet/rocker/rocker_ofdpa.c | 4 ++-- include/net/switchdev.h | 6 ++++-- net/bridge/br.c | 4 ++-- net/bridge/br_fdb.c | 22 ++++++++++++++++++++++ net/bridge/br_private.h | 8 ++++++++ net/bridge/br_switchdev.c | 13 +++++++++++++ 7 files changed, 52 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1 -1
@@ -1867,7 +1867,7 @@ static void mlxsw_sp_fdb_call_notifiers(bool learning_sync, bool adding,if (learning_sync) { info.addr = mac; info.vid = vid; - notifier_type = adding ?SWITCHDEV_FDB_ADD :SWITCHDEV_FDB_DEL ; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ;call_switchdev_notifiers (notifier_type, dev, &info.info); } }
drivers/net/ethernet/rocker/rocker_ofdpa.c +2 -2
@@ -1939,10 +1939,10 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)rtnl_lock ();if (learned && removing) -call_switchdev_notifiers (SWITCHDEV_FDB_DEL , +call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , lw->ofdpa_port->dev, &info.info);else if (learned && !removing) -call_switchdev_notifiers (SWITCHDEV_FDB_ADD , +call_switchdev_notifiers (SWITCHDEV_FDB_ADD_TO_BRIDGE , lw->ofdpa_port->dev, &info.info);rtnl_unlock ();
include/net/switchdev.h +4 -2
@@ -155,8 +155,10 @@ struct switchdev_ops { };enum switchdev_notifier_type { -SWITCHDEV_FDB_ADD =1 , -SWITCHDEV_FDB_DEL , +SWITCHDEV_FDB_ADD_TO_BRIDGE =1 , +SWITCHDEV_FDB_DEL_TO_BRIDGE , +SWITCHDEV_FDB_ADD_TO_DEVICE , +SWITCHDEV_FDB_DEL_TO_DEVICE , };struct switchdev_notifier_info {
net/bridge/br.c +2 -2
@@ -138,14 +138,14 @@ static int br_switchdev_event(struct notifier_block *unused, br = p->br;switch (event) { -case SWITCHDEV_FDB_ADD : +case SWITCHDEV_FDB_ADD_TO_BRIDGE : fdb_info = ptr; err =br_fdb_external_learn_add (br, p, fdb_info->addr, fdb_info->vid);if (err) err =notifier_from_errno (err);break ; -case SWITCHDEV_FDB_DEL : +case SWITCHDEV_FDB_DEL_TO_BRIDGE : fdb_info = ptr; err =br_fdb_external_learn_del (br, p, fdb_info->addr, fdb_info->vid);
net/bridge/br_fdb.c +22 -0
@@ -683,6 +683,26 @@ static inline size_t fdb_nlmsg_size(void) +nla_total_size (sizeof (struct nda_cacheinfo )); } +static void +fdb_notify_switchdev (const struct net_bridge_fdb_entry *fdb,int type) +{ +if (!fdb->added_by_user) +return ; + +switch (type) { +case RTM_DELNEIGH : +br_switchdev_fdb_call_notifiers (false, fdb->addr.addr, + fdb->vlan_id, + fdb->dst->dev); +break ; +case RTM_NEWNEIGH : +br_switchdev_fdb_call_notifiers (true, fdb->addr.addr, + fdb->vlan_id, + fdb->dst->dev); +break ; + } +} +static void fdb_notify (struct net_bridge *br,const struct net_bridge_fdb_entry *fdb,int type) {
@@ -690,6 +710,8 @@ static void fdb_notify(struct net_bridge *br,struct sk_buff *skb;int err = -ENOBUFS ; +fdb_notify_switchdev (fdb, type); + skb =nlmsg_new (fdb_nlmsg_size (),GFP_ATOMIC );if (skb ==NULL ) goto errout;
net/bridge/br_private.h +8 -0
@@ -1086,6 +1086,8 @@ void nbp_switchdev_frame_mark(const struct net_bridge_port *p, struct sk_buff *skb);bool nbp_switchdev_allowed_egress (const struct net_bridge_port *p,const struct sk_buff *skb); +void br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev);#else static inline int nbp_switchdev_mark_set (struct net_bridge_port *p) {
@@ -1102,6 +1104,12 @@ static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, {return true; } + +static inline void +br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev) +{ +}#endif /* CONFIG_NET_SWITCHDEV */ #endif
net/bridge/br_switchdev.c +13 -0
@@ -55,3 +55,16 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,return !skb->offload_fwd_mark ||BR_INPUT_SKB_CB (skb)->offload_fwd_mark != p->offload_fwd_mark; } + +void +br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev) +{ +struct switchdev_notifier_fdb_info info; +unsigned long notifier_type; + + info.addr = mac; + info.vid = vid; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_DEVICE :SWITCHDEV_FDB_DEL_TO_DEVICE ; +call_switchdev_notifiers (notifier_type, dev, &info.info); +}
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 9/19 mlxsw: spectrum: Remove support for bypass bridge port attributes/vlan set
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
The bridge port attributes/vlan for mlxsw devices should be set only from bridge code. The vlans are synced totally with the bridge so there is no need to special dump support.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 3 -- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 41 ---------------------- 2 files changed, 44 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +0 -3
@@ -1755,9 +1755,6 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = { .ndo_fdb_add = switchdev_port_fdb_add, .ndo_fdb_del = switchdev_port_fdb_del, .ndo_fdb_dump = switchdev_port_fdb_dump, - .ndo_bridge_setlink = switchdev_port_bridge_setlink, - .ndo_bridge_getlink = switchdev_port_bridge_getlink, - .ndo_bridge_dellink = switchdev_port_bridge_dellink, .ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name, };
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0 -41
65 lines not on this page · raw message
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 10/19 mlxsw: spectrum_switchdev: Change switchdev notifier API
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
The current API for sending switchdev notifications implies only FDB add/del. In order to support notification about successful FDB offload the API is changed.
--- .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +11 -8
@@ -1819,17 +1819,16 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,mlxsw_sp_bridge_port_put (mlxsw_sp->bridge, bridge_port); } -static void mlxsw_sp_fdb_call_notifiers (bool adding, -char *mac,u16 vid, -struct net_device *dev) +static void +mlxsw_sp_fdb_call_notifiers (enum switchdev_notifier_type type, +const char *mac,u16 vid, +struct net_device *dev) {struct switchdev_notifier_fdb_info info; -unsigned long notifier_type; info.addr = mac; info.vid = vid; - notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ; -call_switchdev_notifiers (notifier_type, dev, &info.info); +call_switchdev_notifiers (type, dev, &info.info); } static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
@@ -1840,6 +1839,7 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_bridge_device *bridge_device;struct mlxsw_sp_bridge_port *bridge_port;struct mlxsw_sp_port *mlxsw_sp_port; +enum switchdev_notifier_type type;char mac[ETH_ALEN ];u8 local_port;u16 vid, fid;
@@ -1878,7 +1878,8 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,if (!do_notification)return ; -mlxsw_sp_fdb_call_notifiers (adding, mac, vid, bridge_port->dev); + type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ; +mlxsw_sp_fdb_call_notifiers (type, mac, vid, bridge_port->dev);return ;
@@ -1896,6 +1897,7 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_bridge_device *bridge_device;struct mlxsw_sp_bridge_port *bridge_port;struct mlxsw_sp_port *mlxsw_sp_port; +enum switchdev_notifier_type type;char mac[ETH_ALEN ];u16 lag_vid =0 ;u16 lag_id;
@@ -1936,7 +1938,8 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,if (!do_notification)return ; -mlxsw_sp_fdb_call_notifiers (adding, mac, vid, bridge_port->dev); + type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ; +mlxsw_sp_fdb_call_notifiers (type, mac, vid, bridge_port->dev);return ;
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 12/19 mlxsw: spectrum: Remove support for bridge bypass FDB add/del
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
The FDB add/del are now done through the notification chain. The FDBs are synced with the bridge and there is no need for extra dumping.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 3 - .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 200 --------------------- 2 files changed, 203 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +0 -3
@@ -1752,9 +1752,6 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = { .ndo_get_offload_stats = mlxsw_sp_port_get_offload_stats, .ndo_vlan_rx_add_vid = mlxsw_sp_port_add_vid, .ndo_vlan_rx_kill_vid = mlxsw_sp_port_kill_vid, - .ndo_fdb_add = switchdev_port_fdb_add, - .ndo_fdb_del = switchdev_port_fdb_del, - .ndo_fdb_dump = switchdev_port_fdb_dump, .ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name, };
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0 -200
235 lines not on this page · raw message
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 14/19 rocker: Remove support for bridge FDB learning sync
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Currently the rocker driver supports an option for disabling syncing the hardware learned FDBs with the software bridge. This behavior breaks the bridge offload model and thus it is removed.
--- drivers/net/ethernet/rocker/rocker_ofdpa.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/rocker/rocker_ofdpa.c +1 -5
@@ -1959,7 +1959,6 @@ static int ofdpa_port_fdb_learn(struct ofdpa_port *ofdpa_port,u32 out_pport = ofdpa_port->pport;u32 tunnel_id =0 ;u32 group_id =ROCKER_GROUP_NONE ; -bool syncing = !!(ofdpa_port->brport_flags &BR_LEARNING_SYNC );bool copy_to_cpu = false;int err;
@@ -1974,9 +1973,6 @@ static int ofdpa_port_fdb_learn(struct ofdpa_port *ofdpa_port,return err; } -if (!syncing) -return 0 ; -if (!ofdpa_port_is_bridged (ofdpa_port))return 0 ;
@@ -2550,7 +2546,7 @@ static int ofdpa_port_pre_init(struct rocker_port *rocker_port) ofdpa_port->rocker_port = rocker_port; ofdpa_port->dev = rocker_port->dev; ofdpa_port->pport = rocker_port->pport; - ofdpa_port->brport_flags =BR_LEARNING |BR_LEARNING_SYNC ; + ofdpa_port->brport_flags =BR_LEARNING ; ofdpa_port->ageing_time =BR_DEFAULT_AGEING_TIME ;return 0 ; }
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 13/19 net: Remove support for bridge bypass ndos from stacked devices
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Remove support for bridge bypass ndos from stacked devices. At this point no driver which supports stack device behavior offload supports operation with SELF flag. The case for upper device is already taken care of in both of the following cases:
1. FDB add/del - driver should check at the notification cb if the stacked device contains his ports.
2. Port attribute - calls switchdev code directly which checks for case of stack device.
--- drivers/net/bonding/bond_main.c | 6 ------ drivers/net/team/team.c | 6 ------ net/8021q/vlan_dev.c | 6 ------ 3 files changed, 18 deletions(-)
drivers/net/bonding/bond_main.c +0 -6
@@ -4175,12 +4175,6 @@ static const struct net_device_ops bond_netdev_ops = { .ndo_add_slave = bond_enslave, .ndo_del_slave = bond_release, .ndo_fix_features = bond_fix_features, - .ndo_bridge_setlink = switchdev_port_bridge_setlink, - .ndo_bridge_getlink = switchdev_port_bridge_getlink, - .ndo_bridge_dellink = switchdev_port_bridge_dellink, - .ndo_fdb_add = switchdev_port_fdb_add, - .ndo_fdb_del = switchdev_port_fdb_del, - .ndo_fdb_dump = switchdev_port_fdb_dump, .ndo_features_check = passthru_features_check, };
drivers/net/team/team.c +0 -6
@@ -2005,12 +2005,6 @@ static const struct net_device_ops team_netdev_ops = { .ndo_del_slave = team_del_slave, .ndo_fix_features = team_fix_features, .ndo_change_carrier = team_change_carrier, - .ndo_bridge_setlink = switchdev_port_bridge_setlink, - .ndo_bridge_getlink = switchdev_port_bridge_getlink, - .ndo_bridge_dellink = switchdev_port_bridge_dellink, - .ndo_fdb_add = switchdev_port_fdb_add, - .ndo_fdb_del = switchdev_port_fdb_del, - .ndo_fdb_dump = switchdev_port_fdb_dump, .ndo_features_check = passthru_features_check, };
net/8021q/vlan_dev.c +0 -6
@@ -797,12 +797,6 @@ static const struct net_device_ops vlan_netdev_ops = { .ndo_netpoll_cleanup = vlan_dev_netpoll_cleanup, #endif .ndo_fix_features = vlan_dev_fix_features, - .ndo_fdb_add = switchdev_port_fdb_add, - .ndo_fdb_del = switchdev_port_fdb_del, - .ndo_fdb_dump = switchdev_port_fdb_dump, - .ndo_bridge_setlink = switchdev_port_bridge_setlink, - .ndo_bridge_getlink = switchdev_port_bridge_getlink, - .ndo_bridge_dellink = switchdev_port_bridge_dellink, .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, .ndo_get_iflink = vlan_dev_get_iflink, };
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 16/19 rocker: Change world_ops API and implementation to be switchdev independant
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Currently the switchdev_trans struct is embedded in the world_ops API. In order to add support for adding FDB via a notfication chain the API should be switchdev independent.
--- drivers/net/ethernet/rocker/rocker.h | 11 +- drivers/net/ethernet/rocker/rocker_main.c | 28 +- drivers/net/ethernet/rocker/rocker_ofdpa.c | 535 +++++++++++------------------ 3 files changed, 235 insertions(+), 339 deletions(-)
drivers/net/ethernet/rocker/rocker.h +4 -7
@@ -105,8 +105,7 @@ struct rocker_world_ops {int (*port_open)(struct rocker_port *rocker_port);void (*port_stop)(struct rocker_port *rocker_port);int (*port_attr_stp_state_set)(struct rocker_port *rocker_port, -u8 state, -struct switchdev_trans *trans); +u8 state);int (*port_attr_bridge_flags_set)(struct rocker_port *rocker_port,unsigned long brport_flags,struct switchdev_trans *trans);
@@ -120,18 +119,16 @@ struct rocker_world_ops {u32 ageing_time, struct switchdev_trans *trans);int (*port_obj_vlan_add)(struct rocker_port *rocker_port, -const struct switchdev_obj_port_vlan *vlan, -struct switchdev_trans *trans); +const struct switchdev_obj_port_vlan *vlan);int (*port_obj_vlan_del)(struct rocker_port *rocker_port,const struct switchdev_obj_port_vlan *vlan);int (*port_obj_vlan_dump)(const struct rocker_port *rocker_port,struct switchdev_obj_port_vlan *vlan,switchdev_obj_dump_cb_t *cb);int (*port_obj_fdb_add)(struct rocker_port *rocker_port, -const struct switchdev_obj_port_fdb *fdb, -struct switchdev_trans *trans); +u16 vid,const unsigned char *addr);int (*port_obj_fdb_del)(struct rocker_port *rocker_port, -const struct switchdev_obj_port_fdb *fdb); +u16 vid,const unsigned char *addr);int (*port_obj_fdb_dump)(const struct rocker_port *rocker_port,struct switchdev_obj_port_fdb *fdb,switchdev_obj_dump_cb_t *cb);
drivers/net/ethernet/rocker/rocker_main.c +24 -4
@@ -1557,7 +1557,11 @@ static int rocker_world_port_attr_stp_state_set(struct rocker_port *rocker_port,if (!wops->port_attr_stp_state_set)return -EOPNOTSUPP ; -return wops->port_attr_stp_state_set (rocker_port, state, trans); + +if (switchdev_trans_ph_prepare (trans)) +return 0 ; + +return wops->port_attr_stp_state_set (rocker_port, state); } static int
@@ -1569,6 +1573,10 @@ rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,if (!wops->port_attr_bridge_flags_set)return -EOPNOTSUPP ; + +if (switchdev_trans_ph_prepare (trans)) +return 0 ; +return wops->port_attr_bridge_flags_set (rocker_port, brport_flags, trans); }
@@ -1608,6 +1616,10 @@ rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,if (!wops->port_attr_bridge_ageing_time_set)return -EOPNOTSUPP ; + +if (switchdev_trans_ph_prepare (trans)) +return 0 ; +return wops->port_attr_bridge_ageing_time_set (rocker_port, ageing_time, trans); }
@@ -1621,7 +1633,11 @@ rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port,if (!wops->port_obj_vlan_add)return -EOPNOTSUPP ; -return wops->port_obj_vlan_add (rocker_port, vlan, trans); + +if (switchdev_trans_ph_prepare (trans)) +return 0 ; + +return wops->port_obj_vlan_add (rocker_port, vlan); } static int
@@ -1656,7 +1672,11 @@ rocker_world_port_obj_fdb_add(struct rocker_port *rocker_port,if (!wops->port_obj_fdb_add)return -EOPNOTSUPP ; -return wops->port_obj_fdb_add (rocker_port, fdb, trans); + +if (switchdev_trans_ph_prepare (trans)) +return 0 ; + +return wops->port_obj_fdb_add (rocker_port, fdb->vid, fdb->addr); } static int
@@ -1667,7 +1687,7 @@ rocker_world_port_obj_fdb_del(struct rocker_port *rocker_port,if (!wops->port_obj_fdb_del)return -EOPNOTSUPP ; -return wops->port_obj_fdb_del (rocker_port, fdb); +return wops->port_obj_fdb_del (rocker_port, fdb->vid, fdb->addr); } static int
drivers/net/ethernet/rocker/rocker_ofdpa.c +207 -328
1,358 lines not on this page · raw message
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 17/19 rocker: Add support for learning FDB through notification
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Add support for learning FDB through notification. The driver defers the hardware update via ordered work queue.
--- drivers/net/ethernet/rocker/rocker_main.c | 140 ++++++++++++++++++++++++++++-- 1 file changed, 135 insertions(+), 5 deletions(-)
drivers/net/ethernet/rocker/rocker_main.c +135 -5
@@ -1691,6 +1691,29 @@ rocker_world_port_obj_fdb_del(struct rocker_port *rocker_port, }static int +rocker_world_port_fdb_add (struct rocker_port *rocker_port, +struct switchdev_notifier_fdb_info *info) +{ +struct rocker_world_ops *wops = rocker_port->rocker->wops; + +if (!wops->port_obj_fdb_add) +return -EOPNOTSUPP ; + +return wops->port_obj_fdb_add (rocker_port, info->vid, info->addr); +} + +static int +rocker_world_port_fdb_del (struct rocker_port *rocker_port, +struct switchdev_notifier_fdb_info *info) +{ +struct rocker_world_ops *wops = rocker_port->rocker->wops; + +if (!wops->port_obj_fdb_del) +return -EOPNOTSUPP ; +return wops->port_obj_fdb_del (rocker_port, info->vid, info->addr); +} + +static int rocker_world_port_obj_fdb_dump (const struct rocker_port *rocker_port,struct switchdev_obj_port_fdb *fdb,switchdev_obj_dump_cb_t *cb)
@@ -2767,6 +2790,109 @@ static void rocker_msix_fini(const struct rocker *rocker)kfree (rocker->msix_entries); } +static bool rocker_port_dev_check (const struct net_device *dev) +{ +return dev->netdev_ops == &rocker_port_netdev_ops; +} + +struct rocker_switchdev_event_work { +struct work_struct work; +struct switchdev_notifier_fdb_info fdb_info; +struct rocker_port *rocker_port; +unsigned long event; +}; + +static void +rocker_fdb_offload_notify (struct rocker_port *rocker_port, +struct switchdev_notifier_fdb_info *recv_info) +{ +struct switchdev_notifier_fdb_info info; + + info.addr = recv_info->addr; + info.vid = recv_info->vid; +call_switchdev_notifiers (SWITCHDEV_FDB_OFFLOADED , + rocker_port->dev, &info.info); +} + +static void rocker_switchdev_event_work (struct work_struct *work) +{ +struct rocker_switchdev_event_work *switchdev_work = + container_of(work, struct rocker_switchdev_event_work, work); +struct rocker_port *rocker_port = switchdev_work->rocker_port; +struct switchdev_notifier_fdb_info *fdb_info; +int err; + +rtnl_lock (); +switch (switchdev_work->event) { +case SWITCHDEV_FDB_ADD_TO_DEVICE : + fdb_info = &switchdev_work->fdb_info; + err =rocker_world_port_fdb_add (rocker_port, fdb_info); +if (err) { +netdev_dbg (rocker_port->dev,"fdb add failed err=%d\n" , err); +break ; + } +rocker_fdb_offload_notify (rocker_port, fdb_info); +break ; +case SWITCHDEV_FDB_DEL_TO_DEVICE : + fdb_info = &switchdev_work->fdb_info; + err =rocker_world_port_fdb_del (rocker_port, fdb_info); +if (err) +netdev_dbg (rocker_port->dev,"fdb add failed err=%d\n" , err); +break ; + } +rtnl_unlock (); + +kfree (switchdev_work->fdb_info.addr); +kfree (switchdev_work); +dev_put (rocker_port->dev); +} + +/* called under rcu_read_lock() */ +static int rocker_switchdev_event (struct notifier_block *unused, +unsigned long event,void *ptr) +{ +struct net_device *dev =switchdev_notifier_info_to_dev (ptr); +struct rocker_switchdev_event_work *switchdev_work; +struct switchdev_notifier_fdb_info *fdb_info = ptr; +struct rocker_port *rocker_port; + +if (!rocker_port_dev_check (dev)) +return NOTIFY_DONE ; + + rocker_port =netdev_priv (dev); + switchdev_work =kzalloc (sizeof (*switchdev_work),GFP_ATOMIC ); +if (WARN_ON (!switchdev_work)) +return NOTIFY_BAD ; + +INIT_WORK (&switchdev_work->work, rocker_switchdev_event_work); + switchdev_work->rocker_port = rocker_port; + switchdev_work->event = event; + +switch (event) { +case SWITCHDEV_FDB_ADD_TO_DEVICE :/* fall through */ +case SWITCHDEV_FDB_DEL_TO_DEVICE : +memcpy (&switchdev_work->fdb_info, ptr, +sizeof (switchdev_work->fdb_info)); + switchdev_work->fdb_info.addr =kzalloc (ETH_ALEN ,GFP_ATOMIC ); +ether_addr_copy ((u8 *)switchdev_work->fdb_info.addr, + fdb_info->addr); +/* Take a reference on the rocker device */ +dev_hold (dev); +break ; +default : +kfree (switchdev_work); +return NOTIFY_DONE ; + } + +queue_work (rocker_port->rocker->rocker_owq, + &switchdev_work->work); +return NOTIFY_DONE ; +} + +static struct notifier_block rocker_switchdev_notifier = { + .notifier_call = rocker_switchdev_event, +}; +static int rocker_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct rocker *rocker;
@@ -2872,6 +2998,12 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_register_fib_notifier; + err =register_switchdev_notifier (&rocker_switchdev_notifier); +if (err) { +dev_err (&pdev->dev,"Failed to register switchdev notifier\n" ); + goto err_register_switchdev_notifier; + } + rocker->hw.id =rocker_read64 (rocker,SWITCH_ID ); err =rocker_probe_ports (rocker);
@@ -2886,6 +3018,8 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)return 0 ; err_probe_ports: +unregister_switchdev_notifier (&rocker_switchdev_notifier); +err_register_switchdev_notifier:unregister_fib_notifier (&rocker->fib_nb); err_register_fib_notifier:destroy_workqueue (rocker->rocker_owq);
@@ -2916,6 +3050,7 @@ static void rocker_remove(struct pci_dev *pdev)struct rocker *rocker =pci_get_drvdata (pdev);rocker_remove_ports (rocker); +unregister_switchdev_notifier (&rocker_switchdev_notifier);unregister_fib_notifier (&rocker->fib_nb);rocker_write32 (rocker,CONTROL ,ROCKER_CONTROL_RESET );destroy_workqueue (rocker->rocker_owq);
@@ -2940,11 +3075,6 @@ static struct pci_driver rocker_pci_driver = {* Net device notifier event handler ************************************/ -static bool rocker_port_dev_check (const struct net_device *dev) -{ -return dev->netdev_ops == &rocker_port_netdev_ops; -} -static bool rocker_port_dev_check_under (const struct net_device *dev,struct rocker *rocker) {
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 18/19 rocker: Remove support for bypass bridge port attributes/vlan set
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
The bridge port attributes/vlan for mlxsw devices should be set only from bridge code. The vlans are synced totally with the bridge so there is no need to special dump support.
--- drivers/net/ethernet/rocker/rocker.h | 3 --- drivers/net/ethernet/rocker/rocker_main.c | 20 -------------------- drivers/net/ethernet/rocker/rocker_ofdpa.c | 24 ------------------------ 3 files changed, 47 deletions(-)
drivers/net/ethernet/rocker/rocker.h +0 -3
@@ -122,9 +122,6 @@ struct rocker_world_ops { const struct switchdev_obj_port_vlan *vlan);int (*port_obj_vlan_del)(struct rocker_port *rocker_port,const struct switchdev_obj_port_vlan *vlan); -int (*port_obj_vlan_dump)(const struct rocker_port *rocker_port, -struct switchdev_obj_port_vlan *vlan, -switchdev_obj_dump_cb_t *cb);int (*port_obj_fdb_add)(struct rocker_port *rocker_port,u16 vid,const unsigned char *addr); int (*port_obj_fdb_del)(struct rocker_port *rocker_port,
drivers/net/ethernet/rocker/rocker_main.c +0 -20
@@ -1652,18 +1652,6 @@ rocker_world_port_obj_vlan_del(struct rocker_port *rocker_port, }static int -rocker_world_port_obj_vlan_dump (const struct rocker_port *rocker_port, -struct switchdev_obj_port_vlan *vlan, -switchdev_obj_dump_cb_t *cb) -{ -struct rocker_world_ops *wops = rocker_port->rocker->wops; - -if (!wops->port_obj_vlan_dump) -return -EOPNOTSUPP ; -return wops->port_obj_vlan_dump (rocker_port, vlan, cb); -} - -static int rocker_world_port_obj_fdb_add (struct rocker_port *rocker_port,const struct switchdev_obj_port_fdb *fdb,struct switchdev_trans *trans)
@@ -2079,9 +2067,6 @@ static const struct net_device_ops rocker_port_netdev_ops = { .ndo_start_xmit = rocker_port_xmit, .ndo_set_mac_address = rocker_port_set_mac_address, .ndo_change_mtu = rocker_port_change_mtu, - .ndo_bridge_getlink = switchdev_port_bridge_getlink, - .ndo_bridge_setlink = switchdev_port_bridge_setlink, - .ndo_bridge_dellink = switchdev_port_bridge_dellink, .ndo_fdb_add = switchdev_port_fdb_add, .ndo_fdb_del = switchdev_port_fdb_del, .ndo_fdb_dump = switchdev_port_fdb_dump,
@@ -2214,11 +2199,6 @@ static int rocker_port_obj_dump(struct net_device *dev,SWITCHDEV_OBJ_PORT_FDB (obj), cb);break ; -case SWITCHDEV_OBJ_ID_PORT_VLAN : - err =rocker_world_port_obj_vlan_dump (rocker_port, -SWITCHDEV_OBJ_PORT_VLAN (obj), - cb); -break ;default : err = -EOPNOTSUPP ;break ;
drivers/net/ethernet/rocker/rocker_ofdpa.c +0 -24
@@ -2583,29 +2583,6 @@ static int ofdpa_port_obj_vlan_del(struct rocker_port *rocker_port,return 0 ; } -static int ofdpa_port_obj_vlan_dump (const struct rocker_port *rocker_port, -struct switchdev_obj_port_vlan *vlan, -switchdev_obj_dump_cb_t *cb) -{ -const struct ofdpa_port *ofdpa_port = rocker_port->wpriv; -u16 vid; -int err =0 ; - -for (vid =1 ; vid <VLAN_N_VID ; vid++) { -if (!test_bit (vid, ofdpa_port->vlan_bitmap)) -continue ; - vlan->flags =0 ; -if (ofdpa_vlan_id_is_internal (htons (vid))) - vlan->flags |=BRIDGE_VLAN_INFO_PVID ; - vlan->vid_begin = vlan->vid_end = vid; - err =cb (&vlan->obj); -if (err) -break ; - } - -return err; -} -static int ofdpa_port_obj_fdb_add (struct rocker_port *rocker_port,u16 vid,const unsigned char *addr) {
@@ -2882,7 +2859,6 @@ struct rocker_world_ops rocker_ofdpa_ops = { .port_attr_bridge_ageing_time_set = ofdpa_port_attr_bridge_ageing_time_set, .port_obj_vlan_add = ofdpa_port_obj_vlan_add, .port_obj_vlan_del = ofdpa_port_obj_vlan_del, - .port_obj_vlan_dump = ofdpa_port_obj_vlan_dump, .port_obj_fdb_add = ofdpa_port_obj_fdb_add, .port_obj_fdb_del = ofdpa_port_obj_fdb_del, .port_obj_fdb_dump = ofdpa_port_obj_fdb_dump,
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 11/19 mlxsw: spectrum_switchdev: Add support for learning FDB through notification
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Add support for learning FDB through notification. The driver defers the hardware update via ordered work queue. Support for stacked devices is also provided. In case of a successful FDB add a notification is sent back to bridge.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 + .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 137 +++++++++++++++++++++ 3 files changed, 139 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +1 -1
@@ -3700,7 +3700,7 @@ struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev)return mlxsw_sp_port ? mlxsw_sp_port->mlxsw_sp :NULL ; } -static struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu (struct net_device *dev) +struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu (struct net_device *dev) {struct mlxsw_sp_port *mlxsw_sp_port;
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +1 -0
@@ -361,6 +361,7 @@ struct mlxsw_sp *mlxsw_sp_lower_get(struct net_device *dev);struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find (struct net_device *dev);struct mlxsw_sp_port *mlxsw_sp_port_lower_dev_hold (struct net_device *dev);void mlxsw_sp_port_dev_put (struct mlxsw_sp_port *mlxsw_sp_port); +struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find_rcu (struct net_device *dev);/* spectrum_dcb.c */ #ifdef CONFIG_MLXSW_SPECTRUM_DCB
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +137 -0
161 lines not on this page · raw message
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 15/19 rocker: Add support for querying supported bridge flags
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Add support for querying supported bridge flags.
--- drivers/net/ethernet/rocker/rocker.h | 4 ++++ drivers/net/ethernet/rocker/rocker_main.c | 18 ++++++++++++++++++ drivers/net/ethernet/rocker/rocker_ofdpa.c | 11 +++++++++++ 3 files changed, 33 insertions(+)
drivers/net/ethernet/rocker/rocker.h +4 -0
@@ -112,6 +112,10 @@ struct rocker_world_ops { struct switchdev_trans *trans);int (*port_attr_bridge_flags_get)(const struct rocker_port *rocker_port,unsigned long *p_brport_flags); +int (*port_attr_bridge_flags_support_get)(const struct rocker_port * + rocker_port, +unsigned long * + p_brport_flags);int (*port_attr_bridge_ageing_time_set)(struct rocker_port *rocker_port,u32 ageing_time,struct switchdev_trans *trans);
drivers/net/ethernet/rocker/rocker_main.c +18 -0
@@ -1585,6 +1585,20 @@ rocker_world_port_attr_bridge_flags_get(const struct rocker_port *rocker_port, }static int +rocker_world_port_attr_bridge_flags_support_get (const struct rocker_port * + rocker_port, +unsigned long * + p_brport_flags_support) +{ +struct rocker_world_ops *wops = rocker_port->rocker->wops; + +if (!wops->port_attr_bridge_flags_support_get) +return -EOPNOTSUPP ; +return wops->port_attr_bridge_flags_support_get (rocker_port, + p_brport_flags_support); +} + +static int rocker_world_port_attr_bridge_ageing_time_set (struct rocker_port *rocker_port,u32 ageing_time,struct switchdev_trans *trans)
@@ -2053,6 +2067,10 @@ static int rocker_port_attr_get(struct net_device *dev, err =rocker_world_port_attr_bridge_flags_get (rocker_port, &attr->u.brport_flags);break ; +case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT : + err =rocker_world_port_attr_bridge_flags_support_get (rocker_port, + &attr->u.brport_flags_support); +break ;default :return -EOPNOTSUPP ; }
drivers/net/ethernet/rocker/rocker_ofdpa.c +11 -0
@@ -2643,6 +2643,16 @@ ofdpa_port_attr_bridge_flags_get(const struct rocker_port *rocker_port, }static int +ofdpa_port_attr_bridge_flags_support_get (const struct rocker_port * + rocker_port, +unsigned long * + p_brport_flags_support) +{ + *p_brport_flags_support =BR_LEARNING ; +return 0 ; +} + +static int ofdpa_port_attr_bridge_ageing_time_set (struct rocker_port *rocker_port,u32 ageing_time,struct switchdev_trans *trans)
@@ -2989,6 +2999,7 @@ struct rocker_world_ops rocker_ofdpa_ops = { .port_attr_stp_state_set = ofdpa_port_attr_stp_state_set, .port_attr_bridge_flags_set = ofdpa_port_attr_bridge_flags_set, .port_attr_bridge_flags_get = ofdpa_port_attr_bridge_flags_get, + .port_attr_bridge_flags_support_get = ofdpa_port_attr_bridge_flags_support_get, .port_attr_bridge_ageing_time_set = ofdpa_port_attr_bridge_ageing_time_set, .port_obj_vlan_add = ofdpa_port_obj_vlan_add, .port_obj_vlan_del = ofdpa_port_obj_vlan_del,
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 19/19 rocker: Remove support bridge bypass FDB
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
The FDB add/delete are now done through the notification chain. The FDBs are synced with the bridge and there is no need for extra dumping.
--- drivers/net/ethernet/rocker/rocker.h | 3 -- drivers/net/ethernet/rocker/rocker_main.c | 73 ------------------------------ drivers/net/ethernet/rocker/rocker_ofdpa.c | 30 ------------ 3 files changed, 106 deletions(-)
drivers/net/ethernet/rocker/rocker.h +0 -3
@@ -126,9 +126,6 @@ struct rocker_world_ops { u16 vid, const unsigned char *addr);int (*port_obj_fdb_del)(struct rocker_port *rocker_port,u16 vid,const unsigned char *addr); -int (*port_obj_fdb_dump)(const struct rocker_port *rocker_port, -struct switchdev_obj_port_fdb *fdb, -switchdev_obj_dump_cb_t *cb);int (*port_master_linked)(struct rocker_port *rocker_port,struct net_device *master); int (*port_master_unlinked)(struct rocker_port *rocker_port,
drivers/net/ethernet/rocker/rocker_main.c +0 -73
109 lines not on this page · raw message
drivers/net/ethernet/rocker/rocker_ofdpa.c +0 -30
@@ -2608,35 +2608,6 @@ static int ofdpa_port_obj_fdb_del(struct rocker_port *rocker_port,return ofdpa_port_fdb (ofdpa_port, addr, vlan_id, flags); } -static int ofdpa_port_obj_fdb_dump (const struct rocker_port *rocker_port, -struct switchdev_obj_port_fdb *fdb, -switchdev_obj_dump_cb_t *cb) -{ -const struct ofdpa_port *ofdpa_port = rocker_port->wpriv; -struct ofdpa *ofdpa = ofdpa_port->ofdpa; -struct ofdpa_fdb_tbl_entry *found; -struct hlist_node *tmp; -unsigned long lock_flags; -int bkt; -int err =0 ; - -spin_lock_irqsave (&ofdpa->fdb_tbl_lock, lock_flags); -hash_for_each_safe (ofdpa->fdb_tbl, bkt, tmp, found, entry) { -if (found->key.ofdpa_port != ofdpa_port) -continue ; -ether_addr_copy (fdb->addr, found->key.addr); - fdb->ndm_state =NUD_REACHABLE ; - fdb->vid =ofdpa_port_vlan_to_vid (ofdpa_port, - found->key.vlan_id); - err =cb (&fdb->obj); -if (err) -break ; - } -spin_unlock_irqrestore (&ofdpa->fdb_tbl_lock, lock_flags); - -return err; -} -static int ofdpa_port_bridge_join (struct ofdpa_port *ofdpa_port,struct net_device *bridge) {
@@ -2861,7 +2832,6 @@ struct rocker_world_ops rocker_ofdpa_ops = { .port_obj_vlan_del = ofdpa_port_obj_vlan_del, .port_obj_fdb_add = ofdpa_port_obj_fdb_add, .port_obj_fdb_del = ofdpa_port_obj_fdb_del, - .port_obj_fdb_dump = ofdpa_port_obj_fdb_dump, .port_master_linked = ofdpa_port_master_linked, .port_master_unlinked = ofdpa_port_master_unlinked, .port_neigh_update = ofdpa_port_neigh_update,
Signature · 1 line
2.9.3
Jiri Pirko
maintainerPATCH 1/1 bridge: Distinguish between externally learned vs offloaded FDBs
In reply to Jiri PirkoFrom: Arkadi Sharshevsky <[email protected]>
Distinguish between externally learned vs offloaded FDBs. This is done in order to indicate that FDBs added by software was successfully offloaded.
--- bridge/fdb.c | 6 ++++++ include/linux/neighbour.h | 1 + 2 files changed, 7 insertions(+)
bridge/fdb.c +6 -0
@@ -262,6 +262,10 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) }if (r->ndm_flags &NTF_EXT_LEARNED ) {start_json_fdb_flags_array (&fdb_flags); +jsonw_string (jw_global,"extern_learn" ); + } +if (r->ndm_flags &NTF_OFFLOADED ) { +start_json_fdb_flags_array (&fdb_flags);jsonw_string (jw_global,"offload" ); }if (r->ndm_flags &NTF_MASTER )
@@ -280,6 +284,8 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)if (r->ndm_flags &NTF_ROUTER )fprintf (fp,"router " );if (r->ndm_flags &NTF_EXT_LEARNED ) +fprintf (fp,"extern_learn " ); +if (r->ndm_flags &NTF_OFFLOADED )fprintf (fp,"offload " );if (tb[NDA_MASTER ]) { fprintf(fp, "master %s ",
include/linux/neighbour.h +1 -0
@@ -41,6 +41,7 @@ enum {#define NTF_MASTER 0x04#define NTF_PROXY 0x08/* == ATF_PUBL */ #define NTF_EXT_LEARNED 0x10 +#define NTF_OFFLOADED 0x20#define NTF_ROUTER 0x80/*
Signature · 1 line
2.9.3
Re: [patch net-next 02/19] net: bridge: Add support for offloading port attributes
In reply to Jiri PirkoQuoted 11 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
Currently the flood, learning and
learning_syncport attributes are offloaded by setting the SELF flag. Add support for offloading the flood and learning attribute through the bridge code. In case of setting an unsupported flag on a offloded port the operation will fail.The
learning_syncattribute doesn't have any software representation and cannot be offloaded through the bridge code.
Quoted 8 lines
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- net/bridge/br_netlink.c | 112 +++++++++++++++++++++++++++++++++++++++--------- net/bridge/br_private.h | 4 ++ 2 files changed, 96 insertions(+), 20 deletions(-)
Hi Arkadi,
A few comments below
Quoted 54 lines
net/bridge/br_netlink.c +30
-8@@ -17,6 +17,7 @@#include <net/net_namespace.h> #include <net/sock.h> #include <uapi/linux/if_bridge.h> +#include <net/switchdev.h> #include "br_private.h" #include "br_private_stp.h" @@ -662,16 +663,52 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state) }/* Set/clear or port flags based on attribute */ -static void br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], -int attrtype,unsigned long mask) +static int br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], +int attrtype,unsigned long mask) { -if (tb[attrtype]) { -u8 flag =nla_get_u8 (tb[attrtype]); -if (flag) - p->flags |= mask; -else - p->flags &= ~mask; +struct switchdev_attr attr = { + .orig_dev = p->dev, + .id =SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT , + }; +unsigned long flags; +int err; + +if (!tb[attrtype]) +return 0 ; + +if (nla_get_u8 (tb[attrtype])) + flags = p->flags | mask; +else + flags = p->flags & ~mask; + +if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD ) + goto out; + + err =switchdev_port_attr_get (p->dev, &attr); +if (err == -EOPNOTSUPP ) + goto out; +if (err) +return err; + +/* Check if specific bridge flag attribute offload is supported */ +if (!(attr.u.brport_flags_support & mask)) { + br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",
net/bridge/br_netlink.c static int br_set_port_state(struct net_bridge_port *p, u8 state) · line 705
Quoted 10 lines
net/bridge/br_netlink.c +10
-0+ (unsigned int)p->port_no, p->dev->name); +return -EOPNOTSUPP ; + } + + 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) { + br_warn(p->br, "error setting offload FLAG on port %u(%s)\n",
Why all caps (FLAG) ?
net/bridge/br_netlink.c static int br_set_port_state(struct net_bridge_port *p, u8 state) · line 708
Quoted 3 lines
net/bridge/br_netlink.c +2
-0+ (unsigned int)p->port_no, p->dev->name); +return err; }
I think all of this switchdev-specific code should be contained into br_switchdev.c and exported via some function. Anyone changing only the bridge can easily get confused.
Quoted 90 lines
net/bridge/br_netlink.c +50
-12+out: + p->flags = flags; +return 0 ; }/* Process bridge protocol info on port */ @@ -681,20 +718,55 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])bool br_vlan_tunnel_old = false;int err; -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 ); + 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; -br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); + err =br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); +if (err) +return err; +if (br_vlan_tunnel_old && !(p->flags &BR_VLAN_TUNNEL ))nbp_vlan_tunnel_info_flush (p);net/bridge/br_private.h +4
-0@@ -42,6 +42,10 @@/* Path to usermode spanning tree program */ #define BR_STP_PROG "/sbin/bridge-stp" +/* Flags that can be offloaded to hardware */ +#define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \ + BR_MCAST_FLOOD | BR_BCAST_FLOOD) +typedef struct bridge_id bridge_id ;typedef struct mac_addr mac_addr ;typedef __u16 port_id ;
Re: [patch net-next 05/19] net: bridge: Add support for notifying devices about FDB add/del
In reply to Jiri PirkoQuoted 114 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
Currently the bridge doesn't notify the underlying devices about new FDBs learned. The FDB sync is placed on the switchdev notifier chain because devices may potentially learn FDB that are not directly related to their ports, for example:
1. Mixed SW/HW bridge - FDBs that point to the ASICs external devices should be offloaded as CPU traps in order to perform forwarding in slow path.
2. EVPN - Externally learned FDBs for the vtep device.Notification is sent only about static FDB add/del. This is done due to fact that currently this is the only scenario supported by switch drivers.
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +- drivers/net/ethernet/rocker/rocker_ofdpa.c | 4 ++-- include/net/switchdev.h | 6 ++++-- net/bridge/br.c | 4 ++-- net/bridge/br_fdb.c | 22 ++++++++++++++++++++++ net/bridge/br_private.h | 8 ++++++++ net/bridge/br_switchdev.c | 13 +++++++++++++ 7 files changed, 52 insertions(+), 7 deletions(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1@@ -1867,7 +1867,7 @@ static void mlxsw_sp_fdb_call_notifiers(bool learning_sync, bool adding,if (learning_sync) { info.addr = mac; info.vid = vid; - notifier_type = adding ?SWITCHDEV_FDB_ADD :SWITCHDEV_FDB_DEL ; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ;call_switchdev_notifiers (notifier_type, dev, &info.info); } }drivers/net/ethernet/rocker/rocker_ofdpa.c +2
-2@@ -1939,10 +1939,10 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)rtnl_lock ();if (learned && removing) -call_switchdev_notifiers (SWITCHDEV_FDB_DEL , +call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , lw->ofdpa_port->dev, &info.info);else if (learned && !removing) -call_switchdev_notifiers (SWITCHDEV_FDB_ADD , +call_switchdev_notifiers (SWITCHDEV_FDB_ADD_TO_BRIDGE , lw->ofdpa_port->dev, &info.info);rtnl_unlock ();include/net/switchdev.h +4
-2@@ -155,8 +155,10 @@ struct switchdev_ops { };enum switchdev_notifier_type { -SWITCHDEV_FDB_ADD =1 , -SWITCHDEV_FDB_DEL , +SWITCHDEV_FDB_ADD_TO_BRIDGE =1 , +SWITCHDEV_FDB_DEL_TO_BRIDGE , +SWITCHDEV_FDB_ADD_TO_DEVICE , +SWITCHDEV_FDB_DEL_TO_DEVICE , };struct switchdev_notifier_info {net/bridge/br.c +2
-2@@ -138,14 +138,14 @@ static int br_switchdev_event(struct notifier_block *unused, br = p->br;switch (event) { -case SWITCHDEV_FDB_ADD : +case SWITCHDEV_FDB_ADD_TO_BRIDGE : fdb_info = ptr; err =br_fdb_external_learn_add (br, p, fdb_info->addr, fdb_info->vid);if (err) err =notifier_from_errno (err);break ; -case SWITCHDEV_FDB_DEL : +case SWITCHDEV_FDB_DEL_TO_BRIDGE : fdb_info = ptr; err =br_fdb_external_learn_del (br, p, fdb_info->addr, fdb_info->vid);net/bridge/br_fdb.c +9
-0@@ -683,6 +683,26 @@ static inline size_t fdb_nlmsg_size(void) +nla_total_size (sizeof (struct nda_cacheinfo )); } +static void +fdb_notify_switchdev (const struct net_bridge_fdb_entry *fdb,int type) +{ +if (!fdb->added_by_user) +return ; + +switch (type) { +case RTM_DELNEIGH : + br_switchdev_fdb_call_notifiers(false, fdb->addr.addr,
net/bridge/br_fdb.c static inline size_t fdb_nlmsg_size(void) · line 704
Quoted 10 lines
net/bridge/br_fdb.c +10
-0+ fdb->vlan_id, + fdb->dst->dev); +break ; +case RTM_NEWNEIGH : +br_switchdev_fdb_call_notifiers (true, fdb->addr.addr, + fdb->vlan_id, + fdb->dst->dev); +break ; + } +}
Same comment here, this switchdev-specific logic can be contained in br_switchdev_fdb_call_notifiers().
Quoted 61 lines
net/bridge/br_fdb.c +3
-0+static void fdb_notify (struct net_bridge *br,const struct net_bridge_fdb_entry *fdb,int type) {@@ -690,6 +710,8 @@ static void fdb_notify(struct net_bridge *br,struct sk_buff *skb;int err = -ENOBUFS ; +fdb_notify_switchdev (fdb, type); + skb =nlmsg_new (fdb_nlmsg_size (),GFP_ATOMIC );if (skb ==NULL ) goto errout;net/bridge/br_private.h +8
-0@@ -1086,6 +1086,8 @@ void nbp_switchdev_frame_mark(const struct net_bridge_port *p, struct sk_buff *skb);bool nbp_switchdev_allowed_egress (const struct net_bridge_port *p,const struct sk_buff *skb); +void br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev);#else static inline int nbp_switchdev_mark_set (struct net_bridge_port *p) {@@ -1102,6 +1104,12 @@ static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, {return true; } + +static inline void +br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev) +{ +}#endif /* CONFIG_NET_SWITCHDEV */ #endif net/bridge/br_switchdev.c +13
-0@@ -55,3 +55,16 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,return !skb->offload_fwd_mark ||BR_INPUT_SKB_CB (skb)->offload_fwd_mark != p->offload_fwd_mark; } + +void +br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev) +{ +struct switchdev_notifier_fdb_info info; +unsigned long notifier_type; + + info.addr = mac; + info.vid = vid; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_DEVICE :SWITCHDEV_FDB_DEL_TO_DEVICE ; +call_switchdev_notifiers (notifier_type, dev, &info.info); +}
Re: [patch net-next 03/19] net: bridge: Add support for calling FDB external learning under rcu
In reply to Jiri PirkoQuoted 6 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
This is done as a preparation to moving the switchdev notifier chain to be atomic. The FDB external learning should be called under rtnl or rcu.
Quoted 9 lines
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- net/bridge/br.c | 4 ++-- net/bridge/br_fdb.c | 2 -- net/bridge/br_private.h | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-)
Re: [patch net-next 06/19] net: bridge: Receive notification about successful FDB offload
In reply to Jiri PirkoQuoted 14 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
When a new static FDB is added to the bridge a notification is sent to the driver for offload. In case of successful offload the driver should notify the bridge back, which in turn should mark the FDB as offloaded.
Currently, externally learned is equivalent for being offloaded which is not correct due to the fact that FDBs which are added from user-space are also marked as externally learned. In order to specify if an FDB was successfully offloaded a new flag is introduced.
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Quoted 8 lines
--- include/net/switchdev.h | 1 + include/uapi/linux/neighbour.h | 1 + net/bridge/br.c | 11 ++++++++++- net/bridge/br_fdb.c | 22 +++++++++++++++++++++- net/bridge/br_private.h | 5 ++++- 5 files changed, 37 insertions(+), 3 deletions(-)
Overall the patch looks good to me, one thing to note is that there's a race window between the call to br_fdb_external_learn_add() and br_fdb_offloaded_set() where a sw port can take over the entry (and thus set added_by_external_learn = 0) but have br_fdb_offloaded_set() set its offloaded flag to 1. Now I know the bridge generally has these known race conditions between fdb flag manipulations so just wanted to mention it.
Re: [patch net-next 04/19] net: switchdev: Change notifier chain to be atomic
In reply to Jiri PirkoQuoted 75 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
In order to use the switchdev notifier chain for FDB sync with the device it has to be changed to atomic. The is done because the bridge can learn new FDBs in atomic context.
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- net/switchdev/switchdev.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)net/switchdev/switchdev.c +5
-21@@ -571,24 +571,17 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj, }EXPORT_SYMBOL_GPL (switchdev_port_obj_dump); -static RAW_NOTIFIER_HEAD (switchdev_notif_chain); +static ATOMIC_NOTIFIER_HEAD (switchdev_notif_chain);/** * register_switchdev_notifier - Register notifier * @nb: notifier_block * -* Register switch device notifier. This should be used by code -* which needs to monitor events happening in particular device. -* Return values are same as for atomic_notifier_chain_register(). +* Register switch device notifier. */ int register_switchdev_notifier (struct notifier_block *nb) { -int err; - -rtnl_lock (); - err =raw_notifier_chain_register (&switchdev_notif_chain, nb); -rtnl_unlock (); -return err; +return atomic_notifier_chain_register (&switchdev_notif_chain, nb); }EXPORT_SYMBOL_GPL (register_switchdev_notifier);@@ -597,16 +590,10 @@ EXPORT_SYMBOL_GPL(register_switchdev_notifier);* @nb: notifier_block * * Unregister switch device notifier. -* Return values are same as for atomic_notifier_chain_unregister(). */ int unregister_switchdev_notifier (struct notifier_block *nb) { -int err; - -rtnl_lock (); - err =raw_notifier_chain_unregister (&switchdev_notif_chain, nb); -rtnl_unlock (); -return err; +return atomic_notifier_chain_unregister (&switchdev_notif_chain, nb); }EXPORT_SYMBOL_GPL (unregister_switchdev_notifier);@@ -616,18 +603,13 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);* @dev: port device * @info: notifier information data * -* Call all network notifier blocks. This should be called by driver -* when it needs to propagate hardware event. -* Return values are same as for atomic_notifier_call_chain(). -* rtnl_lock must be held. +* Call all network notifier blocks. */ int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
net/switchdev/switchdev.c EXPORT_SYMBOL_GPL(unregister_switchdev_notifier); · line 615
Quoted 10 lines
net/switchdev/switchdev.c +1
-3struct switchdev_notifier_info *info) { -ASSERT_RTNL (); - info->dev = dev; -return raw_notifier_call_chain (&switchdev_notif_chain, val, info); +return atomic_notifier_call_chain (&switchdev_notif_chain, val, info); }EXPORT_SYMBOL_GPL (call_switchdev_notifiers);
Re: [patch net-next 01/19] net: switchdev: Add support for querying supported bridge flags by hardware
In reply to Jiri PirkoQuoted 32 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
This is done as a preparation stage before setting the bridge port flags from the bridge code. Currently the device can be queried for the bridge flags state, but the querier cannot distinguish if the flag is disabled or if it is not supported at all. Thus, add new attr and a bit-mask which include information regarding the support on a per-flag basis.
Drivers that support bridge offload but not support bridge flags should return zeroed bitmask.
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- include/net/switchdev.h | 2 ++ 1 file changed, 2 insertions(+)include/net/switchdev.h +1
-0@@ -46,6 +46,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_PORT_PARENT_ID ,SWITCHDEV_ATTR_ID_PORT_STP_STATE ,SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS , +SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT ,SWITCHDEV_ATTR_ID_PORT_MROUTER ,SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME , SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,
include/net/switchdev.h struct switchdev_attr { · line 69
Quoted 7 lines
include/net/switchdev.h +1
-0@@ -62,6 +63,7 @@ struct switchdev_attr {struct netdev_phys_item_id ppid;/* PORT_PARENT_ID */ u8 stp_state;/* PORT_STP_STATE */ unsigned long brport_flags;/* PORT_BRIDGE_FLAGS */ +unsigned long brport_flags_support;/* PORT_BRIDGE_FLAGS_SUPPORT */ bool mrouter;/* PORT_MROUTER */ clock_t ageing_time;/* BRIDGE_AGEING_TIME */ bool vlan_filtering;/* BRIDGE_VLAN_FILTERING */
Re: [patch net-next 02/19] net: bridge: Add support for offloading port attributes
In reply to Nikolay AleksandrovQuoted 21 lines · Nikolay Aleksandrov
Quoted 11 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
Currently the flood, learning and
learning_syncport attributes are offloaded by setting the SELF flag. Add support for offloading the flood and learning attribute through the bridge code. In case of setting an unsupported flag on a offloded port the operation will fail.The
learning_syncattribute doesn't have any software representation and cannot be offloaded through the bridge code.Quoted 8 lines
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- net/bridge/br_netlink.c | 112 +++++++++++++++++++++++++++++++++++++++--------- net/bridge/br_private.h | 4 ++ 2 files changed, 96 insertions(+), 20 deletions(-)
Quoted 3 lines
Hi Arkadi,
A few comments below
Hi Nikolay,
Thank you very much for the review, will fix.
Quoted 165 lines
Quoted 54 lines
net/bridge/br_netlink.c +30
-8@@ -17,6 +17,7 @@#include <net/net_namespace.h> #include <net/sock.h> #include <uapi/linux/if_bridge.h> +#include <net/switchdev.h> #include "br_private.h" #include "br_private_stp.h" @@ -662,16 +663,52 @@ static int br_set_port_state(struct net_bridge_port *p, u8 state) }/* Set/clear or port flags based on attribute */ -static void br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], -int attrtype,unsigned long mask) +static int br_set_port_flag (struct net_bridge_port *p,struct nlattr *tb[], +int attrtype,unsigned long mask) { -if (tb[attrtype]) { -u8 flag =nla_get_u8 (tb[attrtype]); -if (flag) - p->flags |= mask; -else - p->flags &= ~mask; +struct switchdev_attr attr = { + .orig_dev = p->dev, + .id =SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT , + }; +unsigned long flags; +int err; + +if (!tb[attrtype]) +return 0 ; + +if (nla_get_u8 (tb[attrtype])) + flags = p->flags | mask; +else + flags = p->flags & ~mask; + +if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD ) + goto out; + + err =switchdev_port_attr_get (p->dev, &attr); +if (err == -EOPNOTSUPP ) + goto out; +if (err) +return err; + +/* Check if specific bridge flag attribute offload is supported */ +if (!(attr.u.brport_flags_support & mask)) { + br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",net/bridge/br_netlink.c static int br_set_port_state(struct net_bridge_port *p, u8 state) · line 705
Quoted 10 lines
net/bridge/br_netlink.c +10
-0+ (unsigned int)p->port_no, p->dev->name); +return -EOPNOTSUPP ; + } + + 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) { + br_warn(p->br, "error setting offload FLAG on port %u(%s)\n",Why all caps (FLAG) ?
net/bridge/br_netlink.c static int br_set_port_state(struct net_bridge_port *p, u8 state) · line 708
Quoted 3 lines
net/bridge/br_netlink.c +2
-0+ (unsigned int)p->port_no, p->dev->name); +return err; }I think all of this switchdev-specific code should be contained into
br_switchdev.cand exported via some function. Anyone changing only the bridge can easily get confused.Quoted 90 lines
net/bridge/br_netlink.c +50
-12+out: + p->flags = flags; +return 0 ; }/* Process bridge protocol info on port */ @@ -681,20 +718,55 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])bool br_vlan_tunnel_old = false;int err; -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 ); + 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; -br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); + err =br_set_port_flag (p, tb,IFLA_BRPORT_VLAN_TUNNEL ,BR_VLAN_TUNNEL ); +if (err) +return err; +if (br_vlan_tunnel_old && !(p->flags &BR_VLAN_TUNNEL ))nbp_vlan_tunnel_info_flush (p);net/bridge/br_private.h +4
-0@@ -42,6 +42,10 @@/* Path to usermode spanning tree program */ #define BR_STP_PROG "/sbin/bridge-stp" +/* Flags that can be offloaded to hardware */ +#define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \ + BR_MCAST_FLOOD | BR_BCAST_FLOOD) +typedef struct bridge_id bridge_id ;typedef struct mac_addr mac_addr ;typedef __u16 port_id ;
Re: [patch net-next 05/19] net: bridge: Add support for notifying devices about FDB add/del
In reply to Nikolay AleksandrovQuoted 120 lines · Nikolay Aleksandrov
Quoted 119 lines · Jiri Pirko
From: Arkadi Sharshevsky <[email protected]>
Currently the bridge doesn't notify the underlying devices about new FDBs learned. The FDB sync is placed on the switchdev notifier chain because devices may potentially learn FDB that are not directly related to their ports, for example:
1. Mixed SW/HW bridge - FDBs that point to the ASICs external devices should be offloaded as CPU traps in order to perform forwarding in slow path.
2. EVPN - Externally learned FDBs for the vtep device.Notification is sent only about static FDB add/del. This is done due to fact that currently this is the only scenario supported by switch drivers.
Signed-off-by Arkadi Sharshevsky <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Jiri Pirko <[email protected]>--- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +- drivers/net/ethernet/rocker/rocker_ofdpa.c | 4 ++-- include/net/switchdev.h | 6 ++++-- net/bridge/br.c | 4 ++-- net/bridge/br_fdb.c | 22 ++++++++++++++++++++++ net/bridge/br_private.h | 8 ++++++++ net/bridge/br_switchdev.c | 13 +++++++++++++ 7 files changed, 52 insertions(+), 7 deletions(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1
-1@@ -1867,7 +1867,7 @@ static void mlxsw_sp_fdb_call_notifiers(bool learning_sync, bool adding,if (learning_sync) { info.addr = mac; info.vid = vid; - notifier_type = adding ?SWITCHDEV_FDB_ADD :SWITCHDEV_FDB_DEL ; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_BRIDGE :SWITCHDEV_FDB_DEL_TO_BRIDGE ;call_switchdev_notifiers (notifier_type, dev, &info.info); } }drivers/net/ethernet/rocker/rocker_ofdpa.c +2
-2@@ -1939,10 +1939,10 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)rtnl_lock ();if (learned && removing) -call_switchdev_notifiers (SWITCHDEV_FDB_DEL , +call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , lw->ofdpa_port->dev, &info.info);else if (learned && !removing) -call_switchdev_notifiers (SWITCHDEV_FDB_ADD , +call_switchdev_notifiers (SWITCHDEV_FDB_ADD_TO_BRIDGE , lw->ofdpa_port->dev, &info.info);rtnl_unlock ();include/net/switchdev.h +4
-2@@ -155,8 +155,10 @@ struct switchdev_ops { };enum switchdev_notifier_type { -SWITCHDEV_FDB_ADD =1 , -SWITCHDEV_FDB_DEL , +SWITCHDEV_FDB_ADD_TO_BRIDGE =1 , +SWITCHDEV_FDB_DEL_TO_BRIDGE , +SWITCHDEV_FDB_ADD_TO_DEVICE , +SWITCHDEV_FDB_DEL_TO_DEVICE , };struct switchdev_notifier_info {net/bridge/br.c +2
-2@@ -138,14 +138,14 @@ static int br_switchdev_event(struct notifier_block *unused, br = p->br;switch (event) { -case SWITCHDEV_FDB_ADD : +case SWITCHDEV_FDB_ADD_TO_BRIDGE : fdb_info = ptr; err =br_fdb_external_learn_add (br, p, fdb_info->addr, fdb_info->vid);if (err) err =notifier_from_errno (err);break ; -case SWITCHDEV_FDB_DEL : +case SWITCHDEV_FDB_DEL_TO_BRIDGE : fdb_info = ptr; err =br_fdb_external_learn_del (br, p, fdb_info->addr, fdb_info->vid);net/bridge/br_fdb.c +14
-0@@ -683,6 +683,26 @@ static inline size_t fdb_nlmsg_size(void) +nla_total_size (sizeof (struct nda_cacheinfo )); } +static void +fdb_notify_switchdev (const struct net_bridge_fdb_entry *fdb,int type) +{ +if (!fdb->added_by_user) +return ; + +switch (type) { +case RTM_DELNEIGH : +br_switchdev_fdb_call_notifiers (false, fdb->addr.addr, + fdb->vlan_id, + fdb->dst->dev); +break ; +case RTM_NEWNEIGH : + br_switchdev_fdb_call_notifiers(true, fdb->addr.addr,
Quoted 9 lines
net/bridge/br_fdb.c static inline size_t fdb_nlmsg_size(void) · line 704
Quoted 5 lines
net/bridge/br_fdb.c +5
-0+ fdb->vlan_id, + fdb->dst->dev); +break ; + } +}Same comment here, this switchdev-specific logic can be contained in
br_switchdev_fdb_call_notifiers().
Thanks, will move it to br_switchdev.c.
Quoted 62 lines
Quoted 61 lines
net/bridge/br_fdb.c +3
-0+static void fdb_notify (struct net_bridge *br,const struct net_bridge_fdb_entry *fdb,int type) {@@ -690,6 +710,8 @@ static void fdb_notify(struct net_bridge *br,struct sk_buff *skb;int err = -ENOBUFS ; +fdb_notify_switchdev (fdb, type); + skb =nlmsg_new (fdb_nlmsg_size (),GFP_ATOMIC );if (skb ==NULL ) goto errout;net/bridge/br_private.h +8
-0@@ -1086,6 +1086,8 @@ void nbp_switchdev_frame_mark(const struct net_bridge_port *p, struct sk_buff *skb);bool nbp_switchdev_allowed_egress (const struct net_bridge_port *p,const struct sk_buff *skb); +void br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev);#else static inline int nbp_switchdev_mark_set (struct net_bridge_port *p) {@@ -1102,6 +1104,12 @@ static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, {return true; } + +static inline void +br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev) +{ +}#endif /* CONFIG_NET_SWITCHDEV */ #endif net/bridge/br_switchdev.c +13
-0@@ -55,3 +55,16 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,return !skb->offload_fwd_mark ||BR_INPUT_SKB_CB (skb)->offload_fwd_mark != p->offload_fwd_mark; } + +void +br_switchdev_fdb_call_notifiers (bool adding,const unsigned char *mac, +u16 vid,struct net_device *dev) +{ +struct switchdev_notifier_fdb_info info; +unsigned long notifier_type; + + info.addr = mac; + info.vid = vid; + notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_DEVICE :SWITCHDEV_FDB_DEL_TO_DEVICE ; +call_switchdev_notifiers (notifier_type, dev, &info.info); +}
Stephen Hemminger
AppliedRe: [patch iproute2] bridge: Distinguish between externally learned vs offloaded FDBs
In reply to Jiri PirkoQuoted 8 lines · On Mon, 5 Jun 2017 12:07:05 +0200 Jiri Pirko <[email protected]> wrote:
From: Arkadi Sharshevsky <[email protected]>
Distinguish between externally learned vs offloaded FDBs. This is done in order to indicate that FDBs added by software was successfully offloaded.
Signed-off-by Arkadi Sharshevsky <[email protected]>Signed-off-by Jiri Pirko <[email protected]>
Applied to net-next