net-timestamp: ACK timestamp for bytestreams
[cascardo/linux.git] / include / linux / skbuff.h
index ec89301..11c2705 100644 (file)
 #define CHECKSUM_COMPLETE      2
 #define CHECKSUM_PARTIAL       3
 
-#define SKB_DATA_ALIGN(X)      (((X) + (SMP_CACHE_BYTES - 1)) & \
-                                ~(SMP_CACHE_BYTES - 1))
+#define SKB_DATA_ALIGN(X)      ALIGN(X, SMP_CACHE_BYTES)
 #define SKB_WITH_OVERHEAD(X)   \
        ((X) - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
 #define SKB_MAX_ORDER(X, ORDER) \
@@ -211,18 +210,9 @@ static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
  * struct skb_shared_hwtstamps - hardware time stamps
  * @hwtstamp:  hardware time stamp transformed into duration
  *             since arbitrary point in time
- * @syststamp: hwtstamp transformed to system time base
  *
  * Software time stamps generated by ktime_get_real() are stored in
- * skb->tstamp. The relation between the different kinds of time
- * stamps is as follows:
- *
- * syststamp and tstamp can be compared against each other in
- * arbitrary combinations.  The accuracy of a
- * syststamp/tstamp/"syststamp from other device" comparison is
- * limited by the accuracy of the transformation into system time
- * base. This depends on the device driver and its underlying
- * hardware.
+ * skb->tstamp.
  *
  * hwtstamps can only be compared against other hwtstamps from
  * the same device.
@@ -232,7 +222,6 @@ static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
  */
 struct skb_shared_hwtstamps {
        ktime_t hwtstamp;
-       ktime_t syststamp;
 };
 
 /* Definitions for tx_flags in struct skb_shared_info */
@@ -240,7 +229,7 @@ enum {
        /* generate hardware time stamp */
        SKBTX_HW_TSTAMP = 1 << 0,
 
-       /* generate software time stamp */
+       /* generate software time stamp when queueing packet to NIC */
        SKBTX_SW_TSTAMP = 1 << 1,
 
        /* device driver is going to provide hardware time stamp */
@@ -258,8 +247,19 @@ enum {
         * all frags to avoid possible bad checksum
         */
        SKBTX_SHARED_FRAG = 1 << 5,
+
+       /* generate software time stamp when entering packet scheduling */
+       SKBTX_SCHED_TSTAMP = 1 << 6,
+
+       /* generate software timestamp on peer data acknowledgment */
+       SKBTX_ACK_TSTAMP = 1 << 7,
 };
 
+#define SKBTX_ANY_SW_TSTAMP    (SKBTX_SW_TSTAMP    | \
+                                SKBTX_SCHED_TSTAMP | \
+                                SKBTX_ACK_TSTAMP)
+#define SKBTX_ANY_TSTAMP       (SKBTX_HW_TSTAMP | SKBTX_ANY_SW_TSTAMP)
+
 /*
  * The callback notifies userspace to release buffers when skb DMA is done in
  * lower device, the skb last reference should be 0 when calling this.
@@ -286,6 +286,7 @@ struct skb_shared_info {
        unsigned short  gso_type;
        struct sk_buff  *frag_list;
        struct skb_shared_hwtstamps hwtstamps;
+       u32             tskey;
        __be32          ip6_frag_id;
 
        /*
@@ -455,6 +456,7 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
  *     @ooo_okay: allow the mapping of a socket to a queue to be changed
  *     @l4_hash: indicate hash is a canonical 4-tuple hash over transport
  *             ports.
+ *     @sw_hash: indicates hash was computed in software stack
  *     @wifi_acked_valid: wifi_acked was set
  *     @wifi_acked: whether frame was acked on wifi or not
  *     @no_fcs:  Request NIC to treat last 4 bytes as Ethernet FCS
@@ -562,6 +564,7 @@ struct sk_buff {
        __u8                    pfmemalloc:1;
        __u8                    ooo_okay:1;
        __u8                    l4_hash:1;
+       __u8                    sw_hash:1;
        __u8                    wifi_acked_valid:1;
        __u8                    wifi_acked:1;
        __u8                    no_fcs:1;
@@ -575,7 +578,7 @@ struct sk_buff {
        __u8                    encap_hdr_csum:1;
        __u8                    csum_valid:1;
        __u8                    csum_complete_sw:1;
-       /* 3/5 bit hole (depending on ndisc_nodetype presence) */
+       /* 2/4 bit hole (depending on ndisc_nodetype presence) */
        kmemcheck_bitfield_end(flags2);
 
 #if defined CONFIG_NET_DMA || defined CONFIG_NET_RX_BUSY_POLL
@@ -830,13 +833,14 @@ static inline void
 skb_set_hash(struct sk_buff *skb, __u32 hash, enum pkt_hash_types type)
 {
        skb->l4_hash = (type == PKT_HASH_TYPE_L4);
+       skb->sw_hash = 0;
        skb->hash = hash;
 }
 
 void __skb_get_hash(struct sk_buff *skb);
 static inline __u32 skb_get_hash(struct sk_buff *skb)
 {
-       if (!skb->l4_hash)
+       if (!skb->l4_hash && !skb->sw_hash)
                __skb_get_hash(skb);
 
        return skb->hash;
@@ -850,6 +854,7 @@ static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
 static inline void skb_clear_hash(struct sk_buff *skb)
 {
        skb->hash = 0;
+       skb->sw_hash = 0;
        skb->l4_hash = 0;
 }
 
@@ -862,6 +867,7 @@ static inline void skb_clear_hash_if_not_l4(struct sk_buff *skb)
 static inline void skb_copy_hash(struct sk_buff *to, const struct sk_buff *from)
 {
        to->hash = from->hash;
+       to->sw_hash = from->sw_hash;
        to->l4_hash = from->l4_hash;
 };
 
@@ -2697,6 +2703,10 @@ static inline bool skb_defer_rx_timestamp(struct sk_buff *skb)
 void skb_complete_tx_timestamp(struct sk_buff *skb,
                               struct skb_shared_hwtstamps *hwtstamps);
 
+void __skb_tstamp_tx(struct sk_buff *orig_skb,
+                    struct skb_shared_hwtstamps *hwtstamps,
+                    struct sock *sk, int tstype);
+
 /**
  * skb_tstamp_tx - queue clone of skb with send time stamps
  * @orig_skb:  the original outgoing packet
@@ -3005,7 +3015,7 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
        return skb->queue_mapping != 0;
 }
 
-u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
+u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
                  unsigned int num_tx_queues);
 
 static inline struct sec_path *skb_sec_path(struct sk_buff *skb)