Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 |
| 5 | |
| 6 | Offload structure in the second cache line, next pointer in the |
| 7 | first cache line. Issue reported to Intel. |
| 8 | --- |
| 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(-) |
| 12 | |
| 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 |
| 20 | */ |
| 21 | +/* |
| 22 | + * offload in the second cache line, next in the first. Better for vpp |
| 23 | + * at least as of right now. |
| 24 | + */ |
| 25 | struct rte_kni_mbuf { |
| 26 | void *buf_addr __attribute__((__aligned__(RTE_CACHE_LINE_SIZE))); |
| 27 | char pad0[10]; |
| 28 | @@ -121,16 +125,18 @@ struct rte_kni_mbuf { |
| 29 | char pad2[4]; |
| 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. */ |
| 32 | + char pad3[2]; |
| 33 | #else |
| 34 | char pad2[2]; |
| 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. */ |
| 37 | + char pad3[4]; |
| 38 | #endif |
| 39 | + void *next; |
| 40 | |
| 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))); |
| 44 | void *pool; |
| 45 | - void *next; |
| 46 | }; |
| 47 | |
| 48 | /* |
| 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 |
| 54 | /** |
| 55 | * The generic rte_mbuf, containing a packet mbuf. |
| 56 | */ |
| 57 | +/* |
| 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 |
| 62 | + */ |
| 63 | struct rte_mbuf { |
| 64 | MARKER cacheline0; |
| 65 | |
| 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. */ |
| 71 | + |
| 72 | + uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */ |
| 73 | +#ifdef RTE_NEXT_ABI |
| 74 | + uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ |
| 75 | +#endif /* RTE_NEXT_ABI */ |
| 76 | + |
| 77 | + /* second cache line - fields only used in slow path or on TX */ |
| 78 | + MARKER cacheline1 __rte_cache_aligned; |
| 79 | + |
| 80 | union { |
| 81 | uint32_t rss; /**< RSS hash result if RSS enabled */ |
| 82 | struct { |
| 83 | @@ -828,21 +844,12 @@ struct rte_mbuf { |
| 84 | uint32_t usr; /**< User defined tags. See rte_distributor_process() */ |
| 85 | } hash; /**< hash information */ |
| 86 | |
| 87 | - uint32_t seqn; /**< Sequence number. See also rte_reorder_insert() */ |
| 88 | -#ifdef RTE_NEXT_ABI |
| 89 | - uint16_t vlan_tci_outer; /**< Outer VLAN Tag Control Identifier (CPU order) */ |
| 90 | -#endif /* RTE_NEXT_ABI */ |
| 91 | - |
| 92 | - /* second cache line - fields only used in slow path or on TX */ |
| 93 | - MARKER cacheline1 __rte_cache_aligned; |
| 94 | - |
| 95 | union { |
| 96 | void *userdata; /**< Can be used for external metadata */ |
| 97 | uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */ |
| 98 | }; |
| 99 | |
| 100 | struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ |
| 101 | - struct rte_mbuf *next; /**< Next segment of scattered packet. */ |
| 102 | |
| 103 | /* fields to support TX offloads */ |
| 104 | union { |
| 105 | -- |
| 106 | 2.5.0 |
| 107 | |