gPTP Documentation
|
#include <avbts_port.hpp>
Public Member Functions | |
bool | serializeState (void *buf, long *count) |
Serializes (i.e. copy over buf pointer) the information from the variables (in that order): More... | |
bool | restoreSerializedState (void *buf, long *count) |
Restores the serialized state from the buffer. Copies the information from buffer to the variables (in that order): More... | |
void | becomeMaster (bool annc) |
Switches port to a gPTP master. More... | |
void | becomeSlave (bool restart_syntonization) |
Switches port to a gPTP slave. More... | |
void | startPDelay () |
Starts pDelay event timer. More... | |
void | startAnnounce () |
Starts announce event timer. More... | |
void | syncDone () |
Starts pDelay event timer if not yet started. More... | |
OSTimerFactory * | getTimerFactory () |
Gets a pointer to timer_factory object. More... | |
void | setAsCapable (bool ascap) |
Sets asCapable flag. More... | |
bool | getAsCapable () |
Gets the asCapable flag. More... | |
~IEEE1588Port () | |
IEEE1588Port (IEEE1588Clock *clock, uint16_t index, bool forceSlave, int accelerated_sync_count, HWTimestamper *timestamper, int32_t offset, InterfaceLabel *net_label, OSConditionFactory *condition_factory, OSThreadFactory *thread_factory, OSTimerFactory *timer_factory, OSLockFactory *lock_factory) | |
Creates the IEEE1588Port interface. More... | |
bool | init_port () |
Initializes the port. Creates network interface, initializes hardware timestamper and create OS locks conditions. More... | |
void | recoverPort (void) |
Currently doesnt do anything. Just returns. More... | |
void * | openPort (void) |
Receives messages from the network interface. More... | |
unsigned | getPayloadOffset () |
Get the payload offset inside a packet. More... | |
void | sendEventPort (uint8_t *buf, int len, MulticastType mcast_type, PortIdentity *destIdentity) |
Sends and event to a IEEE1588 port. It includes timestamp. More... | |
void | sendGeneralPort (uint8_t *buf, int len, MulticastType mcast_type, PortIdentity *destIdentity) |
Sends a general message to a port. No timestamps. More... | |
void | processEvent (Event e) |
Process all events for a IEEE1588Port. More... | |
PTPMessageAnnounce * | calculateERBest (void) |
Gets the "best" announce. More... | |
void | addForeignMaster (PTPMessageAnnounce *msg) |
Adds a foreign master. More... | |
void | removeForeignMaster (PTPMessageAnnounce *msg) |
Remove a foreign master. More... | |
void | removeForeignMasterAll (void) |
Remove all foreign masters. More... | |
void | addQualifiedAnnounce (PTPMessageAnnounce *msg) |
Adds a new qualified announce the port. IEEE 802.1AS Clause 10.3.10.2. More... | |
char | getSyncInterval (void) |
Gets the sync interval value. More... | |
char | getAnnounceInterval (void) |
Gets the announce interval. More... | |
char | getPDelayInterval (void) |
Gets the pDelay minimum interval. More... | |
PortState | getPortState (void) |
Gets the portState information. More... | |
void | setPortState (PortState state) |
Sets the PortState. More... | |
void | getPortIdentity (PortIdentity &identity) |
Gets port identity. More... | |
bool | burstEnabled (void) |
Gets the burst_enabled flag. More... | |
uint16_t | getNextAnnounceSequenceId (void) |
Increments announce sequence id and returns. More... | |
uint16_t | getNextSyncSequenceId (void) |
Increments sync sequence ID and returns. More... | |
uint16_t | getNextPDelaySequenceId (void) |
Increments PDelay sequence ID and returns. More... | |
uint16_t | getParentLastSyncSequenceNumber (void) |
Gets last sync sequence number from parent. More... | |
void | setParentLastSyncSequenceNumber (uint16_t num) |
Sets last sync sequence number from parent. More... | |
IEEE1588Clock * | getClock (void) |
Gets a pointer to IEEE1588Clock. More... | |
void | setLastSync (PTPMessageSync *msg) |
Sets last sync ptp message. More... | |
PTPMessageSync * | getLastSync (void) |
Gets last sync message. More... | |
bool | getPDelayRxLock () |
Locks PDelay RX. More... | |
bool | tryPDelayRxLock () |
Do a trylock on the PDelay RX. More... | |
bool | putPDelayRxLock () |
Unlocks PDelay RX. More... | |
bool | getTxLock () |
Locks the TX port. More... | |
bool | putTxLock () |
Unlocks the port TX. More... | |
int | getTimestampVersion () |
Gets the hardware timestamper version. More... | |
void | setLastPDelayReq (PTPMessagePathDelayReq *msg) |
Sets the last_pdelay_req message. More... | |
PTPMessagePathDelayReq * | getLastPDelayReq (void) |
Gets the last PTPMessagePathDelayReq message. More... | |
void | setLastPDelayResp (PTPMessagePathDelayResp *msg) |
Sets the last PTPMessagePathDelayResp message. More... | |
PTPMessagePathDelayResp * | getLastPDelayResp (void) |
Gets the last PTPMessagePathDelayResp message. More... | |
void | setLastPDelayRespFollowUp (PTPMessagePathDelayRespFollowUp *msg) |
Sets the last PTPMessagePathDelayRespFollowUp message. More... | |
PTPMessagePathDelayRespFollowUp * | getLastPDelayRespFollowUp (void) |
Gets the last PTPMessagePathDelayRespFollowUp message. More... | |
FrequencyRatio | getPeerRateOffset (void) |
Gets the Peer rate offset. Used to calculate neighbor rate ratio. More... | |
void | setPeerRateOffset (FrequencyRatio offset) |
Sets the peer rate offset. Used to calculate neighbor rate ratio. More... | |
void | setPeerOffset (Timestamp mine, Timestamp theirs) |
Sets peer offset timestamps. More... | |
bool | getPeerOffset (Timestamp &mine, Timestamp &theirs) |
Gets peer offset timestamps. More... | |
bool | _adjustClockRate (FrequencyRatio freq_offset) |
Adjusts the clock frequency. More... | |
bool | adjustClockRate (FrequencyRatio freq_offset) |
Adjusts the clock frequency. More... | |
void | getExtendedError (char *msg) |
Gets extended error message from hardware timestamper. More... | |
int | getRxTimestamp (PortIdentity *sourcePortIdentity, uint16_t sequenceId, Timestamp ×tamp, unsigned &counter_value, bool last) |
Gets RX timestamp based on port identity. More... | |
int | getTxTimestamp (PortIdentity *sourcePortIdentity, uint16_t sequenceId, Timestamp ×tamp, unsigned &counter_value, bool last) |
Gets TX timestamp based on port identity. More... | |
int | getTxTimestamp (PTPMessageCommon *msg, Timestamp ×tamp, unsigned &counter_value, bool last) |
Gets TX timestamp based on PTP message. More... | |
int | getRxTimestamp (PTPMessageCommon *msg, Timestamp ×tamp, unsigned &counter_value, bool last) |
Gets RX timestamp based on PTP message. More... | |
void | getDeviceTime (Timestamp &system_time, Timestamp &device_time, uint32_t &local_clock, uint32_t &nominal_clock_rate) |
Get the cross timestamping information. The gPTP subsystem uses these samples to calculate ratios which can be used to translate or extrapolate one clock into another clock reference. The gPTP service uses these supplied cross timestamps to perform internal rate estimation and conversion functions. More... | |
uint64_t | getLinkDelay (void) |
Gets the link delay information. More... | |
void | setLinkDelay (int64_t delay) |
Sets link delay information. Signed value allows this to be negative result because of inaccurate timestamps. More... | |
void | recommendState (PortState state, bool changed_external_master) |
Changes the port state. More... | |
void | mapSocketAddr (PortIdentity *destIdentity, LinkLayerAddress *remote) |
Maps socket addr to the remote link layer address. More... | |
void | addSockAddrMap (PortIdentity *destIdentity, LinkLayerAddress *remote) |
Adds New sock addr map. More... | |
void | incPdelayCount () |
Increments Pdelay count. More... | |
unsigned | getPdelayCount () |
Gets current pdelay count value. It is set to zero when asCapable is false. More... | |
void | incSyncCount () |
Increments sync count. More... | |
unsigned | getSyncCount () |
Gets current sync count value. It is set to zero when master and incremented at each sync received for slave. More... | |
Public Attributes | |
bool | forceSlave |
Forces port to be slave. Added for testing. | |
Provides the IEEE 1588 port interface
IEEE1588Port::~IEEE1588Port | ( | ) |
Destroys a IEEE1588Port
IEEE1588Port::IEEE1588Port | ( | IEEE1588Clock * | clock, |
uint16_t | index, | ||
bool | forceSlave, | ||
int | accelerated_sync_count, | ||
HWTimestamper * | timestamper, | ||
int32_t | offset, | ||
InterfaceLabel * | net_label, | ||
OSConditionFactory * | condition_factory, | ||
OSThreadFactory * | thread_factory, | ||
OSTimerFactory * | timer_factory, | ||
OSLockFactory * | lock_factory | ||
) |
Creates the IEEE1588Port interface.
clock | IEEE1588Clock instance |
index | Interface index |
forceSlave | Forces port to be slave |
accelerated_sync_count | If non-zero, then start 16ms sync timer |
timestamper | Hardware timestamper instance |
offset | Initial clock offset |
net_label | Network label |
condition_factory | OSConditionFactory instance |
thread_factory | OSThreadFactory instance |
timer_factory | OSTimerFactory instance |
lock_factory | OSLockFactory instance |
|
inline |
Adjusts the clock frequency.
freq_offset | Frequency offset |
void IEEE1588Port::addForeignMaster | ( | PTPMessageAnnounce * | msg | ) |
Adds a foreign master.
msg | [in] PTP announce message |
|
inline |
Adds a new qualified announce the port. IEEE 802.1AS Clause 10.3.10.2.
msg | PTP announce message |
void IEEE1588Port::addSockAddrMap | ( | PortIdentity * | destIdentity, |
LinkLayerAddress * | remote | ||
) |
Adds New sock addr map.
destIdentity | [in] PortIdentity remote |
remote | [in] remote link layer address |
|
inline |
Adjusts the clock frequency.
freq_offset | Frequency offset |
void IEEE1588Port::becomeMaster | ( | bool | annc | ) |
Switches port to a gPTP master.
annc | If TRUE, starts announce event timer. |
void IEEE1588Port::becomeSlave | ( | bool | restart_syntonization | ) |
Switches port to a gPTP slave.
restart_syntonization | if TRUE, restarts the syntonization |
|
inline |
Gets the burst_enabled flag.
PTPMessageAnnounce* IEEE1588Port::calculateERBest | ( | void | ) |
Gets the "best" announce.
|
inline |
Gets the announce interval.
|
inline |
Gets the asCapable flag.
IEEE1588Clock* IEEE1588Port::getClock | ( | void | ) |
Gets a pointer to IEEE1588Clock.
void IEEE1588Port::getDeviceTime | ( | Timestamp & | system_time, |
Timestamp & | device_time, | ||
uint32_t & | local_clock, | ||
uint32_t & | nominal_clock_rate | ||
) |
Get the cross timestamping information. The gPTP subsystem uses these samples to calculate ratios which can be used to translate or extrapolate one clock into another clock reference. The gPTP service uses these supplied cross timestamps to perform internal rate estimation and conversion functions.
system_time | [out] System time |
device_time | [out] Device time |
local_clock | [out] Local clock |
nominal_clock_rate | [out] Nominal clock rate |
|
inline |
Gets extended error message from hardware timestamper.
msg | [out] Extended error message |
|
inline |
Gets the last PTPMessagePathDelayReq message.
|
inline |
Gets the last PTPMessagePathDelayResp message.
|
inline |
Gets the last PTPMessagePathDelayRespFollowUp message.
|
inline |
Gets last sync message.
|
inline |
Gets the link delay information.
|
inline |
Increments announce sequence id and returns.
|
inline |
Increments PDelay sequence ID and returns.
|
inline |
Increments sync sequence ID and returns.
uint16_t IEEE1588Port::getParentLastSyncSequenceNumber | ( | void | ) |
Gets last sync sequence number from parent.
unsigned IEEE1588Port::getPayloadOffset | ( | ) |
Get the payload offset inside a packet.
|
inline |
Gets current pdelay count value. It is set to zero when asCapable is false.
|
inline |
Gets the pDelay minimum interval.
|
inline |
Locks PDelay RX.
Gets peer offset timestamps.
mine | [out] Reference to local timestamps |
theirs | [out] Reference to remote timestamps |
|
inline |
Gets the Peer rate offset. Used to calculate neighbor rate ratio.
|
inline |
|
inline |
Gets the portState information.
int IEEE1588Port::getRxTimestamp | ( | PortIdentity * | sourcePortIdentity, |
uint16_t | sequenceId, | ||
Timestamp & | timestamp, | ||
unsigned & | counter_value, | ||
bool | last | ||
) |
Gets RX timestamp based on port identity.
sourcePortIdentity | [in] Source port identity |
sequenceId | Sequence ID |
timestamp | [out] RX timestamp |
counter_value | [out] timestamp count value |
last | If true, removes the rx lock. |
int IEEE1588Port::getRxTimestamp | ( | PTPMessageCommon * | msg, |
Timestamp & | timestamp, | ||
unsigned & | counter_value, | ||
bool | last | ||
) |
Gets RX timestamp based on PTP message.
msg | PTPMessageCommon message |
timestamp | [out] RX timestamp |
counter_value | [out] timestamp count value |
last | If true, removes the RX lock |
|
inline |
Gets current sync count value. It is set to zero when master and incremented at each sync received for slave.
|
inline |
Gets the sync interval value.
|
inline |
Gets a pointer to timer_factory object.
|
inline |
Gets the hardware timestamper version.
|
inline |
Locks the TX port.
int IEEE1588Port::getTxTimestamp | ( | PortIdentity * | sourcePortIdentity, |
uint16_t | sequenceId, | ||
Timestamp & | timestamp, | ||
unsigned & | counter_value, | ||
bool | last | ||
) |
Gets TX timestamp based on port identity.
sourcePortIdentity | [in] Source port identity |
sequenceId | Sequence ID |
timestamp | [out] TX timestamp |
counter_value | [out] timestamp count value |
last | If true, removes the TX lock |
int IEEE1588Port::getTxTimestamp | ( | PTPMessageCommon * | msg, |
Timestamp & | timestamp, | ||
unsigned & | counter_value, | ||
bool | last | ||
) |
Gets TX timestamp based on PTP message.
msg | PTPMessageCommon message |
timestamp | [out] TX timestamp |
counter_value | [out] timestamp count value |
last | If true, removes the TX lock |
|
inline |
Increments Pdelay count.
|
inline |
Increments sync count.
bool IEEE1588Port::init_port | ( | ) |
Initializes the port. Creates network interface, initializes hardware timestamper and create OS locks conditions.
void IEEE1588Port::mapSocketAddr | ( | PortIdentity * | destIdentity, |
LinkLayerAddress * | remote | ||
) |
Maps socket addr to the remote link layer address.
destIdentity | [in] PortIdentity remote |
remote | [in] remote link layer address |
void* IEEE1588Port::openPort | ( | void | ) |
Receives messages from the network interface.
void IEEE1588Port::processEvent | ( | Event | e | ) |
|
inline |
Unlocks PDelay RX.
|
inline |
Unlocks the port TX.
void IEEE1588Port::recommendState | ( | PortState | state, |
bool | changed_external_master | ||
) |
Changes the port state.
state | Current state |
changed_external_master | TRUE if external master has changed, FALSE otherwise |
void IEEE1588Port::recoverPort | ( | void | ) |
Currently doesnt do anything. Just returns.
void IEEE1588Port::removeForeignMaster | ( | PTPMessageAnnounce * | msg | ) |
Remove a foreign master.
msg | [in] PTP announce message |
void IEEE1588Port::removeForeignMasterAll | ( | void | ) |
bool IEEE1588Port::restoreSerializedState | ( | void * | buf, |
long * | count | ||
) |
Restores the serialized state from the buffer. Copies the information from buffer to the variables (in that order):
buf | Buffer containing the serialized state. |
count | Buffer lenght. It is decremented by the same size of the variables that are being copied. |
void IEEE1588Port::sendEventPort | ( | uint8_t * | buf, |
int | len, | ||
MulticastType | mcast_type, | ||
PortIdentity * | destIdentity | ||
) |
Sends and event to a IEEE1588 port. It includes timestamp.
buf | [in] Pointer to the data buffer |
len | Size of the message |
mcast_type | Enumeration MulticastType (pdlay, none or other). Depracated. |
destIdentity | Destination port identity |
void IEEE1588Port::sendGeneralPort | ( | uint8_t * | buf, |
int | len, | ||
MulticastType | mcast_type, | ||
PortIdentity * | destIdentity | ||
) |
Sends a general message to a port. No timestamps.
buf | [in] Pointer to the data buffer |
len | Size of the message |
mcast_type | Enumeration MulticastType (pdelay, none or other). Depracated. |
destIdentity | Destination port identity |
bool IEEE1588Port::serializeState | ( | void * | buf, |
long * | count | ||
) |
Serializes (i.e. copy over buf pointer) the information from the variables (in that order):
buf | [out] Buffer where to put the results. |
count | [inout] Length of buffer. It contains maximum length to be written when the function is called, and the value is decremented by the same amount the buf size increases. |
|
inline |
Sets asCapable flag.
ascap | flag to be set. If FALSE, marks peer_offset_init as false. |
|
inline |
Sets the last_pdelay_req message.
msg | [in] PTPMessagePathDelayReq message to set |
|
inline |
|
inline |
Sets the last PTPMessagePathDelayRespFollowUp message.
msg | [in] last pdelay response follow up |
|
inline |
Sets last sync ptp message.
msg | [in] PTP sync message |
|
inline |
Sets link delay information. Signed value allows this to be negative result because of inaccurate timestamps.
delay | Link delay |
void IEEE1588Port::setParentLastSyncSequenceNumber | ( | uint16_t | num | ) |
Sets last sync sequence number from parent.
num | Sequence number |
Sets peer offset timestamps.
mine | Local timestamps |
theirs | Remote timestamps |
|
inline |
Sets the peer rate offset. Used to calculate neighbor rate ratio.
offset | Offset to be set |
|
inline |
Sets the PortState.
state | value to be set |
void IEEE1588Port::startAnnounce | ( | ) |
Starts announce event timer.
void IEEE1588Port::startPDelay | ( | ) |
Starts pDelay event timer.
|
inline |
Starts pDelay event timer if not yet started.
|
inline |
Do a trylock on the PDelay RX.