Skip to content

Commit 4a57ebc

Browse files
tlendackydavem330
authored andcommitted
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>
1 parent c635eaa commit 4a57ebc

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ void xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
702702
DBGPR("-->xgbe_init_rx_coalesce\n");
703703

704704
pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS);
705+
pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS;
705706
pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES;
706707

707708
hw_if->config_rx_coalesce(pdata);

drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,12 @@ static int xgbe_get_coalesce(struct net_device *netdev,
377377
struct ethtool_coalesce *ec)
378378
{
379379
struct xgbe_prv_data *pdata = netdev_priv(netdev);
380-
struct xgbe_hw_if *hw_if = &pdata->hw_if;
381-
unsigned int riwt;
382380

383381
DBGPR("-->xgbe_get_coalesce\n");
384382

385383
memset(ec, 0, sizeof(struct ethtool_coalesce));
386384

387-
riwt = pdata->rx_riwt;
388-
ec->rx_coalesce_usecs = hw_if->riwt_to_usec(pdata, riwt);
385+
ec->rx_coalesce_usecs = pdata->rx_usecs;
389386
ec->rx_max_coalesced_frames = pdata->rx_frames;
390387

391388
ec->tx_max_coalesced_frames = pdata->tx_frames;
@@ -438,17 +435,17 @@ static int xgbe_set_coalesce(struct net_device *netdev,
438435
}
439436

440437
rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs);
438+
rx_usecs = ec->rx_coalesce_usecs;
441439
rx_frames = ec->rx_max_coalesced_frames;
442440

443441
/* Use smallest possible value if conversion resulted in zero */
444-
if (ec->rx_coalesce_usecs && !rx_riwt)
442+
if (rx_usecs && !rx_riwt)
445443
rx_riwt = 1;
446444

447445
/* Check the bounds of values for Rx */
448446
if (rx_riwt > XGMAC_MAX_DMA_RIWT) {
449-
rx_usecs = hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT);
450447
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));
452449
return -EINVAL;
453450
}
454451
if (rx_frames > pdata->rx_desc_count) {
@@ -467,6 +464,7 @@ static int xgbe_set_coalesce(struct net_device *netdev,
467464
}
468465

469466
pdata->rx_riwt = rx_riwt;
467+
pdata->rx_usecs = rx_usecs;
470468
pdata->rx_frames = rx_frames;
471469
hw_if->config_rx_coalesce(pdata);
472470

drivers/net/ethernet/amd/xgbe/xgbe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ struct xgbe_prv_data {
716716

717717
/* Rx coalescing settings */
718718
unsigned int rx_riwt;
719+
unsigned int rx_usecs;
719720
unsigned int rx_frames;
720721

721722
/* Current Rx buffer size */

0 commit comments

Comments
 (0)