[PATCH net-next 3/6] net: mvpp2: split the max ring size from the default one

2017-12-07 Thread Antoine Tenart
From: Yan Markman 

The Rx/Tx ring sizes can be adjusted thanks to ethtool given specific
network needs. This commit splits the default ring size from its max
value to allow ethtool to vary the parameters in both ways.

Signed-off-by: Yan Markman 
[Antoine: commit message]
Signed-off-by: Antoine Tenart 
---
 drivers/net/ethernet/marvell/mvpp2.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 2f86358614a6..1e4129f71071 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -504,10 +504,12 @@
 #define MVPP2_DEFAULT_RXQ  4
 
 /* Max number of Rx descriptors */
-#define MVPP2_MAX_RXD  128
+#define MVPP2_MAX_RXD_MAX  1024
+#define MVPP2_MAX_RXD_DFLT 128
 
 /* Max number of Tx descriptors */
-#define MVPP2_MAX_TXD  1024
+#define MVPP2_MAX_TXD_MAX  2048
+#define MVPP2_MAX_TXD_DFLT 1024
 
 /* Amount of Tx descriptors that can be reserved at once by CPU */
 #define MVPP2_CPU_DESC_CHUNK   64
@@ -6866,13 +6868,13 @@ static int mvpp2_check_ringparam_valid(struct 
net_device *dev,
if (ring->rx_pending == 0 || ring->tx_pending == 0)
return -EINVAL;
 
-   if (ring->rx_pending > MVPP2_MAX_RXD)
-   new_rx_pending = MVPP2_MAX_RXD;
+   if (ring->rx_pending > MVPP2_MAX_RXD_MAX)
+   new_rx_pending = MVPP2_MAX_RXD_MAX;
else if (!IS_ALIGNED(ring->rx_pending, 16))
new_rx_pending = ALIGN(ring->rx_pending, 16);
 
-   if (ring->tx_pending > MVPP2_MAX_TXD)
-   new_tx_pending = MVPP2_MAX_TXD;
+   if (ring->tx_pending > MVPP2_MAX_TXD_MAX)
+   new_tx_pending = MVPP2_MAX_TXD_MAX;
else if (!IS_ALIGNED(ring->tx_pending, 32))
new_tx_pending = ALIGN(ring->tx_pending, 32);
 
@@ -7374,8 +7376,8 @@ static void mvpp2_ethtool_get_ringparam(struct net_device 
*dev,
 {
struct mvpp2_port *port = netdev_priv(dev);
 
-   ring->rx_max_pending = MVPP2_MAX_RXD;
-   ring->tx_max_pending = MVPP2_MAX_TXD;
+   ring->rx_max_pending = MVPP2_MAX_RXD_MAX;
+   ring->tx_max_pending = MVPP2_MAX_TXD_MAX;
ring->rx_pending = port->rx_ring_size;
ring->tx_pending = port->tx_ring_size;
 }
@@ -7822,7 +7824,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
goto err_free_netdev;
}
 
-   dev->tx_queue_len = MVPP2_MAX_TXD;
+   dev->tx_queue_len = MVPP2_MAX_TXD_MAX;
dev->watchdog_timeo = 5 * HZ;
dev->netdev_ops = _netdev_ops;
dev->ethtool_ops = _eth_tool_ops;
@@ -7905,8 +7907,8 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 
mvpp2_port_copy_mac_addr(dev, priv, port_node, _from);
 
-   port->tx_ring_size = MVPP2_MAX_TXD;
-   port->rx_ring_size = MVPP2_MAX_RXD;
+   port->tx_ring_size = MVPP2_MAX_TXD_DFLT;
+   port->rx_ring_size = MVPP2_MAX_RXD_DFLT;
SET_NETDEV_DEV(dev, >dev);
 
err = mvpp2_port_init(port);
-- 
2.14.3



[PATCH net-next 3/6] net: mvpp2: split the max ring size from the default one

2017-12-07 Thread Antoine Tenart
From: Yan Markman 

The Rx/Tx ring sizes can be adjusted thanks to ethtool given specific
network needs. This commit splits the default ring size from its max
value to allow ethtool to vary the parameters in both ways.

Signed-off-by: Yan Markman 
[Antoine: commit message]
Signed-off-by: Antoine Tenart 
---
 drivers/net/ethernet/marvell/mvpp2.c | 24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 2f86358614a6..1e4129f71071 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -504,10 +504,12 @@
 #define MVPP2_DEFAULT_RXQ  4
 
 /* Max number of Rx descriptors */
-#define MVPP2_MAX_RXD  128
+#define MVPP2_MAX_RXD_MAX  1024
+#define MVPP2_MAX_RXD_DFLT 128
 
 /* Max number of Tx descriptors */
-#define MVPP2_MAX_TXD  1024
+#define MVPP2_MAX_TXD_MAX  2048
+#define MVPP2_MAX_TXD_DFLT 1024
 
 /* Amount of Tx descriptors that can be reserved at once by CPU */
 #define MVPP2_CPU_DESC_CHUNK   64
@@ -6866,13 +6868,13 @@ static int mvpp2_check_ringparam_valid(struct 
net_device *dev,
if (ring->rx_pending == 0 || ring->tx_pending == 0)
return -EINVAL;
 
-   if (ring->rx_pending > MVPP2_MAX_RXD)
-   new_rx_pending = MVPP2_MAX_RXD;
+   if (ring->rx_pending > MVPP2_MAX_RXD_MAX)
+   new_rx_pending = MVPP2_MAX_RXD_MAX;
else if (!IS_ALIGNED(ring->rx_pending, 16))
new_rx_pending = ALIGN(ring->rx_pending, 16);
 
-   if (ring->tx_pending > MVPP2_MAX_TXD)
-   new_tx_pending = MVPP2_MAX_TXD;
+   if (ring->tx_pending > MVPP2_MAX_TXD_MAX)
+   new_tx_pending = MVPP2_MAX_TXD_MAX;
else if (!IS_ALIGNED(ring->tx_pending, 32))
new_tx_pending = ALIGN(ring->tx_pending, 32);
 
@@ -7374,8 +7376,8 @@ static void mvpp2_ethtool_get_ringparam(struct net_device 
*dev,
 {
struct mvpp2_port *port = netdev_priv(dev);
 
-   ring->rx_max_pending = MVPP2_MAX_RXD;
-   ring->tx_max_pending = MVPP2_MAX_TXD;
+   ring->rx_max_pending = MVPP2_MAX_RXD_MAX;
+   ring->tx_max_pending = MVPP2_MAX_TXD_MAX;
ring->rx_pending = port->rx_ring_size;
ring->tx_pending = port->tx_ring_size;
 }
@@ -7822,7 +7824,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
goto err_free_netdev;
}
 
-   dev->tx_queue_len = MVPP2_MAX_TXD;
+   dev->tx_queue_len = MVPP2_MAX_TXD_MAX;
dev->watchdog_timeo = 5 * HZ;
dev->netdev_ops = _netdev_ops;
dev->ethtool_ops = _eth_tool_ops;
@@ -7905,8 +7907,8 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 
mvpp2_port_copy_mac_addr(dev, priv, port_node, _from);
 
-   port->tx_ring_size = MVPP2_MAX_TXD;
-   port->rx_ring_size = MVPP2_MAX_RXD;
+   port->tx_ring_size = MVPP2_MAX_TXD_DFLT;
+   port->rx_ring_size = MVPP2_MAX_RXD_DFLT;
SET_NETDEV_DEV(dev, >dev);
 
err = mvpp2_port_init(port);
-- 
2.14.3