Skip to content

Commit 1a1aa35

Browse files
mmaloszeanguy11
authored andcommitted
iavf: Fix reporting when setting descriptor count
iavf_set_ringparams doesn't communicate to the user that 1. The user requested descriptor count is out of range. Instead it just quietly sets descriptors to the "clamped" value and calls it done. This makes it look an invalid value was successfully set as the descriptor count when this isn't actually true. 2. The user provided descriptor count needs to be inflated for alignment reasons. This behavior is confusing. The ice driver has already addressed this by rejecting invalid values for descriptor count and messaging for alignment adjustments. Do the same thing here by adding the error and info messages. Fixes: fbb7ddf ("i40evf: core ethtool functionality") Signed-off-by: Anirudh Venkataramanan <[email protected]> Signed-off-by: Michal Maloszewski <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 7e4dcc1 commit 1a1aa35

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,23 +615,44 @@ static int iavf_set_ringparam(struct net_device *netdev,
615615
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
616616
return -EINVAL;
617617

618-
new_tx_count = clamp_t(u32, ring->tx_pending,
619-
IAVF_MIN_TXD,
620-
IAVF_MAX_TXD);
621-
new_tx_count = ALIGN(new_tx_count, IAVF_REQ_DESCRIPTOR_MULTIPLE);
618+
if (ring->tx_pending > IAVF_MAX_TXD ||
619+
ring->tx_pending < IAVF_MIN_TXD ||
620+
ring->rx_pending > IAVF_MAX_RXD ||
621+
ring->rx_pending < IAVF_MIN_RXD) {
622+
netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n",
623+
ring->tx_pending, ring->rx_pending, IAVF_MIN_TXD,
624+
IAVF_MAX_RXD, IAVF_REQ_DESCRIPTOR_MULTIPLE);
625+
return -EINVAL;
626+
}
622627

623-
new_rx_count = clamp_t(u32, ring->rx_pending,
624-
IAVF_MIN_RXD,
625-
IAVF_MAX_RXD);
626-
new_rx_count = ALIGN(new_rx_count, IAVF_REQ_DESCRIPTOR_MULTIPLE);
628+
new_tx_count = ALIGN(ring->tx_pending, IAVF_REQ_DESCRIPTOR_MULTIPLE);
629+
if (new_tx_count != ring->tx_pending)
630+
netdev_info(netdev, "Requested Tx descriptor count rounded up to %d\n",
631+
new_tx_count);
632+
633+
new_rx_count = ALIGN(ring->rx_pending, IAVF_REQ_DESCRIPTOR_MULTIPLE);
634+
if (new_rx_count != ring->rx_pending)
635+
netdev_info(netdev, "Requested Rx descriptor count rounded up to %d\n",
636+
new_rx_count);
627637

628638
/* if nothing to do return success */
629639
if ((new_tx_count == adapter->tx_desc_count) &&
630-
(new_rx_count == adapter->rx_desc_count))
640+
(new_rx_count == adapter->rx_desc_count)) {
641+
netdev_dbg(netdev, "Nothing to change, descriptor count is same as requested\n");
631642
return 0;
643+
}
632644

633-
adapter->tx_desc_count = new_tx_count;
634-
adapter->rx_desc_count = new_rx_count;
645+
if (new_tx_count != adapter->tx_desc_count) {
646+
netdev_dbg(netdev, "Changing Tx descriptor count from %d to %d\n",
647+
adapter->tx_desc_count, new_tx_count);
648+
adapter->tx_desc_count = new_tx_count;
649+
}
650+
651+
if (new_rx_count != adapter->rx_desc_count) {
652+
netdev_dbg(netdev, "Changing Rx descriptor count from %d to %d\n",
653+
adapter->rx_desc_count, new_rx_count);
654+
adapter->rx_desc_count = new_rx_count;
655+
}
635656

636657
if (netif_running(netdev)) {
637658
adapter->flags |= IAVF_FLAG_RESET_NEEDED;

0 commit comments

Comments
 (0)