aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
diff options
context:
space:
mode:
authorTimur Tabi <timur@codeaurora.org>2017-02-08 15:49:28 -0600
committerDavid S. Miller <davem@davemloft.net>2017-02-09 17:09:19 -0500
commit038b9404d4e2db4fbc03d5d2203abafc6e188528 (patch)
treefd3c02c461fdeb60eb1ae3ab7470fcb92ec3399e /drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
parentnet: qcom/emac: add ethtool support for reading hardware registers (diff)
downloadlinux-dev-038b9404d4e2db4fbc03d5d2203abafc6e188528.tar.xz
linux-dev-038b9404d4e2db4fbc03d5d2203abafc6e188528.zip
net: qcom/emac: add ethtool support for setting ring parameters
Implement the set_ringparam method, which allows the user to specify the size of the TX and RX descriptor rings. The values are constrained to the limits of the hardware. Since the driver does not use separate queues for mini or jumbo frames, attempts to set those values are rejected. If the interface is already running when the setting is changed, then the interface is reset. Signed-off-by: Timur Tabi <timur@codeaurora.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qualcomm/emac/emac-ethtool.c')
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-ethtool.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c b/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
index 758cd648d666..0d9945fb79be 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-ethtool.c
@@ -145,6 +145,29 @@ static void emac_get_ringparam(struct net_device *netdev,
ring->tx_pending = adpt->tx_desc_cnt;
}
+static int emac_set_ringparam(struct net_device *netdev,
+ struct ethtool_ringparam *ring)
+{
+ struct emac_adapter *adpt = netdev_priv(netdev);
+
+ /* We don't have separate queues/rings for small/large frames, so
+ * reject any attempt to specify those values separately.
+ */
+ if (ring->rx_mini_pending || ring->rx_jumbo_pending)
+ return -EINVAL;
+
+ adpt->tx_desc_cnt =
+ clamp_val(ring->tx_pending, EMAC_MIN_TX_DESCS, EMAC_MAX_TX_DESCS);
+
+ adpt->rx_desc_cnt =
+ clamp_val(ring->rx_pending, EMAC_MIN_RX_DESCS, EMAC_MAX_RX_DESCS);
+
+ if (netif_running(netdev))
+ return emac_reinit_locked(adpt);
+
+ return 0;
+}
+
static void emac_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause)
{
@@ -219,6 +242,7 @@ static const struct ethtool_ops emac_ethtool_ops = {
.get_ethtool_stats = emac_get_ethtool_stats,
.get_ringparam = emac_get_ringparam,
+ .set_ringparam = emac_set_ringparam,
.get_pauseparam = emac_get_pauseparam,
.set_pauseparam = emac_set_pauseparam,