aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-02 23:53:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-02 23:53:45 -0400
commitcd6362befe4cc7bf589a5236d2a780af2d47bcc9 (patch)
tree3bd4e13ec3f92a00dc4f6c3d65e820b54dbfe46e /include/linux/skbuff.h
parent0f1b1e6d73cb989ce2c071edc57deade3b084dfe (diff)
parentb1586f099ba897542ece36e8a23c1a62907261ef (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Here is my initial pull request for the networking subsystem during this merge window: 1) Support for ESN in AH (RFC 4302) from Fan Du. 2) Add full kernel doc for ethtool command structures, from Ben Hutchings. 3) Add BCM7xxx PHY driver, from Florian Fainelli. 4) Export computed TCP rate information in netlink socket dumps, from Eric Dumazet. 5) Allow IPSEC SA to be dumped partially using a filter, from Nicolas Dichtel. 6) Convert many drivers to pci_enable_msix_range(), from Alexander Gordeev. 7) Record SKB timestamps more efficiently, from Eric Dumazet. 8) Switch to microsecond resolution for TCP round trip times, also from Eric Dumazet. 9) Clean up and fix 6lowpan fragmentation handling by making use of the existing inet_frag api for it's implementation. 10) Add TX grant mapping to xen-netback driver, from Zoltan Kiss. 11) Auto size SKB lengths when composing netlink messages based upon past message sizes used, from Eric Dumazet. 12) qdisc dumps can take a long time, add a cond_resched(), From Eric Dumazet. 13) Sanitize netpoll core and drivers wrt. SKB handling semantics. Get rid of never-used-in-tree netpoll RX handling. From Eric W Biederman. 14) Support inter-address-family and namespace changing in VTI tunnel driver(s). From Steffen Klassert. 15) Add Altera TSE driver, from Vince Bridgers. 16) Optimizing csum_replace2() so that it doesn't adjust the checksum by checksumming the entire header, from Eric Dumazet. 17) Expand BPF internal implementation for faster interpreting, more direct translations into JIT'd code, and much cleaner uses of BPF filtering in non-socket ocntexts. From Daniel Borkmann and Alexei Starovoitov" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1976 commits) netpoll: Use skb_irq_freeable to make zap_completion_queue safe. net: Add a test to see if a skb is freeable in irq context qlcnic: Fix build failure due to undefined reference to `vxlan_get_rx_port' net: ptp: move PTP classifier in its own file net: sxgbe: make "core_ops" static net: sxgbe: fix logical vs bitwise operation net: sxgbe: sxgbe_mdio_register() frees the bus Call efx_set_channels() before efx->type->dimension_resources() xen-netback: disable rogue vif in kthread context net/mlx4: Set proper build dependancy with vxlan be2net: fix build dependency on VxLAN mac802154: make csma/cca parameters per-wpan mac802154: allow only one WPAN to be up at any given time net: filter: minor: fix kdoc in __sk_run_filter netlink: don't compare the nul-termination in nla_strcmp can: c_can: Avoid led toggling for every packet. can: c_can: Simplify TX interrupt cleanup can: c_can: Store dlc private can: c_can: Reduce register access can: c_can: Make the code readable ...
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;