Skip to content

Commit

Permalink
rocker: Check Handle PORT_PRE_BRIDGE_FLAGS
Browse files Browse the repository at this point in the history
In preparation for getting rid of switchdev_port_attr_get(), have rocker
check for the bridge flags being set through switchdev_port_attr_set()
with the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS attribute identifier.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Feb 21, 2019
1 parent ea87005 commit 9370045
Showing 1 changed file with 41 additions and 14 deletions.
55 changes: 41 additions & 14 deletions drivers/net/ethernet/rocker/rocker_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1566,34 +1566,57 @@ static int rocker_world_port_attr_stp_state_set(struct rocker_port *rocker_port,
}

static int
rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
unsigned long brport_flags,
struct switchdev_trans *trans)
rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *
rocker_port,
unsigned long *
p_brport_flags_support)
{
struct rocker_world_ops *wops = rocker_port->rocker->wops;

if (!wops->port_attr_bridge_flags_support_get)
return -EOPNOTSUPP;
return wops->port_attr_bridge_flags_support_get(rocker_port,
p_brport_flags_support);
}

static int
rocker_world_port_attr_pre_bridge_flags_set(struct rocker_port *rocker_port,
unsigned long brport_flags,
struct switchdev_trans *trans)
{
struct rocker_world_ops *wops = rocker_port->rocker->wops;
unsigned long brport_flags_s;
int err;

if (!wops->port_attr_bridge_flags_set)
return -EOPNOTSUPP;

if (switchdev_trans_ph_prepare(trans))
return 0;
err = rocker_world_port_attr_bridge_flags_support_get(rocker_port,
&brport_flags_s);
if (err)
return err;

return wops->port_attr_bridge_flags_set(rocker_port, brport_flags,
trans);
if (brport_flags & ~brport_flags_s)
return -EINVAL;

return 0;
}

static int
rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *
rocker_port,
unsigned long *
p_brport_flags_support)
rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
unsigned long brport_flags,
struct switchdev_trans *trans)
{
struct rocker_world_ops *wops = rocker_port->rocker->wops;

if (!wops->port_attr_bridge_flags_support_get)
if (!wops->port_attr_bridge_flags_set)
return -EOPNOTSUPP;
return wops->port_attr_bridge_flags_support_get(rocker_port,
p_brport_flags_support);

if (switchdev_trans_ph_prepare(trans))
return 0;

return wops->port_attr_bridge_flags_set(rocker_port, brport_flags,
trans);
}

static int
Expand Down Expand Up @@ -2074,6 +2097,10 @@ static int rocker_port_attr_set(struct net_device *dev,
attr->u.stp_state,
trans);
break;
case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
err = rocker_world_port_attr_pre_bridge_flags_set(rocker_port,
attr->u.brport_flags,
trans);
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
err = rocker_world_port_attr_bridge_flags_set(rocker_port,
attr->u.brport_flags,
Expand Down

0 comments on commit 9370045

Please sign in to comment.