The example used the deprecated mbuf field udata64. It is moved to a dynamic field in order to allow removal of udata64.
Signed-off-by: Thomas Monjalon <tho...@monjalon.net> --- doc/guides/sample_app_ug/rxtx_callbacks.rst | 4 ++-- examples/rxtx_callbacks/main.c | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/guides/sample_app_ug/rxtx_callbacks.rst b/doc/guides/sample_app_ug/rxtx_callbacks.rst index 62d1f39d7e..56c4293a1a 100644 --- a/doc/guides/sample_app_ug/rxtx_callbacks.rst +++ b/doc/guides/sample_app_ug/rxtx_callbacks.rst @@ -152,7 +152,7 @@ all packets received: uint64_t now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) - pkts[i]->udata64 = now; + TSC_FIELD(pkts[i]) = now; return nb_pkts; } @@ -179,7 +179,7 @@ packets prior to transmission: unsigned i; for (i = 0; i < nb_pkts; i++) - cycles += now - pkts[i]->udata64; + cycles += now - TSC_FIELD(pkts[i]); latency_numbers.total_cycles += cycles; latency_numbers.total_pkts += nb_pkts; diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c index 6fe39546dd..db3412dafe 100644 --- a/examples/rxtx_callbacks/main.c +++ b/examples/rxtx_callbacks/main.c @@ -10,6 +10,7 @@ #include <rte_cycles.h> #include <rte_lcore.h> #include <rte_mbuf.h> +#include <rte_mbuf_dyn.h> #define RX_RING_SIZE 1024 #define TX_RING_SIZE 1024 @@ -18,6 +19,11 @@ #define MBUF_CACHE_SIZE 250 #define BURST_SIZE 32 +static int tsc_dynfield_offset; +#define TSC_FIELD_TYPE uint64_t +#define TSC_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \ + tsc_dynfield_offset, TSC_FIELD_TYPE *)) + static const char usage[] = "%s EAL_ARGS -- [-t]\n"; @@ -47,7 +53,7 @@ add_timestamps(uint16_t port __rte_unused, uint16_t qidx __rte_unused, uint64_t now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) - pkts[i]->udata64 = now; + TSC_FIELD(pkts[i]) = now; return nb_pkts; } @@ -65,7 +71,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused, rte_eth_read_clock(port, &ticks); for (i = 0; i < nb_pkts; i++) { - cycles += now - pkts[i]->udata64; + cycles += now - TSC_FIELD(pkts[i]); if (hw_timestamping) queue_ticks += ticks - pkts[i]->timestamp; } @@ -261,6 +267,11 @@ main(int argc, char *argv[]) }; int opt, option_index; + static const struct rte_mbuf_dynfield tsc_dynfield_desc = { + .name = "example_bbdev_dynfield_tsc", + .size = sizeof(TSC_FIELD_TYPE), + .align = __alignof__(TSC_FIELD_TYPE), + }; /* init EAL */ int ret = rte_eal_init(argc, argv); @@ -292,6 +303,11 @@ main(int argc, char *argv[]) if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); + tsc_dynfield_offset = + rte_mbuf_dynfield_register(&tsc_dynfield_desc); + if (tsc_dynfield_offset < 0) + rte_exit(EXIT_FAILURE, "Cannot register mbuf field\n"); + /* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) -- 2.28.0