Skip to content

Commit

Permalink
[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
acmel authored and David S. Miller committed Apr 26, 2007
1 parent e023dd6 commit eddc9ec
Show file tree
Hide file tree
Showing 132 changed files with 565 additions and 564 deletions.
2 changes: 1 addition & 1 deletion drivers/ieee1394/eth1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
if (memcmp(eth->h_dest, dev->broadcast, ETH1394_ALEN) == 0 ||
proto == htons(ETH_P_ARP) ||
(proto == htons(ETH_P_IP) &&
IN_MULTICAST(ntohl(skb->nh.iph->daddr)))) {
IN_MULTICAST(ntohl(ip_hdr(skb)->daddr)))) {
tx_type = ETH1394_GASP;
dest_node = LOCAL_BUS | ALL_NODES;
max_payload = priv->bc_maxpayload - ETHER1394_GASP_OVERHEAD;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/8139cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
if (mss)
flags |= LargeSend | ((mss & MSSMask) << MSSShift);
else if (skb->ip_summed == CHECKSUM_PARTIAL) {
const struct iphdr *ip = skb->nh.iph;
const struct iphdr *ip = ip_hdr(skb);
if (ip->protocol == IPPROTO_TCP)
flags |= IPCS | TCPCS;
else if (ip->protocol == IPPROTO_UDP)
Expand All @@ -825,7 +825,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
u32 first_len, first_eor;
dma_addr_t first_mapping;
int frag, first_entry = entry;
const struct iphdr *ip = skb->nh.iph;
const struct iphdr *ip = ip_hdr(skb);

/* We must give this initial chunk to the device last.
* Otherwise we could race with the device.
Expand Down
15 changes: 8 additions & 7 deletions drivers/net/atl1/atl1_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,17 +1294,18 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
}

if (skb->protocol == ntohs(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);
ipofst = skb_network_offset(skb);
if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;

tso->tsopl |= (skb->nh.iph->ihl &
tso->tsopl |= (iph->ihl &
CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT;
tso->tsopl |= ((skb->h.th->doff << 2) &
TSO_PARAM_TCPHDRLEN_MASK) << TSO_PARAM_TCPHDRLEN_SHIFT;
Expand Down
18 changes: 9 additions & 9 deletions drivers/net/bnx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4513,6 +4513,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
if ((mss = skb_shinfo(skb)->gso_size) &&
(skb->len > (bp->dev->mtu + ETH_HLEN))) {
u32 tcp_opt_len, ip_tcp_len;
struct iphdr *iph;

if (skb_header_cloned(skb) &&
pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
Expand All @@ -4529,16 +4530,15 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
}
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);
skb->h.th->check =
~csum_tcpudp_magic(skb->nh.iph->saddr,
skb->nh.iph->daddr,
0, IPPROTO_TCP, 0);
iph = ip_hdr(skb);
iph->check = 0;
iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
skb->h.th->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
0, IPPROTO_TCP, 0);

if (tcp_opt_len || (skb->nh.iph->ihl > 5)) {
vlan_tag_flags |= ((skb->nh.iph->ihl - 5) +
(tcp_opt_len >> 2)) << 8;
if (tcp_opt_len || (iph->ihl > 5)) {
vlan_tag_flags |= ((iph->ihl - 5) +
(tcp_opt_len >> 2)) << 8;
}
}
else
Expand Down
17 changes: 10 additions & 7 deletions drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static inline struct arp_pkt *arp_pkt(const struct sk_buff *skb)
/* Forward declaration */
static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]);

static inline u8 _simple_hash(u8 *hash_start, int hash_size)
static inline u8 _simple_hash(const u8 *hash_start, int hash_size)
{
int i;
u8 hash = 0;
Expand Down Expand Up @@ -1268,7 +1268,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
int hash_size = 0;
int do_tx_balance = 1;
u32 hash_index = 0;
u8 *hash_start = NULL;
const u8 *hash_start = NULL;
int res = 1;

skb_reset_mac_header(skb);
Expand All @@ -1285,15 +1285,18 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
}

switch (ntohs(skb->protocol)) {
case ETH_P_IP:
case ETH_P_IP: {
const struct iphdr *iph = ip_hdr(skb);

if ((memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) ||
(skb->nh.iph->daddr == ip_bcast) ||
(skb->nh.iph->protocol == IPPROTO_IGMP)) {
(iph->daddr == ip_bcast) ||
(iph->protocol == IPPROTO_IGMP)) {
do_tx_balance = 0;
break;
}
hash_start = (char*)&(skb->nh.iph->daddr);
hash_size = sizeof(skb->nh.iph->daddr);
hash_start = (char *)&(iph->daddr);
hash_size = sizeof(iph->daddr);
}
break;
case ETH_P_IPV6:
if (memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3476,7 +3476,7 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb,
struct net_device *bond_dev, int count)
{
struct ethhdr *data = (struct ethhdr *)skb->data;
struct iphdr *iph = skb->nh.iph;
struct iphdr *iph = ip_hdr(skb);
u16 *layer4hdr = (u16 *)((u32 *)iph + iph->ihl);
int layer4_xor = 0;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/chelsio/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));
hdr->opcode = CPL_TX_PKT_LSO;
hdr->ip_csum_dis = hdr->l4_csum_dis = 0;
hdr->ip_hdr_words = skb->nh.iph->ihl;
hdr->ip_hdr_words = ip_hdr(skb)->ihl;
hdr->tcp_hdr_words = skb->h.th->doff;
hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
skb_shinfo(skb)->gso_size));
Expand Down Expand Up @@ -1912,7 +1912,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)

