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

High Accuracy - Second implementation

This implementation does not include yet the possibility to declare 2
exclusive instances on a same port (WR & HA)
- Some structures are renamed with the suffix _t to make it more
readable.
- Some variables are renamed  to be more clear
- Implementation of masterOnly, slaveOnly and externalPortConfiguration
- All extension specific includes (XX-api.h) is now automatically
included in ppsi.h and do not need to be included in other files.
parent e0b61c86
......@@ -88,10 +88,10 @@ struct sim_ppi_arch_data {
/* Runtime options */
struct pp_runtime_opts *rt_opts;
/* Data sets */
DSDefault *defaultDS;
DSCurrent *currentDS;
DSParent *parentDS;
DSTimeProperties *timePropertiesDS;
defaultDS_t *defaultDS;
currentDS_t *currentDS;
[parentDS_t *parentDS;
timePropertiesDS_t *timePropertiesDS;
/* other pp_instance, used in net ops */
struct pp_instance *other_ppi;
};
......
......@@ -20,11 +20,11 @@ static struct pp_runtime_opts sim_master_rt_opts = {
.ap = PP_DEFAULT_AP,
.ai = PP_DEFAULT_AI,
.s = PP_DEFAULT_DELAY_S,
.announce_intvl = PP_DEFAULT_ANNOUNCE_INTERVAL,
.sync_intvl = PP_DEFAULT_SYNC_INTERVAL,
.prio1 = PP_DEFAULT_PRIORITY1,
.prio2 = PP_DEFAULT_PRIORITY2,
.domain_number = PP_DEFAULT_DOMAIN_NUMBER,
.logAnnounceInterval = PP_DEFAULT_ANNOUNCE_INTERVAL,
.logSyncInterval = PP_DEFAULT_SYNC_INTERVAL,
.priority1 = PP_DEFAULT_PRIORITY1,
.priority2 = PP_DEFAULT_PRIORITY2,
.domainNumber = PP_DEFAULT_DOMAIN_NUMBER,
.ttl = PP_DEFAULT_TTL,
};
......@@ -142,7 +142,7 @@ int main(int argc, char **argv)
sim_set_global_DS(ppi);
ppi->iface_name = ppi->cfg.iface_name;
ppi->port_name = ppi->cfg.port_name;
ppi->mech = ppi->cfg.mech;
ppi->delayMechanism = ppi->cfg.delayMechanism;
if (ppi->proto == PPSI_PROTO_RAW)
pp_printf("Warning: simulator doesn't support raw "
"ethernet. Using UDP\n");
......
......@@ -25,10 +25,10 @@
/* ppg and fields */
static struct pp_globals ppg_static;
static DSDefault defaultDS;
static DSCurrent currentDS;
static DSParent parentDS;
static DSTimeProperties timePropertiesDS;
static defaultDS_t defaultDS;
static currentDS_t currentDS;
static [parentDS_t parentDS;
static timePropertiesDS_t timePropertiesDS;
static struct pp_servo servo;
extern struct pp_ext_hooks pp_hooks;
......
......@@ -24,7 +24,8 @@ OBJ-y += \
$A/wrc_ptp_ppsi.o \
lib/dump-funcs.o \
lib/drop.o \
lib/div64.o
lib/div64.o \
lib/time-arith.o
OBJ-$(CONFIG_WRPC_FAULTS) += $A/faults.o
......
......@@ -48,10 +48,10 @@ struct wrh_operations wrh_oper = {
};
/*ppi fields*/
static DSDefault defaultDS;
static DSCurrent currentDS;
static DSParent parentDS;
static DSTimeProperties timePropertiesDS;
static defaultDS_t defaultDS;
static currentDS_t currentDS;
static [parentDS_t parentDS;
static timePropertiesDS_t timePropertiesDS;
static struct pp_servo servo;
......@@ -65,7 +65,7 @@ static struct wr_data wr_ext_data; /* WR extension data */
static struct wr_dsport wr_dsport;
#endif
static DSPort portDS ;
static portDS_t portDS ;
static int delay_ms = PP_DEFAULT_NEXT_DELAY_MS;
static int start_tics = 0;
......@@ -117,7 +117,6 @@ int wrc_ptp_init()
ppi->ext_hooks = &wr_ext_hooks;
ppi->ext_data = &wr_ext_data;
wr_ext_data->servo_state.servo_head.extension=PPSI_EXT_WR;
GBLS(ppi)->global_ext_data=&wr_ext_data.servo_state; /* Updated for the WR monitor tools */
portDS.ext_dsport = &wr_dsport;
}
......
......@@ -73,7 +73,7 @@ int wrpc_calibrating_poll(struct pp_instance *ppi, int txrx, uint32_t *delta)
/* FIXME: why delta was 64bit whereas ep_get_deltas accepts 32bit? */
wrpc_read_calibration_data(ppi, &delta_tx, &delta_rx, NULL, NULL);
if (txrx == WR_HW_CALIB_TX)
if (txrx == WRH_HW_CALIB_TX)
*delta = delta_tx;
else
*delta = delta_rx;
......
......@@ -11,6 +11,8 @@
#include <softpll_ng.h>
#include "../proto-ext-whiterabbit/wr-constants.h"
#include <rxts_calibrator.h>
#include "../include/hw-specific/wrh.h"
#include "wrpc.h"
extern uint32_t cal_phase_transition;
......@@ -20,7 +22,7 @@ int wrpc_spll_locking_enable(struct pp_instance *ppi)
spll_init(SPLL_MODE_SLAVE, 0, 1);
spll_enable_ptracker(0, 1);
rxts_calibration_start();
return WR_SPLL_OK;
return WRH_SPLL_OK;
}
int wrpc_spll_locking_poll(struct pp_instance *ppi, int grandmaster)
......@@ -31,7 +33,7 @@ int wrpc_spll_locking_poll(struct pp_instance *ppi, int grandmaster)
locked = spll_check_lock(0); /* both slave and gm mode */
if (grandmaster)
return locked ? WR_SPLL_READY : WR_SPLL_ERROR;
return locked ? WRH_SPLL_READY : WRH_SPLL_ERROR;
/* Else, slave: ensure calibration is done */
if(!locked) {
......@@ -40,30 +42,30 @@ int wrpc_spll_locking_poll(struct pp_instance *ppi, int grandmaster)
else if(locked && !t24p_calibrated) {
/*run t24p calibration if needed*/
if (calib_t24p(WRC_MODE_SLAVE, &cal_phase_transition) < 0)
return WR_SPLL_CALIB_NOT_READY;
return WRH_SPLL_CALIB_NOT_READY;
t24p_calibrated = 1;
}
return locked ? WR_SPLL_READY : WR_SPLL_ERROR;
return locked ? WRH_SPLL_READY : WRH_SPLL_ERROR;
}
int wrpc_spll_locking_reset(struct pp_instance *ppi)
{
//TODO?
return WR_SPLL_OK;
return WRH_SPLL_OK;
}
int wrpc_spll_locking_disable(struct pp_instance *ppi)
{
/* softpll_disable(); */
return WR_SPLL_OK;
return WRH_SPLL_OK;
}
int wrpc_spll_enable_ptracker(struct pp_instance *ppi)
{
spll_enable_ptracker(0, 1);
return WR_SPLL_OK;
return WRH_SPLL_OK;
}
int wrpc_enable_timing_output(struct pp_instance *ppi, int enable)
......@@ -73,7 +75,7 @@ int wrpc_enable_timing_output(struct pp_instance *ppi, int enable)
WR_DSPOR(ppi)->ppsOutputOn = enable;
shw_pps_gen_enable_output(enable);
return WR_SPLL_OK;
return WRH_SPLL_OK;
}
int wrpc_adjust_in_progress(void)
......@@ -93,6 +95,6 @@ int wrpc_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec)
int wrpc_adjust_phase(int32_t phase_ps)
{
spll_set_phase_shift(SPLL_ALL_CHANNELS, phase_ps);
return WR_SPLL_OK;
return WRH_SPLL_OK;
}
......@@ -51,7 +51,7 @@ int wrpc_spll_enable_ptracker(struct pp_instance *ppi);
int wrpc_adjust_in_progress(void);
int wrpc_adjust_counters(int64_t adjust_sec, int32_t adjust_nsec);
int wrpc_adjust_phase(int32_t phase_ps);
int wrpc_enable_timing_output(struct pp_instance *ppi, int enable);
int wrpc_enable_timing_output(struct pp_instance *ppi, int *ppsOutputOn, int enable);
/* wrpc-calibration.c */
int wrpc_read_calibration_data(struct pp_instance *ppi,
......
......@@ -74,9 +74,6 @@ struct hal_port_state {
int fd;
int hw_addr_auto;
/* port timing mode (HEXP_PORT_MODE_xxxx) */
int mode;
/* port FSM state (HAL_PORT_STATE_xxxx) */
int state;
......
......@@ -13,6 +13,9 @@
#include <libwr/shmem.h>
#include <libwr/hal_shmem.h>
#define WRS_NUMBER_PHYSICAL_PORTS 18 /* Number of physical ports on a WR switch */
extern struct minipc_ch *hal_ch;
extern struct minipc_ch *ppsi_ch;
extern struct hal_port_state *hal_ports;
......
......@@ -16,7 +16,6 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#include <wr-api.h>
#include <hal_exports.h>
#include <common-fun.h>
......
......@@ -8,7 +8,6 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#include <hal_exports.h>
#include <wr-api.h>
/* minipc Encoding of the supported commands */
......
......@@ -28,9 +28,6 @@
#include <ppsi-wrs.h>
#include <libwr/shmem.h>
#include "../proto-ext-whiterabbit/wr-api.h"
#include "../proto-ext-l1sync/l1e-api.h"
# define WRSW_HAL_RETRIES 1000
#define WRSW_HAL_TIMEOUT 2000000 /* us */
......@@ -217,14 +214,14 @@ int main(int argc, char **argv)
char s[128];
int i;
for (i = 0; i < 18; i++) {
for (i = 0; i < WRS_NUMBER_PHYSICAL_PORTS; i++) {
Boolean configured=FALSE;
#if CONFIG_EXT_L1SYNC == 1
#if CONFIG_PROFILE_HA == 1
sprintf(s, "port %i; iface wri%i; proto raw;"
"profile ha; role auto", i + 1, i + 1);
configured=TRUE;
#endif
#if CONFIG_EXT_WR == 1
#if CONFIG_PROFILE_WR == 1
if ( ! configured )
sprintf(s, "port %i; iface wri%i; proto raw;"
"profile wr; role auto", i + 1, i + 1);
......@@ -243,9 +240,10 @@ int main(int argc, char **argv)
ppi->port_name = ppi->cfg.port_name;
ppi->delayMechanism = ppi->cfg.delayMechanism;
ppi->portDS = alloc_fn(ppsi_head, sizeof(*ppi->portDS));
ppi->servo = alloc_fn(ppsi_head, sizeof(*ppi->servo));
ppi->ext_hooks=&pp_hooks; /* Default value. Can be overwritten by an extension */
if (ppi->portDS) {
#if CONFIG_EXT_WR == 1
#if CONFIG_PROFILE_WR == 1
if ( ppi->cfg.profile==PPSI_PROFILE_WR ) {
ppi->protocol_extension=PPSI_EXT_WR;
/* Add WR extension portDS */
......@@ -262,7 +260,7 @@ int main(int argc, char **argv)
ppi->ext_hooks=&wr_ext_hooks;
}
#endif
#if CONFIG_EXT_L1SYNC == 1
#if CONFIG_PROFILE_HA == 1
if ( ppi->cfg.profile==PPSI_PROFILE_HA ) {
ppi->protocol_extension=PPSI_EXT_L1S;
/* Add L1E extension portDS */
......@@ -281,13 +279,20 @@ int main(int argc, char **argv)
ppi->asymmetryCorrectionPortDS.constantAsymmetry=picos_to_interval(ppi->cfg.constantAsymmetry_ps);
ppi->asymmetryCorrectionPortDS.scaledDelayCoefficient=
(RelativeDifference)(ppi->cfg.delayCoefficient * (double)pow(2.0, REL_DIFF_FRACBITS_AS_FLOAT));
/* Set L1SYNC portDS */
L1E_DSPOR_BS(ppi)->logL1SyncInterval=ppi->cfg.l1sync_interval;
L1E_DSPOR_BS(ppi)->L1SyncReceiptTimeout=ppi->cfg.l1sync_receipt_timeout;
/* Set L1SYNC extension hooks */
ppi->ext_hooks=&l1e_ext_hooks;
/* Set default profile parameters */
ppg->defaultDS->externalPortConfigurationEnabled = 1;
ppi->portDS->masterOnly = 0;
}
#endif
ppi->portDS->masterOnly= ppi->cfg.masterOnly; /* can be overridden in pp_init_globals() */
ppi->portDS->logAnnounceInterval=ppi->cfg.announce_interval;
ppi->portDS->announceReceiptTimeout=ppi->cfg.announce_receipt_timeout;
ppi->portDS->logSyncInterval=ppi->cfg.sync_interval;
ppi->portDS->logMinDelayReqInterval=ppi->cfg.min_delay_req_interval;
ppi->portDS->logMinPdelayReqInterval=ppi->cfg.min_pdelay_req_interval;
} else {
goto exit_out_of_memory;
}
......
......@@ -164,7 +164,7 @@ static int pp_packet_prefilter(struct pp_instance *ppi)
sizeof(ClockIdentity))) {
if (DSDEF(ppi)->numberPorts > 1) {
/* Announces are handled by the BMC, since otherwise the state
* also the PASSIVE states in this case is overwritten */
* also the PASSIVE states in this case is overwritten */
if (hdr->messageType != PPM_ANNOUNCE) {
/* ignore messages, except announce coming from its own clock */
return -1;
......@@ -225,7 +225,7 @@ int pp_state_machine(struct pp_instance *ppi, void *buf, int len)
"RECV %02d bytes at %9d.%09d.%03d (type %x, %s)\n",
len, (int)t->secs, (int)(t->scaled_nsecs >> 16),
((int)(t->scaled_nsecs & 0xffff) * 1000) >> 16,
msgtype, pp_msgtype_info[msgtype].name);
msgtype, pp_msgtype_name[msgtype]);
}
/*
......@@ -298,12 +298,12 @@ int pp_state_machine(struct pp_instance *ppi, void *buf, int len)
return pp_leave_current_state(ppi);
}
pp_diag_fsm(ppi, ip->name, STATE_LOOP, 0);
/* check if the BMC timeout is the next to run */
if (pp_next_delay_1(ppi, PP_TO_BMC) < ppi->next_delay)
ppi->next_delay = pp_next_delay_1(ppi, PP_TO_BMC);
pp_diag_fsm(ppi, ip->name, STATE_LOOP, 0);
/* Run the extension state machine. The extension can provide its own time-out */
if ( ppi->ext_hooks->run_ext_state_machine) {
int delay = ppi->ext_hooks->run_ext_state_machine(ppi);
......
......@@ -13,7 +13,7 @@
#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 */
#define WRS_PPSI_SHMEM_VERSION 32 /* added HAL_PORT_STATE_RESET to hal */
/* White Rabbit softpll status values */
#define WRH_SPLL_OK 0
......
......@@ -187,7 +187,7 @@ typedef struct MsgPDelayRespFollowUp {
PortIdentity requestingPortIdentity;
} MsgPDelayRespFollowUp;
/* Signaling Message (table 33, page 133) */
/* Signaling Message (Table 51 : Signaling message fields) */
typedef struct MsgSignaling {
PortIdentity targetPortIdentity;
char *tlv;
......@@ -218,7 +218,7 @@ typedef struct { /* page 65 */
/** 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*/
Boolean 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 */
......@@ -332,6 +332,10 @@ typedef struct { /*draft P1588_v_29: page129*/
RelativeDifference scaledDelayCoefficient;
} asymmetryCorrectionPortDS_t;
typedef struct {/*draft P1588_v_29: Clause 17.6.3 */
Enumeration8 desiredState; /* draft P1588_v_29: Clause 17.6.3.2 */
}externalPortConfigurationPortDS_t;
/** ************************************************************************/
/* Enumeration States (table 8, page 73) */
enum pp_std_states {
......
......@@ -24,6 +24,7 @@ struct pp_runtime_opts {
int priority1;
int priority2;
int domainNumber;
Boolean externalPortConfigurationEnabled;
void *arch_opts;
};
......@@ -204,11 +205,11 @@ struct pp_instance {
portDS_t *portDS; /* page 72 */
struct pp_servo *servo; /* Servo moved from globals because we may have more than one servo : redundancy */
/** (IEEE1588-2018) */
/** (IEEE1588-2019) */
asymmetryCorrectionPortDS_t asymmetryCorrectionPortDS; /*draft P1588_v_29: page 99*/
timestampCorrectionPortDS_t timestampCorrectionPortDS; /*draft P1588_v_29: page 99*/
/** *********************** */
externalPortConfigurationPortDS_t externalPortConfigurationPortDS; /*draft P1588: Clause 17.6.3*/
/************************* */
unsigned long timeouts[__PP_TO_ARRAY_SIZE];
UInteger16 recv_sync_sequence_id;
......
......@@ -23,6 +23,14 @@
#include <arch/arch.h> /* ntohs and so on -- and wr-api.h for wr archs */
#if CONFIG_EXT_WR==1
#include "../proto-ext-whiterabbit/wr-api.h"
#endif
#if CONFIG_EXT_L1SYNC==1
#include "../proto-ext-l1sync/l1e-api.h"
#endif
/* At this point in time, we need ARRAY_SIZE to conditionally build vlan code */
#undef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
......
......@@ -23,11 +23,11 @@ void ppsi_clear_bss(void)
}
/* ppg fields */
static DSDefault defaultDS;
static DSCurrent currentDS;
static DSParent parentDS;
static DSPort portDS;
static DSTimeProperties timePropertiesDS;
static defaultDS_t defaultDS;
static currentDS_t currentDS;
static [parentDS_t parentDS;
static portDS_t portDS;
static timePropertiesDS_t timePropertiesDS;
static struct pp_servo servo;
static struct pp_globals ppg_static; /* forward declaration */
......@@ -43,7 +43,7 @@ static struct pp_instance ppi_static = {
.port_name = "eth0",
.vlans_array_len = CONFIG_VLAN_ARRAY_SIZE,
.proto = PP_DEFAULT_PROTO,
.mech = CONFIG_HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH,
.delayMechanism = CONFIG_HAS_P2P ? P2P : E2E,
.__tx_buffer = __tx_buffer,
.__rx_buffer = __rx_buffer,
};
......
......@@ -119,7 +119,7 @@ void pp_time_hardwarize(struct pp_time *time, int clock_period_ps,
ps = time->scaled_nsecs & 0xffff; /* fractional nano */
ps = (ps * 1000) >> TIME_INTERVAL_FRACBITS; /* now picoseconds 0..999 -- positive*/
ns = time->scaled_nsecs >> TIME_INTERVAL_FRACBITS;
if (ns > 0) {
if (ns > 0 && clock_ns) {
ps += (ns % clock_ns) * 1000;
ns -= (ns % clock_ns);
}
......
......@@ -26,7 +26,12 @@
#define L1E_TIMEOUT_TX_SYNC PP_TO_EXT_0
#define L1E_TIMEOUT_RX_SYNC PP_TO_EXT_1
#define L1E_DEFAULT_L1SYNCRECEIPTTIMEOUT 5 /* was 3: need more for pll lock */
#define L1E_DEFAULT_L1SYNC_INTERVAL 0
#define L1E_MIN_L1SYNC_INTERVAL -4
#define L1E_MAX_L1SYNC_INTERVAL 4
#define L1E_DEFAULT_L1SYNC_RECEIPT_TIMEOUT 3
#define L1E_MIN_L1SYNC_RECEIPT_TIMEOUT 2
#define L1E_MAX_L1SYNC_RECEIPT_TIMEOUT 10
/*
* We don't have ha_dsport, but rather rely on wr_dsport with our fields added.
......
......@@ -8,7 +8,6 @@
#include <inttypes.h>
#include <ppsi/ppsi.h>
#include <common-fun.h>
#include "l1e-api.h"
#include "l1e-constants.h"
#include <math.h>
......@@ -86,7 +85,7 @@ static int l1e_init(struct pp_instance *ppi, void *buf, int len)
bds->congruentIsRequired = TRUE;
bds->optParamsEnabled = FALSE;
bds->logL1SyncInterval = 0;
bds->L1SyncReceiptTimeout = L1E_DEFAULT_L1SYNCRECEIPTTIMEOUT;
bds->L1SyncReceiptTimeout = L1E_DEFAULT_L1SYNC_RECEIPT_TIMEOUT;
// init dynamic data set members with zeros/defaults
bds->L1SyncLinkAlive = FALSE;
bds->isTxCoherent = FALSE;
......@@ -234,6 +233,20 @@ static int l1e_ready_for_slave(struct pp_instance *ppi)
}
static void l1e_state_change(struct pp_instance *ppi) {
switch (ppi->next_state) {
case PPS_DISABLED :
/* In PPSI we go to DISABLE state when the link is down */
/* For the time being, it should be done like this because fsm is not called when the link is down */
l1e_run_state_machine(ppi); /* First call to choose the next state */
l1e_run_state_machine(ppi); /* Second call to apply next state */
break;
case PPS_INITIALIZING :
L1E_DSPOR(ppi)->basic.L1SyncState=L1E_DSPOR(ppi)->basic.next_state=L1SYNC_DISABLED;
break;
}
}
/* The global structure used by ppsi */
struct pp_ext_hooks l1e_ext_hooks = {
.open = l1e_open,
......@@ -246,5 +259,6 @@ struct pp_ext_hooks l1e_ext_hooks = {
#if CONFIG_HAS_P2P
.handle_presp = l1e_handle_presp,
#endif
.state_change = l1e_state_change,
};
......@@ -6,7 +6,6 @@
*/
#include <ppsi/ppsi.h>
#include "l1e-api.h"
#define MSG_OFFSET_HEADER 0
#define MSG_OFFSET_HEADER_MESSAGE_LENGTH (MSG_OFFSET_HEADER+2)
......@@ -26,10 +25,6 @@
#define MSG_TYPE_SIGNALING 0xC
#define MSG_HEADER_CONTROL_FIELD_ALL_OTHERS 5
#define MSG_TYPE_
#define MSG_GET_16(buf,off) (*(UInteger16 *)(buf+off))
#define MSG_GET_8(buf,off ) *(UInteger8 *)(buf+off)
......@@ -41,13 +36,7 @@
#define MSG_GET_TLV_L1SYNC_PEER_ACTIVE(buf) MSG_GET_8(buf,MSG_OFFSET_TLV_L1SYNC_PEER_ACTIVE)
#define MSG_SET_HEADER_TYPE(buf,val) MSG_GET_8(buf,MSG_OFFSET_HEADER_TYPE) = \
(MSG_GET_8(buf,MSG_OFFSET_HEADER_TYPE) & 0xF0) | val
#define MSG_SET_HEADER_MESSAGE_LENGTH(buf,val) MSG_GET_16(buf,MSG_OFFSET_HEADER_MESSAGE_LENGTH) = htons(val)
#define MSG_SET_HEADER_CONTROL_FIELD(buf, val) MSG_GET_8(buf,MSG_OFFSET_HEADER_CONTROL_FIELD) = val
#define MSG_SET_TARGET_PORT_IDENTITY(buf,clock,port) *(ClockIdentity *)(buf+MSG_OFFSET_TARGET_PORT_IDENTITY) = clock;\
MSG_GET_16(buf,MSG_OFFSET_TARGET_PORT_IDENTITY_PORT_NUMBER) = htons(port);
#define MSG_SET_TLV_TYPE(buf,val) MSG_GET_16(buf,MSG_OFFSET_TLV_TYPE)=htons(val)
#define MSG_SET_TLV_LENGTH_FIELD(buf,val) MSG_GET_16(buf,MSG_OFFSET_TLV_LENGTH_FIELD)=htons(val)
#define MSG_SET_TLV_L1SYNC_PEER_CONF(buf,val) MSG_GET_8(buf,MSG_OFFSET_TLV_L1SYNC_PEER_CONF)= val
#define MSG_SET_TLV_L1SYNC_PEER_ACTIVE(buf,val) MSG_GET_8(buf,MSG_OFFSET_TLV_L1SYNC_PEER_ACTIVE)=val
......@@ -58,27 +47,16 @@
int l1e_pack_signal(struct pp_instance *ppi)
{
void *buf;
void *buf=ppi->tx_ptp;
PortIdentity targetPortIdentity;
uint8_t local_config, local_active;
L1SyncBasicPortDS_t * bds=L1E_DSPOR_BS(ppi);
buf = ppi->tx_ptp;
/* Changes in header */
MSG_SET_HEADER_TYPE(buf,MSG_TYPE_SIGNALING);
MSG_SET_HEADER_CONTROL_FIELD(buf,MSG_HEADER_CONTROL_FIELD_ALL_OTHERS);
memset(&targetPortIdentity,-1,sizeof(targetPortIdentity)); /* cloclk identity and port set all 1's */
/* Generic pack of a signaling message */
msg_pack_signaling_no_fowardable(ppi,&targetPortIdentity,TLV_TYPE_L1_SYNC,2);
/* target portIdentity */
MSG_SET_TARGET_PORT_IDENTITY(buf,
DSPAR(ppi)->parentPortIdentity.clockIdentity,
DSPAR(ppi)->parentPortIdentity.portNumber);
/* L1SyncTLV */
MSG_SET_TLV_TYPE(buf,TLV_TYPE_L1_SYNC);
MSG_SET_TLV_LENGTH_FIELD(buf,2);
/* O.6.4 */
/* Clause O.6.4 */
local_config = l1e_creat_L1Sync_bitmask(bds->txCoherentIsRequired,
bds->rxCoherentIsRequired,
bds->congruentIsRequired);
......@@ -104,10 +82,6 @@ int l1e_unpack_signal(struct pp_instance *ppi, void *buf, int plen)
L1SyncBasicPortDS_t * basicDS=L1E_DSPOR_BS(ppi);
int l1sync_peer_conf, l1sync_peer_acti;
if ( MSG_GET_HEADER_TYPE(buf) != MSG_TYPE_SIGNALING) {
pp_diag(ppi, ext, 1, "Not a signaling message, ignore\n");
return -1;
}
if (MSG_GET_TLV_TYPE(buf) != TLV_TYPE_L1_SYNC) {
pp_diag(ppi, ext, 1, "Not L1Sync TLV, ignore\n");
return -1;
......
......@@ -6,7 +6,6 @@
*/
#include <ppsi/ppsi.h>
#include "l1e-api.h"
#include "l1e-constants.h"
#include <libwr/shmem.h>
......
......@@ -7,7 +7,6 @@
#include <ppsi/ppsi.h>
#include <common-fun.h>
#include "l1e-api.h"
#include "l1e-constants.h"
#include <math.h>
......@@ -167,8 +166,7 @@ static void l1e_send_sync_msg(struct pp_instance *ppi, Boolean immediatSend) {
pp_diag(ppi, ext, 1, "Sending L1SYNC_TLV signaling msg\n");
len = l1e_pack_signal(ppi);
/* FIXME: check the destination MAC address */
__send_and_log(ppi, len, PP_NP_GEN);
__send_and_log(ppi, len, PP_NP_GEN,PPM_SIGNALING_NO_FWD_FMT);
/* Calculate when the next message should be sent */
__pp_timeout_set(ppi, L1E_TIMEOUT_TX_SYNC,
......
......@@ -5,7 +5,6 @@
* Released according to the GNU LGPL, version 2.1 or any later version.
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/* We are entering WR handshake, as either master or slave */
void wr_handshake_init(struct pp_instance *ppi, int mode_or_retry)
......
......@@ -6,7 +6,6 @@
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/*
* This is the WR state machine table.
......
#include <ppsi/ppsi.h>
#include "wr-api.h"
/* ext-whiterabbit must offer its own hooks */
......@@ -8,6 +7,7 @@ static int wr_init(struct pp_instance *ppi, void *buf, int len)
struct wr_dsport *wrp = WR_DSPOR(ppi);
pp_diag(ppi, ext, 2, "hook: %s\n", __func__);
wrp->wrStateTimeout = WR_DEFAULT_STATE_TIMEOUT_MS;
wrp->calPeriod = WR_DEFAULT_CAL_PERIOD;
wrp->head.extModeOn = 0;
......@@ -39,15 +39,15 @@ static int wr_open(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts)
pp_diag(NULL, ext, 2, "hook: %s\n", __func__);
if (ppi->protocol_extension == PPSI_EXT_WR) {
switch (ppi->role) {
case PPSI_ROLE_MASTER:
if ( DSDEF(ppi)->slaveOnly ) {
WR_DSPOR(ppi)->wrConfig = WR_S_ONLY;
} else {
if ( ppi->portDS->masterOnly ) {
WR_DSPOR(ppi)->wrConfig = WR_M_ONLY;
break;
case PPSI_ROLE_SLAVE:
WR_DSPOR(ppi)->wrConfig = WR_S_ONLY;
break;
default:
} else {
WR_DSPOR(ppi)->wrConfig = WR_M_AND_S;
}
}
return 0;
}
......
#include <ppsi/ppsi.h>
#include "common-fun.h"
#include "wr-api.h"
/*
* This is similar to master state, but it only sends sync, that
......
......@@ -7,7 +7,6 @@
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/*
* We enter here from WRS_CALIBRATION. If master we wait for
......
......@@ -7,7 +7,6 @@
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/*
* We enter this state from WRS_M_LOCK or WRS_RESP_CALIB_REQ.
......
......@@ -7,7 +7,6 @@
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/*
* This is the last WR state: ack the other party and go master or slave.
......
......@@ -7,7 +7,6 @@
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/*
* WR slave: got here from WRS_S_LOCK: send LOCKED, wait for CALIBRATE.
......
......@@ -7,7 +7,6 @@
*/
#include <ppsi/ppsi.h>
#include "wr-api.h"
/*
* This the entry point for a WR master: send "LOCK" and wait
......