Skip to content

Commit

Permalink
[SK_BUFF]: Introduce skb_reset_mac_header(skb)
Browse files Browse the repository at this point in the history
For the common, open coded 'skb->mac.raw = skb->data' operation, so that we can
later turn skb->mac.raw into a offset, reducing the size of struct sk_buff in
64bit land while possibly keeping it as a pointer on 32bit.

This one touches just the most simple case, next will handle the slightly more
"complex" cases.

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 4c13eb6 commit 459a98e
Show file tree
Hide file tree
Showing 85 changed files with 119 additions and 109 deletions.
2 changes: 1 addition & 1 deletion arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static int uml_net_rx(struct net_device *dev)

skb->dev = dev;
skb_put(skb, dev->mtu);
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
pkt_len = (*lp->read)(lp->fd, &skb, lp);

if (pkt_len > 0) {
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/platform-iss/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static int iss_net_rx(struct net_device *dev)
/* Setup skb */

skb->dev = dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
pkt_len = lp->tp.read(lp, &skb);
skb_put(skb, pkt_len);

Expand Down
3 changes: 2 additions & 1 deletion drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ new_skb(ulong len)

skb = alloc_skb(len, GFP_ATOMIC);
if (skb) {
skb->nh.raw = skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->nh.raw = skb->data;
skb->protocol = __constant_htons(ETH_P_AOE);
skb->priority = 0;
skb->next = skb->prev = NULL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ieee1394/eth1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ static inline u16 ether1394_type_trans(struct sk_buff *skb,
struct eth1394hdr *eth;
unsigned char *rawp;

skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull (skb, ETH1394_HLEN);
eth = eth1394_hdr(skb);

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/ulp/ipoib/ipoib_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
skb_put_frags(skb, IPOIB_CM_HEAD_SIZE, wc->byte_len, newskb);

skb->protocol = ((struct ipoib_header *) skb->data)->proto;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, IPOIB_ENCAP_LEN);

dev->last_rx = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/ulp/ipoib/ipoib_ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
if (wc->slid != priv->local_lid ||
wc->src_qp != priv->qp->qp_num) {
skb->protocol = ((struct ipoib_header *) skb->data)->proto;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, IPOIB_ENCAP_LEN);

dev->last_rx = jiffies;
Expand Down
4 changes: 2 additions & 2 deletions drivers/isdn/i4l/isdn_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev)
struct ethhdr *eth;
unsigned char *rawp;

skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, ETH_HLEN);
eth = eth_hdr(skb);

Expand Down Expand Up @@ -1786,7 +1786,7 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb)
}
skb->dev = ndev;
skb->pkt_type = PACKET_HOST;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
#ifdef ISDN_DEBUG_NET_DUMP
isdn_dumppkt("R:", skb->data, skb->len, 40);
#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/i4l/isdn_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ isdn_ppp_push_higher(isdn_net_dev * net_dev, isdn_net_local * lp, struct sk_buff
mlp->huptimer = 0;
#endif /* CONFIG_IPPP_FILTER */
skb->dev = dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
netif_rx(skb);
/* net_dev->local->stats.rx_packets++; done in isdn_net.c */
return;
Expand Down
4 changes: 2 additions & 2 deletions drivers/message/fusion/mptlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
/* Set the mac.raw pointer, since this apparently isn't getting
* done before we get the skb. Pull the data pointer past the mac data.
*/
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, 12);

dma = pci_map_single(mpt_dev->pcidev, skb->data, skb->len,
Expand Down Expand Up @@ -1549,7 +1549,7 @@ mpt_lan_type_trans(struct sk_buff *skb, struct net_device *dev)
struct mpt_lan_ohdr *fch = (struct mpt_lan_ohdr *)skb->data;
struct fcllc *fcllc;

skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, sizeof(struct mpt_lan_ohdr));

if (fch->dtype == htons(0xffff)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/appletalk/cops.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ static void cops_rx(struct net_device *dev)
return;
}

