Subject: Re: [RFC PATCH net-next 0/2] Add new switchdev device class

From: Andrew Lunn <[email-masked]>
Date: Fri, 28 Aug 2015 13:52:55 +0200

> So with kobj, a device can have a parent.  So I experimented with my
> RFC patch and changed register_switchdev to take a parent switchdev
> arg, which is NULL for leaf switchdevs:
> 
> int register_switchdev(struct switchdev *sdev, const char *name,
>                        struct switchdev *parent)
> {
>         struct device *dev = &sdev->dev;
>         int err;
> 
>         device_initialize(dev);
> 
>         dev->class = &switchdev_class;
>         if (parent)
>                 dev->parent = &parent->dev;
> 
>         err = dev_set_name(dev, "%s", name);
>         if (err)
>                 return err;
> 
>         return device_add(dev);
> }
 
...

> With this, we can stack switchdevs, I guess as high as we want.  Does
> this look usable for DSA?   An attr set on the master would get pushed
> down to the leaves.  We'd can do it with the same style of recursive
> algos we use for switchdev port attrs.

Since this is a file system, we are limited to trees. But the hardware
is actually a graph. The interconnect points are ports on the switch,
and possible trunks/bonds of ports. I doubt there is a nice way to
represent this.

So it probably makes sense to have the switch with the port to the
host as the root of the tree, and all other switches are leafs of that
root.

How do you envisage addressing? I want to use netlink to read the
global registers from a specific switch for example.

       Andrew