Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9bdd4b5 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller
Browse files

[IP]: Introduce ip_hdrlen()



For the common sequence "skb->nh.iph->ihl * 4", removing a good number of open
coded skb->nh.iph uses, now to go after the rest...

Just out of curiosity, here are the idioms found to get the same result:

skb->nh.iph->ihl << 2
skb->nh.iph->ihl<<2
skb->nh.iph->ihl * 4
skb->nh.iph->ihl*4
(skb->nh.iph)->ihl * sizeof(u32)

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0272ffc4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4527,7 +4527,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
		if (skb->h.th->doff > 5) {
			tcp_opt_len = (skb->h.th->doff - 5) << 2;
		}
		ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr);
		ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);

		skb->nh.iph->check = 0;
		skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
+2 −2
Original line number Diff line number Diff line
@@ -1263,7 +1263,7 @@ static inline void write_ip_start_end(struct ehea_swqe *swqe,
				      const struct sk_buff *skb)
{
	swqe->ip_start = (u8)(((u64)skb->nh.iph) - ((u64)skb->data));
	swqe->ip_end = (u8)(swqe->ip_start + skb->nh.iph->ihl * 4 - 1);
	swqe->ip_end = (u8)(swqe->ip_start + ip_hdrlen(skb) - 1);
}

static inline void write_tcp_offset_end(struct ehea_swqe *swqe,
@@ -1300,7 +1300,7 @@ static void write_swqe2_TSO(struct sk_buff *skb,
	/* copy only eth/ip/tcp headers to immediate data and
	 * the rest of skb->data to sg1entry
	 */
	headersize = ETH_HLEN + (skb->nh.iph->ihl * 4) + (skb->h.th->doff * 4);
	headersize = ETH_HLEN + ip_hdrlen(skb) + (skb->h.th->doff * 4);

	skb_data_size = skb->len - skb->data_len;

+5 −3
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@
#include "netxen_nic_hw.h"
#include "netxen_nic_phan_reg.h"

#include <net/ip.h>

/*  PCI Windowing for DDR regions.  */

#define ADDR_IN_RANGE(addr, low, high)	\
@@ -371,9 +373,9 @@ void netxen_tso_check(struct netxen_adapter *adapter,
		      struct cmd_desc_type0 *desc, struct sk_buff *skb)
{
	if (desc->mss) {
		desc->total_hdr_length = sizeof(struct ethhdr) +
		    ((skb->nh.iph)->ihl * sizeof(u32)) +
		    ((skb->h.th)->doff * sizeof(u32));
		desc->total_hdr_length = (sizeof(struct ethhdr) +
					  ip_hdrlen(skb) +
					  skb->h.th->doff * 4);
		netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
	} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
		if (skb->nh.iph->protocol == IPPROTO_TCP) {
+3 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@

#include <linux/dma-mapping.h>
#include <linux/vmalloc.h>
#include <net/ip.h>

MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
MODULE_LICENSE("GPL");
@@ -778,9 +779,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
		if (skb_shinfo(skb)->gso_size > 0) {

			no_of_desc++;
			if (((skb->nh.iph)->ihl * sizeof(u32)) +
			    ((skb->h.th)->doff * sizeof(u32)) +
			    sizeof(struct ethhdr) >
			if ((ip_hdrlen(skb) + skb->h.th->doff * 4 +
			     sizeof(struct ethhdr)) >
			    (sizeof(struct cmd_desc_type0) - 2)) {
				no_of_desc++;
			}
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <linux/ethtool.h>
#include <linux/pci.h>
#include <linux/ip.h>
#include <net/ip.h>
#include <linux/tcp.h>
#include <linux/in.h>
#include <linux/delay.h>
@@ -1392,7 +1393,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
	mss = skb_shinfo(skb)->gso_size;
	if (mss != 0) {
		mss += ((skb->h.th->doff - 5) * 4);	/* TCP options */
		mss += (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
		mss += ip_hdrlen(skb) + sizeof(struct tcphdr);
		mss += ETH_HLEN;

		if (mss != sky2->tx_last_mss) {
Loading