lantiq: clarify VG3503J name
[oweals/openwrt.git] / target / linux / mvebu / patches-4.9 / 424-net-mvneta-add-flow-control-support-via-phylink.patch
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
4
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.
8
9 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
10 ---
11
12 --- a/drivers/net/ethernet/marvell/mvneta.c
13 +++ b/drivers/net/ethernet/marvell/mvneta.c
14 @@ -3180,6 +3180,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);
17  
18 +       state->pause = 0;
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;
23 +
24         return 1;
25  }
26  
27 @@ -3222,6 +3228,8 @@ static void mvneta_mac_config(struct net
28  
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;
33  
34         switch (mode) {
35         case MLO_AN_SGMII:
36 @@ -3246,7 +3254,7 @@ static void mvneta_mac_config(struct net
37                          /* The MAC only supports FD mode */
38                          MVNETA_GMAC_CONFIG_FULL_DUPLEX;
39  
40 -               if (state->an_enabled)
41 +               if (state->pause & MLO_PAUSE_AN && state->an_enabled)
42                         new_an |= MVNETA_GMAC_AN_FLOW_CTRL_EN;
43                 break;
44  
45 @@ -3712,6 +3720,22 @@ static int mvneta_ethtool_set_ringparam(
46         return 0;
47  }
48  
49 +static void mvneta_ethtool_get_pauseparam(struct net_device *dev,
50 +                                         struct ethtool_pauseparam *pause)
51 +{
52 +       struct mvneta_port *pp = netdev_priv(dev);
53 +
54 +       phylink_ethtool_get_pauseparam(pp->phylink, pause);
55 +}
56 +
57 +static int mvneta_ethtool_set_pauseparam(struct net_device *dev,
58 +                                        struct ethtool_pauseparam *pause)
59 +{
60 +       struct mvneta_port *pp = netdev_priv(dev);
61 +
62 +       return phylink_ethtool_set_pauseparam(pp->phylink, pause);
63 +}
64 +
65  static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,
66                                        u8 *data)
67  {
68 @@ -3903,6 +3927,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,