diff options
Diffstat (limited to 'include/linux/skbuff.h')
| -rw-r--r-- | include/linux/skbuff.h | 117 |
1 files changed, 67 insertions, 50 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 77eb60d2b496..e6ba898de61c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
| @@ -129,8 +129,13 @@ typedef struct skb_frag_struct skb_frag_t; | |||
| 129 | 129 | ||
| 130 | struct skb_frag_struct { | 130 | struct skb_frag_struct { |
| 131 | struct page *page; | 131 | struct page *page; |
| 132 | #if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536) | ||
| 132 | __u32 page_offset; | 133 | __u32 page_offset; |
| 133 | __u32 size; | 134 | __u32 size; |
| 135 | #else | ||
| 136 | __u16 page_offset; | ||
| 137 | __u16 size; | ||
| 138 | #endif | ||
| 134 | }; | 139 | }; |
| 135 | 140 | ||
| 136 | #define HAVE_HW_TIME_STAMP | 141 | #define HAVE_HW_TIME_STAMP |
| @@ -163,26 +168,19 @@ struct skb_shared_hwtstamps { | |||
| 163 | ktime_t syststamp; | 168 | ktime_t syststamp; |
| 164 | }; | 169 | }; |
| 165 | 170 | ||
| 166 | /** | 171 | /* Definitions for tx_flags in struct skb_shared_info */ |
| 167 | * struct skb_shared_tx - instructions for time stamping of outgoing packets | 172 | enum { |
| 168 | * @hardware: generate hardware time stamp | 173 | /* generate hardware time stamp */ |
| 169 | * @software: generate software time stamp | 174 | SKBTX_HW_TSTAMP = 1 << 0, |
| 170 | * @in_progress: device driver is going to provide | 175 | |
| 171 | * hardware time stamp | 176 | /* generate software time stamp */ |
| 172 | * @prevent_sk_orphan: make sk reference available on driver level | 177 | SKBTX_SW_TSTAMP = 1 << 1, |
| 173 | * @flags: all shared_tx flags | 178 | |
| 174 | * | 179 | /* device driver is going to provide hardware time stamp */ |
| 175 | * These flags are attached to packets as part of the | 180 | SKBTX_IN_PROGRESS = 1 << 2, |
| 176 | * &skb_shared_info. Use skb_tx() to get a pointer. | 181 | |
| 177 | */ | 182 | /* ensure the originating sk reference is available on driver level */ |
| 178 | union skb_shared_tx { | 183 | SKBTX_DRV_NEEDS_SK_REF = 1 << 3, |
| 179 | struct { | ||
| 180 | __u8 hardware:1, | ||
| 181 | software:1, | ||
| 182 | in_progress:1, | ||
| 183 | prevent_sk_orphan:1; | ||
| 184 | }; | ||
| 185 | __u8 flags; | ||
| 186 | }; | 184 | }; |
| 187 | 185 | ||
| 188 | /* This data is invariant across clones and lives at | 186 | /* This data is invariant across clones and lives at |
| @@ -195,7 +193,7 @@ struct skb_shared_info { | |||
| 195 | unsigned short gso_segs; | 193 | unsigned short gso_segs; |
| 196 | unsigned short gso_type; | 194 | unsigned short gso_type; |
| 197 | __be32 ip6_frag_id; | 195 | __be32 ip6_frag_id; |
| 198 | union skb_shared_tx tx_flags; | 196 | __u8 tx_flags; |
| 199 | struct sk_buff *frag_list; | 197 | struct sk_buff *frag_list; |
| 200 | struct skb_shared_hwtstamps hwtstamps; | 198 | struct skb_shared_hwtstamps hwtstamps; |
| 201 | 199 | ||
| @@ -462,19 +460,7 @@ static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) | |||
| 462 | skb->_skb_refdst = (unsigned long)dst; | 460 | skb->_skb_refdst = (unsigned long)dst; |
| 463 | } | 461 | } |
| 464 | 462 | ||
| 465 | /** | 463 | extern void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst); |
| 466 | * skb_dst_set_noref - sets skb dst, without a reference | ||
| 467 | * @skb: buffer | ||
| 468 | * @dst: dst entry | ||
| 469 | * | ||
| 470 | * Sets skb dst, assuming a reference was not taken on dst | ||
| 471 | * skb_dst_drop() should not dst_release() this dst | ||
| 472 | */ | ||
| 473 | static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst) | ||
| 474 | { | ||
| 475 | WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held()); | ||
| 476 | skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; | ||
| 477 | } | ||
| 478 | 464 | ||
| 479 | /** | 465 | /** |
| 480 | * skb_dst_is_noref - Test if skb dst isnt refcounted | 466 | * skb_dst_is_noref - Test if skb dst isnt refcounted |
| @@ -498,13 +484,13 @@ extern struct sk_buff *__alloc_skb(unsigned int size, | |||
| 498 | static inline struct sk_buff *alloc_skb(unsigned int size, | 484 | static inline struct sk_buff *alloc_skb(unsigned int size, |
| 499 | gfp_t priority) | 485 | gfp_t priority) |
| 500 | { | 486 | { |
| 501 | return __alloc_skb(size, priority, 0, -1); | 487 | return __alloc_skb(size, priority, 0, NUMA_NO_NODE); |
| 502 | } | 488 | } |
| 503 | 489 | ||
| 504 | static inline struct sk_buff *alloc_skb_fclone(unsigned int size, | 490 | static inline struct sk_buff *alloc_skb_fclone(unsigned int size, |
| 505 | gfp_t priority) | 491 | gfp_t priority) |
| 506 | { | 492 | { |
| 507 | return __alloc_skb(size, priority, 1, -1); | 493 | return __alloc_skb(size, priority, 1, NUMA_NO_NODE); |
| 508 | } | 494 | } |
| 509 | 495 | ||
| 510 | extern bool skb_recycle_check(struct sk_buff *skb, int skb_size); | 496 | extern bool skb_recycle_check(struct sk_buff *skb, int skb_size); |
| @@ -558,6 +544,15 @@ extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, | |||
| 558 | unsigned int to, struct ts_config *config, | 544 | unsigned int to, struct ts_config *config, |
| 559 | struct ts_state *state); | 545 | struct ts_state *state); |
| 560 | 546 | ||
| 547 | extern __u32 __skb_get_rxhash(struct sk_buff *skb); | ||
| 548 | static inline __u32 skb_get_rxhash(struct sk_buff *skb) | ||
| 549 | { | ||
| 550 | if (!skb->rxhash) | ||
| 551 | skb->rxhash = __skb_get_rxhash(skb); | ||
| 552 | |||
| 553 | return skb->rxhash; | ||
| 554 | } | ||
| 555 | |||
| 561 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | 556 | #ifdef NET_SKBUFF_DATA_USES_OFFSET |
| 562 | static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) | 557 | static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) |
| 563 | { | 558 | { |
| @@ -578,11 +573,6 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb) | |||
| 578 | return &skb_shinfo(skb)->hwtstamps; | 573 | return &skb_shinfo(skb)->hwtstamps; |
| 579 | } | 574 | } |
| 580 | 575 | ||
| 581 | static inline union skb_shared_tx *skb_tx(struct sk_buff *skb) | ||
| 582 | { | ||
| 583 | return &skb_shinfo(skb)->tx_flags; | ||
| 584 | } | ||
| 585 | |||
| 586 | /** | 576 | /** |
| 587 | * skb_queue_empty - check if a queue is empty | 577 | * skb_queue_empty - check if a queue is empty |
| 588 | * @list: queue head | 578 | * @list: queue head |
| @@ -604,7 +594,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list) | |||
| 604 | static inline bool skb_queue_is_last(const struct sk_buff_head *list, | 594 | static inline bool skb_queue_is_last(const struct sk_buff_head *list, |
| 605 | const struct sk_buff *skb) | 595 | const struct sk_buff *skb) |
| 606 | { | 596 | { |
| 607 | return (skb->next == (struct sk_buff *) list); | 597 | return skb->next == (struct sk_buff *)list; |
| 608 | } | 598 | } |
| 609 | 599 | ||
| 610 | /** | 600 | /** |
| @@ -617,7 +607,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list, | |||
| 617 | static inline bool skb_queue_is_first(const struct sk_buff_head *list, | 607 | static inline bool skb_queue_is_first(const struct sk_buff_head *list, |
| 618 | const struct sk_buff *skb) | 608 | const struct sk_buff *skb) |
| 619 | { | 609 | { |
| 620 | return (skb->prev == (struct sk_buff *) list); | 610 | return skb->prev == (struct sk_buff *)list; |
| 621 | } | 611 | } |
| 622 | 612 | ||
| 623 | /** | 613 | /** |
| @@ -1123,7 +1113,7 @@ extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, | |||
| 1123 | int off, int size); | 1113 | int off, int size); |
| 1124 | 1114 | ||
| 1125 | #define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) | 1115 | #define SKB_PAGE_ASSERT(skb) BUG_ON(skb_shinfo(skb)->nr_frags) |
| 1126 | #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frags(skb)) | 1116 | #define SKB_FRAG_ASSERT(skb) BUG_ON(skb_has_frag_list(skb)) |
| 1127 | #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) | 1117 | #define SKB_LINEAR_ASSERT(skb) BUG_ON(skb_is_nonlinear(skb)) |
| 1128 | 1118 | ||
| 1129 | #ifdef NET_SKBUFF_DATA_USES_OFFSET | 1119 | #ifdef NET_SKBUFF_DATA_USES_OFFSET |
| @@ -1561,13 +1551,25 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, | |||
| 1561 | return skb; | 1551 | return skb; |
| 1562 | } | 1552 | } |
| 1563 | 1553 | ||
| 1564 | extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask); | 1554 | /** |
| 1555 | * __netdev_alloc_page - allocate a page for ps-rx on a specific device | ||
| 1556 | * @dev: network device to receive on | ||
| 1557 | * @gfp_mask: alloc_pages_node mask | ||
| 1558 | * | ||
| 1559 | * Allocate a new page. dev currently unused. | ||
| 1560 | * | ||
| 1561 | * %NULL is returned if there is no free memory. | ||
| 1562 | */ | ||
| 1563 | static inline struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask) | ||
| 1564 | { | ||
| 1565 | return alloc_pages_node(NUMA_NO_NODE, gfp_mask, 0); | ||
| 1566 | } | ||
| 1565 | 1567 | ||
| 1566 | /** | 1568 | /** |
| 1567 | * netdev_alloc_page - allocate a page for ps-rx on a specific device | 1569 | * netdev_alloc_page - allocate a page for ps-rx on a specific device |
| 1568 | * @dev: network device to receive on | 1570 | * @dev: network device to receive on |
| 1569 | * | 1571 | * |
| 1570 | * Allocate a new page node local to the specified device. | 1572 | * Allocate a new page. dev currently unused. |
| 1571 | * | 1573 | * |
| 1572 | * %NULL is returned if there is no free memory. | 1574 | * %NULL is returned if there is no free memory. |
| 1573 | */ | 1575 | */ |
| @@ -1787,7 +1789,7 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len) | |||
| 1787 | skb = skb->prev) | 1789 | skb = skb->prev) |
| 1788 | 1790 | ||
| 1789 | 1791 | ||
| 1790 | static inline bool skb_has_frags(const struct sk_buff *skb) | 1792 | static inline bool skb_has_frag_list(const struct sk_buff *skb) |
| 1791 | { | 1793 | { |
| 1792 | return skb_shinfo(skb)->frag_list != NULL; | 1794 | return skb_shinfo(skb)->frag_list != NULL; |
| 1793 | } | 1795 | } |
| @@ -1987,8 +1989,8 @@ extern void skb_tstamp_tx(struct sk_buff *orig_skb, | |||
| 1987 | 1989 | ||
| 1988 | static inline void sw_tx_timestamp(struct sk_buff *skb) | 1990 | static inline void sw_tx_timestamp(struct sk_buff *skb) |
| 1989 | { | 1991 | { |
| 1990 | union skb_shared_tx *shtx = skb_tx(skb); | 1992 | if (skb_shinfo(skb)->tx_flags & SKBTX_SW_TSTAMP && |
| 1991 | if (shtx->software && !shtx->in_progress) | 1993 | !(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) |
| 1992 | skb_tstamp_tx(skb, NULL); | 1994 | skb_tstamp_tx(skb, NULL); |
| 1993 | } | 1995 | } |
| 1994 | 1996 | ||
| @@ -2159,7 +2161,7 @@ static inline u16 skb_get_rx_queue(const struct sk_buff *skb) | |||
| 2159 | 2161 | ||
| 2160 | static inline bool skb_rx_queue_recorded(const struct sk_buff *skb) | 2162 | static inline bool skb_rx_queue_recorded(const struct sk_buff *skb) |
| 2161 | { | 2163 | { |
| 2162 | return (skb->queue_mapping != 0); | 2164 | return skb->queue_mapping != 0; |
| 2163 | } | 2165 | } |
| 2164 | 2166 | ||
| 2165 | extern u16 skb_tx_hash(const struct net_device *dev, | 2167 | extern u16 skb_tx_hash(const struct net_device *dev, |
| @@ -2209,6 +2211,21 @@ static inline void skb_forward_csum(struct sk_buff *skb) | |||
| 2209 | skb->ip_summed = CHECKSUM_NONE; | 2211 | skb->ip_summed = CHECKSUM_NONE; |
| 2210 | } | 2212 | } |
| 2211 | 2213 | ||
| 2214 | /** | ||
| 2215 | * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE | ||
| 2216 | * @skb: skb to check | ||
| 2217 | * | ||
| 2218 | * fresh skbs have their ip_summed set to CHECKSUM_NONE. | ||
| 2219 | * Instead of forcing ip_summed to CHECKSUM_NONE, we can | ||
| 2220 | * use this helper, to document places where we make this assertion. | ||
| 2221 | */ | ||
| 2222 | static inline void skb_checksum_none_assert(struct sk_buff *skb) | ||
| 2223 | { | ||
| 2224 | #ifdef DEBUG | ||
| 2225 | BUG_ON(skb->ip_summed != CHECKSUM_NONE); | ||
| 2226 | #endif | ||
| 2227 | } | ||
| 2228 | |||
| 2212 | bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off); | 2229 | bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off); |
| 2213 | #endif /* __KERNEL__ */ | 2230 | #endif /* __KERNEL__ */ |
| 2214 | #endif /* _LINUX_SKBUFF_H */ | 2231 | #endif /* _LINUX_SKBUFF_H */ |
