Skip to contentSkip to conversation

switchdev: push bridge ageing_time attribute down

PATCH In review [email protected] 6 participants 26 messages Oct 9, 2015 – Oct 13, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover switchdev: push bridge ageing_time attribute down

From: Scott Feldman <[email protected]>

Push bridge-level attributes down to switchdev drivers. This patchset adds the infrastructure and then pushes, as an example, ageing_time attribute down from bridge to switchdev (rocker) driver. Add some range-checking for ageing_time.

# ip link set dev br0 type bridge ageing_time 1000
# ip link set dev br0 type bridge ageing_time 999
RTNETLINK answers: Numerical result out of range

Up until now, switchdev attrs where port-level attrs, so the netdev used in switchdev_attr_set() would be a switch port or bond of switch ports. With bridge-level attrs, the netdev passed to switchdev_attr_set() is the bridge netdev. The same recusive algo is used to visit the leaves of the stacked drivers to set the attr, it's just in this case we start one layer higher in the stack. One note is not all ports in the bridge may support setting a bridge-level attribute, so rather than failing the entire set, we'll skip over those ports returning -EOPNOTSUPP.

v2->v3: Per Jiri review: push only ageing_time attr down at this time, and don't pass raw bridge IFLA_BR_* values; rather use new switchdev attr ID for ageing_time.

v1->v2: rebase w/ net-next

Scott Feldman (4):
switchdev: add bridge ageing_time attribute
switchdev: skip over ports returning -EOPNOTSUPP when recursing ports
bridge: push bridge setting ageing_time down to switchdev
rocker: handle setting bridge ageing_time

 drivers/net/ethernet/rocker/rocker.c |   16 ++++++++++++++++
 include/net/switchdev.h              |    3 +++
 net/bridge/br_ioctl.c                |    3 +--
 net/bridge/br_netlink.c              |    6 +++---
 net/bridge/br_private.h              |    1 +
 net/bridge/br_stp.c                  |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c             |    3 +--
 net/switchdev/switchdev.c            |    9 ++++++++-
 8 files changed, 56 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/4 switchdev: add bridge ageing_time attribute

From: Scott Feldman <[email protected]>

Setting the stage to push bridge-level attributes down to port driver so hardware can be programmed accordingly. Bridge-level attribute example is ageing_time. This is a per-bridge attribute, not a per-bridge-port attr.

---
 include/net/switchdev.h |    2 ++
 1 file changed, 2 insertions(+)
include/net/switchdev.h +2 -0
index 89266a3..61f129b 100644
@@ -43,6 +43,7 @@ enum switchdev_attr_id {
 	SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
 	SWITCHDEV_ATTR_ID_PORT_STP_STATE,
 	SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
+	SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
 };
 
 struct switchdev_attr {
@@ -52,6 +53,7 @@ struct switchdev_attr {
 		struct netdev_phys_item_id ppid;	/* PORT_PARENT_ID */
 		u8 stp_state;				/* PORT_STP_STATE */
 		unsigned long brport_flags;		/* PORT_BRIDGE_FLAGS */
+		u32 ageing_time;			/* BRIDGE_AGEING_TIME */
 	} u;
 };
 
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v3 2/4 switchdev: skip over ports returning -EOPNOTSUPP when recursing ports

In reply to [email protected]

From: Scott Feldman <[email protected]>

This allows us to recurse over all the ports, skipping over unsupporting ports. Without the change, the recursion would stop at first unsupported port.

---
 include/net/switchdev.h   |    1 +
 net/switchdev/switchdev.c |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
include/net/switchdev.h +1 -0
index 61f129b..1ce7083 100644
@@ -16,6 +16,7 @@
 #include <linux/list.h>
 
 #define SWITCHDEV_F_NO_RECURSE		BIT(0)
