DPDK 26.07.0-rc1
Data Structures | Macros | Functions
rte_ptp.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <rte_byteorder.h>
#include <rte_common.h>

Go to the source code of this file.

Data Structures

struct  rte_ptp_port_id
 
struct  rte_ptp_hdr
 
struct  rte_ptp_timestamp
 

Macros

#define RTE_IPPORT_PTP_EVENT   319
 
#define RTE_IPPORT_PTP_GENERAL   320
 
#define RTE_ETHER_ADDR_PTP_MULTICAST   { 0x01, 0x1B, 0x19, 0x00, 0x00, 0x00 }
 
#define RTE_ETHER_ADDR_PTP_MULTICAST_PDELAY   { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E }
 
#define RTE_PTP_MSGTYPE_SYNC   0x0
 
#define RTE_PTP_MSGTYPE_DELAY_REQ   0x1
 
#define RTE_PTP_MSGTYPE_PDELAY_REQ   0x2
 
#define RTE_PTP_MSGTYPE_PDELAY_RESP   0x3
 
#define RTE_PTP_MSGTYPE_FU   0x8
 
#define RTE_PTP_MSGTYPE_DELAY_RESP   0x9
 
#define RTE_PTP_MSGTYPE_PDELAY_RESP_FU   0xA
 
#define RTE_PTP_MSGTYPE_ANNOUNCE   0xB
 
#define RTE_PTP_MSGTYPE_SIGNALING   0xC
 
#define RTE_PTP_MSGTYPE_MANAGEMENT   0xD
 
#define RTE_PTP_FLAG_TWO_STEP   (UINT16_C(1) << 9)
 
#define RTE_PTP_FLAG_UNICAST   (UINT16_C(1) << 10)
 
#define RTE_PTP_FLAG_LI_61   (UINT16_C(1) << 0)
 
#define RTE_PTP_FLAG_LI_59   (UINT16_C(1) << 1)
 

Functions

static bool rte_ptp_is_event (const struct rte_ptp_hdr *hdr)
 
static bool rte_ptp_is_two_step (const struct rte_ptp_hdr *hdr)
 
static void rte_ptp_add_correction (struct rte_ptp_hdr *hdr, uint64_t residence_ns)
 
static uint64_t rte_ptp_timestamp_to_ns (const struct rte_ptp_timestamp *ts)
 

Detailed Description

PTP (IEEE 1588) protocol definitions

Definition in file rte_ptp.h.

Macro Definition Documentation

◆ RTE_IPPORT_PTP_EVENT

#define RTE_IPPORT_PTP_EVENT   319

PTP over UDP event port (Sync, Delay_Req, PDelay_Req, PDelay_Resp).

Definition at line 29 of file rte_ptp.h.

◆ RTE_IPPORT_PTP_GENERAL

#define RTE_IPPORT_PTP_GENERAL   320

PTP over UDP general port (Follow_Up, Delay_Resp, Announce, etc.).

Definition at line 32 of file rte_ptp.h.

◆ RTE_ETHER_ADDR_PTP_MULTICAST

#define RTE_ETHER_ADDR_PTP_MULTICAST   { 0x01, 0x1B, 0x19, 0x00, 0x00, 0x00 }

PTP multicast MAC address: 01:1B:19:00:00:00.

Definition at line 35 of file rte_ptp.h.

◆ RTE_ETHER_ADDR_PTP_MULTICAST_PDELAY

#define RTE_ETHER_ADDR_PTP_MULTICAST_PDELAY   { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E }

PTP peer delay multicast MAC: 01:80:C2:00:00:0E.

Definition at line 38 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_SYNC

#define RTE_PTP_MSGTYPE_SYNC   0x0

Sync (event).

Examples
examples/ptpclient/ptpclient.c.

Definition at line 44 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_DELAY_REQ

#define RTE_PTP_MSGTYPE_DELAY_REQ   0x1

Delay_Req (event).

Examples
examples/ptpclient/ptpclient.c.

Definition at line 45 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_PDELAY_REQ

#define RTE_PTP_MSGTYPE_PDELAY_REQ   0x2

Peer_Delay_Req (event).

Definition at line 46 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_PDELAY_RESP

#define RTE_PTP_MSGTYPE_PDELAY_RESP   0x3

Peer_Delay_Resp (event).

Definition at line 47 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_FU

#define RTE_PTP_MSGTYPE_FU   0x8

Follow_Up (general).

Examples
examples/ptpclient/ptpclient.c.

Definition at line 48 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_DELAY_RESP

#define RTE_PTP_MSGTYPE_DELAY_RESP   0x9

Delay_Resp (general).

Examples
examples/ptpclient/ptpclient.c.

Definition at line 49 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_PDELAY_RESP_FU

#define RTE_PTP_MSGTYPE_PDELAY_RESP_FU   0xA

Peer_Delay_Resp_Follow_Up (general).

Definition at line 50 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_ANNOUNCE

#define RTE_PTP_MSGTYPE_ANNOUNCE   0xB

Announce (general).

Definition at line 51 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_SIGNALING

#define RTE_PTP_MSGTYPE_SIGNALING   0xC

Signaling (general).

Definition at line 52 of file rte_ptp.h.

◆ RTE_PTP_MSGTYPE_MANAGEMENT

#define RTE_PTP_MSGTYPE_MANAGEMENT   0xD

Management (general).

Definition at line 53 of file rte_ptp.h.

◆ RTE_PTP_FLAG_TWO_STEP

#define RTE_PTP_FLAG_TWO_STEP   (UINT16_C(1) << 9)

Two-step flag.

Definition at line 63 of file rte_ptp.h.

◆ RTE_PTP_FLAG_UNICAST

#define RTE_PTP_FLAG_UNICAST   (UINT16_C(1) << 10)

Unicast flag.

Definition at line 64 of file rte_ptp.h.

◆ RTE_PTP_FLAG_LI_61

#define RTE_PTP_FLAG_LI_61   (UINT16_C(1) << 0)

Leap indicator 61.

Definition at line 65 of file rte_ptp.h.

◆ RTE_PTP_FLAG_LI_59

#define RTE_PTP_FLAG_LI_59   (UINT16_C(1) << 1)

Leap indicator 59.

Definition at line 66 of file rte_ptp.h.

Function Documentation

◆ rte_ptp_is_event()

static bool rte_ptp_is_event ( const struct rte_ptp_hdr hdr)
inlinestatic

Check if PTP message type is an event message. Event messages (msg_type 0x0-0x3) require timestamps.

Parameters
hdrPointer to PTP header.
Returns
true if event message, false otherwise.
Examples
examples/ptp_tap_relay_sw/ptp_tap_relay_sw.c.

Definition at line 146 of file rte_ptp.h.

◆ rte_ptp_is_two_step()

static bool rte_ptp_is_two_step ( const struct rte_ptp_hdr hdr)
inlinestatic

Check if the two-step flag is set in a PTP header.

Parameters
hdrPointer to PTP header.
Returns
true if two-step flag is set.

Definition at line 160 of file rte_ptp.h.

◆ rte_ptp_add_correction()

static void rte_ptp_add_correction ( struct rte_ptp_hdr hdr,
uint64_t  residence_ns 
)
inlinestatic

Add a residence time (in nanoseconds) to the correctionField. Used by Transparent Clocks to account for relay transit delay. The correctionField uses IEEE 1588 scaled nanoseconds (48.16 fixed-point).

Parameters
hdrPointer to PTP header (will be modified in-place).
residence_nsResidence time in nanoseconds to add.
Examples
examples/ptp_tap_relay_sw/ptp_tap_relay_sw.c.

Definition at line 176 of file rte_ptp.h.

◆ rte_ptp_timestamp_to_ns()

static uint64_t rte_ptp_timestamp_to_ns ( const struct rte_ptp_timestamp ts)
inlinestatic

Convert a PTP timestamp structure to nanoseconds since epoch.

Parameters
tsPointer to PTP timestamp.
Returns
Time in nanoseconds since PTP epoch.

Definition at line 193 of file rte_ptp.h.