]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
switchdev: add bridge port flags attr
authorScott Feldman <sfeldma@gmail.com>
Sun, 10 May 2015 16:47:55 +0000 (09:47 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 May 2015 22:43:54 +0000 (18:43 -0400)
rocker: use switchdev get/set attr for bridge port flags

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Acked-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/rocker/rocker.c
include/net/switchdev.h

index 84084806231a03fd14890686b25d7dcec8f4f668..ceb6a643614421a4dcbdf050dc528ed6c29bb715 100644 (file)
@@ -4394,6 +4394,9 @@ static int rocker_port_attr_get(struct net_device *dev,
                attr->ppid.id_len = sizeof(rocker->hw.id);
                memcpy(&attr->ppid.id, &rocker->hw.id, attr->ppid.id_len);
                break;
+       case SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS:
+               attr->brport_flags = rocker_port->brport_flags;
+               break;
        default:
                return -EOPNOTSUPP;
        }
@@ -4411,6 +4414,24 @@ static void rocker_port_trans_abort(struct rocker_port *rocker_port)
        }
 }
 
+static int rocker_port_brport_flags_set(struct rocker_port *rocker_port,
+                                       enum switchdev_trans trans,
+                                       unsigned long brport_flags)
+{
+       unsigned long orig_flags;
+       int err = 0;
+
+       orig_flags = rocker_port->brport_flags;
+       rocker_port->brport_flags = brport_flags;
+       if ((orig_flags ^ rocker_port->brport_flags) & BR_LEARNING)
+               err = rocker_port_set_learning(rocker_port, trans);
+
+       if (trans == SWITCHDEV_TRANS_PREPARE)
+               rocker_port->brport_flags = orig_flags;
+
+       return err;
+}
+
 static int rocker_port_attr_set(struct net_device *dev,
                                struct switchdev_attr *attr)
 {
@@ -4433,6 +4454,10 @@ static int rocker_port_attr_set(struct net_device *dev,
                err = rocker_port_stp_update(rocker_port, attr->trans,
                                             attr->stp_state);
                break;
+       case SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS:
+               err = rocker_port_brport_flags_set(rocker_port, attr->trans,
+                                                  attr->brport_flags);
+               break;
        default:
                err = -EOPNOTSUPP;
                break;
index e598c2d45786faf515e280f16a0196e3206bc020..6cf6de1a90b4bddcfbd61d01122fb550e9f587af 100644 (file)
@@ -27,6 +27,7 @@ enum switchdev_attr_id {
        SWITCHDEV_ATTR_UNDEFINED,
        SWITCHDEV_ATTR_PORT_PARENT_ID,
        SWITCHDEV_ATTR_PORT_STP_STATE,
+       SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS,
 };
 
 struct switchdev_attr {
@@ -36,6 +37,7 @@ struct switchdev_attr {
        union {
                struct netdev_phys_item_id ppid;        /* PORT_PARENT_ID */
                u8 stp_state;                           /* PORT_STP_STATE */
+               unsigned long brport_flags;             /* PORT_BRIDGE_FLAGS */
        };
 };