aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-19 23:29:13 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:26:28 -0400
commit27a884dc3cb63b93c2b3b643f5b31eed5f8a4d26 (patch)
tree5a267e40f9b94014be38dad5de0a52b6628834e0 /include/linux/skbuff.h
parentbe8bd86321fa7f06359d866ef61fb4d2f3e9dce9 (diff)
[SK_BUFF]: Convert skb->tail to sk_buff_data_t
So that it is also an offset from skb->head, reduces its size from 8 to 4 bytes on 64bit architectures, allowing us to combine the 4 bytes hole left by the layer headers conversion, reducing struct sk_buff size to 256 bytes, i.e. 4 64byte cachelines, and since the sk_buff slab cache is SLAB_HWCACHE_ALIGN... :-) Many calculations that previously required that skb->{transport,network, mac}_header be first converted to a pointer now can be done directly, being meaningful as offsets or pointers. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h57
1 files changed, 45 insertions, 12 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2e7405500626..e1c2392ecb56 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -246,9 +246,6 @@ struct sk_buff {
246 int iif; 246 int iif;
247 /* 4 byte hole on 64 bit*/ 247 /* 4 byte hole on 64 bit*/
248 248
249 sk_buff_data_t transport_header;
250 sk_buff_data_t network_header;
251 sk_buff_data_t mac_header;
252 struct dst_entry *dst; 249 struct dst_entry *dst;
253 struct sec_path *sp; 250 struct sec_path *sp;
254 251
@@ -303,13 +300,16 @@ struct sk_buff {
303 300
304 __u32 mark; 301 __u32 mark;
305 302
303 sk_buff_data_t transport_header;
304 sk_buff_data_t network_header;
305 sk_buff_data_t mac_header;
306 /* These elements must be at the end, see alloc_skb() for details. */ 306 /* These elements must be at the end, see alloc_skb() for details. */
307 unsigned int truesize; 307 sk_buff_data_t tail;
308 atomic_t users;
309 unsigned char *head, 308 unsigned char *head,
310 *data, 309 *data,
311 *tail,
312 *end; 310 *end;
311 unsigned int truesize;
312 atomic_t users;
313}; 313};
314 314
315#ifdef __KERNEL__ 315#ifdef __KERNEL__
@@ -812,12 +812,45 @@ static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
812#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list) 812#define SKB_FRAG_ASSERT(skb) BUG_ON(skb_shinfo(skb)->frag_list)
813#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) 813#define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb))
814 814
815#ifdef NET_SKBUFF_DATA_USES_OFFSET
816static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
817{
818 return skb->head + skb->tail;
819}
820
821static inline void skb_reset_tail_pointer(struct sk_buff *skb)
822{
823 skb->tail = skb->data - skb->head;
824}
825
826static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
827{
828 skb_reset_tail_pointer(skb);
829 skb->tail += offset;
830}
831#else /* NET_SKBUFF_DATA_USES_OFFSET */
832static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
833{
834 return skb->tail;
835}
836
837static inline void skb_reset_tail_pointer(struct sk_buff *skb)
838{
839 skb->tail = skb->data;
840}
841
842static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
843{
844 skb->tail = skb->data + offset;
845}
846#endif /* NET_SKBUFF_DATA_USES_OFFSET */
847
815/* 848/*
816 * Add data to an sk_buff 849 * Add data to an sk_buff
817 */ 850 */
818static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) 851static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
819{ 852{
820 unsigned char *tmp = skb->tail; 853 unsigned char *tmp = skb_tail_pointer(skb);
821 SKB_LINEAR_ASSERT(skb); 854 SKB_LINEAR_ASSERT(skb);
822 skb->tail += len; 855 skb->tail += len;
823 skb->len += len; 856 skb->len += len;
@@ -835,11 +868,11 @@ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
835 */ 868 */
836static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len) 869static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
837{ 870{
838 unsigned char *tmp = skb->tail; 871 unsigned char *tmp = skb_tail_pointer(skb);
839 SKB_LINEAR_ASSERT(skb); 872 SKB_LINEAR_ASSERT(skb);
840 skb->tail += len; 873 skb->tail += len;
841 skb->len += len; 874 skb->len += len;
842 if (unlikely(skb->tail>skb->end)) 875 if (unlikely(skb_tail_pointer(skb) > skb->end))
843 skb_over_panic(skb, len, current_text_addr()); 876 skb_over_panic(skb, len, current_text_addr());
844 return tmp; 877 return tmp;
845} 878}
@@ -935,7 +968,7 @@ static inline int skb_headroom(const struct sk_buff *skb)
935 */ 968 */
936static inline int skb_tailroom(const struct sk_buff *skb) 969static inline int skb_tailroom(const struct sk_buff *skb)
937{ 970{
938 return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail; 971 return skb_is_nonlinear(skb) ? 0 : skb->end - skb_tail_pointer(skb);
939} 972}
940 973
941/** 974/**
@@ -1127,8 +1160,8 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
1127 WARN_ON(1); 1160 WARN_ON(1);
1128 return; 1161 return;
1129 } 1162 }
1130 skb->len = len; 1163 skb->len = len;
1131 skb->tail = skb->data + len; 1164 skb_set_tail_pointer(skb, len);
1132} 1165}
1133 1166
1134/** 1167/**