The mbuf timestamp is moved to a dynamic field
in order to allow removal of the deprecated static field.

Signed-off-by: Thomas Monjalon <tho...@monjalon.net>
---
 examples/rxtx_callbacks/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index b9a98ceddc..4798e0962c 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -19,6 +19,10 @@
 #define MBUF_CACHE_SIZE 250
 #define BURST_SIZE 32
 
+static int hwts_dynfield_offset = -1;
+#define HWTS_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \
+               hwts_dynfield_offset, rte_mbuf_timestamp_t *))
+
 typedef uint64_t tsc_t;
 static int tsc_dynfield_offset = -1;
 #define TSC_FIELD(mbuf) (*RTE_MBUF_DYNFIELD(mbuf, \
@@ -73,7 +77,7 @@ calc_latency(uint16_t port, uint16_t qidx __rte_unused,
        for (i = 0; i < nb_pkts; i++) {
                cycles += now - TSC_FIELD(pkts[i]);
                if (hw_timestamping)
-                       queue_ticks += ticks - pkts[i]->timestamp;
+                       queue_ticks += ticks - HWTS_FIELD(pkts[i]);
        }
 
        latency_numbers.total_cycles += cycles;
@@ -137,6 +141,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                        return -1;
                }
                port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
+               hwts_dynfield_offset = rte_mbuf_dynfield_lookup(
+                               RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL);
+               if (hwts_dynfield_offset < 0) {
+                       printf("ERROR: Failed to lookup timestamp field\n");
+                       return -rte_errno;
+               }
        }
 
        retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
-- 
2.28.0

Reply via email to