Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/ppsi
1 result
Show changes
Commits on Source (3)
......@@ -62,6 +62,7 @@ static inline wrs_arch_data_t *WRS_ARCH_G(struct pp_globals *ppg)
extern void wrs_main_loop(struct pp_globals *ppg);
void set_param_global_prio1(struct pp_globals *ppg, int prio1);
void set_param_global_prio2(struct pp_globals *ppg, int prio2);
void set_param_global_bmca(struct pp_globals *ppg, int bmca);
void set_param_inst_logMinDelayReqInterval(struct pp_instance *ppi,
int logMinDelayReqInterval);
void set_param_inst_logMinPdelayReqInterval(struct pp_instance *ppi,
......
......@@ -4,6 +4,9 @@
#include <stdio.h>
#include <stdlib.h>
#define PPSIEXP_DISABLE 0
#define PPSIEXP_ENABLE 1
#define PPSIEXP_COMMAND_TRACKING 1
/* Return values */
......@@ -15,6 +18,8 @@
/* Commands for ppsiexp_update_param_cmd */
#define PPSIEXP_PARAM_PRIORITY1_CMD 1
#define PPSIEXP_PARAM_PRIORITY2_CMD 2
#define PPSIEXP_PARAM_BMCA_CMD 5
#define PPSIEXP_PARAM_EXT_PORT_CONFIG_CMD 10
/* Commands for ppsiexp_update_param64_cmd */
#define PPSIEXP_PARAM64_DELTA_RXM_CMD 1
......@@ -29,6 +34,7 @@
#define PPSIEXP_PARAM_INST_EXTENSION_CMD 3
#define PPSIEXP_PARAM_INST_PROFILE_CMD 4
#define PPSIEXP_PARAM_INST_AUTONEG_CMD 5
#define PPSIEXP_PARAM_INST_EPC_DESIRED_CMD 8
/* Commands for ppsiexp_update_param64_instance_cmd */
#define PPSIEXP_PARAM64_INST_DELAY_COEFFICIENT_CMD 1
......@@ -49,6 +55,17 @@
#define PPSIEXP_PARAM_PROFILE_HA_WR PPSI_PROFILE_HA_WR
#define PPSIEXP_PARAM_PROFILE_CUSTOM PPSI_PROFILE_CUSTOM
/* Values for PPSIEXP_PARAM_INST_EPC_DESIRED_CMD */
#define PPSIEXP_PARAM_EPC_DESIRED_INITIALIZING PPS_INITIALIZING
#define PPSIEXP_PARAM_EPC_DESIRED_FAULTY PPS_FAULTY
#define PPSIEXP_PARAM_EPC_DESIRED_DISABLED PPS_DISABLED
#define PPSIEXP_PARAM_EPC_DESIRED_LISTENING PPS_LISTENING
#define PPSIEXP_PARAM_EPC_DESIRED_PRE_MASTER PPS_PRE_MASTER
#define PPSIEXP_PARAM_EPC_DESIRED_MASTER PPS_MASTER
#define PPSIEXP_PARAM_EPC_DESIRED_PASSIVE PPS_PASSIVE
#define PPSIEXP_PARAM_EPC_DESIRED_UNCALIBRATED PPS_UNCALIBRATED
#define PPSIEXP_PARAM_EPC_DESIRED_SLAVE PPS_SLAVE
#define PPSIEXP_COMMAND_TRACKING_DISABLE WRH_TRACKING_DISABLE
#define PPSIEXP_COMMAND_TRACKING_ENABLE WRH_TRACKING_ENABLE
#define PPSIEXP_COMMAND_TRACKING_TOGGLE WRH_TRACKING_TOGGLE
......
......@@ -50,6 +50,7 @@ static int update_param_cmd(const struct minipc_pd *pd, uint32_t *args,
int rval = PPSIEXP_RET_OK;
int param_type = args[0];
int param_val = args[1];
int new_bmca;
switch (param_type) {
case PPSIEXP_PARAM_PRIORITY1_CMD:
......@@ -86,6 +87,63 @@ static int update_param_cmd(const struct minipc_pd *pd, uint32_t *args,
set_param_global_prio2(ppg_local, param_val);
break;
case PPSIEXP_PARAM_BMCA_CMD:
pp_diag(NULL, config, 2,
"%s: cmd %d (PPSIEXP_PARAM_BMCA_CMD) value %d\n",
__func__, param_type, param_val);
if (!check_range_global_bmca(ppg_local->rt_opts->globalProfile,
param_val)) {
pp_diag(NULL, config, 1,
"Param update Error: value of "
"bmca (%d) not in range! "
"cmd %d (PPSIEXP_PARAM_BMCA_CMD)\n",
param_val, param_type);
rval = PPSIEXP_RET_ERROR_VAL;
break;
}
set_param_global_bmca(ppg_local, param_val);
break;
case PPSIEXP_PARAM_EXT_PORT_CONFIG_CMD:
pp_diag(NULL, config, 2,
"%s cmd %d (PPSIEXP_PARAM_EXT_PORT_CONFIG_CMD) "
"value %d\n",
__func__, param_type, param_val);
if (param_val == PPSIEXP_ENABLE) {
/* Enable externalPortConfiguration */
new_bmca = PPSI_BMCA_EXT_PORT_CONFIG;
} else if (param_val == PPSIEXP_DISABLE) {
/* Disable externalPortConfiguration, use previously
* set BMCA. Error if no valid was set before. */
new_bmca = ppg_local->defaultDS->bmcaType;
} else {
pp_diag(NULL, config, 1,
"Param update Error: value of "
"externalPortConfiguration (%d) not in range! "
"cmd %d (PPSIEXP_PARAM_EXT_PORT_CONFIG_CMD)\n",
param_val, param_type);
rval = PPSIEXP_RET_ERROR_VAL;
break;
}
if (!check_range_global_bmca(ppg_local->rt_opts->globalProfile,
new_bmca)) {
pp_diag(NULL, config, 1,
"Param update Error: value of "
"bmca for externalPortConfiguration (%d) not "
"in range! "
"cmd %d (PPSIEXP_PARAM_EXT_PORT_CONFIG_CMD)\n",
new_bmca, param_type);
rval = PPSIEXP_RET_ERROR_VAL;
break;
}
set_param_global_bmca(ppg_local, new_bmca);
break;
default:
pp_diag(NULL, config, 1,
"Param update Error: not supported param cmd %d value "
......@@ -208,6 +266,41 @@ static int update_param_instance(struct pp_instance *ppi, int ppi_i,
rval = PPSIEXP_RET_OK;
break;
case PPSIEXP_PARAM_INST_EPC_DESIRED_CMD:
pp_diag(ppi, config, 2,
"%s cmd %d (PPSIEXP_PARAM_INST_EPC_DESIRED_CMD) "
"instance %d, port %s, value %d\n",
__func__, param_type, ppi_i,
ppi->iface_name, param_val);
switch (param_val) {
case PPSIEXP_PARAM_EPC_DESIRED_INITIALIZING:
case PPSIEXP_PARAM_EPC_DESIRED_FAULTY:
case PPSIEXP_PARAM_EPC_DESIRED_DISABLED:
case PPSIEXP_PARAM_EPC_DESIRED_LISTENING:
case PPSIEXP_PARAM_EPC_DESIRED_PRE_MASTER:
case PPSIEXP_PARAM_EPC_DESIRED_MASTER:
case PPSIEXP_PARAM_EPC_DESIRED_PASSIVE:
case PPSIEXP_PARAM_EPC_DESIRED_UNCALIBRATED:
case PPSIEXP_PARAM_EPC_DESIRED_SLAVE:
/* Known value */
break;
default:
/* Value not known */
pp_diag(ppi, config, 1,
"Param update Error: value of "
"externalPortConfiguration (%d) not in range! "
"cmd %d (PPSIEXP_PARAM_INST_EPC_DESIRED_CMD) "
"instance %d, port %s\n",
param_val, param_type, ppi_i, ppi->iface_name);
return PPSIEXP_RET_ERROR_VAL;
}
set_param_externalPortConfiguration_desiredState(ppi,
param_val);
break;
case PPSIEXP_PARAM_INST_EXTENSION_CMD:
pp_diag(ppi, config, 2,
"%s: cmd %d (PPSIEXP_PARAM_INST_EXTENSION_CMD) "
......
......@@ -481,6 +481,12 @@ void set_param_global_prio2(struct pp_globals *ppg, int prio2)
bmc_apply_configured_device_attributes(ppg);
}
void set_param_global_bmca(struct pp_globals *ppg, int bmca)
{
ppg->rt_opts->bmca = bmca;
pp_set_bmca(ppg, bmca);
}
/* Functions to set parameters specific to instance */
void set_param_inst_logMinDelayReqInterval(struct pp_instance *ppi,
......
......@@ -9,17 +9,22 @@ There are two sets of parameters, global and specific for port/instance.
List of global parameters:
@table @t
@item --bmca=<ptp|standard|externalPortConfiguration|extPortConf|epc>
select BMCA to be used; @t{ptp=standard};
@t{externalPortConfiguration=extPortConf=epc}
@item --delta-rxm=<num64>
overwrite Master PHY delay RX (RXM);
only for slave port;
used only by White Rabbit!;
64bit value in ps;
this value is reset at link down/up
this value is reset at link down/up during to WR handshake
@item --delta-txm=<num64>
overwrite Master PHY delay TX (TXM);
only for slave port;
used only by White Rabbit!;
64bit value in ps;
this value is reset at link down/up
this value is reset at link down/up during to WR handshake
@item --diags=<num>
change PPSI's global diagnostics to @t{<num>};
......@@ -110,6 +115,15 @@ Parameters specific for PPSi instance:
@item --extension=<none|wr|l1s|l1sync>
sets the extension; extension has to be supported by a selected profile
@item --externalPortConfiguration-desired-state=<...>
@itemx --epc-desired-state=<...>
sets the desired state for @i{externalPortConfiguration};
valid states are:
@t{initializing}, @t{faulty}, @t{disabled}, @t{listening}, @t{pre_master},
@t{master}, @t{passive}, @t{uncalibrated}, @t{slave};
NOTE: to make this setting useful make sure that the BMCA is set to
@t{epc} (or @t{externalPortConfiguration})
@item --ingress-latency=<num64>
sets the ingress latency; 64bit value in ps is kept over link down/up;
see also @t{--egress-latency}
......
......@@ -303,6 +303,7 @@ extern const struct pp_time_operations unix_time_ops;
extern int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *opts);
extern int pp_close_globals(struct pp_globals *ppg);
extern int pp_set_bmca(struct pp_globals *ppg, int bmca);
extern int pp_set_externalPortConfiguration_disable(struct pp_globals *ppg);
extern void pp_parse_cmdline_early(int argc, char **argv);
extern int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv);
......
......@@ -11,7 +11,8 @@
int set_param_delay_coefficient64(struct pp_instance *ppi,
int64_t delay_coefficient);
void set_param_ptpVersion(struct pp_instance *ppi);
void set_param_externalPortConfiguration_desiredState(struct pp_instance *ppi,
int desiredState);
int set_param_delta_rxm64(struct pp_globals *ppg, int delta_rxm);
int set_param_delta_txm64(struct pp_globals *ppg, int delta_txm);
int set_param_egress_latency64(struct pp_instance *ppi, int64_t egress_latency);
......
......@@ -81,11 +81,12 @@ int pp_set_bmca(struct pp_globals *ppg, int bmca)
return -(bmca != PPSI_BMCA_STANDARD);
}
def->externalPortConfigurationEnabled = 0;
def->bmcaType = bmca;
if (bmca == PPSI_BMCA_EXT_PORT_CONFIG)
if (bmca == PPSI_BMCA_EXT_PORT_CONFIG) {
def->externalPortConfigurationEnabled = 1;
} else {
def->externalPortConfigurationEnabled = 0;
def->bmcaType = bmca;
}
return 0;
}
......@@ -195,6 +196,14 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
def->clockQuality.clockClass=PP_CLASS_DEFAULT;
pp_printf("PPSi: GM clock set but slave present. Clock class set to %d\n", def->clockQuality.clockClass);
}
} else {
/* Copy cfg.desiredState even if externalPortConfiguration
* is disabled. May be useful if externalPortConfiguration
* enabled in runtime and desiredState is present. */
for (i = 0; i < get_numberPorts(def); i++) {
struct pp_instance *ppi = INST(ppg, i);
ppi->externalPortConfigurationPortDS.desiredState = ppi->cfg.desiredState;
}
}
for (i = 0; i < get_numberPorts(def); i++) {
......
......@@ -284,3 +284,11 @@ int set_param_constant_asymmetry64(struct pp_instance *ppi,
return 0;
}
void set_param_externalPortConfiguration_desiredState(struct pp_instance *ppi,
int desiredState)
{
ppi->externalPortConfigurationPortDS.desiredState = desiredState;
ppi->cfg.desiredState = desiredState;
/* The actual change of a state happens in state's handling */
}
......@@ -77,6 +77,18 @@ int pp_master(struct pp_instance *ppi, void *buf, int len)
int pre = (ppi->state == PPS_PRE_MASTER);
int e = 0; /* error var, to check errors in msg handling */
/* Check if we're in the desired state when externalPortConfiguration is
* enabled. Desired state may change due to runtime reconfiguration. */
if (is_externalPortConfigurationEnabled(DSDEF(ppi))
&& ppi->externalPortConfigurationPortDS.desiredState != PPS_PRE_MASTER
&& ppi->externalPortConfigurationPortDS.desiredState != PPS_MASTER
) {
/* Jump straight away to PPS_INITIALIZING */
ppi->next_state = PPS_INITIALIZING;
ppi->next_delay = 0;
return 0;
}
/* upgrade from pre-master to master */
if (!is_externalPortConfigurationEnabled(DSDEF(ppi)) &&
pre &&
......
......@@ -68,6 +68,17 @@ int pp_passive(struct pp_instance *ppi, void *buf, int len)
int e = 0; /* error var, to check errors in msg handling */
MsgHeader *hdr = &ppi->received_ptp_header;
/* Check if we're in the desired state when externalPortConfiguration is
* enabled. Desired state may change due to runtime reconfiguration. */
if (is_externalPortConfigurationEnabled(DSDEF(ppi))
&& ppi->externalPortConfigurationPortDS.desiredState != PPS_PASSIVE
) {
/* Jump straight away to PPS_INITIALIZING */
ppi->next_state = PPS_INITIALIZING;
ppi->next_delay = 0;
return 0;
}
/* when the clock is using peer-delay, passive must send it too */
if ( is_delayMechanismP2P(ppi) )
e = pp_lib_may_issue_request(ppi);
......
......@@ -240,6 +240,18 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
Boolean uncalibrated = (ppi->state == PPS_UNCALIBRATED);
MsgHeader *hdr = &ppi->received_ptp_header;
/* Check if we're in the desired state when externalPortConfiguration is
* enabled. Desired state may change due to runtime reconfiguration. */
if (is_externalPortConfigurationEnabled(DSDEF(ppi))
&& ppi->externalPortConfigurationPortDS.desiredState != PPS_UNCALIBRATED
&& ppi->externalPortConfigurationPortDS.desiredState != PPS_SLAVE
) {
/* Jump straight away to PPS_INITIALIZING */
ppi->next_state = PPS_INITIALIZING;
ppi->next_delay = 0;
return 0;
}
/* upgrade from uncalibrated to slave or back*/
if (uncalibrated) {
if ( is_ext_hook_available(ppi,ready_for_slave) ) {
......
......@@ -26,6 +26,7 @@ static struct minipc_ch *ptp_ch;
enum input_arg {
arg_help = 'z' + 1, /* avoid conflicts with short options */
arg_autoneg,
arg_bmca,
arg_constant_asymmetry,
arg_delay_coefficient,
arg_delay_req_interval,
......@@ -34,6 +35,7 @@ enum input_arg {
arg_diags,
arg_diags_inst,
arg_egress_latency,
arg_epc_desired_state,
arg_extension,
arg_ingress_latency,
arg_instance,
......@@ -50,6 +52,7 @@ static struct option long_opts[] = {
{"help", no_argument, NULL, arg_help},
{"alpha", required_argument, NULL, arg_delay_coefficient},
{"autonegotiation", required_argument, NULL, arg_autoneg},
{"bmca", required_argument, NULL, arg_bmca},
{"constant-asymmetry", required_argument, NULL, arg_constant_asymmetry},
{"delay-coefficient", required_argument, NULL, arg_delay_coefficient},
{"delay-req-interval", required_argument, NULL, arg_delay_req_interval},
......@@ -58,7 +61,9 @@ static struct option long_opts[] = {
{"diags", required_argument, NULL, arg_diags},
{"diags-inst", required_argument, NULL, arg_diags_inst},
{"egress-latency", required_argument, NULL, arg_egress_latency},
{"epc-desired-state", required_argument, NULL, arg_epc_desired_state},
{"extension", required_argument, NULL, arg_extension},
{"externalPortConfiguration-desired-state", required_argument, NULL, arg_epc_desired_state},
{"ingress-latency", required_argument, NULL, arg_ingress_latency},
{"instance", required_argument, NULL, arg_instance},
{"ppi", required_argument, NULL, arg_instance},
......@@ -83,12 +88,15 @@ void help(char *prgname)
" -h|--help - print help\n"
" -v|--verbose - verbose output\n"
"Global parameters:\n"
" --bmca=<ptp|standard|externalPortConfiguration|extPortConf|epc>\n"
" - select BMCA to used\n"
" ptp=standard; externalPortConfiguration=extPortConf=epc\n"
" --delta-rxm=<num64>\n"
" - overwrite Master PHY delay RX (RXM); only for slave port; 64bit value in ps;\n"
" this value is reset at link down/up\n"
" - overwrite Master PHY delay RX (RXM); only for slave port; applicable only for White Rabbit!\n"
" 64bit value in ps; this value is reset at link down/up\n"
" --delta-txm=<num64>\n"
" - overwrite Master PHY delay TX (TXM); only for slave port; 64bit value in ps;\n"
" this value is reset at link down/up\n"
" - overwrite Master PHY delay TX (TXM); only for slave port; applicable only for White Rabbit!\n"
" 64bit value in ps; this value is reset at link down/up\n"
" --diags=<num> - change PPSI's global diagnostics to <num>\n"
" order: FSM, Time, Frames, Servo, BMC, Extension, Configuration\n"
" --prio1=<num>\n"
......@@ -133,6 +141,13 @@ void help(char *prgname)
" see also --ingress-latency\n"
" --extension=<none|wr|l1s|l1sync>\n"
" - sets the extension; extension has to be supported by a selected profile\n"
" --externalPortConfiguration-desired-state=<initializing|faulty|disabled|listening|pre_master\n"
" |master|passive|uncalibrated|slave>\n"
" --epc-desired-state=<initializing|faulty|disabled|listening|pre_master|master|passive|uncalibrated\n"
" |slave>\n"
" - sets the desired state for externalPortConfiguration\n"
" NOTE: to make this setting useful, make sure that the BMCA is set to\n"
" epc (externalPortConfiguration)\n"
" --ingress-latency=<num64>\n"
" - sets the ingress latency; 64bit value in ps is kept over link down/up;\n"
" see also --egress-latency\n"
......@@ -389,6 +404,35 @@ int main(int argc, char *argv[])
}
break;
case arg_bmca:
if (!strcmp(optarg, "ptp")
|| !strcmp(optarg, "standard"))
tmp = PPSI_BMCA_STANDARD;
else if (!strcmp(optarg, "extPortConf")
|| !strcmp(optarg, "externalPortConfiguration")
|| !strcmp(optarg, "epc"))
tmp = PPSI_BMCA_EXT_PORT_CONFIG;
else {
fprintf(stderr, "Error setting bmca, wrong "
"value %s\n", optarg);
exit (1);
}
if (verbose)
printf("Set bmca to %s\n",
optarg);
if (tmp == PPSI_BMCA_EXT_PORT_CONFIG)
printf("NOTE: changing the role for "
"externalPortConfiguration is not "
"implemented!\n");
ret = ppsi_set_param(PPSIEXP_PARAM_BMCA_CMD, tmp);
if (ret == PPSIEXP_RET_ERROR_VAL)
printf("Unable to set bmca to %s\n",
optarg);
break;
case arg_constant_asymmetry:
/* Check if an instance is set. If not use all
* instances/ports. */
......@@ -540,6 +584,58 @@ int main(int argc, char *argv[])
}
break;
case arg_epc_desired_state:
/* Check if an instance is set. If not exit. */
check_instance(ppsi_instance);
if (!strcmp(optarg, "initializing")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_INITIALIZING;
} else if (!strcmp(optarg, "faulty")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_FAULTY;
} else if (!strcmp(optarg, "disabled")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_DISABLED;
} else if (!strcmp(optarg, "listening")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_LISTENING;
} else if (!strcmp(optarg, "pre_master")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_PRE_MASTER;
} else if (!strcmp(optarg, "master")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_MASTER;
} else if (!strcmp(optarg, "passive")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_PASSIVE;
} else if (!strcmp(optarg, "uncalibrated")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_UNCALIBRATED;
} else if (!strcmp(optarg, "slave")) {
tmp = PPSIEXP_PARAM_EPC_DESIRED_SLAVE;
} else {
fprintf(stderr, "Error setting "
"externalPortConfiguration for %s %d to"
" %s, wrong value\n",
ppsi_port == -1 ? "instance" : "port",
ppsi_instance & ~PPSIEXP_PPSI_INSTANCE_USE_PORT,
optarg);
exit (1);
}
if (verbose)
printf("Setting externalPortConfiguration for "
"%s %d to %s\n",
ppsi_port == -1 ? "instance" : "port",
ppsi_instance & ~PPSIEXP_PPSI_INSTANCE_USE_PORT,
tmp_str);
ret = ppsi_set_param_instance(
PPSIEXP_PARAM_INST_EPC_DESIRED_CMD,
ppsi_instance,
tmp);
if (ret) {
fprintf(stderr, "Error setting "
"externalPortConfiguration for %s %d to"
" %s, ret %d\n",
ppsi_port == -1 ? "instance" : "port",
ppsi_instance & ~PPSIEXP_PPSI_INSTANCE_USE_PORT,
tmp_str, ret);
exit (1);
}
break;
case arg_extension:
/* Check if an instance is set. If not exit. */
check_instance(ppsi_instance);
......@@ -703,7 +799,7 @@ int main(int argc, char *argv[])
ppsi_port == -1 ? "instance" : "port",
ppsi_instance & ~PPSIEXP_PPSI_INSTANCE_USE_PORT,
tmp_str);
ret = ppsi_set_param_instance(
ret = ppsi_set_param_instance(
PPSIEXP_PARAM_INST_PROFILE_CMD,
ppsi_instance,
tmp);
......@@ -727,7 +823,7 @@ int main(int argc, char *argv[])
ppsi_port == -1 ? "instance" : "port",
ppsi_instance & ~PPSIEXP_PPSI_INSTANCE_USE_PORT,
tmp);
ret = ppsi_set_param_instance(
ret = ppsi_set_param_instance(
PPSIEXP_PARAM_INST_SYNC_INT_CMD,
ppsi_instance,
tmp);
......