s390/qeth: Add bridge to switchdev LEARNING_SYNC
Subsystems (4)
cover s390/qeth: Add bridge to switchdev LEARNING_SYNC
Please apply the following patch series for qeth to netdev's net-next tree.
The netlink bridgeport attribute LEARNING_SYNC can be used to enable qeth interfaces to report MAC addresses that are reachable via this qeth interface to the attached software bridge via switchdev notifiers SWITCHDEV_FDB_ADD_TO_BRIDGE and SWITCHDEV_FDB_DEL_TO_BRIDGE.
Extend this support of LEARNING_SYNC to the bridge to switchdev notifiers SWITCHDEV_FDB_ADD_TO_DEVICE and SWITCHDEV_FDB_DEL_TO_DEVICE.
Add the capability to sync MAC addresses that are learned by a north-facing, non-isolated bridgeport of a software bridge to south-facing, isolated bridgeports. This enables the software bridge to influence south to north traffic steering in hardware.
Alexandra Winter (3):
s390/qeth: Register switchdev event handler
s390/qeth: Switchdev event handler
s390/qeth: Update MACs of LEARNING_SYNC device
drivers/s390/net/Kconfig | 1 + drivers/s390/net/qeth_l2_main.c | 239 +++++++++++++++++++++++++++++++- 2 files changed, 237 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 s390/qeth: Register switchdev event handler
From: Alexandra Winter <[email protected]>
Conditionally register a qeth_l2 switchdev_event handler to handle bridge to device switchdev events, when at least one qeth interface has the bridgeport attribute LEARNING_SYNC enabled.
--- drivers/s390/net/qeth_l2_main.c | 43 ++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-)
drivers/s390/net/qeth_l2_main.c +40 -3
@@ -717,6 +717,31 @@ static int qeth_l2_dev2br_an_set(struct qeth_card *card, bool enable)return rc; } +static refcount_t qeth_l2_switchdev_notify_refcnt; + +/* Called under rtnl_lock */ +static void qeth_l2_br2dev_get (void ) +{ +if (!refcount_inc_not_zero (&qeth_l2_switchdev_notify_refcnt)) { +/* tbd: register_switchdev_notifier(&qeth_l2_sw_notifier); */ +refcount_set (&qeth_l2_switchdev_notify_refcnt,1 ); +QETH_DBF_MESSAGE (2 ,"qeth_l2_sw_notifier registered\n" ); + } +QETH_DBF_TEXT_ (SETUP ,2 ,"b2d+%04d" , + qeth_l2_switchdev_notify_refcnt.refs.counter); +} + +/* Called under rtnl_lock */ +static void qeth_l2_br2dev_put (void ) +{ +if (refcount_dec_and_test (&qeth_l2_switchdev_notify_refcnt)) { +/* tbd: unregister_switchdev_notifier(&qeth_l2_sw_notifier); */ +QETH_DBF_MESSAGE (2 ,"qeth_l2_sw_notifier unregistered\n" ); + } +QETH_DBF_TEXT_ (SETUP ,2 ,"b2d-%04d" , + qeth_l2_switchdev_notify_refcnt.refs.counter); +} +static int qeth_l2_bridge_getlink (struct sk_buff *skb,u32 pid,u32 seq,struct net_device *dev,u32 filter_mask,int nlflags)
@@ -810,16 +835,19 @@ static int qeth_l2_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, }else if (enable) {qeth_l2_set_pnso_mode (card,QETH_PNSO_ADDR_INFO ); rc =qeth_l2_dev2br_an_set (card, true); -if (rc) +if (rc) {qeth_l2_set_pnso_mode (card,QETH_PNSO_NONE ); -else + }else { priv->brport_features |=BR_LEARNING_SYNC ; +qeth_l2_br2dev_get (); + } }else { rc =qeth_l2_dev2br_an_set (card, false);if (!rc) {qeth_l2_set_pnso_mode (card,QETH_PNSO_NONE ); priv->brport_features ^=BR_LEARNING_SYNC ;qeth_l2_dev2br_fdb_flush (card); +qeth_l2_br2dev_put (); } }mutex_unlock (&card->sbp_lock);
@@ -2072,6 +2100,7 @@ static int qeth_l2_probe_device(struct ccwgroup_device *gdev)static void qeth_l2_remove_device (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev); +struct qeth_priv *priv;if (gdev->dev.type != &qeth_l2_devtype)device_remove_groups (&gdev->dev, qeth_l2_attr_groups);
@@ -2083,8 +2112,15 @@ static void qeth_l2_remove_device(struct ccwgroup_device *gdev)qeth_set_offline (card, card->discipline, false);cancel_work_sync (&card->close_dev_work); -if (card->dev->reg_state ==NETREG_REGISTERED ) +if (card->dev->reg_state ==NETREG_REGISTERED ) { + priv =netdev_priv (card->dev); +if (priv->brport_features &BR_LEARNING_SYNC ) { +rtnl_lock (); +qeth_l2_br2dev_put (); +rtnl_unlock (); + }unregister_netdev (card->dev); + } }static int qeth_l2_set_online (struct qeth_card *card,bool carrier_ok)
@@ -2207,6 +2243,7 @@ EXPORT_SYMBOL_GPL(qeth_l2_discipline);static int __init qeth_l2_init (void ) {pr_info ("register layer 2 discipline\n" ); +refcount_set (&qeth_l2_switchdev_notify_refcnt,0 );return 0 ; }
Signature · 1 line
2.25.1
PATCH 2/3 s390/qeth: Switchdev event handler
In reply to Karsten GraulFrom: Alexandra Winter <[email protected]>
QETH HiperSockets devices with LEARNING_SYNC capability can be used to construct a linux bridge with:
2 isolated southbound interfaces:
a) a default network interface
b) a LEARNING-SYNC HiperSockets interface
and 1 non-isolated northbound interface. This is called a 'HiperSockets Converged Interface' (HSCI).
The existing LEARNING_SYNC functionality is used to update the bridge fdb with MAC addresses that should be sent-out via the HiperSockets interface, instead of the default network interface.
Add handling of switchdev events SWITCHDEV_FDB_ADD_TO_DEVICE and SWITCHDEV_FDB_DEL_TO_DEVICE to the qeth LEARNING_SYNC functionality. Thus if the northbound bridgeport of an HSCI doesn't only have a single static MAC address, but instead is a learning bridgeport, work is enqueued, so the HiperSockets virtual switch (that is external to this Linux instance) can update its fdb.
When BRIDGE is a loadable module, QETH_L2 mustn't be built-in:
drivers/s390/net/qeth_l2_main.o: in function 'qeth_l2_switchdev_event':drivers/s390/net/qeth_l2_main.c:927: undefined reference to 'br_port_flag_is_set'
Add Kconfig dependency to enforce usable configurations.
--- drivers/s390/net/Kconfig | 1 + drivers/s390/net/qeth_l2_main.c | 83 +++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 5 deletions(-)
drivers/s390/net/Kconfig +1 -0
@@ -74,6 +74,7 @@ config QETH_L2 def_tristate y prompt "qeth layer 2 device support" depends on QETH + depends on BRIDGE || BRIDGE=n help Select this option to be able to run qeth devices in layer 2 mode. To compile as a module, choose M. The module name is qeth_l2.
drivers/s390/net/qeth_l2_main.c +78 -5
102 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/3 s390/qeth: Update MACs of LEARNING_SYNC device
In reply to Karsten GraulFrom: Alexandra Winter <[email protected]>
Update the MAC addresses that are registered with a LEARNING_SYNC qeth device with the events announced by the attached software bridge.
Typically the LEARNING_SYNC qeth bridge port has an isolated sibling (the default interface of an 'HiperSockets Converged Interface' (HSCI)). Update the MACs of isolated siblings as well, to avoid unnecessary flooding in the attached virtualized switches.
--- drivers/s390/net/qeth_l2_main.c | 131 +++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 4 deletions(-)
drivers/s390/net/qeth_l2_main.c +127 -4
@@ -717,6 +717,15 @@ static int qeth_l2_dev2br_an_set(struct qeth_card *card, bool enable)return rc; } +struct qeth_l2_br2dev_event_work { +struct work_struct work; +struct net_device *br_dev; +struct net_device *lsync_dev; +struct net_device *dst_dev; +unsigned long event; +unsigned char addr[ETH_ALEN ]; +}; +static const struct net_device_ops qeth_l2_netdev_ops; static bool qeth_l2_must_learn(struct net_device *netdev,
@@ -732,6 +741,116 @@ static bool qeth_l2_must_learn(struct net_device *netdev, netdev->netdev_ops == &qeth_l2_netdev_ops); } +/** +* qeth_l2_br2dev_worker() - update local MACs +* @work: bridge to device FDB update +* +* Update local MACs of a learning_sync bridgeport so it can receive +* messages for a destination port. +* In case of an isolated learning_sync port, also update its isolated +* siblings. +*/ +static void qeth_l2_br2dev_worker (struct work_struct *work) +{ +struct qeth_l2_br2dev_event_work *br2dev_event_work = + container_of(work, struct qeth_l2_br2dev_event_work, work); +struct net_device *lsyncdev = br2dev_event_work->lsync_dev; +struct net_device *dstdev = br2dev_event_work->dst_dev; +struct net_device *brdev = br2dev_event_work->br_dev; +unsigned long event = br2dev_event_work->event; +unsigned char *addr = br2dev_event_work->addr; +struct qeth_card *card = lsyncdev->ml_priv; +struct net_device *lowerdev; +struct list_head *iter; +int err =0 ; + +kfree (br2dev_event_work); +QETH_CARD_TEXT_ (card,4 ,"b2dw%04x" , event); +QETH_CARD_TEXT_ (card,4 ,"ma%012lx" ,ether_addr_to_u64 (addr)); + +rcu_read_lock (); +/* Verify preconditions are still valid: */ +if (!netif_is_bridge_port (lsyncdev) || + brdev !=netdev_master_upper_dev_get_rcu (lsyncdev)) + goto unlock; +if (!qeth_l2_must_learn (lsyncdev, dstdev)) + goto unlock; + +if (br_port_flag_is_set (lsyncdev,BR_ISOLATED )) { +/* Update lsyncdev and its isolated sibling(s): */ + iter = &brdev->adj_list.lower; + lowerdev =netdev_next_lower_dev_rcu (brdev, &iter); +while (lowerdev) { +if (br_port_flag_is_set (lowerdev,BR_ISOLATED )) { +switch (event) { +case SWITCHDEV_FDB_ADD_TO_DEVICE : + err =dev_uc_add (lowerdev, addr); +break ; +case SWITCHDEV_FDB_DEL_TO_DEVICE : + err =dev_uc_del (lowerdev, addr); +break ; +default : +break ; + } +if (err) { +QETH_CARD_TEXT (card,2 ,"b2derris" ); +QETH_CARD_TEXT_ (card,2 , +"err%02x%03d" , event, + lowerdev->ifindex); + } + } + lowerdev =netdev_next_lower_dev_rcu (brdev, &iter); + } + }else { +switch (event) { +case SWITCHDEV_FDB_ADD_TO_DEVICE : + err =dev_uc_add (lsyncdev, addr); +break ; +case SWITCHDEV_FDB_DEL_TO_DEVICE : + err =dev_uc_del (lsyncdev, addr); +break ; +default : +break ; + } +if (err) +QETH_CARD_TEXT_ (card,2 ,"b2derr%02x" , event); + } + +unlock: +rcu_read_unlock (); +dev_put (brdev); +dev_put (lsyncdev); +dev_put (dstdev); +} + +static int qeth_l2_br2dev_queue_work (struct net_device *brdev, +struct net_device *lsyncdev, +struct net_device *dstdev, +unsigned long event, +const unsigned char *addr) +{ +struct qeth_l2_br2dev_event_work *worker_data; +struct qeth_card *card; + + worker_data =kzalloc (sizeof (*worker_data),GFP_ATOMIC ); +if (!worker_data) +return -ENOMEM ; +INIT_WORK (&worker_data->work, qeth_l2_br2dev_worker); + worker_data->br_dev = brdev; + worker_data->lsync_dev = lsyncdev; + worker_data->dst_dev = dstdev; + worker_data->event = event; +ether_addr_copy (worker_data->addr, addr); + + card = lsyncdev->ml_priv; +/* Take a reference on the sw port devices and the bridge */ +dev_hold (brdev); +dev_hold (lsyncdev); +dev_hold (dstdev); +queue_work (card->event_wq, &worker_data->work); +return 0 ; +} +/* Called under rtnl_lock */ static int qeth_l2_switchdev_event (struct notifier_block *unused,unsigned long event,void *ptr)
@@ -741,6 +860,7 @@ static int qeth_l2_switchdev_event(struct notifier_block *unused,struct switchdev_notifier_info *info = ptr;struct list_head *iter;struct qeth_card *card; +int rc;if (!(event ==SWITCHDEV_FDB_ADD_TO_DEVICE || event ==SWITCHDEV_FDB_DEL_TO_DEVICE ))
@@ -759,10 +879,13 @@ static int qeth_l2_switchdev_event(struct notifier_block *unused,if (qeth_l2_must_learn (lowerdev, dstdev)) { card = lowerdev->ml_priv;QETH_CARD_TEXT_ (card,4 ,"b2dqw%03x" , event); -/* tbd: rc = qeth_l2_br2dev_queue_work(brdev, lowerdev, -* dstdev, event, -* fdb_info->addr); -*/ + rc =qeth_l2_br2dev_queue_work (brdev, lowerdev, + dstdev, event, + fdb_info->addr); +if (rc) { +QETH_CARD_TEXT (card,2 ,"b2dqwerr" ); +return NOTIFY_BAD ; + } } lowerdev =netdev_next_lower_dev_rcu (brdev, &iter); }
Signature · 1 line
2.25.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Fri, 6 Aug 2021 17:26:00 +0200 you wrote:
Please apply the following patch series for qeth to netdev's net-next tree.
The netlink bridgeport attribute
LEARNING_SYNCcan be used to enable qeth interfaces to report MAC addresses that are reachable via this qeth interface to the attached software bridge via switchdev notifiersSWITCHDEV_FDB_ADD_TO_BRIDGEandSWITCHDEV_FDB_DEL_TO_BRIDGE.[...]
Here is the summary with links:
- [net-next,1/3] s390/qeth: Register switchdev event handler
https://git.kernel.org/netdev/net-next/c/60bb1089467d - [net-next,2/3] s390/qeth: Switchdev event handler https://git.kernel.org/netdev/net-next/c/4e20e73e631a - [net-next,3/3] s390/qeth: Update MACs of LEARNING_SYNC device https://git.kernel.org/netdev/net-next/c/f7936b7b2663
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html