diff options
author | 2019-05-28 20:38:12 +0300 | |
---|---|---|
committer | 2019-05-29 21:48:53 -0700 | |
commit | 44cc27e43fa3b8977373915a8e7f515a9d263343 (patch) | |
tree | cbfeeabbc90eea38508f3f8ab15a078243d3322b /net/dsa | |
parent | net: phylink: Add phylink_mac_link_{up, down} wrapper functions (diff) | |
download | linux-44cc27e43fa3b8977373915a8e7f515a9d263343.tar.gz linux-44cc27e43fa3b8977373915a8e7f515a9d263343.tar.bz2 linux-44cc27e43fa3b8977373915a8e7f515a9d263343.zip |
net: phylink: Add struct phylink_config to PHYLINK API
The phylink_config structure will encapsulate a pointer to a struct
device and the operation type requested for this instance of PHYLINK.
This patch does not make any functional changes, it just transitions the
PHYLINK internals and all its users to the new API.
A pointer to a phylink_config structure will be passed to
phylink_create() instead of the net_device directly. Also, the same
phylink_config pointer will be passed back to all phylink_mac_ops
callbacks instead of the net_device. Using this mechanism, a PHYLINK
user can get the original net_device using a structure such as
'to_net_dev(config->dev)' or directly the structure containing the
phylink_config using a container_of call.
At the moment, only the PHYLINK_NETDEV is defined as a valid operation
type for PHYLINK. In this mode, a valid reference to a struct device
linked to the original net_device should be passed to PHYLINK through
the phylink_config structure.
This API changes is mainly driven by the necessity of adding a new
operation type in PHYLINK that disconnects the phy_device from the
net_device and also works when the net_device is lacking.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/slave.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 9892ca1f6859..48e017637d4f 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1164,11 +1164,11 @@ static struct device_type dsa_type = { .name = "dsa", }; -static void dsa_slave_phylink_validate(struct net_device *dev, +static void dsa_slave_phylink_validate(struct phylink_config *config, unsigned long *supported, struct phylink_link_state *state) { - struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); struct dsa_switch *ds = dp->ds; if (!ds->ops->phylink_validate) @@ -1177,10 +1177,10 @@ static void dsa_slave_phylink_validate(struct net_device *dev, ds->ops->phylink_validate(ds, dp->index, supported, state); } -static int dsa_slave_phylink_mac_link_state(struct net_device *dev, +static int dsa_slave_phylink_mac_link_state(struct phylink_config *config, struct phylink_link_state *state) { - struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); struct dsa_switch *ds = dp->ds; /* Only called for SGMII and 802.3z */ @@ -1190,11 +1190,11 @@ static int dsa_slave_phylink_mac_link_state(struct net_device *dev, return ds->ops->phylink_mac_link_state(ds, dp->index, state); } -static void dsa_slave_phylink_mac_config(struct net_device *dev, +static void dsa_slave_phylink_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state) { - struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); struct dsa_switch *ds = dp->ds; if (!ds->ops->phylink_mac_config) @@ -1203,9 +1203,9 @@ static void dsa_slave_phylink_mac_config(struct net_device *dev, ds->ops->phylink_mac_config(ds, dp->index, mode, state); } -static void dsa_slave_phylink_mac_an_restart(struct net_device *dev) +static void dsa_slave_phylink_mac_an_restart(struct phylink_config *config) { - struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); struct dsa_switch *ds = dp->ds; if (!ds->ops->phylink_mac_an_restart) @@ -1214,11 +1214,12 @@ static void dsa_slave_phylink_mac_an_restart(struct net_device *dev) ds->ops->phylink_mac_an_restart(ds, dp->index); } -static void dsa_slave_phylink_mac_link_down(struct net_device *dev, +static void dsa_slave_phylink_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { - struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); + struct net_device *dev = dp->slave; struct dsa_switch *ds = dp->ds; if (!ds->ops->phylink_mac_link_down) { @@ -1230,12 +1231,13 @@ static void dsa_slave_phylink_mac_link_down(struct net_device *dev, ds->ops->phylink_mac_link_down(ds, dp->index, mode, interface); } -static void dsa_slave_phylink_mac_link_up(struct net_device *dev, +static void dsa_slave_phylink_mac_link_up(struct phylink_config *config, unsigned int mode, phy_interface_t interface, struct phy_device *phydev) { - struct dsa_port *dp = dsa_slave_to_port(dev); + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); + struct net_device *dev = dp->slave; struct dsa_switch *ds = dp->ds; if (!ds->ops->phylink_mac_link_up) { @@ -1303,7 +1305,10 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) if (mode < 0) mode = PHY_INTERFACE_MODE_NA; - dp->pl = phylink_create(slave_dev, of_fwnode_handle(port_dn), mode, + dp->pl_config.dev = &slave_dev->dev; + dp->pl_config.type = PHYLINK_NETDEV; + + dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode, &dsa_slave_phylink_mac_ops); if (IS_ERR(dp->pl)) { netdev_err(slave_dev, |