PDK API Guide for J721E
TIMESYNC HAL API

Introduction

Data Structures

struct  TimeSync_VlanConfig
 TimeSync VLAN configuration structure. More...
 
struct  TimeSync_PpsConfig
 TimeSync PPS configuration structure. More...
 
struct  TimeSync_ProtocolConfig
 TimeSync protocol configuration structure. More...
 
struct  TimeSync_FrameNotifyConfig
 TimeSync frame notify configuration structure. More...
 
struct  TimeSync_SocConfig
 TimeSync SoC configuration structure. More...
 
struct  TimeSync_Config
 Time synchronization configuration structure. More...
 

Functions

TimeSync_Handle TimeSync_open (TimeSync_Config *timeSyncConfig)
 Function to configure low-level network driver. More...
 
int32_t TimeSync_getRxTimestamp (TimeSync_Handle timeSyncHandle, TimeSync_FrameType rxFrameType, uint8_t rxPort, uint16_t seqId, uint32_t *nanoseconds, uint64_t *seconds)
 Reads and provides timestamp of a received event message. More...
 
int32_t TimeSync_getTxTimestamp (TimeSync_Handle timeSyncHandle, TimeSync_FrameType txFrameType, uint8_t txPort, uint16_t seqId, uint32_t *nanoseconds, uint64_t *seconds)
 Reads and provides timestamp of a transmitted event message. More...
 
int32_t TimeSync_adjTimeSlowComp (TimeSync_Handle timeSyncHandle, int32_t adjOffset, uint32_t syncInterval)
 Adjusts the clock by the drift value over one Sync interval. More...
 
int32_t TimeSync_setClockTime (TimeSync_Handle timeSyncHandle, uint32_t nanoseconds, uint64_t seconds)
 Changes the timer value. More...
 
void TimeSync_getCurrentTime (TimeSync_Handle timeSyncHandle, uint32_t *nanoseconds, uint64_t *seconds)
 Returns the current time on device. More...
 
int32_t TimeSync_getPtpFrame (TimeSync_Handle timeSyncHandle, uint8_t *frame, uint32_t *size, uint8_t *rxPort)
 Receive the PTP frame from hardware queue. More...
 
int32_t TimeSync_sendPtpFrame (TimeSync_Handle timeSyncHandle, uint8_t *frame, uint32_t size, uint8_t txPort)
 Transmit the PTP frame to the directed port. More...
 
int32_t TimeSync_isSingleStepSupported (TimeSync_Handle timeSyncHandle)
 Helper function to check if single step mode is supported or not. More...
 
int32_t TimeSync_getPpsTs (TimeSync_Handle timeSyncHandle, uint32_t *nanoseconds, uint64_t *seconds)
 Get PPS timestamp value. More...
 
void TimeSync_recalibratePps (TimeSync_Handle timeSyncHandle)
 Re-calibrate PPS compare values to align with timer's second increment. This recalibration is required when there is a huge jump in timer's value because of correction/adjustment. More...
 
int8_t TimeSync_isPortLinkUp (TimeSync_Handle timeSyncHandle, uint8_t portNum)
 Time sync port link status helper function. More...
 
void TimeSync_reset (TimeSync_Handle timeSyncHandle)
 Time sync module reset. More...
 
void TimeSync_close (TimeSync_Handle timeSyncHandle)
 Time sync module close. More...
 
void TimeSync_updateParentAddress (TimeSync_Handle timeSyncHandle, uint8_t *parentMac)
 Write the MAC ID of PTP master to Firmware. BMC Algorithm calls this API. More...
 
void TimeSync_setRcf (TimeSync_Handle timeSyncHandle, uint32_t rcfValue)
 Set rate compensation factor value. This is used to communicate path rate compensation factor value to ICSS firmware, for other devices this function returns without doing anything. More...
 
void TimeSync_setPathDelay (TimeSync_Handle timeSyncHandle, uint32_t pathDelay, uint8_t portNum)
 Set path delay for port. This is used to communicate path delay to ICSS firmware, for other devices this function returns without doing anything. More...
 
void TimeSync_writeTsSingleStepSync (TimeSync_Handle timeSyncHandle, uint8_t portNum)
 For single step master, computation of Tx seconds and nanoseconds timestamp requires some techniques to avoid a long division in firmware. 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...
 
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...
 
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_calcUdpChecksum (uint8_t *packet)
 Compute checksum for UDP Header and modify in place. More...
 
void TimeSync_getMacId (uint8_t *packet, uint8_t *macId)
 Get the MAC Id from the network stream, convert it to little endian format and return it assumption : MAC is present in big endian byte format and starts from zero offset. More...
 
void TimeSync_addMacID (uint8_t *src, uint8_t *macID)
 Copy MAC ID to a stream. More...
 
uint32_t TimeSync_convBigEndianToLittleEndianWord (uint8_t *byte)
 Get a word from the network stream, convert it to little endian format and return it assumption word is present in big endian byte format and starts from zero offset. More...
 
uint16_t TimeSync_convBigEndianToLittleEndianHalfWord (uint8_t *byte)
 get a halfword from the network stream, convert it to little endian format and return it assumption halfword is present in big endian byte format and starts from zero offset 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...
 

Typedefs

typedef void(* TimeSync_txNotifyCb) (void *cbArg, uint8_t portNum, uint8_t frameType, uint16_t seqId)
 Transmit callback function. More...
 
typedef void(* TimeSync_rxNotifyCb) (void *cbArg)
 Receive callback function. More...
 
typedef void(* TimeSync_ppsNotifyCb) (void *cbArg)
 PTP PPS callback function. More...
 
typedef struct TimeSync_Obj_s * TimeSync_Handle
 TimeSync handle. More...
 

Enumerations

enum  TimeSync_DeviceConfig {
  TIMESYNC_MASTER_CLOCK = 1U, TIMESYNC_TRANSPARENT_CLOCK = 2U, TIMESYNC_ORDINARY_CLOCK = 3U, TIMESYNC_OC_AND_TC = 4U,
  TIMESYNC_BOUNDARY_CLOCK = 5U
}
 PTP Device configuration. More...
 
enum  TimeSync_NetworkProtType {
  TIMESYNC_PROT_UDP_IPV4 = 1U, TIMESYNC_PROT_UDP_IPV6 = 2U, TIMESYNC_PROT_IEEE_802_3 = 3U, TIMESYNC_PROT_DEVICE_NET = 4U,
  TIMESYNC_PROT_CONTROL_NET = 5U, TIMESYNC_PROT_PROFINET = 6U, TIMESYNC_PROT_UNKNOWN = 0xFFFEU
}
 Network Protocol Type. More...
 
enum  TimeSync_VlanType { TIMESYNC_VLAN_TYPE_NONE = 0x00U, TIMESYNC_VLAN_TYPE_SINGLE_TAG = 0x01U, TIMESYNC_VLAN_TYPE_DOUBLE_TAG = 0x02U }
 Enum of VLAN usage type. More...
 
enum  TimeSync_FrameType {
  TIMESYNC_SYNC_FRAME = 0x00U, TIMESYNC_DELAY_REQ_FRAME = 0x01U, TIMESYNC_PDELAY_REQ_FRAME = 0x02U, TIMESYNC_PDELAY_RESP_FRAME = 0x03U,
  TIMESYNC_FOLLOW_UP_FRAME = 0x08U, TIMESYNC_DELAY_RESP_FRAME = 0x09U, TIMESYNC_PDELAY_RESP_FOLLOW_UP_FRAME = 0x0AU, TIMESYNC_ANNOUNCE_FRAME = 0x0BU,
  TIMESYNC_SIGNALING_FRAME = 0x0CU, TIMESYNC_MANAGEMENT_FRAME = 0x0DU
}
 PTP frame types. More...
 
enum  TimeSync_SocType {
  TIMESYNC_SOC_AM335x = 1U, TIMESYNC_SOC_AM437x = 2U, TIMESYNC_SOC_AM571x = 3U, TIMESYNC_SOC_AM572x = 4U,
  TIMESYNC_SOC_AM574x = 5U, TIMESYNC_SOC_AM65xx = 6U, TIMESYNC_SOC_J721E = 7U, TIMESYNC_SOC_UNKNOWN = 0xFFFE
}
 Enum of supported SoCs. More...
 
