mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
skb: Add inline helper for getting the skb end offset from head
[ Upstream commit ec47ea8247
]
With the recent changes for how we compute the skb truesize it occurs to me
we are probably going to have a lot of calls to skb_end_pointer -
skb->head. Instead of running all over the place doing that it would make
more sense to just make it a separate inline skb_end_offset(skb) that way
we can return the correct value without having gcc having to do all the
optimization to cancel out skb->head - skb->head.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
62e1a647e7
commit
1102122b2b
6 changed files with 19 additions and 10 deletions
|
@ -802,7 +802,7 @@ static void fill_rx_pool (amb_dev * dev, unsigned char pool,
|
||||||
}
|
}
|
||||||
// cast needed as there is no %? for pointer differences
|
// cast needed as there is no %? for pointer differences
|
||||||
PRINTD (DBG_SKB, "allocated skb at %p, head %p, area %li",
|
PRINTD (DBG_SKB, "allocated skb at %p, head %p, area %li",
|
||||||
skb, skb->head, (long) (skb_end_pointer(skb) - skb->head));
|
skb, skb->head, (long) skb_end_offset(skb));
|
||||||
rx.handle = virt_to_bus (skb);
|
rx.handle = virt_to_bus (skb);
|
||||||
rx.host_address = cpu_to_be32 (virt_to_bus (skb->data));
|
rx.host_address = cpu_to_be32 (virt_to_bus (skb->data));
|
||||||
if (rx_give (dev, &rx, pool))
|
if (rx_give (dev, &rx, pool))
|
||||||
|
|
|
@ -1258,7 +1258,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
|
||||||
tail = readl(SAR_REG_RAWCT);
|
tail = readl(SAR_REG_RAWCT);
|
||||||
|
|
||||||
pci_dma_sync_single_for_cpu(card->pcidev, IDT77252_PRV_PADDR(queue),
|
pci_dma_sync_single_for_cpu(card->pcidev, IDT77252_PRV_PADDR(queue),
|
||||||
skb_end_pointer(queue) - queue->head - 16,
|
skb_end_offset(queue) - 16,
|
||||||
PCI_DMA_FROMDEVICE);
|
PCI_DMA_FROMDEVICE);
|
||||||
|
|
||||||
while (head != tail) {
|
while (head != tail) {
|
||||||
|
|
|
@ -277,7 +277,7 @@ retry:
|
||||||
d_printf(1, dev, "RX: size changed to %d, received %d, "
|
d_printf(1, dev, "RX: size changed to %d, received %d, "
|
||||||
"copied %d, capacity %ld\n",
|
"copied %d, capacity %ld\n",
|
||||||
rx_size, read_size, rx_skb->len,
|
rx_size, read_size, rx_skb->len,
|
||||||
(long) (skb_end_pointer(new_skb) - new_skb->head));
|
(long) skb_end_offset(new_skb));
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
/* In most cases, it happens due to the hardware scheduling a
|
/* In most cases, it happens due to the hardware scheduling a
|
||||||
|
|
|
@ -345,7 +345,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||||
}
|
}
|
||||||
if (unlikely
|
if (unlikely
|
||||||
(skb->truesize !=
|
(skb->truesize !=
|
||||||
sizeof(*skb) + skb_end_pointer(skb) - skb->head)) {
|
sizeof(*skb) + skb_end_offset(skb))) {
|
||||||
/*
|
/*
|
||||||
printk("TX buffer truesize has been changed\n");
|
printk("TX buffer truesize has been changed\n");
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -640,11 +640,21 @@ static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
return skb->head + skb->end;
|
return skb->head + skb->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int skb_end_offset(const struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return skb->end;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
|
static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
return skb->end;
|
return skb->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned int skb_end_offset(const struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return skb->end - skb->head;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Internal */
|
/* Internal */
|
||||||
|
@ -2574,7 +2584,7 @@ static inline bool skb_is_recycleable(const struct sk_buff *skb, int skb_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
skb_size = SKB_DATA_ALIGN(skb_size + NET_SKB_PAD);
|
skb_size = SKB_DATA_ALIGN(skb_size + NET_SKB_PAD);
|
||||||
if (skb_end_pointer(skb) - skb->head < skb_size)
|
if (skb_end_offset(skb) < skb_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (skb_shared(skb) || skb_cloned(skb))
|
if (skb_shared(skb) || skb_cloned(skb))
|
||||||
|
|
|
@ -821,7 +821,7 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
|
||||||
struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
|
struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
|
||||||
{
|
{
|
||||||
int headerlen = skb_headroom(skb);
|
int headerlen = skb_headroom(skb);
|
||||||
unsigned int size = (skb_end_pointer(skb) - skb->head) + skb->data_len;
|
unsigned int size = skb_end_offset(skb) + skb->data_len;
|
||||||
struct sk_buff *n = alloc_skb(size, gfp_mask);
|
struct sk_buff *n = alloc_skb(size, gfp_mask);
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
|
@ -922,7 +922,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u8 *data;
|
u8 *data;
|
||||||
int size = nhead + (skb_end_pointer(skb) - skb->head) + ntail;
|
int size = nhead + skb_end_offset(skb) + ntail;
|
||||||
long off;
|
long off;
|
||||||
bool fastpath;
|
bool fastpath;
|
||||||
|
|
||||||
|
@ -2721,14 +2721,13 @@ struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features)
|
||||||
if (unlikely(!nskb))
|
if (unlikely(!nskb))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
hsize = skb_end_pointer(nskb) - nskb->head;
|
hsize = skb_end_offset(nskb);
|
||||||
if (skb_cow_head(nskb, doffset + headroom)) {
|
if (skb_cow_head(nskb, doffset + headroom)) {
|
||||||
kfree_skb(nskb);
|
kfree_skb(nskb);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
nskb->truesize += skb_end_pointer(nskb) - nskb->head -
|
nskb->truesize += skb_end_offset(nskb) - hsize;
|
||||||
hsize;
|
|
||||||
skb_release_head_state(nskb);
|
skb_release_head_state(nskb);
|
||||||
__skb_push(nskb, doffset);
|
__skb_push(nskb, doffset);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue