![]() |
emacps
Xilinx SDK Drivers API Documentation
|
This file implements the following functionalities.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a asa 09/16/11 First release based on the AVB driver. 1.01a asa 03/03/12 Support for Zynq is added. 3.3 asa 05/19/16 Removed code specific to PEEP.
Functions | |
void | XEmacPs_PtpTxDoFurtherProcessing (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
This function is invoked from the TxDone callback. 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... | |
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_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_DecodeRxAnnounceFrame (XEmacPs_Ieee1588 *InstancePtr, u8 *PacketBuf) |
This function is invoked when a new Announce frame is received. 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_UpdateBmcRecords (XEmacPs_BmcData *NewMaster, XEmacPs_BmcData *CurrentBmc) |
This function updates the PTP master records (BMC records) with incoming BMC data. 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... | |
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().
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().
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. |
void XEmacPs_PtpTxDoFurtherProcessing | ( | XEmacPs_Ieee1588 * | InstancePtr, |
u8 * | PacketBuf | ||
) |
This function is invoked from the TxDone callback.
For sync frame it obtains the time stamp and populates the FollowUp frame Tx buffer. For PDelayReq and PDelayResp frames it obtains the time stamp and stores it is appropriate buffers.
InstancePntr | is a pointer to the instance of the XEmacPs_Ieee1588. |
PacketBuf | which contains the buffer just transmitted |
References XEmacPs_GetMsgType().
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. |
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. |