enum  TimeSync_EthIpVer {
  TIMESYNC_IP_VER_ICSS_V1 = 0U, TIMESYNC_IP_VER_ICSS_V2 = 1U, TIMESYNC_IP_VER_CPSW_2G = 2U, TIMESYNC_IP_VER_CPSW_9G = 3U,
  TIMESYNC_IP_VER_UNKNOWN = 0xFFFE
}
 Enum of supported IP versions. More...
 
enum  TimeSync_StepMode { TIMESYNC_SINGLE_STEP = 1U, TIMESYNC_DOUBLE_STEP = 2U }
 Enum of PTP step modes. More...
 

Macros

#define TIMESYNC_OK   (0)
 Success. More...
 
#define TIMESYNC_UNABLE_TO_INIT_HAL   (-1)
 Time Sync feature not supported. More...
 
#define TIMESYNC_UNABLE_TO_CREATE_TASK   (-2)
 Time Sync module is unable to create a Task. More...
 
#define TIMESYNC_UNABLE_TO_CREATE_SEMAPHORE   (-3)
 Time Sync module is unable to create a Semaphore. More...
 
#define TIMESYNC_UNABLE_TO_CREATE_INTERRUPT   (-4)
 Time Sync module is unable to create an interrupt. More...
 
#define TIMESYNC_UNABLE_TO_ALLOC_MEM   (-5)
 Time Sync module is unable to allocate memory. More...
 
#define TIMESYNC_UNABLE_TO_CREATE_CLOCK   (-6)
 Time Sync module is unable to create timer. More...
 
#define TIMESYNC_UNABLE_TO_CREATE_MAILBOX   (-7)
 Time Sync module is unable to create a mailbox. More...
 
#define TIMESYNC_UNABLE_TO_CREATE_EVENT   (-8)
 Time Sync module is unable to create an event. More...
 
#define TIMESYNC_UNSUPPORTED_FORMAT   (-9)
 Time Sync unsupported format. More...
 
#define TIMESYNC_DMA_INIT_FAILED   (-10)
 Time Sync not able to initialize DMA. More...
 
#define TIMESYNC_FEATURE_NOT_ENABLED   (-11)
 Time Sync feature disabled. More...
 
#define TIMESYNC_HANDLE_NOT_INITIALIZED   (-12)
 Time Sync handle uninitialized. More...
 
#define TIMESYNC_TX_FRAMETYPE_NOTVALID   (-13)
 Time Sync Tx frame type invalid. More...
 
#define TIMESYNC_TX_PORTNUMBER_NOTVALID   (-14)
 Time Sync Tx port number invalid. More...
 
#define TIMESYNC_RX_FRAMETYPE_NOTVALID   (-15)
 Time Sync Rx frame type invalid. More...
 
#define TIMESYNC_RX_PORTNUMBER_NOTVALID   (-16)
 Time Sync Rx port number invalid. More...
 
#define TIMESYNC_PARAM_INVALID   (-17)
 Time Sync invalid parameter. More...
 
#define TIMESYNC_FEATURE_NOT_SUPPORTED   (-18)
 Time Sync feature not supported. More...
 
#define TIMESYNC_FRAME_NOT_AVAILABLE   (-19)
 Time Sync frame not available. More...
 
#define TIMESYNC_NUM_DOMAINS   (2U)
 
#define TIMESYNC_SET_BIT(n)   (1U << (n))
 
#define TIMESYNC_GET_BIT(val, n)   ((val & (1U << n)) >> n)
 
#define TIMESYNC_IS_BIT_SET(val, n)   (((val) & (1U << (n))) != 0U)
 
#define TIMESYNC_START_OF_IP_HEADER   (14)
 
#define TIMESYNC_START_OF_IP_CHECKSUM   (TIMESYNC_START_OF_IP_HEADER + 10U)
 
#define TIMESYNC_START_OF_IP_LENGTH   (TIMESYNC_START_OF_IP_HEADER + 2U)
 
