2
0

424-net-mvneta-add-flow-control-support-via-phylink.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From: Russell King <[email protected]>
  2. Date: Thu, 1 Oct 2015 17:41:44 +0100
  3. Subject: [PATCH] net: mvneta: add flow control support via phylink
  4. Add flow control support to mvneta, including the ethtool hooks. This
  5. uses the phylink code to calculate the result of autonegotiation where
  6. a phy is attached, and to handle the ethtool settings.
  7. Signed-off-by: Russell King <[email protected]>
  8. ---
  9. --- a/drivers/net/ethernet/marvell/mvneta.c
  10. +++ b/drivers/net/ethernet/marvell/mvneta.c
  11. @@ -3180,6 +3180,12 @@ static int mvneta_mac_link_state(struct
  12. state->link = !!(gmac_stat & MVNETA_GMAC_LINK_UP);
  13. state->duplex = !!(gmac_stat & MVNETA_GMAC_FULL_DUPLEX);
  14. + state->pause = 0;
  15. + if (gmac_stat & MVNETA_GMAC_RX_FLOW_CTRL_ENABLE)
  16. + state->pause |= MLO_PAUSE_RX;
  17. + if (gmac_stat & MVNETA_GMAC_TX_FLOW_CTRL_ENABLE)
  18. + state->pause |= MLO_PAUSE_TX;
  19. +
  20. return 1;
  21. }
  22. @@ -3222,6 +3228,8 @@ static void mvneta_mac_config(struct net
  23. if (phylink_test(state->advertising, Pause))
  24. new_an |= MVNETA_GMAC_ADVERT_SYM_FLOW_CTRL;
  25. + if (state->pause & MLO_PAUSE_TXRX_MASK)
  26. + new_an |= MVNETA_GMAC_CONFIG_FLOW_CTRL;
  27. switch (mode) {
  28. case MLO_AN_SGMII:
  29. @@ -3246,7 +3254,7 @@ static void mvneta_mac_config(struct net
  30. /* The MAC only supports FD mode */
  31. MVNETA_GMAC_CONFIG_FULL_DUPLEX;
  32. - if (state->an_enabled)
  33. + if (state->pause & MLO_PAUSE_AN && state->an_enabled)
  34. new_an |= MVNETA_GMAC_AN_FLOW_CTRL_EN;
  35. break;
  36. @@ -3712,6 +3720,22 @@ static int mvneta_ethtool_set_ringparam(
  37. return 0;
  38. }
  39. +static void mvneta_ethtool_get_pauseparam(struct net_device *dev,
  40. + struct ethtool_pauseparam *pause)
  41. +{
  42. + struct mvneta_port *pp = netdev_priv(dev);
  43. +
  44. + phylink_ethtool_get_pauseparam(pp->phylink, pause);
  45. +}
  46. +
  47. +static int mvneta_ethtool_set_pauseparam(struct net_device *dev,
  48. + struct ethtool_pauseparam *pause)
  49. +{
  50. + struct mvneta_port *pp = netdev_priv(dev);
  51. +
  52. + return phylink_ethtool_set_pauseparam(pp->phylink, pause);
  53. +}
  54. +
  55. static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,
  56. u8 *data)
  57. {
  58. @@ -3903,6 +3927,8 @@ const struct ethtool_ops mvneta_eth_tool
  59. .get_drvinfo = mvneta_ethtool_get_drvinfo,
  60. .get_ringparam = mvneta_ethtool_get_ringparam,
  61. .set_ringparam = mvneta_ethtool_set_ringparam,
  62. + .get_pauseparam = mvneta_ethtool_get_pauseparam,
  63. + .set_pauseparam = mvneta_ethtool_set_pauseparam,
  64. .get_strings = mvneta_ethtool_get_strings,
  65. .get_ethtool_stats = mvneta_ethtool_get_stats,
  66. .get_sset_count = mvneta_ethtool_get_sset_count,