skb->mac.raw = skb->data; /* Point to entire packet. */
skb_reset_mac_header(skb); /* Point to entire packet. */
skb_pull(skb,3);
skb->h.raw = skb->data; /* Point to data (Skip header). */

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/appletalk/ltpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ static int sendup_buffer (struct net_device *dev)
skb->data[0] = dnode;
skb->data[1] = snode;
skb->data[2] = llaptype;
skb->mac.raw = skb->data; /* save pointer to llap header */
skb_reset_mac_header(skb); /* save pointer to llap header */
skb_pull(skb,3);

/* copy ddp(s,e)hdr + contents */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arcnet/arc-rawmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void rx(struct net_device *dev, int bufnum,

pkt = (struct archdr *) skb->data;

skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, ARC_HDR_SIZE);

/* up to sizeof(pkt->soft) has already been copied from the card */
Expand Down
11 changes: 4 additions & 7 deletions drivers/net/arcnet/capmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ static void rx(struct net_device *dev, int bufnum,
}
skb_put(skb, length + ARC_HDR_SIZE + sizeof(int));
skb->dev = dev;

pkt = (struct archdr *) skb->data;

skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
pkt = (struct archdr *)skb->mac.raw;
skb_pull(skb, ARC_HDR_SIZE);

/* up to sizeof(pkt->soft) has already been copied from the card */
Expand Down Expand Up @@ -270,9 +268,8 @@ static int ack_tx(struct net_device *dev, int acked)
skb_put(ackskb, length + ARC_HDR_SIZE );
ackskb->dev = dev;

ackpkt = (struct archdr *) ackskb->data;

ackskb->mac.raw = ackskb->data;
skb_reset_mac_header(ackskb);
ackpkt = (struct archdr *)ackskb->mac.raw;
/* skb_pull(ackskb, ARC_HDR_SIZE); */


Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arcnet/rfc1051.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE;

/* Pull off the arcnet header. */
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, hdr_size);

if (pkt->hard.dest == 0)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arcnet/rfc1201.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static unsigned short type_trans(struct sk_buff *skb, struct net_device *dev)
int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE;

/* Pull off the arcnet header. */
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb_pull(skb, hdr_size);

if (pkt->hard.dest == 0)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/bonding/bond_3ad.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ static int ad_lacpdu_send(struct port *port)
}

skb->dev = slave->dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->nh.raw = skb->data + ETH_HLEN;
skb->protocol = PKT_TYPE_LACPDU;
skb->priority = TC_PRIO_CONTROL;
Expand Down Expand Up @@ -928,7 +928,7 @@ static int ad_marker_send(struct port *port, struct marker *marker)
skb_reserve(skb, 16);

skb->dev = slave->dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->nh.raw = skb->data + ETH_HLEN;
skb->protocol = PKT_TYPE_LACPDU;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
data = skb_put(skb, size);
memcpy(data, &pkt, size);

skb->mac.raw = data;
skb_reset_mac_header(skb);
skb->nh.raw = data + ETH_HLEN;
skb->protocol = pkt.type;
skb->priority = TC_PRIO_CONTROL;
Expand Down Expand Up @@ -1266,7 +1266,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
u8 *hash_start = NULL;
int res = 1;

skb->mac.raw = (unsigned char *)skb->data;
skb_reset_mac_header(skb);
eth_data = eth_hdr(skb);

