aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h127
1 files changed, 116 insertions, 11 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9dcf956ad18a..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,7 +463,8 @@ 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,
@@ -459,6 +512,16 @@ static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
459/* Internal */ 512/* Internal */
460#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)))
461 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
462/** 525/**
463 * skb_queue_empty - check if a queue is empty 526 * skb_queue_empty - check if a queue is empty
464 * @list: queue head 527 * @list: queue head
@@ -1278,7 +1341,7 @@ static inline int skb_network_offset(const struct sk_buff *skb)
1278 * The networking layer reserves some headroom in skb data (via 1341 * The networking layer reserves some headroom in skb data (via
1279 * 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
1280 * 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
1281 * 16 bytes or less we avoid the reallocation. 1344 * 32 bytes or less we avoid the reallocation.
1282 * 1345 *
1283 * Unfortunately this headroom changes the DMA alignment of the resulting 1346 * Unfortunately this headroom changes the DMA alignment of the resulting
1284 * 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
@@ -1286,11 +1349,11 @@ static inline int skb_network_offset(const struct sk_buff *skb)
1286 * 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
1287 * 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.
1288 * 1351 *
1289 * 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
1290 * headroom, you should not reduce this. 1353 * headroom, you should not reduce this.
1291 */ 1354 */
1292#ifndef NET_SKB_PAD 1355#ifndef NET_SKB_PAD
1293#define NET_SKB_PAD 16 1356#define NET_SKB_PAD 32
1294#endif 1357#endif
1295 1358
1296extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); 1359extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
@@ -1678,8 +1741,6 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
1678 int shiftlen); 1741 int shiftlen);
1679 1742
1680extern struct sk_buff *skb_segment(struct sk_buff *skb, int features); 1743extern struct sk_buff *skb_segment(struct sk_buff *skb, int features);
1681extern int skb_gro_receive(struct sk_buff **head,
1682 struct sk_buff *skb);
1683 1744
1684static 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,
1685 int len, void *buffer) 1746 int len, void *buffer)
@@ -1726,6 +1787,11 @@ static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
1726 1787
1727extern void skb_init(void); 1788extern void skb_init(void);
1728 1789
1790static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
1791{
1792 return skb->tstamp;
1793}
1794
1729/** 1795/**
1730 * skb_get_timestamp - get timestamp from a skb 1796 * skb_get_timestamp - get timestamp from a skb
1731 * @skb: skb to get stamp from 1797 * @skb: skb to get stamp from
@@ -1735,11 +1801,18 @@ extern void skb_init(void);
1735 * 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
1736 * it in stamp. 1802 * it in stamp.
1737 */ 1803 */
1738static 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)
1739{ 1806{
1740 *stamp = ktime_to_timeval(skb->tstamp); 1807 *stamp = ktime_to_timeval(skb->tstamp);
1741} 1808}
1742 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
1743static inline void __net_timestamp(struct sk_buff *skb) 1816static inline void __net_timestamp(struct sk_buff *skb)
1744{ 1817{
1745 skb->tstamp = ktime_get_real(); 1818 skb->tstamp = ktime_get_real();
@@ -1755,6 +1828,20 @@ static inline ktime_t net_invalid_timestamp(void)
1755 return ktime_set(0, 0); 1828 return ktime_set(0, 0);
1756} 1829}
1757 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
1758extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); 1845extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
1759extern __sum16 __skb_checksum_complete(struct sk_buff *skb); 1846extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1760 1847
@@ -1885,7 +1972,7 @@ static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
1885 skb->queue_mapping = queue_mapping; 1972 skb->queue_mapping = queue_mapping;
1886} 1973}
1887 1974
1888static inline u16 skb_get_queue_mapping(struct sk_buff *skb) 1975static inline u16 skb_get_queue_mapping(const struct sk_buff *skb)
1889{ 1976{
1890 return skb->queue_mapping; 1977 return skb->queue_mapping;
1891} 1978}
@@ -1895,6 +1982,24 @@ static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_bu
1895 to->queue_mapping = from->queue_mapping; 1982 to->queue_mapping = from->queue_mapping;
1896} 1983}
1897 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
1898#ifdef CONFIG_XFRM 2003#ifdef CONFIG_XFRM
1899static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 2004static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
1900{ 2005{