if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
skb->ip_summed == CHECKSUM_PARTIAL &&
skb->nh.iph->protocol == IPPROTO_UDP) {
ip_hdr(skb)->protocol == IPPROTO_UDP) {
if (unlikely(skb_checksum_help(skb))) {
pr_debug("%s: unable to do udp checksum\n", dev->name);
dev_kfree_skb_any(skb);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/cxgb3/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
eth_type = skb_network_offset(skb) == ETH_HLEN ?
CPL_ETH_II : CPL_ETH_II_VLAN;
tso_info |= V_LSO_ETH_TYPE(eth_type) |
V_LSO_IPHDR_WORDS(skb->nh.iph->ihl) |
V_LSO_IPHDR_WORDS(ip_hdr(skb)->ihl) |
V_LSO_TCPHDR_WORDS(skb->h.th->doff);
hdr->lso_info = htonl(tso_info);
flits = 3;
Expand Down
16 changes: 7 additions & 9 deletions drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2890,14 +2890,12 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
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;
} else if (skb->protocol == htons(ETH_P_IPV6)) {
Expand All @@ -2911,7 +2909,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
ipcse = 0;
}
ipcss = skb_network_offset(skb);
ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
tucss = skb->h.raw - skb->data;
tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
tucse = 0;
Expand Down
20 changes: 11 additions & 9 deletions drivers/net/ehea/ehea_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ static int ehea_clean_portres(struct ehea_port *port, struct ehea_port_res *pr)
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_start = skb_network_offset(skb);
swqe->ip_end = (u8)(swqe->ip_start + ip_hdrlen(skb) - 1);
}

