Commit 91a208f2 authored by Russell King's avatar Russell King Committed by David S. Miller
Browse files

net: phylink: propagate resolved link config via mac_link_up()



Propagate the resolved link parameters via the mac_link_up() call for
MACs that do not automatically track their PCS state. We propagate the
link parameters via function arguments so that inappropriate members
of struct phylink_link_state can't be accessed, and creating a new
structure just for this adds needless complexity to the API.

Tested-by: default avatarAndre Przywara <andre.przywara@arm.com>
Tested-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2e6af0f3
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -74,10 +74,13 @@ phylib to the sfp/phylink support. Please send patches to improve
this documentation.

1. Optionally split the network driver's phylib update function into
   three parts dealing with link-down, link-up and reconfiguring the
   MAC settings. This can be done as a separate preparation commit.
   two parts dealing with link-down and link-up. This can be done as
   a separate preparation commit.

   An example of this preparation can be found in git commit fc548b991fb0.
   An older example of this preparation can be found in git commit
   fc548b991fb0, although this was splitting into three parts; the
   link-up part now includes configuring the MAC for the link settings.
   Please see :c:func:`mac_link_up` for more information on this.

2. Replace::

@@ -207,6 +210,14 @@ this documentation.
   using. This is particularly important for in-band negotiation
   methods such as 1000base-X and SGMII.

   The :c:func:`mac_link_up` method is used to inform the MAC that the
   link has come up. The call includes the negotiation mode and interface
   for reference only. The finalised link parameters are also supplied
   (speed, duplex and flow control/pause enablement settings) which
   should be used to configure the MAC when the MAC and PCS are not
   tightly integrated, or when the settings are not coming from in-band
   negotiation.

   The :c:func:`mac_config` method is used to update the MAC with the
   requested state, and must avoid unnecessarily taking the link down
   when making changes to the MAC configuration.  This means the
+5 −2
Original line number Diff line number Diff line
@@ -626,8 +626,11 @@ static void macb_mac_link_down(struct phylink_config *config, unsigned int mode,
	netif_tx_stop_all_queues(ndev);
}

static void macb_mac_link_up(struct phylink_config *config, unsigned int mode,
			     phy_interface_t interface, struct phy_device *phy)
static void macb_mac_link_up(struct phylink_config *config,
			     struct phy_device *phy,
			     unsigned int mode, phy_interface_t interface,
			     int speed, int duplex,
			     bool tx_pause, bool rx_pause)
{
	struct net_device *ndev = to_net_dev(config->dev);
	struct macb *bp = netdev_priv(ndev);
+5 −2
Original line number Diff line number Diff line
@@ -154,8 +154,11 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
		netdev_err(mac->net_dev, "dpmac_set_link_state() = %d\n", err);
}

static void dpaa2_mac_link_up(struct phylink_config *config, unsigned int mode,
			      phy_interface_t interface, struct phy_device *phy)
static void dpaa2_mac_link_up(struct phylink_config *config,
			      struct phy_device *phy,
			      unsigned int mode, phy_interface_t interface,
			      int speed, int duplex,
			      bool tx_pause, bool rx_pause)
{
	struct dpaa2_mac *mac = phylink_to_dpaa2_mac(config);
	struct dpmac_link_state *dpmac_state = &mac->state;
+5 −3
Original line number Diff line number Diff line
@@ -3965,9 +3965,11 @@ static void mvneta_mac_link_down(struct phylink_config *config,
	mvneta_set_eee(pp, false);
}

static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
			       phy_interface_t interface,
			       struct phy_device *phy)
static void mvneta_mac_link_up(struct phylink_config *config,
			       struct phy_device *phy,
			       unsigned int mode, phy_interface_t interface,
			       int speed, int duplex,
			       bool tx_pause, bool rx_pause)
{
	struct net_device *ndev = to_net_dev(config->dev);
	struct mvneta_port *pp = netdev_priv(ndev);
+13 −6
Original line number Diff line number Diff line
@@ -58,8 +58,11 @@ static struct {
 */
static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
			     const struct phylink_link_state *state);
static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
			      phy_interface_t interface, struct phy_device *phy);
static void mvpp2_mac_link_up(struct phylink_config *config,
			      struct phy_device *phy,
			      unsigned int mode, phy_interface_t interface,
			      int speed, int duplex,
			      bool tx_pause, bool rx_pause);

/* Queue modes */
#define MVPP2_QDIST_SINGLE_MODE	0
@@ -3473,8 +3476,9 @@ static void mvpp2_start_dev(struct mvpp2_port *port)
			.interface = port->phy_interface,
		};
		mvpp2_mac_config(&port->phylink_config, MLO_AN_INBAND, &state);
		mvpp2_mac_link_up(&port->phylink_config, MLO_AN_INBAND,
				  port->phy_interface, NULL);
		mvpp2_mac_link_up(&port->phylink_config, NULL,
				  MLO_AN_INBAND, port->phy_interface,
				  SPEED_UNKNOWN, DUPLEX_UNKNOWN, false, false);
	}

	netif_tx_start_all_queues(port->dev);
@@ -5141,8 +5145,11 @@ static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
	mvpp2_port_enable(port);
}

static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
			      phy_interface_t interface, struct phy_device *phy)
static void mvpp2_mac_link_up(struct phylink_config *config,
			      struct phy_device *phy,
			      unsigned int mode, phy_interface_t interface,
			      int speed, int duplex,
			      bool tx_pause, bool rx_pause)
{
	struct net_device *dev = to_net_dev(config->dev);
	struct mvpp2_port *port = netdev_priv(dev);
Loading