diff options
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 124 |
1 files changed, 113 insertions, 11 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 9dcf956ad18a..bb1981fd60f3 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 | */ | ||
160 | struct 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 | */ | ||
175 | union 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]; |
@@ -373,6 +421,7 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb, | |||
373 | #endif | 421 | #endif |
374 | 422 | ||
375 | extern void kfree_skb(struct sk_buff *skb); | 423 | extern void kfree_skb(struct sk_buff *skb); |
424 | extern void consume_skb(struct sk_buff *skb); | ||
376 | extern void __kfree_skb(struct sk_buff *skb); | 425 | extern void __kfree_skb(struct sk_buff *skb); |
377 | extern struct sk_buff *__alloc_skb(unsigned int size, | 426 | extern struct sk_buff *__alloc_skb(unsigned int size, |
378 | gfp_t priority, int fclone, int node); | 427 | gfp_t priority, int fclone, int node); |
@@ -411,7 +460,8 @@ extern int skb_to_sgvec(struct sk_buff *skb, | |||
411 | extern int skb_cow_data(struct sk_buff *skb, int tailbits, | 460 | extern int skb_cow_data(struct sk_buff *skb, int tailbits, |
412 | struct sk_buff **trailer); | 461 | struct sk_buff **trailer); |
413 | extern int skb_pad(struct sk_buff *skb, int pad); | 462 | extern int skb_pad(struct sk_buff *skb, int pad); |
414 | #define dev_kfree_skb(a) kfree_skb(a) | 463 | #define dev_kfree_skb(a) consume_skb(a) |
464 | #define dev_consume_skb(a) kfree_skb_clean(a) | ||
415 | extern void skb_over_panic(struct sk_buff *skb, int len, | 465 | extern void skb_over_panic(struct sk_buff *skb, int len, |
416 | void *here); | 466 | void *here); |
417 | extern void skb_under_panic(struct sk_buff *skb, int len, | 467 | extern void skb_under_panic(struct sk_buff *skb, int len, |
@@ -459,6 +509,16 @@ static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) | |||
459 | /* Internal */ | 509 | /* Internal */ |
460 | #define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) | 510 | #define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) |
461 | 511 | ||
512 | static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb) | ||
513 | { | ||
514 | return &skb_shinfo(skb)->hwtstamps; | ||
515 | } | ||
516 | |||
517 | static inline union skb_shared_tx *skb_tx(struct sk_buff *skb) | ||
518 | { | ||
519 | return &skb_shinfo(skb)->tx_flags; | ||
520 | } | ||
521 | |||
462 | /** | 522 | /** |
463 | * skb_queue_empty - check if a queue is empty | 523 | * skb_queue_empty - check if a queue is empty |
464 | * @list: queue head | 524 | * @list: queue head |
@@ -1278,7 +1338,7 @@ static inline int skb_network_offset(const struct sk_buff *skb) | |||
1278 | * The networking layer reserves some headroom in skb data (via | 1338 | * 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 | 1339 | * 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 | 1340 | * the header has to grow. In the default case, if the header has to grow |
1281 | * 16 bytes or less we avoid the reallocation. | 1341 | * 32 bytes or less we avoid the reallocation. |
1282 | * | 1342 | * |
1283 | * Unfortunately this headroom changes the DMA alignment of the resulting | 1343 | * Unfortunately this headroom changes the DMA alignment of the resulting |
1284 | * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive | 1344 | * network packet. As for NET_IP_ALIGN, this unaligned DMA is expensive |
@@ -1286,11 +1346,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 | 1346 | * 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. | 1347 | * cacheline alignment of the DMA). It must be a power of 2. |
1288 | * | 1348 | * |
1289 | * Various parts of the networking layer expect at least 16 bytes of | 1349 | * Various parts of the networking layer expect at least 32 bytes of |
1290 | * headroom, you should not reduce this. | 1350 | * headroom, you should not reduce this. |
1291 | */ | 1351 | */ |
1292 | #ifndef NET_SKB_PAD | 1352 | #ifndef NET_SKB_PAD |
1293 | #define NET_SKB_PAD 16 | 1353 | #define NET_SKB_PAD 32 |
1294 | #endif | 1354 | #endif |
1295 | 1355 | ||
1296 | extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); | 1356 | extern int ___pskb_trim(struct sk_buff *skb, unsigned int len); |
@@ -1678,8 +1738,6 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, | |||
1678 | int shiftlen); | 1738 | int shiftlen); |
1679 | 1739 | ||
1680 | extern struct sk_buff *skb_segment(struct sk_buff *skb, int features); | 1740 | extern struct sk_buff *skb_segment(struct sk_buff *skb, int features); |
1681 | extern int skb_gro_receive(struct sk_buff **head, | ||
1682 | struct sk_buff *skb); | ||
1683 | 1741 | ||
1684 | static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, | 1742 | static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, |
1685 | int len, void *buffer) | 1743 | int len, void *buffer) |
@@ -1726,6 +1784,11 @@ static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb, | |||
1726 | 1784 | ||
1727 | extern void skb_init(void); | 1785 | extern void skb_init(void); |
1728 | 1786 | ||
1787 | static inline ktime_t skb_get_ktime(const struct sk_buff *skb) | ||
1788 | { | ||
1789 | return skb->tstamp; | ||
1790 | } | ||
1791 | |||
1729 | /** | 1792 | /** |
1730 | * skb_get_timestamp - get timestamp from a skb | 1793 | * skb_get_timestamp - get timestamp from a skb |
1731 | * @skb: skb to get stamp from | 1794 | * @skb: skb to get stamp from |
@@ -1735,11 +1798,18 @@ extern void skb_init(void); | |||
1735 | * This function converts the offset back to a struct timeval and stores | 1798 | * This function converts the offset back to a struct timeval and stores |
1736 | * it in stamp. | 1799 | * it in stamp. |
1737 | */ | 1800 | */ |
1738 | static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp) | 1801 | static inline void skb_get_timestamp(const struct sk_buff *skb, |
1802 | struct timeval *stamp) | ||
1739 | { | 1803 | { |
1740 | *stamp = ktime_to_timeval(skb->tstamp); | 1804 | *stamp = ktime_to_timeval(skb->tstamp); |
1741 | } | 1805 | } |
1742 | 1806 | ||
1807 | static inline void skb_get_timestampns(const struct sk_buff *skb, | ||
1808 | struct timespec *stamp) | ||
1809 | { | ||
1810 | *stamp = ktime_to_timespec(skb->tstamp); | ||
1811 | } | ||
1812 | |||
1743 | static inline void __net_timestamp(struct sk_buff *skb) | 1813 | static inline void __net_timestamp(struct sk_buff *skb) |
1744 | { | 1814 | { |
1745 | skb->tstamp = ktime_get_real(); | 1815 | skb->tstamp = ktime_get_real(); |
@@ -1755,6 +1825,20 @@ static inline ktime_t net_invalid_timestamp(void) | |||
1755 | return ktime_set(0, 0); | 1825 | return ktime_set(0, 0); |
1756 | } | 1826 | } |
1757 | 1827 | ||
1828 | /** | ||
1829 | * skb_tstamp_tx - queue clone of skb with send time stamps | ||
1830 | * @orig_skb: the original outgoing packet | ||
1831 | * @hwtstamps: hardware time stamps, may be NULL if not available | ||
1832 | * | ||
1833 | * If the skb has a socket associated, then this function clones the | ||
1834 | * skb (thus sharing the actual data and optional structures), stores | ||
1835 | * the optional hardware time stamping information (if non NULL) or | ||
1836 | * generates a software time stamp (otherwise), then queues the clone | ||
1837 | * to the error queue of the socket. Errors are silently ignored. | ||
1838 | */ | ||
1839 | extern void skb_tstamp_tx(struct sk_buff *orig_skb, | ||
1840 | struct skb_shared_hwtstamps *hwtstamps); | ||
1841 | |||
1758 | extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); | 1842 | extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); |
1759 | extern __sum16 __skb_checksum_complete(struct sk_buff *skb); | 1843 | extern __sum16 __skb_checksum_complete(struct sk_buff *skb); |
1760 | 1844 | ||
@@ -1885,7 +1969,7 @@ static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping) | |||
1885 | skb->queue_mapping = queue_mapping; | 1969 | skb->queue_mapping = queue_mapping; |
1886 | } | 1970 | } |
1887 | 1971 | ||
1888 | static inline u16 skb_get_queue_mapping(struct sk_buff *skb) | 1972 | static inline u16 skb_get_queue_mapping(const struct sk_buff *skb) |
1889 | { | 1973 | { |
1890 | return skb->queue_mapping; | 1974 | return skb->queue_mapping; |
1891 | } | 1975 | } |
@@ -1895,6 +1979,24 @@ static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_bu | |||
1895 | to->queue_mapping = from->queue_mapping; | 1979 | to->queue_mapping = from->queue_mapping; |
1896 | } | 1980 | } |
1897 | 1981 | ||
1982 | static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue) | ||
1983 | { | ||
1984 | skb->queue_mapping = rx_queue + 1; | ||
1985 | } | ||
1986 | |||
1987 | static inline u16 skb_get_rx_queue(const struct sk_buff *skb) | ||
1988 | { | ||
1989 | return skb->queue_mapping - 1; | ||
1990 | } | ||
1991 | |||
1992 | static inline bool skb_rx_queue_recorded(const struct sk_buff *skb) | ||
1993 | { | ||
1994 | return (skb->queue_mapping != 0); | ||
1995 | } | ||
1996 | |||
1997 | extern u16 skb_tx_hash(const struct net_device *dev, | ||
1998 | const struct sk_buff *skb); | ||
1999 | |||
1898 | #ifdef CONFIG_XFRM | 2000 | #ifdef CONFIG_XFRM |
1899 | static inline struct sec_path *skb_sec_path(struct sk_buff *skb) | 2001 | static inline struct sec_path *skb_sec_path(struct sk_buff *skb) |
1900 | { | 2002 | { |