#define TIMESYNC_START_OF_UDP_HEADER   (34U)
 
#define TIMESYNC_START_OF_UDP_CHECKSUM   (TIMESYNC_START_OF_UDP_HEADER + 6U)
 
#define TIMESYNC_START_OF_UDP_LENGTH   (TIMESYNC_START_OF_UDP_HEADER + 4U)
 
#define TIMESYNC_START_OF_IP_PROTOCOL   (TIMESYNC_START_OF_IP_HEADER + 9U)
 
#define TIMESYNC_START_OF_IP_ADDRESS   (TIMESYNC_START_OF_IP_HEADER + 12U)
 
#define TIMESYNC_DEFAULT_ETH_HEADER_SIZE   (14U)
 
#define TIMESYNC_DEFAULT_IP_HEADER_SIZE   (20U)
 
#define TIMESYNC_DEFAULT_UDP_HEADER_SIZE   (8U)
 
#define TIMESYNC_DEFAULT_HEADER_SIZE   (42U)
 
#define TIMESYNC_START_OF_PAYLOAD   (TIMESYNC_START_OF_UDP_HEADER + TIMESYNC_DEFAULT_UDP_HEADER_SIZE)
 
#define TIMESYNC_SEC_TO_NS   (1000000000U)
 
#define TIMESYNC_MAC_ADDR_LEN   (6U)
 
#define TIMESYNC_IPV4_ADDR_LEN   (4U)
 
#define TIMESYNC_IPV6_ADDR_LEN   (16U)
 
#define TIMESYNC_COMPARE_MAC(x, y)   (memcmp((x), (y), 6U) == 0)
 

Macro Definition Documentation

#define TIMESYNC_OK   (0)

Success.

#define TIMESYNC_UNABLE_TO_INIT_HAL   (-1)

Time Sync feature not supported.

#define TIMESYNC_UNABLE_TO_CREATE_TASK   (-2)

Time Sync module is unable to create a Task.

#define TIMESYNC_UNABLE_TO_CREATE_SEMAPHORE   (-3)

Time Sync module is unable to create a Semaphore.

#define TIMESYNC_UNABLE_TO_CREATE_INTERRUPT   (-4)

Time Sync module is unable to create an interrupt.

#define TIMESYNC_UNABLE_TO_ALLOC_MEM   (-5)

Time Sync module is unable to allocate memory.

#define TIMESYNC_UNABLE_TO_CREATE_CLOCK   (-6)

Time Sync module is unable to create timer.

#define TIMESYNC_UNABLE_TO_CREATE_MAILBOX   (-7)

Time Sync module is unable to create a mailbox.

#define TIMESYNC_UNABLE_TO_CREATE_EVENT   (-8)

Time Sync module is unable to create an event.

#define TIMESYNC_UNSUPPORTED_FORMAT   (-9)

Time Sync unsupported format.

#define TIMESYNC_DMA_INIT_FAILED   (-10)

Time Sync not able to initialize DMA.

#define TIMESYNC_FEATURE_NOT_ENABLED   (-11)

Time Sync feature disabled.

#define TIMESYNC_HANDLE_NOT_INITIALIZED   (-12)

Time Sync handle uninitialized.

#define TIMESYNC_TX_FRAMETYPE_NOTVALID   (-13)

Time Sync Tx frame type invalid.

#define TIMESYNC_TX_PORTNUMBER_NOTVALID   (-14)

Time Sync Tx port number invalid.

#define TIMESYNC_RX_FRAMETYPE_NOTVALID   (-15)

Time Sync Rx frame type invalid.

#define TIMESYNC_RX_PORTNUMBER_NOTVALID   (-16)

Time Sync Rx port number invalid.

#define TIMESYNC_PARAM_INVALID   (-17)

Time Sync invalid parameter.

#define TIMESYNC_FEATURE_NOT_SUPPORTED   (-18)

Time Sync feature not supported.

#define TIMESYNC_FRAME_NOT_AVAILABLE   (-19)

Time Sync frame not available.

#define TIMESYNC_NUM_DOMAINS   (2U)

Number of domains supported by this PTP implementation

#define TIMESYNC_SET_BIT (   n)    (1U << (n))

Macro to set bit at given bit position

#define TIMESYNC_GET_BIT (   val,
 
)    ((val & (1U << n)) >> n)

Macro to get bit at given bit position

#define TIMESYNC_IS_BIT_SET (   val,
 
)    (((val) & (1U << (n))) != 0U)

Macro to check if bit at given bit position is set

#define TIMESYNC_START_OF_IP_HEADER   (14)

Starting offset for an IP header in TCP/IP packet

#define TIMESYNC_START_OF_IP_CHECKSUM   (TIMESYNC_START_OF_IP_HEADER + 10U)

Starting offset for checksum in IP header in TCP/IP packet

#define TIMESYNC_START_OF_IP_LENGTH   (TIMESYNC_START_OF_IP_HEADER + 2U)

Starting offset for length field in IP header in TCP/IP packet

#define TIMESYNC_START_OF_UDP_HEADER   (34U)

Starting offset for UDP header in TCP/IP packet

#define TIMESYNC_START_OF_UDP_CHECKSUM   (TIMESYNC_START_OF_UDP_HEADER + 6U)

Starting offset for checksum field in UDP header in TCP/IP packet

#define TIMESYNC_START_OF_UDP_LENGTH   (TIMESYNC_START_OF_UDP_HEADER + 4U)

Starting offset for length field in UDP header in TCP/IP packet

#define TIMESYNC_START_OF_IP_PROTOCOL   (TIMESYNC_START_OF_IP_HEADER + 9U)

Starting offset for protocol field in IP header in TCP/IP packet

#define TIMESYNC_START_OF_IP_ADDRESS   (TIMESYNC_START_OF_IP_HEADER + 12U)

Starting offset for IP address field in IP header in TCP/IP packet

#define TIMESYNC_DEFAULT_ETH_HEADER_SIZE   (14U)

standard size for Ethernet Header (src MAC + dst MAC + EthType) in 802.3 packet

#define TIMESYNC_DEFAULT_IP_HEADER_SIZE   (20U)

standard size for IP header in TCP/IP packet

#define TIMESYNC_DEFAULT_UDP_HEADER_SIZE   (8U)

standard size for UDP header in TCP/IP packet

#define TIMESYNC_DEFAULT_HEADER_SIZE   (42U)

standard size for UDP + IP header in TCP/IP packet

#define TIMESYNC_START_OF_PAYLOAD   (TIMESYNC_START_OF_UDP_HEADER + TIMESYNC_DEFAULT_UDP_HEADER_SIZE)

Starting offset for payload data in UDP header in TCP/IP packet

#define TIMESYNC_SEC_TO_NS   (1000000000U)

Value of seconds in nanoseconds. Useful for calculations

#define TIMESYNC_MAC_ADDR_LEN   (6U)

Length of MAC address in bytes

#define TIMESYNC_IPV4_ADDR_LEN   (4U)

Length of IPv4 address in bytes

#define TIMESYNC_IPV6_ADDR_LEN   (16U)

Length of IPv4 address in bytes

#define TIMESYNC_COMPARE_MAC (   x,
 
)    (memcmp((x), (y), 6U) == 0)

Compare MAC ID's. Uses memcmp internally

Typedef Documentation

typedef void(* TimeSync_txNotifyCb) (void *cbArg, uint8_t portNum, uint8_t frameType, uint16_t seqId)

Transmit callback function.

Parameters
[in]cbArgPointer to callback argument
[in]portNumPort number to which frame was transmitted
[in]frameTypePTP frame type of transmitted frame
[in]seqIdPTP sequence ID of transmitted frame
Returns
None
typedef void(* TimeSync_rxNotifyCb) (void *cbArg)

Receive callback function.

Parameters
[in]cbArgPointer to callback argument
Returns
None
typedef void(* TimeSync_ppsNotifyCb) (void *cbArg)

PTP PPS callback function.

Parameters
[in]cbArgPointer to callback argument
Returns
None
typedef struct TimeSync_Obj_s* TimeSync_Handle

TimeSync handle.

TimeSync opaque handle

