OSDN Git Service

ixgbe: change MAX_RXD/MAX_TXD based on adapter type
authorDaniel Willenson <daniel@veobot.com>
Mon, 17 Oct 2022 15:52:59 +0000 (11:52 -0400)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 4 Nov 2022 18:09:57 +0000 (11:09 -0700)
Set the length limit for the receive descriptor buffer and transmit
descriptor buffer based on the controller type. The values used are called
out in the controller datasheets as a 'Note:' in the RDLEN and TDLEN
register descriptions.

This allows the user to use ethtool to allocate larger descriptor buffers
in the case where data is received or transmitted too quickly for the
driver to keep up.

Signed-off-by: Daniel Willenson <daniel@veobot.com>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c

index 5369a97..bc68b8f 100644 (file)
 /* TX/RX descriptor defines */
 #define IXGBE_DEFAULT_TXD                  512
 #define IXGBE_DEFAULT_TX_WORK              256
-#define IXGBE_MAX_TXD                     4096
+#define IXGBE_MAX_TXD_82598               4096
+#define IXGBE_MAX_TXD_82599               8192
+#define IXGBE_MAX_TXD_X540                8192
+#define IXGBE_MAX_TXD_X550               32768
 #define IXGBE_MIN_TXD                       64
 
 #if (PAGE_SIZE < 8192)
 #else
 #define IXGBE_DEFAULT_RXD                  128
 #endif
-#define IXGBE_MAX_RXD                     4096
+#define IXGBE_MAX_RXD_82598               4096
+#define IXGBE_MAX_RXD_82599               8192
+#define IXGBE_MAX_RXD_X540                8192
+#define IXGBE_MAX_RXD_X550               32768
 #define IXGBE_MIN_RXD                       64
 
 /* flow control */
index eda7188..d737e85 100644 (file)
@@ -1117,6 +1117,42 @@ static void ixgbe_get_drvinfo(struct net_device *netdev,
        drvinfo->n_priv_flags = IXGBE_PRIV_FLAGS_STR_LEN;
 }
 
+static u32 ixgbe_get_max_rxd(struct ixgbe_adapter *adapter)
+{
+       switch (adapter->hw.mac.type) {
+       case ixgbe_mac_82598EB:
+               return IXGBE_MAX_RXD_82598;
+       case ixgbe_mac_82599EB:
+               return IXGBE_MAX_RXD_82599;
+       case ixgbe_mac_X540:
+               return IXGBE_MAX_RXD_X540;
+       case ixgbe_mac_X550:
+       case ixgbe_mac_X550EM_x:
+       case ixgbe_mac_x550em_a:
+               return IXGBE_MAX_RXD_X550;
+       default:
+               return IXGBE_MAX_RXD_82598;
+       }
+}
+
+static u32 ixgbe_get_max_txd(struct ixgbe_adapter *adapter)
+{
+       switch (adapter->hw.mac.type) {
+       case ixgbe_mac_82598EB:
+               return IXGBE_MAX_TXD_82598;
+       case ixgbe_mac_82599EB:
+               return IXGBE_MAX_TXD_82599;
+       case ixgbe_mac_X540:
+               return IXGBE_MAX_TXD_X540;
+       case ixgbe_mac_X550:
+       case ixgbe_mac_X550EM_x:
+       case ixgbe_mac_x550em_a:
+               return IXGBE_MAX_TXD_X550;
+       default:
+               return IXGBE_MAX_TXD_82598;
+       }
+}
+
 static void ixgbe_get_ringparam(struct net_device *netdev,
                                struct ethtool_ringparam *ring,
                                struct kernel_ethtool_ringparam *kernel_ring,
@@ -1126,8 +1162,8 @@ static void ixgbe_get_ringparam(struct net_device *netdev,
        struct ixgbe_ring *tx_ring = adapter->tx_ring[0];
        struct ixgbe_ring *rx_ring = adapter->rx_ring[0];
 
-       ring->rx_max_pending = IXGBE_MAX_RXD;
-       ring->tx_max_pending = IXGBE_MAX_TXD;
+       ring->rx_max_pending = ixgbe_get_max_rxd(adapter);
+       ring->tx_max_pending = ixgbe_get_max_txd(adapter);
        ring->rx_pending = rx_ring->count;
        ring->tx_pending = tx_ring->count;
 }
@@ -1146,11 +1182,11 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
                return -EINVAL;
 
        new_tx_count = clamp_t(u32, ring->tx_pending,
-                              IXGBE_MIN_TXD, IXGBE_MAX_TXD);
+                              IXGBE_MIN_TXD, ixgbe_get_max_txd(adapter));
        new_tx_count = ALIGN(new_tx_count, IXGBE_REQ_TX_DESCRIPTOR_MULTIPLE);
 
        new_rx_count = clamp_t(u32, ring->rx_pending,
-                              IXGBE_MIN_RXD, IXGBE_MAX_RXD);
+                              IXGBE_MIN_RXD, ixgbe_get_max_rxd(adapter));
        new_rx_count = ALIGN(new_rx_count, IXGBE_REQ_RX_DESCRIPTOR_MULTIPLE);
 
        if ((new_tx_count == adapter->tx_ring_count) &&