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.h104
1 files changed, 86 insertions, 18 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6b8466365fbd..08074a810164 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -32,6 +32,7 @@
32#include <linux/hrtimer.h> 32#include <linux/hrtimer.h>
33#include <linux/dma-mapping.h> 33#include <linux/dma-mapping.h>
34#include <linux/netdev_features.h> 34#include <linux/netdev_features.h>
35#include <linux/sched.h>
35#include <net/flow_keys.h> 36#include <net/flow_keys.h>
36 37
37/* A. Checksumming of received packets by device. 38/* A. Checksumming of received packets by device.
@@ -356,11 +357,62 @@ typedef unsigned int sk_buff_data_t;
356typedef unsigned char *sk_buff_data_t; 357typedef unsigned char *sk_buff_data_t;
357#endif 358#endif
358 359
360/**
361 * struct skb_mstamp - multi resolution time stamps
362 * @stamp_us: timestamp in us resolution
363 * @stamp_jiffies: timestamp in jiffies
364 */
365struct skb_mstamp {
366 union {
367 u64 v64;
368 struct {
369 u32 stamp_us;
370 u32 stamp_jiffies;
371 };
372 };
373};
374
375/**
376 * skb_mstamp_get - get current timestamp
377 * @cl: place to store timestamps
378 */
379static inline void skb_mstamp_get(struct skb_mstamp *cl)
380{
381 u64 val = local_clock();
382
383 do_div(val, NSEC_PER_USEC);
384 cl->stamp_us = (u32)val;
385 cl->stamp_jiffies = (u32)jiffies;
386}
387
388/**
389 * skb_mstamp_delta - compute the difference in usec between two skb_mstamp
390 * @t1: pointer to newest sample
391 * @t0: pointer to oldest sample
392 */
393static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
394 const struct skb_mstamp *t0)
395{
396 s32 delta_us = t1->stamp_us - t0->stamp_us;
397 u32 delta_jiffies = t1->stamp_jiffies - t0->stamp_jiffies;
398
399 /* If delta_us is negative, this might be because interval is too big,
400 * or local_clock() drift is too big : fallback using jiffies.
401 */
402 if (delta_us <= 0 ||
403 delta_jiffies >= (INT_MAX / (USEC_PER_SEC / HZ)))
404
405 delta_us = jiffies_to_usecs(delta_jiffies);
406
407 return delta_us;
408}
409
410
359/** 411/**
360 * struct sk_buff - socket buffer 412 * struct sk_buff - socket buffer
361 * @next: Next buffer in list 413 * @next: Next buffer in list
362 * @prev: Previous buffer in list 414 * @prev: Previous buffer in list
363 * @tstamp: Time we arrived 415 * @tstamp: Time we arrived/left
364 * @sk: Socket we are owned by 416 * @sk: Socket we are owned by
365 * @dev: Device we arrived on/are leaving by 417 * @dev: Device we arrived on/are leaving by
366 * @cb: Control buffer. Free for use by every layer. Put private vars here 418 * @cb: Control buffer. Free for use by every layer. Put private vars here
@@ -392,11 +444,11 @@ typedef unsigned char *sk_buff_data_t;
392 * @skb_iif: ifindex of device we arrived on 444 * @skb_iif: ifindex of device we arrived on
393 * @tc_index: Traffic control index 445 * @tc_index: Traffic control index
394 * @tc_verd: traffic control verdict 446 * @tc_verd: traffic control verdict
395 * @rxhash: the packet hash computed on receive 447 * @hash: the packet hash
396 * @queue_mapping: Queue mapping for multiqueue devices 448 * @queue_mapping: Queue mapping for multiqueue devices
397 * @ndisc_nodetype: router type (from link layer) 449 * @ndisc_nodetype: router type (from link layer)
398 * @ooo_okay: allow the mapping of a socket to a queue to be changed 450 * @ooo_okay: allow the mapping of a socket to a queue to be changed
399 * @l4_rxhash: indicate rxhash is a canonical 4-tuple hash over transport 451 * @l4_hash: indicate hash is a canonical 4-tuple hash over transport
400 * ports. 452 * ports.
401 * @wifi_acked_valid: wifi_acked was set 453 * @wifi_acked_valid: wifi_acked was set
402 * @wifi_acked: whether frame was acked on wifi or not 454 * @wifi_acked: whether frame was acked on wifi or not
@@ -429,7 +481,10 @@ struct sk_buff {
429 struct sk_buff *next; 481 struct sk_buff *next;
430 struct sk_buff *prev; 482 struct sk_buff *prev;
431 483
432 ktime_t tstamp; 484 union {
485 ktime_t tstamp;
486 struct skb_mstamp skb_mstamp;
487 };
433 488
434 struct sock *sk; 489 struct sock *sk;
435 struct net_device *dev; 490 struct net_device *dev;
@@ -482,7 +537,7 @@ struct sk_buff {
482 537
483 int skb_iif; 538 int skb_iif;
484 539
485 __u32 rxhash; 540 __u32 hash;
486 541
487 __be16 vlan_proto; 542 __be16 vlan_proto;
488 __u16 vlan_tci; 543 __u16 vlan_tci;
@@ -501,7 +556,7 @@ struct sk_buff {
501#endif 556#endif
502 __u8 pfmemalloc:1; 557 __u8 pfmemalloc:1;
503 __u8 ooo_okay:1; 558 __u8 ooo_okay:1;
504 __u8 l4_rxhash:1; 559 __u8 l4_hash:1;
505 __u8 wifi_acked_valid:1; 560 __u8 wifi_acked_valid:1;
506 __u8 wifi_acked:1; 561 __u8 wifi_acked:1;
507 __u8 no_fcs:1; 562 __u8 no_fcs:1;
@@ -691,6 +746,8 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
691 unsigned int headroom); 746 unsigned int headroom);
692struct sk_buff *skb_copy_expand(const struct sk_buff *skb, int newheadroom, 747struct sk_buff *skb_copy_expand(const struct sk_buff *skb, int newheadroom,
693 int newtailroom, gfp_t priority); 748 int newtailroom, gfp_t priority);
749int skb_to_sgvec_nomark(struct sk_buff *skb, struct scatterlist *sg,
750 int offset, int len);
694int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, 751int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset,
695 int len); 752 int len);
696int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer); 753int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
@@ -758,40 +815,40 @@ enum pkt_hash_types {
758static inline void 815static inline void
759skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type) 816skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
760{ 817{
761 skb->l4_rxhash = (type == PKT_HASH_TYPE_L4); 818 skb->l4_hash = (type == PKT_HASH_TYPE_L4);
762 skb->rxhash = hash; 819 skb->hash = hash;
763} 820}
764 821
765void __skb_get_hash(struct sk_buff *skb); 822void __skb_get_hash(struct sk_buff *skb);
766static inline __u32 skb_get_hash(struct sk_buff *skb) 823static inline __u32 skb_get_hash(struct sk_buff *skb)
767{ 824{
768 if (!skb->l4_rxhash) 825 if (!skb->l4_hash)
769 __skb_get_hash(skb); 826 __skb_get_hash(skb);
770 827
771 return skb->rxhash; 828 return skb->hash;
772} 829}
773 830
774static inline __u32 skb_get_hash_raw(const struct sk_buff *skb) 831static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
775{ 832{
776 return skb->rxhash; 833 return skb->hash;
777} 834}
778 835
779static inline void skb_clear_hash(struct sk_buff *skb) 836static inline void skb_clear_hash(struct sk_buff *skb)
780{ 837{
781 skb->rxhash = 0; 838 skb->hash = 0;
782 skb->l4_rxhash = 0; 839 skb->l4_hash = 0;
783} 840}
784 841
785static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb) 842static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb)
786{ 843{
787 if (!skb->l4_rxhash) 844 if (!skb->l4_hash)
788 skb_clear_hash(skb); 845 skb_clear_hash(skb);
789} 846}
790 847
791static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from) 848static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
792{ 849{
793 to->rxhash = from->rxhash; 850 to->hash = from->hash;
794 to->l4_rxhash = from->l4_rxhash; 851 to->l4_hash = from->l4_hash;
795}; 852};
796 853
797#ifdef NET_SKBUFF_DATA_USES_OFFSET 854#ifdef NET_SKBUFF_DATA_USES_OFFSET
@@ -2573,8 +2630,6 @@ static inline ktime_t net_invalid_timestamp(void)
2573 return ktime_set(0, 0); 2630 return ktime_set(0, 0);
2574} 2631}
2575 2632
2576void skb_timestamping_init(void);
2577
2578#ifdef CONFIG_NETWORK_PHY_TIMESTAMPING 2633#ifdef CONFIG_NETWORK_PHY_TIMESTAMPING
2579 2634
2580void skb_clone_tx_timestamp(struct sk_buff *skb); 2635void skb_clone_tx_timestamp(struct sk_buff *skb);
@@ -2776,6 +2831,19 @@ static inline void skb_init_secmark(struct sk_buff *skb)
2776{ } 2831{ }
2777#endif 2832#endif
2778 2833
2834static inline bool skb_irq_freeable(const struct sk_buff *skb)
2835{
2836 return !skb->destructor &&
2837#if IS_ENABLED(CONFIG_XFRM)
2838 !skb->sp &&
2839#endif
2840#if IS_ENABLED(CONFIG_NF_CONNTRACK)
2841 !skb->nfct &&
2842#endif
2843 !skb->_skb_refdst &&
2844 !skb_has_frag_list(skb);
2845}
2846
2779static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping) 2847static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
2780{ 2848{
2781 skb->queue_mapping = queue_mapping; 2849 skb->queue_mapping = queue_mapping;