Commit 41bedca5 authored by Jean-Claude BAU's avatar Jean-Claude BAU Committed by Adam Wujek

Arch. changes for HA integration + bring into compliance with the

standard IEEE1588-2018

We bring here a lot of changes to :
- make the implementation more complaiant with the standard
IEEE1588-2018.
  We introduce new structures for the time (TimeInterval, Relative
difference)
  Named used in structures are aligned to the standard, ...
  It is just a first step. More work is needed
- be able to use more than one protocol extension at the same time
  (configurations, structures, ...)
- add the concept of profile
- increase diagnostics by displaying also standard PTP servo
informations
parent f290c38b
......@@ -116,7 +116,7 @@ config PROFILE_WR
config PROFILE_HA
bool
default y if ARCH_WRS || ARCH_WRPC
default n if ARCH_WRS || ARCH_WRPC
config PROFILE_PTP
bool
......@@ -134,14 +134,6 @@ config EXT_NONE
bool
default y if PROFILE_PTP
config EXTENSIONS
string
default "whiterabbit l1sync" if (EXT_WR && EXT_L1SYNC)
default "whiterabbit" if (EXT_WR && !EXT_L1SYNC)
default "l1sync" if (!EXT_WR && EXT_L1SYNC)
default "" if PROFILE_PTP
config CROSS_COMPILE
string "Cross compiler prefix"
default "/opt/gcc-lm32/bin/lm32-elf-" if ARCH_WRPC
......
......@@ -75,10 +75,11 @@ CFLAGS += -Iarch-$(ARCH)/include
# proto-standard is always included, as it provides default function
# so the extension can avoid duplication of code.
ifneq ($(PROTO_EXTS),)
PROT_EXT_DIRS=${foreach EXT_NAME,${subst $\",,${PROTO_EXTS}},proto-ext-${EXT_NAME} }
PROT_EXT_MKFS=${foreach PROT_EXT_MKF,${PROT_EXT_DIRS},${PROT_EXT_MKF}/Makefile}
include ${PROT_EXT_MKFS}
ifeq ($(CONFIG_EXT_WR),y)
include proto-ext-whiterabbit/Makefile
endif
ifeq ($(CONFIG_EXT_L1SYNC),y)
include proto-ext-l1sync/Makefile
endif
include proto-standard/Makefile
......
......@@ -68,7 +68,7 @@ int main(int argc, char **argv)
ppi = INST(ppg, i);
ppi->proto = PP_DEFAULT_PROTO;
ppi->role = PP_DEFAULT_ROLE;
ppi->mech = PP_E2E_MECH;
ppi->delayMechanism = E2E;
}
/* Set offset here, so config parsing can override it */
......@@ -94,7 +94,7 @@ int main(int argc, char **argv)
ppi->vlans_array_len = CONFIG_VLAN_ARRAY_SIZE,
ppi->iface_name = ppi->cfg.iface_name;
ppi->port_name = ppi->cfg.port_name;
ppi->mech = ppi->cfg.mech;
ppi->delayMechanism = ppi->cfg.delayMechanism;
ppi->ext_hooks= &pp_hooks;
/* The following default names depend on TIME= at build time */
......
......@@ -82,7 +82,7 @@ struct pp_instance ppi_static = {
.t_ops = &wrpc_time_ops,
.vlans_array_len = CONFIG_VLAN_ARRAY_SIZE,
.proto = PP_DEFAULT_PROTO,
.mech = PP_E2E_MECH, /* until changed by cfg */
.delayMechanism = E2E, /* until changed by cfg */
.iface_name = "wr1",
.port_name = "wr1",
.__tx_buffer = __tx_buffer,
......@@ -225,18 +225,18 @@ int wrc_ptp_sync_mech(int e2e_p2p_qry)
int running;
if (!CONFIG_HAS_P2P)
return ppi->mech;
return ppi->delayMechanism;
switch(e2e_p2p_qry) {
case PP_E2E_MECH:
case PP_P2P_MECH:
case E2E:
case P2P:
running = wrc_ptp_run(-1);
wrc_ptp_run(0);
ppi->mech = e2e_p2p_qry;
ppi->delayMechanism = e2e_p2p_qry;
wrc_ptp_run(running);
return 0;
default:
return ppi->mech;
return ppi->delayMechanism;
}
}
......
......@@ -19,7 +19,8 @@ OBJ-y += $A/wrs-startup.o \
lib/dump-funcs.o \
lib/drop.o \
lib/assert.o \
lib/div64.o
lib/div64.o \
lib/time-arith.o
# We only support "wrs" time operations
TIME = wrs
......
......@@ -2,8 +2,9 @@
#define __ARCH_H__
#include <ppsi/assert.h>
/* This arch exports wr functions, so include this for consistency checking */
/* This arch exports wr/l1e functions, so include this for consistency checking */
#include "../proto-ext-whiterabbit/wr-api.h"
#include "../proto-ext-l1sync/l1e-api.h"
/* Architecture-specific defines, included by top-level stuff */
......
......@@ -30,26 +30,6 @@ static inline struct hal_port_state *pp_wrs_lookup_port(char *name)
#define DEFAULT_TO 200000 /* ms */
/* FIXME return values, here copied from proto-ext-whiterabbit.
* I do not include proto-ext-whiterabbit/wr-constants.h in order not to
* have a dependency on ext when compiling wrs architecture. All the return
* values mechanism of wrs hw should be reviewed in this src and in the
* whole ppsi */
/* White Rabbit softpll status values */
#define WR_SPLL_OK 0
#define WR_SPLL_READY 1
#define WR_SPLL_CALIB_NOT_READY 2
#define WR_SPLL_ERROR -1
/* White Rabbit calibration defines */
#define WR_HW_CALIB_TX 1
#define WR_HW_CALIB_RX 2
#define WR_HW_CALIB_OK 0
#define WR_HW_CALIB_READY 1
#define WR_HW_CALIB_ERROR -1
#define WR_HW_CALIB_NOT_FOUND -3
#define POSIX_ARCH(ppg) ((struct unix_arch_data *)(ppg->arch_data))
struct unix_arch_data {
struct timeval tv;
......
......@@ -24,10 +24,10 @@ int wrs_read_calibration_data(struct pp_instance *ppi,
p = pp_wrs_lookup_port(ppi->iface_name);
if (!p)
return WR_HW_CALIB_NOT_FOUND;
return WRH_HW_CALIB_NOT_FOUND;
if(!p->calib.tx_calibrated || !p->calib.rx_calibrated)
return WR_HW_CALIB_NOT_FOUND;
return WRH_HW_CALIB_NOT_FOUND;
/*
* Like in wrs_net_init, we build fields that were in
......@@ -54,7 +54,7 @@ int wrs_read_calibration_data(struct pp_instance *ppi,
*fix_alpha = port_fix_alpha;
if(clock_period)
*clock_period = 16000; /* REF_CLOCK_PERIOD_PS */
return WR_HW_CALIB_OK;
return WRH_HW_CALIB_OK;
}
int wrs_calibrating_disable(struct pp_instance *ppi, int txrx)
......@@ -73,9 +73,9 @@ int wrs_calibrating_poll(struct pp_instance *ppi, int txrx, uint32_t *delta)
wrs_read_calibration_data(ppi, &delta_tx, &delta_rx, NULL, NULL);
*delta = (txrx == WR_HW_CALIB_TX) ? delta_tx : delta_rx;
*delta = (txrx == WRH_HW_CALIB_TX) ? delta_tx : delta_rx;
return WR_HW_CALIB_READY;
return WRH_HW_CALIB_READY;
}
int wrs_calibration_pattern_enable(struct pp_instance *ppi,
......@@ -83,10 +83,10 @@ int wrs_calibration_pattern_enable(struct pp_instance *ppi,
unsigned int calib_pattern,
unsigned int calib_pattern_len)
{
return WR_HW_CALIB_OK;
return WRH_HW_CALIB_OK;
}
int wrs_calibration_pattern_disable(struct pp_instance *ppi)
{
return WR_HW_CALIB_OK;
return WRH_HW_CALIB_OK;
}
......@@ -12,7 +12,8 @@
/* minipc Encoding of the supported commands */
#define PTPDEXP_COMMAND_TRACKING 1
#define PTPDEXP_COMMAND_WR_TRACKING 1
#define PTPDEXP_COMMAND_L1SYNC_TRACKING 2
static struct minipc_pd __rpcdef_cmd = {
.name = "cmd",
......@@ -27,9 +28,17 @@ static struct minipc_pd __rpcdef_cmd = {
/* Execute command coming ipc */
static int wrsipc_cmd(int cmd, int value)
{
if(cmd == PTPDEXP_COMMAND_TRACKING) {
if(cmd == PTPDEXP_COMMAND_WR_TRACKING) {
#if CONFIG_EXT_WR == 1
wr_servo_enable_tracking(value);
return 0;
#endif
}
if(cmd == PTPDEXP_COMMAND_L1SYNC_TRACKING) {
#if CONFIG_EXT_L1SYNC == 1
l1e_servo_enable_tracking(value);
return 0;
#endif
}
return -1;
......
......@@ -28,12 +28,8 @@
#include <ppsi-wrs.h>
#include <libwr/shmem.h>
#if CONFIG_EXT_WR == 1
/* WR extension declaration */
#include "../proto-ext-whiterabbit/wr-api.h"
#include "../proto-ext-whiterabbit/wr-constants.h"
#endif
#include "../proto-ext-l1sync/l1e-api.h"
# define WRSW_HAL_RETRIES 1000
......@@ -179,8 +175,7 @@ int main(int argc, char **argv)
ppg->defaultDS = alloc_fn(ppsi_head, sizeof(*ppg->defaultDS));
ppg->currentDS = alloc_fn(ppsi_head, sizeof(*ppg->currentDS));
ppg->parentDS = alloc_fn(ppsi_head, sizeof(*ppg->parentDS));
ppg->timePropertiesDS = alloc_fn(ppsi_head,
sizeof(*ppg->timePropertiesDS));
ppg->timePropertiesDS = alloc_fn(ppsi_head,sizeof(*ppg->timePropertiesDS));
ppg->servo = alloc_fn(ppsi_head, sizeof(*ppg->servo));
ppg->rt_opts = &__pp_default_rt_opts;
......@@ -234,13 +229,13 @@ int main(int argc, char **argv)
ppi->vlans_array_len = CONFIG_VLAN_ARRAY_SIZE;
ppi->iface_name = ppi->cfg.iface_name;
ppi->port_name = ppi->cfg.port_name;
ppi->mech = ppi->cfg.mech;
ppi->delayMechanism = ppi->cfg.delayMechanism;
ppi->portDS = alloc_fn(ppsi_head, sizeof(*ppi->portDS));
ppi->ext_hooks=&pp_hooks; /* Default value. Can be overwritten by an extension */
if (ppi->portDS) {
if ( CONFIG_EXT_WR == 1 && ppi->cfg.ext==PPSI_PROFILE_WR ) {
struct wr_data *wdata;
#if CONFIG_EXT_WR == 1
if ( ppi->cfg.profile==PPSI_PROFILE_WR ) {
ppi->protocol_extension=PPSI_EXT_WR;
/* Add WR extension portDS */
if ( !(ppi->portDS->ext_dsport =
alloc_fn(ppsi_head, sizeof(struct wr_dsport))) ) {
......@@ -248,14 +243,33 @@ int main(int argc, char **argv)
}
/* Allocate WR data extension */
if (! (wdata=ppi->ext_data = alloc_fn(ppsi_head,sizeof(struct wr_data))) ) {
if (! (ppi->ext_data = alloc_fn(ppsi_head,sizeof(struct wr_data))) ) {
goto exit_out_of_memory;
}
wdata->servo_state.servo_head.extension=PPSI_EXT_WR;
/* Set WR extension hooks */
ppi->ext_hooks=&wr_ext_hooks;
ppg->global_ext_data=wdata;
}
#endif
#if CONFIG_EXT_L1SYNC == 1
if ( ppi->cfg.profile==PPSI_PROFILE_HA ) {
ppi->protocol_extension=PPSI_EXT_L1S;
/* Add L1E extension portDS */
if ( !(ppi->portDS->ext_dsport =alloc_fn(ppsi_head, sizeof(struct l1e_ext_portDS))) ) {
goto exit_out_of_memory;
}
/* Allocate WR data extension */
if (! (ppi->ext_data = alloc_fn(ppsi_head,sizeof(struct l1e_data))) ) {
goto exit_out_of_memory;
}
/* Set L1SYNC extension hooks */
ppi->ext_hooks=&l1e_ext_hooks;
/* Set default profile parameters */
ppg->defaultDS->externalPortConfigurationEnabled = 1;
ppi->portDS->masterOnly = 0;
}
#endif
} else {
goto exit_out_of_memory;
}
......
......@@ -12,15 +12,53 @@
#include <stdint.h>
#include <ppsi/lib.h>
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data structure */
#define WRS_PPSI_SHMEM_VERSION 31 /* changed wrs_shm_head */
/* White Rabbit softpll status values */
#define WRH_SPLL_OK 0
#define WRH_SPLL_READY 1
#define WRH_SPLL_CALIB_NOT_READY 2
#define WRH_SPLL_ERROR -1
/* White Rabbit calibration defines */
#define WRH_HW_CALIB_TX 1
#define WRH_HW_CALIB_RX 2
#define WRH_HW_CALIB_OK 0
#define WRH_HW_CALIB_READY 1
#define WRH_HW_CALIB_ERROR -1
#define WRH_HW_CALIB_NOT_FOUND -3
enum {
WRH_SERVO_ENTER, WRH_SERVO_LEAVE
};
struct wrh_servo_head {
int extension; /* Used to identify the servo extension. Useful for the monitoring tool */
};
#define FIX_ALPHA_FRACBITS 40
#define FIX_ALPHA_FRACBITS_AS_FLOAT 40.0
#define WRH_SERVO_OFFSET_STABILITY_THRESHOLD 60 /* psec */
#ifdef CONFIG_WRPC_FAULTS
#define PROTO_EXT_HAS_FAULTS 1
#else
#define PROTO_EXT_HAS_FAULTS 0
#endif
/* Contains portDS common stuff which is manipulated outside of the protocol extension code */
/* Must be declared on top of the extension portDS structure */
typedef struct {
Boolean extModeOn;
Boolean ppsOutputOn;
} wrh_portds_head_t;
/* The head is expected at the beginning of the portDS structure */
static inline wrh_portds_head_t *WRH_DSPOR_HEAD(struct pp_instance *ppi)
{
return (wrh_portds_head_t *) ppi->portDS->ext_dsport;
}
/* White Rabbit hw-dependent functions (code in arch-wrpc and arch-wrs) */
struct wrh_operations {
......@@ -46,7 +84,7 @@ struct wrh_operations {
unsigned int calibrationPatternLen);
int (*calib_pattern_disable)(struct pp_instance *ppi);
int (*enable_timing_output)(struct pp_instance *ppi, int enable);
int (*servo_hook)(struct wrh_servo_head *s, int action);
int (*servo_hook)(struct pp_instance *ppi, int action);
int (*read_corr_data)(struct pp_instance *ppi, int64_t *delayCoeff,
int64_t *ingressLatency, int64_t *egressLatency,
int64_t *msgTPointLatency, int64_t *delayAsymmetry,
......
......@@ -21,9 +21,11 @@ typedef uint8_t Octet;
typedef int8_t Integer8;
typedef int16_t Integer16;
typedef int32_t Integer32;
typedef int64_t Integer64;
typedef uint8_t UInteger8;
typedef uint16_t UInteger16;
typedef uint32_t UInteger32;
typedef uint64_t UInteger64;
/* Enumerations are unsigned, see 5.4.2, page 15 */
typedef uint16_t Enumeration16;
typedef uint8_t Enumeration8;
......@@ -38,23 +40,25 @@ typedef struct UInteger48 {
uint16_t msb;
} UInteger48;
typedef struct Integer64 {
typedef struct _Integer64 { /* TODO : Should be replaced by Integer64 */
uint32_t lsb;
int32_t msb;
} Integer64;
} _Integer64;
typedef struct UInteger64 {
typedef struct _UInteger64 { /*/* TODO : Should be replaced by UInteger64 */
uint32_t lsb;
uint32_t msb;
} UInteger64;
} _UInteger64;
struct TimeInterval { /* page 12 (32) -- never used */
Integer64 scaledNanoseconds;
};
/* Page 19 :the time interval is expressed in units of nanoseconds and multiplied by 2 +16 */
#define TIME_INTERVAL_FRACBITS 16
#define TIME_INTERVAL_FRACBITS_AS_FLOAT 16.0
typedef Integer64 TimeInterval;
/* White Rabbit extension */
typedef struct FixedDelta {
UInteger64 scaledPicoseconds;
_UInteger64 scaledPicoseconds;
} FixedDelta;
typedef struct Timestamp { /* page 13 (33) -- no typedef expected */
......@@ -62,6 +66,17 @@ typedef struct Timestamp { /* page 13 (33) -- no typedef expected */
UInteger32 nanosecondsField;
} Timestamp;
/** ******************* IEEE1588-2018 **************************************/
#define REL_DIFF_FRACBITS 62
#define REL_DIFF_FRACBITS_AS_FLOAT 62.0
/*draft P1588_v_29: page 17*/
/* The scaledRelativeDifference member is the relative difference expressed
* as a dimensionless fraction and multiplied by 2+^62, with any remaining
* fractional part truncated. */
typedef Integer64 RelativeDifference;
typedef struct ClockIdentity { /* page 13 (33) */
Octet id[8];
} ClockIdentity;
......@@ -179,7 +194,7 @@ typedef struct MsgSignaling {
} MsgSignaling;
/* Management Message (table 37, page 137) */
typedef struct MsgManagement{
typedef struct {
PortIdentity targetPortIdentity;
UInteger8 startingBoundaryHops;
UInteger8 boundaryHops;
......@@ -188,7 +203,7 @@ typedef struct MsgManagement{
} MsgManagement;
/* Default Data Set */
typedef struct DSDefault { /* page 65 */
typedef struct { /* page 65 */
/* Static */
Boolean twoStepFlag;
ClockIdentity clockIdentity;
......@@ -200,21 +215,29 @@ typedef struct DSDefault { /* page 65 */
UInteger8 priority2;
UInteger8 domainNumber;
Boolean slaveOnly;
} DSDefault;
/** Optional (IEEE1588-2018) */
Timestamp currentTime; /*draft P1588_v_29: page 85*/
Boolean instanceEnable; /*draft P1588_v_29: page 86*/
Enumeration8 externalPortConfigurationEnabled; /*draft P1588_v_29: page 86*/
Enumeration8 maxStepsRemoved; /*draft P1588_v_29: page 86 (bug)*/
Enumeration8 SdoId; /*draft P1588_v_29: page 86 (bug)*/
Enumeration8 instanceType; /*draft P1588_v_29: page 86 */
/** *********************** */
} defaultDS_t;
/* Current Data Set */
typedef struct DSCurrent { /* page 67 */
typedef struct { /* page 67 */
/* Dynamic */
UInteger16 stepsRemoved;
struct pp_time offsetFromMaster;
struct pp_time meanPathDelay; /* oneWayDelay */
TimeInterval offsetFromMaster; /* page 112 */
TimeInterval meanDelay; /* page 112 : one Way Delay */
/* White Rabbit extension begin */
UInteger16 primarySlavePortNumber;
/* White Rabbit extension end */
} DSCurrent;
} currentDS_t;
/* Parent Data Set */
typedef struct DSParent { /* page 68 */
typedef struct { /* page 68 */
/* Dynamic */
PortIdentity parentPortIdentity;
/* Boolean parentStats; -- not used */
......@@ -224,10 +247,10 @@ typedef struct DSParent { /* page 68 */
ClockQuality grandmasterClockQuality;
UInteger8 grandmasterPriority1;
UInteger8 grandmasterPriority2;
} DSParent;
} parentDS_t;
/* Port Data set */
typedef struct DSPort { /* page 72 */
typedef struct { /* page 72 */
/* Static */
PortIdentity portIdentity;
/* Dynamic */
......@@ -241,10 +264,18 @@ typedef struct DSPort { /* page 72 */
UInteger4 versionNumber;
void *ext_dsport;
} DSPort;
/** (IEEE1588-2018) */
Integer8 logMinPdelayReqInterval; /*draft P1588_v_29: page 124 */
UInteger4 minorVersionNumber; /*draft P1588_v_29: page 124 */
TimeInterval delayAsymmetry; /*draft P1588_v_29: page 124 */
/** Optional: */
Boolean portEnable; /*draft P1588_v_29: page 124 */
Boolean masterOnly; /*draft P1588_v_29: page 124 */
/** *********************** */
} portDS_t;
/* Time Properties Data Set */
typedef struct DSTimeProperties { /* page 70 */
typedef struct { /* page 70 */
/* Dynamic */
Integer16 currentUtcOffset;
Boolean currentUtcOffsetValid;
......@@ -254,8 +285,54 @@ typedef struct DSTimeProperties { /* page 70 */
Boolean frequencyTraceable;
Boolean ptpTimescale;
Enumeration8 timeSource;
} DSTimeProperties;
} timePropertiesDS_t;
/** ******************* IEEE1588-2018 **************************************
* Adding new optional data sets (DS) defined in clause, only these relevant
* for HA
*/
typedef struct { /*draft P1588_v_29: page 118 */
Octet manufacturerIdentity[3];
struct PTPText productDescription;
struct PTPText productRevision;
struct PTPText userDescription;
} descriptionDS_t;
/* Optional, not implemented, Instance DS:
* faultLogDS: draft P1588_v_29: page 93
* nonvolatileStorageDS draft P1588_v_29: page 94
* pathTraceDS draft P1588_v_29: page 95
* alternateTimescaleOffsetsDS draft P1588_v_29: page 95
* holdoverUpgradeDS draft P1588_v_29: page 95
* grandmasterClusterDS draft P1588_v_29: page 95
* acceptableMasterTableDS draft P1588_v_29: page 95
* clockPerformanceMonitoringDS draft P1588_v_29: page 95
*
* Optional, not implemented, port DS
* descriptionPortDS draft P1588_v_29: page 99
* unicastNegotiationDS draft P1588_v_29: page 100
* alternateMasterDS draft P1588_v_29: page 100
* unicastDiscoveryDS draft P1588_v_29: page 100
* acceptableMasterPortDS draft P1588_v_29: page 100
* performanceMonitoringPortDS draft P1588_v_29: page 101
*
* For Transparent Clocks, not implemented
* transparentClockDefaultDS draft P1588_v_29: page 102
* transparentClockPortDS draft P1588_v_29: page 103
*/
typedef struct { /*draft P1588_v_29: page 128*/
TimeInterval egressLatency;
TimeInterval ingressLatency;
TimeInterval messageTimestampPointLatency;
/* Not in specification */
TimeInterval semistaticLatency;
} timestampCorrectionPortDS_t;
typedef struct { /*draft P1588_v_29: page129*/
TimeInterval constantAsymmetry;
RelativeDifference scaledDelayCoefficient;
} asymmetryCorrectionPortDS_t;
/** ************************************************************************/
/* Enumeration States (table 8, page 73) */
enum pp_std_states {
PPS_END_OF_TABLE = 0,
......@@ -286,6 +363,7 @@ enum pp_std_messages {
/* NO_MESSAGE means "no message received", or "eaten by hook" */
PPM_NO_MESSAGE,
PPM_NOTHING_TO_DO = 0x100, /* for hooks.master_msg() */
};
/* Enumeration Domain Number (table 2, page 41) */
......@@ -318,11 +396,13 @@ enum ENTimeSource {
INTERNAL_OSCILLATOR = 0xA0
};
/* Enumeration Delay mechanism (table 9, page 74) */
/* Enumeration Delay mechanism (table 21, page 126) */
enum ENDelayMechanism {
E2E = 1,
P2P = 2,
DELAY_DISABLED = 0xFE
E2E = 1,
P2P = 2,
COMMON_P2P = 3,
SPECIAL = 4,
NO_MECHANISM = 0xFE
};
#endif /* __PPSI_IEEE_1588_TYPES_H__ */
......@@ -20,11 +20,11 @@ struct pp_runtime_opts {
int flags; /* see below */
Integer16 ap, ai;
Integer16 s;
Integer8 announce_intvl;
int sync_intvl;
int prio1;
int prio2;
int domain_number;
Integer8 logAnnounceInterval;
int logSyncInterval;
int priority1;
int priority2;
int domainNumber;
void *arch_opts;
};
......@@ -89,7 +89,7 @@ struct pp_frgn_master {
* machine are implemented.
*
* pp_avg_fltr: It is a variable cutoff/delay low-pass, infinite impulse
* response (IIR) filter. The meanPathDelay filter has the difference equation:
* response (IIR) filter. The meanDelay filter has the difference equation:
* s*y[n] - (s-1)*y[n-1] = x[n]/2 + x[n-1]/2,
* where increasing the stiffness (s) lowers the cutoff and increases the delay.
*/
......@@ -99,11 +99,24 @@ struct pp_avg_fltr {
int64_t s_exp;
};
/* Servo flags for communication diagnostic tool */
#define PP_SERVO_FLAG_VALID (1<<0)
#define PP_SERVO_FLAG_WAIT_HW (1<<1)
struct pp_servo {
struct pp_time m_to_s_dly;
struct pp_time s_to_m_dly;
struct pp_time delayMS;
struct pp_time delaySM;
long long obs_drift;
struct pp_avg_fltr mpd_fltr;
struct pp_time meanDelay;
struct pp_time offsetFromMaster;
/* diagnostic data */
unsigned long flags; /* PP_SERVO_FLAG_INVALID, PP_SERVO_FLAG_VALID, ...*/
uint32_t update_count; /* incremented each time the servo is running */
char servo_state_name[32]; /* Updated by the servo itself */
int servo_locked; /* TRUE when servo is locked. This info can be used by HAL */
};
enum { /* The two sockets. They are called "net path" for historical reasons */
......@@ -119,8 +132,8 @@ enum { /* The two sockets. They are called "net path" for historical reasons */
struct pp_instance_cfg {
char port_name[16];
char iface_name[16];
int ext; /* 0: none, 1: whiterabbit. 2: HA */
int mech; /* 0: E2E, 1: P2P */
int profile; /* PPSI_PROFILE_PTP, PPSI_PROFILE_WR, PPSI_PROFILE_HA */
int delayMechanism; /* Should be enum ENDelayMechanism but forced to int for configuration parsing */
};
/*
......@@ -132,12 +145,13 @@ struct pp_instance {
struct pp_state_table_item *current_state_item;
void *arch_data; /* if arch needs it */
void *ext_data; /* if protocol ext needs it */
int protocol_extension; /* PPSI_EXT_NONE, PPSI_EXT_WR, PPSI_EXT_L1S */
struct pp_ext_hooks *ext_hooks; /* if protocol ext needs it */
unsigned long d_flags; /* diagnostics, ppi-specific flags */
unsigned char flags; /* protocol flags (see below) */
int role, /* same as in config file */
proto, /* same as in config file */
mech; /* same as in config file */
proto; /* same as in config file */
int delayMechanism; /* same as in config file */
/* Pointer to global instance owning this pp_instance*/
struct pp_globals *glbs;
......@@ -163,6 +177,7 @@ struct pp_instance {
/* Times, for the various offset computations */
struct pp_time t1, t2, t3, t4, t5, t6; /* *the* stamps */
Integer32 t4_cf, t6_cf;
uint64_t syncCF; /* transp. clocks */
struct pp_time last_rcv_time, last_snt_time; /* two temporaries */
......@@ -173,7 +188,13 @@ struct pp_instance {
Integer16 frgn_rec_best;
struct pp_frgn_master frgn_master[PP_NR_FOREIGN_RECORDS];
DSPort *portDS; /* page 72 */
portDS_t *portDS; /* page 72 */
/** (IEEE1588-2018) */
asymmetryCorrectionPortDS_t asymmetryCorrectionPortDS; /*draft P1588_v_29: page 99*/
timestampCorrectionPortDS_t timestampCorrectionPortDS; /*draft P1588_v_29: page 99*/
/** *********************** */
unsigned long timeouts[__PP_TO_ARRAY_SIZE];
UInteger16 recv_sync_sequence_id;
......@@ -215,10 +236,10 @@ struct pp_globals {
struct pp_runtime_opts *rt_opts;
/* Data sets */
DSDefault *defaultDS; /* page 65 */
DSCurrent *currentDS; /* page 67 */
DSParent *parentDS; /* page 68 */
DSTimeProperties *timePropertiesDS; /* page 70 */
defaultDS_t *defaultDS; /* page 65 */
currentDS_t *currentDS; /* page 67 */
parentDS_t *parentDS; /* page 68 */
timePropertiesDS_t *timePropertiesDS; /* page 70 */
/* Index of the pp_instance receiving the "Ebest" clock */
int ebest_idx;
......
......@@ -118,32 +118,32 @@ static inline struct pp_runtime_opts *OPTS(struct pp_instance *ppi)
return GOPTS(GLBS(ppi));
}
static inline struct DSDefault *GDSDEF(struct pp_globals *ppg)
static inline defaultDS_t *GDSDEF(struct pp_globals *ppg)
{
return ppg->defaultDS;
}
static inline struct DSDefault *DSDEF(struct pp_instance *ppi)
static inline defaultDS_t *DSDEF(struct pp_instance *ppi)
{
return GDSDEF(GLBS(ppi));
}
static inline struct DSCurrent *DSCUR(struct pp_instance *ppi)
static inline currentDS_t *DSCUR(struct pp_instance *ppi)
{
return GLBS(ppi)->currentDS;
}
static inline struct DSParen