1 From: Russell King <rmk+kernel@arm.linux.org.uk>
2 Date: Thu, 1 Oct 2015 17:41:44 +0100
3 Subject: [PATCH] net: mvneta: add flow control support via phylink
5 Add flow control support to mvneta, including the ethtool hooks. This
6 uses the phylink code to calculate the result of autonegotiation where
7 a phy is attached, and to handle the ethtool settings.
9 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
12 --- a/drivers/net/ethernet/marvell/mvneta.c
13 +++ b/drivers/net/ethernet/marvell/mvneta.c
14 @@ -3179,6 +3179,12 @@ static int mvneta_mac_link_state(struct
15 state->link = !!(gmac_stat & MVNETA_GMAC_LINK_UP);
16 state->duplex = !!(gmac_stat & MVNETA_GMAC_FULL_DUPLEX);
19 + if (gmac_stat & MVNETA_GMAC_RX_FLOW_CTRL_ENABLE)
20 + state->pause |= MLO_PAUSE_RX;
21 + if (gmac_stat & MVNETA_GMAC_TX_FLOW_CTRL_ENABLE)
22 + state->pause |= MLO_PAUSE_TX;
27 @@ -3221,6 +3227,8 @@ static void mvneta_mac_config(struct net
29 if (phylink_test(state->advertising, Pause))
30 new_an |= MVNETA_GMAC_ADVERT_SYM_FLOW_CTRL;
31 + if (state->pause & MLO_PAUSE_TXRX_MASK)
32 + new_an |= MVNETA_GMAC_CONFIG_FLOW_CTRL;
36 @@ -3245,7 +3253,7 @@ static void mvneta_mac_config(struct net
37 /* The MAC only supports FD mode */
38 MVNETA_GMAC_CONFIG_FULL_DUPLEX;
40 - if (state->an_enabled)
41 + if (state->pause & MLO_PAUSE_AN && state->an_enabled)
42 new_an |= MVNETA_GMAC_AN_FLOW_CTRL_EN;
45 @@ -3711,6 +3719,22 @@ static int mvneta_ethtool_set_ringparam(
49 +static void mvneta_ethtool_get_pauseparam(struct net_device *dev,
50 + struct ethtool_pauseparam *pause)
52 + struct mvneta_port *pp = netdev_priv(dev);
54 + phylink_ethtool_get_pauseparam(pp->phylink, pause);
57 +static int mvneta_ethtool_set_pauseparam(struct net_device *dev,
58 + struct ethtool_pauseparam *pause)
60 + struct mvneta_port *pp = netdev_priv(dev);
62 + return phylink_ethtool_set_pauseparam(pp->phylink, pause);
65 static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,
68 @@ -3902,6 +3926,8 @@ const struct ethtool_ops mvneta_eth_tool
69 .get_drvinfo = mvneta_ethtool_get_drvinfo,
70 .get_ringparam = mvneta_ethtool_get_ringparam,
71 .set_ringparam = mvneta_ethtool_set_ringparam,
72 + .get_pauseparam = mvneta_ethtool_get_pauseparam,
73 + .set_pauseparam = mvneta_ethtool_set_pauseparam,
74 .get_strings = mvneta_ethtool_get_strings,
75 .get_ethtool_stats = mvneta_ethtool_get_stats,
76 .get_sset_count = mvneta_ethtool_get_sset_count,