]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/ixgb/ixgb_main.c
ixgb and e1000: Use new function for copybreak tests
[net-next-2.6.git] / drivers / net / ixgb / ixgb_main.c
index d58ca6b578ccc9a9f80fbc3606eb9746341c5d13..c6b75c83100c91b782221bf3e7ae6f813ef43da5 100644 (file)
@@ -1921,6 +1921,31 @@ ixgb_rx_checksum(struct ixgb_adapter *adapter,
        }
 }
 
+/*
+ * this should improve performance for small packets with large amounts
+ * of reassembly being done in the stack
+ */
+static void ixgb_check_copybreak(struct net_device *netdev,
+                                struct ixgb_buffer *buffer_info,
+                                u32 length, struct sk_buff **skb)
+{
+       struct sk_buff *new_skb;
+
+       if (length > copybreak)
+               return;
+
+       new_skb = netdev_alloc_skb_ip_align(netdev, length);
+       if (!new_skb)
+               return;
+
+       skb_copy_to_linear_data_offset(new_skb, -NET_IP_ALIGN,
+                                      (*skb)->data - NET_IP_ALIGN,
+                                      length + NET_IP_ALIGN);
+       /* save the skb in buffer_info as good */
+       buffer_info->skb = *skb;
+       *skb = new_skb;
+}
+
 /**
  * ixgb_clean_rx_irq - Send received data up the network stack,
  * @adapter: board private structure
@@ -1957,11 +1982,14 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
 
                prefetch(skb->data - NET_IP_ALIGN);
 
-               if (++i == rx_ring->count) i = 0;
+               if (++i == rx_ring->count)
+                       i = 0;
                next_rxd = IXGB_RX_DESC(*rx_ring, i);
                prefetch(next_rxd);
 
-               if ((j = i + 1) == rx_ring->count) j = 0;
+               j = i + 1;
+               if (j == rx_ring->count)
+                       j = 0;
                next2_buffer = &rx_ring->buffer_info[j];
                prefetch(next2_buffer);
 
@@ -1997,25 +2025,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do)
                        goto rxdesc_done;
                }
 
-               /* code added for copybreak, this should improve
-                * performance for small packets with large amounts
-                * of reassembly being done in the stack */
-               if (length < copybreak) {
-                       struct sk_buff *new_skb =
-                           netdev_alloc_skb_ip_align(netdev, length);
-                       if (new_skb) {
-                               skb_copy_to_linear_data_offset(new_skb,
-                                                              -NET_IP_ALIGN,
-                                                              (skb->data -
-                                                               NET_IP_ALIGN),
-                                                              (length +
-                                                               NET_IP_ALIGN));
-                               /* save the skb in buffer_info as good */
-                               buffer_info->skb = skb;
-                               skb = new_skb;
-                       }
-               }
-               /* end copybreak code */
+               ixgb_check_copybreak(netdev, buffer_info, length, &skb);
 
                /* Good Receive */
                skb_put(skb, length);