Configure Distributed Switch Architecture Via Device Tree

2 messages, 1 author, 2011-06-10 · open the first message on its own page

Configure Distributed Switch Architecture Via Device Tree

From: Barry G <hidden>
Date: 2011-06-08 17:18:16

Hello,

We are working on bringing up a powerpc platform that has a few
Marvell switches on it.  We would like to make use of the DSA
stuff in the kernel.

It appears all the devices currently in the kernel that use DSA
are done via the platform_add_devices route.  I was hoping
to use the device tree since most of the powerpc stuff does.

My main two questions right now are:
How do I pull together the various components into the
dsa structures and how do I register that structure with
the dsa subsystem.

I added the following to my device tree:
   virtual-device {
      compatible = "simple-bus";
      dsa {
         compatible = "vendor,my-dsa-of";
         ethernet-handle = <&enet0>;
         mdio-handle = <&mdio0>;
      };
   };

And wrote the attached driver.  It loads at boot, so I
know the compatible stuff is working and all, but
I am a little lost as to the next steps.  Any help
would be much appreciated.

Thanks,

Barry


Here is my first hack at a drive:
#include <linux/of.h>
#include <linux/kernel.h>
#include <linux/of_platform.h>
#include <net/dsa.h>

133 more lines

Re: Configure Distributed Switch Architecture Via Device Tree

From: Barry G <hidden>
Date: 2011-06-10 15:14:40

Just in case anyone else runs into this problem, this is what I ended up doing.
This code needs more error checking and isn't "right", plus it needs
to read the
chip mapping stuff from the OF, but it answers my original two questions :-)

#include <linux/of.h>
#include <linux/kernel.h>
#include <linux/of_platform.h>
#include <net/dsa.h>

static struct dsa_chip_data switches[] = {
   {
      .sw_addr = 0x9,
      .port_names = {
         "eth%d", //0
         "eth%d", //1
         "eth%d", //2
         "eth%d", //3
         "eth%d", //4
         "eth%d", //5
         "eth%d", //6
         "eth%d", //7
         NULL,   //8
         NULL,   //9
         "cpu",   //10
      },
      .rtable = (s8 []){-1, 9, 8},
   },
   {
      .sw_addr = 0xa,
      .port_names = {
         "eth%d", //0
         "eth%d", //1
         "eth%d", //2
         "eth%d", //3
         "eth%d", //4
         "eth%d", //5
         "eth%d", //6
         "eth%d", //7
         "dsa",   //8

118 more lines

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help