Commit eb21e3fa authored by Adam Wujek's avatar Adam Wujek

Merge wrpc-v5 into master

Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parents 61f7d34d 851c4244
......@@ -4,6 +4,9 @@ A := arch-$(ARCH)
CFLAGS += -Itools
# needed for --gc-sections option of ld
PPSI_O_LDFLAGS = --entry=main
OBJ-y += $A/unix-startup.o \
$A/main-loop.o \
$A/unix-io.o \
......@@ -14,7 +17,8 @@ OBJ-y += $A/unix-startup.o \
lib/dump-funcs.o \
lib/drop.o \
lib/assert.o \
lib/div64.o
lib/div64.o \
lib/time-arith.o
# The user can set TIME=, but we pick unix time by default
TIME ?= unix
......
/*
* Copyright (C) 2011 CERN (www.cern.ch)
* Copyright (C) 2011-2022 CERN (www.cern.ch)
* Author: Alessandro Rubini
*
* Released to the public domain
......@@ -24,8 +24,26 @@ static int run_all_state_machines(struct pp_globals *ppg)
int j;
int delay_ms = 0, delay_ms_j;
/* TODO: check if in GM mode and initialized */
for (j = 0; j < ppg->nlinks; j++) {
struct pp_instance *ppi = INST(ppg, j);
int old_lu = ppi->link_up;
/* TODO: add the proper discovery of link_up */
ppi->link_up = 1;
if (old_lu != ppi->link_up) {
pp_diag(ppi, fsm, 1, "iface %s went %s\n",
ppi->iface_name, ppi->link_up ? "up" : "down");
if (ppi->link_up) {
ppi->state = PPS_INITIALIZING;
/* TODO: Get calibration values here */
}
}
delay_ms_j = pp_state_machine(ppi, NULL, 0);
/* delay_ms is the least delay_ms among all instances */
......@@ -35,6 +53,22 @@ static int run_all_state_machines(struct pp_globals *ppg)
delay_ms = delay_ms_j;
}
/* BMCA must run at least once per announce interval 9.2.6.8 */
if (pp_gtimeout(ppg, PP_TO_BMC)) {
/* Calculation of erbest, ebest, ... */
bmc_calculate_ebest(ppg);
pp_gtimeout_reset(ppg, PP_TO_BMC);
delay_ms = 0;
/* TODO: Check PLL state if needed/available */
} else {
/* check if the BMC timeout is the next to run */
int delay_bmca;
if ((delay_bmca = pp_gnext_delay_1(ppg, PP_TO_BMC)) < delay_ms)
delay_ms = delay_bmca;
}
return delay_ms;
}
......@@ -48,8 +82,6 @@ void unix_main_loop(struct pp_globals *ppg)
for (j = 0; j < ppg->nlinks; j++) {
ppi = INST(ppg, j);
/* just tell that the links are up */
ppi->link_up = TRUE;
/*
* The main loop here is based on select. While we are not
......@@ -62,32 +94,14 @@ void unix_main_loop(struct pp_globals *ppg)
delay_ms = run_all_state_machines(ppg);
while (1) {
int i;
/*
* If Ebest was changed in previous loop, run best
* master clock before checking for new packets, which
* would affect port state again
*/
if (ppg->ebest_updated) {
for (j = 0; j < ppg->nlinks; j++) {
int new_state;
struct pp_instance *ppi = INST(ppg, j);
new_state = bmc(ppg);
if (new_state != ppi->state) {
ppi->state = new_state;
ppi->is_new_state = 1;
}
}
ppg->ebest_updated = 0;
}
int packet_available;
i = unix_net_ops.check_packet(ppg, delay_ms);
packet_available = unix_net_ops.check_packet(ppg, delay_ms);
if (i < 0)
if (packet_available < 0)
continue;
if (i == 0) {
if (packet_available == 0) {
delay_ms = run_all_state_machines(ppg);
continue;
}
......@@ -99,7 +113,7 @@ void unix_main_loop(struct pp_globals *ppg)
delay_ms = -1;
for (j = 0; j < ppg->nlinks; j++) {
int tmp_d;
int tmp_d, i;
ppi = INST(ppg, j);
if ((ppi->ch[PP_NP_GEN].pkt_present) ||
......
/*
* Copyright (C) 2011 CERN (www.cern.ch)
* Copyright (C) 2011-2022 CERN (www.cern.ch)
* Author: Alessandro Rubini
*
* Released to the public domain
......@@ -23,16 +23,36 @@
#include <ppsi/ppsi.h>
#include "ppsi-unix.h"
char *format_hex(char *s, const unsigned char *mac, int cnt);
char *format_hex8(char *s, const unsigned char *mac);
/* ppg and fields */
static struct pp_globals ppg_static;
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;
/**
* Enable/disable asymmetry correction
*/
static void enable_asymmetryCorrection(struct pp_instance *ppi, Boolean enable ) {
if ((ppi->asymmetryCorrectionPortDS.enable = enable) == TRUE ) {
/* Enabled: The delay asymmetry will be calculated */
ppi->asymmetryCorrectionPortDS.scaledDelayCoefficient =
(ppi->cfg.scaledDelayCoefficient != 0) ?
ppi->cfg.scaledDelayCoefficient :
(RelativeDifference)(ppi->cfg.delayCoefficient * REL_DIFF_TWO_POW_FRACBITS);
ppi->portDS->delayAsymCoeff =
pp_servo_calculateDelayAsymCoefficient(ppi->asymmetryCorrectionPortDS.scaledDelayCoefficient);
}
ppi->asymmetryCorrectionPortDS.constantAsymmetry =
picos_to_interval(ppi->cfg.constantAsymmetry_ps);
}
int main(int argc, char **argv)
{
struct pp_globals *ppg;
......@@ -45,6 +65,15 @@ int main(int argc, char **argv)
pp_printf("PPSi. Commit %s, built on " __DATE__ "\n", PPSI_VERSION);
/* So far allow more than one instance of PPSi running on the same
* machine.
TODO: to be considered to allow only one instance of PPSi to run
* at the same time.
* Potential problems my be in:
* shmem (not used in arch-unix)
* race of setting of time if more than one instance run as slave
*/
ppg = &ppg_static;
ppg->defaultDS = &defaultDS;
ppg->currentDS = &currentDS;
......@@ -62,16 +91,17 @@ int main(int argc, char **argv)
exit(1);
}
/* Before the configuration is parsed, set defaults */
/* Set default configuration value for all instances */
for (i = 0; i < ppg->max_links; i++) {
ppi = INST(ppg, i);
ppi->proto = PP_DEFAULT_PROTO;
ppi->delayMechanism = MECH_E2E;
memcpy(&INST(ppg, i)->cfg, &__pp_default_instance_cfg,
sizeof(__pp_default_instance_cfg));
}
/* Set offset here, so config parsing can override it */
if (adjtimex(&t) >= 0)
timePropertiesDS.currentUtcOffset = t.tai;
memset(&t, 0, sizeof(t));
if (adjtimex(&t) >= 0) {
ppg->timePropertiesDS->currentUtcOffset = (Integer16)t.tai;
}
if (pp_parse_cmdline(ppg, argc, argv) != 0)
return -1;
......@@ -79,6 +109,8 @@ int main(int argc, char **argv)
/* If no item has been parsed, provide a default file or string */
if (ppg->cfg.cfg_items == 0)
pp_config_file(ppg, 0, PP_DEFAULT_CONFIGFILE);
/* No config found, add default */
if (ppg->cfg.cfg_items == 0)
pp_config_string(ppg, strdup("link 0; iface eth0; proto udp"));
......@@ -87,27 +119,118 @@ int main(int argc, char **argv)
ppi = INST(ppg, i);
ppi->ch[PP_NP_EVT].fd = -1;
ppi->ch[PP_NP_GEN].fd = -1;
ppi->servo = &servo;
ppi->glbs = ppg;
ppi->vlans_array_len = CONFIG_VLAN_ARRAY_SIZE,
ppi->iface_name = ppi->cfg.iface_name;
ppi->port_name = ppi->cfg.port_name;
ppi->delayMechanism = ppi->cfg.delayMechanism;
ppi->ext_hooks= &pp_hooks;
ppi->portDS = calloc(1, sizeof(*ppi->portDS));
ppi->servo = calloc(1, sizeof(*ppi->servo));
ppi->ext_hooks = &pp_hooks;
ppi->ptp_support = TRUE;
if (ppi->portDS) {
switch (ppi->cfg.profile) {
case PPSI_PROFILE_WR:
#if CONFIG_HAS_PROFILE_WR
ppi->protocol_extension = PPSI_EXT_WR;
/* Add WR extension portDS */
if ( !(ppi->portDS->ext_dsport =
wrs_shm_alloc(ppsi_head,
sizeof(struct wr_dsport))
)
) {
goto exit_out_of_memory;
}
/* Allocate WR data extension */
if (! (ppi->ext_data =
wrs_shm_alloc(ppsi_head,
sizeof(struct wr_data))
)
) {
goto exit_out_of_memory;
}
/* Set WR extension hooks */
ppi->ext_hooks = &wr_ext_hooks;
enable_asymmetryCorrection(ppi, TRUE);
#else
fprintf(stderr, "ppsi: Profile WR not supported");
exit(1);
#endif
break;
case PPSI_PROFILE_HA:
#if CONFIG_HAS_PROFILE_HA
if (!enable_l1Sync(ppi, TRUE))
goto exit_out_of_memory;
/* Force mandatory attributes - Do not take care of the configuration */
L1E_DSPOR_BS(ppi)->rxCoherentIsRequired = TRUE;
L1E_DSPOR_BS(ppi)->txCoherentIsRequired = TRUE;
L1E_DSPOR_BS(ppi)->congruentIsRequired = TRUE;
L1E_DSPOR_BS(ppi)->L1SyncEnabled = TRUE;
L1E_DSPOR_BS(ppi)->optParamsEnabled = FALSE;
enable_asymmetryCorrection(ppi, TRUE);
#else
fprintf(stderr, "ppsi: Profile HA not supported");
exit(1);
#endif
break;
case PPSI_PROFILE_PTP :
/* Do not take care of L1SYNC */
enable_asymmetryCorrection(ppi,
ppi->cfg.asymmetryCorrectionEnable);
ppi->protocol_extension = PPSI_EXT_NONE;
break;
case PPSI_PROFILE_CUSTOM :
#if CONFIG_HAS_PROFILE_CUSTOM
ppi->protocol_extension = PPSI_EXT_NONE; /* can be changed ...*/
#if CONFIG_HAS_EXT_L1SYNC
if (ppi->cfg.l1SyncEnabled) {
if (!enable_l1Sync(ppi, TRUE))
goto exit_out_of_memory;
/* Read L1SYNC parameters */
L1E_DSPOR_BS(ppi)->rxCoherentIsRequired = ppi->cfg.l1SyncRxCoherencyIsRequired;
L1E_DSPOR_BS(ppi)->txCoherentIsRequired = ppi->cfg.l1SyncTxCoherencyIsRequired;
L1E_DSPOR_BS(ppi)->congruentIsRequired = ppi->cfg.l1SyncCongruencyIsRequired;
L1E_DSPOR_BS(ppi)->optParamsEnabled = ppi->cfg.l1SyncOptParamsEnabled;
if (L1E_DSPOR_BS(ppi)->optParamsEnabled) {
L1E_DSPOR_OP(ppi)->timestampsCorrectedTx = ppi->cfg.l1SyncOptParamsTimestampsCorrectedTx;
}
}
enable_asymmetryCorrection(ppi, ppi->cfg.asymmetryCorrectionEnable);
#endif
#else
fprintf(stderr, "ppsi: Profile CUSTOM not supported");
exit(1);
#endif
break;
}
/* Parameters profile independent */
ppi->timestampCorrectionPortDS.egressLatency = picos_to_interval(ppi->cfg.egressLatency_ps);
ppi->timestampCorrectionPortDS.ingressLatency = picos_to_interval(ppi->cfg.ingressLatency_ps);
ppi->timestampCorrectionPortDS.messageTimestampPointLatency = 0;
ppi->portDS->masterOnly = ppi->cfg.masterOnly; /* can be overridden in pp_init_globals() */
} else {
goto exit_out_of_memory;
}
/* The following default names depend on TIME= at build time */
ppi->n_ops = &DEFAULT_NET_OPS;
ppi->t_ops = &DEFAULT_TIME_OPS;
ppi->portDS = calloc(1, sizeof(*ppi->portDS));
ppi->__tx_buffer = malloc(PP_MAX_FRAME_LENGTH);
ppi->__rx_buffer = malloc(PP_MAX_FRAME_LENGTH);
if (!ppi->portDS || !ppi->__tx_buffer || !ppi->__rx_buffer) {
fprintf(stderr, "ppsi: out of memory\n");
exit(1);
goto exit_out_of_memory;
}
}
pp_init_globals(ppg, &__pp_default_rt_opts);
seed = time(NULL);
......@@ -117,4 +240,21 @@ int main(int argc, char **argv)
unix_main_loop(ppg);
return 0; /* never reached */
exit_out_of_memory:
fprintf(stderr, "ppsi: out of memory\n");
exit(1);
}
char *format_hex(char *s, const unsigned char *mac, int cnt)
{
int i;
*s = '\0';
for (i = 0; i < cnt; i++) {
pp_sprintf(s, "%s%02x:", s, mac[i]);
}
/* remove last colon */
s[cnt * 3 - 1] = '\0'; /* cnt * strlen("FF:") - 1 */
return s;
}
/hal_minirpc.c
......@@ -36,24 +36,49 @@ arch-spec-o = $(patsubst %.c,%.o,$(arch-spec-c))
OBJ-y += $(arch-spec-o)
# build symbolic links for libwr
hal_headers = hal_shmem.h \
libwr_headers = hal_shmem.h \
generic_fsm.h\
sfp_lib.h\
util.h\
shmem.h \
timeout.h
hal_headers_in_ppsi= $(addprefix $A/include/libwr/,$(hal_headers))
libwr_headers_in_ppsi= $(addprefix $A/include/libwr/,$(libwr_headers))
all: $(TARGET)
$(arch-spec-o) : $(libwr_headers_in_ppsi)
$(arch-spec-o) : $(hal_headers_in_ppsi)
$(hal_headers_in_ppsi):
$(libwr_headers_in_ppsi):
@f=$(notdir $@); \
echo "Creating symbolic link to $$f";\
echo "Creating symbolic link to include/libwr/$$f";\
ln -sf ../../../../libwr/include/libwr/$$f $@
# build symbolic links for source files in libwr
libwr_source = hal_minirpc.c
libwr_source_in_ppsi= $(addprefix $A,/$(libwr_source))
$(arch-spec-o) : $(libwr_source_in_ppsi)
$(libwr_source_in_ppsi):
@f=$(notdir $@); \
echo "Creating symbolic link to $$f";\
ln -sf ../../libwr/$$f $@
# build symbolic links for userspace files from wrs
wrs_userspace_headers = hal_exports.h
wrs_userspace_headers_in_ppsi = $(addprefix $A/include/,$(wrs_userspace_headers))
$(arch-spec-o): $(wrs_userspace_headers_in_ppsi)
$(wrs_userspace_headers_in_ppsi):
@f=$(notdir $@); \
echo "Creating symbolic link to include/$$f";\
ln -sf ../../../include/$$f $@
export size_db_file:=size_wrs_db.txt
export size_info_file:=size_wrs_info.txt
......@@ -77,7 +102,10 @@ $(MINIPC_LIB):
OBJ-y += $(MINIPC_LIB)
clean::
rm -f $(hal_headers_in_ppsi)
rm -f \
$(libwr_headers_in_ppsi) \
$(libwr_source_in_ppsi) \
$(wrs_userspace_headers_in_ppsi)
# to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_init_globals() ).
......
#ifndef __HAL_EXPORTS_C
#define __HAL_EXPORTS_C
#include <minipc.h>
#include <hal_exports.h>
/* Export structures, shared by server and client for argument matching */
struct minipc_pd __rpcdef_check_running = {
.name = "check_running",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_END,
},
};
//int halexp_reset_port(const char *port_name);
struct minipc_pd __rpcdef_reset_port = {
.name = "reset_port",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRING, char *),
MINIPC_ARG_END,
},
};
//int halexp_calibration_cmd(const char *port_name, int command, int on_off);
struct minipc_pd __rpcdef_calibration_cmd = {
.name = "calibration_cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRING, char *),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
//int halexp_lock_cmd(const char *port_name, int command, int priority);
struct minipc_pd __rpcdef_lock_cmd = {
.name = "lock_cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRING, char *),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
//int halexp_pps_cmd(int cmd, hexp_pps_params_t *params);
struct minipc_pd __rpcdef_pps_cmd = {
.name = "pps_cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, hexp_pps_params_t),
MINIPC_ARG_END,
},
};
//int halexp_info_cmd(hexp_info_params_t *params);
struct minipc_pd __rpcdef_port_update_cmd = {
.name = "info_cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, hexp_port_info_params_t),
MINIPC_ARG_END,
},
};
#endif
#ifndef __HAL_EXPORTS_H
#define __HAL_EXPORTS_H
#include <stdint.h>
#define HAL_MAX_PORTS 32
#define WRSW_HAL_SERVER_ADDR "wrsw_hal"
// checks if the calibration unit is idle
#define HEXP_CAL_CMD_CHECK_IDLE 1
// enables/disables transmission of calibration pattern
#define HEXP_CAL_CMD_TX_PATTERN 2
// requests a measurement of TX delta
#define HEXP_CAL_CMD_TX_MEASURE 4
// requests a measurement of RX delta
#define HEXP_CAL_CMD_RX_MEASURE 5
#define HEXP_CAL_RESP_BUSY 1
#define HEXP_CAL_RESP_OK 0
#define HEXP_CAL_RESP_ERROR -1
#define HEXP_LOCK_CMD_START 1
#define HEXP_LOCK_CMD_CHECK 2
#define HEXP_LOCK_CMD_ENABLE_TRACKING 3
#define HEXP_LOCK_CMD_RESET 4
#define HEXP_LOCK_STATUS_UNLOCKED 0
#define HEXP_LOCK_STATUS_LOCKED 1
#define HEXP_LOCK_STATUS_RELOCK_ERROR 2
#define HEXP_LOCK_STATUS_ERROR 3
#define HEXP_PPSG_CMD_GET 0
#define HEXP_PPSG_CMD_ADJUST_PHASE 1
#define HEXP_PPSG_CMD_ADJUST_SEC 2
#define HEXP_PPSG_CMD_ADJUST_NSEC 3
#define HEXP_PPSG_CMD_POLL 4
#define HEXP_PPSG_CMD_SET_VALID 5
#define HEXP_PPSG_CMD_SET_TIMING_MODE 6
#define HEXP_PPSG_CMD_GET_TIMING_MODE 7
#define HEXP_PPSG_CMD_GET_TIMING_MODE_STATE 8
#define HEXP_ON 1
#define HEXP_OFF 0
#define HEXP_FREQ 0
#define HEXP_PHASE 1
/////////////////added by ML//////////
#define HEXP_EXTSRC_CMD_CHECK 0
#define HEXP_EXTSRC_STATUS_LOCKED 0
#define HEXP_LOCK_STATUS_BUSY 1
#define HEXP_EXTSRC_STATUS_NOSRC 2
/////////////////////////////////////
#define HAL_TIMING_MODE_GRAND_MASTER 0
#define HAL_TIMING_MODE_FREE_MASTER 1
#define HAL_TIMING_MODE_BC 2
#define HAL_TIMING_MODE_DISABLED 3
#define HAL_TIMING_MODE_TMDT_UNLOCKED 0
#define HAL_TIMING_MODE_TMDT_LOCKED 1
#define HAL_TIMING_MODE_TMDT_HOLDHOVER 2
typedef struct {
char port_name[16];
int pps_valid;
uint32_t current_phase_shift;
int32_t adjust_phase_shift;
int64_t adjust_sec;
int32_t adjust_nsec;
uint64_t current_sec;
uint32_t current_nsec;
uint32_t timing_mode;
} hexp_pps_params_t;
#define PORT_MODE_OTHER 0
#define PORT_MODE_SLAVE 1
#define PORT_MODE_MASTER 2
typedef struct {
char name[16]; // Interface name
int synchronized; // <>0 : Master/Slave are synchronized
int mode; // PORT_MODE_XXXX
}hexp_port_info_t;
typedef struct {
int numberPortInterfaces;
hexp_port_info_t hIFace[HAL_MAX_PORTS];
} hexp_port_info_params_t;
/* Port modes (hal_port_state.mode) */
#define HEXP_PORT_MODE_WR_MASTER 1
#define HEXP_PORT_MODE_WR_SLAVE 2
#define HEXP_PORT_MODE_NON_WR 3
#define HEXP_PORT_MODE_WR_M_AND_S 4
#define HEXP_PORT_MODE_NONE 5
#define FIX_ALPHA_FRACBITS 40
/*
#define HEXP_PORT_TSC_RISING 1
#define HEXP_PORT_TSC_FALLING 2
*/
extern struct minipc_pd __rpcdef_lock_cmd;
extern struct minipc_pd __rpcdef_pps_cmd;
extern struct minipc_pd __rpcdef_port_update_cmd;
/* Prototypes of functions that call on rpc */
extern int halexp_lock_cmd(const char *port_name, int command, int priority);
extern int halexp_pps_cmd(int cmd, hexp_pps_params_t *params);
#endif
......@@ -2,5 +2,6 @@
/timeout.h
/hal_shmem.h
/sfp_lib.h
/shmem.h
/util.h
#ifndef __PPSI_EXPORTS_H
#define __PPSI_EXPORTS_H
#include <stdio.h>
#include <stdlib.h>
#define PPSIEXP_COMMAND_WR_TRACKING 1
#define PPSIEXP_COMMAND_L1SYNC_TRACKING 2
/* Export structures, shared by server and client for argument matching */
#ifdef PPSI_EXPORT_STRUCTURES
struct minipc_pd __rpcdef_cmd = {
.name = "cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
#endif /* PTP_EXPORT_STRUCTURES */
#endif /* __PPSI_EXPORTS_H */
......@@ -7,33 +7,20 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#include <hal_exports.h>
/* minipc Encoding of the supported commands */
#define PTPDEXP_COMMAND_WR_TRACKING 1
#define PTPDEXP_COMMAND_L1SYNC_TRACKING 2
static struct minipc_pd __rpcdef_cmd = {
.name = "cmd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
MINIPC_ARG_END,
},
};
#define PPSI_EXPORT_STRUCTURES
#include <ppsi_exports.h>
/* Execute command coming ipc */
static int wrsipc_cmd(int cmd, int value)
{
if(cmd == PTPDEXP_COMMAND_WR_TRACKING) {
if(cmd == PPSIEXP_COMMAND_WR_TRACKING) {
if ( CONFIG_HAS_EXT_WR ) {
wrh_servo_enable_tracking(value);
return 0;
}
}
if(cmd == PTPDEXP_COMMAND_L1SYNC_TRACKING) {
if(cmd == PPSIEXP_COMMAND_L1SYNC_TRACKING) {
if ( CONFIG_HAS_EXT_L1SYNC ) {
wrh_servo_enable_tracking(value);
return 0;
......
......@@ -70,7 +70,7 @@ int wrs_update_port_info(struct pp_globals *ppg) {
}
}
}
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_port_update_cmd,
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_port_info_cmd,
&rval, &infos);
if (ret < 0)
......
......@@ -22,7 +22,6 @@
#include <signal.h>
#include <minipc.h>
#include <hal_exports.h>
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
......@@ -441,7 +440,6 @@ int main(int argc, char **argv)
*/
enablePPS=(WRS_ARCH_G(ppg)->timingModeLockingState== WRH_TM_LOCKING_STATE_LOCKED &&
ppg->defaultDS->clockQuality.clockClass == PP_PTP_CLASS_GM_LOCKED) ||
ppg->defaultDS->clockQuality.clockClass == PP_FRUNNING_CLOCK_CLASS ||
GOPTS(ppg)->forcePpsGen;
TOPS(ppi)->enable_timing_output(ppg,enablePPS);
}
......
This diff is collapsed.
......@@ -10,7 +10,7 @@
#define __WRH_H__
/* Please increment WRS_PPSI_SHMEM_VERSION if you change any exported data structure */
#define WRS_PPSI_SHMEM_VERSION 35
#define WRS_PPSI_SHMEM_VERSION 36
/* Don't include the Following when this file is included in assembler. */
#ifndef __ASSEMBLY__
......
......@@ -25,7 +25,8 @@ static struct cmd_line_opt cmd_line_list[] = {
{"-C CONFIG_ITEM", "set configuration options as stated in CONFIG_ITEM\n\t"
"CONFIG_ITEM must be a valid config string, enclosed by \" \""},
{"-f FILE", "read configuration file"},
{"-d STRING", "diagnostic level (see diag-macros.h)"},
{"-d STRING", "diagnostic level (see diag-macros.h)\n\t"
"FSM, Time, Frames, Servo, BMC, Extension, Configuration"},
CMD_LINE_SEPARATOR,
{"-t", "do not adjust the system clock"},
{"-w NUMBER", "specify meanDelay filter stiffness"},
......
......@@ -9,5 +9,6 @@
#ifndef __L1SYNC_EXT_CONSTANTS_H__
#define __L1SYNC_EXT_CONSTANTS_H__
#define TLV_TYPE_L1_SYNC 0x8001u
#endif /* __L1SYNC_EXT_CONSTANTS_H__ */
......@@ -6,6 +6,7 @@
*/
#include <ppsi/ppsi.h>
#include "l1e-constants.h"
#define MSG_OFFSET_HEADER 0u
#define MSG_OFFSET_HEADER_MESSAGE_LENGTH (MSG_OFFSET_HEADER+2u)
......
......@@ -147,6 +147,29 @@ static unsigned long bare_calc_timeout(struct pp_instance *ppi, int millisec)
return now_ms + millisec;
}
static int bare_get_GM_lock_state(struct pp_globals *ppg,
pp_timing_mode_state_t *state)
{
*state = PP_TIMING_MODE_STATE_LOCKED;
return 0;
}
static int bare_enable_timing_output(struct pp_globals *ppg, int enable)
{
static int prev_enable = 0;
if (prev_enable != enable) {
pp_diag(NULL, time, 2, "%s dummy timing output\n",
enable ? "enable" : "disable");
prev_enable = enable;
return 0;
}
return 0;
}
struct pp_time_operations bare_time_ops = {
.get_utc_time = bare_time_get_utc_time,
.get_utc_offset = bare_time_get_utc_offset,
......@@ -158,4 +181,6 @@ struct pp_time_operations bare_time_ops = {
.adjust_offset = bare_time_adjust_offset,
.adjust_freq = bare_time_adjust_freq,
.calc_timeout = bare_calc_timeout,
.get_GM_lock_state = bares_get_GM_lock_state,
.enable_timing_output = bare_enable_timing_output
};
......@@ -144,8 +144,26 @@ static unsigned long sim_calc_timeout(struct pp_instance *ppi, int millisec)
return millisec + SIM_PPI_ARCH(ppi)->time.current_ns / 1000LL / 1000LL;
}
static int sim_get_GM_lock_state(struct pp_globals *ppg,
pp_timing_mode_state_t *state)
{
*state = PP_TIMING_MODE_STATE_LOCKED;
return 0;
}
static int sim_enable_timing_output(struct pp_globals *ppg, int enable)
{
static int prev_enable = 0;
if (prev_enable != enable) {
pp_diag(NULL, time, 2, "%s dummy timing output\n",
enable ? "enable" : "disable");
prev_enable = enable;
return 0;
}
return 0;
}
......@@ -161,5 +179,6 @@ const struct pp_time_operations sim_time_ops = {
.adjust_freq = sim_adjust_freq,
.init_servo = sim_init_servo,
.calc_timeout = sim_calc_timeout,
.get_GM_lock_state = sim_get_GM_lock_state,
.enable_timing_output = sim_enable_timing_output
};
......@@ -22,7 +22,7 @@
#include <ppsi/ppsi.h>
#include "ptpdump.h"
#include "../arch-unix/ppsi-unix.h"
#include "../arch-unix/include/ppsi-unix.h"
/* unix_recv_msg uses recvmsg for timestamp query */
static int unix_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
......
......@@ -11,6 +11,7 @@
#include <time.h>
#include <sys/timex.h>
#include <ppsi/ppsi.h>
#include "../arch-unix/include/ppsi-unix.h"
#ifndef MOD_TAI
#define MOD_TAI 0x80
......@@ -280,6 +281,29 @@ static unsigned long unix_calc_timeout(struct pp_instance *ppi, int millisec)
return now_ms + millisec;
}
static int unix_get_GM_lock_state(struct pp_globals *ppg,
pp_timing_mode_state_t *state)
{
*state = PP_TIMING_MODE_STATE_LOCKED;
return 0;
}
static int unix_enable_timing_output(struct pp_globals *ppg, int enable)
{
static int prev_enable = 0;
if (prev_enable != enable) {
pp_diag(NULL, time, 2, "%s dummy timing output\n",
enable ? "enable" : "disable");
prev_enable = enable;
return 0;
}
return 0;
}
const struct pp_time_operations unix_time_ops = {
.get_utc_time = unix_time_get_utc_time,
.get_utc_offset = unix_time_get_utc_offset,
......@@ -291,5 +315,6 @@ const struct pp_time_operations unix_time_ops = {
.adjust_freq = unix_time_adjust_freq,
.init_servo = unix_time_init_servo,
.calc_timeout = unix_calc_timeout,
.get_GM_lock_state = unix_get_GM_lock_state,
.enable_timing_output = unix_enable_timing_output
};
......@@ -431,10 +431,11 @@ static int wrs_time_get(struct pp_instance *ppi, struct pp_time *t)
static int wrs_time_set(struct pp_instance *ppi, const struct pp_time *t)
{
if ( WRS_ARCH_I(ppi)->timingMode==WRH_TM_GRAND_MASTER) {
// Grand master mode
// We delegate the time setup to the wr_date tool has
// it can take time to adjust the time
system("/wr/bin/wr_date -v set host &");
/* Grand master mode
* We delegate the time setup to the wr_date script as it can
* take time to adjust the time. Let it know that we call it
* from the ppsi */
system("/etc/init.d/wr_date ppsi &");
} else {
struct pp_time diff, now;
int msec;
......
This diff is collapsed.
......@@ -6,6 +6,7 @@
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <unistd.h>
static unsigned long unix_calc_timeout(void)
{
......
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