![]() |
emacps
Xilinx SDK Drivers API Documentation
|
Defines hash defines, common data types and prototypes to be used with the PTP standalone example source code residing in this directory.
The PTP standalone example files implement the basic PTPv2 protocol as an example application. However the accuracy of clock offset adjustment is not guaranted as of now. Also the clock rate adjustment and signalling frames are not implemented. Also it may not be implementing all aspects of PTPv2 strictly as per specs. Since it is based on AVB driver (which is 802.1as based), some aspects of 802.1as which are not there in IEEE1588 may be there in the protocol implementation inadvertently. The sync frame interval, announce frame interval and PDelayReq frame intervals are hard-coded.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a asa 09/16/11 First release based on AVB driver 1.01a asa 03/03/12 New hashdefines are added and new function prototypes are added. 3.3 asa 05/19/16 Fix for CR#951152. Made following changes.
Functions | |
void | XEmacPs_PtpRxInterruptHandler (XEmacPs_Ieee1588 *InstancePtr) |
This function is the EmacPs Rx interrupt callback invoked from the EmacPs driver. More... | |
int | XEmacPs_PtpTxPacket (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf, int PacketLen) |
This function is initiates a PTP Tx. More... | |
u32 | XEmacPs_ComparePortIdentity (XEmacPs_PortIdentity Identity1, XEmacPs_PortIdentity Identity2) |
A function to compare two PortIdentity values. More... | |
u32 | XEmacPs_CompareClockIdentity (XEmacPs_ClockIdentity Identity1, XEmacPs_ClockIdentity Identity2) |
A function to compare two ClockIdentity values. More... | |
void | XEmacPs_MasterSendAnnounce (XEmacPs_Ieee1588 *InstancePtr) |
A function to format and then initiate the Tx of a PTP Announce Packet. More... | |
void | XEmacPs_MasterSendSync (XEmacPs_Ieee1588 *InstancePtr) |
A function to format and then initiate the Tx of a PTP SYNC Packet. More... | |
void | XEmacPs_MasterSendFollowUp (XEmacPs_Ieee1588 *InstancePtr) |
A function to format and then initiate the Tx of a PTP FOLLOWUP Packet. More... | |
void | XEmacPs_SendPDelayReq (XEmacPs_Ieee1588 *InstancePtr) |
A function to format and then initiate the Tx of a PTP PDelayReq Packet. More... | |
void | XEmacPs_SendPDelayResp (XEmacPs_Ieee1588 *InstancePtr) |
A function to format and then initiate the Tx of a PTP PDelayResp Packet. More... | |
void | XEmacPs_SendPDelayRespFollowUp (XEmacPs_Ieee1588 *InstancePtr) |
A function to format and then initiate the Tx of a PTP PDelayRespFollowUp Packet. More... | |
u32 | XEmacPs_IsRxFramePTP (u8 *PacketBuf) |
This function extracts length/type information from the Ethernet packet. More... | |
void | XEmacPs_DecodeRxSync (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
A function to decode a received PTP Sync Packet. More... | |
void | XEmacPs_DecodeRxFollowUp (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
A function to decode a received PTP FollowUp Packet. More... | |
void | XEmacPs_DecodeRxPDelayResp (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
A function to decode a received PTP PDelayResp Packet. More... | |
void | XEmacPs_DecodeRxPDelayRespFollowUp (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
A function to decode a received PTP PDelayRespFollowUp Packet. More... | |
void | XEmacPs_DecodeRxSignaling (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
A function to decode a received PTP Signalling Packet. More... | |
void | XEmacPs_DecodeTxAnnounceFrame (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
This function is invoked to compare the Current Master clock's parameter with that of the PTP node's (own) and run Best Master Clock Algorithm. More... | |
void | XEmacPs_DecodeRxAnnounceFrame (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
This function is invoked when a new Announce frame is received. More... | |
void | XEmacPs_ReadAnnounceFrame (u8 *PacketBuf, XEmacPs_BmcData *AnnounceFrame) |
This function is invoked from various places to extract clock information from a buffer and populate the XEmacPs_BmcData instance passed. More... | |
void | XEmacPs_UpdateBmcRecords (XEmacPs_BmcData *NewMaster, XEmacPs_BmcData *CurrentBmc) |
This function updates the PTP master records (BMC records) with incoming BMC data. More... | |
u32 | XEmacPs_BestMasterClockAlgorithm (XEmacPs_BmcData *AnnounceFrame, XEmacPs_BmcData *CurrentBmc) |
This function will accept the data pointer to the current BMCA records, accept a pointer to an equivalent data structure for the new Announce Packet. More... | |
void | XEmacPs_BecomeRtcMaster (XEmacPs_Ieee1588 *InstancePtr, u8 txAnnounceHasWon) |
This function is called when the PTP node becomes RTC or PTP Master. More... | |
void | XEmacPs_BecomeRtcSlave (XEmacPs_Ieee1588 *InstancePtr) |
This function is called when the PTP node becomes PTP Slave. More... | |
void | XEmacPs_ChangePeerIeee1588v2Capability (XEmacPs_Ieee1588 *InstancePtr, u8 capable) |
This function is called to change the Peer capability of processing Iee1588v2 specific frames, e.g. More... | |
void | XEmacPs_CalcDelay (XEmacPs_Ieee1588 *InstancePtr) |
This function is called to calculate the link delay. More... | |
void | XEmacPs_CalcRtcOffset (XEmacPs_Ieee1588 *InstancePtr) |
This function calculates the Slave Offset from the GrandMaster time. More... | |
void | XEmacPs_UpdateRtcIncrement (XEmacPs_Ieee1588 *InstancePtr) |
This function clock rate adjustment. More... | |
u32 | XEmacPs_htonll (unsigned long long int n) |
A function to do endian conversion for long long int type. More... | |
u32 | XEmacPs_ntohll (long long int n) |
A function to do endian conversion for long long int type. More... | |
u8 | XEmacPs_GetMsgType (u8 *PacketBuf) |
This function extracts PTP messgae type information from the PTP packet. More... | |
void | XEmacPs_GetPortIdentity (u8 *PacketBuf, XEmacPs_PortIdentity *portID) |
A function to extract portIdentity information from a received PTP frame. More... | |
u16 | XEmacPs_GetSequenceId (u8 *PacketBuf) |
A function to extract SequenceId information from a received PTP frame. More... | |
u16 | XEmacPs_IncSequenceId (u8 *PacketBuf) |
A function to increment sequence ID in a PTP frames. More... | |
void | XEmacPs_SetMdioDivisor (XEmacPs *InstancePtr, XEmacPs_MdcDiv Divisor) |
Set the MDIO clock divisor. More... | |
unsigned int | XEmacPs_TsuCalcClk (u32 Freq) |
Calculate clock configuration register values for indicated input clock. More... | |
void XEmacPs_BecomeRtcMaster | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 | txAnnounceHasWon | ||
) |
This function is called when the PTP node becomes RTC or PTP Master.
This will make any adjustments needed when the node becomes the Grand Master, including resetting the RTC to its nominal value
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
txAnnounceHasWon | if 1, indicates that this function has been called from the function XEmacPs_DecodeTxAnnounceFrame(). This way it can avoid performing things that are already done. |
References XEMACPS_1588_INC_OFFSET, XEmacPs_ReadAnnounceFrame(), XEmacPs_TsuCalcClk(), XEmacPs_UpdateBmcRecords(), and XEmacPs_WriteReg.
Referenced by XEmacPs_DecodeTxAnnounceFrame(), and XEmacPs_InitializeProtocolData().
void XEmacPs_BecomeRtcSlave | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
This function is called when the PTP node becomes PTP Slave.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
u32 XEmacPs_BestMasterClockAlgorithm | ( | XEmacPs_BmcData * | AnnounceFrame, |
XEmacPs_BmcData * | CurrentBmc | ||
) |
This function will accept the data pointer to the current BMCA records, accept a pointer to an equivalent data structure for the new Announce Packet.
TheBest Master Clock Algorithm (BMCA) is then performed on these two data structures by comparing the data fields
AnnounceFrame | of the received new frame |
CurrentBmc | is the existing BMC records |
Referenced by XEmacPs_DecodeRxAnnounceFrame(), and XEmacPs_DecodeTxAnnounceFrame().
void XEmacPs_CalcDelay | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
This function is called to calculate the link delay.
This is called after a complete sequence of PDelay packets. The PTP node sends a PDelayReq packet to start. Afterwards it receives the PDelayResp and PDelayRespFollowUp frames. Upon receiving the PDelayRespFollowUp, this function is invoked to calculate the link delay.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
void XEmacPs_CalcRtcOffset | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
This function calculates the Slave Offset from the GrandMaster time.
It is called after receiving a Sync and FollowUp frame pair.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
void XEmacPs_ChangePeerIeee1588v2Capability | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 | Capable | ||
) |
This function is called to change the Peer capability of processing Iee1588v2 specific frames, e.g.
PDelayReq, PDelayResp etc. A peer is Ieee1588v2 capable when it is able to send PDelayReq frames or able to respond to PDelayReq frames.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
capable | is Peer's capability |
Referenced by XEmacPs_DecodeRxPDelayResp(), and XEmacPs_InitializeProtocolData().
u32 XEmacPs_CompareClockIdentity | ( | XEmacPs_ClockIdentity | Identity1, |
XEmacPs_ClockIdentity | Identity2 | ||
) |
A function to compare two ClockIdentity values.
Identity1 | is the first ClockIdentity to be compared |
Identity2 | is the second ClockIdentity to be compared |
Referenced by XEmacPs_DecodeRxAnnounceFrame().
u32 XEmacPs_ComparePortIdentity | ( | XEmacPs_PortIdentity | Identity1, |
XEmacPs_PortIdentity | Identity2 | ||
) |
A function to compare two PortIdentity values.
Identity1 | is the first sourcePortIdentity to be compared |
Identity2 | is the second sourcePortIdentity to be compared |
Referenced by XEmacPs_DecodeRxAnnounceFrame(), XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayResp(), XEmacPs_DecodeRxPDelayRespFollowUp(), and XEmacPs_DecodeRxSync().
void XEmacPs_DecodeRxAnnounceFrame | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
This function is invoked when a new Announce frame is received.
This function first reads the Announce frame parameters. If it is found that the announce frame has been received from the PTP master then the records are updated with the clock parameters. The Best Master Clock Algorithm is run in case any of the parameters in the announce frame has changed. There can be cases when the PTP master reduces its clock priority that may force the current PTP node to become master. If the PTP node is master and it has received this announce frame, then BMCA is run and if the incoming clock parameters are better tyhan that of the present node, the present node becomes SLAVE.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the Announce Frame. |
References XEmacPs_BestMasterClockAlgorithm(), XEmacPs_CompareClockIdentity(), XEmacPs_ComparePortIdentity(), XEmacPs_DecodeTxAnnounceFrame(), XEmacPs_ReadAnnounceFrame(), and XEmacPs_UpdateBmcRecords().
void XEmacPs_DecodeRxFollowUp | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
A function to decode a received PTP FollowUp Packet.
If the PTP node is master, source port identity of the received FollowUp frame matches that with this node's source port identity, the sequence Id of the received folowup frame matches that of last received Sync frame sequence Id, the function XEmacPs_CalcRtcOffset is invoked to calculate clock offset. Similalry for every 2 sync frames clock rate adjustment is done by calling XEmacPs_UpdateRtcIncrement. However, as of now, this function is not implemented and is empty.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the followup packet. |
References XEmacPs_ComparePortIdentity(), XEmacPs_GetPortIdentity(), and XEmacPs_GetSequenceId().
void XEmacPs_DecodeRxPDelayResp | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
A function to decode a received PTP PDelayResp Packet.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the PDelayResp packet. |
References XEmacPs_ChangePeerIeee1588v2Capability(), XEmacPs_ComparePortIdentity(), and XEmacPs_GetPortIdentity().
void XEmacPs_DecodeRxPDelayRespFollowUp | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
A function to decode a received PTP PDelayRespFollowUp Packet.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the PDelayRespFollowUp packet. |
References XEmacPs_ComparePortIdentity(), XEmacPs_GetPortIdentity(), and XEmacPs_GetSequenceId().
void XEmacPs_DecodeRxSignaling | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
A function to decode a received PTP Signalling Packet.
Empty as of now.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the signalling packet. |
void XEmacPs_DecodeRxSync | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
A function to decode a received PTP Sync Packet.
It extracts the sync frame time stamp and stores it in appropriate buffer. It stores the sequence ID as well.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the sync packet. |
References XEmacPs_ComparePortIdentity(), XEmacPs_GetPortIdentity(), XEmacPs_GetSequenceId(), XEMACPS_PTP_RXNANOSEC_OFFSET, XEMACPS_PTP_RXSEC_OFFSET, and XEmacPs_ReadReg.
void XEmacPs_DecodeTxAnnounceFrame | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
This function is invoked to compare the Current Master clock's parameter with that of the PTP node's (own) and run Best Master Clock Algorithm.
A typical scenario is a new Announce frame has been received from the PTP Master and the PTP master record has been updated. Then this function is invoked to run Best Master Clock Algorithm with the PTP node's Announce Frame parameters and Current PTP Master's parameter.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
PacketBuf | is the buffer that contains the Announce Frame. For this function the buffer passed is the Tx Announce Frame stored in the buffer AnnounceFrmToTx in XEmacPs_Ieee1588 instance. |
References XEmacPs_BecomeRtcMaster(), XEmacPs_BestMasterClockAlgorithm(), XEmacPs_ReadAnnounceFrame(), and XEmacPs_UpdateBmcRecords().
Referenced by XEmacPs_DecodeRxAnnounceFrame(), and XEmacPs_InitializeProtocolData().
u8 XEmacPs_GetMsgType | ( | u8 * | PacketBuf | ) |
This function extracts PTP messgae type information from the PTP packet.
PacketBuf | contains the Ethernet packet. |
Referenced by XEmacPs_PtpTxDoFurtherProcessing().
void XEmacPs_GetPortIdentity | ( | u8 * | PacketBuf, |
XEmacPs_PortIdentity * | portID | ||
) |
A function to extract portIdentity information from a received PTP frame.
This can be any portIdentity field (header portIdentity, requestingPortIdentity etc...)
PacketBuf | contains the PTP buffer from which the portIdentity is to be extracted. |
portID | is the address of type XEmacPs_PortIdentity is which the extracted port identity is put. |
Referenced by XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayResp(), XEmacPs_DecodeRxPDelayRespFollowUp(), XEmacPs_DecodeRxSync(), and XEmacPs_ReadAnnounceFrame().
u16 XEmacPs_GetSequenceId | ( | u8 * | PacketBuf | ) |
A function to extract SequenceId information from a received PTP frame.
PacketBuf | contains the PTP buffer from which the portIdentity is to be extracted. |
Referenced by XEmacPs_DecodeRxFollowUp(), XEmacPs_DecodeRxPDelayRespFollowUp(), and XEmacPs_DecodeRxSync().
u32 XEmacPs_htonll | ( | unsigned long long int | n | ) |
A function to do endian conversion for long long int type.
This is for little to big endian conversion.
Parameter | whose endian conversion is needed |
Referenced by XEmacPs_ntohll().
u16 XEmacPs_IncSequenceId | ( | u8 * | PacketBuf | ) |
A function to increment sequence ID in a PTP frames.
It first extracts the sequence ID and then increments and puts it back in the PTP frame.
PacketBuf | contains the PTP buffer from which the portIdentity is to be extracted. |
Referenced by XEmacPs_MasterSendAnnounce(), and XEmacPs_SendPDelayReq().
u32 XEmacPs_IsRxFramePTP | ( | u8 * | PacketBuf | ) |
This function extracts length/type information from the Ethernet packet.
PacketBuf | contains the Ethernet packet. |
void XEmacPs_MasterSendAnnounce | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
A function to format and then initiate the Tx of a PTP Announce Packet.
The sequence Id of the announce frame is incremented before initiating the Tx.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
References XEmacPs_IncSequenceId(), and XEmacPs_PtpTxPacket().
void XEmacPs_MasterSendFollowUp | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
A function to format and then initiate the Tx of a PTP FOLLOWUP Packet.
Updates the correction field in the buffer.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
void XEmacPs_MasterSendSync | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
A function to format and then initiate the Tx of a PTP SYNC Packet.
The sequence Id of the announce frame is incremented before initiating the Tx.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
u32 XEmacPs_ntohll | ( | long long int | n | ) |
A function to do endian conversion for long long int type.
This is for big to little endian conversion.
Parameter | whose endian conversion is needed |
References XEmacPs_htonll().
void XEmacPs_PtpRxInterruptHandler | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
This function is the EmacPs Rx interrupt callback invoked from the EmacPs driver.
Here we set the flag PtpNewPktRecd to true. This flag is checked for in the function XEmacPs_RunIEEE1588Protocol for further processing of packets.
InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588. |
int XEmacPs_PtpTxPacket | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf, | ||
int | PacketLen | ||
) |
This function is initiates a PTP Tx.
This is called from various places.
InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588. |
PacketBuf | is the buffer that contains the packet to be Txed |
PacketLen | is the length of the packet to be Txed. |
References XEmacPs_BdClearTxUsed, XEmacPs_BdRingAlloc(), XEmacPs_BdRingToHw(), XEmacPs_BdSetAddressTx, XEmacPs_BdSetLast, XEmacPs_BdSetLength, XEmacPs_GetTxRing, XEmacPs_ReadReg, XEmacPs_Transmit, and XEMACPS_TXSR_OFFSET.
Referenced by XEmacPs_MasterSendAnnounce().
void XEmacPs_ReadAnnounceFrame | ( | u8 * | PacketBuf, |
XEmacPs_BmcData * | AnnounceFrame | ||
) |
This function is invoked from various places to extract clock information from a buffer and populate the XEmacPs_BmcData instance passed.
PacketBuf | from which the clock information is extracted |
AnnounceFrame | which is populated with clock information |
References XEmacPs_GetPortIdentity().
Referenced by XEmacPs_BecomeRtcMaster(), XEmacPs_DecodeRxAnnounceFrame(), and XEmacPs_DecodeTxAnnounceFrame().
void XEmacPs_SendPDelayReq | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
A function to format and then initiate the Tx of a PTP PDelayReq Packet.
The sequence Id of the announce frame is incremented before initiating the Tx.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
References XEmacPs_IncSequenceId().
void XEmacPs_SendPDelayResp | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
A function to format and then initiate the Tx of a PTP PDelayResp Packet.
This function is invoked upon receiving a PDelayReq frame. It first gets the time stamps of the received PDelayReq from the hardware and stores them at appropriate entries in the structure instance PtpRecords. It then formats the PDelayResp frame with these time stamp values.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
void XEmacPs_SendPDelayRespFollowUp | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
A function to format and then initiate the Tx of a PTP PDelayRespFollowUp Packet.
This function is invoked after a PDelayResp is successfully sent out (Tx done interrupt is received for PDelayResp packet). It populates the PDelayRespFollowUp frame with time stamps of the just transmitted PDelayResp packet.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |
unsigned int XEmacPs_TsuCalcClk | ( | u32 | Freq | ) |
Calculate clock configuration register values for indicated input clock.
- | Freq |
Referenced by XEmacPs_BecomeRtcMaster().
void XEmacPs_UpdateBmcRecords | ( | XEmacPs_BmcData * | NewMaster, |
XEmacPs_BmcData * | CurrentBmc | ||
) |
This function updates the PTP master records (BMC records) with incoming BMC data.
NewMaster | is the new data to be updated |
CurrentBmc | is the existing BMC records that needs to be updated. |
Referenced by XEmacPs_BecomeRtcMaster(), XEmacPs_DecodeRxAnnounceFrame(), and XEmacPs_DecodeTxAnnounceFrame().
void XEmacPs_UpdateRtcIncrement | ( | XEmacPs_Ieee1588 * | InstancePtr | ) |
This function clock rate adjustment.
Not implemented as of now.
InstancePtr | is a pointer to the XEmacPs_Ieee1588 instance. |