flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
master.c
Go to the documentation of this file.
1#include "master.h"
2
3#include "common.h"
4#include "flexptp_options.h"
5#include "format_utils.h"
6#include "msg_utils.h"
7#include "ptp_core.h"
8#include "ptp_defs.h"
10#include "ptp_sync_cycle_data.h"
11#include "ptp_types.h"
12#include "task_ptp.h"
13#include "timeutils.h"
14#include "tlv.h"
15
16#include <inttypes.h>
17#include <string.h>
18
19#include "minmax.h"
20
22#define S (gPtpCoreState)
24
25/*
26 * Message headaers and compiled bodies. They can be statically
27 * allocated, since nothing depends on the Announce message
28 * and a Follow_Up is always triggered by the transmission of
29 * a Sync. TODO: Maybe Sync transmissions should be constrained,
30 * so that no new Sync transmission would be scheduled if the Follow_Up
31 * was in the queue.
32 */
39
43 announceHeader.transportSpecific = (uint8_t)S.profile.transportSpecific;
45 announceHeader.domainNumber = S.profile.domainNumber;
46 // announceHeader.flags.PTP_TWO_STEP = true;
50
51 memcpy(&announceHeader.clockIdentity, &S.hwoptions.clockIdentity, 8);
52
55 announceHeader.logMessagePeriod = S.profile.logAnnouncePeriod;
56
57 // insert TLVs from the profile
62
65}
66
67static void ptp_init_sync_header() {
69 syncHeader.transportSpecific = S.profile.transportSpecific;
71 syncHeader.transportSpecific = (uint8_t)S.profile.transportSpecific;
73 syncHeader.domainNumber = S.profile.domainNumber;
75 // syncHeader.flags.PTP_TIMESCALE = false;
78
79 memcpy(&syncHeader.clockIdentity, &S.hwoptions.clockIdentity, 8);
80
83 syncHeader.logMessagePeriod = S.profile.logSyncPeriod;
84
85 // insert TLVs from the profile
90
91 // save message sizes
92 sync_.size = PTP_PCKT_SIZE_SYNC + tlvSize;
94}
95
97 // insert TLVs from the profile
103}
104
106 // set sequence ID
107 announceHeader.sequenceID = S.master.messaging.announceSequenceID++;
108 announceHeader.transportSpecific = S.profile.transportSpecific;
109
110 // fill-in fields
112 ptp_write_binary_timestamps(announce.data, &zeroTs, 1); // insert an empty timestamp
113 ptp_construct_binary_announce_message(announce.data, &S.capabilities); // insert Announce body
114
115 // setup packet
117 announce.pTxCb = NULL;
118 announce.tx_dm = S.profile.delayMechanism;
121
122 // send message
124}
125
126static void ptp_send_follow_up(const RawPtpMessage *pMsg) {
127 // fetch header from preceding Sync
128 PtpHeader header;
129 ptp_extract_header(&header, pMsg->data);
130 TimestampI t1 = pMsg->ts;
131
132 // modify header fields
133 header.minorVersionPTP = 0;
134 header.transportSpecific = S.profile.transportSpecific;
136 header.messageLength = followUp.size;
137 header.control = PTP_CON_Follow_Up;
138 // ptp_clear_flags(&(header.flags));
139
140 // write fields
141 ptp_construct_binary_header(followUp.data, &header); // insert header
142 ptp_write_binary_timestamps(followUp.data, &t1, 1); // insert t1 timestamp
143
144 // setup packet
146 followUp.pTxCb = NULL;
147 followUp.tx_dm = S.profile.delayMechanism;
150
151 // transmit
153}
154
156 // set sequence ID
157 syncHeader.sequenceID = S.master.messaging.syncSequenceID++;
158
159 // fill-in fields
161 ptp_write_binary_timestamps(sync_.data, &zeroTs, 1); // insert an empty timestamp (TWO_STEP -> "reserved")
162
163 // setup packet
166 sync_.tx_dm = S.profile.delayMechanism;
168 sync_.ttl = FLEXPTP_RANDOM_TAGGED_MESSAGE_TTL_TICKS; //S.master.syncTickPeriod;
169
170 // send message
172}
173
174static void ptp_send_delay_resp_message(const RawPtpMessage *pRawMsg, const PtpHeader *pHeader) {
175 RawPtpMessage delRespMsg = {0};
176
177 PtpHeader header = *pHeader; // make a copy
178 header.minorVersionPTP = 0;
179 TimestampI t4 = pRawMsg->ts; // fetch t4 timestamp
180
181 // create requestingSourcePortIdentity based on clockId from the header
182 PtpDelay_RespIdentification reqDelRespId = {header.clockIdentity, header.sourcePortID};
183
184 // modify header fields
185 header.messageType = PTP_MT_Delay_Resp; // change message type
186 ptp_clear_flags(&header.flags); // clear flags
187 header.flags.PTP_TWO_STEP = true; // set TWO_STEP flag
188 header.sourcePortID = PTP_PORT_ID; // set source port number
189 header.messageLength = PTP_PCKT_SIZE_DELAY_RESP; // set appropriate size
190 header.clockIdentity = S.hwoptions.clockIdentity; // set our clock identity
192
193 // write fields
194 ptp_construct_binary_header(delRespMsg.data, &header); // HEADER
195 ptp_write_binary_timestamps(delRespMsg.data, &t4, 1); // t4 TIMESTAMP
196 ptp_write_delay_resp_id_data(delRespMsg.data, &reqDelRespId); // REQ.SRC.PORT.ID
197
198 // setup packet
199 delRespMsg.tag = RPMT_RANDOM;
200 delRespMsg.size = PTP_PCKT_SIZE_DELAY_RESP;
201 delRespMsg.pTxCb = NULL;
202 delRespMsg.tx_dm = PTP_DM_E2E;
203 delRespMsg.tx_mc = PTP_MC_GENERAL;
205
206 // send packet
207 ptp_transmit_enqueue(&delRespMsg);
208}
209
210// ------------------------
211
212static char *P2P_SLAVE_STATE_HINTS[] = {
213 "NONE",
214 "CANDIDATE",
215 "ESTABLISHED"};
216
217#define PTP_MASTER_P2P_SLAVE_STATE_LOG() \
218 CLILOG(S.logging.def && (si->state != prevState), "%s -> %s\n", P2P_SLAVE_STATE_HINTS[prevState], P2P_SLAVE_STATE_HINTS[si->state])
219
225static void ptp_master_p2p_slave_reported(uint64_t slClockId) {
226 PtpP2PSlaveInfo *si = &(S.master.p2pSlave);
227 PtpP2PSlaveState prevState = si->state;
228
229 switch (si->state) {
230 case PTP_P2PSS_NONE:
231 si->reportCount = 0; // increase the report count
232 si->dropoutCntr = PTP_PDELAY_DROPOUT; // reload the dropout counter
233 si->identity = slClockId; // save the clock ID
234 si->state = PTP_P2PSS_CANDIDATE; // switch to candidate state
235 break;
238 if (si->identity == slClockId) { // if the slave candidate keep reporting in...
239 si->dropoutCntr = PTP_PDELAY_DROPOUT; // reload the counter
240 si->reportCount = MIN(PTP_PDELAY_SLAVE_QUALIFICATION + 1, si->reportCount + 1); // increase the report count
241 if (si->reportCount > PTP_PDELAY_SLAVE_QUALIFICATION) { // switch to ESTABLISHED if qualification has passed
243 }
244 } else { // if a different slave has also appeared, then it's either a fault, or the previous one had been replaced
245 si->state = PTP_P2PSS_NONE; // revert to NONE state
246 si->identity = 0; // clear the identity
247 si->dropoutCntr = 0; // clear the dropout counter
248 si->reportCount = 0; // clear the report counter
249 }
250 break;
251 }
252
254}
255
256// /**
257// * Calculate the mean path delay.
258// */
259// static void ptp_master_calculate_mean_path_delay() {
260// // fetch value arrays
261// TimestampI * pMPD = &S.network.meanPathDelay;
262// uint64_t * pCf = S.master.scd.cf;
263
264// // convert correction field values to timestamp objects
265// TimestampI * pTs = S.master.scd.t;
266// TimestampI cf = {0, 0}; // variable for accounting correction fields in
267// nsToTsI(&cf, pCf[T2] + pCf[T3]);
268
269// // compute difference between master and slave clock
270// subTime(pMPD, &pTs[T4], &pTs[T1]); // t4 - t1 ...
271// subTime(pMPD, pMPD, &pTs[T3]); // - t3 ...
272// addTime(pMPD, pMPD, &pTs[T2]); // + t2
273// subTime(pMPD, pMPD, &cf); // - CF of (PDelay_Resp + PDelay_Resp_Follow_Up)
274// divTime(pMPD, pMPD, 2); // division by 2
275// }
276
278 PtpSyncCycleData *scd = &S.master.scd;
279 TimestampI *mpd = &S.network.meanPathDelay;
280 ptp_compute_mean_path_delay_p2p(scd->t, scd->cf, mpd);
281
282 CLILOG(S.logging.timestamps,
283 "seqID: %u\n"
284 "T1: %d.%09d <- PDelay_Req TX (master)\n"
285 "T2: %d.%09d <- PDelay_Req RX (slave) \n"
286 "T3: %d.%09d <- PDelay_Resp TX (slave) \n"
287 "T4: %d.%09d <- PDelay_Resp RX (master)\n"
288 " %09" __PRI64_PREFIX "u -- %09" __PRI64_PREFIX "u <- CF in PDelay_Resp and ..._Follow_Up\n\n",
289 (uint32_t)S.master.pdelay_reqSequenceID,
290 (int32_t)scd->t[T1].sec, scd->t[T1].nanosec,
291 (int32_t)scd->t[T2].sec, scd->t[T2].nanosec,
292 (int32_t)scd->t[T3].sec, scd->t[T3].nanosec,
293 (int32_t)scd->t[T4].sec, scd->t[T4].nanosec,
294 scd->cf[T2], scd->cf[T3]);
295
296 CLILOG(S.logging.def, "%" __PRI64_PREFIX "d\n", nsI(mpd));
297}
298
300 PtpMessageType mt = pHeader->messageType;
301 PtpDelayMechanism dm = S.profile.delayMechanism;
302
303 if ((mt == PTP_MT_Delay_Req) && (dm == PTP_DM_E2E)) { // pass only Delay_Req through E2E delay mechanism
304 // dispatch DELAY_REQ_RECVED user event
306
307 // send Delay_Resp message
308 ptp_send_delay_resp_message(pRawMsg, pHeader);
309
310 // dispatch DELAY_RESP_SENT user event
312
313 } else if (((mt == PTP_MT_PDelay_Resp) || (mt == PTP_MT_PDelay_Resp_Follow_Up)) && (dm == PTP_DM_P2P)) { // let PDelay_Resp and PDelay_Resp_Follow_Up through in P2P mode
314
315 // try fetching PDelay_Req timestamp
316 if ((mt == PTP_MT_PDelay_Resp) && (!ptp_read_and_clear_transmit_timestamp(RPMT_DELAY_REQ, &S.master.scd.t[T1]))) {
317 return;
318 }
319
320 PtpDelay_RespIdentification delay_respID; // acquire PDelay_Resp(_Follow_Up) identification info
321 ptp_read_delay_resp_id_data(&delay_respID, pRawMsg->data);
322
323 if ((delay_respID.requestingSourceClockIdentity == S.hwoptions.clockIdentity) &&
324 (delay_respID.requestingSourcePortIdentity == PTP_PORT_ID) && (pHeader->sequenceID == S.master.pdelay_reqSequenceID)) {
325 PtpSyncCycleData *scd = &S.master.scd;
326
327 if (mt == PTP_MT_PDelay_Resp) {
328 if (S.master.p2pSlave.state != PTP_P2PSS_NONE) {
329 ptp_extract_timestamps(&(scd->t[T2]), pRawMsg->data, 1); // extract PDelay_Req reception time
330 scd->cf[T2] = pHeader->correction_ns; // correction field of the PDelay_Resp
331 scd->t[T4] = pRawMsg->ts; // save PDelay_Resp reception time
332 }
333
334 if (!pHeader->flags.PTP_TWO_STEP) {
336
337 // mean path delay calculation
338 if (S.master.p2pSlave.state != PTP_P2PSS_NONE) { // one-step mode responder
339 scd->t[T2] = scd->t[T3] = zeroTs;
340 scd->cf[T3] = 0;
342 }
343
344 // dispatch user event
346 } else { // expect a ...FollowUp coming in two-step mode
347 S.master.expectPDelRespFollowUp = true;
348 }
349 } else if (mt == PTP_MT_PDelay_Resp_Follow_Up) {
350 if (!S.master.expectPDelRespFollowUp) {
351 return;
352 }
353 S.master.expectPDelRespFollowUp = false;
354
355 if (S.master.p2pSlave.state != PTP_P2PSS_NONE) {
356 ptp_extract_timestamps(&(scd->t[T3]), pRawMsg->data, 1); // extract PDelay_Resp transmission time
357 scd->cf[T3] = pHeader->correction_ns; // correction field of the PDelay_Resp_Follow_Up
359 }
360
362
363 // dispatch user event
365 }
366 }
367 }
368}
369
370// ------------------------
371
373 // reset master module
375}
376
378 return;
379}
380
382 // load the TLV chain based on the profile
383 tlvChain = ptp_tlv_chain_preset_get(S.profile.tlvSet);
384
385 // initialize Announce message header
387
388 // initialize Sync message header
390
391 // initialze Follow_Up message
393
394 // disable the module
395 S.master.enabled = false;
396
397 // don't expect a PDelay_Req_Follow_Up coming
398 S.master.expectPDelRespFollowUp = false;
399
400 // clear the messaging state
401 memset(&S.master.messaging, 0, sizeof(PtpMasterMessagingState));
402}
403
405 // enable the module
406 S.master.enabled = true;
407
408 // calculate periods
409 S.master.syncTickPeriod = ptp_logi2ms(S.profile.logSyncPeriod) / PTP_HEARTBEAT_TICKRATE_MS;
410 S.master.announceTickPeriod = ptp_logi2ms(S.profile.logAnnouncePeriod) / PTP_HEARTBEAT_TICKRATE_MS;
411 S.master.pdelayReqTickPeriod = ptp_logi2ms((S.profile.logDelayReqPeriod == PTP_LOGPER_SYNCMATCHED) ? S.profile.logSyncPeriod : S.profile.logDelayReqPeriod) / PTP_HEARTBEAT_TICKRATE_MS;
412
413 // clear counters
414 S.master.syncTmr = 0;
415 S.master.announceTmr = 0;
416 S.master.pdelayReqTmr = 0;
417
418 // reset PDelay_Request's sequence ID
419 S.master.pdelay_reqSequenceID = 0;
420
421 // clear Sync cycle data
422 memset(&S.master.scd, 0, sizeof(PtpSyncCycleData));
423
424 // clear P2P slave information
425 memset(&S.master.p2pSlave, 0, sizeof(PtpP2PSlaveInfo));
426}
427
429 S.master.enabled = false;
430}
431
433 if (!S.master.enabled) {
434 return;
435 }
436
437 PtpDelayMechanism dm = S.profile.delayMechanism; // fetch Delay Mechanism
438
439 // gating signal for Sync and Announce transmission
440 bool infoEn = (dm == PTP_DM_E2E) || ((dm == PTP_DM_P2P) && ((S.master.p2pSlave.state == PTP_P2PSS_ESTABLISHED) || (!(S.profile.flags & PTP_PF_ISSUE_SYNC_FOR_COMPLIANT_SLAVE_ONLY_IN_P2P))));
441
442 if (infoEn) {
443 // Sync transmission
444 if (++S.master.syncTmr >= S.master.syncTickPeriod) {
445 S.master.syncTmr = 0;
448 }
449
450 // Announce transmission
451 if (++S.master.announceTmr >= S.master.announceTickPeriod) { // advance Announce timer
452 S.master.announceTmr = 0;
453 }
454
455 // shift Announce transmission phase with 1 tick
456 if (S.master.announceTmr == 1) {
459 }
460 }
461
462 // issue PDelay_Req messages
463 if (dm == PTP_DM_P2P) {
464 if (++S.master.pdelayReqTmr >= S.master.pdelayReqTickPeriod) { // advance the PDelay_Req counter
465 S.master.pdelayReqTmr = 0;
466 }
467
468 // separate PDelay_Req transmission from the Sync-Follow_Up pair by shifting it's phase by one tick
469 if (S.master.pdelayReqTmr == 1) {
470 PtpP2PSlaveInfo *si = &(S.master.p2pSlave);
471 PtpP2PSlaveState prevState = si->state;
472 si->dropoutCntr = (si->dropoutCntr > 0) ? (si->dropoutCntr - 1) : 0; // decrease the slave dropout counter
473 if (si->dropoutCntr == 0) {
474 si->state = PTP_P2PSS_NONE;
475 si->identity = 0;
476 }
478
479 ptp_send_delay_req_message(); // send a PDelay_Request message
480
481 // dispatch PDELAY_REQUEST_SENT message
483 }
484 }
485}
void ptp_compute_mean_path_delay_p2p(const TimestampI *pTs, const uint64_t *pCf, TimestampI *pMPD)
Definition: common.c:152
void ptp_send_delay_req_message()
Definition: common.c:44
This module defines messaging functions for both the slave and master modules.
@ PTP_UEV_PDELAY_RESP_FOLLOW_UP_RECVED
A PDelay_Resp_Follow_Up had been received (master/slave)
Definition: event.h:62
@ PTP_UEV_PDELAY_REQ_SENT
A PDelay_Req had been sent (master/slave)
Definition: event.h:59
@ PTP_UEV_SYNC_SENT
A Sync message has eebn sent (master)
Definition: event.h:51
@ PTP_UEV_PDELAY_RESP_RECVED
A PDelay_Resp had been received (master/slave)
Definition: event.h:60
@ PTP_UEV_DELAY_RESP_SENT
A Delay_Resp had been sent (master)
Definition: event.h:57
@ PTP_UEV_ANNOUNCE_SENT
An Announce message has been sent (master)
Definition: event.h:64
@ PTP_UEV_DELAY_REQ_RECVED
A Delay_Req had been received (master)
Definition: event.h:54
#define PTP_IUEV(uev)
Definition: event.h:83
#define CLILOG(en,...)
uint16_t ptp_logi2ms(int8_t logi)
Definition: format_utils.c:14
This module defines format conversion functions between network and host byte order and conversion fu...
static void ptp_init_sync_header()
Definition: master.c:67
void ptp_master_disable()
Definition: master.c:428
static PtpHeader syncHeader
Definition: master.c:35
void ptp_master_enable()
Definition: master.c:404
void ptp_master_tick()
Definition: master.c:432
#define PTP_MASTER_P2P_SLAVE_STATE_LOG()
Definition: master.c:217
static void ptp_master_p2p_slave_reported(uint64_t slClockId)
Definition: master.c:225
void ptp_master_reset()
Definition: master.c:381
static void ptp_send_delay_resp_message(const RawPtpMessage *pRawMsg, const PtpHeader *pHeader)
Definition: master.c:174
void ptp_master_init()
Definition: master.c:372
static void ptp_init_follow_up_message()
Definition: master.c:96
static RawPtpMessage sync_
Definition: master.c:36
static RawPtpMessage followUp
Definition: master.c:37
static PtpHeader announceHeader
Definition: master.c:33
static void ptp_send_follow_up(const RawPtpMessage *pMsg)
Definition: master.c:126
static void ptp_send_announce_message()
Definition: master.c:105
void ptp_master_destroy()
Definition: master.c:377
static const PtpProfileTlvElement * tlvChain
Definition: master.c:38
void ptp_master_process_message(RawPtpMessage *pRawMsg, PtpHeader *pHeader)
Definition: master.c:299
static void ptp_init_announce_header()
Definition: master.c:40
static RawPtpMessage announce
Definition: master.c:34
static char * P2P_SLAVE_STATE_HINTS[]
Definition: master.c:212
static void ptp_send_sync_message()
Definition: master.c:155
static void ptp_master_commence_mpd_computation()
Definition: master.c:277
This module implements the master clock functionality.
#define MIN(a, b)
Definition: minmax.h:8
void ptp_write_delay_resp_id_data(void *pPayload, const PtpDelay_RespIdentification *pDRData)
Definition: msg_utils.c:224
void ptp_construct_binary_announce_message(void *pData, const PtpAnnounceBody *pAnnounce)
Definition: msg_utils.c:143
void ptp_extract_header(PtpHeader *pHeader, const void *pPayload)
Definition: msg_utils.c:55
void ptp_extract_timestamps(TimestampI *ts, void *pPayload, uint8_t n)
Definition: msg_utils.c:189
void ptp_read_delay_resp_id_data(PtpDelay_RespIdentification *pDRData, void *pPayload)
Definition: msg_utils.c:214
void ptp_construct_binary_header(void *pData, const PtpHeader *pHeader)
Definition: msg_utils.c:90
void ptp_write_binary_timestamps(void *pPayload, const TimestampI *ts, uint8_t n)
Definition: msg_utils.c:166
void ptp_clear_flags(PtpFlags *pFlags)
Definition: msg_utils.c:232
This module defines functions that deal with actual PTP messages; they can extract or insert headers,...
Core of the PTP implementation. Defines functions for message processing, clock tuning,...
In here reside a multitude of fundamental PTP-related constants and definitions.
#define PTP_HEARTBEAT_TICKRATE_MS
Heartbeat ticking period.
Definition: ptp_defs.h:128
#define PTP_PCKT_SIZE_FOLLOW_UP
Size of a Follow_Up message.
Definition: ptp_defs.h:54
#define PTP_PCKT_SIZE_ANNOUNCE
Size of an Announce message.
Definition: ptp_defs.h:61
#define PTP_PDELAY_DROPOUT
Maximum number of failed PDelReq-PDelResp cycles before the MASTER drops the SLAVE.
Definition: ptp_defs.h:196
#define PTP_PCKT_SIZE_DELAY_RESP
Size of a Delay_Resp message.
Definition: ptp_defs.h:56
#define PTP_PCKT_SIZE_SYNC
Size of a Sync message.
Definition: ptp_defs.h:53
#define PTP_PORT_ID
PTP port ID on the device.
Definition: ptp_defs.h:132
#define PTP_PDELAY_SLAVE_QUALIFICATION
Number of consecutive PDelReq-PDelResp iterations after the SLAVE is considered stable.
Definition: ptp_defs.h:192
#define FLEXPTP_RANDOM_TAGGED_MESSAGE_TTL_TICKS
Definition: ptp_defs.h:240
const PtpProfileTlvElement * ptp_tlv_chain_preset_get(const char *pName)
This module manages predefined profile presets. It allows their fetching by name or ID.
This module defines the context object of a full synchronization cycle. In SLAVE mode four timestamps...
#define T2
#define T3
#define T4
#define T1
This module defines the fundamental PTP message and state machine type, flags, bitfields and the PTP ...
@ PTP_CON_Other
Other.
Definition: ptp_types.h:56
@ PTP_CON_Follow_Up
Follow Up.
Definition: ptp_types.h:54
@ PTP_CON_Delay_Resp
Delay Response.
Definition: ptp_types.h:55
@ PTP_CON_Sync
Sync.
Definition: ptp_types.h:52
@ PTP_LOGPER_SYNCMATCHED
Messaging occurs whenever a Sync arrives.
Definition: ptp_types.h:306
@ PTP_MC_EVENT
Event Message Class.
Definition: ptp_types.h:161
@ PTP_MC_GENERAL
General Message Class.
Definition: ptp_types.h:162
PtpMessageType
PTP packet type enumeration.
Definition: ptp_types.h:37
@ PTP_MT_Delay_Resp
Delay Response.
Definition: ptp_types.h:43
@ PTP_MT_PDelay_Resp
Peer Delay Response.
Definition: ptp_types.h:41
@ PTP_MT_Sync
Sync.
Definition: ptp_types.h:38
@ PTP_MT_Announce
Announce.
Definition: ptp_types.h:45
@ PTP_MT_Delay_Req
Delay Request.
Definition: ptp_types.h:39
@ PTP_MT_PDelay_Resp_Follow_Up
Peer Delay Response Follow Up.
Definition: ptp_types.h:44
@ PTP_MT_Follow_Up
Follow Up.
Definition: ptp_types.h:42
PtpDelayMechanism
PTP Delay mechanism enumeration.
Definition: ptp_types.h:144
@ PTP_DM_E2E
End-to-End Delay Mechanism.
Definition: ptp_types.h:145
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
Definition: ptp_types.h:146
@ RPMT_RANDOM
Create a random, unique tag.
Definition: ptp_types.h:181
@ RPMT_DELAY_REQ
(P)Delay_Req tag
Definition: ptp_types.h:183
#define MAX_PTP_MSG_SIZE
Maximum PTP message size.
Definition: ptp_types.h:165
PtpP2PSlaveState
PTP P2P slave state viewed from the MASTER.
Definition: ptp_types.h:431
@ PTP_P2PSS_ESTABLISHED
The slave is considered stable and ready.
Definition: ptp_types.h:434
@ PTP_P2PSS_NONE
No slave is detected.
Definition: ptp_types.h:432
@ PTP_P2PSS_CANDIDATE
A slave has reported in at least once, now being checked on.
Definition: ptp_types.h:433
@ PTP_PF_ISSUE_SYNC_FOR_COMPLIANT_SLAVE_ONLY_IN_P2P
Send Sync messages only for a compliant peer in P2P mode.
Definition: ptp_types.h:348
Identification carrying Delay_Resp message.
Definition: ptp_types.h:128
uint64_t requestingSourceClockIdentity
Requesting Source Clock Identity.
Definition: ptp_types.h:129
uint16_t requestingSourcePortIdentity
Requesting Source Port Identity.
Definition: ptp_types.h:130
bool PTP_TIMESCALE
Timescale.
Definition: ptp_types.h:71
bool PTP_TWO_STEP
Two Step.
Definition: ptp_types.h:67
PTP message header structure.
Definition: ptp_types.h:81
int8_t logMessagePeriod
Definition: ptp_types.h:122
uint8_t versionPTP
PTP version.
Definition: ptp_types.h:87
uint8_t messageType
ID.
Definition: ptp_types.h:83
uint64_t clockIdentity
Clock Identity.
Definition: ptp_types.h:110
uint16_t sequenceID
Sequence ID.
Definition: ptp_types.h:116
uint16_t messageLength
Length.
Definition: ptp_types.h:91
uint16_t sourcePortID
Source Port ID.
Definition: ptp_types.h:113
PtpFlags flags
Flags.
Definition: ptp_types.h:100
uint8_t minorVersionPTP
Definition: ptp_types.h:88
uint8_t control
Control.
Definition: ptp_types.h:119
uint64_t correction_ns
Correction nanoseconds.
Definition: ptp_types.h:103
uint8_t domainNumber
Domain.
Definition: ptp_types.h:94
uint32_t correction_subns
Correction subnanoseconds.
Definition: ptp_types.h:104
uint8_t transportSpecific
Transport Specific.
Definition: ptp_types.h:84
PTP master messaging state structure.
Definition: ptp_types.h:423
PTP P2P slave info structure;.
Definition: ptp_types.h:440
uint16_t reportCount
Number of times the slave had reported in.
Definition: ptp_types.h:443
uint16_t dropoutCntr
Dropout watchdog counter for resetting the state machine if the slave went silent.
Definition: ptp_types.h:444
uint64_t identity
The clock identity of the connected, operating P2P slave.
Definition: ptp_types.h:442
PtpP2PSlaveState state
Indicates that a slave is responding to our PDELAY_REQ messages.
Definition: ptp_types.h:441
PTP profile additional data list element.
Definition: ptp_types.h:336
PTP synchronization cycle data.
TimestampI t[6]
T1-T6 timestamps.
uint64_t cf[6]
T1-T6 correction fields.
TimestampI ts
Timestamp.
Definition: ptp_types.h:187
uint32_t tag
unique transmit tag
Definition: ptp_types.h:191
PtpDelayMechanism tx_dm
transmit transport type
Definition: ptp_types.h:194
uint32_t ttl
transmit Time-to-Live in ticks
Definition: ptp_types.h:192
PtpMessageClass tx_mc
transmit message class
Definition: ptp_types.h:195
uint32_t size
Packet size.
Definition: ptp_types.h:188
uint8_t data[(128)]
raw packet data
Definition: ptp_types.h:198
TxCb * pTxCb
transmit callback function
Definition: ptp_types.h:193
Timestamp (signed)
Definition: timeutils.h:33
int32_t nanosec
nanoseconds
Definition: timeutils.h:35
int64_t sec
seconds
Definition: timeutils.h:34
bool ptp_transmit_enqueue(const RawPtpMessage *pMsg)
Definition: task_ptp.c:502
bool ptp_read_and_clear_transmit_timestamp(uint32_t tag, TimestampI *pTs)
Definition: task_ptp.c:564
The entry point of the whole PTP-implementation. Calling reg_task_ptp() initializes the PTP-engine,...
int64_t nsI(const TimestampI *t)
Definition: timeutils.c:52
This module defines storage classes for timestamps and operations on time values.
uint16_t ptp_tlv_insert(void *dst, const PtpProfileTlvElement *pad, PtpMessageType mt, uint16_t maxLen)
Definition: tlv.c:5
This module implements the TLV-related functionality.