Commit b44700e9 authored by Timur Tabi's avatar Timur Tabi Committed by David S. Miller

net: qcom/emac: add ethool support for setting pause parameters

To support setting the pause parameters, the driver can no longer just
mirror the PHY.  The set_pauseparam feature allows the driver to
force the setting in the MAC, regardless of how the PHY is configured.
This means that we now need to maintain an internal state for pause
frame support, and so get_pauseparam also needs to be updated.

If the interface is already running when the setting is changed, then
the interface is reset.

Note that if the MAC is configured to enable RX pause frame support
(i.e. it transmits pause frames to throttle the other end), but the
PHY is configured to block those frames, then the feature will not work.

Also some buffer size initialization code into emac_init_adapter(),
so that it lives with similar code, including the initializtion of
pause frame support.
Signed-off-by: default avatarTimur Tabi <timur@codeaurora.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 29ba6e74
...@@ -148,16 +148,26 @@ static void emac_get_ringparam(struct net_device *netdev, ...@@ -148,16 +148,26 @@ static void emac_get_ringparam(struct net_device *netdev,
static void emac_get_pauseparam(struct net_device *netdev, static void emac_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause) struct ethtool_pauseparam *pause)
{ {
struct phy_device *phydev = netdev->phydev; struct emac_adapter *adpt = netdev_priv(netdev);
if (phydev) { pause->autoneg = adpt->automatic ? AUTONEG_ENABLE : AUTONEG_DISABLE;
if (phydev->autoneg) pause->rx_pause = adpt->rx_flow_control ? 1 : 0;
pause->autoneg = 1; pause->tx_pause = adpt->tx_flow_control ? 1 : 0;;
if (phydev->pause) }
pause->rx_pause = 1;
if (phydev->pause != phydev->asym_pause) static int emac_set_pauseparam(struct net_device *netdev,
pause->tx_pause = 1; struct ethtool_pauseparam *pause)
} {
struct emac_adapter *adpt = netdev_priv(netdev);
adpt->automatic = pause->autoneg == AUTONEG_ENABLE;
adpt->rx_flow_control = pause->rx_pause != 0;
adpt->tx_flow_control = pause->tx_pause != 0;
if (netif_running(netdev))
return emac_reinit_locked(adpt);
return 0;
} }
static const struct ethtool_ops emac_ethtool_ops = { static const struct ethtool_ops emac_ethtool_ops = {
...@@ -172,7 +182,9 @@ static const struct ethtool_ops emac_ethtool_ops = { ...@@ -172,7 +182,9 @@ static const struct ethtool_ops emac_ethtool_ops = {
.get_ethtool_stats = emac_get_ethtool_stats, .get_ethtool_stats = emac_get_ethtool_stats,
.get_ringparam = emac_get_ringparam, .get_ringparam = emac_get_ringparam,
.get_pauseparam = emac_get_pauseparam, .get_pauseparam = emac_get_pauseparam,
.set_pauseparam = emac_set_pauseparam,
.nway_reset = emac_nway_reset, .nway_reset = emac_nway_reset,
......
...@@ -565,11 +565,19 @@ static void emac_mac_start(struct emac_adapter *adpt) ...@@ -565,11 +565,19 @@ static void emac_mac_start(struct emac_adapter *adpt)
mac |= TXEN | RXEN; /* enable RX/TX */ mac |= TXEN | RXEN; /* enable RX/TX */
/* Configure MAC flow control to match the PHY's settings. */ /* Configure MAC flow control. If set to automatic, then match
if (phydev->pause) * whatever the PHY does. Otherwise, enable or disable it, depending
mac |= RXFC; * on what the user configured via ethtool.
if (phydev->pause != phydev->asym_pause) */
mac |= TXFC; mac &= ~(RXFC | TXFC);
if (adpt->automatic) {
/* If it's set to automatic, then update our local values */
adpt->rx_flow_control = phydev->pause;
adpt->tx_flow_control = phydev->pause != phydev->asym_pause;
}
mac |= adpt->rx_flow_control ? RXFC : 0;
mac |= adpt->tx_flow_control ? TXFC : 0;
/* setup link speed */ /* setup link speed */
mac &= ~SPEED_MASK; mac &= ~SPEED_MASK;
......
...@@ -436,6 +436,10 @@ static void emac_init_adapter(struct emac_adapter *adpt) ...@@ -436,6 +436,10 @@ static void emac_init_adapter(struct emac_adapter *adpt)
{ {
u32 reg; u32 reg;
adpt->rrd_size = EMAC_RRD_SIZE;
adpt->tpd_size = EMAC_TPD_SIZE;
adpt->rfd_size = EMAC_RFD_SIZE;
/* descriptors */ /* descriptors */
adpt->tx_desc_cnt = EMAC_DEF_TX_DESCS; adpt->tx_desc_cnt = EMAC_DEF_TX_DESCS;
adpt->rx_desc_cnt = EMAC_DEF_RX_DESCS; adpt->rx_desc_cnt = EMAC_DEF_RX_DESCS;
...@@ -456,6 +460,9 @@ static void emac_init_adapter(struct emac_adapter *adpt) ...@@ -456,6 +460,9 @@ static void emac_init_adapter(struct emac_adapter *adpt)
/* others */ /* others */
adpt->preamble = EMAC_PREAMBLE_DEF; adpt->preamble = EMAC_PREAMBLE_DEF;
/* default to automatic flow control */
adpt->automatic = true;
} }
/* Get the clock */ /* Get the clock */
...@@ -675,10 +682,6 @@ static int emac_probe(struct platform_device *pdev) ...@@ -675,10 +682,6 @@ static int emac_probe(struct platform_device *pdev)
netdev->watchdog_timeo = EMAC_WATCHDOG_TIME; netdev->watchdog_timeo = EMAC_WATCHDOG_TIME;
netdev->irq = adpt->irq.irq; netdev->irq = adpt->irq.irq;
adpt->rrd_size = EMAC_RRD_SIZE;
adpt->tpd_size = EMAC_TPD_SIZE;
adpt->rfd_size = EMAC_RFD_SIZE;
netdev->netdev_ops = &emac_netdev_ops; netdev->netdev_ops = &emac_netdev_ops;
emac_init_adapter(adpt); emac_init_adapter(adpt);
......
...@@ -306,6 +306,13 @@ struct emac_adapter { ...@@ -306,6 +306,13 @@ struct emac_adapter {
unsigned int rxbuf_size; unsigned int rxbuf_size;
/* Flow control / pause frames support. If automatic=True, do whatever
* the PHY does. Otherwise, use tx_flow_control and rx_flow_control.
*/
bool automatic;
bool tx_flow_control;
bool rx_flow_control;
/* Ring parameter */ /* Ring parameter */
u8 tpd_burst; u8 tpd_burst;
u8 rfd_burst; u8 rfd_burst;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment