[PATCH v6 4/4] examples/ptpclient: use shared PTP library definitions

Rajesh Kumar rajesh3.kumar at intel.com
Thu May 7 12:13:14 CEST 2026


Update ptpclient example to use IEEE 1588 PTP definitions from lib/net:
  - Replace PTP_PROTOCOL macro with standard RTE_ETHER_TYPE_1588
  - Remove local duplicate PTP header definitions
  - Add net library dependency in meson.build
  - Leverage rte_ptp.h inline helpers for header access

This aligns with DPDK library patterns and reduces code duplication.
The example remains compatible with standard linuxptp (ptp4l) tooling
for time synchronization.

Signed-off-by: Rajesh Kumar <rajesh3.kumar at intel.com>
---
 examples/ptpclient/meson.build | 1 +
 examples/ptpclient/ptpclient.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/examples/ptpclient/meson.build b/examples/ptpclient/meson.build
index 2e9b7625fc..9087c987d5 100644
--- a/examples/ptpclient/meson.build
+++ b/examples/ptpclient/meson.build
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 allow_experimental_apis = true
+deps += ['net']
 sources = files(
         'ptpclient.c',
 )
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 174ca5dd70..ec6f316139 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -441,7 +441,7 @@ parse_fup(struct ptpv2_time_receiver_ordinary *ptp_data)
 		/* Set multicast address 01-1B-19-00-00-00. */
 		rte_ether_addr_copy(&eth_multicast, &eth_hdr->dst_addr);
 
-		eth_hdr->ether_type = htons(PTP_PROTOCOL);
+		eth_hdr->ether_type = htons(RTE_ETHER_TYPE_1588);
 		req_msg = rte_pktmbuf_mtod_offset(created_pkt,
 			struct delay_req_msg *, sizeof(struct
 			rte_ether_hdr));
@@ -582,7 +582,7 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
 	eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
 	eth_type = rte_be_to_cpu_16(eth_hdr->ether_type);
 
-	if (eth_type == PTP_PROTOCOL) {
+	if (eth_type == RTE_ETHER_TYPE_1588) {
 		ptp_data.m = m;
 		ptp_data.portid = portid;
 		ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
-- 
2.53.0



More information about the dev mailing list