amd-xgbe: Fix Rx coalescing reporting
authorLendacky, Thomas <Thomas.Lendacky@amd.com>
Fri, 20 Mar 2015 16:50:34 +0000 (11:50 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Mar 2015 20:33:57 +0000 (16:33 -0400)
The Rx coalescing value is internally converted from usecs to a value
that the hardware can use. When reporting the Rx coalescing value, this
internal value is converted back to usecs. During the conversion from
and back to usecs some rounding occurs. So, for example, when setting an
Rx usec of 30, it will be reported as 29. Fix this reporting issue by
keeping the original usec value and using that during reporting.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
drivers/net/ethernet/amd/xgbe/xgbe.h

index 122a631..fc362be 100644 (file)
@@ -702,6 +702,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
        DBGPR("-->xgbe_init_rx_coalesce\n");
 
        pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS);
+       pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS;
        pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES;
 
        hw_if->config_rx_coalesce(pdata);
index 376d6a5..b4f6eaa 100644 (file)
@@ -377,15 +377,12 @@ static int xgbe_get_coalesce(struct net_device *netdev,
                             struct ethtool_coalesce *ec)
 {
        struct xgbe_prv_data *pdata = netdev_priv(netdev);
-       struct xgbe_hw_if *hw_if = &pdata->hw_if;
-       unsigned int riwt;
 
        DBGPR("-->xgbe_get_coalesce\n");
 
        memset(ec, 0, sizeof(struct ethtool_coalesce));
 
-       riwt = pdata->rx_riwt;
-       ec->rx_coalesce_usecs = hw_if->riwt_to_usec(pdata, riwt);
+       ec->rx_coalesce_usecs = pdata->rx_usecs;
        ec->rx_max_coalesced_frames = pdata->rx_frames;
 
        ec->tx_max_coalesced_frames = pdata->tx_frames;
@@ -438,17 +435,17 @@ static int xgbe_set_coalesce(struct net_device *netdev,
        }
 
        rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs);
+       rx_usecs = ec->rx_coalesce_usecs;
        rx_frames = ec->rx_max_coalesced_frames;
 
        /* Use smallest possible value if conversion resulted in zero */
-       if (ec->rx_coalesce_usecs && !rx_riwt)
+       if (rx_usecs && !rx_riwt)
                rx_riwt = 1;
 
        /* Check the bounds of values for Rx */
        if (rx_riwt > XGMAC_MAX_DMA_RIWT) {
-               rx_usecs = hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT);
                netdev_alert(netdev, "rx-usec is limited to %d usecs\n",
-                            rx_usecs);
+                            hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT));
                return -EINVAL;
        }
        if (rx_frames > pdata->rx_desc_count) {
@@ -467,6 +464,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
        }
 
        pdata->rx_riwt = rx_riwt;
+       pdata->rx_usecs = rx_usecs;
        pdata->rx_frames = rx_frames;
        hw_if->config_rx_coalesce(pdata);
 
index 72b8f27..dd74242 100644 (file)
@@ -716,6 +716,7 @@ struct xgbe_prv_data {
 
        /* Rx coalescing settings */
        unsigned int rx_riwt;
+       unsigned int rx_usecs;
        unsigned int rx_frames;
 
        /* Current Rx buffer size */