Commit af2a3eac2fe6a6d8e9fdf6927284b34466a7d808
Committed by
David S. Miller
1 parent
a8c30832b5
Exists in
master
and in
7 other branches
mdio: Add mdio45_ethtool_spauseparam_an()
This implements the ETHTOOL_SPAUSEPARAM operation for MDIO (clause 45) PHYs with auto-negotiation MMDs. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 2 changed files with 33 additions and 0 deletions Side-by-side Diff
drivers/net/mdio.c
... | ... | @@ -275,6 +275,36 @@ |
275 | 275 | EXPORT_SYMBOL(mdio45_ethtool_gset_npage); |
276 | 276 | |
277 | 277 | /** |
278 | + * mdio45_ethtool_spauseparam_an - set auto-negotiated pause parameters | |
279 | + * @mdio: MDIO interface | |
280 | + * @ecmd: Ethtool request structure | |
281 | + * | |
282 | + * This function assumes that the PHY has an auto-negotiation MMD. It | |
283 | + * will enable and disable advertising of flow control as appropriate. | |
284 | + */ | |
285 | +void mdio45_ethtool_spauseparam_an(const struct mdio_if_info *mdio, | |
286 | + const struct ethtool_pauseparam *ecmd) | |
287 | +{ | |
288 | + int adv, old_adv; | |
289 | + | |
290 | + WARN_ON(!(mdio->mmds & MDIO_DEVS_AN)); | |
291 | + | |
292 | + old_adv = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN, | |
293 | + MDIO_AN_ADVERTISE); | |
294 | + adv = old_adv & ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM); | |
295 | + if (ecmd->autoneg) | |
296 | + adv |= mii_advertise_flowctrl( | |
297 | + (ecmd->rx_pause ? FLOW_CTRL_RX : 0) | | |
298 | + (ecmd->tx_pause ? FLOW_CTRL_TX : 0)); | |
299 | + if (adv != old_adv) { | |
300 | + mdio->mdio_write(mdio->dev, mdio->prtad, MDIO_MMD_AN, | |
301 | + MDIO_AN_ADVERTISE, adv); | |
302 | + mdio45_nway_restart(mdio); | |
303 | + } | |
304 | +} | |
305 | +EXPORT_SYMBOL(mdio45_ethtool_spauseparam_an); | |
306 | + | |
307 | +/** | |
278 | 308 | * mdio_mii_ioctl - MII ioctl interface for MDIO (clause 22 or 45) PHYs |
279 | 309 | * @mdio: MDIO interface |
280 | 310 | * @mii_data: MII ioctl data structure |
include/linux/mdio.h
... | ... | @@ -279,6 +279,9 @@ |
279 | 279 | extern void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio, |
280 | 280 | struct ethtool_cmd *ecmd, |
281 | 281 | u32 npage_adv, u32 npage_lpa); |
282 | +extern void | |
283 | +mdio45_ethtool_spauseparam_an(const struct mdio_if_info *mdio, | |
284 | + const struct ethtool_pauseparam *ecmd); | |
282 | 285 | |
283 | 286 | /** |
284 | 287 | * mdio45_ethtool_gset - get settings for ETHTOOL_GSET |