Commit 654fcea2 authored by Adam Wujek's avatar Adam Wujek 💬 Committed by Grzegorz Daniluk

ppsi update to support locks on ppsi's shmem

ppsi for wrs requres locks in shmem when shmem is changing. Since servo is
shared between wrs and wrpc fixes had to be implemented.
Since there is no shmem in wrpc, dummy function for locking had to be added.
As a side effect include/libwr/shmem.h was added.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 650a1933
/*
* This is the shared memory interface for multi-process cooperation
* within the whiterabbit switch. Everyone exports status information.
*/
#ifndef __WRS_SHM_H__
#define __WRS_SHM_H__
#include <stdint.h>
#define WRS_SHM_FILE "/dev/shm/wrs-shmem-%i"
#define WRS_SHM_MIN_SIZE (4*1024)
#define WRS_SHM_MAX_SIZE (256*1024)
/* Each process "name" (i.e. id) is added to the filename above */
enum wrs_shm_name {
wrs_shm_ptp,
wrs_shm_rtu,
wrs_shm_hal,
wrs_shm_vlan,
WRS_SHM_N_NAMES, /* must be last */
};
/* Each area starts with this process identifier */
struct wrs_shm_head {
void *mapbase; /* In writer's addr space (to track ptrs) */
char name[7 * sizeof(void *)];
unsigned long stamp; /* Last modified, w/ CLOCK_MONOTONIC */
unsigned long data_off; /* Where the structure lives */
int fd; /* So we can enlarge it using fd */
int pid; /* The current pid owning the area */
unsigned pidsequence; /* Each new pid must increments this */
unsigned sequence; /* If we need consistency, this is it */
unsigned version; /* Version of the data structure */
unsigned data_size; /* Size of it (for binary dumps) */
};
/* flags */
#define WRS_SHM_READ 0x0000
#define WRS_SHM_WRITE 0x0001
#define WRS_SHM_LOCKED 0x0002 /* at init time: writers locks, readers wait */
/* get vs. put, like in the kernel. Errors are in errno (see source) */
void *wrs_shm_get(enum wrs_shm_name name_id, char *name, unsigned long flags);
int wrs_shm_put(void *headptr);
/* The writer can allocate structures that live in the area itself */
void *wrs_shm_alloc(void *headptr, size_t size);
/* The reader can track writer's pointers, if they are in the area */
void *wrs_shm_follow(void *headptr, void *ptr);
/* Before and after writing a chunk of data, act on sequence and stamp */
#define WRS_SHM_WRITE_BEGIN 1
#define WRS_SHM_WRITE_END 0
extern void wrs_shm_write(void *headptr, int flags);
/* A reader can rely on the sequence number (in the <linux/seqlock.h> way) */
extern unsigned wrs_shm_seqbegin(void *headptr);
extern int wrs_shm_seqretry(void *headptr, unsigned start);
/* A reader can check wether information is current enough */
extern int wrs_shm_age(void *headptr);
/* A reader can get the information pointer, for a specific version, or NULL */
extern void *wrs_shm_data(void *headptr, unsigned version);
#endif /* __WRS_SHM_H__ */
#include <stdint.h>
#include <libwr/hal_shmem.h>
#include <libwr/shmem.h>
#include <wrc_ptp.h>
#include <syscon.h>
#include <endpoint.h>
#include <softpll_ng.h>
#include <ptpd_netif.h>
struct wrs_shm_head *ppsi_head;
/* Following code from ptp-noposix/libposix/freestanding-wrapper.c */
uint64_t ptpd_netif_get_msec_tics(void)
......@@ -69,3 +72,9 @@ int ptpd_netif_get_dmtd_phase(wr_socket_t *sock, int32_t *phase)
return spll_read_ptracker(0, phase, NULL);
return 0;
}
/* dummy function, no shmem locks (no even shmem) are implemented in wrpc */
void wrs_shm_write(void *headptr, int flags)
{
return;
}
ppsi @ 14583c20
Subproject commit 2181324ae355f72299abc63b5fa8c9e1fcc742b1
Subproject commit 14583c205cf103fd917076712cc89faec00c0b4e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment