Skip to content

Commit

Permalink
net: dsa: move VLAN handlers
Browse files Browse the repository at this point in the history
Move the DSA port code which handles VLAN objects in port.c, where it
belongs.

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>
  • Loading branch information
Vivien Didelot authored and David S. Miller committed May 22, 2017
1 parent 3a9afea commit 076e713
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
8 changes: 8 additions & 0 deletions net/dsa/dsa_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ int dsa_port_mdb_del(struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb);
int dsa_port_mdb_dump(struct dsa_port *dp, struct switchdev_obj_port_mdb *mdb,
switchdev_obj_dump_cb_t *cb);
int dsa_port_vlan_add(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan,
struct switchdev_trans *trans);
int dsa_port_vlan_del(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan);
int dsa_port_vlan_dump(struct dsa_port *dp,
struct switchdev_obj_port_vlan *vlan,
switchdev_obj_dump_cb_t *cb);

/* slave.c */
extern const struct dsa_device_ops notag_netdev_ops;
Expand Down
41 changes: 41 additions & 0 deletions net/dsa/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,44 @@ int dsa_port_mdb_dump(struct dsa_port *dp, struct switchdev_obj_port_mdb *mdb,

return -EOPNOTSUPP;
}

int dsa_port_vlan_add(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan,
struct switchdev_trans *trans)
{
struct dsa_switch *ds = dp->ds;

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, dp->index, vlan, trans);
}

ds->ops->port_vlan_add(ds, dp->index, vlan, trans);

return 0;
}

int dsa_port_vlan_del(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan)
{
struct dsa_switch *ds = dp->ds;

if (!ds->ops->port_vlan_del)
return -EOPNOTSUPP;

return ds->ops->port_vlan_del(ds, dp->index, vlan);
}

int dsa_port_vlan_dump(struct dsa_port *dp,
struct switchdev_obj_port_vlan *vlan,
switchdev_obj_dump_cb_t *cb)
{
struct dsa_switch *ds = dp->ds;

if (ds->ops->port_vlan_dump)
return ds->ops->port_vlan_dump(ds, dp->index, vlan, cb);

return -EOPNOTSUPP;
}
41 changes: 0 additions & 41 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,47 +204,6 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
return 0;
}

static int dsa_port_vlan_add(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan,
struct switchdev_trans *trans)
{
struct dsa_switch *ds = dp->ds;

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, dp->index, vlan, trans);
}

ds->ops->port_vlan_add(ds, dp->index, vlan, trans);

return 0;
}

static int dsa_port_vlan_del(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan)
{
struct dsa_switch *ds = dp->ds;

if (!ds->ops->port_vlan_del)
return -EOPNOTSUPP;

return ds->ops->port_vlan_del(ds, dp->index, vlan);
}

static int dsa_port_vlan_dump(struct dsa_port *dp,
struct switchdev_obj_port_vlan *vlan,
switchdev_obj_dump_cb_t *cb)
{
struct dsa_switch *ds = dp->ds;

if (ds->ops->port_vlan_dump)
return ds->ops->port_vlan_dump(ds, dp->index, vlan, cb);

return -EOPNOTSUPP;
}

static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct dsa_slave_priv *p = netdev_priv(dev);
Expand Down

0 comments on commit 076e713

Please sign in to comment.