net: ethernet: ti: cpsw: extend limits for cpsw_get/set_ringparam
authorIvan Khoronzhuk <[email protected]>
Sun, 8 Jan 2017 20:12:27 +0000 (22:12 +0200)
committerDavid S. Miller <[email protected]>
Mon, 9 Jan 2017 19:29:07 +0000 (14:29 -0500)
Allow to set number of descs close to possible values. In case of
minimum limit it's equal to number of channels to be able to set
at least one desc per channel. For maximum limit leave enough descs
number for tx channels.

Signed-off-by: Ivan Khoronzhuk <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/ti/cpsw.c

index f339268da11aa070fe3a1c707d01923dbd96c15d..02b03ee2e31484b2c84b214951494106e6716dcc 100644 (file)
@@ -2493,8 +2493,7 @@ static void cpsw_get_ringparam(struct net_device *ndev,
        /* not supported */
        ering->tx_max_pending = 0;
        ering->tx_pending = cpdma_get_num_tx_descs(cpsw->dma);
-       /* Max 90% RX buffers */
-       ering->rx_max_pending = (descs_pool_size * 9) / 10;
+       ering->rx_max_pending = descs_pool_size - CPSW_MAX_QUEUES;
        ering->rx_pending = cpdma_get_num_rx_descs(cpsw->dma);
 }
 
@@ -2509,8 +2508,8 @@ static int cpsw_set_ringparam(struct net_device *ndev,
        /* ignore ering->tx_pending - only rx_pending adjustment is supported */
 
        if (ering->rx_mini_pending || ering->rx_jumbo_pending ||
-           ering->rx_pending < (descs_pool_size / 10) ||
-           ering->rx_pending > ((descs_pool_size * 9) / 10))
+           ering->rx_pending < CPSW_MAX_QUEUES ||
+           ering->rx_pending > (descs_pool_size - CPSW_MAX_QUEUES))
                return -EINVAL;
 
        if (ering->rx_pending == cpdma_get_num_rx_descs(cpsw->dma))