mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-24 15:42:32 +00:00
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>
This commit is contained in:
parent
8ae5bcdc5d
commit
d0c627b874
3 changed files with 66 additions and 16 deletions
|
@ -158,6 +158,43 @@ static int dsa_switch_mdb_del(struct dsa_switch *ds,
|
|||
return ds->ops->port_mdb_del(ds, info->port, mdb);
|
||||
}
|
||||
|
||||
static int dsa_switch_vlan_add(struct dsa_switch *ds,
|
||||
struct dsa_notifier_vlan_info *info)
|
||||
{
|
||||
const struct switchdev_obj_port_vlan *vlan = info->vlan;
|
||||
struct switchdev_trans *trans = info->trans;
|
||||
|
||||
/* Do not care yet about other switch chips of the fabric */
|
||||
if (ds->index != info->sw_index)
|
||||
return 0;
|
||||
|
||||
if (switchdev_trans_ph_prepare(trans)) {
|
||||
if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return ds->ops->port_vlan_prepare(ds, info->port, vlan, trans);
|
||||
}
|
||||
|
||||
ds->ops->port_vlan_add(ds, info->port, vlan, trans);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dsa_switch_vlan_del(struct dsa_switch *ds,
|
||||
struct dsa_notifier_vlan_info *info)
|
||||
{
|
||||
const struct switchdev_obj_port_vlan *vlan = info->vlan;
|
||||
|
||||
/* Do not care yet about other switch chips of the fabric */
|
||||
if (ds->index != info->sw_index)
|
||||
return 0;
|
||||
|
||||
if (!ds->ops->port_vlan_del)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return ds->ops->port_vlan_del(ds, info->port, vlan);
|
||||
}
|
||||
|
||||
static int dsa_switch_event(struct notifier_block *nb,
|
||||
unsigned long event, void *info)
|
||||
{
|
||||
|
@ -186,6 +223,12 @@ static int dsa_switch_event(struct notifier_block *nb,
|
|||
case DSA_NOTIFIER_MDB_DEL:
|
||||
err = dsa_switch_mdb_del(ds, info);
|
||||
break;
|
||||
case DSA_NOTIFIER_VLAN_ADD:
|
||||
err = dsa_switch_vlan_add(ds, info);
|
||||
break;
|
||||
case DSA_NOTIFIER_VLAN_DEL:
|
||||
err = dsa_switch_vlan_del(ds, info);
|
||||
break;
|
||||
default:
|
||||
err = -EOPNOTSUPP;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue