netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	privat@egil-hjelmeland.no, andrew@lunn.ch,
	vivien.didelot@savoirfairelinux.com, davem@davemloft.net,
	rmk+kernel@armlinux.org.uk, sean.wang@mediatek.com,
	Woojung.Huh@microchip.com, john@phrozen.org, cphealy@gmail.com
Subject: [PATCH net-next 2/4] net: phy: phylink: Provide PHY interface to mac_link_{up,down}
Date: Sun, 18 Mar 2018 11:52:44 -0700	[thread overview]
Message-ID: <20180318185246.19311-3-f.fainelli@gmail.com> (raw)
In-Reply-To: <20180318185246.19311-1-f.fainelli@gmail.com>

In preparation for having DSA transition entirely to PHYLINK, we need to pass a
PHY interface type to the mac_link_{up,down} callbacks because we may have to
make decisions on that (e.g: turn on/off RGMII interfaces etc.). We do not pass
an entire phylink_link_state because not all parameters (pause, duplex etc.) are
defined when the link is down, only link and interface are.

Update mvneta accordingly since it currently implements phylink_mac_ops.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/marvell/mvneta.c |  4 +++-
 drivers/net/phy/phylink.c             |  6 +++++-
 include/linux/phylink.h               | 10 ++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 25e9a551cc8c..60de9b8d62c2 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3396,7 +3396,8 @@ static void mvneta_set_eee(struct mvneta_port *pp, bool enable)
 	mvreg_write(pp, MVNETA_LPI_CTRL_1, lpi_ctl1);
 }
 
-static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
+static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode,
+				 phy_interface_t interface)
 {
 	struct mvneta_port *pp = netdev_priv(ndev);
 	u32 val;
@@ -3415,6 +3416,7 @@ static void mvneta_mac_link_down(struct net_device *ndev, unsigned int mode)
 }
 
 static void mvneta_mac_link_up(struct net_device *ndev, unsigned int mode,
+			       phy_interface_t interface,
 			       struct phy_device *phy)
 {
 	struct mvneta_port *pp = netdev_priv(ndev);
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 51a011a349fe..cef3c1356a8c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -423,8 +423,10 @@ static void phylink_resolve(struct work_struct *w)
 	if (pl->phylink_disable_state) {
 		pl->mac_link_dropped = false;
 		link_state.link = false;
+		link_state.interface = pl->phy_state.interface;
 	} else if (pl->mac_link_dropped) {
 		link_state.link = false;
+		link_state.interface = pl->phy_state.interface;
 	} else {
 		switch (pl->link_an_mode) {
 		case MLO_AN_PHY:
@@ -470,10 +472,12 @@ static void phylink_resolve(struct work_struct *w)
 	if (link_state.link != netif_carrier_ok(ndev)) {
 		if (!link_state.link) {
 			netif_carrier_off(ndev);
-			pl->ops->mac_link_down(ndev, pl->link_an_mode);
+			pl->ops->mac_link_down(ndev, pl->link_an_mode,
+					       pl->phy_state.interface);
 			netdev_info(ndev, "Link is Down\n");
 		} else {
 			pl->ops->mac_link_up(ndev, pl->link_an_mode,
+					     pl->phy_state.interface,
 					     pl->phydev);
 
 			netif_carrier_on(ndev);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index bd137c273d38..f29a40947de9 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -73,8 +73,10 @@ struct phylink_mac_ops {
 	void (*mac_config)(struct net_device *ndev, unsigned int mode,
 			   const struct phylink_link_state *state);
 	void (*mac_an_restart)(struct net_device *ndev);
-	void (*mac_link_down)(struct net_device *ndev, unsigned int mode);
+	void (*mac_link_down)(struct net_device *ndev, unsigned int mode,
+			      phy_interface_t interface);
 	void (*mac_link_up)(struct net_device *ndev, unsigned int mode,
+			    phy_interface_t interface,
 			    struct phy_device *phy);
 };
 
@@ -161,17 +163,20 @@ void mac_an_restart(struct net_device *ndev);
  * mac_link_down() - take the link down
  * @ndev: a pointer to a &struct net_device for the MAC.
  * @mode: link autonegotiation mode
+ * @interface: link &typedef phy_interface_t mode
  *
  * If @mode is not an in-band negotiation mode (as defined by
  * phylink_autoneg_inband()), force the link down and disable any
  * Energy Efficient Ethernet MAC configuration.
  */
-void mac_link_down(struct net_device *ndev, unsigned int mode);
+void mac_link_down(struct net_device *ndev, unsigned int mode,
+		   phy_interface_t interface);
 
 /**
  * mac_link_up() - allow the link to come up
  * @ndev: a pointer to a &struct net_device for the MAC.
  * @mode: link autonegotiation mode
+ * @interface: link &typedef phy_interface_t mode
  * @phy: any attached phy
  *
  * If @mode is not an in-band negotiation mode (as defined by
@@ -180,6 +185,7 @@ void mac_link_down(struct net_device *ndev, unsigned int mode);
  * phy_init_eee() and perform appropriate MAC configuration for EEE.
  */
 void mac_link_up(struct net_device *ndev, unsigned int mode,
+		 phy_interface_t interface,
 		 struct phy_device *phy);
 #endif
 
-- 
2.14.1

  parent reply	other threads:[~2018-03-18 18:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-18 18:52 [PATCH net-next 0/4] net: dsa: Plug in PHYLINK support Florian Fainelli
2018-03-18 18:52 ` [PATCH net-next 1/4] net: dsa: Eliminate dsa_slave_get_link() Florian Fainelli
2018-03-18 19:12   ` Andrew Lunn
2018-03-18 18:52 ` Florian Fainelli [this message]
2018-03-28  9:50   ` [PATCH net-next 2/4] net: phy: phylink: Provide PHY interface to mac_link_{up,down} Russell King - ARM Linux
2018-03-18 18:52 ` [PATCH net-next 3/4] net: dsa: Plug in PHYLINK support Florian Fainelli
2018-03-18 19:19   ` Andrew Lunn
2018-03-19 17:59     ` Florian Fainelli
2018-03-19 18:09       ` Russell King - ARM Linux
2018-03-19 18:11         ` Florian Fainelli
2018-03-18 18:52 ` [PATCH net-next 4/4] net: dsa: bcm_sf2: Implement phylink_mac_ops Florian Fainelli
2018-03-19  0:11 ` [PATCH net-next 0/4] net: dsa: Plug in PHYLINK support Florian Fainelli
2018-03-19 13:44   ` Andrew Lunn
2018-03-19 17:45     ` Florian Fainelli
2018-03-20 15:28 ` David Miller
2018-03-20 15:51   ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180318185246.19311-3-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=Woojung.Huh@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=cphealy@gmail.com \
    --cc=davem@davemloft.net \
    --cc=john@phrozen.org \
    --cc=netdev@vger.kernel.org \
    --cc=privat@egil-hjelmeland.no \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=sean.wang@mediatek.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).