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.h126
1 files changed, 115 insertions, 11 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9dcf956ad18a..55d67300fa10 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,55 @@ 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 *
172 * These flags are attached to packets as part of the
173 * &skb_shared_info. Use skb_tx() to get a pointer.
174 */
175union skb_shared_tx {
176 struct {
177 __u8 hardware:1,
178 software:1,
179 in_progress:1;
180 };
181 __u8 flags;
182};
183
138/* This data is invariant across clones and lives at 184/* This data is invariant across clones and lives at
139 * the end of the header data, ie. at skb->end. 185 * the end of the header data, ie. at skb->end.
140 */ 186 */
@@ -146,10 +192,12 @@ struct skb_shared_info {
146 unsigned short gso_segs; 192 unsigned short gso_segs;
147 unsigned short gso_type; 193 unsigned short gso_type;
148 __be32 ip6_frag_id; 194 __be32 ip6_frag_id;
195 union skb_shared_tx tx_flags;
149#ifdef CONFIG_HAS_DMA 196#ifdef CONFIG_HAS_DMA
150 unsigned int num_dma_maps; 197 unsigned int num_dma_maps;
151#endif 198#endif
152 struct sk_buff *frag_list; 199 struct sk_buff *frag_list;
200 struct skb_shared_hwtstamps hwtstamps;
153 skb_frag_t frags[MAX_SKB_FRAGS]; 201 skb_frag_t frags[MAX_SKB_FRAGS];
154#ifdef CONFIG_HAS_DMA 202#ifdef CONFIG_HAS_DMA
155 dma_addr_t dma_maps[MAX_SKB_FRAGS + 1]; 203 dma_addr_t dma_maps[MAX_SKB_FRAGS + 1];
@@ -188,6 +236,8 @@ enum {
188 SKB_GSO_TCP_ECN = 1 << 3, 236 SKB_GSO_TCP_ECN = 1 << 3,
189 237
190 SKB_GSO_TCPV6 = 1 << 4, 238 SKB_GSO_TCPV6 = 1 << 4,
239
240 SKB_GSO_FCOE = 1 << 5,
191}; 241};
192 242
193#if BITS_PER_LONG > 32 243#if BITS_PER_LONG > 32
@@ -373,6 +423,7 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
373#endif 423#endif
374 424
375extern void kfree_skb(struct sk_buff *skb); 425extern void kfree_skb(struct sk_buff *skb);
426extern void consume_skb(struct sk_buff *skb);
376extern void __kfree_skb(struct sk_buff *skb); 427extern void __kfree_skb(struct sk_buff *skb);
377extern struct sk_buff *__alloc_skb(unsigned int size, 428extern struct sk_buff *__alloc_skb(unsigned int size,
378 gfp_t priority, int fclone, int node); 429 gfp_t priority, int fclone, int node);
@@ -411,7 +462,8 @@ extern int skb_to_sgvec(struct sk_buff *skb,
411extern int skb_cow_data(struct sk_buff *skb, int tailbits, 462extern int skb_cow_data(struct sk_buff *skb, int tailbits,
412 struct sk_buff **trailer); 463 struct sk_buff **trailer);
413extern int skb_pad(struct sk_buff *skb, int pad); 464extern int skb_pad(struct sk_buff *skb, int pad);
414#define dev_kfree_skb(a) kfree_skb(a) 465#define dev_kfree_skb(a) consume_skb(a)
466#define dev_consume_skb(a) kfree_skb_clean(a)
415extern void skb_over_panic(struct sk_buff *skb, int len, 467extern void skb_over_panic(struct sk_buff *skb, int len,
416 void *here); 468 void *here);
417extern void skb_under_panic(struct sk_buff *skb, int len, 469extern void skb_under_panic(struct sk_buff *skb, int len,
@@ -459,6 +511,16 @@ static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
459/* Internal */ 511/* Internal */
460#define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) 512#define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB)))
461 513
514static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
515{
516 return &skb_shinfo(skb)->hwtstamps;
517}
518
519static inline union skb_shared_tx *skb_tx(struct sk_buff *skb)
520{
521 return &skb_shinfo(skb)->tx_flags;
522}
523
462/** 524/**
463 * skb_queue_empty - check if a queue is empty 525 * skb_queue_empty - check if a queue is empty
464 * @list: queue head 526 * @list: queue head
@@ -1278,7 +1340,7 @@ static inline int skb_network_offset(const struct sk_buff *skb)
1278 * The networking layer reserves some headroom in skb data (via 1340 * 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 1341 * 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 1342 * the header has to grow. In the default case, if the header has to grow
1281 * 16 bytes or less we avoid the reallocation. 1343 * 32 bytes or less we avoid the reallocation.
1282 * 1344 *
1283 * Unfortunately this headroom changes the DMA alignment of the resulting 1345 * Unfortunately this headroom changes the DMA alignment of the resulting
1284 * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive 1346 * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive
@@ -1286,11 +1348,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 1348 * 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. 1349 * cacheline alignment of the DMA). It must be a power of 2.
1288 * 1350 *
1289 * Various parts of the networking layer expect at least 16 bytes of 1351 * Various parts of the networking layer expect at least 32 bytes of
1290 * headroom, you should not reduce this. 1352 * headroom, you should not reduce this.
1291 */ 1353 */
1292#ifndef NET_SKB_PAD 1354#ifndef NET_SKB_PAD
1293#define NET_SKB_PAD 16 1355#define NET_SKB_PAD 32
1294#endif 1356#endif
1295 1357
1296extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); 1358extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
@@ -1678,8 +1740,6 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
1678 int shiftlen); 1740 int shiftlen);
1679 1741
1680extern struct sk_buff *skb_segment(struct sk_buff *skb, int features); 1742extern 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 1743
1684static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, 1744static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1685 int len, void *buffer) 1745 int len, void *buffer)
@@ -1726,6 +1786,11 @@ static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
1726 1786
1727extern void skb_init(void); 1787extern void skb_init(void);
1728 1788
1789static inline ktime_t skb_get_ktime(const struct sk_buff *skb)
1790{
1791 return skb->tstamp;
1792}
1793
1729/** 1794/**
1730 * skb_get_timestamp - get timestamp from a skb 1795 * skb_get_timestamp - get timestamp from a skb
1731 * @skb: skb to get stamp from 1796 * @skb: skb to get stamp from
@@ -1735,11 +1800,18 @@ extern void skb_init(void);
1735 * This function converts the offset back to a struct timeval and stores 1800 * This function converts the offset back to a struct timeval and stores
1736 * it in stamp. 1801 * it in stamp.
1737 */ 1802 */
1738static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) 1803static inline void skb_get_timestamp(const struct sk_buff *skb,
1804 struct timeval *stamp)
1739{ 1805{
1740 *stamp = ktime_to_timeval(skb->tstamp); 1806 *stamp = ktime_to_timeval(skb->tstamp);
1741} 1807}
1742 1808
1809static inline void skb_get_timestampns(const struct sk_buff *skb,
1810 struct timespec *stamp)
1811{
1812 *stamp = ktime_to_timespec(skb->tstamp);
1813}
1814
1743static inline void __net_timestamp(struct sk_buff *skb) 1815static inline void __net_timestamp(struct sk_buff *skb)
1744{ 1816{
1745 skb->tstamp = ktime_get_real(); 1817 skb->tstamp = ktime_get_real();
@@ -1755,6 +1827,20 @@ static inline ktime_t net_invalid_timestamp(void)
1755 return ktime_set(0, 0); 1827 return ktime_set(0, 0);
1756} 1828}
1757 1829
1830/**
1831 * skb_tstamp_tx - queue clone of skb with send time stamps
1832 * @orig_skb: the original outgoing packet
1833 * @hwtstamps: hardware time stamps, may be NULL if not available
1834 *
1835 * If the skb has a socket associated, then this function clones the
1836 * skb (thus sharing the actual data and optional structures), stores
1837 * the optional hardware time stamping information (if non NULL) or
1838 * generates a software time stamp (otherwise), then queues the clone
1839 * to the error queue of the socket. Errors are silently ignored.
1840 */
1841extern void skb_tstamp_tx(struct sk_buff *orig_skb,
1842 struct skb_shared_hwtstamps *hwtstamps);
1843
1758extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); 1844extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
1759extern __sum16 __skb_checksum_complete(struct sk_buff *skb); 1845extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1760 1846
@@ -1885,7 +1971,7 @@ static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
1885 skb->queue_mapping = queue_mapping; 1971 skb->queue_mapping = queue_mapping;
1886} 1972}
1887 1973
1888static inline u16 skb_get_queue_mapping(struct sk_buff *skb) 1974static inline u16 skb_get_queue_mapping(const struct sk_buff *skb)
1889{ 1975{
1890 return skb->queue_mapping; 1976 return skb->queue_mapping;
1891} 1977}
@@ -1895,6 +1981,24 @@ static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_bu
1895 to->queue_mapping = from->queue_mapping; 1981 to->queue_mapping = from->queue_mapping;
1896} 1982}
1897 1983
1984static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue)
1985{
1986 skb->queue_mapping = rx_queue + 1;
1987}
1988
1989static inline u16 skb_get_rx_queue(const struct sk_buff *skb)
1990{
1991 return skb->queue_mapping - 1;
1992}
1993
1994static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
1995{
1996 return (skb->queue_mapping != 0);
1997}
1998
1999extern u16 skb_tx_hash(const struct net_device *dev,
2000 const struct sk_buff *skb);
2001
1898#ifdef CONFIG_XFRM 2002#ifdef CONFIG_XFRM
1899static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 2003static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
1900{ 2004{