[NET]: convert network timestamps to ktime_t
[pandora-kernel.git] / include / linux / skbuff.h
index 755e9cd..f9441b5 100644 (file)
 #include <asm/atomic.h>
 #include <asm/types.h>
 #include <linux/spinlock.h>
-#include <linux/mm.h>
-#include <linux/highmem.h>
-#include <linux/poll.h>
 #include <linux/net.h>
 #include <linux/textsearch.h>
 #include <net/checksum.h>
+#include <linux/rcupdate.h>
 #include <linux/dmaengine.h>
+#include <linux/hrtimer.h>
 
 #define HAVE_ALLOC_SKB         /* For the drivers to know */
 #define HAVE_ALIGNABLE_SKB     /* Ditto 8)                */
 
 #define CHECKSUM_NONE 0
-#define CHECKSUM_HW 1
+#define CHECKSUM_PARTIAL 1
 #define CHECKSUM_UNNECESSARY 2
+#define CHECKSUM_COMPLETE 3
 
 #define SKB_DATA_ALIGN(X)      (((X) + (SMP_CACHE_BYTES - 1)) & \
                                 ~(SMP_CACHE_BYTES - 1))
  *           Apparently with secret goal to sell you new device, when you
  *           will add new protocol to your host. F.e. IPv6. 8)
  *
- *     HW: the most generic way. Device supplied checksum of _all_
+ *     COMPLETE: the most generic way. Device supplied checksum of _all_
  *         the packet as seen by netif_rx in skb->csum.
  *         NOTE: Even if device supports only some protocols, but
- *         is able to produce some skb->csum, it MUST use HW,
+ *         is able to produce some skb->csum, it MUST use COMPLETE,
  *         not UNNECESSARY.
  *
  * B. Checksumming on output.
  *
  *     NONE: skb is checksummed by protocol or csum is not required.
  *
- *     HW: device is required to csum packet as seen by hard_start_xmit
+ *     PARTIAL: device is required to csum packet as seen by hard_start_xmit
  *     from skb->h.raw to the end and to record the checksum
  *     at skb->h.raw+skb->csum.
  *
@@ -138,7 +138,7 @@ struct skb_shared_info {
        /* Warning: this field is not always filled in (UFO)! */
        unsigned short  gso_segs;
        unsigned short  gso_type;
-       unsigned int    ip6_frag_id;
+       __be32          ip6_frag_id;
        struct sk_buff  *frag_list;
        skb_frag_t      frags[MAX_SKB_FRAGS];
 };
