Merge branch 'e1000-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[pandora-kernel.git] / include / linux / skbuff.h
index 3724790..2694cb3 100644 (file)
 #define HAVE_ALLOC_SKB         /* For the drivers to know */
 #define HAVE_ALIGNABLE_SKB     /* Ditto 8)                */
 
+/* Don't change this without changing skb_csum_unnecessary! */
 #define CHECKSUM_NONE 0
-#define CHECKSUM_PARTIAL 1
-#define CHECKSUM_UNNECESSARY 2
-#define CHECKSUM_COMPLETE 3
+#define CHECKSUM_UNNECESSARY 1
+#define CHECKSUM_COMPLETE 2
+#define CHECKSUM_PARTIAL 3
 
 #define SKB_DATA_ALIGN(X)      (((X) + (SMP_CACHE_BYTES - 1)) & \
                                 ~(SMP_CACHE_BYTES - 1))
@@ -86,6 +87,7 @@
  */
 
 struct net_device;
+struct scatterlist;
 
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
 struct nf_conntrack {
@@ -204,7 +206,9 @@ typedef unsigned char *sk_buff_data_t;
  *     @len: Length of actual data
  *     @data_len: Data length
  *     @mac_len: Length of link layer header
- *     @csum: Checksum
+ *     @csum: Checksum (must include start/offset pair)
+ *     @csum_start: Offset from skb->head where checksumming should start
+ *     @csum_offset: Offset from csum_start where checksum should be stored
  *     @local_df: allow local fragmentation
  *     @cloned: Head may be cloned (check refcnt to be sure)
  *     @nohdr: Payload reference only, must not modify header
@@ -260,7 +264,10 @@ struct sk_buff {
                                mac_len;
        union {
                __wsum          csum;
-               __u32           csum_offset;
+               struct {
+                       __u16   csum_start;
+                       __u16   csum_offset;
+               };
        };
        __u32                   priority;
        __u8                    local_df:1,
@@ -347,6 +354,11 @@ extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb,
 extern struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
                                       int newheadroom, int newtailroom,
                                       gfp_t priority);
+extern int            skb_to_sgvec(struct sk_buff *skb,
+                                   struct scatterlist *sg, int offset,
+                                   int len);
+extern int            skb_cow_data(struct sk_buff *skb, int tailbits,
+                                   struct sk_buff **trailer);
 extern int            skb_pad(struct sk_buff *skb, int pad);
 #define dev_kfree_skb(a)       kfree_skb(a)
 extern void          skb_over_panic(struct sk_buff *skb, int len,
@@ -1482,8 +1494,8 @@ 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 int            skb_store_bits(struct sk_buff *skb, int offset,
+                                     const void *from, int len);
 extern __wsum         skb_copy_and_csum_bits(const struct sk_buff *skb,
                                              int offset, u8 *to, int len,
                                              __wsum csum);
@@ -1507,6 +1519,35 @@ static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
        return buffer;
 }
 
+static inline void skb_copy_from_linear_data(const struct sk_buff *skb,
+                                            void *to,
+                                            const unsigned int len)
+{
+       memcpy(to, skb->data, len);
+}
+
+static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb,
+                                                   const int offset, void *to,
+                                                   const unsigned int len)
+{
+       memcpy(to, skb->data + offset, len);
+}
+
+static inline void skb_copy_to_linear_data(struct sk_buff *skb,
+                                          const void *from,
+                                          const unsigned int len)
+{
+       memcpy(skb->data, from, len);
+}
+
+static inline void skb_copy_to_linear_data_offset(struct sk_buff *skb,
+                                                 const int offset,
+                                                 const void *from,
+                                                 const unsigned int len)
+{
+       memcpy(skb->data + offset, from, len);
+}
+
 extern void skb_init(void);
 
 /**
@@ -1528,10 +1569,20 @@ static inline void __net_timestamp(struct sk_buff *skb)
        skb->tstamp = ktime_get_real();
 }
 
+static inline ktime_t net_timedelta(ktime_t t)
+{
+       return ktime_sub(ktime_get_real(), t);
+}
+
 
 extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
 extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
 
+static inline int skb_csum_unnecessary(const struct sk_buff *skb)
+{
+       return skb->ip_summed & CHECKSUM_UNNECESSARY;
+}
+
 /**
  *     skb_checksum_complete - Calculate checksum of an entire packet
  *     @skb: packet to process
@@ -1550,8 +1601,8 @@ extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
  */
 static inline unsigned int skb_checksum_complete(struct sk_buff *skb)
 {
-       return skb->ip_summed != CHECKSUM_UNNECESSARY &&
-               __skb_checksum_complete(skb);
+       return skb_csum_unnecessary(skb) ?
+              0 : __skb_checksum_complete(skb);
 }
 
 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
@@ -1654,5 +1705,12 @@ static inline int skb_is_gso(const struct sk_buff *skb)
        return skb_shinfo(skb)->gso_size;
 }
 
+static inline void skb_forward_csum(struct sk_buff *skb)
+{
+       /* Unfortunately we don't support this one.  Any brave souls? */
+       if (skb->ip_summed == CHECKSUM_COMPLETE)
+               skb->ip_summed = CHECKSUM_NONE;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_SKBUFF_H */