aboutsummaryrefslogtreecommitdiffstats
path: root/dpdk/dpdk-2.1.0_patches/0002-mbuf-rearrange-rte_mbuf-metadata-to-suit-vpp.patch
blob: 2ce5004a4218052acbd48f6d29c380a5e3cb2bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
From 3609c4fb4d07d4285e96187598f54cb21e9e9b08 Mon Sep 17 00:00:00 2001
From: Shesha Sreenivasamurthy <shesha@cisco.com>
Date: Wed, 2 Sep 2015 08:57:24 -0700
Subject: [PATCH 2/9] mbuf: rearrange rte_mbuf metadata to suit vpp

Offload structure in the second cache line, next pointer in the
first cache line. Issue reported to Intel.
---
 .../linuxapp/eal/include/exec-env/rte_kni_common.h | 10 +++++++--
 lib/librte_mbuf/rte_mbuf.h                         | 25 ++++++++++++++--------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
index e9f38bd..d327f71 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
@@ -111,6 +111,10 @@ struct rte_kni_fifo {
  * The kernel image of the rte_mbuf struct, with only the relevant fields.
  * Padding is necessary to assure the offsets of these fields
  */
+/*
+ * offload in the second cache line, next in the first. Better for vpp
+ * at least as of right now.
+ */
 struct rte_kni_mbuf {
 	void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
 	char pad0[10];
@@ -121,16 +125,18 @@ struct rte_kni_mbuf {
 	char pad2[4];
 	uint32_t pkt_len;       /**< Total pkt len: sum of all segment data_len. */
 	uint16_t data_len;      /**< Amount of data in segment buffer. */
+	char pad3[2];
 #else
 	char pad2[2];
 	uint16_t data_len;      /**< Amount of data in segment buffer. */
 	uint32_t pkt_len;       /**< Total pkt len: sum of all segment data_len. */
+	char pad3[4];
 #endif
+	void *next;
 
 	/* fields on second cache line */
-	char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
+	char pad4[12] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
 	void *pool;
-	void *next;
 };
 
 /*
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 8c2db1b..61cbbd7 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -743,6 +743,12 @@ typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
 /**
  * The generic rte_mbuf, containing a packet mbuf.
  */
+/*
+ * offload in the second cache line, next in the first. Better for vpp 
+ * at least as of right now.
+ * If you change this structure, you must change the user-mode
+ * version in rte_mbuf.h
+ */
 struct rte_mbuf {
 	MARKER cacheline0;
 
@@ -809,6 +815,16 @@ struct rte_mbuf {
 	uint16_t vlan_tci;        /**< VLAN Tag Control Identifier (CPU order) */
 	uint16_t vlan_tci_outer;  /**< Outer VLAN Tag Control Identifier (CPU order) */
 #endif /* RTE_NEXT_ABI */
+	struct rte_mbuf *next;    /**< Next segment of scattered packet. */
+
+	uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */
+#ifdef RTE_NEXT_ABI
+	uint16_t vlan_tci_outer;  /**< Outer VLAN Tag Control Identifier (CPU order) */
+#endif /* RTE_NEXT_ABI */
+
+	/* second cache line - fields only used in slow path or on TX */
+	MARKER cacheline1 __rte_cache_aligned;
+
 	union {
 		uint32_t rss;     /**< RSS hash result if RSS enabled */
 		struct {
@@ -828,21 +844,12 @@ struct rte_mbuf {
 		uint32_t usr;	  /**< User defined tags. See rte_distributor_process() */
 	} hash;                   /**< hash information */
 
-	uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */
-#ifdef RTE_NEXT_ABI
-	uint16_t vlan_tci_outer;  /**< Outer VLAN Tag Control Identifier (CPU order) */
-#endif /* RTE_NEXT_ABI */
-
-	/* second cache line - fields only used in slow path or on TX */
-	MARKER cacheline1 __rte_cache_aligned;
-
 	union {
 		void *userdata;   /**< Can be used for external metadata */
 		uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
 	};
 
 	struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
-	struct rte_mbuf *next;    /**< Next segment of scattered packet. */
 
 	/* fields to support TX offloads */
 	union {
-- 
2.5.0
THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <vnet/ip/ip.h> ip_csum_t ip_incremental_checksum (ip_csum_t sum, void *_data, uword n_bytes) { uword data = pointer_to_uword (_data); ip_csum_t sum0, sum1; sum0 = 0; sum1 = sum; /* Align data pointer to 64 bits. */ #define _(t) \ do { \ if (n_bytes >= sizeof (t) \ && sizeof (t) < sizeof (ip_csum_t) \ && (data % (2 * sizeof (t))) != 0) \ { \ sum0 += * uword_to_pointer (data, t *); \ data += sizeof (t); \ n_bytes -= sizeof (t); \ } \ } while (0) _(u8); _(u16); if (BITS (ip_csum_t) > 32) _(u32); #undef _ { ip_csum_t *d = uword_to_pointer (data, ip_csum_t *); while (n_bytes >= 2 * sizeof (d[0])) { sum0 = ip_csum_with_carry (sum0, d[0]); sum1 = ip_csum_with_carry (sum1, d[1]); d += 2; n_bytes -= 2 * sizeof (d[0]); } data = pointer_to_uword (d); } #define _(t) \ do { \ if (n_bytes >= sizeof (t) && sizeof (t) <= sizeof (ip_csum_t)) \ { \ sum0 = ip_csum_with_carry (sum0, * uword_to_pointer (data, t *)); \ data += sizeof (t); \ n_bytes -= sizeof (t); \ } \ } while (0) if (BITS (ip_csum_t) > 32) _(u64); _(u32); _(u16); _(u8); #undef _ /* Combine even and odd sums. */ sum0 = ip_csum_with_carry (sum0, sum1); return sum0; } ip_csum_t ip_csum_and_memcpy (ip_csum_t sum, void *dst, void *src, uword n_bytes) { uword n_left; ip_csum_t sum0 = sum, sum1; n_left = n_bytes; if (n_left && (pointer_to_uword (dst) & sizeof (u8))) { u8 *d8, val; d8 = dst; val = ((u8 *) src)[0]; d8[0] = val; dst += 1; src += 1; n_left -= 1; sum0 = ip_csum_with_carry (sum0, val << (8 * CLIB_ARCH_IS_LITTLE_ENDIAN)); } while ((n_left >= sizeof (u16)) && (pointer_to_uword (dst) & (sizeof (sum) - sizeof (u16)))) { u16 *d16, *s16; d16 = dst; s16 = src; d16[0] = clib_mem_unaligned (&s16[0], u16); sum0 = ip_csum_with_carry (sum0, d16[0]); dst += sizeof (u16); src += sizeof (u16); n_left -= sizeof (u16); } sum1 = 0; while (n_left >= 2 * sizeof (sum)) { ip_csum_t dst0, dst1; ip_csum_t *dst_even, *src_even; dst_even = dst; src_even = src; dst0 = clib_mem_unaligned (&src_even[0], ip_csum_t); dst1 = clib_mem_unaligned (&src_even[1], ip_csum_t); dst_even[0] = dst0; dst_even[1] = dst1; dst += 2 * sizeof (dst_even[0]); src += 2 * sizeof (dst_even[0]); n_left -= 2 * sizeof (dst_even[0]); sum0 = ip_csum_with_carry (sum0, dst0); sum1 = ip_csum_with_carry (sum1, dst1); } sum0 = ip_csum_with_carry (sum0, sum1); while (n_left >= 1 * sizeof (sum)) { ip_csum_t dst0, *dst_even, *src_even; dst_even = dst; src_even = src; dst0 = clib_mem_unaligned (&src_even[0], ip_csum_t); dst_even[0] = dst0; dst += 1 * sizeof (sum); src += 1 * sizeof (sum); n_left -= 1 * sizeof (sum); sum0 = ip_csum_with_carry (sum0, dst0); } while (n_left >= sizeof (u16)) { u16 dst0, *dst_short, *src_short; dst_short = dst; src_short = src; dst0 = clib_mem_unaligned (&src_short[0], u16); dst_short[0] = dst0; sum0 = ip_csum_with_carry (sum0, dst_short[0]); dst += 1 * sizeof (dst0); src += 1 * sizeof (dst0); n_left -= 1 * sizeof (dst0); } if (n_left == 1) { u8 *d8, *s8, val; d8 = dst; s8 = src; d8[0] = val = s8[0]; d8 += 1; s8 += 1; n_left -= 1; sum0 = ip_csum_with_carry (sum0, val << (8 * CLIB_ARCH_IS_BIG_ENDIAN)); } return sum0; } /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */