net: dsa: Copy the routing table into the switch structure
[cascardo/linux.git] / include / net / dsa.h
index 17c3d37..b666f27 100644 (file)
@@ -58,12 +58,11 @@ struct dsa_chip_data {
        struct device_node *port_dn[DSA_MAX_PORTS];
 
        /*
-        * An array (with nr_chips elements) of which element [a]
-        * indicates which port on this switch should be used to
-        * send packets to that are destined for switch a.  Can be
-        * NULL if there is only one switch chip.
+        * An array of which element [a] indicates which port on this
+        * switch should be used to send packets to that are destined
+        * for switch a. Can be NULL if there is only one switch chip.
         */
-       s8              *rtable;
+       s8              rtable[DSA_MAX_SWITCHES];
 };
 
 struct dsa_platform_data {
@@ -119,6 +118,11 @@ struct dsa_switch_tree {
        struct dsa_switch       *ds[DSA_MAX_SWITCHES];
 };
 
+struct dsa_port {
+       struct net_device       *netdev;
+       struct device_node      *dn;
+};
+
 struct dsa_switch {
        struct device *dev;
 
@@ -144,6 +148,13 @@ struct dsa_switch {
         */
        struct dsa_switch_driver        *drv;
 
+       /*
+        * An array of which element [a] indicates which port on this
+        * switch should be used to send packets to that are destined
+        * for switch a. Can be NULL if there is only one switch chip.
+        */
+       s8              rtable[DSA_MAX_SWITCHES];
+
 #ifdef CONFIG_NET_DSA_HWMON
        /*
         * Hardware monitoring information
@@ -158,8 +169,8 @@ struct dsa_switch {
        u32                     dsa_port_mask;
        u32                     enabled_port_mask;
        u32                     phys_mii_mask;
+       struct dsa_port         ports[DSA_MAX_PORTS];
        struct mii_bus          *slave_mii_bus;
-       struct net_device       *ports[DSA_MAX_PORTS];
 };
 
 static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
@@ -174,7 +185,7 @@ static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
 
 static inline bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
 {
-       return ds->enabled_port_mask & (1 << p) && ds->ports[p];
+       return ds->enabled_port_mask & (1 << p) && ds->ports[p].netdev;
 }
 
 static inline u8 dsa_upstream_port(struct dsa_switch *ds)
@@ -190,7 +201,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
        if (dst->cpu_switch == ds->index)
                return dst->cpu_port;
        else
-               return ds->cd->rtable[dst->cpu_switch];
+               return ds->rtable[dst->cpu_switch];
 }
 
 struct switchdev_trans;