ixgbe: set max desc to prevent total RSC packet size of 64K
authorAlexander Duyck <alexander.h.duyck@intel.com>
Sun, 17 May 2009 20:57:47 +0000 (20:57 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 May 2009 22:09:43 +0000 (15:09 -0700)
The performance of hardware RSC is greatly reduced if the total for max rsc
descriptors multiplied by the buffer size is greater than 65535.  To
prevent this we need to adjust the max rsc descriptors appropriately.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ixgbe/ixgbe.h
drivers/net/ixgbe/ixgbe_main.c

index d291d1cbe041f615e18bb33c44946eb880ff0b6b..05a24055ac2f75cb0cb3913b8afaed287856d29d 100644 (file)
@@ -75,6 +75,8 @@
 #define IXGBE_RXBUFFER_128   128    /* Used for packet split */
 #define IXGBE_RXBUFFER_256   256    /* Used for packet split */
 #define IXGBE_RXBUFFER_2048  2048
+#define IXGBE_RXBUFFER_4096  4096
+#define IXGBE_RXBUFFER_8192  8192
 #define IXGBE_MAX_RXBUFFER   16384  /* largest size for a single descriptor */
 
 #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
index b53f265011730e5b7e480448732c4440567c2cd1..4ab17ab7fbce22ee93587213acff888a8ba450a5 100644 (file)
@@ -1995,21 +1995,28 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
                        rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j));
                        rscctrl |= IXGBE_RSCCTL_RSCEN;
                        /*
-                        *  if packet split is enabled we can only support up
-                        *  to max frags + 1 descriptors.
+                        * we must limit the number of descriptors so that the
+                        * total size of max desc * buf_len is not greater
+                        * than 65535
                         */
-                       if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED)
-#if (MAX_SKB_FRAGS < 3)
-                               rscctrl |= IXGBE_RSCCTL_MAXDESC_1;
-#elif (MAX_SKB_FRAGS < 7)
-                               rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
-#elif (MAX_SKB_FRAGS < 15)
+                       if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
+#if (MAX_SKB_FRAGS > 16)
+                               rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
+#elif (MAX_SKB_FRAGS > 8)
                                rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
+#elif (MAX_SKB_FRAGS > 4)
+                               rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
 #else
-                               rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
+                               rscctrl |= IXGBE_RSCCTL_MAXDESC_1;
 #endif
-                       else
-                               rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
+                       } else {
+                               if (rx_buf_len < IXGBE_RXBUFFER_4096)
+                                       rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
+                               else if (rx_buf_len < IXGBE_RXBUFFER_8192)
+                                       rscctrl |= IXGBE_RSCCTL_MAXDESC_8;
+                               else
+                                       rscctrl |= IXGBE_RSCCTL_MAXDESC_4;
+                       }
                        IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl);
                }
                /* Disable RSC for ACK packets */