summaryrefslogtreecommitdiffstats
path: root/net/dsa/switch.c
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-05-19 17:00:53 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-22 19:37:32 -0400
commit685fb6a40ddace10a0bc8a680ab6ba65c6cdfdaf (patch)
tree258dc0f599d0e3ae686ce59ba7c5b84655328a7b /net/dsa/switch.c
parent1faabf7440f17999f41973e91878c13ad9f080b2 (diff)
net: dsa: add FDB notifier
Add two new DSA_NOTIFIER_FDB_ADD and DSA_NOTIFIER_FDB_DEL events to notify not only a single switch, but all switches of a the fabric when an FDB entry is added or removed. For the moment, keep the current behavior and ignore other switches. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/switch.c')
-rw-r--r--net/dsa/switch.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 540770ecc8b0..e71cc860d32c 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -84,6 +84,43 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
84 return 0; 84 return 0;
85} 85}
86 86
87static int dsa_switch_fdb_add(struct dsa_switch *ds,
88 struct dsa_notifier_fdb_info *info)
89{
90 const struct switchdev_obj_port_fdb *fdb = info->fdb;
91 struct switchdev_trans *trans = info->trans;
92
93 /* Do not care yet about other switch chips of the fabric */
94 if (ds->index != info->sw_index)
95 return 0;
96
97 if (switchdev_trans_ph_prepare(trans)) {
98 if (!ds->ops->port_fdb_prepare || !ds->ops->port_fdb_add)
99 return -EOPNOTSUPP;
100
101 return ds->ops->port_fdb_prepare(ds, info->port, fdb, trans);
102 }
103
104 ds->ops->port_fdb_add(ds, info->port, fdb, trans);
105
106 return 0;
107}
108
109static int dsa_switch_fdb_del(struct dsa_switch *ds,
110 struct dsa_notifier_fdb_info *info)
111{
112 const struct switchdev_obj_port_fdb *fdb = info->fdb;
113
114 /* Do not care yet about other switch chips of the fabric */
115 if (ds->index != info->sw_index)
116 return 0;
117
118 if (!ds->ops->port_fdb_del)
119 return -EOPNOTSUPP;
120
121 return ds->ops->port_fdb_del(ds, info->port, fdb);
122}
123
87static int dsa_switch_event(struct notifier_block *nb, 124static int dsa_switch_event(struct notifier_block *nb,
88 unsigned long event, void *info) 125 unsigned long event, void *info)
89{ 126{
@@ -100,6 +137,12 @@ static int dsa_switch_event(struct notifier_block *nb,
100 case DSA_NOTIFIER_BRIDGE_LEAVE: 137 case DSA_NOTIFIER_BRIDGE_LEAVE:
101 err = dsa_switch_bridge_leave(ds, info); 138 err = dsa_switch_bridge_leave(ds, info);
102 break; 139 break;
140 case DSA_NOTIFIER_FDB_ADD:
141 err = dsa_switch_fdb_add(ds, info);
142 break;
143 case DSA_NOTIFIER_FDB_DEL:
144 err = dsa_switch_fdb_del(ds, info);
145 break;
103 default: 146 default:
104 err = -EOPNOTSUPP; 147 err = -EOPNOTSUPP;
105 break; 148 break;