aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-03-18 20:43:48 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:25:24 -0400
commitab6a5bb6b28a970104a34f0f6959b73cf61bdc72 (patch)
tree54cfa7d4fe00d0c28a60022b075afc0856d6fc2b /drivers/net
parent88c7664f13bd1a36acb8566b93892a4c58759ac6 (diff)
[TCP]: Introduce tcp_hdrlen() and tcp_optlen()
The ip_hdrlen() buddy, created to reduce the number of skb->h.th-> uses and to avoid the longer, open coded equivalent. Ditched a no-op in bnx2 in the process. I wonder if we should have a BUG_ON(skb->h.th->doff < 5) in tcp_optlen()... Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/atl1/atl1_main.c7
-rw-r--r--drivers/net/bnx2.c7
-rw-r--r--drivers/net/e1000/e1000_main.c4
-rw-r--r--drivers/net/ehea/ehea_main.c2
-rw-r--r--drivers/net/ixgb/ixgb_main.c2
-rw-r--r--drivers/net/myri10ge/myri10ge.c3
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c3
-rw-r--r--drivers/net/netxen/netxen_nic_main.c2
-rw-r--r--drivers/net/sky2.c2
-rw-r--r--drivers/net/tg3.c4
10 files changed, 16 insertions, 20 deletions
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c
index c26f8ce320e6..8d5994751e2e 100644
--- a/drivers/net/atl1/atl1_main.c
+++ b/drivers/net/atl1/atl1_main.c
@@ -1307,7 +1307,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
1307 1307
1308 tso->tsopl |= (iph->ihl & 1308 tso->tsopl |= (iph->ihl &
1309 CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT; 1309 CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT;
1310 tso->tsopl |= ((skb->h.th->doff << 2) & 1310 tso->tsopl |= (tcp_hdrlen(skb) &
1311 TSO_PARAM_TCPHDRLEN_MASK) << TSO_PARAM_TCPHDRLEN_SHIFT; 1311 TSO_PARAM_TCPHDRLEN_MASK) << TSO_PARAM_TCPHDRLEN_SHIFT;
1312 tso->tsopl |= (skb_shinfo(skb)->gso_size & 1312 tso->tsopl |= (skb_shinfo(skb)->gso_size &
1313 TSO_PARAM_MSS_MASK) << TSO_PARAM_MSS_SHIFT; 1313 TSO_PARAM_MSS_MASK) << TSO_PARAM_MSS_SHIFT;
@@ -1369,8 +1369,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter,
1369 1369
1370 if (tcp_seg) { 1370 if (tcp_seg) {
1371 /* TSO/GSO */ 1371 /* TSO/GSO */
1372 proto_hdr_len = (skb_transport_offset(skb) + 1372 proto_hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1373 (skb->h.th->doff << 2));
1374 buffer_info->length = proto_hdr_len; 1373 buffer_info->length = proto_hdr_len;
1375 page = virt_to_page(skb->data); 1374 page = virt_to_page(skb->data);
1376 offset = (unsigned long)skb->data & ~PAGE_MASK; 1375 offset = (unsigned long)skb->data & ~PAGE_MASK;
@@ -1563,7 +1562,7 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1563 if (mss) { 1562 if (mss) {
1564 if (skb->protocol == htons(ETH_P_IP)) { 1563 if (skb->protocol == htons(ETH_P_IP)) {
1565 proto_hdr_len = (skb_transport_offset(skb) + 1564 proto_hdr_len = (skb_transport_offset(skb) +
1566 (skb->h.th->doff << 2)); 1565 tcp_hdrlen(skb));
1567 if (unlikely(proto_hdr_len > len)) { 1566 if (unlikely(proto_hdr_len > len)) {
1568 dev_kfree_skb_any(skb); 1567 dev_kfree_skb_any(skb);
1569 return NETDEV_TX_OK; 1568 return NETDEV_TX_OK;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index eb0c4f1d4483..73512fb16452 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -4521,13 +4521,12 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4521 return NETDEV_TX_OK; 4521 return NETDEV_TX_OK;
4522 } 4522 }
4523 4523
4524 tcp_opt_len = ((skb->h.th->doff - 5) * 4);
4525 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO; 4524 vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;
4526 4525
4527 tcp_opt_len = 0; 4526 tcp_opt_len = 0;
4528 if (skb->h.th->doff > 5) { 4527 if (skb->h.th->doff > 5)
4529 tcp_opt_len = (skb->h.th->doff - 5) << 2; 4528 tcp_opt_len = tcp_optlen(skb);
4530 } 4529
4531 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); 4530 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
4532 4531
4533 iph = ip_hdr(skb); 4532 iph = ip_hdr(skb);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 78cf417cf236..4572fbba50f9 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2887,7 +2887,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2887 return err; 2887 return err;
2888 } 2888 }
2889 2889
2890 hdr_len = (skb_transport_offset(skb) + (skb->h.th->doff << 2)); 2890 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
2891 mss = skb_shinfo(skb)->gso_size; 2891 mss = skb_shinfo(skb)->gso_size;
2892 if (skb->protocol == htons(ETH_P_IP)) { 2892 if (skb->protocol == htons(ETH_P_IP)) {
2893 struct iphdr *iph = ip_hdr(skb); 2893 struct iphdr *iph = ip_hdr(skb);
@@ -3292,7 +3292,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3292 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data 3292 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
3293 * points to just header, pull a few bytes of payload from 3293 * points to just header, pull a few bytes of payload from
3294 * frags into skb->data */ 3294 * frags into skb->data */
3295 hdr_len = (skb_transport_offset(skb) + (skb->h.th->doff << 2)); 3295 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
3296 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) { 3296 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
3297 switch (adapter->hw.mac_type) { 3297 switch (adapter->hw.mac_type) {
3298 unsigned int pull_size; 3298 unsigned int pull_size;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 0dc701e611e5..63732d2305bb 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -1300,7 +1300,7 @@ static void write_swqe2_TSO(struct sk_buff *skb,
1300 /* copy only eth/ip/tcp headers to immediate data and 1300 /* copy only eth/ip/tcp headers to immediate data and
1301 * the rest of skb->data to sg1entry 1301 * the rest of skb->data to sg1entry
1302 */ 1302 */
1303 headersize = ETH_HLEN + ip_hdrlen(skb) + (skb->h.th->doff * 4); 1303 headersize = ETH_HLEN + ip_hdrlen(skb) + tcp_hdrlen(skb);
1304 1304
1305 skb_data_size = skb->len - skb->data_len; 1305 skb_data_size = skb->len - skb->data_len;
1306 1306
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index ceea6e45792d..96550d681623 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1190,7 +1190,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1190 return err; 1190 return err;
1191 } 1191 }
1192 1192
1193 hdr_len = (skb_transport_offset(skb) + (skb->h.th->doff << 2)); 1193 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1194 mss = skb_shinfo(skb)->gso_size; 1194 mss = skb_shinfo(skb)->gso_size;
1195 iph = ip_hdr(skb); 1195 iph = ip_hdr(skb);
1196 iph->tot_len = 0; 1196 iph->tot_len = 0;
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index e04228c7b14f..e4b69a0485ba 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2054,8 +2054,7 @@ again:
2054 * send loop that we are still in the 2054 * send loop that we are still in the
2055 * header portion of the TSO packet. 2055 * header portion of the TSO packet.
2056 * TSO header must be at most 134 bytes long */ 2056 * TSO header must be at most 134 bytes long */
2057 cum_len = -(skb_transport_offset(skb) + 2057 cum_len = -(skb_transport_offset(skb) + tcp_hdrlen(skb));
2058 (skb->h.th->doff << 2));
2059 2058
2060 /* for TSO, pseudo_hdr_offset holds mss. 2059 /* for TSO, pseudo_hdr_offset holds mss.
2061 * The firmware figures out where to put 2060 * The firmware figures out where to put
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 09ca2192cbfa..0fba8f190762 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -374,8 +374,7 @@ void netxen_tso_check(struct netxen_adapter *adapter,
374{ 374{
375 if (desc->mss) { 375 if (desc->mss) {
376 desc->total_hdr_length = (sizeof(struct ethhdr) + 376 desc->total_hdr_length = (sizeof(struct ethhdr) +
377 ip_hdrlen(skb) + 377 ip_hdrlen(skb) + tcp_hdrlen(skb));
378 skb->h.th->doff * 4);
379 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO); 378 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
380 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 379 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
381 if (ip_hdr(skb)->protocol == IPPROTO_TCP) { 380 if (ip_hdr(skb)->protocol == IPPROTO_TCP) {
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index b548a30e5c8e..b488e94bc4c0 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -779,7 +779,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
779 if (skb_shinfo(skb)->gso_size > 0) { 779 if (skb_shinfo(skb)->gso_size > 0) {
780 780
781 no_of_desc++; 781 no_of_desc++;
782 if ((ip_hdrlen(skb) + skb->h.th->doff * 4 + 782 if ((ip_hdrlen(skb) + tcp_hdrlen(skb) +
783 sizeof(struct ethhdr)) > 783 sizeof(struct ethhdr)) >
784 (sizeof(struct cmd_desc_type0) - 2)) { 784 (sizeof(struct cmd_desc_type0) - 2)) {
785 no_of_desc++; 785 no_of_desc++;
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index a35f2f2784ae..fd291fc93169 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1392,7 +1392,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1392 /* Check for TCP Segmentation Offload */ 1392 /* Check for TCP Segmentation Offload */
1393 mss = skb_shinfo(skb)->gso_size; 1393 mss = skb_shinfo(skb)->gso_size;
1394 if (mss != 0) { 1394 if (mss != 0) {
1395 mss += ((skb->h.th->doff - 5) * 4); /* TCP options */ 1395 mss += tcp_optlen(skb); /* TCP options */
1396 mss += ip_hdrlen(skb) + sizeof(struct tcphdr); 1396 mss += ip_hdrlen(skb) + sizeof(struct tcphdr);
1397 mss += ETH_HLEN; 1397 mss += ETH_HLEN;
1398 1398
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 76a31afe20de..7ca30d76bf6f 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -3911,7 +3911,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3911 else { 3911 else {
3912 struct iphdr *iph = ip_hdr(skb); 3912 struct iphdr *iph = ip_hdr(skb);
3913 3913
3914 tcp_opt_len = ((skb->h.th->doff - 5) * 4); 3914 tcp_opt_len = tcp_optlen(skb);
3915 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); 3915 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
3916 3916
3917 iph->check = 0; 3917 iph->check = 0;
@@ -4065,7 +4065,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4065 goto out_unlock; 4065 goto out_unlock;
4066 } 4066 }
4067 4067
4068 tcp_opt_len = ((skb->h.th->doff - 5) * 4); 4068 tcp_opt_len = tcp_optlen(skb);
4069 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); 4069 ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
4070 4070
4071 hdr_len = ip_tcp_len + tcp_opt_len; 4071 hdr_len = ip_tcp_len + tcp_opt_len;