Skip to content

Commit ce68155

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: phylink: mac_link_(up|down)() clarifications
As a result of an email from the fbnic author, I reviewed the phylink documentation, and I have decided to clarify the wording in the mac_link_(up|down)() kernel documentation as this was written from the point of view of mvneta/mvpp2 and is misleading. The documentation talks about forcing the link - indeed, this is what is done in the mvneta and mvpp2 drivers but not at the physical layer but the MACs idea, which has the effect of only allowing or stopping packet flow at the MAC. This "link" needs to be controlled when using a PHY or fixed link to start or stop packet flow at the MAC. However, as the MAC and PCS are tightly integrated, if the MACs idea of the link is forced down, it has the side effect that there is no way to determine that the media link has come up - in this mode, the MAC must be allowed to follow its built-in PCS so we can read the link state. Frame the documentation in more generic terms, to avoid the thought that the physical media link to the partner needs in some way to be forced up or down with these calls; it does not. If that were to be done, it would be a self-fulfilling prophecy - e.g. if the media link goes down, then mac_link_down() will be called, and if the media link is then placed into a forced down state, there is no possibility that the media link will ever come up again - clearly this is a wrong interpretation. These methods are notifications to the MAC about what has happened to the media link state - either from the PHY, or a PCS, or whatever mechanism fixed-link is using. Thus, reword them to get away from talking about changing link state to avoid confusion with media link state. This is not a change of any requirements of these methods. Also, remove the obsolete references to EEE for these methods, we now have the LPI functions for configuring the EEE parameters which renders this redundant, and also makes the passing of "phy" to the mac_link_up() function obsolete. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://patch.msgid.link/E1u5Ah5-001GO1-7E@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4c8925c commit ce68155

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

include/linux/phylink.h

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,31 +361,40 @@ int mac_finish(struct phylink_config *config, unsigned int mode,
361361
phy_interface_t iface);
362362

363363
/**
364-
* mac_link_down() - take the link down
364+
* mac_link_down() - notification that the link has gone down
365365
* @config: a pointer to a &struct phylink_config.
366366
* @mode: link autonegotiation mode
367367
* @interface: link &typedef phy_interface_t mode
368368
*
369-
* If @mode is not an in-band negotiation mode (as defined by
370-
* phylink_autoneg_inband()), force the link down and disable any
371-
* Energy Efficient Ethernet MAC configuration. Interface type
372-
* selection must be done in mac_config().
369+
* Notifies the MAC that the link has gone down. This will not be called
370+
* unless mac_link_up() has been previously called.
371+
*
372+
* The MAC should stop processing packets for transmission and reception.
373+
* phylink will have called netif_carrier_off() to notify the networking
374+
* stack that the link has gone down, so MAC drivers should not make this
375+
* call.
376+
*
377+
* If @mode is %MLO_AN_INBAND, then this function must not prevent the
378+
* link coming up.
373379
*/
374380
void mac_link_down(struct phylink_config *config, unsigned int mode,
375381
phy_interface_t interface);
376382

377383
/**
378-
* mac_link_up() - allow the link to come up
384+
* mac_link_up() - notification that the link has come up
379385
* @config: a pointer to a &struct phylink_config.
380-
* @phy: any attached phy
386+
* @phy: any attached phy (deprecated - please use LPI interfaces)
381387
* @mode: link autonegotiation mode
382388
* @interface: link &typedef phy_interface_t mode
383389
* @speed: link speed
384390
* @duplex: link duplex
385391
* @tx_pause: link transmit pause enablement status
386392
* @rx_pause: link receive pause enablement status
387393
*
388-
* Configure the MAC for an established link.
394+
* Notifies the MAC that the link has come up, and the parameters of the
395+
* link as seen from the MACs point of view. If mac_link_up() has been
396+
* called previously, there will be an intervening call to mac_link_down()
397+
* before this method will be subsequently called.
389398
*
390399
* @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link
391400
* settings, and should be used to configure the MAC block appropriately
@@ -397,9 +406,9 @@ void mac_link_down(struct phylink_config *config, unsigned int mode,
397406
* that the user wishes to override the pause settings, and this should
398407
* be allowed when considering the implementation of this method.
399408
*
400-
* If in-band negotiation mode is disabled, allow the link to come up. If
401-
* @phy is non-%NULL, configure Energy Efficient Ethernet by calling
402-
* phy_init_eee() and perform appropriate MAC configuration for EEE.
409+
* Once configured, the MAC may begin to process packets for transmission
410+
* and reception.
411+
*
403412
* Interface type selection must be done in mac_config().
404413
*/
405414
void mac_link_up(struct phylink_config *config, struct phy_device *phy,

0 commit comments

Comments
 (0)