Re: [Bridge] [PATCH net-next 1/5] bridge: initialize port flags with switchdev defaults

2018-03-12 Thread Igor Mitsyanko

On 03/10/2018 08:32 AM, Stephen Hemminger wrote:

Yes hardware devices may come it with different default values.
But the user experience on Linux needs to be consistent.

Instead, it makes more sense to me for each device driver using switchdev
to program to the values that it sees in the bridge.

Please revise this.



Right, it does change default user view, setting flags instead of 
querying makes more sense then.


However there is a problem that switchdev may not support all flags that 
bridge code sets by default. For example, looking at 
spectrum_switchdev.c, it only advertises support for BR_LEARNING | 
BR_FLOOD | BR_MCAST_FLOOD.
Currently, I assume that even though some flags are shown as set by 
default on a new bridge port, some of them are not actually working in 
switchdev?


Re: [Bridge] [PATCH net-next 1/5] bridge: initialize port flags with switchdev defaults

2018-03-12 Thread Igor Mitsyanko

On 03/10/2018 08:30 AM, Andrew Lunn wrote:

+
+ ret = switchdev_port_attr_get(dev, );
+ if (ret)
+ return BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;



Hi Igor

Please check if ret == -EOPNOTSUPP and only then use the defaults. A
real error should be propagated, causing new_nbp to fail. You might
also consider what to do when ENODATA is returned.

  Andrew



Hi Andrew,
ok, will change it so an error is propagated.
There is one more comment from Stephen suggesting that flags must be set 
in switchdev, rather then queried: this approach should take care about 
ENODATA I assume.


Re: [Bridge] [PATCH net-next 1/5] bridge: initialize port flags with switchdev defaults

2018-03-10 Thread Andrew Lunn
On Fri, Mar 09, 2018 at 07:03:04PM -0800, Igor Mitsyanko wrote:
> Default bridge port flags for switchdev devices can be different from
> what is used in bridging core. Get default value from switchdev itself
> on port initialization.
> 
> Signed-off-by: Igor Mitsyanko 
> ---
>  net/bridge/br_if.c | 17 -
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
> index 9ba4ed6..d658b55 100644
> --- a/net/bridge/br_if.c
> +++ b/net/bridge/br_if.c
> @@ -342,6 +342,21 @@ static int find_portno(struct net_bridge *br)
>   return (index >= BR_MAX_PORTS) ? -EXFULL : index;
>  }
>  
> +static unsigned long nbp_flags_get_default(struct net_device *dev)
> +{
> + struct switchdev_attr attr = {
> + .orig_dev = dev,
> + .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
> + };
> + int ret;
> +
> + ret = switchdev_port_attr_get(dev, );
> + if (ret)
> + return BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;


Hi Igor

Please check if ret == -EOPNOTSUPP and only then use the defaults. A
real error should be propagated, causing new_nbp to fail. You might
also consider what to do when ENODATA is returned.

 Andrew


Re: [Bridge] [PATCH net-next 1/5] bridge: initialize port flags with switchdev defaults

2018-03-10 Thread Stephen Hemminger
On Fri,  9 Mar 2018 19:03:04 -0800
Igor Mitsyanko  wrote:

> Default bridge port flags for switchdev devices can be different from
> what is used in bridging core. Get default value from switchdev itself
> on port initialization.
> 
> Signed-off-by: Igor Mitsyanko 
> ---

Yes hardware devices may come it with different default values.
But the user experience on Linux needs to be consistent.

Instead, it makes more sense to me for each device driver using switchdev
to program to the values that it sees in the bridge.

Please revise this.


[Bridge] [PATCH net-next 1/5] bridge: initialize port flags with switchdev defaults

2018-03-09 Thread Igor Mitsyanko
Default bridge port flags for switchdev devices can be different from
what is used in bridging core. Get default value from switchdev itself
on port initialization.

Signed-off-by: Igor Mitsyanko 
---
 net/bridge/br_if.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 9ba4ed6..d658b55 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -342,6 +342,21 @@ static int find_portno(struct net_bridge *br)
return (index >= BR_MAX_PORTS) ? -EXFULL : index;
 }
 
+static unsigned long nbp_flags_get_default(struct net_device *dev)
+{
+   struct switchdev_attr attr = {
+   .orig_dev = dev,
+   .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
+   };
+   int ret;
+
+   ret = switchdev_port_attr_get(dev, );
+   if (ret)
+   return BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;
+   else
+   return attr.u.brport_flags;
+}
+
 /* called with RTNL but without bridge lock */
 static struct net_bridge_port *new_nbp(struct net_bridge *br,
   struct net_device *dev)
@@ -363,7 +378,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge 
*br,
p->path_cost = port_cost(dev);
p->priority = 0x8000 >> BR_PORT_BITS;
p->port_no = index;
-   p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;
+   p->flags = nbp_flags_get_default(dev);
br_init_port(p);
br_set_state(p, BR_STATE_DISABLED);
br_stp_port_timer_init(p);
-- 
2.9.5