aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-04-07 05:15:40 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-07 05:15:40 -0400
commit5e34437840d33554f69380584311743b39e8fbeb (patch)
treee081135619ee146af5efb9ee883afca950df5757 /include/linux/skbuff.h
parent77d05632baee21b1cef8730d7c06aa69601e4dca (diff)
parentd508afb437daee7cf07da085b635c44a4ebf9b38 (diff)
Merge branch 'linus' into core/softlockup
Conflicts: kernel/sysctl.c
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h136
1 files changed, 116 insertions, 20 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index cf2cb50f77d1..5fd389162f01 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -29,9 +29,6 @@
29#include <linux/dmaengine.h> 29#include <linux/dmaengine.h>
30#include <linux/hrtimer.h> 30#include <linux/hrtimer.h>
31 31
32#define HAVE_ALLOC_SKB /* For the drivers to know */
33#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
34
35/* Don't change this without changing skb_csum_unnecessary! */ 32/* Don't change this without changing skb_csum_unnecessary! */
36#define CHECKSUM_NONE 0 33#define CHECKSUM_NONE 0
37#define CHECKSUM_UNNECESSARY 1 34#define CHECKSUM_UNNECESSARY 1
@@ -135,6 +132,56 @@ struct skb_frag_struct {
135 __u32 size; 132 __u32 size;
136}; 133};
137 134
135#define HAVE_HW_TIME_STAMP
136
137/**
138 * struct skb_shared_hwtstamps - hardware time stamps
139 * @hwtstamp: hardware time stamp transformed into duration
140 * since arbitrary point in time
141 * @syststamp: hwtstamp transformed to system time base
142 *
143 * Software time stamps generated by ktime_get_real() are stored in
144 * skb->tstamp. The relation between the different kinds of time
145 * stamps is as follows:
146 *
147 * syststamp and tstamp can be compared against each other in
148 * arbitrary combinations. The accuracy of a
149 * syststamp/tstamp/"syststamp from other device" comparison is
150 * limited by the accuracy of the transformation into system time
151 * base. This depends on the device driver and its underlying
152 * hardware.
153 *
154 * hwtstamps can only be compared against other hwtstamps from
155 * the same device.
156 *
157 * This structure is attached to packets as part of the
158 * &skb_shared_info. Use skb_hwtstamps() to get a pointer.
159 */
160struct skb_shared_hwtstamps {
161 ktime_t hwtstamp;
162 ktime_t syststamp;
163};
164
165/**
166 * struct skb_shared_tx - instructions for time stamping of outgoing packets
167 * @hardware: generate hardware time stamp
168 * @software: generate software time stamp
169 * @in_progress: device driver is going to provide
170 * hardware time stamp
171 * @flags: all shared_tx flags
172 *
173 * These flags are attached to packets as part of the
174 * &skb_shared_info. Use skb_tx() to get a pointer.
175 */
176union skb_shared_tx {
177 struct {
178 __u8 hardware:1,
179 software:1,
180 in_progress:1;
181 };
182 __u8 flags;
183};
184
138/* This data is invariant across clones and lives at 185/* This data is invariant across clones and lives at
139 * the end of the header data, ie. at skb->end. 186 * the end of the header data, ie. at skb->end.
140 */ 187 */
@@ -146,10 +193,12 @@ struct skb_shared_info {
146 unsigned short gso_segs; 193 unsigned short gso_segs;
147 unsigned short gso_type; 194 unsigned short gso_type;
148 __be32 ip6_frag_id; 195 __be32 ip6_frag_id;
196 union skb_shared_tx tx_flags;
149#ifdef CONFIG_HAS_DMA 197#ifdef CONFIG_HAS_DMA
150 unsigned int num_dma_maps; 198 unsigned int num_dma_maps;
151#endif 199#endif
152 struct sk_buff *frag_list; 200 struct sk_buff *frag_list;
201 struct skb_shared_hwtstamps hwtstamps;
153 skb_frag_t frags[MAX_SKB_FRAGS]; 202 skb_frag_t frags[MAX_SKB_FRAGS];
154#ifdef CONFIG_HAS_DMA 203#ifdef CONFIG_HAS_DMA
155 dma_addr_t dma_maps[MAX_SKB_FRAGS + 1]; 204 dma_addr_t dma_maps[MAX_SKB_FRAGS + 1];
@@ -188,6 +237,8 @@ enum {
188 SKB_GSO_TCP_ECN = 1 << 3, 237 SKB_GSO_TCP_ECN = 1 << 3,
189 238
190 SKB_GSO_TCPV6 = 1 << 4, 239 SKB_GSO_TCPV6 = 1 << 4,
240
241 SKB_GSO_FCOE = 1 << 5,
191}; 242};
192 243
193#if BITS_PER_LONG > 32 244#if BITS_PER_LONG > 32
@@ -373,6 +424,7 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
373#endif 424#endif
374 425
375extern void kfree_skb(struct sk_buff *skb); 426extern void kfree_skb(struct sk_buff *skb);
427extern void consume_skb(struct sk_buff *skb);
376extern void __kfree_skb(struct sk_buff *skb); 428extern void __kfree_skb(struct sk_buff *skb);
377extern struct sk_buff *__alloc_skb(unsigned int size, 429extern struct sk_buff *__alloc_skb(unsigned int size,
378 gfp_t priority, int fclone, int node); 430 gfp_t priority, int fclone, int node);
@@ -411,20 +463,12 @@ extern int skb_to_sgvec(struct sk_buff *skb,
411extern int skb_cow_data(struct sk_buff *skb, int tailbits, 463extern int skb_cow_data(struct sk_buff *skb, int tailbits,
412 struct sk_buff **trailer); 464 struct sk_buff **trailer);
413extern int skb_pad(struct sk_buff *skb, int pad); 465extern int skb_pad(struct sk_buff *skb, int pad);
414#define dev_kfree_skb(a) kfree_skb(a) 466#define dev_kfree_skb(a) consume_skb(a)
467#define dev_consume_skb(a) kfree_skb_clean(a)
415extern void skb_over_panic(struct sk_buff *skb, int len, 468extern void skb_over_panic(struct sk_buff *skb, int len,
416 void *here); 469 void *here);
417extern void skb_under_panic(struct sk_buff *skb, int len, 470extern void skb_under_panic(struct sk_buff *skb, int len,
418 void *here); 471 void *here);
419extern void skb_truesize_bug(struct sk_buff *skb);
420
421static inline void skb_truesize_check(struct sk_buff *skb)
422{
423 int len = sizeof(struct sk_buff) + skb->len;
424
425 if (unlikely((int)skb->truesize < len))
426 skb_truesize_bug(skb);
427}
428 472
429extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb, 473extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
430 int getfrag(void *from, char *to, int offset, 474 int getfrag(void *from, char *to, int offset,
@@ -468,6 +512,16 @@ static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
468/* Internal */ 512/* Internal */
469#define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) 513#define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB)))
470 514
515static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
516{
517 return &skb_shinfo(skb)->hwtstamps;
518}
519
520static inline union skb_shared_tx *skb_tx(struct sk_buff *skb)
521{
522 return &skb_shinfo(skb)->tx_flags;
523}
524
471/** 525/**
472 * skb_queue_empty - check if a queue is empty 526 * skb_queue_empty - check if a queue is empty
473 * @list: queue head 527 * @list: queue head
@@ -1287,7 +1341,7 @@ static inline int skb_network_offset(const struct sk_buff *skb)
1287 * The networking layer reserves some headroom in skb data (via 1341 * The networking layer reserves some headroom in skb data (via
1288 * dev_alloc_skb). This is used to avoid having to reallocate skb data when 1342 * dev_alloc_skb). This is used to avoid having to reallocate skb data when
1289 * the header has to grow. In the default case, if the header has to grow 1343 * the header has to grow. In the default case, if the header has to grow
1290 * 16 bytes or less we avoid the reallocation. 1344 * 32 bytes or less we avoid the reallocation.
1291 * 1345 *
1292 * Unfortunately this headroom changes the DMA alignment of the resulting 1346 * Unfortunately this headroom changes the DMA alignment of the resulting
1293 * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive 1347 * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive
@@ -1295,11 +1349,11 @@ static inline int skb_network_offset(const struct sk_buff *skb)
1295 * perhaps setting it to a cacheline in size (since that will maintain 1349 * perhaps setting it to a cacheline in size (since that will maintain
1296 * cacheline alignment of the DMA). It must be a power of 2. 1350 * cacheline alignment of the DMA). It must be a power of 2.
1297 * 1351 *
1298 * Various parts of the networking layer expect at least 16 bytes of 1352 * Various parts of the networking layer expect at least 32 bytes of
1299 * headroom, you should not reduce this. 1353 * headroom, you should not reduce this.
1300 */ 1354 */
1301#ifndef NET_SKB_PAD 1355#ifndef NET_SKB_PAD
1302#define NET_SKB_PAD 16 1356#define NET_SKB_PAD 32
1303#endif 1357#endif
1304 1358
1305extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); 1359extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
@@ -1687,8 +1741,6 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
1687 int shiftlen); 1741 int shiftlen);
1688 1742
1689extern struct sk_buff *skb_segment(struct sk_buff *skb, int features); 1743extern struct sk_buff *skb_segment(struct sk_buff *skb, int features);
1690extern int skb_gro_receive(struct sk_buff **head,
1691 struct sk_buff *skb);
1692 1744
1693static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, 1745static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1694 int len, void *buffer) 1746 int len, void *buffer)
@@ -1735,6 +1787,11 @@ static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
1735 1787
1736extern void skb_init(void); 1788extern void skb_init(void);
1737 1789
1790static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
1791{
1792 return skb->tstamp;
1793}
1794
1738/** 1795/**
1739 * skb_get_timestamp - get timestamp from a skb 1796 * skb_get_timestamp - get timestamp from a skb
1740 * @skb: skb to get stamp from 1797 * @skb: skb to get stamp from
@@ -1744,11 +1801,18 @@ extern void skb_init(void);
1744 * This function converts the offset back to a struct timeval and stores 1801 * This function converts the offset back to a struct timeval and stores
1745 * it in stamp. 1802 * it in stamp.
1746 */ 1803 */
1747static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) 1804static inline void skb_get_timestamp(const struct sk_buff *skb,
1805 struct timeval *stamp)
1748{ 1806{
1749 *stamp = ktime_to_timeval(skb->tstamp); 1807 *stamp = ktime_to_timeval(skb->tstamp);
1750} 1808}
1751 1809
1810static inline void skb_get_timestampns(const struct sk_buff *skb,
1811 struct timespec *stamp)
1812{
1813 *stamp = ktime_to_timespec(skb->tstamp);
1814}
1815
1752static inline void __net_timestamp(struct sk_buff *skb) 1816static inline void __net_timestamp(struct sk_buff *skb)
1753{ 1817{
1754 skb->tstamp = ktime_get_real(); 1818 skb->tstamp = ktime_get_real();
@@ -1764,6 +1828,20 @@ static inline ktime_t net_invalid_timestamp(void)
1764 return ktime_set(0, 0); 1828 return ktime_set(0, 0);
1765} 1829}
1766 1830
1831/**
1832 * skb_tstamp_tx - queue clone of skb with send time stamps
1833 * @orig_skb: the original outgoing packet
1834 * @hwtstamps: hardware time stamps, may be NULL if not available
1835 *
1836 * If the skb has a socket associated, then this function clones the
1837 * skb (thus sharing the actual data and optional structures), stores
1838 * the optional hardware time stamping information (if non NULL) or
1839 * generates a software time stamp (otherwise), then queues the clone
1840 * to the error queue of the socket. Errors are silently ignored.
1841 */
1842extern void skb_tstamp_tx(struct sk_buff *orig_skb,
1843 struct skb_shared_hwtstamps *hwtstamps);
1844
1767extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); 1845extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
1768extern __sum16 __skb_checksum_complete(struct sk_buff *skb); 1846extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1769 1847
@@ -1894,7 +1972,7 @@ static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
1894 skb->queue_mapping = queue_mapping; 1972 skb->queue_mapping = queue_mapping;
1895} 1973}
1896 1974
1897static inline u16 skb_get_queue_mapping(struct sk_buff *skb) 1975static inline u16 skb_get_queue_mapping(const struct sk_buff *skb)
1898{ 1976{
1899 return skb->queue_mapping; 1977 return skb->queue_mapping;
1900} 1978}
@@ -1904,6 +1982,24 @@ static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_bu
1904 to->queue_mapping = from->queue_mapping; 1982 to->queue_mapping = from->queue_mapping;
1905} 1983}
1906 1984
1985static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue)
1986{
1987 skb->queue_mapping = rx_queue + 1;
1988}
1989
1990static inline u16 skb_get_rx_queue(const struct sk_buff *skb)
1991{
1992 return skb->queue_mapping - 1;
1993}
1994
1995static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
1996{
1997 return (skb->queue_mapping != 0);
1998}
1999
2000extern u16 skb_tx_hash(const struct net_device *dev,
2001 const struct sk_buff *skb);
2002
1907#ifdef CONFIG_XFRM 2003#ifdef CONFIG_XFRM
1908static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 2004static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
1909{ 2005{