]> err.no Git - linux-2.6/blobdiff - drivers/net/e1000/e1000_main.c
[TCP]: Introduce tcp_hdrlen() and tcp_optlen()
[linux-2.6] / drivers / net / e1000 / e1000_main.c
index 1d08e937af825421009ba1071190ac1dc5049a9c..4572fbba50f9d45531befcd5f67890d8ed9e208c 100644 (file)
@@ -2887,32 +2887,28 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
                                return err;
                }
 
-               hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
+               hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
                mss = skb_shinfo(skb)->gso_size;
                if (skb->protocol == htons(ETH_P_IP)) {
-                       skb->nh.iph->tot_len = 0;
-                       skb->nh.iph->check = 0;
-                       skb->h.th->check =
-                               ~csum_tcpudp_magic(skb->nh.iph->saddr,
-                                                  skb->nh.iph->daddr,
-                                                  0,
-                                                  IPPROTO_TCP,
-                                                  0);
+                       struct iphdr *iph = ip_hdr(skb);
+                       iph->tot_len = 0;
+                       iph->check = 0;
+                       skb->h.th->check = ~csum_tcpudp_magic(iph->saddr,
+                                                             iph->daddr, 0,
+                                                             IPPROTO_TCP, 0);
                        cmd_length = E1000_TXD_CMD_IP;
-                       ipcse = skb->h.raw - skb->data - 1;
+                       ipcse = skb_transport_offset(skb) - 1;
                } else if (skb->protocol == htons(ETH_P_IPV6)) {
-                       skb->nh.ipv6h->payload_len = 0;
+                       ipv6_hdr(skb)->payload_len = 0;
                        skb->h.th->check =
-                               ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
-                                                &skb->nh.ipv6h->daddr,
-                                                0,
-                                                IPPROTO_TCP,
-                                                0);
+                               ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
+                                                &ipv6_hdr(skb)->daddr,
+                                                0, IPPROTO_TCP, 0);
                        ipcse = 0;
                }
-               ipcss = skb->nh.raw - skb->data;
-               ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
-               tucss = skb->h.raw - skb->data;
+               ipcss = skb_network_offset(skb);
+               ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
+               tucss = skb_transport_offset(skb);
                tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
                tucse = 0;
 
@@ -2954,7 +2950,7 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
        uint8_t css;
 
        if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
-               css = skb->h.raw - skb->data;
+               css = skb_transport_offset(skb);
 
                i = tx_ring->next_to_use;
                buffer_info = &tx_ring->buffer_info[i];
@@ -3296,7 +3292,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
                * points to just header, pull a few bytes of payload from
                * frags into skb->data */
-               hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
+               hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
                if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
                        switch (adapter->hw.mac_type) {
                                unsigned int pull_size;
@@ -3796,7 +3792,7 @@ e1000_intr_msi(int irq, void *data)
 
        for (i = 0; i < E1000_MAX_INTR; i++)
                if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
-                  e1000_clean_tx_irq(adapter, adapter->tx_ring)))
+                  !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
                        break;
 
        if (likely(adapter->itr_setting & 3))
@@ -3899,7 +3895,7 @@ e1000_intr(int irq, void *data)
 
        for (i = 0; i < E1000_MAX_INTR; i++)
                if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
-                  e1000_clean_tx_irq(adapter, adapter->tx_ring)))
+                  !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
                        break;
 
        if (likely(adapter->itr_setting & 3))
@@ -3949,7 +3945,7 @@ e1000_clean(struct net_device *poll_dev, int *budget)
        poll_dev->quota -= work_done;
 
        /* If no Tx and not enough Rx work done, exit the polling mode */
-       if ((tx_cleaned && (work_done < work_to_do)) ||
+       if ((!tx_cleaned && (work_done == 0)) ||
           !netif_running(poll_dev)) {
 quit_polling:
                if (likely(adapter->itr_setting & 3))
@@ -3979,7 +3975,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
 #ifdef CONFIG_E1000_NAPI
        unsigned int count = 0;
 #endif
-       boolean_t cleaned = TRUE;
+       boolean_t cleaned = FALSE;
        unsigned int total_tx_bytes=0, total_tx_packets=0;
 
        i = tx_ring->next_to_clean;
@@ -4013,10 +4009,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
 #ifdef CONFIG_E1000_NAPI
 #define E1000_TX_WEIGHT 64
                /* weight of a sort for tx, to avoid endless transmit cleanup */
-               if (count++ == E1000_TX_WEIGHT) {
-                       cleaned = FALSE;
-                       break;
-               }
+               if (count++ == E1000_TX_WEIGHT) break;
 #endif
        }