Enumeration Type Documentation

PTP Device configuration.

Enumerator
TIMESYNC_MASTER_CLOCK 

Master Clock

TIMESYNC_TRANSPARENT_CLOCK 

Only Transparent Clock

TIMESYNC_ORDINARY_CLOCK 

Only Ordinary Clock

TIMESYNC_OC_AND_TC 

Both Ordinary and Transparent clock

TIMESYNC_BOUNDARY_CLOCK 

Boundary clock

Network Protocol Type.

Enumerator
TIMESYNC_PROT_UDP_IPV4 

IPv4

TIMESYNC_PROT_UDP_IPV6 

IPv6

TIMESYNC_PROT_IEEE_802_3 

Ethernet without TCP/IP

TIMESYNC_PROT_DEVICE_NET 

Device Net

TIMESYNC_PROT_CONTROL_NET 

Control Net

TIMESYNC_PROT_PROFINET 

PROFINET

TIMESYNC_PROT_UNKNOWN 

Unknown protocol type

Enum of VLAN usage type.

Enumerator
TIMESYNC_VLAN_TYPE_NONE 

No VLAN tag

TIMESYNC_VLAN_TYPE_SINGLE_TAG 

Single VLAN tag

TIMESYNC_VLAN_TYPE_DOUBLE_TAG 

Double VLAN tag

PTP frame types.

Enumerator
TIMESYNC_SYNC_FRAME 

Sync frame Id

TIMESYNC_DELAY_REQ_FRAME 

Delay request frame Id

TIMESYNC_PDELAY_REQ_FRAME 

Peer delay request frame Id

TIMESYNC_PDELAY_RESP_FRAME 

Peer delay response frame Id

TIMESYNC_FOLLOW_UP_FRAME 

Followup frame Id

TIMESYNC_DELAY_RESP_FRAME 

Delay response frame Id

TIMESYNC_PDELAY_RESP_FOLLOW_UP_FRAME 

Peer delay response followup frame Id

TIMESYNC_ANNOUNCE_FRAME 

Announce frame Id

TIMESYNC_SIGNALING_FRAME 

Signaling frame Id

TIMESYNC_MANAGEMENT_FRAME 

Management frame Id

Enum of supported SoCs.

Enumerator
TIMESYNC_SOC_AM335x 

AM335x SoC

TIMESYNC_SOC_AM437x 

AM437x SoC

TIMESYNC_SOC_AM571x 

AM571x SoC

TIMESYNC_SOC_AM572x 

AM572x SoC

TIMESYNC_SOC_AM574x 

AM574x SoC

TIMESYNC_SOC_AM65xx 

AM65xx SoC

TIMESYNC_SOC_J721E 

J721E SoC

TIMESYNC_SOC_UNKNOWN 

Unknown SoC

Enum of supported IP versions.

Enumerator
TIMESYNC_IP_VER_ICSS_V1 

For AM335x and AM437x

TIMESYNC_IP_VER_ICSS_V2 

For AM57x

TIMESYNC_IP_VER_CPSW_2G 

CPSW 2G

TIMESYNC_IP_VER_CPSW_9G 

CPSW 9G

TIMESYNC_IP_VER_UNKNOWN 

Unknown IP

Enum of PTP step modes.

Enumerator
TIMESYNC_SINGLE_STEP 

PTP in single step mode

TIMESYNC_DOUBLE_STEP 

PTP in double step mode

Function Documentation

TimeSync_Handle TimeSync_open ( TimeSync_Config timeSyncConfig)

Function to configure low-level network driver.

Parameters
[in]timeSyncConfigPointer to time sync configuration structure
Returns
timeSyncHandle Handle to TimeSync HAL object
int32_t TimeSync_getRxTimestamp ( TimeSync_Handle  timeSyncHandle,
TimeSync_FrameType  rxFrameType,
uint8_t  rxPort,
uint16_t  seqId,
uint32_t *  nanoseconds,
uint64_t *  seconds 
)

