rocker: Change world_ops API and implementation to be switchdev independant

Currently the switchdev_trans struct is embedded in the world_ops API.
In order to add support for adding FDB via a notfication chain the API should
be switchdev independent.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Arkadi Sharshevsky 2017-06-08 08:44:25 +02:00 committed by David S. Miller
parent 96673a3044
commit 00fc0c51e3
3 changed files with 235 additions and 339 deletions

View File

@ -105,8 +105,7 @@ struct rocker_world_ops {
int (*port_open)(struct rocker_port *rocker_port);
void (*port_stop)(struct rocker_port *rocker_port);
int (*port_attr_stp_state_set)(struct rocker_port *rocker_port,
u8 state,
struct switchdev_trans *trans);
u8 state);
int (*port_attr_bridge_flags_set)(struct rocker_port *rocker_port,
unsigned long brport_flags,
struct switchdev_trans *trans);
@ -120,18 +119,16 @@ struct rocker_world_ops {
u32 ageing_time,
struct switchdev_trans *trans);
int (*port_obj_vlan_add)(struct rocker_port *rocker_port,
const struct switchdev_obj_port_vlan *vlan,
struct switchdev_trans *trans);
const struct switchdev_obj_port_vlan *vlan);
int (*port_obj_vlan_del)(struct rocker_port *rocker_port,
const struct switchdev_obj_port_vlan *vlan);
int (*port_obj_vlan_dump)(const struct rocker_port *rocker_port,
struct switchdev_obj_port_vlan *vlan,
switchdev_obj_dump_cb_t *cb);
int (*port_obj_fdb_add)(struct rocker_port *rocker_port,
const struct switchdev_obj_port_fdb *fdb,
struct switchdev_trans *trans);
u16 vid, const unsigned char *addr);
int (*port_obj_fdb_del)(struct rocker_port *rocker_port,
const struct switchdev_obj_port_fdb *fdb);
u16 vid, const unsigned char *addr);
int (*port_obj_fdb_dump)(const struct rocker_port *rocker_port,
struct switchdev_obj_port_fdb *fdb,
switchdev_obj_dump_cb_t *cb);

View File

@ -1557,7 +1557,11 @@ static int rocker_world_port_attr_stp_state_set(struct rocker_port *rocker_port,
if (!wops->port_attr_stp_state_set)
return -EOPNOTSUPP;
return wops->port_attr_stp_state_set(rocker_port, state, trans);
if (switchdev_trans_ph_prepare(trans))
return 0;
return wops->port_attr_stp_state_set(rocker_port, state);
}
static int
@ -1569,6 +1573,10 @@ rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
if (!wops->port_attr_bridge_flags_set)
return -EOPNOTSUPP;
if (switchdev_trans_ph_prepare(trans))
return 0;
return wops->port_attr_bridge_flags_set(rocker_port, brport_flags,
trans);
}
@ -1608,6 +1616,10 @@ rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
if (!wops->port_attr_bridge_ageing_time_set)
return -EOPNOTSUPP;
if (switchdev_trans_ph_prepare(trans))
return 0;
return wops->port_attr_bridge_ageing_time_set(rocker_port, ageing_time,
trans);
}
@ -1621,7 +1633,11 @@ rocker_world_port_obj_vlan_add(struct rocker_port *rocker_port,
if (!wops->port_obj_vlan_add)
return -EOPNOTSUPP;
return wops->port_obj_vlan_add(rocker_port, vlan, trans);
if (switchdev_trans_ph_prepare(trans))
return 0;
return wops->port_obj_vlan_add(rocker_port, vlan);
}
static int
@ -1656,7 +1672,11 @@ rocker_world_port_obj_fdb_add(struct rocker_port *rocker_port,
if (!wops->port_obj_fdb_add)
return -EOPNOTSUPP;
return wops->port_obj_fdb_add(rocker_port, fdb, trans);
if (switchdev_trans_ph_prepare(trans))
return 0;
return wops->port_obj_fdb_add(rocker_port, fdb->vid, fdb->addr);
}
static int
@ -1667,7 +1687,7 @@ rocker_world_port_obj_fdb_del(struct rocker_port *rocker_port,
if (!wops->port_obj_fdb_del)
return -EOPNOTSUPP;
return wops->port_obj_fdb_del(rocker_port, fdb);
return wops->port_obj_fdb_del(rocker_port, fdb->vid, fdb->addr);
}
static int

File diff suppressed because it is too large Load Diff