summaryrefslogtreecommitdiffstats
path: root/net/dsa/switch.c
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-02-03 13:20:21 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-06 16:53:29 -0500
commit04d3a4c6af52a58370795bc9f70dc15f51f8bb84 (patch)
tree07ed46ceedeb980d62da34ae26e3aac5f8af7dfb /net/dsa/switch.c
parentf515f192ab4f45bb695146b82432d63d98775787 (diff)
net: dsa: introduce bridge notifier
A slave device will now notify the switch fabric once its port is bridged or unbridged, instead of calling directly its switch operations. This code allows propagating cross-chip bridging events in the fabric. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/switch.c')
-rw-r--r--net/dsa/switch.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index e22fa7633d03..6456dacf9ae9 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -13,6 +13,32 @@
13#include <linux/notifier.h> 13#include <linux/notifier.h>
14#include <net/dsa.h> 14#include <net/dsa.h>
15 15
16static int dsa_switch_bridge_join(struct dsa_switch *ds,
17 struct dsa_notifier_bridge_info *info)
18{
19 if (ds->index == info->sw_index && ds->ops->port_bridge_join)
20 return ds->ops->port_bridge_join(ds, info->port, info->br);
21
22 if (ds->index != info->sw_index)
23 dev_dbg(ds->dev, "crosschip DSA port %d.%d bridged to %s\n",
24 info->sw_index, info->port, netdev_name(info->br));
25
26 return 0;
27}
28
29static int dsa_switch_bridge_leave(struct dsa_switch *ds,
30 struct dsa_notifier_bridge_info *info)
31{
32 if (ds->index == info->sw_index && ds->ops->port_bridge_leave)
33 ds->ops->port_bridge_leave(ds, info->port, info->br);
34
35 if (ds->index != info->sw_index)
36 dev_dbg(ds->dev, "crosschip DSA port %d.%d unbridged from %s\n",
37 info->sw_index, info->port, netdev_name(info->br));
38
39 return 0;
40}
41
16static int dsa_switch_event(struct notifier_block *nb, 42static int dsa_switch_event(struct notifier_block *nb,
17 unsigned long event, void *info) 43 unsigned long event, void *info)
18{ 44{
@@ -20,6 +46,12 @@ static int dsa_switch_event(struct notifier_block *nb,
20 int err; 46 int err;
21 47
22 switch (event) { 48 switch (event) {
49 case DSA_NOTIFIER_BRIDGE_JOIN:
50 err = dsa_switch_bridge_join(ds, info);
51 break;
52 case DSA_NOTIFIER_BRIDGE_LEAVE:
53 err = dsa_switch_bridge_leave(ds, info);
54 break;
23 default: 55 default:
24 err = -EOPNOTSUPP; 56 err = -EOPNOTSUPP;
25 break; 57 break;