Reads and provides timestamp of a received event message.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]rxFrameTypeFrame type of received packet
[in]rxPortPort used for receiving packet
[in]seqIdSequence ID of the packet
[out]nanosecondsPointer to 32 bit nanoseconds field
[out]secondsPointer to 64 bit(48 used) seconds field
Returns
TimeSync error code
int32_t TimeSync_getTxTimestamp ( TimeSync_Handle  timeSyncHandle,
TimeSync_FrameType  txFrameType,
uint8_t  txPort,
uint16_t  seqId,
uint32_t *  nanoseconds,
uint64_t *  seconds 
)

Reads and provides timestamp of a transmitted event message.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]txFrameTypeFrame type transmitted packet
[in]txPortPort used for transmit
[in]seqIdSequence ID of the packet
[out]nanosecondsPointer to 32 bit nanoseconds field
[out]secondsPointer to 64 bit(48 used) seconds field
Returns
TimeSync error code
int32_t TimeSync_adjTimeSlowComp ( TimeSync_Handle  timeSyncHandle,
int32_t  adjOffset,
uint32_t  syncInterval 
)

Adjusts the clock by the drift value over one Sync interval.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]adjOffsetFiltered offset from master in nanoseconds
[in]syncIntervalSync interval
Returns
TimeSync error code
int32_t TimeSync_setClockTime ( TimeSync_Handle  timeSyncHandle,
uint32_t  nanoseconds,
uint64_t  seconds 
)

Changes the timer value.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]nanoseconds32 bit nanoseconds value
[in]seconds64 bit seconds value
Returns
TimeSync error code
void TimeSync_getCurrentTime ( TimeSync_Handle  timeSyncHandle,
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.

    Parameters
    [in]timeSyncHandlePointer to TimeSync object
    [out]nanosecondsPointer to nanoseconds field
    [out]secondsPointer to seconds field
    Returns
    None
int32_t TimeSync_getPtpFrame ( TimeSync_Handle  timeSyncHandle,
uint8_t *  frame,
uint32_t *  size,
uint8_t *  rxPort 
)

Receive the PTP frame from hardware queue.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[out]framePointer to PTP frame buffer
[out]sizeSize of received frame
[out]rxPortPort number frame was received
Returns
TimeSync error code
int32_t TimeSync_sendPtpFrame ( TimeSync_Handle  timeSyncHandle,
uint8_t *  frame,
uint32_t  size,
uint8_t  txPort 
)

Transmit the PTP frame to the directed port.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]framePointer to PTP frame buffer
[in]sizeSize of received frame
[in]txPortPort number to which frame is to be sent
Returns
TimeSync error code
int32_t TimeSync_isSingleStepSupported ( TimeSync_Handle  timeSyncHandle)

Helper function to check if single step mode is supported or not.

Parameters
[in]timeSyncHandlePointer to TimeSync object
Returns
TIMESYNC_OK if supported, otherwise returns TIMESYNC_FEATURE_NOT_SUPPORTED
int32_t TimeSync_getPpsTs ( TimeSync_Handle  timeSyncHandle,
uint32_t *  nanoseconds,
uint64_t *  seconds 
)

Get PPS timestamp value.

Note: In case of ICSS, there are FIFO for PPS timestamps. So, based on consumption rate of timestamps by stack, maximum frequency(or minimum ppsPulseIntervalNs) will have to be fixed.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[out]nanosecondsPointer to nanoseconds field
[out]secondsPointer to seconds field
Returns
TimeSync error code
void TimeSync_recalibratePps ( TimeSync_Handle  timeSyncHandle)

Re-calibrate PPS compare values to align with timer's second increment. This recalibration is required when there is a huge jump in timer's value because of correction/adjustment.

Parameters
[in]timeSyncHandlePointer to TimeSync object
Returns
None
int8_t TimeSync_isPortLinkUp ( TimeSync_Handle  timeSyncHandle,
uint8_t  portNum 
)

Time sync port link status helper function.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]portNumPort number
Returns
TRUE - if link is up FALSE - if link is down.
void TimeSync_reset ( TimeSync_Handle  timeSyncHandle)

Time sync module reset.

Parameters
[in]timeSyncHandlePointer to TimeSync object
Returns
None
void TimeSync_close ( TimeSync_Handle  timeSyncHandle)