/* make sure that the curr_active_slave and the slaves list do
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/cxgb3/cxgb3_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ static int do_trace(struct t3cdev *dev, struct sk_buff *skb)
skb->protocol = htons(0xffff);
skb->dev = dev->lldev;
skb_pull(skb, sizeof(*p));
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
netif_receive_skb(skb);
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/cxgb3/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,8 @@ static inline int rx_offload(struct t3cdev *tdev, struct sge_rspq *rq,
unsigned int gather_idx)
{
rq->offload_pkts++;
skb->mac.raw = skb->nh.raw = skb->h.raw = skb->data;
skb_reset_mac_header(skb);
skb->nh.raw = skb->h.raw = skb->data;

if (rq->polling) {
rx_gather[gather_idx++] = skb;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/ali-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
self->stats.rx_packets++;

skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
self->netdev->last_rx = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/au1k_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ static int au1k_irda_rx(struct net_device *dev)
skb_put(skb, count-2);
memcpy(skb->data, (void *)pDB->vaddr, count-2);
skb->dev = dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
prxd->count_0 = 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/donauboe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');

self->stats.rx_packets++;
skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons (ETH_P_IRDA);
}
else
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/irda-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static void irda_usb_receive(struct urb *urb)

/* Ask the networking layer to queue the packet for the IrDA stack */
dataskb->dev = self->netdev;
dataskb->mac.raw = dataskb->data;
skb_reset_mac_header(dataskb);
dataskb->protocol = htons(ETH_P_IRDA);
len = dataskb->len;
netif_rx(dataskb);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/irda/mcs7780.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len)
skb_reserve(skb, 1);
memcpy(skb->data, buf, new_len);
skb_put(skb, new_len);
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
skb->dev = mcs->netdev;

Expand Down Expand Up @@ -481,7 +481,7 @@ static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len)
skb_reserve(skb, 1);
memcpy(skb->data, buf, new_len);
skb_put(skb, new_len);
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
skb->dev = mcs->netdev;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/nsc-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
self->stats.rx_packets++;

skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
self->netdev->last_rx = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/pxaficp_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev, in

/* Feed it to IrLAP */
skb->dev = dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/sa1100_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev

skb_put(skb, len);
skb->dev = dev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
si->stats.rx_packets++;
si->stats.rx_bytes += len;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/smsc-ircc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
self->stats.rx_bytes += len;

skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/stir4200.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ static void fir_eof(struct stir_cb *stir)

skb_put(skb, len);

skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
skb->dev = stir->netdev;

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/irda/via-ircc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
self->stats.rx_bytes += len;
self->stats.rx_packets++;
skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
return TRUE;
Expand Down Expand Up @@ -1198,7 +1198,7 @@ F01_E */
self->stats.rx_bytes += len;
self->stats.rx_packets++;
skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);

Expand Down Expand Up @@ -1244,7 +1244,7 @@ static int upload_rxdata(struct via_ircc_cb *self, int iobase)
self->stats.rx_bytes += len;
self->stats.rx_packets++;
skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
if (st_fifo->len < (MAX_RX_WINDOW + 2)) {
Expand Down Expand Up @@ -1313,7 +1313,7 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
self->stats.rx_bytes += len;
self->stats.rx_packets++;
skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
} //while
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/vlsi_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static int vlsi_process_rx(struct vlsi_ring *r, struct ring_descr *rd)
rd->skb = NULL;
skb->dev = ndev;
memcpy(skb_put(skb,len), rd->buf, len);
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
if (in_interrupt())
netif_rx(skb);
else
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/irda/w83977af_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ int w83977af_dma_receive_complete(struct w83977af_ir *self)
self->stats.rx_packets++;

skb->dev = self->netdev;
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IRDA);
netif_rx(skb);
self->netdev->last_rx = jiffies;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/myri_sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static __be16 myri_type_trans(struct sk_buff *skb, struct net_device *dev)
struct ethhdr *eth;
unsigned char *rawp;

skb->mac.raw = (((unsigned char *)skb->data) + MYRI_PAD_LEN);
skb->mac.raw = skb->data + MYRI_PAD_LEN;
skb_pull(skb, dev->hard_header_len);
eth = eth_hdr(skb);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
skb_pull_rcsum(skb, 2);
skb->dev = ppp->dev;
skb->protocol = htons(npindex_to_ethertype[npi]);
skb->mac.raw = skb->data;
skb_reset_mac_header(skb);
netif_rx(skb);
ppp->dev->last_rx = jiffies;
}
Expand Down
Loading

0 comments on commit 459a98e

Please sign in to comment.