Skip to content

Commit 1ef0764

Browse files
ffainellidavem330
authored andcommitted
net: bridge: Stop calling switchdev_port_attr_get()
Now that all switchdev drivers have been converted to check the SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS flags and report flags that they do not support accordingly, we can migrate the bridge code to try to set that attribute first, check the results and then do the actual setting. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9370045 commit 1ef0764

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎net/bridge/br_switchdev.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,19 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
6464
{
6565
struct switchdev_attr attr = {
6666
.orig_dev = p->dev,
67-
.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
67+
.id = SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS,
68+
.u.brport_flags = mask,
6869
};
6970
int err;
7071

7172
if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD)
7273
return 0;
7374

74-
err = switchdev_port_attr_get(p->dev, &attr);
75+
err = switchdev_port_attr_set(p->dev, &attr);
7576
if (err == -EOPNOTSUPP)
7677
return 0;
77-
if (err)
78-
return err;
7978

80-
/* Check if specific bridge flag attribute offload is supported */
81-
if (!(attr.u.brport_flags_support & mask)) {
79+
if (err) {
8280
br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",
8381
(unsigned int)p->port_no, p->dev->name);
8482
return -EOPNOTSUPP;
@@ -87,6 +85,7 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
8785
attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS;
8886
attr.flags = SWITCHDEV_F_DEFER;
8987
attr.u.brport_flags = flags;
88+
9089
err = switchdev_port_attr_set(p->dev, &attr);
9190
if (err) {
9291
br_warn(p->br, "error setting offload flag on port %u(%s)\n",

0 commit comments

Comments
 (0)