Time sync module close.

Parameters
[in]timeSyncHandlePointer to TimeSync object
Returns
None
void TimeSync_updateParentAddress ( TimeSync_Handle  timeSyncHandle,
uint8_t *  parentMac 
)

Write the MAC ID of PTP master to Firmware. BMC Algorithm calls this API.

Below functions are IP-specific. IPs without these features will return without doing anything.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]parentMacPointer to MAC ID of master.
Returns
None
void TimeSync_setRcf ( TimeSync_Handle  timeSyncHandle,
uint32_t  rcfValue 
)

Set rate compensation factor value. This is used to communicate path rate compensation factor value to ICSS firmware, for other devices this function returns without doing anything.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]rcfValueRate compensation factor value
Returns
None
void TimeSync_setPathDelay ( TimeSync_Handle  timeSyncHandle,
uint32_t  pathDelay,
uint8_t  portNum 
)

Set path delay for port. This is used to communicate path delay to ICSS firmware, for other devices this function returns without doing anything.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]pathDelayPath delay value
[in]portNumPort number
Returns
None
void TimeSync_writeTsSingleStepSync ( TimeSync_Handle  timeSyncHandle,
uint8_t  portNum 
)

For single step master, computation of Tx seconds and nanoseconds timestamp requires some techniques to avoid a long division in firmware.

Parameters
[in]timeSyncHandlePointer to TimeSync object
[in]portNumPort number
Returns
None
void TimeSync_addWord ( uint8_t *  src,
uint32_t  word 
)

Add a word to the packet stream.

Parameters
srcPointer to the packet stream
wordWord which is to be added
Returns
None
void TimeSync_addHalfWord ( volatile uint8_t *  src,
uint16_t  halfWord 
)

Add a half word to the packet stream.

Parameters
srcPointer to the packet stream
halfWord16-bit word which is to be added
Returns
None
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 :

  1. Source and Destination are different
  2. Memory is properly allocated (!Function does not check for memory overrun)
  3. Number of bytes is even
    Parameters
    srcPointer to source byte stream
    dstPointer to destination byte stream
    numBytesNumber of bytes to convert and copy
    Returns
    None
uint32_t TimeSync_calcChecksum ( uint8_t *  packet,
uint16_t  len 
)

Compute checksum used in IP/UDP packets for a given stream.

Parameters
packetPointer to the packet stream
lenLength of stream
Returns
Checksum computed
void TimeSync_calcIpChecksum ( uint8_t *  packet)

Compute checksum for IP Header and modify in place.

Parameters
packetPointer to the packet stream
Returns
None
void TimeSync_calcUdpChecksum ( uint8_t *  packet)

Compute checksum for UDP Header and modify in place.

Parameters
packetPointer to the packet stream
Returns
None
void TimeSync_getMacId ( uint8_t *  packet,
uint8_t *  macId 
)

Get the MAC Id from the network stream, convert it to little endian format and return it assumption : MAC is present in big endian byte format and starts from zero offset.

Parameters
packetPointer to byte stream
macIdPointer to array of six bytes which contain the MAC Id in little endian format
Returns
None
void TimeSync_addMacID ( uint8_t *  src,
uint8_t *  macID 
)

Copy MAC ID to a stream.

Parameters
srcPointer to stream
macIDPointer to MAC ID
Returns
None
uint32_t TimeSync_convBigEndianToLittleEndianWord ( uint8_t *  byte)

Get a word from the network stream, convert it to little endian format and return it assumption word is present in big endian byte format and starts from zero offset.

Parameters
bytePointer to byte stream
Returns
word in little endian format
uint16_t TimeSync_convBigEndianToLittleEndianHalfWord ( uint8_t *  byte)

get a halfword from the network stream, convert it to little endian format and return it assumption halfword is present in big endian byte format and starts from zero offset

Parameters
bytePointer to byte stream
Returns
halfword halfword in little endian format
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 :

  1. Source and Destination are different
  2. Memory is properly allocated (!Function does not check for memory overrun)
    Parameters
    srcPointer to source byte stream
    dstPointer to destination byte stream
    Returns
    None