34 #ifndef LINUX_HAL_COMMON_HPP
35 #define LINUX_HAL_COMMON_HPP
50 #define ONE_WAY_PHY_DELAY 400
51 #define P8021AS_MULTICAST "\x01\x80\xC2\x00\x00\x0E"
52 #define PTP_DEVICE "/dev/ptpXX"
53 #define PTP_DEVICE_IDX_OFFS 8
55 #define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD)
65 struct TicketingLockPrivate;
89 bool lock(
bool *got = NULL );
118 uint8_t cond_ticket_issue;
119 uint8_t cond_ticket_serving;
225 struct LinuxLockPrivate;
299 struct LinuxConditionPrivate;
368 struct LinuxTimerQueueActionArg;
382 struct LinuxTimerQueuePrivate;
400 void LinuxTimerQueueAction( LinuxTimerQueueActionArg *arg );
467 virtual unsigned long sleep(
unsigned long micros);
505 struct LinuxThreadPrivate;
582 int len = strnlen(group_name,16);
583 this->group_name =
new char[len+1];
584 strncpy( this->group_name, group_name, len+1 );
585 this->group_name[len] =
'\0';
596 #define DEFAULT_GROUPNAME "ptp"
601 class LinuxSharedMemoryIPC:public OS_IPC {
604 char *master_offset_buffer;
613 master_offset_buffer = NULL;
640 (int64_t ml_phoffset, int64_t ls_phoffset,
FrequencyRatio ml_freqoffset,
641 FrequencyRatio ls_freqoffset, uint64_t local_time, uint32_t sync_count,
642 uint32_t pdelay_count,
PortState port_state );
struct LinuxTimerQueuePrivate * LinuxTimerQueuePrivate_t
Definition: linux_hal_common.hpp:386
friend void * LinuxTimerQueueHandler(void *arg)
Linux timer queue handler. Deals with linux queues.
bool wait()
Waits until the ready signal condition is met and decrements the counter.
Definition: avbts_osnet.hpp:330
Definition: linux_hal_common.hpp:514
Definition: ieee1588.hpp:101
Definition: ieee1588.hpp:445
virtual OSTimerQueue * createOSTimerQueue(IEEE1588Clock *clock)
Creates Linux timer queue.
Definition: avbts_ostimer.hpp:62
bool init()
Initializes all flags and counters. Create private structures.
bool wait_prelock()
Counts up the amount of times we call the locking mechanism.
void * LinuxTimerQueueHandler(void *arg)
Linux timer queue handler. Deals with linux queues.
virtual bool join(OSThreadExitCode &exit_code)
Joins a new thread.
Definition: linux_hal_common.hpp:234
virtual OSTimer * createTimer()
Creates the linux timer.
Definition: linux_hal_common.hpp:484
Definition: avbts_ostimerq.hpp:49
LinuxSharedMemoryIPC()
Definition: linux_hal_common.hpp:610
virtual net_result nrecv(LinkLayerAddress *addr, uint8_t *payload, size_t &length)
Receives a packet from a remote address.
OSLockResult lock()
Provides a simple lock mechanism.
OSLock * createLock(OSLockType type)
Creates the locking mechanism.
Definition: linux_hal_common.hpp:289
bool addEvent(unsigned long micros, int type, ostimerq_handler func, event_descriptor_t *arg, bool rm, unsigned *event)
Add an event to the timer queue.
std::list< LinuxNetworkInterface * > LinuxNetworkInterfaceList
Definition: linux_hal_common.hpp:223
void disable_clear_rx_queue()
Disables rx socket descriptor and and clears the rx queue.
OSLockResult trylock()
Provides a simple trylock mechanism.
void * arg
Definition: linux_hal_common.hpp:494
LinuxTimerQueue()
Definition: linux_hal_common.hpp:405
Definition: avbts_clock.hpp:77
Definition: avbts_oscondition.hpp:106
Definition: ieee1588.hpp:93
Definition: linux_hal_common.hpp:478
Definition: linux_hal_common.hpp:573
Definition: linux_hal_common.hpp:601
Definition: linux_hal_common.hpp:492
struct LinuxConditionPrivate * LinuxConditionPrivate_t
Definition: linux_hal_common.hpp:303
virtual net_result send(LinkLayerAddress *addr, uint8_t *payload, size_t length, bool timestamp)
Sends a packet to a remote address.
LinuxLock()
Definition: linux_hal_common.hpp:243
virtual void getLinkLayerAddress(LinkLayerAddress *addr)
Gets the local link layer address.
Definition: linux_hal_common.hpp:198
void stop()
unmaps and unlink shared memory
virtual unsigned getPayloadOffset()
Gets the payload offset.
Definition: linux_hal_common.hpp:206
void(* ostimerq_handler)(void *)
Definition: avbts_ostimerq.hpp:42
virtual bool init()
Initializes internal variables.
OSLockType
Definition: avbts_oslock.hpp:44
PortState
Definition: ptptypes.hpp:48
struct TicketingLockPrivate * TicketingLockPrivate_t
Definition: linux_hal_common.hpp:70
bool unlock()
Unlock mechanism. Increments the release counter and unblock other threads waiting for a condition fl...
Definition: linux_hal_common.hpp:146
LinuxTimer()
Definition: linux_hal_common.hpp:472
virtual bool update(int64_t ml_phoffset, int64_t ls_phoffset, FrequencyRatio ml_freqoffset, FrequencyRatio ls_freqoffset, uint64_t local_time, uint32_t sync_count, uint32_t pdelay_count, PortState port_state)
Updates IPC values.
LinuxNetworkInterface()
Definition: linux_hal_common.hpp:217
OSThreadFunction func
Definition: linux_hal_common.hpp:493
Definition: avbts_ostimerq.hpp:91
Definition: avbts_osnet.hpp:52
virtual bool createInterface(OSNetworkInterface **net_iface, InterfaceLabel *label, HWTimestamper *timestamper)
Creates a new interface.
LinuxLockPrivate * LinuxLockPrivate_t
Definition: linux_hal_common.hpp:225
void reenable_rx_queue()
Enables the rx socket descriptor.
Definition: linux_hal_common.hpp:356
virtual unsigned long sleep(unsigned long micros)
Sleeps for a given amount of time in microsseconds.
Definition: avbts_oscondition.hpp:42
OSLockResult
Definition: avbts_oslock.hpp:52
bool cancelEvent(int type, unsigned *event)
Removes an event from the timer queue.
Definition: avbts_osnet.hpp:277
virtual bool start(OSThreadFunction function, void *arg)
Starts a new thread.
std::map< int, struct LinuxTimerQueueActionArg * > LinuxTimerQueueMap_t
Definition: linux_hal_common.hpp:368
Definition: linux_hal_common.hpp:391
void * OSThreadCallback(void *input)
OSThread callback.
Definition: linux_hal_common.hpp:308
virtual bool init(OS_IPC_ARG *barg=NULL)
Initializes shared memory with DEFAULT_GROUPNAME case arg is null.
Definition: avbts_ostimer.hpp:42
Definition: linux_hal_common.hpp:282
virtual ~LinuxIPCArg()
Definition: linux_hal_common.hpp:590
Definition: linux_hal_common.hpp:446
Definition: linux_hal_common.hpp:81
OSThreadExitCode
Definition: avbts_osthread.hpp:44
Definition: avbts_oslock.hpp:98
Definition: linux_hal_common.hpp:459
bool signal()
Unblock all threads that are busy waiting for a condition.
Definition: avbts_osthread.hpp:54
LinuxThreadPrivate * LinuxThreadPrivate_t
Definition: linux_hal_common.hpp:505
net_result
Definition: avbts_osnet.hpp:272
virtual bool post_init(int ifindex, int sd, TicketingLock *lock)=0
Provides a generic method for initializing timestamp interfaces.
OSLockResult unlock()
Provides a simple unlock mechanism.
Definition: linux_hal_common.hpp:126
Definition: avbts_oslock.hpp:57
OSThreadExitCode ret
Definition: linux_hal_common.hpp:495
bool initialize()
Initializes locks and mutex conditions.
Definition: avbts_osipc.hpp:46
OSCondition * createCondition()
Creates LinuxCondition objects.
Definition: linux_hal_common.hpp:362
long double FrequencyRatio
Definition: ptptypes.hpp:39
Definition: linux_hal_common.hpp:542
Timestamp tsToTimestamp(struct timespec *ts)
Converts timestamp in the struct timespec format to Timestamp.
OSThread * createThread()
Creates a new LinuxThread.
Definition: linux_hal_common.hpp:548
Definition: avbts_osthread.hpp:78
bool initialize(OSLockType type)
Initializes all mutexes and locks.
Definition: linux_hal_common.hpp:556
LinuxIPCArg(char *group_name)
Initializes IPCArg object.
Definition: linux_hal_common.hpp:581
bool lock(bool *got=NULL)
Lock mechanism. Gets a ticket and try locking the process.
virtual ~LinuxTimestamper()=0
Definition: ieee1588.hpp:222
OSThreadExitCode(* OSThreadFunction)(void *)
Definition: avbts_osthread.hpp:49