summaryrefslogtreecommitdiffstats
path: root/net/dsa/switch.c
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-05-19 17:00:55 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-22 19:37:32 -0400
commitd0c627b8740ca6243054263fbc98981a36ac5618 (patch)
tree0ad7c85f4b512127fa93980bbd92ebb192fa145d /net/dsa/switch.c
parent8ae5bcdc5d98a99e59f194101e7acd2e9d055758 (diff)
net: dsa: add VLAN notifier
Add two new DSA_NOTIFIER_VLAN_ADD and DSA_NOTIFIER_VLAN_DEL events to notify not only a single switch, but all switches of a the fabric when an VLAN 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 b7e8e45869fc..c1e4b2d5a3ae 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -158,6 +158,43 @@ static int dsa_switch_mdb_del(struct dsa_switch *ds,
158 return ds->ops->port_mdb_del(ds, info->port, mdb); 158 return ds->ops->port_mdb_del(ds, info->port, mdb);
159} 159}
160 160
161static int dsa_switch_vlan_add(struct dsa_switch *ds,
162 struct dsa_notifier_vlan_info *info)
163{
164 const struct switchdev_obj_port_vlan *vlan = info->vlan;
165 struct switchdev_trans *trans = info->trans;
166
167 /* Do not care yet about other switch chips of the fabric */
168 if (ds->index != info->sw_index)
169 return 0;
170
171 if (switchdev_trans_ph_prepare(trans)) {
172 if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
173 return -EOPNOTSUPP;
174
175 return ds->ops->port_vlan_prepare(ds, info->port, vlan, trans);
176 }
177
178 ds->ops->port_vlan_add(ds, info->port, vlan, trans);
179
180 return 0;
181}
182
183static int dsa_switch_vlan_del(struct dsa_switch *ds,
184 struct dsa_notifier_vlan_info *info)
185{
186 const struct switchdev_obj_port_vlan *vlan = info->vlan;
187
188 /* Do not care yet about other switch chips of the fabric */
189 if (ds->index != info->sw_index)
190 return 0;
191
192 if (!ds->ops->port_vlan_del)
193 return -EOPNOTSUPP;
194
195 return ds->ops->port_vlan_del(ds, info->port, vlan);
196}
197
161static int dsa_switch_event(struct notifier_block *nb, 198static int dsa_switch_event(struct notifier_block *nb,
162 unsigned long event, void *info) 199 unsigned long event, void *info)
163{ 200{
@@ -186,6 +223,12 @@ static int dsa_switch_event(struct notifier_block *nb,
186 case DSA_NOTIFIER_MDB_DEL: 223 case DSA_NOTIFIER_MDB_DEL:
187 err = dsa_switch_mdb_del(ds, info); 224 err = dsa_switch_mdb_del(ds, info);
188 break; 225 break;
226 case DSA_NOTIFIER_VLAN_ADD:
227 err = dsa_switch_vlan_add(ds, info);
228 break;
229 case DSA_NOTIFIER_VLAN_DEL:
230 err = dsa_switch_vlan_del(ds, info);
231 break;
189 default: 232 default:
190 err = -EOPNOTSUPP; 233 err = -EOPNOTSUPP;
191 break; 234 break;