From c86345c395168394e1d65bf5d709141be21403af Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 28 Mar 2024 16:12:32 +0100 Subject: [PATCH] dpdk: update for 24.03 Signed-off-by: Robin Jarry --- modules/infra/datapath/rx.c | 6 +- modules/infra/datapath/tx.c | 6 +- modules/ip4/datapath/lookup.c | 4 +- modules/ip4/datapath/rewrite.c | 4 +- subprojects/dpdk.wrap | 2 - .../build-pass-cflags-in-subproject.patch | 48 ------------- .../build-whole-archive-for-static-libs.patch | 27 ------- ...raph-expose-node-context-as-pointers.patch | 72 +++++++++++++++---- 8 files changed, 67 insertions(+), 102 deletions(-) delete mode 100644 subprojects/packagefiles/dpdk/build-pass-cflags-in-subproject.patch delete mode 100644 subprojects/packagefiles/dpdk/build-whole-archive-for-static-libs.patch diff --git a/modules/infra/datapath/rx.c b/modules/infra/datapath/rx.c index ead7a868..11e3f5e5 100644 --- a/modules/infra/datapath/rx.c +++ b/modules/infra/datapath/rx.c @@ -26,7 +26,7 @@ struct rx_ctx { static uint16_t rx_process(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t count) { - const struct rx_ctx *ctx = node->ctx_ptr1; + const struct rx_ctx *ctx = node->ctx_ptr; struct rx_port_queue q; (void)objs; @@ -67,14 +67,14 @@ static int rx_init(const struct rte_graph *graph, struct rte_node *node) { ctx->n_queues = data->n_queues; ctx->burst_size = RTE_GRAPH_BURST_SIZE / data->n_queues; memcpy(ctx->queues, data->queues, ctx->n_queues * sizeof(*ctx->queues)); - node->ctx_ptr1 = ctx; + node->ctx_ptr = ctx; return 0; } static void rx_fini(const struct rte_graph *graph, struct rte_node *node) { (void)graph; - rte_free(node->ctx_ptr1); + rte_free(node->ctx_ptr); } static struct rte_node_register rx_node_base = { diff --git a/modules/infra/datapath/tx.c b/modules/infra/datapath/tx.c index 6d7f506f..22b8fdfb 100644 --- a/modules/infra/datapath/tx.c +++ b/modules/infra/datapath/tx.c @@ -30,7 +30,7 @@ static inline uint16_t tx_burst( struct rte_mbuf **mbufs, uint16_t n ) { - const struct tx_ctx *ctx = node->ctx_ptr1; + const struct tx_ctx *ctx = node->ctx_ptr; uint16_t txq_id, tx_ok; txq_id = ctx->txq_ids[port_id]; @@ -118,14 +118,14 @@ static int tx_init(const struct rte_graph *graph, struct rte_node *node) { return -1; } memcpy(ctx->txq_ids, data->txq_ids, sizeof(ctx->txq_ids)); - node->ctx_ptr1 = ctx; + node->ctx_ptr = ctx; return 0; } static void tx_fini(const struct rte_graph *graph, struct rte_node *node) { (void)graph; - rte_free(node->ctx_ptr1); + rte_free(node->ctx_ptr); } static struct rte_node_register tx_node_base = { diff --git a/modules/ip4/datapath/lookup.c b/modules/ip4/datapath/lookup.c index 2d495580..a0553dc3 100644 --- a/modules/ip4/datapath/lookup.c +++ b/modules/ip4/datapath/lookup.c @@ -27,7 +27,7 @@ enum edges { static uint16_t lookup_process(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs) { - struct rte_fib *fib = node->ctx_ptr1; + struct rte_fib *fib = node->ctx_ptr; struct rte_ipv4_hdr *hdr; struct rte_mbuf *mbuf; ip4_addr_t dst_addr; @@ -122,7 +122,7 @@ static int lookup_init(const struct rte_graph *graph, struct rte_node *node) { LOG(ERR, "rte_fib_find_existing(%s): %s", BR_IP4_FIB_NAME, rte_strerror(rte_errno)); return -rte_errno; } - node->ctx_ptr1 = fib; + node->ctx_ptr = fib; return 0; } diff --git a/modules/ip4/datapath/rewrite.c b/modules/ip4/datapath/rewrite.c index 144c0fc7..93a2087b 100644 --- a/modules/ip4/datapath/rewrite.c +++ b/modules/ip4/datapath/rewrite.c @@ -32,7 +32,7 @@ enum { static uint16_t rewrite_process(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs) { - struct rte_hash *next_hops = node->ctx_ptr1; + struct rte_hash *next_hops = node->ctx_ptr; struct rte_rcu_qsbr *rcu = node->ctx_ptr2; struct rte_ether_hdr *eth_hdr; struct rte_ipv4_hdr *ip4_hdr; @@ -97,7 +97,7 @@ static int rewrite_init(const struct rte_graph *graph, struct rte_node *node) { return -1; } - node->ctx_ptr1 = next_hops; + node->ctx_ptr = next_hops; node->ctx_ptr2 = rcu; return 0; diff --git a/subprojects/dpdk.wrap b/subprojects/dpdk.wrap index 5e8f9101..0566bbc7 100644 --- a/subprojects/dpdk.wrap +++ b/subprojects/dpdk.wrap @@ -3,8 +3,6 @@ url = https://dpdk.org/git/dpdk revision = releases depth = 1 diff_files = - dpdk/build-whole-archive-for-static-libs.patch, - dpdk/build-pass-cflags-in-subproject.patch, dpdk/mbuf-fix-strict-aliasing-error.patch, dpdk/graph-enhance-export-to-graphviz.patch, dpdk/graph-expose-node-context-as-pointers.patch, diff --git a/subprojects/packagefiles/dpdk/build-pass-cflags-in-subproject.patch b/subprojects/packagefiles/dpdk/build-pass-cflags-in-subproject.patch deleted file mode 100644 index dc98c46c..00000000 --- a/subprojects/packagefiles/dpdk/build-pass-cflags-in-subproject.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 6a724e94fd49eec171ad5828a6f775b27fc5e34c Mon Sep 17 00:00:00 2001 -From: Robin Jarry -Date: Mon, 29 Jan 2024 13:47:17 +0100 -Subject: [PATCH] build: pass cflags in subproject - -When DPDK is used as a subproject, include the required compile -arguments so that the parent project is also built with the appropriate -cflags (most importantly -march). Use the same cflags as pkg-config. - -Fixes: f93a605f2d6e ("build: add definitions for use as Meson subproject") -Cc: stable@dpdk.org - -Signed-off-by: Robin Jarry ---- - buildtools/subproject/meson.build | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build -index 322e01c02969..203c5d36c6e9 100644 ---- a/buildtools/subproject/meson.build -+++ b/buildtools/subproject/meson.build -@@ -2,10 +2,15 @@ - # Copyright(c) 2022 Intel Corporation - - message('DPDK subproject linking: ' + get_option('default_library')) -+subproject_cflags = ['-include', 'rte_config.h'] + machine_args -+if is_freebsd -+ subproject_cflags += ['-D__BSD_VISIBLE'] -+endif - if get_option('default_library') == 'static' - dpdk_dep = declare_dependency( - version: meson.project_version(), - dependencies: dpdk_static_lib_deps, -+ compile_args: subproject_cflags, - # static library deps in DPDK build don't include "link_with" parameters, - # so explicitly link-in both libs and drivers - link_whole: dpdk_static_libraries + dpdk_drivers, -@@ -13,6 +18,7 @@ if get_option('default_library') == 'static' - else - dpdk_dep = declare_dependency( - version: meson.project_version(), -+ compile_args: subproject_cflags, - # shared library deps include all necessary linking parameters - dependencies: dpdk_shared_lib_deps) - endif --- -2.44.0 - diff --git a/subprojects/packagefiles/dpdk/build-whole-archive-for-static-libs.patch b/subprojects/packagefiles/dpdk/build-whole-archive-for-static-libs.patch deleted file mode 100644 index a9de4b9c..00000000 --- a/subprojects/packagefiles/dpdk/build-whole-archive-for-static-libs.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 468f0f044389906f87bbd15cc4514fe16717689a Mon Sep 17 00:00:00 2001 -From: Robin Jarry -Date: Thu, 25 Jan 2024 11:32:52 +0100 -Subject: [PATCH] build: whole-archive for static libs - -Signed-off-by: Robin Jarry ---- - buildtools/subproject/meson.build | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build -index 985ce76a9384..aa28f5fae152 100644 ---- a/buildtools/subproject/meson.build -+++ b/buildtools/subproject/meson.build -@@ -8,8 +8,7 @@ if get_option('default_library') == 'static' - dependencies: dpdk_static_lib_deps, - # static library deps in DPDK build don't include "link_with" parameters, - # so explicitly link-in both libs and drivers -- link_with: dpdk_static_libraries, -- link_whole: dpdk_drivers, -+ link_whole: dpdk_static_libraries + dpdk_drivers, - link_args: dpdk_extra_ldflags) - else - dpdk_dep = declare_dependency( --- -2.43.0 - diff --git a/subprojects/packagefiles/dpdk/graph-expose-node-context-as-pointers.patch b/subprojects/packagefiles/dpdk/graph-expose-node-context-as-pointers.patch index 3267ce63..1704aa9f 100644 --- a/subprojects/packagefiles/dpdk/graph-expose-node-context-as-pointers.patch +++ b/subprojects/packagefiles/dpdk/graph-expose-node-context-as-pointers.patch @@ -1,6 +1,6 @@ -From cc63894567e3cdc187076f4522299de879fcadc9 Mon Sep 17 00:00:00 2001 -From: Robin Jarry -Date: Wed, 27 Mar 2024 12:31:57 +0100 +From ccee0823214d32bd7b9fd7541e8870d6e4f9ba4f Mon Sep 17 00:00:00 2001 +From: Robin Jarry +Date: Wed, 20 Mar 2024 18:16:03 +0100 Subject: [PATCH] graph: expose node context as pointers In some cases, the node context data is used to store two pointers @@ -20,22 +20,58 @@ bytes. Add a static assert to ensure that the unnamed union is not larger than the context array (RTE_NODE_CTX_SZ). -Signed-off-by: Robin Jarry +Signed-off-by: Robin Jarry --- - lib/graph/rte_graph_worker_common.h | 22 +++++++++++++++------- - 1 file changed, 15 insertions(+), 7 deletions(-) + +Notes: + v5: + + * Helper functions to hide casting proved to be harder than expected. + Naive casting may even be impossible without breaking strict aliasing + rules. The only other option would be to use explicit memcpy calls. + * Unnamed union tentative again. As suggested by Tyler (thank you!), + using an intermediate unnamed struct to carry the alignment produces + consistent ABI in C and C++. + * Also, Tyler (thank you!) suggested that the fast path area alignment + size may be incorrect for architectures where the cache line is not 64 + bytes. There will be a 64 bytes hole in the structure at the end of + the unnamed struct before the zero length next nodes array. Use + __rte_cache_min_aligned to preserve existing alignment. + + v4: + + * Replaced the unnamed union with helper inline functions. + + v3: + + * Added __extension__ to the unnamed struct inside the union. + * Fixed C++ header checks. + * Replaced alignas() with an explicit static_assert. + + lib/graph/rte_graph_worker_common.h | 27 ++++++++++++++++++++------- + 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h -index 4045a7a8dc82..4aaba9fc86fc 100644 +index 36d864e2c14e..84d4997bbbf6 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h -@@ -108,14 +108,21 @@ struct rte_node { +@@ -12,7 +12,9 @@ + * process, enqueue and move streams of objects to the next nodes. + */ + ++#include + #include ++#include + + #include + #include +@@ -111,14 +113,21 @@ struct __rte_cache_aligned rte_node { } dispatch; }; /* Fast path area */ + __extension__ struct __rte_cache_min_aligned { #define RTE_NODE_CTX_SZ 16 -- uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */ +- alignas(RTE_CACHE_LINE_SIZE) uint8_t ctx[RTE_NODE_CTX_SZ]; /**< Node Context. */ - uint16_t size; /**< Total number of objects available. */ - uint16_t idx; /**< Number of objects used. */ - rte_graph_off_t off; /**< Offset of node in the graph reel. */ @@ -43,12 +79,12 @@ index 4045a7a8dc82..4aaba9fc86fc 100644 - uint64_t total_calls; /**< Calls done to this node. */ - uint64_t total_objs; /**< Objects processed by this node. */ + union { -+ uint8_t ctx[RTE_NODE_CTX_SZ]; /**< Node Context. */ ++ uint8_t ctx[RTE_NODE_CTX_SZ]; + __extension__ struct { -+ void *ctx_ptr1; ++ void *ctx_ptr; + void *ctx_ptr2; + }; -+ }; ++ }; /**< Node Context. */ + uint16_t size; /**< Total number of objects available. */ + uint16_t idx; /**< Number of objects used. */ + rte_graph_off_t off; /**< Offset of node in the graph reel. */ @@ -58,14 +94,20 @@ index 4045a7a8dc82..4aaba9fc86fc 100644 union { void **objs; /**< Array of object pointers. */ uint64_t objs_u64; -@@ -124,6 +131,7 @@ struct rte_node { +@@ -127,9 +136,13 @@ struct __rte_cache_aligned rte_node { rte_node_process_t process; /**< Process function. */ uint64_t process_u64; }; + }; - struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */ - } __rte_cache_aligned; + alignas(RTE_CACHE_LINE_MIN_SIZE) struct rte_node *nodes[]; /**< Next nodes. */ + }; ++static_assert(offsetof(struct rte_node, size) - offsetof(struct rte_node, ctx) == RTE_NODE_CTX_SZ, ++ "rte_node context must be RTE_NODE_CTX_SZ bytes exactly"); ++ + /** + * @internal + * -- 2.44.0