1 From 3609c4fb4d07d4285e96187598f54cb21e9e9b08 Mon Sep 17 00:00:00 2001
2 From: Shesha Sreenivasamurthy <shesha@cisco.com>
3 Date: Wed, 2 Sep 2015 08:57:24 -0700
4 Subject: [PATCH 2/9] mbuf: rearrange rte_mbuf metadata to suit vpp
6 Offload structure in the second cache line, next pointer in the
7 first cache line. Issue reported to Intel.
9 .../linuxapp/eal/include/exec-env/rte_kni_common.h | 10 +++++++--
10 lib/librte_mbuf/rte_mbuf.h | 25 ++++++++++++++--------
11 2 files changed, 24 insertions(+), 11 deletions(-)
13 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
14 index e9f38bd..d327f71 100644
15 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
16 +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h
17 @@ -111,6 +111,10 @@ struct rte_kni_fifo {
18 * The kernel image of the rte_mbuf struct, with only the relevant fields.
19 * Padding is necessary to assure the offsets of these fields
22 + * offload in the second cache line, next in the first. Better for vpp
23 + * at least as of right now.
26 void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
28 @@ -121,16 +125,18 @@ struct rte_kni_mbuf {
30 uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */
31 uint16_t data_len; /**< Amount of data in segment buffer. */
35 uint16_t data_len; /**< Amount of data in segment buffer. */
36 uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */
41 /* fields on second cache line */
42 - char pad3[8] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
43 + char pad4[12] __attribute__((__aligned__(RTE_CACHE_LINE_SIZE)));
49 diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
50 index 8c2db1b..61cbbd7 100644
51 --- a/lib/librte_mbuf/rte_mbuf.h
52 +++ b/lib/librte_mbuf/rte_mbuf.h
53 @@ -743,6 +743,12 @@ typedef uint64_t MARKER64[0]; /**< marker that allows us to overwrite 8 bytes
55 * The generic rte_mbuf, containing a packet mbuf.
58 + * offload in the second cache line, next in the first. Better for vpp
59 + * at least as of right now.
60 + * If you change this structure, you must change the user-mode
61 + * version in rte_mbuf.h
66 @@ -809,6 +815,16 @@ struct rte_mbuf {
67 uint16_t vlan_tci; /**< VLAN Tag Control Identifier (CPU order) */
68 uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */
69 #endif /* RTE_NEXT_ABI */
70 + struct rte_mbuf *next; /**< Next segment of scattered packet. */
72 + uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */
74 + uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */
75 +#endif /* RTE_NEXT_ABI */
77 + /* second cache line - fields only used in slow path or on TX */
78 + MARKER cacheline1 __rte_cache_aligned;
81 uint32_t rss; /**< RSS hash result if RSS enabled */
83 @@ -828,21 +844,12 @@ struct rte_mbuf {
84 uint32_t usr; /**< User defined tags. See rte_distributor_process() */
85 } hash; /**< hash information */
87 - uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */
89 - uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */
90 -#endif /* RTE_NEXT_ABI */
92 - /* second cache line - fields only used in slow path or on TX */
93 - MARKER cacheline1 __rte_cache_aligned;
96 void *userdata; /**< Can be used for external metadata */
97 uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
100 struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
101 - struct rte_mbuf *next; /**< Next segment of scattered packet. */
103 /* fields to support TX offloads */