+#define SWITCHDEV_F_SKIP_EOPNOTSUPP	BIT(1)
 
 struct switchdev_trans_item {
 	struct list_head list;
net/switchdev/switchdev.c +8 -1
index 6e4a4f9..7a9ab90 100644
@@ -147,7 +147,7 @@ static int __switchdev_port_attr_set(struct net_device *dev,
 		return ops->switchdev_port_attr_set(dev, attr, trans);
 
 	if (attr->flags & SWITCHDEV_F_NO_RECURSE)
-		return err;
+		goto done;
 
 	/* Switch device port(s) may be stacked under
 	 * bond/team/vlan dev, so recurse down to set attr on
@@ -156,10 +156,17 @@ static int __switchdev_port_attr_set(struct net_device *dev,
 
 	netdev_for_each_lower_dev(dev, lower_dev, iter) {
 		err = __switchdev_port_attr_set(lower_dev, attr, trans);
+		if (err == -EOPNOTSUPP &&
+		    attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP)
+			continue;
 		if (err)
 			break;
 	}
 
+done:
+	if (err == -EOPNOTSUPP && attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP)
+		err = 0;
+
 	return err;
 }
 
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH v3 3/4 bridge: push bridge setting ageing_time down to switchdev

In reply to [email protected]

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

---
 net/bridge/br_ioctl.c    |    3 +--
 net/bridge/br_netlink.c  |    6 +++---
 net/bridge/br_private.h  |    1 +
 net/bridge/br_stp.c      |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c |    3 +--
 5 files changed, 29 insertions(+), 7 deletions(-)
net/bridge/br_ioctl.c +1 -2
index 8d423bc..263b4de 100644
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 		if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
 			return -EPERM;
 
-		br->ageing_time = clock_t_to_jiffies(args[1]);
-		return 0;
+		return br_set_ageing_time(br, args[1]);
 
 	case BRCTL_GET_PORT_INFO:
 	{
net/bridge/br_netlink.c +3 -3
index d78b442..544ab96 100644
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
 	}
 
 	if (data[IFLA_BR_AGEING_TIME]) {
-		u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
-
-		br->ageing_time = clock_t_to_jiffies(ageing_time);
+		err = br_set_ageing_time(br, nla_get_u32(data[IFLA_BR_AGEING_TIME]));
+		if (err)
+			return err;
 	}
 
 	if (data[IFLA_BR_STP_STATE]) {
net/bridge/br_private.h +1 -0
index 09d3ecb..ba0c67b 100644
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
 int br_set_hello_time(struct net_bridge *br, unsigned long x);
 int br_set_max_age(struct net_bridge *br, unsigned long x);
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time);
 
 
 /* br_stp_if.c */
net/bridge/br_stp.c +23 -0
index 3a982c0..db6d243de 100644
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
 
 }
 
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+	struct switchdev_attr attr = {
+		.id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+		.flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+		.u.ageing_time = ageing_time,
+	};
+	unsigned long t = clock_t_to_jiffies(ageing_time);
+	int err;
+
+	if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+		return -ERANGE;
+
+	err = switchdev_port_attr_set(br->dev, &attr);
+	if (err)
+		return err;
+
+	br->ageing_time = t;
+	mod_timer(&br->gc_timer, jiffies);
+
+	return 0;
+}
+
 void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
 {
 	br->bridge_forward_delay = t;
net/bridge/br_sysfs_br.c +1 -2
index 4c97fc5..04ef192 100644
@@ -102,8 +102,7 @@ static ssize_t ageing_time_show(struct device *d,
 
 static int set_ageing_time(struct net_bridge *br, unsigned long val)
 {
-	br->ageing_time = clock_t_to_jiffies(val);
-	return 0;
+	return br_set_ageing_time(br, val);
 }
 
 static ssize_t ageing_time_store(struct device *d,
Signature · 1 line
1.7.10.4
#21 lore raw

PATCH v3 4/4 rocker: handle setting bridge ageing_time

In reply to [email protected]

From: Scott Feldman <[email protected]>

The FDB cleanup timer will get rescheduled to re-evaluate FDB entries based on new ageing_time.

---
 drivers/net/ethernet/rocker/rocker.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/net/ethernet/rocker/rocker.c +16 -0
index cf91ffc..eafa907 100644
@@ -4361,6 +4361,18 @@ static int rocker_port_brport_flags_set(struct rocker_port *rocker_port,
 	return err;
 }
 
+static int rocker_port_bridge_ageing_time(struct rocker_port *rocker_port,
+					  struct switchdev_trans *trans,
+					  u32 ageing_time)
+{
+	if (!switchdev_trans_ph_prepare(trans)) {
+		rocker_port->ageing_time = clock_t_to_jiffies(ageing_time);
+		mod_timer(&rocker_port->rocker->fdb_cleanup_timer, jiffies);
+	}
+
+	return 0;
+}
+
 static int rocker_port_attr_set(struct net_device *dev,
 				struct switchdev_attr *attr,
 				struct switchdev_trans *trans)
@@ -4378,6 +4390,10 @@ static int rocker_port_attr_set(struct net_device *dev,
 		err = rocker_port_brport_flags_set(rocker_port, trans,
 						   attr->u.brport_flags);
 		break;
+	case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
+		err = rocker_port_bridge_ageing_time(rocker_port, trans,
+						     attr->u.ageing_time);
+		break;
 	default:
 		err = -EOPNOTSUPP;
 		break;
Signature · 1 line
1.7.10.4
#6 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to [email protected]

2015-10-08 19:23 GMT-07:00 <[email protected]>:

Quoted 80 lines

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

---
 net/bridge/br_ioctl.c    |    3 +--
 net/bridge/br_netlink.c  |    6 +++---
 net/bridge/br_private.h  |    1 +
 net/bridge/br_stp.c      |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c |    3 +--
 5 files changed, 29 insertions(+), 7 deletions(-)
net/bridge/br_ioctl.c +1 -2
index 8d423bc..263b4de 100644
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
                        return -EPERM;
 
-               br->ageing_time = clock_t_to_jiffies(args[1]);
-               return 0;
+               return br_set_ageing_time(br, args[1]);
 
        case BRCTL_GET_PORT_INFO:
        {
net/bridge/br_netlink.c +3 -3
index d78b442..544ab96 100644
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
        }
 
        if (data[IFLA_BR_AGEING_TIME]) {
-               u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
-
-               br->ageing_time = clock_t_to_jiffies(ageing_time);
+               err = br_set_ageing_time(br, nla_get_u32(data[IFLA_BR_AGEING_TIME]));
+               if (err)
+                       return err;
        }
 
        if (data[IFLA_BR_STP_STATE]) {
net/bridge/br_private.h +1 -0
index 09d3ecb..ba0c67b 100644
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
 int br_set_hello_time(struct net_bridge *br, unsigned long x);
 int br_set_max_age(struct net_bridge *br, unsigned long x);
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time);
 
 
 /* br_stp_if.c */
net/bridge/br_stp.c +9 -0
index 3a982c0..db6d243de 100644
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
 
 }
 
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+       struct switchdev_attr attr = {
+               .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+               .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+               .u.ageing_time = ageing_time,
+       };
+       unsigned long t = clock_t_to_jiffies(ageing_time);
+       int err;

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 587

Quoted 10 lines
net/bridge/br_stp.c +10 -0
+
+       if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+               return -ERANGE;
+
+       err = switchdev_port_attr_set(br->dev, &attr);
+       if (err)
+               return err;
+
+       br->ageing_time = t;
+       mod_timer(&br->gc_timer, jiffies);

If the switch driver/HW supports ageing, does it still make sense to have this software timer ticking?
--
Florian

Reviewed-by on the v3 series
#23 lore raw
In reply to [email protected]

2015-10-08 19:23 GMT-07:00 <[email protected]>:

Quoted 12 lines

From: Scott Feldman <[email protected]>

Push bridge-level attributes down to switchdev drivers. This patchset adds the infrastructure and then pushes, as an example, ageing_time attribute down from bridge to switchdev (rocker) driver. Add some range-checking for ageing_time.

# ip link set dev br0 type bridge ageing_time 1000
# ip link set dev br0 type bridge ageing_time 999
RTNETLINK answers: Numerical result out of range
Quoted 8 lines

Up until now, switchdev attrs where port-level attrs, so the netdev used in switchdev_attr_set() would be a switch port or bond of switch ports. With bridge-level attrs, the netdev passed to switchdev_attr_set() is the bridge netdev. The same recusive algo is used to visit the leaves of the stacked drivers to set the attr, it's just in this case we start one layer higher in the stack. One note is not all ports in the bridge may support setting a bridge-level attribute, so rather than failing the entire set, we'll skip over those ports returning -EOPNOTSUPP.

Other than the small question on patch #3, this looks good to me:

Quoted 27 lines

v2->v3: Per Jiri review: push only ageing_time attr down at this time, and don't pass raw bridge IFLA_BR_* values; rather use new switchdev attr ID for ageing_time.

v1->v2: rebase w/ net-next

Scott Feldman (4):
switchdev: add bridge ageing_time attribute
switchdev: skip over ports returning -EOPNOTSUPP when recursing ports
bridge: push bridge setting ageing_time down to switchdev
rocker: handle setting bridge ageing_time

 drivers/net/ethernet/rocker/rocker.c |   16 ++++++++++++++++
 include/net/switchdev.h              |    3 +++
 net/bridge/br_ioctl.c                |    3 +--
 net/bridge/br_netlink.c              |    6 +++---
 net/bridge/br_private.h              |    1 +
 net/bridge/br_stp.c                  |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c             |    3 +--
 net/switchdev/switchdev.c            |    9 ++++++++-
 8 files changed, 56 insertions(+), 8 deletions(-)

--
1.7.10.4

Signature · 1 line
Florian
#7 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to Florian Fainelli
Quoted 86 lines · Florian Fainelli

2015-10-08 19:23 GMT-07:00 <[email protected]>:

Quoted 85 lines

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

---
 net/bridge/br_ioctl.c    |    3 +--
 net/bridge/br_netlink.c  |    6 +++---
 net/bridge/br_private.h  |    1 +
 net/bridge/br_stp.c      |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c |    3 +--
 5 files changed, 29 insertions(+), 7 deletions(-)
net/bridge/br_ioctl.c +1 -2
index 8d423bc..263b4de 100644
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
                        return -EPERM;
 
-               br->ageing_time = clock_t_to_jiffies(args[1]);
-               return 0;
+               return br_set_ageing_time(br, args[1]);
 
        case BRCTL_GET_PORT_INFO:
        {
net/bridge/br_netlink.c +3 -3
index d78b442..544ab96 100644
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
        }
 
        if (data[IFLA_BR_AGEING_TIME]) {
-               u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
-
-               br->ageing_time = clock_t_to_jiffies(ageing_time);
+               err = br_set_ageing_time(br, nla_get_u32(data[IFLA_BR_AGEING_TIME]));
+               if (err)
+                       return err;
        }
 
        if (data[IFLA_BR_STP_STATE]) {
net/bridge/br_private.h +1 -0
index 09d3ecb..ba0c67b 100644
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
 int br_set_hello_time(struct net_bridge *br, unsigned long x);
 int br_set_max_age(struct net_bridge *br, unsigned long x);
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time);
 
 
 /* br_stp_if.c */
net/bridge/br_stp.c +14 -0
index 3a982c0..db6d243de 100644
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned long val)
 
 }
 
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+       struct switchdev_attr attr = {
+               .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+               .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+               .u.ageing_time = ageing_time,
+       };
+       unsigned long t = clock_t_to_jiffies(ageing_time);
+       int err;
+
+       if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+               return -ERANGE;
+
+       err = switchdev_port_attr_set(br->dev, &attr);
Quoted 8 lines

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 587

Quoted 5 lines
net/bridge/br_stp.c +5 -0
+       if (err)
+               return err;
+
+       br->ageing_time = t;
+       mod_timer(&br->gc_timer, jiffies);

If the switch driver/HW supports ageing, does it still make sense to have this software timer ticking?

Yes, because the bridge still needs to age out entries it has learned (those not marked with added_by_external_learn), for example entries learned on non-offloaded ports.

maintainer Acked-by on v3 1/4
#2 lore raw

Re: [PATCH net-next v3 1/4] switchdev: add bridge ageing_time attribute

In reply to [email protected]
Quoted 7 lines · Fri, Oct 09, 2015 at 04:23:17AM CEST, [email protected] wrote:

From: Scott Feldman <[email protected]>

Setting the stage to push bridge-level attributes down to port driver so hardware can be programmed accordingly. Bridge-level attribute example is ageing_time. This is a per-bridge attribute, not a per-bridge-port attr.

maintainer Acked-by on v3 2/4
#4 lore raw

Re: [PATCH net-next v3 2/4] switchdev: skip over ports returning -EOPNOTSUPP when recursing ports

In reply to [email protected]
Quoted 7 lines · Fri, Oct 09, 2015 at 04:23:18AM CEST, [email protected] wrote:

From: Scott Feldman <[email protected]>

This allows us to recurse over all the ports, skipping over unsupporting ports. Without the change, the recursion would stop at first unsupported port.

maintainer Acked-by on v3 3/4
#8 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to [email protected]
Quoted 5 lines · Fri, Oct 09, 2015 at 04:23:19AM CEST, [email protected] wrote:

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

Quoted 7 lines

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

Quoted 1 line
maintainer
#24 lore raw
In reply to [email protected]
Quoted 21 lines · Fri, Oct 09, 2015 at 04:23:16AM CEST, [email protected] wrote:

From: Scott Feldman <[email protected]>

Push bridge-level attributes down to switchdev drivers. This patchset adds the infrastructure and then pushes, as an example, ageing_time attribute down from bridge to switchdev (rocker) driver. Add some range-checking for ageing_time.

# ip link set dev br0 type bridge ageing_time 1000
# ip link set dev br0 type bridge ageing_time 999
RTNETLINK answers: Numerical result out of range

Up until now, switchdev attrs where port-level attrs, so the netdev used in switchdev_attr_set() would be a switch port or bond of switch ports. With bridge-level attrs, the netdev passed to switchdev_attr_set() is the bridge netdev. The same recusive algo is used to visit the leaves of the stacked drivers to set the attr, it's just in this case we start one layer higher in the stack. One note is not all ports in the bridge may support setting a bridge-level attribute, so rather than failing the entire set, we'll skip over those ports returning -EOPNOTSUPP.

Quoted 3 lines

v2->v3: Per Jiri review: push only ageing_time attr down at this time, and don't pass raw bridge IFLA_BR_* values; rather use new switchdev attr ID for ageing_time.

Looks fine now. Thanks Scott!

#9 lore raw

RE: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to [email protected]
Quoted 93 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

---
 net/bridge/br_ioctl.c    |    3 +--
 net/bridge/br_netlink.c  |    6 +++---
 net/bridge/br_private.h  |    1 +
 net/bridge/br_stp.c      |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c |    3 +--
 5 files changed, 29 insertions(+), 7 deletions(-)
net/bridge/br_ioctl.c +1 -2
index 8d423bc..263b4de 100644
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct
 ifreq *rq, int cmd)
 		if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
 			return -EPERM;
 