Expand Down Expand Up @@ -1688,6 +1688,7 @@ static void ehea_xmit2(struct sk_buff *skb, struct net_device *dev,
struct ehea_swqe *swqe, u32 lkey)
{
if (skb->protocol == htons(ETH_P_IP)) {
const struct iphdr *iph = ip_hdr(skb);
/* IPv4 */
swqe->tx_control |= EHEA_SWQE_CRC
| EHEA_SWQE_IP_CHECKSUM
Expand All @@ -1697,15 +1698,15 @@ static void ehea_xmit2(struct sk_buff *skb, struct net_device *dev,

write_ip_start_end(swqe, skb);

if (skb->nh.iph->protocol == IPPROTO_UDP) {
if ((skb->nh.iph->frag_off & IP_MF) ||
(skb->nh.iph->frag_off & IP_OFFSET))
if (iph->protocol == IPPROTO_UDP) {
if ((iph->frag_off & IP_MF) ||
(iph->frag_off & IP_OFFSET))
/* IP fragment, so don't change cs */
swqe->tx_control &= ~EHEA_SWQE_TCP_CHECKSUM;
else
write_udp_offset_end(swqe, skb);

} else if (skb->nh.iph->protocol == IPPROTO_TCP) {
} else if (iph->protocol == IPPROTO_TCP) {
write_tcp_offset_end(swqe, skb);
}

Expand All @@ -1731,20 +1732,21 @@ static void ehea_xmit3(struct sk_buff *skb, struct net_device *dev,
int i;

if (skb->protocol == htons(ETH_P_IP)) {
const struct iphdr *iph = ip_hdr(skb);
/* IPv4 */
write_ip_start_end(swqe, skb);

if (skb->nh.iph->protocol == IPPROTO_TCP) {
if (iph->protocol == IPPROTO_TCP) {
swqe->tx_control |= EHEA_SWQE_CRC
| EHEA_SWQE_IP_CHECKSUM
| EHEA_SWQE_TCP_CHECKSUM
| EHEA_SWQE_IMM_DATA_PRESENT;

write_tcp_offset_end(swqe, skb);

} else if (skb->nh.iph->protocol == IPPROTO_UDP) {
if ((skb->nh.iph->frag_off & IP_MF) ||
(skb->nh.iph->frag_off & IP_OFFSET))
} else if (iph->protocol == IPPROTO_UDP) {
if ((iph->frag_off & IP_MF) ||
(iph->frag_off & IP_OFFSET))
/* IP fragment, so don't change cs */
swqe->tx_control |= EHEA_SWQE_CRC
| EHEA_SWQE_IMM_DATA_PRESENT;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/gianfar.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)

/* Tell the controller what the protocol is */
/* And provide the already calculated phcs */
if (skb->nh.iph->protocol == IPPROTO_UDP) {
if (ip_hdr(skb)->protocol == IPPROTO_UDP) {
flags |= TXFCB_UDP;
fcb->phcs = skb->h.uh->check;
} else
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ioc3-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1393,9 +1393,9 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
* manually.
*/
if (skb->ip_summed == CHECKSUM_PARTIAL) {
int proto = ntohs(skb->nh.iph->protocol);
const struct iphdr *ih = ip_hdr(skb);
const int proto = ntohs(ih->protocol);
unsigned int csoff;
struct iphdr *ih = skb->nh.iph;
uint32_t csum, ehsum;
uint16_t *eh;

Expand Down
12 changes: 7 additions & 5 deletions drivers/net/ixgb/ixgb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,8 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)

if (likely(skb_is_gso(skb))) {
struct ixgb_buffer *buffer_info;
struct iphdr *iph;

if (skb_header_cloned(skb)) {
err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
if (err)
Expand All @@ -1190,13 +1192,13 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)

hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
mss = skb_shinfo(skb)->gso_size;
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,
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);
ipcss = skb_network_offset(skb);
ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
ipcso = (void *)&(iph->check) - (void *)skb->data;
ipcse = skb->h.raw - skb->data - 1;
tucss = skb->h.raw - skb->data;
tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats);
#ifdef LOOPBACK_TSO
static void emulate_large_send_offload(struct sk_buff *skb)
{
struct iphdr *iph = skb->nh.iph;
struct iphdr *iph = ip_hdr(skb);
struct tcphdr *th = (struct tcphdr *)(skb_network_header(skb) +
(iph->ihl * 4));
unsigned int doffset = (iph->ihl + th->doff) * 4;
Expand All @@ -93,7 +93,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
skb_reserve(nskb, 32);
skb_set_mac_header(nskb, -ETH_HLEN);
skb_reset_network_header(nskb);
iph = nskb->nh.iph;
iph = ip_hdr(nskb);
memcpy(nskb->data, skb_network_header(skb), doffset);
if (skb_copy_bits(skb,
doffset + offset,
Expand Down Expand Up @@ -145,7 +145,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
#ifdef LOOPBACK_TSO
if (skb_is_gso(skb)) {
BUG_ON(skb->protocol != htons(ETH_P_IP));
BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
BUG_ON(ip_hdr(skb)->protocol != IPPROTO_TCP);

emulate_large_send_offload(skb);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,9 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,

cmd_sts |= ETH_GEN_TCP_UDP_CHECKSUM |
ETH_GEN_IP_V_4_CHECKSUM |
skb->nh.iph->ihl << ETH_TX_IHL_SHIFT;
ip_hdr(skb)->ihl << ETH_TX_IHL_SHIFT;

switch (skb->nh.iph->protocol) {
switch (ip_hdr(skb)->protocol) {
case IPPROTO_UDP:
cmd_sts |= ETH_UDP_FRAME;
desc->l4i_chk = skb->h.uh->check;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/netxen/netxen_nic_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ void netxen_tso_check(struct netxen_adapter *adapter,
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) {
if (ip_hdr(skb)->protocol == IPPROTO_TCP) {
netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT);
} else if (skb->nh.iph->protocol == IPPROTO_UDP) {
} else if (ip_hdr(skb)->protocol == IPPROTO_UDP) {
netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT);
} else {
return;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ns83820.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,9 @@ static int ns83820_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
extsts = 0;
if (skb->ip_summed == CHECKSUM_PARTIAL) {
extsts |= EXTSTS_IPPKT;
if (IPPROTO_TCP == skb->nh.iph->protocol)
if (IPPROTO_TCP == ip_hdr(skb)->protocol)
extsts |= EXTSTS_TCPPKT;
else if (IPPROTO_UDP == skb->nh.iph->protocol)
else if (IPPROTO_UDP == ip_hdr(skb)->protocol)
extsts |= EXTSTS_UDPPKT;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/pasemi_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
if (skb->ip_summed == CHECKSUM_PARTIAL) {
const unsigned char *nh = skb_network_header(skb);

switch (skb->nh.iph->protocol) {
switch (ip_hdr(skb)->protocol) {
case IPPROTO_TCP:
dflags |= XCT_MACTX_CSUM_TCP;
dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,7 @@ static inline u32 rtl8169_tso_csum(struct sk_buff *skb, struct net_device *dev)
return LargeSend | ((mss & MSSMask) << MSSShift);
}
if (skb->ip_summed == CHECKSUM_PARTIAL) {
const struct iphdr *ip = skb->nh.iph;
const struct iphdr *ip = ip_hdr(skb);

if (ip->protocol == IPPROTO_TCP)
return IPCS | TCPCS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/sky2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
tcpsum |= offset + skb->csum_offset; /* sum write */

ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
if (skb->nh.iph->protocol == IPPROTO_UDP)
if (ip_hdr(skb)->protocol == IPPROTO_UDP)
ctrl |= UDPTCP;

if (tcpsum != sky2->tx_tcpsum) {
Expand Down
Loading

0 comments on commit eddc9ec

Please sign in to comment.