diff options
author | David S. Miller <davem@davemloft.net> | 2019-10-31 14:26:38 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-10-31 14:26:38 -0700 |
commit | e43ea83cc78604b4eb02d5917f50a8b8eb6c0c85 (patch) | |
tree | 7f47ea748cbfa8ca1e207a954322c590d5ec9404 /include/net/dsa.h | |
parent | 5c26c1d6dffaae126b98ee27feba6e8042cc619d (diff) | |
parent | fcee85f19f39d1b98b2674c2a9e57348fe803252 (diff) |
Merge branch 'net-dsa-replace-routing-tables-with-a-list'
Vivien Didelot says:
====================
net: dsa: replace routing tables with a list
This branch gets rid of the ds->rtable static arrays in favor of
a single dst->rtable list. This allows us to move away from the
DSA_MAX_SWITCHES limitation and simplify the switch fabric setup.
Changes in v2:
- fix the reverse christmas for David
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r-- | include/net/dsa.h | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h index 9aba326abb64..e4c697b95c70 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -123,10 +123,8 @@ struct dsa_switch_tree { /* List of switch ports */ struct list_head ports; - /* - * Data for the individual switch chips. - */ - struct dsa_switch *ds[DSA_MAX_SWITCHES]; + /* List of DSA links composing the routing table */ + struct list_head rtable; }; /* TC matchall action types, only mirroring for now */ @@ -214,6 +212,17 @@ struct dsa_port { bool setup; }; +/* TODO: ideally DSA ports would have a single dp->link_dp member, + * and no dst->rtable nor this struct dsa_link would be needed, + * but this would require some more complex tree walking, + * so keep it stupid at the moment and list them all. + */ +struct dsa_link { + struct dsa_port *dp; + struct dsa_port *link_dp; + struct list_head list; +}; + struct dsa_switch { bool setup; @@ -245,13 +254,6 @@ struct dsa_switch { const struct dsa_switch_ops *ops; /* - * 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]; - - /* * Slave mii_bus and devices for the individual ports. */ u32 phys_mii_mask; @@ -324,6 +326,19 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds) return mask; } +/* Return the local port used to reach an arbitrary switch device */ +static inline unsigned int dsa_routing_port(struct dsa_switch *ds, int device) +{ + struct dsa_switch_tree *dst = ds->dst; + struct dsa_link *dl; + + list_for_each_entry(dl, &dst->rtable, list) + if (dl->dp->ds == ds && dl->link_dp->ds->index == device) + return dl->dp->index; + + return ds->num_ports; +} + /* Return the local port used to reach an arbitrary switch port */ static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device, int port) @@ -331,7 +346,7 @@ static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device, if (device == ds->index) return port; else - return ds->rtable[device]; + return dsa_routing_port(ds, device); } /* Return the local port used to reach the dedicated CPU port */ |