-		br->ageing_time = clock_t_to_jiffies(args[1]);
-		return 0;
+		return br_set_ageing_time(br, args[1]);
 
 	case BRCTL_GET_PORT_INFO:
net/bridge/br_ioctl.c +0 -0
 	{
net/bridge/br_netlink.c +3 -3
index d78b442..544ab96 100644
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct
 nlattr *tb[],
 	}
 
 	if (data[IFLA_BR_AGEING_TIME]) {
-		u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
-
-		br->ageing_time = clock_t_to_jiffies(ageing_time);
+		err = br_set_ageing_time(br,
 nla_get_u32(data[IFLA_BR_AGEING_TIME]));
+		if (err)
+			return err;
 	}
net/bridge/br_netlink.c +0 -0
 	if (data[IFLA_BR_STP_STATE]) {
net/bridge/br_private.h +1 -0
index 09d3ecb..ba0c67b 100644
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br,
 unsigned long t);
 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
 int br_set_hello_time(struct net_bridge *br, unsigned long x);
 int br_set_max_age(struct net_bridge *br, unsigned long x);
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time);
 
 

/* br_stp_if.c */

net/bridge/br_stp.c +4 -0
index 3a982c0..db6d243de 100644
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned
 long val)
 
 }
 
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+	struct switchdev_attr attr = {
+		.id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned · line 583

Quoted 10 lines
net/bridge/br_stp.c +10 -0
+		.flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+		.u.ageing_time = ageing_time,
+	};
+	unsigned long t = clock_t_to_jiffies(ageing_time);
+	int err;
+
+	if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+		return -ERANGE;
+
+	err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