@@ -157,11 +157,6 @@ struct skb_shared_info {
 #define SKB_DATAREF_SHIFT 16
 #define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
 
-struct skb_timeval {
-       u32     off_sec;
-       u32     off_usec;
-};
-
 
 enum {
        SKB_FCLONE_UNAVAILABLE,
@@ -189,7 +184,7 @@ enum {
  *     @sk: Socket we are owned by
  *     @tstamp: Time we arrived
  *     @dev: Device we arrived on/are leaving by
- *     @input_dev: Device we arrived on
+ *     @iif: ifindex of device we arrived on
  *     @h: Transport layer header
  *     @nh: Network layer header
  *     @mac: Link layer header
@@ -215,7 +210,7 @@ enum {
  *     @tail: Tail pointer
  *     @end: End pointer
  *     @destructor: Destruct function
- *     @nfmark: Can be used for communication between hooks
+ *     @mark: Generic packet mark
  *     @nfct: Associated connection, if any
  *     @ipvs_property: skbuff is owned by ipvs
  *     @nfctinfo: Relationship of this skb to the connection
@@ -234,9 +229,10 @@ struct sk_buff {
        struct sk_buff          *prev;
 
        struct sock             *sk;
-       struct skb_timeval      tstamp;
+       ktime_t                 tstamp;
        struct net_device       *dev;
-       struct net_device       *input_dev;
+       int                     iif;
+       /* 4 byte hole on 64 bit*/
 
        union {
                struct tcphdr   *th;
@@ -272,8 +268,11 @@ struct sk_buff {
 
        unsigned int            len,
                                data_len,
-                               mac_len,
-                               csum;
+                               mac_len;
+       union {
+               __wsum          csum;
+               __u32           csum_offset;
+       };
        __u32                   priority;
        __u8                    local_df:1,
                                cloned:1,
@@ -294,7 +293,6 @@ struct sk_buff {
 #ifdef CONFIG_BRIDGE_NETFILTER
        struct nf_bridge_info   *nf_bridge;
 #endif
-       __u32                   nfmark;
 #endif /* CONFIG_NETFILTER */
 #ifdef CONFIG_NET_SCHED
        __u16                   tc_index;       /* traffic control index */
@@ -309,6 +307,7 @@ struct sk_buff {
        __u32                   secmark;
 #endif
 
+       __u32                   mark;
 
        /* These elements must be at the end, see alloc_skb() for details.  */
        unsigned int            truesize;
@@ -330,22 +329,19 @@ struct sk_buff {
 extern void kfree_skb(struct sk_buff *skb);
 extern void           __kfree_skb(struct sk_buff *skb);
 extern struct sk_buff *__alloc_skb(unsigned int size,
-                                  gfp_t priority, int fclone);
+                                  gfp_t priority, int fclone, int node);
 static inline struct sk_buff *alloc_skb(unsigned int size,
                                        gfp_t priority)
 {
-       return __alloc_skb(size, priority, 0);
+       return __alloc_skb(size, priority, 0, -1);
 }
 
 static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
                                               gfp_t priority)
 {
-       return __alloc_skb(size, priority, 1);
+       return __alloc_skb(size, priority, 1, -1);
 }
 
-extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
-                                           unsigned int size,
-                                           gfp_t priority);
 extern void           kfree_skbmem(struct sk_buff *skb);
 extern struct sk_buff *skb_clone(struct sk_buff *skb,
                                 gfp_t priority);
@@ -619,6 +615,13 @@ static inline void skb_queue_head_init(struct sk_buff_head *list)
        list->qlen = 0;
 }
 
+static inline void skb_queue_head_init_class(struct sk_buff_head *list,
+               struct lock_class_key *class)
+{
+       skb_queue_head_init(list);
+       lockdep_set_class(&list->lock, class);
+}
+
 /*
  *     Insert an sk_buff at the start of a list.
  *
@@ -1198,8 +1201,7 @@ static inline int skb_add_data(struct sk_buff *skb,
 
        if (skb->ip_summed == CHECKSUM_NONE) {
                int err = 0;
-               unsigned int csum = csum_and_copy_from_user(from,
-                                                           skb_put(skb, copy),
+               __wsum csum = csum_and_copy_from_user(from, skb_put(skb, copy),
                                                            copy, 0, &err);
                if (!err) {
                        skb->csum = csum_block_add(skb->csum, csum, off);
@@ -1261,14 +1263,14 @@ static inline int skb_linearize_cow(struct sk_buff *skb)
  *     @len: length of data pulled
  *
  *     After doing a pull on a received packet, you need to call this to
- *     update the CHECKSUM_HW checksum, or set ip_summed to CHECKSUM_NONE
- *     so that it can be recomputed from scratch.
+ *     update the CHECKSUM_COMPLETE checksum, or set ip_summed to
+ *     CHECKSUM_NONE so that it can be recomputed from scratch.
  */
 
 static inline void skb_postpull_rcsum(struct sk_buff *skb,
                                      const void *start, unsigned int len)
 {
-       if (skb->ip_summed == CHECKSUM_HW)
+       if (skb->ip_summed == CHECKSUM_COMPLETE)
                skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
 }
 
@@ -1287,29 +1289,11 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
 {
        if (likely(len >= skb->len))
                return 0;
-       if (skb->ip_summed == CHECKSUM_HW)
+       if (skb->ip_summed == CHECKSUM_COMPLETE)
                skb->ip_summed = CHECKSUM_NONE;
        return __pskb_trim(skb, len);
 }
 
-static inline void *kmap_skb_frag(const skb_frag_t *frag)
-{
-#ifdef CONFIG_HIGHMEM
-       BUG_ON(in_irq());
-
-       local_bh_disable();
-#endif
-       return kmap_atomic(frag->page, KM_SKB_DATA_SOFTIRQ);
-}
-
-static inline void kunmap_skb_frag(void *vaddr)
-{
-       kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
-#ifdef CONFIG_HIGHMEM
-       local_bh_enable();
-#endif
-}
-
 #define skb_queue_walk(queue, skb) \
                for (skb = (queue)->next;                                       \
                     prefetch(skb->next), (skb != (struct sk_buff *)(queue));   \
@@ -1334,15 +1318,15 @@ extern int             skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
 extern void           skb_free_datagram(struct sock *sk, struct sk_buff *skb);
 extern void           skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
                                         unsigned int flags);
-extern unsigned int    skb_checksum(const struct sk_buff *skb, int offset,
-                                   int len, unsigned int csum);
+extern __wsum         skb_checksum(const struct sk_buff *skb, int offset,
+                                   int len, __wsum csum);
 extern int            skb_copy_bits(const struct sk_buff *skb, int offset,
                                     void *to, int len);
 extern int            skb_store_bits(const struct sk_buff *skb, int offset,
                                      void *from, int len);
-extern unsigned int    skb_copy_and_csum_bits(const struct sk_buff *skb,
+extern __wsum         skb_copy_and_csum_bits(const struct sk_buff *skb,
                                              int offset, u8 *to, int len,
-                                             unsigned int csum);
+                                             __wsum csum);
 extern void           skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
 extern void           skb_split(struct sk_buff *skb,
                                 struct sk_buff *skb1, const u32 len);
@@ -1377,28 +1361,16 @@ extern void skb_add_mtu(int mtu);
  */
 static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp)
 {
-       stamp->tv_sec  = skb->tstamp.off_sec;
-       stamp->tv_usec = skb->tstamp.off_usec;
+       *stamp = ktime_to_timeval(skb->tstamp);
 }
 
-/**
- *     skb_set_timestamp - set timestamp of a skb
- *     @skb: skb to set stamp of
- *     @stamp: pointer to struct timeval to get stamp from
- *
- *     Timestamps are stored in the skb as offsets to a base timestamp.
- *     This function converts a struct timeval to an offset and stores
- *     it in the skb.
- */
-static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *stamp)
+static inline void __net_timestamp(struct sk_buff *skb)
 {
-       skb->tstamp.off_sec  = stamp->tv_sec;
-       skb->tstamp.off_usec = stamp->tv_usec;
+       skb->tstamp = ktime_get_real();
 }
 
-extern void __net_timestamp(struct sk_buff *skb);
 
-extern unsigned int __skb_checksum_complete(struct sk_buff *skb);
+extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
 
 /**
  *     skb_checksum_complete - Calculate checksum of an entire packet