aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
diff options
context:
space:
mode:
authorLendacky, Thomas <Thomas.Lendacky@amd.com>2015-03-20 12:50:34 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-20 16:33:57 -0400
commit4a57ebcc2c1e8a924c3897df2c11c5d4620ec89e (patch)
treede0886860782befd0b2730bb6097e028f189ad28 /drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
parentc635eaacbf77bd6dae917925ef1e76d044b0da07 (diff)
amd-xgbe: Fix Rx coalescing reporting
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>
Diffstat (limited to 'drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c')
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
index 376d6a529ea1..b4f6eaaa08f0 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
@@ -377,15 +377,12 @@ static int xgbe_get_coalesce(struct net_device *netdev,
377 struct ethtool_coalesce *ec) 377 struct ethtool_coalesce *ec)
378{ 378{
379 struct xgbe_prv_data *pdata = netdev_priv(netdev); 379 struct xgbe_prv_data *pdata = netdev_priv(netdev);
380 struct xgbe_hw_if *hw_if = &pdata->hw_if;
381 unsigned int riwt;
382 380
383 DBGPR("-->xgbe_get_coalesce\n"); 381 DBGPR("-->xgbe_get_coalesce\n");
384 382
385 memset(ec, 0, sizeof(struct ethtool_coalesce)); 383 memset(ec, 0, sizeof(struct ethtool_coalesce));
386 384
387 riwt = pdata->rx_riwt; 385 ec->rx_coalesce_usecs = pdata->rx_usecs;
388 ec->rx_coalesce_usecs = hw_if->riwt_to_usec(pdata, riwt);
389 ec->rx_max_coalesced_frames = pdata->rx_frames; 386 ec->rx_max_coalesced_frames = pdata->rx_frames;
390 387
391 ec->tx_max_coalesced_frames = pdata->tx_frames; 388 ec->tx_max_coalesced_frames = pdata->tx_frames;
@@ -438,17 +435,17 @@ static int xgbe_set_coalesce(struct net_device *netdev,
438 } 435 }
439 436
440 rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs); 437 rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs);
438 rx_usecs = ec->rx_coalesce_usecs;
441 rx_frames = ec->rx_max_coalesced_frames; 439 rx_frames = ec->rx_max_coalesced_frames;
442 440
443 /* Use smallest possible value if conversion resulted in zero */ 441 /* Use smallest possible value if conversion resulted in zero */
444 if (ec->rx_coalesce_usecs && !rx_riwt) 442 if (rx_usecs && !rx_riwt)
445 rx_riwt = 1; 443 rx_riwt = 1;
446 444
447 /* Check the bounds of values for Rx */ 445 /* Check the bounds of values for Rx */
448 if (rx_riwt > XGMAC_MAX_DMA_RIWT) { 446 if (rx_riwt > XGMAC_MAX_DMA_RIWT) {
449 rx_usecs = hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT);
450 netdev_alert(netdev, "rx-usec is limited to %d usecs\n", 447 netdev_alert(netdev, "rx-usec is limited to %d usecs\n",
451 rx_usecs); 448 hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT));
452 return -EINVAL; 449 return -EINVAL;
453 } 450 }
454 if (rx_frames > pdata->rx_desc_count) { 451 if (rx_frames > pdata->rx_desc_count) {
@@ -467,6 +464,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
467 } 464 }
468 465
469 pdata->rx_riwt = rx_riwt; 466 pdata->rx_riwt = rx_riwt;
467 pdata->rx_usecs = rx_usecs;
470 pdata->rx_frames = rx_frames; 468 pdata->rx_frames = rx_frames;
471 hw_if->config_rx_coalesce(pdata); 469 hw_if->config_rx_coalesce(pdata);
472 470