-Prem

Quoted 28 lines
net/bridge/br_stp.c +9 -0
+	if (err)
+		return err;
+
+	br->ageing_time = t;
+	mod_timer(&br->gc_timer, jiffies);
+
+	return 0;
+}
+
 void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
 {
net/bridge/br_stp.c +0 -0
 	br->bridge_forward_delay = t;
net/bridge/br_sysfs_br.c +1 -3
index 4c97fc5..04ef192 100644
@@ -102,8 +102,7 @@ static ssize_t ageing_time_show(struct device *d,
 
 static int set_ageing_time(struct net_bridge *br, unsigned long val)
 {
-	br->ageing_time = clock_t_to_jiffies(val);
-	return 0;
+	return br_set_ageing_time(br, val);
 }
 
 static ssize_t ageing_time_store(struct device *d,
--

1.7.10.4

maintainer
#10 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

Quoted 98 lines · Fri, Oct 09, 2015 at 06:38:10AM CEST, [email protected] wrote:
Quoted 98 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

---
 net/bridge/br_ioctl.c    |    3 +--
 net/bridge/br_netlink.c  |    6 +++---
 net/bridge/br_private.h  |    1 +
 net/bridge/br_stp.c      |   23 +++++++++++++++++++++++
 net/bridge/br_sysfs_br.c |    3 +--
 5 files changed, 29 insertions(+), 7 deletions(-)
net/bridge/br_ioctl.c +1 -2
index 8d423bc..263b4de 100644
@@ -200,8 +200,7 @@ static int old_dev_ioctl(struct net_device *dev, struct
 ifreq *rq, int cmd)
 		if (!ns_capable(dev_net(dev)->user_ns, CAP_NET_ADMIN))
 			return -EPERM;
 
-		br->ageing_time = clock_t_to_jiffies(args[1]);
-		return 0;
+		return br_set_ageing_time(br, args[1]);
 
 	case BRCTL_GET_PORT_INFO:
net/bridge/br_ioctl.c +0 -0
 	{
net/bridge/br_netlink.c +3 -3
index d78b442..544ab96 100644
@@ -870,9 +870,9 @@ static int br_changelink(struct net_device *brdev, struct
 nlattr *tb[],
 	}
 
 	if (data[IFLA_BR_AGEING_TIME]) {
-		u32 ageing_time = nla_get_u32(data[IFLA_BR_AGEING_TIME]);
-
-		br->ageing_time = clock_t_to_jiffies(ageing_time);
+		err = br_set_ageing_time(br,
 nla_get_u32(data[IFLA_BR_AGEING_TIME]));
+		if (err)
+			return err;
 	}
net/bridge/br_netlink.c +0 -0
 	if (data[IFLA_BR_STP_STATE]) {
net/bridge/br_private.h +1 -0
index 09d3ecb..ba0c67b 100644
@@ -882,6 +882,7 @@ void __br_set_forward_delay(struct net_bridge *br,
 unsigned long t);
 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
 int br_set_hello_time(struct net_bridge *br, unsigned long x);
 int br_set_max_age(struct net_bridge *br, unsigned long x);
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time);
 
 

/* br_stp_if.c */

net/bridge/br_stp.c +9 -0
index 3a982c0..db6d243de 100644
@@ -566,6 +566,29 @@ int br_set_max_age(struct net_bridge *br, unsigned
 long val)
 
 }
 
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+	struct switchdev_attr attr = {
+		.id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+		.flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+		.u.ageing_time = ageing_time,
+	};
+	unsigned long t = clock_t_to_jiffies(ageing_time);
+	int err;
Quoted 8 lines

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 5 lines
net/bridge/br_stp.c +5 -0
+
+	if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+		return -ERANGE;
+
+	err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

I general, it can be. And in case of rocker, it is.
Other drivers will just use port handler to set the ageing time on the appropriate bridge.

Quoted 33 lines

-Prem

Quoted 28 lines
net/bridge/br_stp.c +9 -0
+	if (err)
+		return err;
+
+	br->ageing_time = t;
+	mod_timer(&br->gc_timer, jiffies);
+
+	return 0;
+}
+
 void __br_set_forward_delay(struct net_bridge *br, unsigned long t)
 {
net/bridge/br_stp.c +0 -0
 	br->bridge_forward_delay = t;
net/bridge/br_sysfs_br.c +1 -3
index 4c97fc5..04ef192 100644
@@ -102,8 +102,7 @@ static ssize_t ageing_time_show(struct device *d,
 
 static int set_ageing_time(struct net_bridge *br, unsigned long val)
 {
-	br->ageing_time = clock_t_to_jiffies(val);
-	return 0;
+	return br_set_ageing_time(br, val);
 }
 
 static ssize_t ageing_time_store(struct device *d,
--

1.7.10.4

#11 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to Premkumar Jonnala
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 9 lines
Quoted 9 lines
net/bridge/br_stp.c +9 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
Quoted 8 lines

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 5 lines
net/bridge/br_stp.c +5 -0
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

maintainer
#12 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 9 lines
Quoted 9 lines
net/bridge/br_stp.c +9 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
Quoted 8 lines

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 5 lines
net/bridge/br_stp.c +5 -0
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

#13 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 17 lines
Quoted 4 lines
net/bridge/br_stp.c +4 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 10 lines
net/bridge/br_stp.c +10 -0
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 6 lines
Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I think it would be good to introduce such device with an helper to retrieve this upper parent, and move the switchdev ops to this guy.

So switchdev drivers may implement such API calls:

    .obj_add(struct device *swdev, struct switchdev_obj *obj);

    .port_obj_add(struct device *swdev, struct net_device *port,
                  struct switchdev_obj *obj);

Then switchdev code may have a parent API and the current port API may look like this:

    int switchdev_port_obj_add(struct net_device *dev,
                               struct switchdev_obj *obj)
    {
        struct device *swdev = switchdev_get_parent(dev);
        int err = -EOPNOTSUPP;

        if (swdev && swdev->switchdev_ops &&
            swdev->switchdev_ops->port_obj_add)
            err = swdev->switchdev_ops->port_obj_add(swdev, dev, obj);

        return err;
    }

Thanks,
-v

maintainer
#14 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

Quoted 78 lines · Sat, Oct 10, 2015 at 05:56:19PM CEST, [email protected] wrote:
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 17 lines
Quoted 4 lines
net/bridge/br_stp.c +4 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 10 lines
net/bridge/br_stp.c +10 -0
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 6 lines
Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I think it would be good to introduce such device with an helper to retrieve this upper parent, and move the switchdev ops to this guy.

So switchdev drivers may implement such API calls:

   .obj_add(struct device *swdev, struct switchdev_obj *obj);

.port_obj_add(struct device *swdev, struct net_device *port,

                 struct switchdev_obj *obj);

Then switchdev code may have a parent API and the current port API may look like this:

   int switchdev_port_obj_add(struct net_device *dev,
                              struct switchdev_obj *obj)
   {
       struct device *swdev = switchdev_get_parent(dev);
       int err = -EOPNOTSUPP;
Quoted 6 lines
       if (swdev && swdev->switchdev_ops &&
           swdev->switchdev_ops->port_obj_add)
           err = swdev->switchdev_ops->port_obj_add(swdev, dev, obj);

       return err;

}

Fro the record, I don't see any reason for this "device". It would just introduce unnecessary complexicity. So far, we are fine without it.

#15 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

Quoted 83 lines · Jiri Pirko
Quoted 82 lines · Sat, Oct 10, 2015 at 05:56:19PM CEST, [email protected] wrote:
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 17 lines
Quoted 4 lines
net/bridge/br_stp.c +4 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 10 lines
net/bridge/br_stp.c +10 -0
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 6 lines
Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I think it would be good to introduce such device with an helper to retrieve this upper parent, and move the switchdev ops to this guy.

So switchdev drivers may implement such API calls:

   .obj_add(struct device *swdev, struct switchdev_obj *obj);

.port_obj_add(struct device *swdev, struct net_device *port,

                 struct switchdev_obj *obj);

Then switchdev code may have a parent API and the current port API may look like this:

   int switchdev_port_obj_add(struct net_device *dev,
                              struct switchdev_obj *obj)
   {
       struct device *swdev = switchdev_get_parent(dev);
       int err = -EOPNOTSUPP;
       if (swdev && swdev->switchdev_ops &&
           swdev->switchdev_ops->port_obj_add)
           err = swdev->switchdev_ops->port_obj_add(swdev, dev, obj);
Quoted 5 lines
Quoted 2 lines
       return err;

}

Fro the record, I don't see any reason for this "device". It would just introduce unnecessary complexicity. So far, we are fine without it.

I wouldn't say that. I beleive that an Ethernet switch deserves its struct device in the tree, since it is a physical chip, like any other.

Configuring it through one of its port (net_device) is fine, since you want to change the port behavior, and Linux config is on per-port basis.

But the complexity is already introduced in the struct net_device with the switchdev_ops. These ops really belong to the parent device, not to all of its ports.

Ideally a switch device would be registered with this set of operations, creates its net_devices, and will be accessible from a port net_device through a netdev helper function.

Thanks,
-v

#16 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

2015-10-10 15:41 GMT-07:00 Vivien Didelot <[email protected]>:

Quoted 84 lines · Jiri Pirko
Quoted 83 lines
Quoted 82 lines · Sat, Oct 10, 2015 at 05:56:19PM CEST, [email protected] wrote:
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 17 lines
Quoted 4 lines
(quoted diff) +4 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

Review

Quoted 10 lines
(quoted diff) +10 -0
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 6 lines
Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I think it would be good to introduce such device with an helper to retrieve this upper parent, and move the switchdev ops to this guy.

So switchdev drivers may implement such API calls:

   .obj_add(struct device *swdev, struct switchdev_obj *obj);

.port_obj_add(struct device *swdev, struct net_device *port,

                 struct switchdev_obj *obj);

Then switchdev code may have a parent API and the current port API may look like this:

   int switchdev_port_obj_add(struct net_device *dev,
                              struct switchdev_obj *obj)
   {
       struct device *swdev = switchdev_get_parent(dev);
       int err = -EOPNOTSUPP;
       if (swdev && swdev->switchdev_ops &&
           swdev->switchdev_ops->port_obj_add)
           err = swdev->switchdev_ops->port_obj_add(swdev, dev, obj);
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
       return err;

}

Fro the record, I don't see any reason for this "device". It would just introduce unnecessary complexicity. So far, we are fine without it.

I wouldn't say that. I beleive that an Ethernet switch deserves its struct device in the tree, since it is a physical chip, like any other.

Agreed, but gating these patches because we do not yet have a device driver model for an Ethernet switch outside of its individual ports does not seem like it hurts the current patch series, nor the existing model (and future).

Quoted 7 lines

Configuring it through one of its port (net_device) is fine, since you want to change the port behavior, and Linux config is on per-port basis.

But the complexity is already introduced in the struct net_device with the switchdev_ops. These ops really belong to the parent device, not to all of its ports.

I am not sure if complexity is the correct term here, bloat (to some extent) maybe, since with what you are suggesting we could save one set of function pointers per-port, and instead move that to a global/switch-wide device implementing these operations. In essence, there will be per-port switchdev_ops, bridge-specific, and maybe in the future switch device specific.

Quoted 4 lines

Ideally a switch device would be registered with this set of operations, creates its net_devices, and will be accessible from a port net_device through a netdev helper function.

I think the core of the discussion for a proper Ethernet switch device model is precisely whether we want to have a special network device to configure the switch as a whole. It sure would represent one facet of the switch device, but not everything else for which we are still trying to find out what that is.

Signature · 1 line
Florian
#17 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

Quoted 91 lines · Florian Fainelli

2015-10-10 15:41 GMT-07:00 Vivien Didelot <[email protected]>:

Quoted 90 lines · Jiri Pirko
Quoted 88 lines
Quoted 78 lines · Sat, Oct 10, 2015 at 05:56:19PM CEST, [email protected] wrote:
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 17 lines
Quoted 4 lines
(quoted diff) +4 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

Review

Quoted 10 lines
(quoted diff) +10 -0
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 6 lines
Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I think it would be good to introduce such device with an helper to retrieve this upper parent, and move the switchdev ops to this guy.

So switchdev drivers may implement such API calls:

   .obj_add(struct device *swdev, struct switchdev_obj *obj);

.port_obj_add(struct device *swdev, struct net_device *port,

                 struct switchdev_obj *obj);

Then switchdev code may have a parent API and the current port API may look like this:

   int switchdev_port_obj_add(struct net_device *dev,
                              struct switchdev_obj *obj)
   {
       struct device *swdev = switchdev_get_parent(dev);
       int err = -EOPNOTSUPP;
Quoted 6 lines
       if (swdev && swdev->switchdev_ops &&
           swdev->switchdev_ops->port_obj_add)
           err = swdev->switchdev_ops->port_obj_add(swdev, dev, obj);

       return err;

}

Fro the record, I don't see any reason for this "device". It would just introduce unnecessary complexicity. So far, we are fine without it.

Quoted 7 lines
Quoted 2 lines

I wouldn't say that. I beleive that an Ethernet switch deserves its struct device in the tree, since it is a physical chip, like any other.

Agreed, but gating these patches because we do not yet have a device driver model for an Ethernet switch outside of its individual ports does not seem like it hurts the current patch series, nor the existing model (and future).

Sure, I didn't mean to NAK the patch with this comment, I just wrote it because we raised a concern about an API higher than the port level.

Quoted 8 lines
Quoted 7 lines

Configuring it through one of its port (net_device) is fine, since you want to change the port behavior, and Linux config is on per-port basis.

But the complexity is already introduced in the struct net_device with the switchdev_ops. These ops really belong to the parent device, not to all of its ports.

Quoted 6 lines

I am not sure if complexity is the correct term here, bloat (to some extent) maybe, since with what you are suggesting we could save one set of function pointers per-port, and instead move that to a global/switch-wide device implementing these operations. In essence, there will be per-port switchdev_ops, bridge-specific, and maybe in the future switch device specific.

Exact. I think that a switch net_device port should just have a pointer or something to its parent device (the switch) to query its operations.

Quoted 10 lines
Quoted 4 lines

Ideally a switch device would be registered with this set of operations, creates its net_devices, and will be accessible from a port net_device through a netdev helper function.

I think the core of the discussion for a proper Ethernet switch device model is precisely whether we want to have a special network device to configure the switch as a whole. It sure would represent one facet of the switch device, but not everything else for which we are still trying to find out what that is.

I am not even convinced that a switch chip must be represented in the Linux tree by a net_device. That's basically a chip exposing a bench of registers to configure and expose not only net interfaces, but also temperature sensors, and even GPIO sometimes.

Thanks,
-v

#18 lore raw

RE: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to Florian Fainelli
Quoted 100 lines

2015-10-10 15:41 GMT-07:00 Vivien Didelot
<[email protected]>:

Quoted 2 lines · Jiri Pirko
Quoted 1 line

Sat, Oct 10, 2015 at 05:56:19PM CEST, [email protected]

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines · Jiri Pirko
Quoted 2 lines
Quoted 1 line · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:

On Thu, Oct 8, 2015 at 9:38 PM, Premkumar Jonnala

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected];

[email protected];

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Premkumar Jonnala; [email protected];
[email protected]; [email protected];

[email protected];

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

[email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting

ageing_time down

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge

that don't

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now

to

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +8 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why

are we using a "port based api"

Quoted 41 lines
Quoted 40 lines
Quoted 31 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

to pass the attribute down? May be I'm missing something here?

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I think it would be good to introduce such device with an helper to retrieve this upper parent, and move the switchdev ops to this guy.

So switchdev drivers may implement such API calls:

   .obj_add(struct device *swdev, struct switchdev_obj *obj);

.port_obj_add(struct device *swdev, struct net_device *port,

                 struct switchdev_obj *obj);

Then switchdev code may have a parent API and the current port API may look like this:

   int switchdev_port_obj_add(struct net_device *dev,
                              struct switchdev_obj *obj)
   {
       struct device *swdev = switchdev_get_parent(dev);
       int err = -EOPNOTSUPP;
Quoted 6 lines
       if (swdev && swdev->switchdev_ops &&
           swdev->switchdev_ops->port_obj_add)
           err = swdev->switchdev_ops->port_obj_add(swdev, dev, obj);

       return err;

}

Fro the record, I don't see any reason for this "device". It would just introduce unnecessary complexicity. So far, we are fine without it.

Quoted 7 lines
Quoted 2 lines

I wouldn't say that. I beleive that an Ethernet switch deserves its struct device in the tree, since it is a physical chip, like any other.

Agreed, but gating these patches because we do not yet have a device driver model for an Ethernet switch outside of its individual ports does not seem like it hurts the current patch series, nor the existing model (and future).

I don't think we have to gate this patch because of this change, but I wanted to raise this issue because it didn't seem right to use "port level" API when what we want to configure is really a "bridge level" attribute.

Quoted 9 lines
Quoted 8 lines

Configuring it through one of its port (net_device) is fine, since you want to change the port behavior, and Linux config is on per-port basis.

But the complexity is already introduced in the struct net_device with the switchdev_ops. These ops really belong to the parent device, not to all of its ports.

Quoted 6 lines

I am not sure if complexity is the correct term here, bloat (to some extent) maybe, since with what you are suggesting we could save one set of function pointers per-port, and instead move that to a global/switch-wide device implementing these operations. In essence, there will be per-port switchdev_ops, bridge-specific, and maybe in the future switch device specific.

This is right. Going forward, we will have methods/attributes that are bridge specific, router specific, etc. I think having a right model at the start will go a long way in helping keep the code-base extensible in the future.

Quoted 11 lines
Quoted 5 lines

Ideally a switch device would be registered with this set of operations, creates its net_devices, and will be accessible from a port net_device through a netdev helper function.

I think the core of the discussion for a proper Ethernet switch device model is precisely whether we want to have a special network device to configure the switch as a whole. It sure would represent one facet of the switch device, but not everything else for which we are still trying to find out what that is.

Agree. We will have models other than switch device, but given that we are running into switch-level attributes, it would be great if we can introduce that concept now, and add more abstractions/models as we come across new attributes.

-Prem

Quoted 2 lines

--
Florian

#20 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to Jiri Pirko
Quoted 48 lines · Jiri Pirko
Quoted 47 lines · Sat, Oct 10, 2015 at 04:53:52AM CEST, [email protected] wrote:
Quoted 25 lines · Premkumar Jonnala
Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, October 09, 2015 7:53 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Premkumar Jonnala; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

From: Scott Feldman <[email protected]>

Use SWITCHDEV_F_SKIP_EOPNOTSUPP to skip over ports in bridge that don't support setting ageing_time (or setting bridge attrs in general).

If push fails, don't update ageing_time in bridge and return err to user.

If push succeeds, update ageing_time in bridge and run gc_timer now to recalabrate when to run gc_timer next, based on new ageing_time.

<snip>

Quoted 17 lines
Quoted 4 lines
net/bridge/br_stp.c +4 -0
+int br_set_ageing_time(struct net_bridge *br, u32 ageing_time)
+{
+     struct switchdev_attr attr = {
+             .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,

net/bridge/br_stp.c int br_set_max_age(struct net_bridge *br, unsigned long val) · line 582

Quoted 10 lines
net/bridge/br_stp.c +10 -0
+             .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP,
+             .u.ageing_time = ageing_time,
+     };
+     unsigned long t = clock_t_to_jiffies(ageing_time);
+     int err;
+
+     if (t < BR_MIN_AGEING_TIME || t > BR_MAX_AGEING_TIME)
+             return -ERANGE;
+
+     err = switchdev_port_attr_set(br->dev, &attr);

A thought - given that the ageing time is not a per-bridge-port attr, why are we using a "port based api" to pass the attribute down? May be I'm missing something here?

Quoted 6 lines
Quoted 3 lines

I think Florian raised the same point earlier. Sigh, I think this should be addressed....v4 coming soon...thanks guys for keeping the standard high.

Scott, can you tell us how do you want to address this? I like the current implementation.

I like it also, but there is some awkwardness in calling switchdev_port_attr_set() with the first argument being the bridge netdev, not a port netdev. But, the basic algorithm to recurse from _this_ netdev down to its lower netdevs works great in this case; it's just the name "switchdev_port_attr_set" implies a port netdev for top-level netdev. So I was thinking about adding another call, something like "switchdev_master_attr_set", which basically just does the same thing as switchdev_port_attr_set, except maybe skips the check to call the ops->switchdev_port_attr_add on the top-level netdev. But now I don't like that idea so much as "master" would be confusing when your passing a bond netdev (which is also a master), but the bond _is_ the port netdev this time, a port on the bridge.

So let's scrap v4 and go with v3. I think I can live with this naming awkwardness, given that we got something for essentially free by using switchdev_port_attr_set() in a new way.

Davem, I think we're OK going with v3.

(There is a follow-on discussion about a switch device, which we'll continue but it shouldn't block this v3 version).

maintainer
#25 lore raw
In reply to [email protected]

From: [email protected]
Date: Thu, 8 Oct 2015 19:23:16 -0700

Quoted 21 lines

From: Scott Feldman <[email protected]>

Push bridge-level attributes down to switchdev drivers. This patchset adds the infrastructure and then pushes, as an example, ageing_time attribute down from bridge to switchdev (rocker) driver. Add some range-checking for ageing_time.

# ip link set dev br0 type bridge ageing_time 1000
# ip link set dev br0 type bridge ageing_time 999
RTNETLINK answers: Numerical result out of range

Up until now, switchdev attrs where port-level attrs, so the netdev used in switchdev_attr_set() would be a switch port or bond of switch ports. With bridge-level attrs, the netdev passed to switchdev_attr_set() is the bridge netdev. The same recusive algo is used to visit the leaves of the stacked drivers to set the attr, it's just in this case we start one layer higher in the stack. One note is not all ports in the bridge may support setting a bridge-level attribute, so rather than failing the entire set, we'll skip over those ports returning -EOPNOTSUPP.

Quoted 5 lines

v2->v3: Per Jiri review: push only ageing_time attr down at this time, and don't pass raw bridge IFLA_BR_* values; rather use new switchdev attr ID for ageing_time.

v1->v2: rebase w/ net-next

Series applied, thanks.

#19 lore raw

Re: [PATCH net-next v3 3/4] bridge: push bridge setting ageing_time down to switchdev

In reply to Vivien Didelot
Quoted 2 lines · Vivien Didelot

Scott, didn't you have a plan to add a struct device for the parent of switchdev ports?

I had sent out a rough RFC for a switch device in the last window. I have continued working on it, and I plan to send it very soon, probably again as an RFC.