diff options
author | David S. Miller <davem@davemloft.net> | 2017-10-18 12:24:34 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-18 12:24:34 +0100 |
commit | 1bbc728988f09e40c83585cf3322b1f6c1aa17b5 (patch) | |
tree | d73285634543e8063d66da030e34a218fc76e805 /include | |
parent | a2084f5650624edd0805dc78260d097df4f38eb6 (diff) | |
parent | c8652c83bc84ac8db44060ced0036de7628aa5e5 (diff) | |
download | linux-1bbc728988f09e40c83585cf3322b1f6c1aa17b5.tar.bz2 |
Merge branch 'dsa-master-and-slave-helpers'
Vivien Didelot says:
====================
net: dsa: master and slave helpers
This patch series adds a few helpers to DSA core for clarity and
readability but brings no functional changes.
A dsa_slave_notify helper calls the DSA notifiers when (un)registering a
slave device.
Most of the DSA slave code only needs to access the dsa_port structure,
not the dsa_slave_priv (which only contains a few PHY-specific members).
Thus a dsa_slave_to_port helper returns a dsa_port structure of a slave
device.
A dsa_slave_to_master returns the master device of a slave device.
After that the netdev member of the dsa_port structure is split into two
explicit master and slave members to avoid confusion, and a dsa_to_port
helper is added for switch drivers to get a const reference to a port.
Changes in v2:
- prefer dsa_slave_to_master instead of dsa_slave_get_master
- rename dsa_master_get_slave to dsa_master_find_slave
- pack master and slave net devices into an anonymous union
- add dsa_to_port public helper for switch drivers
- add Reviewed-by tags from Florian
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/dsa.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h index 2746741f74cf..38961ef91d3d 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -164,6 +164,14 @@ struct dsa_mall_tc_entry { struct dsa_port { + /* A CPU port is physically connected to a master device. + * A user port exposed to userspace has a slave device. + */ + union { + struct net_device *master; + struct net_device *slave; + }; + /* CPU port tagging operations used by master or slave devices */ const struct dsa_device_ops *tag_ops; @@ -176,7 +184,6 @@ struct dsa_port { unsigned int index; const char *name; struct dsa_port *cpu_dp; - struct net_device *netdev; struct device_node *dn; unsigned int ageing_time; u8 stp_state; @@ -262,6 +269,11 @@ static inline bool dsa_is_normal_port(struct dsa_switch *ds, int p) return !dsa_is_cpu_port(ds, p) && !dsa_is_dsa_port(ds, p); } +static inline const struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p) +{ + return &ds->ports[p]; +} + static inline u8 dsa_upstream_port(struct dsa_switch *ds) { struct dsa_switch_tree *dst = ds->dst; |