APIs for PTP/1588 v2 slave implementation on PRU-ICSS
Functions | |
int8_t | TimeSync_drvInit (TimeSync_ParamsHandle_t timeSyncHandle) |
Initializes variables and timers & clocks, call once at the beginning. More... | |
int8_t | TimeSync_alloc_PktBuffer (TimeSync_ParamsHandle_t timeSyncHandle) |
Allocate Rx and Tx buffers for frames like Sync, Announce etc. More... | |
void | TimeSync_unAlloc_PktBuffer (TimeSync_ParamsHandle_t timeSyncHandle) |
Unallocate Rx and Tx buffers for frames like Sync, Announce etc. More... | |
void | TimeSync_drvEnable (TimeSync_ParamsHandle_t timeSyncHandle) |
Enable PTP firmware. More... | |
void | TimeSync_drvDisable (TimeSync_ParamsHandle_t timeSyncHandle) |
Disable PTP firmware. More... | |
void | TimeSync_dramInit (TimeSync_ParamsHandle_t timeSyncHandle) |
Initialize PTP stored variables in the DRAM. More... | |
void | TimeSync_setDefaultValue (TimeSync_ParamsHandle_t timeSyncHandle) |
Set Default values for the PTP Object based on clock type. More... | |
void | TimeSync_formatPTPFrames (TimeSync_ParamsHandle_t timeSyncHandle, uint8_t *ifMacID) |
Prepare PTP frames with fields, mac addresses etc. More... | |
void | TimeSync_initializeFollowUp (TimeSync_ParamsHandle_t timeSyncHandle) |
Populate MAC ID, clock identity etc in Follow Up frame. Should be called everytime we change to Master from Slave. More... | |
void | TimeSync_addIP (TimeSync_ParamsHandle_t timeSyncHandle, uint32_t IP) |
Update IP and Modify checksum whenever IP is assigned or changed. More... | |
void | TimeSync_addWord (uint8_t *src, uint32_t word) |
Add a word to the packet stream. More... | |
void | TimeSync_addHalfWord (volatile uint8_t *src, uint16_t halfWord) |
Add a half word to the packet stream. More... | |
uint32_t | TimeSync_calcChecksum (uint8_t *packet, uint16_t len) |
Compute checksum used in IP/UDP packets for a given stream. More... | |
void | TimeSync_calcIPChecksum (uint8_t *packet) |
Compute checksum for IP Header and modify in place. More... | |
void | TimeSync_convEndianess (volatile void *src, volatile void *dst, uint8_t numBytes) |
Convert specified number of bytes in source from big endian bytes to little endian and vice versa. Assumption : More... | |
void | TimeSync_convEnd6to8 (volatile void *src, void *dst) |
Takes in a 6 byte reverse byte endian source and puts it in an 64 bit double word with correct endianness. This function is specific to PTP Assumption : More... | |
void | TimeSync_Port1linkResetCallBack (uint8_t linkStatus, void *arg2) |
Callback for link status change on Port 1. More... | |
void | TimeSync_Port2linkResetCallBack (uint8_t linkStatus, void *arg2) |
Callback for link status change on Port 2. More... | |
void | TimeSync_reset (TimeSync_ParamsHandle_t timeSyncHandle) |
Reset the state machine in firmware to restart synchronization (First adjustment happens again) More... | |
void | TimeSync_processPTPFrame (TimeSync_ParamsHandle_t timeSyncHandle, uint8_t *pktBuffer, uint8_t portNum, uint16_t size, uint8_t isLinkLocal) |
Processes a PTP message and extract fields. More... | |
uint8_t | TimeSync_isEnabled (TimeSync_ParamsHandle_t timeSyncHandle) |
Return True/False 1/0 if timeSync module is enabled. More... | |
void | TimeSync_updateParentAddress (TimeSync_ParamsHandle_t timeSyncHandle, uint8_t *parentMac) |
Write the MAC ID of PTP master to Firmware. BMC Algorithm should call this API. More... | |
void | TimeSync_getPrevAddress (TimeSync_ParamsHandle_t timeSyncHandle, uint8_t *prevMac) |
Retuns the previous master's MAC ID. More... | |
void | TimeSync_getGeneralMessage (TimeSync_ParamsHandle_t timeSyncHandle, int8_t *buff) |
Copies the PTP announce message data to PTP stack buffer. More... | |
void | TimeSync_rxPhyDelayCorrection (TimeSync_ParamsHandle_t timeSyncHandle) |
Performs PHY delay correction on Rx timestamp Assumption : The function expects the timestamp in rxTimestamp_gPTP field on which it does correction. More... | |
int32_t | TimeSync_getRxTimestamp (TimeSync_ParamsHandle_t timeSyncParamsHandle, ptpFrameTypes_t rxFrameType, uint8_t rxPort, uint32_t *nanoseconds, uint64_t *seconds) |
Reads and provides timestamp of a received event message. More... | |
int32_t | TimeSync_getRxTimestampFromFrame (TimeSync_ParamsHandle_t timeSyncParamsHandle, uint8_t rxPort, uint32_t *nanoseconds, uint64_t *seconds, uint8_t *TimeStampFromFrame) |
Reads and provides timestamp of a received event message. More... | |
int32_t | TimeSync_config (TimeSync_ParamsHandle_t timeSyncHandle) |
Function to configure domain number and/or log message intervals and/or sync0 signal start time, pulse width. More... | |
int32_t | TimeSync_getTxTimestamp (TimeSync_ParamsHandle_t timeSyncParamsHandle, ptpFrameTypes_t txFrameType, uint8_t txPort, uint32_t *nanoseconds, uint64_t *seconds) |
Reads and provides timestamp of a transmitted event message. More... | |
int8_t | TimeSync_adjTimeSlowComp (TimeSync_ParamsHandle_t timeSyncParamsHandle, int32_t adjOffset) |
Adjusts the IEP clock by the drift value over one Sync interval. More... | |
int32_t | TimeSync_setClockTime (TimeSync_ParamsHandle_t timeSyncParamsHandle) |
Configures the driver memory. More... | |
void | TimeSync_getCurrentTime (TimeSync_ParamsHandle_t timeSyncParamsHandle, uint32_t *nanoseconds, uint64_t *seconds) |
Returns the current time on device. More... | |
void | TimeSync_updateDomainNumberInPTPFrames (TimeSync_ParamsHandle_t timeSyncHandle) |
Update PTP domain number in TX Buffers. More... | |
void | TimeSync_updateLogMessageIntervalInPTPFrames (TimeSync_ParamsHandle_t timeSyncHandle) |
Update log message interval in PTP TX buffers. More... | |
void | TimeSync_updateDscpValueInDelayRequestFrame (TimeSync_ParamsHandle_t timeSyncHandle, uint8_t dscpValue) |
Update DSCP value in IP header in PTP Delay Request buffer. More... | |
#define TS_LEAP_61_INDEX 0 |
Index for Leap 61 status in ptp_flags[] array
#define TS_LEAP_59_INDEX 1 |
Index for Leap 59 status
#define TS_UTC_REASONABLE_INDEX 2 |
Index for UTC reasonable value in ptp_flags[] array
#define TS_PTP_TIMESCALE_INDEX 3 |
Index for value indicating whether PTP Timescale in ptp_flags[] array
#define TS_TIME_TRACEABLE_INDEX 4 |
Index for value indicating whether time traceable in ptp_flags[] array
#define TS_FREQ_TRACEABLE_INDEX 5 |
Index for value indicating whether freq traceable in ptp_flags[] array
#define TS_ALTERNATE_MASTER_INDEX 6 |
Index for value indicating whether alternate master in ptp_flags[] array
#define TS_PTP_TWO_STEP_INDEX 7 |
Index for value indicating whether two step sync in ptp_flags[] array
#define TS_PTP_UNICAST 8 |
Index for value indicating whether messaging is unicast in ptp_flags[] array
#define TS_PROFILE_SPECIFIC_1_INDEX 9 |
Index for value indicating alternate PTP Profile in ptp_flags[] array
#define TS_PROFILE_SPECIFIC_2_INDEX 10 |
Index for value indicating alternate PTP Profile in ptp_flags[] array
#define TS_PTP_SECURITY_INDEX 11 |
Index for value indicating whether PTP security is enabled or not in ptp_flags[] array
#define TS_SYNC_BYTE0_MASK 0xFF |
selects the flags relevant to Sync frame for first byte of the 2 byte flag
#define TS_ANNOUNCE_BYTE0_MASK 0xFD |
selects the flags relevant to Announce frame for first byte of the 2 byte flag
#define TS_FOLLOW_UP_BYTE0_MASK 0xFD |
selects the flags relevant to Follow Up frame for first byte of the 2 byte flag
#define TS_PDELAY_RESP_BYTE0_MASK 0xFE |
selects the flags relevant to Pdelay Resp frame for first byte of the 2 byte flag
#define TS_DELAY_RESP_BYTE0_MASK 0xFD |
selects the flags relevant to Delay Resp frame for first byte of the 2 byte flag
#define TS_OTHER_FRAMES_BYTE0_MASK 0xFC |
selects the flags relevant to Pdelay Req and Delay Request for first byte of the 2 byte flag
#define TIMESYNC_PDELAY_BUF_SIZE 68 |
Size of peer delay buffers on DUT This includes peer delay request, response and respone follow up
#define TIMESYNC_SYNC_BUF_ANNEX_F_SIZE 58 |
Size of Sync buffers on DUT for Annex F mode
#define TIMESYNC_FOLLOW_UP_BUF_ANNEX_F_SIZE 63 |
Size of Follow Up buffers on DUT for Annex F mode
#define TIMESYNC_ANNOUNCE_BUF_ANNEX_F_SIZE 78 |
Size of Announce Up buffers on DUT for Annex F mode
#define TIMESYNC_SYNC_BUF_ANNEX_E_SIZE 86 |
Size of Sync buffers on DUT for Annex E mode
#define TIMESYNC_FOLLOW_UP_BUF_ANNEX_E_SIZE 86 |
Size of Follow Up buffers on DUT for Annex E mode
#define TIMESYNC_ANNOUNCE_BUF_ANNEX_E_SIZE 106 |
Size of Announce Up buffers on DUT for Annex E mode.
#define TIMESYNC_DELAY_REQ_BUF_SIZE 86 |
Size of Delay Request buffer on DUT (only applicable to E2E).
#define TIMESYNC_DEFAULT_PRIO_1 128 |
#define TIMESYNC_DEFAULT_PRIO_2 128 |
#define TIMESYNC_DEFAULT_CLOCK_ACCURACY 0x31 |
#define TIMESYNC_DEFAULT_CLOCK_CLASS 248 |
#define TIMESYNC_DEFAULT_CLOCK_VARIANCE 0 |
#define TIMESYNC_DEFAULT_STEPS_REMOVED 0 |
#define TIMESYNC_UTC_OFFSET 0 |
#define TIMESYNC_DEFAULT_TIME_SOURCE 0xa0 |
#define TIMESYNC_OFFSET_STABLE_ALGO_THRESHOLD 15 |
int8_t TimeSync_drvInit | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Initializes variables and timers & clocks, call once at the beginning.
timeSyncHandle | pointer to PTP Handle structure |
int8_t TimeSync_alloc_PktBuffer | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Allocate Rx and Tx buffers for frames like Sync, Announce etc.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_unAlloc_PktBuffer | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Unallocate Rx and Tx buffers for frames like Sync, Announce etc.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_drvEnable | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Enable PTP firmware.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_drvDisable | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Disable PTP firmware.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_dramInit | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Initialize PTP stored variables in the DRAM.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_setDefaultValue | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Set Default values for the PTP Object based on clock type.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_formatPTPFrames | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
uint8_t * | ifMacID | ||
) |
Prepare PTP frames with fields, mac addresses etc.
timeSyncHandle | pointer to PTP Handle structure |
ifMacID | pointer to MAC ID |
void TimeSync_initializeFollowUp | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Populate MAC ID, clock identity etc in Follow Up frame. Should be called everytime we change to Master from Slave.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_addIP | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
uint32_t | IP | ||
) |
Update IP and Modify checksum whenever IP is assigned or changed.
timeSyncHandle | pointer to PTP Handle structure |
IP | IP address in unsigned 32 bit format. |
void TimeSync_addWord | ( | uint8_t * | src, |
uint32_t | word | ||
) |
Add a word to the packet stream.
src | pointer to the packet stream |
word | the word which is to be added |
void TimeSync_addHalfWord | ( | volatile uint8_t * | src, |
uint16_t | halfWord | ||
) |
Add a half word to the packet stream.
src | pointer to the packet stream |
halfWord | the 16 bit word which is to be added |
uint32_t TimeSync_calcChecksum | ( | uint8_t * | packet, |
uint16_t | len | ||
) |
Compute checksum used in IP/UDP packets for a given stream.
packet | pointer to the packet stream |
len | length of stream |
void TimeSync_calcIPChecksum | ( | uint8_t * | packet | ) |
Compute checksum for IP Header and modify in place.
packet | pointer to the packet stream |
void TimeSync_convEndianess | ( | volatile void * | src, |
volatile void * | dst, | ||
uint8_t | numBytes | ||
) |
Convert specified number of bytes in source from big endian bytes to little endian and vice versa. Assumption :
src | pointer to source byte stream |
dst | pointer to destination byte stream |
numBytes | number of bytes to convert and copy |
void TimeSync_convEnd6to8 | ( | volatile void * | src, |
void * | dst | ||
) |
Takes in a 6 byte reverse byte endian source and puts it in an 64 bit double word with correct endianness. This function is specific to PTP Assumption :
src | pointer to source byte stream |
dst | pointer to destination byte stream |
void TimeSync_Port1linkResetCallBack | ( | uint8_t | linkStatus, |
void * | arg2 | ||
) |
Callback for link status change on Port 1.
linkStatus | 1/0 whether up or down |
arg2 | timeSyncHandle pointer to PTP Handle structure |
void TimeSync_Port2linkResetCallBack | ( | uint8_t | linkStatus, |
void * | arg2 | ||
) |
Callback for link status change on Port 2.
linkStatus | 1/0 whether up or down |
arg2 | timeSyncHandle pointer to PTP Handle structure |
void TimeSync_reset | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Reset the state machine in firmware to restart synchronization (First adjustment happens again)
If Sync interval changes or link break happens or there is a large adjustment in time this function is called.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_processPTPFrame | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
uint8_t * | pktBuffer, | ||
uint8_t | portNum, | ||
uint16_t | size, | ||
uint8_t | isLinkLocal | ||
) |
Processes a PTP message and extract fields.
timeSyncHandle | pointer to PTP Handle structure |
pktBuffer | pointer to packet data |
portNum | port number on which the packet was received |
size | size of the packet |
isLinkLocal |
uint8_t TimeSync_isEnabled | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Return True/False 1/0 if timeSync module is enabled.
timeSyncHandle | pointer to PTP Handle structure |
void TimeSync_updateParentAddress | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
uint8_t * | parentMac | ||
) |
Write the MAC ID of PTP master to Firmware. BMC Algorithm should call this API.
timeSyncHandle | pointer to PTP Handle structure |
parentMac | Pointer to MAC ID of master. |
void TimeSync_getPrevAddress | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
uint8_t * | prevMac | ||
) |
Retuns the previous master's MAC ID.
timeSyncHandle | pointer to PTP Handle structure |
prevMac | Pointer to MAC ID of previous master. |
void TimeSync_getGeneralMessage | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
int8_t * | buff | ||
) |
Copies the PTP announce message data to PTP stack buffer.
timeSyncHandle | pointer to PTP Handle structure |
buff | Pointer to buffer of PTP Stack. |
void TimeSync_rxPhyDelayCorrection | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Performs PHY delay correction on Rx timestamp Assumption : The function expects the timestamp in rxTimestamp_gPTP field on which it does correction.
timeSyncHandle | pointer to PTP Handle structure |
int32_t TimeSync_getRxTimestamp | ( | TimeSync_ParamsHandle_t | timeSyncParamsHandle, |
ptpFrameTypes_t | rxFrameType, | ||
uint8_t | rxPort, | ||
uint32_t * | nanoseconds, | ||
uint64_t * | seconds | ||
) |
Reads and provides timestamp of a received event message.
[in] | timeSyncParamsHandle | Structure of type TimeSync_ParamsHandle_t |
[in] | rxFrameType | (INPUT) frame type received Valid values: 0,1,2,3 |
[in] | rxPort | (INPUT) Port used for receive ICSS_EMAC_PORT_1/ ICSS_EMAC_PORT_2 |
[out] | nanoseconds | (OUTPUT) ptr to 32 bit nanoseconds field |
[out] | seconds | (OUTPUT) ptr to 64 bit(48 used) seconds field |
<0 | value on error |
0 | on success |
int32_t TimeSync_getRxTimestampFromFrame | ( | TimeSync_ParamsHandle_t | timeSyncParamsHandle, |
uint8_t | rxPort, | ||
uint32_t * | nanoseconds, | ||
uint64_t * | seconds, | ||
uint8_t * | TimeStampFromFrame | ||
) |
Reads and provides timestamp of a received event message.
[in] | timeSyncParamsHandle | Structure of type TimeSync_ParamsHandle_t |
[in] | rxPort | (INPUT) Port used for receive ICSS_EMAC_PORT_1/ ICSS_EMAC_PORT_2 |
[out] | nanoseconds | (OUTPUT) ptr to 32 bit nanoseconds field |
[out] | seconds | (OUTPUT) ptr to 64 bit(48 used) seconds field |
[out] | TimeStampFromFrame | (OUTPUT) frame timestamp |
<0 | value on error |
0 | on success |
int32_t TimeSync_config | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Function to configure domain number and/or log message intervals and/or sync0 signal start time, pulse width.
[in] | timeSyncHandle | pointer to PTP Handle structure with updated values in following members : timeSyncHandle->timeSyncConfig.domainNumber, and/or timeSyncHandle->timeSyncConfig.logSyncInterval, and/or timeSyncHandle->timeSyncConfig.logAnnounceSendInterval, and/or timeSyncHandle->timeSyncConfig.syncOut_sync0Start, and/or timeSyncHandle->timeSyncConfig.syncOut_sync0PWidth. |
<0 | value on error |
0 | on success |
int32_t TimeSync_getTxTimestamp | ( | TimeSync_ParamsHandle_t | timeSyncParamsHandle, |
ptpFrameTypes_t | txFrameType, | ||
uint8_t | txPort, | ||
uint32_t * | nanoseconds, | ||
uint64_t * | seconds | ||
) |
Reads and provides timestamp of a transmitted event message.
[in] | timeSyncParamsHandle | Structure of type TimeSync_ParamsHandle_t |
[in] | txFrameType | (INPUT) frame type transmitted Valid values: 0,1,2,3 |
[in] | txPort | (INPUT) Port used for transmit ICSS_EMAC_PORT_1/ ICSS_EMAC_PORT_2 |
[out] | nanoseconds | (OUTPUT) ptr to 32 bit nanoseconds field |
[out] | seconds | (OUTPUT) ptr to 64 bit(48 used) seconds field |
<0 | value on error |
0 | on success |
int8_t TimeSync_adjTimeSlowComp | ( | TimeSync_ParamsHandle_t | timeSyncParamsHandle, |
int32_t | adjOffset | ||
) |
Adjusts the IEP clock by the drift value over one Sync interval.
[in] | timeSyncParamsHandle | Structure of type TimeSync_ParamsHandle_t |
[in] | adjOffset | (filtered offset from master in nanoseconds) |
<0 | value on error |
0 | on success |
Adjustment Offset (INPUT) Set drift value Example: 300 (300ns)
syncInterval (INPUT) Set sync interval Example: 30000000 (30ms)
Writes the IEP compensation registers to adjust the IEP counter by adjustment offset value provided in nanoseconds over one Sync interval. syncInterval/drift value will be written to PRUSS_IEP_SLOW_COMPENSATION register. Compensation increment (10 or 0) will be written to CMP_INC field of PRUSS_IEP_GLOBAL_CFG register.
int32_t TimeSync_setClockTime | ( | TimeSync_ParamsHandle_t | timeSyncParamsHandle | ) |
Configures the driver memory.
[in] | timeSyncParamsHandle | Structure of type TimeSync_ParamsHandle_t |
<0 | value on error |
0 | on success |
clockTime (INPUT) Clock time to set. Provide in Timestamp format
void TimeSync_getCurrentTime | ( | TimeSync_ParamsHandle_t | timeSyncParamsHandle, |
uint32_t * | nanoseconds, | ||
uint64_t * | seconds | ||
) |
Returns the current time on device.
Returns the current time in 1. Seconds : Seconds as on master 2. Nanoseconds : Current nanoseconds as on master The format is identical to the one followed in PTP frames for origin timestamp The time is returned in timeSyncParamsHandle->clockTime
[in] | timeSyncParamsHandle | Pointer to PTP Handle |
[out] | nanoseconds | Pointer to nanoseconds field which is updated by API |
[out] | seconds | Pointer to seconds field which is updated by API |
void TimeSync_updateDomainNumberInPTPFrames | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Update PTP domain number in TX Buffers.
timeSyncHandle | pointer to PTP Handle structure with updated value in timeSyncHandle->timeSyncConfig.domainNumber |
void TimeSync_updateLogMessageIntervalInPTPFrames | ( | TimeSync_ParamsHandle_t | timeSyncHandle | ) |
Update log message interval in PTP TX buffers.
timeSyncHandle | pointer to PTP Handle structure with updated values in timeSyncHandle->timeSyncConfig.logSyncInterval and timeSyncHandle->timeSyncConfig.logAnnounceSendInterval |
void TimeSync_updateDscpValueInDelayRequestFrame | ( | TimeSync_ParamsHandle_t | timeSyncHandle, |
uint8_t | dscpValue | ||
) |
Update DSCP value in IP header in PTP Delay Request buffer.
timeSyncHandle | Pointer to PTP Handle |
dscpValue | New 6-bit DSCP value to be set |