Commit 93700458 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

rocker: Check Handle PORT_PRE_BRIDGE_FLAGS

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: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ea87005a
...@@ -1566,34 +1566,57 @@ static int rocker_world_port_attr_stp_state_set(struct rocker_port *rocker_port, ...@@ -1566,34 +1566,57 @@ static int rocker_world_port_attr_stp_state_set(struct rocker_port *rocker_port,
} }
static int static int
rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port, 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, unsigned long brport_flags,
struct switchdev_trans *trans) struct switchdev_trans *trans)
{ {
struct rocker_world_ops *wops = rocker_port->rocker->wops; struct rocker_world_ops *wops = rocker_port->rocker->wops;
unsigned long brport_flags_s;
int err;
if (!wops->port_attr_bridge_flags_set) if (!wops->port_attr_bridge_flags_set)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (switchdev_trans_ph_prepare(trans)) err = rocker_world_port_attr_bridge_flags_support_get(rocker_port,
return 0; &brport_flags_s);
if (err)
return err;
return wops->port_attr_bridge_flags_set(rocker_port, brport_flags, if (brport_flags & ~brport_flags_s)
trans); return -EINVAL;
return 0;
} }
static int static int
rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port * rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
rocker_port, unsigned long brport_flags,
unsigned long * struct switchdev_trans *trans)
p_brport_flags_support)
{ {
struct rocker_world_ops *wops = rocker_port->rocker->wops; 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 -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 static int
...@@ -2074,6 +2097,10 @@ static int rocker_port_attr_set(struct net_device *dev, ...@@ -2074,6 +2097,10 @@ static int rocker_port_attr_set(struct net_device *dev,
attr->u.stp_state, attr->u.stp_state,
trans); trans);
break; 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: case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
err = rocker_world_port_attr_bridge_flags_set(rocker_port, err = rocker_world_port_attr_bridge_flags_set(rocker_port,
attr->u.brport_flags, attr->u.brport_flags,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment