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

PPSI configuration enhancement

- Assembly_ppi_conf.sh script is able to generate JSON ppsi.conf format
- New parameters in ppsi.conf. Some parameters moved at ppsi instance
level
- port timing configuration in Kconfig moved in KConfig_port_timing.in
file. A file generator 'gen_kconfig_port_timing.sh'is used to generate
it.
- HAL upgraded to use the new dot-config file format. Mode ( auto,
master,...) removed from HAL.
- ppsi-pre.conf: Set empty because the new generated ppsi.conf always
define clock-class and clock accuracy.
parent df02f683
......@@ -387,139 +387,7 @@ config KEEP_ROOTFS
endmenu
menu "Port Timing Configuration"
config PORT01_PARAMS
string "Parameters for port 1"
default "name=wri1,proto=raw,tx=223897,rx=226273,role=slave,ext=WR,dm=e2e,monitor=y,fiber=0" if TIME_BC
default "name=wri1,proto=raw,tx=223897,rx=226273,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
This item, and the following ones, are used to assign the tx and rx
constant delays (likely from calibration), protocol type (raw or udp),
port roles, type of fiber (number referring to the corresponding
FIBERXX_PARAMS) and vlan configuration of PPSi for each of the ports.
Please refer to the user manual for more information.
"role" can be one of the following:
- master - configure port as a master
- slave - configure port as a slave
- auto - when a port is connected to master behave as a slave,
otherwise behave as master
- non-wr - (obsolete) don't report problems with this port via SNMP
like SFP not in DB, copper SFP connected, non 1GB SFP
etc.
- none - disable White Rabbit and PTP on a port
"ext" (extension) can be one of the following:
- WR - use White Rabbit as an extension on this port (default)
- none - no extension on this port
"dm" (delay mechanism) can be one of the following:
- e2e - end to end (default)
- p2p - peer to peer
"monitor" option to disable ("n") or enable ("y") triggering errors in SNMP on a port; "y" by default
config PORT02_PARAMS
string "Parameters for port 2"
default "name=wri2,proto=raw,tx=224037,rx=226377,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT03_PARAMS
string "Parameters for port 3"
default "name=wri3,proto=raw,tx=224142,rx=226638,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT04_PARAMS
string "Parameters for port 4"
default "name=wri4,proto=raw,tx=224313,rx=226471,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT05_PARAMS
string "Parameters for port 5"
default "name=wri5,proto=raw,tx=224455,rx=227679,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT06_PARAMS
string "Parameters for port 6"
default "name=wri6,proto=raw,tx=224603,rx=227891,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT07_PARAMS
string "Parameters for port 7"
default "name=wri7,proto=raw,tx=224761,rx=228055,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT08_PARAMS
string "Parameters for port 8"
default "name=wri8,proto=raw,tx=224898,rx=228178,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT09_PARAMS
string "Parameters for port 9"
default "name=wri9,proto=raw,tx=225069,rx=228277,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT10_PARAMS
string "Parameters for port 10"
default "name=wri10,proto=raw,tx=225245,rx=228435,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT11_PARAMS
string "Parameters for port 11"
default "name=wri11,proto=raw,tx=225463,rx=228963,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT12_PARAMS
string "Parameters for port 12"
default "name=wri12,proto=raw,tx=225645,rx=229107,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT13_PARAMS
string "Parameters for port 13"
default "name=wri13,proto=raw,tx=225801,rx=229225,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT14_PARAMS
string "Parameters for port 14"
default "name=wri14,proto=raw,tx=225983,rx=229463,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT15_PARAMS
string "Parameters for port 15"
default "name=wri15,proto=raw,tx=226208,rx=229850,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT16_PARAMS
string "Parameters for port 16"
default "name=wri16,proto=raw,tx=226393,rx=229907,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT17_PARAMS
string "Parameters for port 17"
default "name=wri17,proto=raw,tx=226594,rx=230106,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
config PORT18_PARAMS
string "Parameters for port 18"
default "name=wri18,proto=raw,tx=226737,rx=230273,role=master,ext=WR,dm=e2e,monitor=y,fiber=0"
help
Please check the help of PORT01_PARAMS
endmenu
source Kconfig_port_timing.in
menu "SFP and Media Timing Configuration"
......@@ -716,10 +584,19 @@ config PTP_CONF_URL
For example: tftp://morgana/wrs-IPADDR-ppsi.conf
menu "PTP options"
depends on PTP_PORT_PARAMS
config PTP_OPT_OVERWRITE_CLOCK_CLASS
boolean "Overwrite default clock-class"
default FALSE
help
The clock class is automatically set depending of the timing mode.
This option allows to overwrite the default value.
config PTP_OPT_CLOCK_CLASS
string "clock-class"
int "clock-class"
default 248
range 0 255
depends on PTP_OPT_OVERWRITE_CLOCK_CLASS
help
An attribute defining the TAI traceability, synchronization state and
expected performance of the time or frequency distributed by a
......@@ -729,7 +606,9 @@ config PTP_OPT_CLOCK_CLASS
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_CLOCK_ACCURACY
string "clock-accuracy"
int "clock-accuracy"
range 0 255
default "254"
help
An attribute defining the accuracy of the Local Clock (e.g. local
oscillator) of a Boundary Clock or Ordinary Clock.
......@@ -738,7 +617,9 @@ config PTP_OPT_CLOCK_ACCURACY
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_CLOCK_ALLAN_VARIANCE
string "clock-allan-variance/offsetScaledLogVariance"
int "clock-allan-variance/offsetScaledLogVariance"
default "65535"
range 0 65535
help
An attribute defining the stability of the Local Clock of a
Boundary Clock or Ordinary Clock.
......@@ -747,44 +628,29 @@ config PTP_OPT_CLOCK_ALLAN_VARIANCE
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_DOMAIN_NUMBER
string "domain-number"
int "domain-number"
default 0
range 0 255
help
A domain consists of one or more PTP devices communicating with each
other as defined by the PTP protocol. A domain defines the scope of
PTP message communication, state, operations, data sets, and
timescale. PTP devices may participate in multiple domains.
For more details please refer to the IEEE 1588-2008 standard.
If set, this configuration item overwrites the default value from
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_ANNOUNCE_INTERVAL
string "announce-interval"
help
The mean time interval between transmissions of successive
Announce messages.
If set, this configuration item overwrites the default value from
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_SYNC_INTERVAL
string "sync-interval"
help
The mean time interval between transmission of successive
Sync messages, i.e., the sync-interval, when transmitted
as multicast messages. The value is the logarithm to the base 2.
If set, this configuration item overwrites the default value from
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_PRIORITY1
string "priority1"
int "priority1"
default "128"
range 0 255
help
A user configurable designation that a clock belongs to an ordered
set of PTP devices from which a PTP Master is selected.
For more details please refer to the IEEE 1588-2008 standard
If set, this configuration item overwrites the default value from
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_PRIORITY2
string "priority2"
int "priority2"
default "128"
range 0 255
help
A user configurable designation that provides finer grained ordering
among otherwise equivalent PTP devices.
......@@ -792,8 +658,18 @@ config PTP_OPT_PRIORITY2
If set, this configuration item overwrites the default value from
ppsi-pre.conf during generation of ppsi.conf.
config PTP_OPT_OVERWRITE_TIME_SOURCE
boolean "Overwrite default time-source"
default FALSE
help
The clock class is automatically set depending of the timing mode.
This option allows to overwrite the default value.
config PTP_OPT_TIME_SOURCE
string "time-source"
int "time-source"
default 160
range 0 255
depends on PTP_OPT_OVERWRITE_TIME_SOURCE
help
This information-only attribute indicates the source of time used
by the grandmaster (or free-running master).
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/bin/bash
# Jean-Claude BAU @CERN
# script to generate Kconfig timing port configuration.
#
# Parameters:
# -o file Overwrite the default output file name
#
OUTPUT_FILE="Kconfig_port_timing.in"
script_name="$0"
#decode script parameters
while getopts o: option
do
case "${option}" in
"o") OUTPUT_FILE=${OPTARG};;
esac
done
function print_header() {
echo -e "menu \"Port Timing Configuration\"" >$OUTPUT_FILE
echo -e "config PTP_OPT_EXT_PORT_CONFIG_ENABLED" >>$OUTPUT_FILE
echo -e "\tbool \"externalPortConfigurationEnabled\" " >>$OUTPUT_FILE
echo -e "\tdefault true" >>$OUTPUT_FILE
echo -e "\thelp" >>$OUTPUT_FILE
echo -e "\t This option is used by the high accuracy profile to force the port state." >>$OUTPUT_FILE
echo -e "\t For more details please refer to the IEEE 1588-20019 (clause 17.6.2)" >>$OUTPUT_FILE
}
function print_footer() {
echo -e "\nendmenu" >>$OUTPUT_FILE
}
function print_port_header() {
#remove leading zero from i_port (params has numbers with leading zero,
#interface names are without leading zero)
local portIdx=$(expr $1 + 0)
echo -e "\nmenu \"PORT ${portIdx}\"" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_PARAMS" >>$OUTPUT_FILE
echo -e "\tstring \"Port parameters\"" >>$OUTPUT_FILE
echo -e "\tdefault \"iface=wri${portIdx},fiber=0,asym=0\"" >>$OUTPUT_FILE
echo -e "\thelp" >>$OUTPUT_FILE
echo -e "\t This item, and the following ones, are used to define physical ports." >>$OUTPUT_FILE
echo -e "\t An empty string means no instance declaration." >>$OUTPUT_FILE
echo -e "\t Please refer to the user manual for more information." >>$OUTPUT_FILE
echo -e "\t \"iface\" - the interface name" >>$OUTPUT_FILE
echo -e "\t \"fiber\" - the type of fiber (number referring to the corresponding " >>$OUTPUT_FILE
echo -e "\t FIBERXX_PARAMS)" >>$OUTPUT_FILE
echo -e "\t \"asym\" - the constant delay asymmetry" >>$OUTPUT_FILE
echo -e "\nchoice" >>$OUTPUT_FILE
echo -e "\tprompt \"Number of port instances\"" >>$OUTPUT_FILE
echo -e "\tdefault PORT${1}_INSTANCE_COUNT_1" >>$OUTPUT_FILE
echo -e "\tconfig PORT${1}_INSTANCE_COUNT_0" >>$OUTPUT_FILE
echo -e "\t bool \"0\"" >>$OUTPUT_FILE
echo -e "\tconfig PORT${1}_INSTANCE_COUNT_1" >>$OUTPUT_FILE
echo -e "\t bool \"1\"" >>$OUTPUT_FILE
echo -e "\tconfig PORT${1}_INSTANCE_COUNT_2" >>$OUTPUT_FILE
echo -e "\t bool \"2\"" >>$OUTPUT_FILE
echo -e "endchoice" >>$OUTPUT_FILE
}
function print_port_footer() {
echo -e "\nendmenu" >>$OUTPUT_FILE
}
function print_instance_header() {
#remove leading zero from i_port (params has numbers with leading zero,
#interface names are without leading zero)
local portIdx=$(expr $1 + 0)
local instIdx=$(expr $2 + 0)
if [ $instIdx -eq 1 ] ; then prof=WR ; else prof=HA ; fi
local tx=${port_tx[$1]}
local rx=${port_rx[$1]}
echo -e "\nmenu \"Instance ${instIdx}\"" >>$OUTPUT_FILE
if [ $instIdx -eq 1 ] ; then
echo -e " depends on PORT${1}_INSTANCE_COUNT_1 || PORT${1}_INSTANCE_COUNT_2 " >>$OUTPUT_FILE
else
echo -e " depends on PORT${1}_INSTANCE_COUNT_2 " >>$OUTPUT_FILE
fi
echo -e "\nconfig PORT${1}_INST${2}" >>$OUTPUT_FILE
echo -e " string \"Port instance 1\"" >>$OUTPUT_FILE
echo -e " default \"tx=${tx},rx=${rx},proto=raw,prof=${prof},dm=e2e,monitor=y\"" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " This item, and the following ones, are used to define PPSI instances." >>$OUTPUT_FILE
echo -e " An empty string means no instance declaration." >>$OUTPUT_FILE
echo -e " Please refer to the user manual for more information." >>$OUTPUT_FILE
echo -e " \"proto\" can be one of the following:" >>$OUTPUT_FILE
echo -e " - raw - raw ethernet protocol" >>$OUTPUT_FILE
echo -e " - udp - UDP protocol" >>$OUTPUT_FILE
echo -e " \"tx\" defines the transmission constant delay (ps)" >>$OUTPUT_FILE
echo -e " \"rx\" defines the reception constant delay (ps) " >>$OUTPUT_FILE
echo -e " \"prof\" (profile) can be one of the following:" >>$OUTPUT_FILE
echo -e " - WR - use White Rabbit (default)" >>$OUTPUT_FILE
echo -e " - HA - use High accuracy profile" >>$OUTPUT_FILE
echo -e " - none - no extension on this port" >>$OUTPUT_FILE
echo -e " \"dm\" (delay mechanism) can be one of the following:" >>$OUTPUT_FILE
echo -e " - e2e - end to end (default)" >>$OUTPUT_FILE
echo -e " - p2p - peer to peer" >>$OUTPUT_FILE
echo -e " \"monitor\" option to disable (\"n\") or enable (\"y\") triggering errors in SNMP on a port; \"y\" by default" >>$OUTPUT_FILE
echo -e "\nchoice" >>$OUTPUT_FILE
echo -e " prompt \"Desired state\"" >>$OUTPUT_FILE
echo -e " depends on PTP_OPT_EXT_PORT_CONFIG_ENABLED" >>$OUTPUT_FILE
[[ $portIdx -eq 1 ]] && echo -e " default PORT${1}_INST${2}_DESIRADE_STATE_SLAVE if TIME_BC" >>$OUTPUT_FILE
echo -e " default PORT${1}_INST${2}_DESIRADE_STATE_MASTER" >>$OUTPUT_FILE
echo -e " config PORT${1}_INST${2}_DESIRADE_STATE_MASTER" >>$OUTPUT_FILE
echo -e " bool \"Master\"" >>$OUTPUT_FILE
echo -e " config PORT${1}_INST${2}_DESIRADE_STATE_SLAVE" >>$OUTPUT_FILE
echo -e " bool \"Slave\"" >>$OUTPUT_FILE
echo -e " config PORT${1}_INST${2}_DESIRADE_STATE_PASSIVE" >>$OUTPUT_FILE
echo -e " bool \"Passive\"" >>$OUTPUT_FILE
echo -e "endchoice" >>$OUTPUT_FILE
echo -e "\nchoice" >>$OUTPUT_FILE
echo -e " prompt \"BMCA mode\"" >>$OUTPUT_FILE
echo -e " depends on PTP_OPT_EXT_PORT_CONFIG_ENABLED!=y" >>$OUTPUT_FILE
echo -e " default PORT${1}_INST${2}_BMODE_MASTER_ONLY if TIME_BC" >>$OUTPUT_FILE
echo -e " default PORT${1}_INST${2}_BMODE_AUTO" >>$OUTPUT_FILE
echo -e " config PORT${1}_INST${2}_BMODE_MASTER_ONLY" >>$OUTPUT_FILE
echo -e " bool \"MasterOnly\"" >>$OUTPUT_FILE
echo -e " config PORT${1}_INST${2}_BMODE_AUTO" >>$OUTPUT_FILE
echo -e " bool \"Auto\"" >>$OUTPUT_FILE
echo -e "endchoice" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_ANNOUNCE_INTERVAL" >>$OUTPUT_FILE
echo -e " int \"announce-interval\" " >>$OUTPUT_FILE
echo -e " default 1" >>$OUTPUT_FILE
echo -e " range 0 4" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The mean time interval between transmissions of successive" >>$OUTPUT_FILE
echo -e " Announce messages. The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be 0 to 4." >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_ANNOUNCE_RECEIPT_TIMEOUT" >>$OUTPUT_FILE
echo -e " int \"announce-receipt-timeout\"" >>$OUTPUT_FILE
echo -e " default 3" >>$OUTPUT_FILE
echo -e " range 2 255" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The announe receipt timeout specifies the number of announceIntervals " >>$OUTPUT_FILE
echo -e " that must pass without receipt of an Announce message before the " >>$OUTPUT_FILE
echo -e " occurrence of the event ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES." >>$OUTPUT_FILE
echo -e " The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be 2 to 255" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_SYNC_INTERVAL" >>$OUTPUT_FILE
echo -e " int \"sync-interval\"" >>$OUTPUT_FILE
echo -e " default 0" >>$OUTPUT_FILE
echo -e " range -1 1" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The mean time interval between transmission of successive" >>$OUTPUT_FILE
echo -e " Sync messages, i.e., the sync-interval, when transmitted" >>$OUTPUT_FILE
echo -e " as multicast messages. The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be -1 to +1" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_MIN_DELAY_REQ_INTERVAL" >>$OUTPUT_FILE
echo -e " int \"min-delay-req-interval\"" >>$OUTPUT_FILE
echo -e " default 0" >>$OUTPUT_FILE
echo -e " range 0 5" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The min delay request interval specifies the minimum permitted" >>$OUTPUT_FILE
echo -e " mean time interval between successive Delay_Req messages." >>$OUTPUT_FILE
echo -e " The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be 0 to 5" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_MIN_PDELAY_REQ_INTERVAL" >>$OUTPUT_FILE
echo -e " int \"min-pdelay-req-interval\"" >>$OUTPUT_FILE
echo -e " default 0" >>$OUTPUT_FILE
echo -e " range 0 5" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The min delay request interval specifies the minimum permitted" >>$OUTPUT_FILE
echo -e " mean time interval between successive Pdelay_Req messages." >>$OUTPUT_FILE
echo -e " The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be 0 to 5" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_L1SYNC_INTERVAL" >>$OUTPUT_FILE
echo -e " int \"l1sync-interval\"" >>$OUTPUT_FILE
echo -e " default 0" >>$OUTPUT_FILE
echo -e " range -4 4" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The L1Sync interval specifies the time interval" >>$OUTPUT_FILE
echo -e " between successive periodic L1_SYNC TLV." >>$OUTPUT_FILE
echo -e " The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be -4 to 4" >>$OUTPUT_FILE
echo -e "\nconfig PORT${1}_INST${2}_L1SYNC_RECEIPT_TIMEOUT" >>$OUTPUT_FILE
echo -e " int \"l1sync-receipt-timeout\"" >>$OUTPUT_FILE
echo -e " default 3" >>$OUTPUT_FILE
echo -e " range 2 10" >>$OUTPUT_FILE
echo -e " help" >>$OUTPUT_FILE
echo -e " The value of L1SyncReceiptTimeout specifies the number of elapsed " >>$OUTPUT_FILE
echo -e " L1SyncIntervals that must pass without reception of the L1_SYNC TLV " >>$OUTPUT_FILE
echo -e " before the L1_SYNC TLV reception timeout occurs." >>$OUTPUT_FILE
echo -e " The value is the logarithm to the base 2." >>$OUTPUT_FILE
echo -e " The configurable range shall be 2 to 10" >>$OUTPUT_FILE
}
function print_instance_footer() {
echo -e "\nendmenu" >>$OUTPUT_FILE
}
declare -A port_tx=(
[01]=223897 [02]=224037 [03]=224142 [04]=224313 [05]=224455 [06]=224603
[07]=224761 [08]=224898 [09]=225069 [10]=225245 [11]=225463 [12]=225645
[13]=225801 [14]=225983 [15]=226208 [16]=226393 [17]=226594 [18]=226737
)
declare -A port_rx=(
[01]=226273 [02]=226377 [03]=226638 [04]=226471 [05]=227679 [06]=227891
[07]=228055 [08]=228178 [09]=228277 [10]=228435 [11]=228963 [12]=229107
[13]=229225 [14]=229463 [15]=229850 [16]=229907 [17]=230106 [18]=230273
)
print_header
for i_port in {01..18}; do
print_port_header ${i_port}
for i_inst in {01..02}; do
print_instance_header ${i_port} ${i_inst}
print_instance_footer ${i_port} ${i_inst}
done
print_port_footer ${i_port}
done
print_footer
......@@ -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;
......
#!/bin/bash
# Adam Wujek @ CERN
# Adam Wujek & Jean-Claude BAU @CERN
# script to assembly ppsi.conf based on dot-config configuration
#
# Parameters:
# -j generate JSON format of ppsi.conf
# -o file Overwrite the default output file name
# -i file Overwrite the default input dot-config file
# -p file Overwrite the default input psi-pre file
#
PRE_FILE="/wr/etc/ppsi-pre.conf"
OUTPUT_FILE="/etc/ppsi.conf"
DOTCONFIG_FILE="/wr/etc/dot-config"
unset JSON_FORMAT
#decode script parameters
while getopts jo:i:p: option
do
case "${option}" in
"j") JSON_FORMAT=1;;
"o") OUTPUT_FILE=${OPTARG};;
"i") DOTCONFIG_FILE=${OPTARG};;
"p") PRE_FILE=$OPTARG;;
esac
done
if [ -f "$DOTCONFIG_FILE" ]; then
. "$DOTCONFIG_FILE"
......@@ -15,191 +35,522 @@ else
exit 1
fi
echo "# Autogenerated file, please don't edit." > $OUTPUT_FILE
echo "# This file will be overwritten at next boot." >> $OUTPUT_FILE
script_name="$0"
#
# This function retreive the fiber delay coefficient from
# the CONFIG_FIBER${1}_PARAMS parameter
# Parameter :
# $1 = fiber index
# Return the fiber delay coefficient
function get_fiber_delay_coeff() {
local dc=0
local fb=$1
if [ -n "$fb" ]; then # check if fiber parameter exists
if [[ "$fb" =~ ^-?[0-9]+$ ]]; then # check if fiber parameter is an integer
printf -v fb "%02d" $fb
local fiber_param=$(eval "echo \$CONFIG_FIBER${fb}_PARAMS")
if [ -n "$fiber_param" ]; then # check if the fiber exists
IFS='=' read -a fpa <<< "$fiber_param"
dc=${fpa[1]}
else
echo "$script_name: Unknown fiber=\"$fb\" in CONFIG_PORT"$i_port"_PARAMS"
fi
else
echo "$script_name: Invalid parameter fiber=\"$fb\" in CONFIG_PORT"$i_port"_PARAMS"
fi
fi
echo "$dc"
}
#
# Decode ppsi.conf 'pre' file. It is used to define or override global keys.
# Expected file format :
# - must define key/value pairs separated with a space character : 'key value'
# - empty line are allowed
# - a comment start at the beginning of the line with the character '#'
# Parameter: $1 file_to_open
#
function decode_pre_file(){
filename="$1"
# read globals entries
while IFS='' read -r line ; do
if [[ -n "$line" ]] && [[ ${line:0:1} != "#" ]] ; then
IFS=' ' read var1 var2 <<< $line
if [[ -n $var1 ]] && [[ -n $var2 ]] ; then
globals[$var1]=$var2
fi
fi
done < "$filename"
}
#
# Generate the ppsi.conf file using the default text format:
# - define key/value pairs separated with a space character : 'key value'
# - empty line are allowed
# - a comment start at the beginning of the line with the character '#'
# - port instances are separated by a empty line
#
# Parameter : $1 output_file_name
# $2 pre_file_name
function gen_ppsi_conf() {
# Read destination - stdout if not defined
output=${1:-/dev/stdout}
echo "# Autogenerated file, please don't edit." >$output
echo "# This file will be overwritten at next boot." >>$output
echo -e "\n# Globals\n" >>$output
# globals
for key in ${globals_indexes}; do
prefix=""
if [[ $key = *"${globals_not_yet_supported}"* ]] ; then
prefix="# Parameter not yet supported // "
fi
value=${globals[$key]}
if [ -n "$value" ]; then
echo "${prefix}$key $value" >>$output
fi
done
echo -e "\n\n# Port instances\n" >>$output
local size
# Physical ports
for i_port in {01..18}; do # scan all the physical ports
port_vn="port${i_port}"
# PPSI instances
for j_inst in {01..02}; do # scan all the ppsi instances for a given port
inst_vn="${port_vn}inst${j_inst}"
eval array=\( \${${inst_vn}[@]} \)
size=${#array[@]}
if [ "${size}" == "0" ] ; then
continue
fi
v="$inst_vn[name]" ; echo "port ${!v}" >>$output
v="$inst_vn[proto]"; echo "proto ${!v}" >>$output
v="$port_vn[iface]"; echo "iface ${!v}" >>$output
v="$inst_vn[masteronly]"; [[ -n "${!v}" ]] && echo "masterOnly ${!v}" >>$output
v="$inst_vn[vlan]" ; [[ -n "${!v}" ]] && echo "vlan ${!v}" >>$output
v="$inst_vn[dm]" ; [[ "${!v}" != "e2e" ]] && echo "dm ${!v}" >>$output
v="$inst_vn[prof]" ; echo "profile ${!v}" >>$output
v="$inst_vn[dstate]"; [[ -n "${!v}" ]] && echo "desiredState ${!v}" >>$output
v="$inst_vn[rx]"; echo "ingressLatency ${!v}" >>$output
v="$inst_vn[tx]"; echo "egressLatency ${!v}" >>$output
v="$port_vn[dcoeff]"; echo "delayCoefficient ${!v}" >>$output
v="$port_vn[asym]"; echo "constantAsymmetry ${!v}" >>$output
for p in $inst_opt_parameters ; do
plc=$(inst_opt_parameter_to_instance_index ${p})
v="$inst_vn[$plc]"
[[ -n "${!v}" ]] && echo "$plc ${!v}" >>$output
done
echo -n -e "\n\n" >>$output
done
done
}
#
# Generate the ppsi.conf file using a JSON format:
# {
# "globals": {
# "clock-class" : 187,
# ...
# },
# "ports" : [
# {
# "iface" : "wri1",
# ...
# "instances" : [
# {
# "name" : "wri1-i1",
# ...
# },
# { ... }
# ]
# },
# { ... }
# ]
# }
#
# Parameter : $1 output_file_name
# $2 pre_file_name
function gen_ppsi_conf_json() {
# Read destination - stdout if not defined
output=${1:-/dev/stdout}
# start globals
echo -e "{\n \"globals\": {\n" >$output
# globals
unset comma_g
for key in ${globals_indexes}; do
if [[ $key = *"${globals_not_yet_supported}"* ]] ; then
continue
fi
value=${globals[$key]}
if [ -n "$value" ]; then
[[ -n "${comma_g}" ]] && echo "," >>$output
echo -e -n " \"$key\": \"$value\"" >>$output
comma_g=1
fi
done
# end globals
echo -e -n "\n }" >>$output
# start ports
echo -e ",\n \"ports\": [" >>$output
local size
# Physical ports
for i_port in {01..18}; do # scan all the physical ports
port_vn="port${i_port}"
# start port
if [ $i_port == "01" ] ; then
echo -e " {" >>$output
else
echo -e ",\n {" >>$output
fi
v="$port_vn[iface]"; echo -e " \"iface\": \"${!v}\"," >>$output
v="$port_vn[dcoeff]"; echo -e " \"delayCoefficient\": \"${!v}\"," >>$output
v="$port_vn[asym]"; echo -e " \"constantAsymmetry\": \"${!v}\"," >>$output
# start instances
echo -e " \"instances\": [" >>$output
# PPSI instances
for j_inst in {01..02}; do # scan all the ppsi instances for a given port
inst_vn="${port_vn}inst${j_inst}"
eval array=\( \${${inst_vn}[@]} \)
size=${#array[@]}
if [ "${size}" == "0" ] ; then
continue
fi
# start instance /instances
if [ $j_inst == "01" ] ; then
# start instances
echo -e " {" >>$output
else
echo -e ",\n {" >>$output
fi
v="$inst_vn[name]" ; echo -e " \"port\": \"${!v}\"," >>$output
v="$inst_vn[rx]"; echo -e " \"ingressLatency\": \"${!v}\"," >>$output
v="$inst_vn[tx]"; echo -e " \"egressLatency\": \"${!v}\"," >>$output
v="$inst_vn[proto]"; echo -e " \"proto\": \"${!v}\"," >>$output
v="$inst_vn[masteronly]"; [[ -n "${!v}" ]] && echo -e " \"masterOnly\": \"${!v}\"," >>$output
v="$inst_vn[vlan]" ; [[ -n "${!v}" ]] && echo -e " \"vlan\": \"${!v}\"," >>$output
v="$inst_vn[dm]" ; [[ "${!v}" != "e2e" ]] && echo -e " \"dm\": \"${!v}\"," >>$output
v="$inst_vn[prof]" ; echo -e -n " \"profile\": \"${!v}\"" >>$output
v="$inst_vn[dstate]"; [[ -n "${!v}" ]] && echo -e -n ",\n \"desiredState\": \"${!v}\"" >>$output
for p in $inst_opt_parameters ; do
plc=$(inst_opt_parameter_to_instance_index ${p})
v="$inst_vn[$plc]"
[[ -n "${!v}" ]] && echo -e -n ",\n \"$plc\": \"${!v}\"" >>$output
done
# end instance
echo -e -n "\n }" >>$output
done
# end instances
echo -e "\n ]" >>$output
# end port
echo -e -n " }" >>$output
done
# end ports
echo -e "\n ]" >>$output
# end main block
echo "}" >>$output
}
#copy top of ppsi.conf
cat $PRE_FILE >> $OUTPUT_FILE
function inst_opt_parameter_to_instance_index() {
echo `echo $1 | tr '[:upper:]_' '[:lower:]-'`
}
globals_indexes='clock-class clock-accuracy clock-allan-variance domain-number priority1 priority2 time-source externalPortConfigurationEnabled'
globals_not_yet_supported='time-source'
port_indexes='fiber asym dcoeff iface'
instance_indexes='rx tx proto prof dm monitor dstate masteronly'
inst_opt_parameters='ANNOUNCE_INTERVAL ANNOUNCE_RECEIPT_TIMEOUT SYNC_INTERVAL MIN_DELAY_REQ_INTERVAL MIN_PDELAY_REQ_INTERVAL L1SYNC_INTERVAL L1SYNC_RECEIPT_TIMEOUT'
echo "${x}" | tr '_' '-' | sed -e "s/\b\(.\)/\u\1/g"
# update instance_indexes with inst_opt_parameters
instance_indexes="$instance_indexes `echo ${inst_opt_parameters} | tr '[:upper:]' '[:lower:]'`"
if [ -n "$CONFIG_PTP_OPT_CLOCK_CLASS" ]; then
echo clock-class "$CONFIG_PTP_OPT_CLOCK_CLASS" >> $OUTPUT_FILE
declare -A globals
# Read specific configuration : Still use the old format - to discuss
[[ "$PRE_FILE" != "" ]] && [[ -f $PRE_FILE ]] && decode_pre_file "$PRE_FILE"
# Use default value of clock class if not overwritten or empty string
if [ -v CONFIG_PTP_OPT_OVERWRITE_CLOCK_CLASS ] && [ -n "$CONFIG_PTP_OPT_CLOCK_CLASS" ]; then
globals[clock-class]="$CONFIG_PTP_OPT_CLOCK_CLASS"
else
if [ "$CONFIG_TIME_GM" = "y" ]; then
echo clock-class 6 >> $OUTPUT_FILE
globals[clock-class]=6
fi
if [ "$CONFIG_TIME_FM" = "y" ]; then
echo clock-class 52 >> $OUTPUT_FILE
globals[clock-class]=52
fi
if [ "$CONFIG_TIME_BC" = "y" ]; then
echo clock-class 248 >> $OUTPUT_FILE
globals[clock-class]=248
fi
fi
if [ -n "$CONFIG_PTP_OPT_CLOCK_ACCURACY" ]; then
echo clock-accuracy "$CONFIG_PTP_OPT_CLOCK_ACCURACY" >> $OUTPUT_FILE
globals[clock-accuracy]="$CONFIG_PTP_OPT_CLOCK_ACCURACY"
fi
if [ -n "$CONFIG_PTP_OPT_CLOCK_ALLAN_VARIANCE" ]; then
echo clock-allan-variance "$CONFIG_PTP_OPT_CLOCK_ALLAN_VARIANCE" >> $OUTPUT_FILE
globals[clock-allan-variance]="$CONFIG_PTP_OPT_CLOCK_ALLAN_VARIANCE"
fi
if [ -n "$CONFIG_PTP_OPT_DOMAIN_NUMBER" ]; then
echo domain-number "$CONFIG_PTP_OPT_DOMAIN_NUMBER" >> $OUTPUT_FILE
globals[domain-number]="$CONFIG_PTP_OPT_DOMAIN_NUMBER"
fi
if [ -n "$CONFIG_PTP_OPT_ANNOUNCE_INTERVAL" ]; then
echo announce-interval "$CONFIG_PTP_OPT_ANNOUNCE_INTERVAL" >> $OUTPUT_FILE
globals[announce-interval]="$CONFIG_PTP_OPT_ANNOUNCE_INTERVAL"
fi
if [ -n "$CONFIG_PTP_OPT_SYNC_INTERVAL" ]; then
echo sync-interval "$CONFIG_PTP_OPT_SYNC_INTERVAL" >> $OUTPUT_FILE
globals[sync-interval]="$CONFIG_PTP_OPT_SYNC_INTERVAL"
fi
if [ -n "$CONFIG_PTP_OPT_PRIORITY1" ]; then
echo priority1 "$CONFIG_PTP_OPT_PRIORITY1" >> $OUTPUT_FILE
globals[priority1]="$CONFIG_PTP_OPT_PRIORITY1"
fi
if [ -n "$CONFIG_PTP_OPT_PRIORITY2" ]; then
echo priority2 "$CONFIG_PTP_OPT_PRIORITY2" >> $OUTPUT_FILE
globals[priority2]="$CONFIG_PTP_OPT_PRIORITY2"
fi
if [ -n "$CONFIG_PTP_OPT_TIME_SOURCE" ]; then
echo time-source "$CONFIG_PTP_OPT_TIME_SOURCE" >> $OUTPUT_FILE
if [ -v CONFIG_PTP_OPT_OVERWRITE_TIME_SOURCE ] && [ -n "$CONFIG_PTP_OPT_TIME_SOURCE" ]; then
globals[time-source]="$CONFIG_PTP_OPT_TIME_SOURCE"
else
if [ "$CONFIG_TIME_GM" = "y" ]; then
globals[time-source]=16 # ATOMIC_CLOCK
fi
if [ "$CONFIG_TIME_FM" = "y" ]; then
globals[time-source]=160 # INTERNAL_OSCILLATOR
fi
if [ "$CONFIG_TIME_BC" = "y" ]; then
globals[time-source]=160 # INTERNAL_OSCILLATOR
fi
fi
if [ -n "$CONFIG_PTP_OPT_EXT_PORT_CONFIG_ENABLED" ]; then
globals[externalPortConfigurationEnabled]="$CONFIG_PTP_OPT_EXT_PORT_CONFIG_ENABLED"
fi
for i_port in {01..18}; do # scan all the physical ports
# 2 new lines
echo -n -e "\n\n" >> $OUTPUT_FILE
port_vn="port${i_port}"
declare -A $port_vn
for i_zero in {01..18};do
# unset parametes
unset p_name
unset p_proto
unset p_role
unset p_ext
# delay mechanism
unset p_dm
unset p_monitor
#remove leading zero from i_port (params has numbers with leading zero,
#interface names are without leading zero)
i_port_int=$(expr $i_port + 0)
# parse parameters
param_line=$(eval "echo \$CONFIG_PORT"$i_zero"_PARAMS")
IFS_OLD=$IFS
IFS=','
port_key="CONFIG_PORT${i_port}_PARAMS"
port_key_value=${!port_key}
# save pairs into array
pair_array=($param_line)
IFS=$IFS_OLD
IFS=',' read -a pair_array <<< "${port_key_value}"
for pair in ${pair_array[@]}
do
# split pairs
IFS='=' read param value <<< "$pair"
case "$param" in
"name")
p_name="$value";;
"proto")
p_proto="$value";;
"role")
p_role="$value";;
"ext")
p_ext="$value";;
"dm")
p_dm="$value";;
"monitor")
# read by SNMP directly from the config
continue;;
"rx"|"tx"|"fiber")
continue;;
"fiber")
v="$port_vn[fiber]"
eval ${v}="$value"
v="$port_vn[dcoeff]"
eval ${v}=$(get_fiber_delay_coeff $value)
;;
"asym")
v="$port_vn[asym]"
eval ${v}="$value"
;;
"iface")
v="$port_vn[iface]"
eval ${v}="$value"
;;
*)
echo "$0: Invalid parameter $param in CONFIG_PORT"$i_zero"_PARAMS" ;;
echo "$script_name: Invalid parameter $param in ${port_key}" ;;
esac
done
for j_inst in {01..02}; do # scan all the ppsi instances for a given port
# if role "none" skip port configuration
if [ "$p_role" == "none" ]; then
continue
fi
#remove leading zero from i_zero (params has numbers with leading zero,
#interface names are without leading zero)
i=$(expr $i_zero + 0)
if [ -n "$p_proto" ]; then
echo "port wri$i-$p_proto" >> $OUTPUT_FILE
echo "proto $p_proto" >> $OUTPUT_FILE
else
echo "port wri$i-raw" >> $OUTPUT_FILE
fi
echo "iface wri$i" >> $OUTPUT_FILE
if [ -n "$p_role" ]; then
echo "role $p_role" >> $OUTPUT_FILE
else
echo "$0: Role not defined in CONFIG_PORT"$i_zero"_PARAMS"
fi
if [ "${p_ext,,}" = "wr" ]; then # lower case
echo "extension whiterabbit" >> $OUTPUT_FILE
# add HA one day...
# elif [ "${p_ext,,}" = "ha" ]; then # lower case
# echo "extension whiterabbit" >> $OUTPUT_FILE
elif [ "${p_ext,,}" = "none" ]; then # lower case
# do nothing
echo "# no extension" >> $OUTPUT_FILE
elif [ -n "$p_ext" ]; then
echo "$0: Invalid parameter ext=\"$p_ext\" in CONFIG_PORT"$i_zero"_PARAMS"
else
# default
echo "extension whiterabbit" >> $OUTPUT_FILE
fi
#remove leading zero from i_port (params has numbers with leading zero,
#interface names are without leading zero)
j_inst_int=$(expr $j_inst + 0)
inst_count="CONFIG_PORT${i_port}_INSTANCE_COUNT_`expr ${j_inst_int} - 1`"
inst_count_value=$(eval "echo \$${inst_count}")
if [ -n "${inst_count_value}" ]; then
break # number of defined instances reached
fi
if [ "${p_dm,,}" = "p2p" ]; then # lower case
echo "mechanism p2p" >> $OUTPUT_FILE
elif [ "${p_dm,,}" = "e2e" ]; then # lower case
# do nothing
true
elif [ -n "$p_dm" ]; then
echo "$0: Invalid parameter dm=\"$p_dm\" in CONFIG_PORT"$i_zero"_PARAMS"
fi
# Set default values
tx=0
rx=0
inst_vn="${port_vn}inst${j_inst}"
declare -A $inst_vn
inst_key="CONFIG_PORT${i_port}_INST${j_inst}"
inst_key_value=${!inst_key}
IFS=',' read -a inst_pair_array <<< "${inst_key_value}"
# add vlans
if [ "$CONFIG_VLANS_ENABLE" = "y" ]; then
unset ppsi_vlans;
unset port_mode_access;
unset port_mode_trunk;
unset port_mode_unqualified;
unset port_mode_disabled;
# check port mode
port_mode_access=$(eval "echo \$CONFIG_VLANS_PORT"$i_zero"_MODE_ACCESS")
port_mode_trunk=$(eval "echo \$CONFIG_VLANS_PORT"$i_zero"_MODE_TRUNK")
port_mode_unqualified=$(eval "echo \$CONFIG_VLANS_PORT"$i_zero"_MODE_UNQUALIFIED")
port_mode_disabled=$(eval "echo \$CONFIG_VLANS_PORT"$i_zero"_MODE_DISABLED")
# check port mode
if [ "$port_mode_access" = "y" ]; then
ppsi_vlans=$(eval "echo \$CONFIG_VLANS_PORT"$i_zero"_VID")
# use "&> /dev/null" to avoid error when $ppsi_vlans
# is not a number
if [ "$ppsi_vlans" -ge 0 ] &> /dev/null \
&& [ "$ppsi_vlans" -le 4094 ] &> /dev/null; then
echo "vlan $ppsi_vlans" >> $OUTPUT_FILE
else
echo "$0: Wrong value \"$ppsi_vlans\" in CONFIG_VLANS_PORT"$i_zero"_VID"
continue;
for pair in ${inst_pair_array[@]}
do
# split pairs
IFS='=' read param value <<< "$pair"
case "$param" in
"tx")
v="$inst_vn[tx]"
eval ${v}="$value"
;;
"rx")
v="$inst_vn[rx]"
eval ${v}="$value"
;;
"proto")
v="$inst_vn[proto]"
eval ${v}="${value,,}"
;;
"ext" | "prof")
v="$inst_vn[prof]"
eval ${v}="${value,,}"
;;
"dm")
v="$inst_vn[dm]"
eval ${v}="${value,,}"
;;
"monitor")
continue;; # read by SNMP directly from the config
*)
echo "$script_name: Invalid parameter $param in ${inst_key}" ;;
esac
done
for p in $inst_opt_parameters; do
k="${inst_key}_$p"
plc=$(inst_opt_parameter_to_instance_index ${p})
if [ -n "$k" ]; then
v="$inst_vn[${plc}]"; eval ${v}="${!k}"
fi
done
v="$inst_vn[proto]"
if [ ! -n "${!v}" ]; then
eval ${v}="raw" # proto not defined. Set it to raw by default
fi
# set the profile
v="$inst_vn[prof]"
p_prof=${!v}
if [ "${p_prof}" = "wr" ]; then
eval ${v}="whiterabbit"
elif [ "${p_prof}" = "ha" ]; then
eval ${v}="highaccuracy"
elif [ "${p_prof}" = "none" ]; then
# do nothing
eval ${v}="ptp" >> $OUTPUT_FILE
p_prof="ptp"
elif [ -n "$p" ]; then
echo "$script_name: Invalid parameter prof=\"$p\" in ${inst_key}"
eval ${v}="highaccuracy"
p_prof="ha"
else
# default
eval ${v}="highaccuracy"
p_prof="ha"
fi
# define instance name
v="$port_vn[iface]"; p_iface=${!v}
v="$inst_vn[proto]"; p_proto=${!v}
v="$inst_vn[name]"; eval ${v}="${p_iface}-${j_inst_int}-${p_prof}-${p_proto}"
# if extPortConfiguration enabled, get the desired state
if [ "$CONFIG_PTP_OPT_EXT_PORT_CONFIG_ENABLED" == 'y' ] ; then
v="$inst_vn[dstate]";
eval ${v}="passive" # default value
k="${inst_key}_DESIRADE_STATE_SLAVE"; [ "${!k}" == 'y' ] && eval ${v}="slave"
k="${inst_key}_DESIRADE_STATE_MASTER"; [ "${!k}" == 'y' ] && eval ${v}="master"
else
v="$inst_vn[masteronly]";
k="${inst_key}_BMODE_MASTER_ONLY"; [ "$k" == 'y' ] && eval ${v}="y"
fi
# set delay mechanism
v="$inst_vn[dm]"
p=${!v}
if [ "${p}" = "p2p" -o "${p}" = "e2e" ]; then
# do nothing
true
elif [ -n "${p}" ]; then
echo "$script_name: Invalid parameter dm=\"${p}\" in ${inst_key}"
fi
if [ "$port_mode_trunk" = "y" ] \
|| [ "$port_mode_disabled" = "y" ] \
|| [ "$port_mode_unqualified" = "y" ]; then
ppsi_vlans=$(eval "echo \$CONFIG_VLANS_PORT"$i_zero"_VID")
if [ -n "$ppsi_vlans" ]; then
mod_vlans=${ppsi_vlans//;/,}
echo "vlan $mod_vlans" >> $OUTPUT_FILE
# add vlans
if [ "$CONFIG_VLANS_ENABLE" = "y" ]; then
unset ppsi_vlans;
unset port_mode_access;
unset port_mode_trunk;
unset port_mode_unqualified;
unset port_mode_disabled;
# check port mode
port_mode_access=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_ACCESS")
port_mode_trunk=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_TRUNK")
port_mode_unqualified=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_UNQUALIFIED")
port_mode_disabled=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_DISABLED")
# check port mode
if [ "$port_mode_access" = "y" ]; then
ppsi_vlans=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_VID")
# use "&> /dev/null" to avoid error when $ppsi_vlans
# is not a number
if [ "$ppsi_vlans" -ge 0 ] &> /dev/null \
&& [ "$ppsi_vlans" -le 4094 ] &> /dev/null; then
v="$inst_vn[vlan]"; eval ${v}="$ppsi_vlans"
else
echo "$script_name: Wrong value \"$ppsi_vlans\" in CONFIG_VLANS_PORT"$i_port"_VID"
continue;
fi
fi
if [ "$port_mode_trunk" = "y" ] \
|| [ "$port_mode_disabled" = "y" ] \
|| [ "$port_mode_unqualified" = "y" ]; then
ppsi_vlans=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_VID")
if [ -n "$ppsi_vlans" ]; then
mod_vlans=${ppsi_vlans//;/,}
v="$inst_vn[vlan]"; eval ${v}="$mod_vlans"
fi
fi
fi
fi
done # scan all the ppsi instances in a port
done # scan all the physical ports
# separate ports
echo "" >> $OUTPUT_FILE
done
if [ -v JSON_FORMAT ] ; then
gen_ppsi_conf_json ${OUTPUT_FILE} ${PRE_FILE}
else
gen_ppsi_conf ${OUTPUT_FILE} ${PRE_FILE}
fi
......@@ -7,90 +7,90 @@ clock-accuracy 254
port wri1
iface wri1
role auto
extension whiterabbit
profile whiterabbit
port wri2
iface wri2
role auto
extension whiterabbit
profile whiterabbit
port wri3
iface wri3
role auto
extension whiterabbit
profile whiterabbit
port wri4
iface wri4
role auto
extension whiterabbit
profile whiterabbit
port wri5
iface wri5
role auto
extension whiterabbit
profile whiterabbit
port wri6
iface wri6
role auto
extension whiterabbit
profile whiterabbit
port wri7
iface wri7
role auto
extension whiterabbit
profile whiterabbit
port wri8
iface wri8
role auto
extension whiterabbit
profile whiterabbit
port wri9
iface wri9
role auto
extension whiterabbit
profile whiterabbit
port wri10
iface wri10
role auto
extension whiterabbit
profile whiterabbit
port wri11
iface wri11
role auto
extension whiterabbit
profile whiterabbit
port wri12
iface wri12
role auto
extension whiterabbit
profile whiterabbit
port wri13
iface wri13
role auto
extension whiterabbit
profile whiterabbit
port wri14
iface wri14
role auto
extension whiterabbit
profile whiterabbit
port wri15
iface wri15
role auto
extension whiterabbit
profile whiterabbit
port wri16
iface wri16
role auto
extension whiterabbit
profile whiterabbit
port wri17
iface wri17
role auto
extension whiterabbit
profile whiterabbit
port wri18
iface wri18
role auto
extension whiterabbit
profile whiterabbit
# Global settings
clock-class 187
clock-accuracy 254
# This file is used to declare global settings which are not defined or left empty
# in the dot-config file.
......@@ -93,10 +93,6 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
*/
wrsPortStatusTable_array[i].wrsPortStatusLink =
1 + state_up(port_state->state);
/* values defined as
* WRS_PORT_STATUS_CONFIGURED_MODE_* */
wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode =
port_state->mode;
if (port_state->state == HAL_PORT_STATE_DISABLED) {
wrsPortStatusTable_array[i].wrsPortStatusSfpError =
WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN;
......
......@@ -117,7 +117,8 @@ static int hal_port_check_presence(const char *if_name, unsigned char *mac)
static int hal_port_init(int index)
{
struct hal_port_state *p = &ports[index];
char name[128], s[128];
int i;
char name[128];
int val, error;
int port_i;
......@@ -128,7 +129,7 @@ static int hal_port_init(int index)
hal_port_reset_state(p);
/* read dot-config values for this index, starting from name */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "name", LIBWR_STRING,
error = libwr_cfg_convert2("PORT%02i_PARAMS", "iface", LIBWR_STRING,
name, port_i);
if (error)
return -1;
......@@ -141,21 +142,38 @@ static int hal_port_init(int index)
p->state = HAL_PORT_STATE_DISABLED;
p->in_use = 1;
/* Search an instance using the WR profile */
for (i=1; i<=2; i++) {
char str[32];
if ( !(error = libwr_cfg_convert2("PORT%02i_INST%02i", "prof", LIBWR_STRING,
str, port_i,i))) {
if ( strcasecmp("WR",str)==0 )
break; // Found
}
}
val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "tx", LIBWR_INT,
&val, port_i);
if (error)
pr_error("port %i (%s): no \"tx=\" specified\n",
port_i, name);
p->calib.phy_tx_min = val;
if ( !error ) {
// WR instance found
val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_INST%02i", "tx", LIBWR_INT,
&val, port_i,i);
if (error)
pr_error("port %i (%s): no \"tx=\" specified\n",
port_i, name);
p->calib.phy_tx_min = val;
val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "rx", LIBWR_INT,
&val, port_i);
if (error)
pr_error("port %i (%s): no \"rx=\" specified\n",
error = libwr_cfg_convert2("PORT%02i_INST%02i", "rx", LIBWR_INT,
&val, port_i,i);
if (error)
pr_error("port %i (%s): no \"rx=\" specified\n",
port_i, name);
p->calib.phy_rx_min = val;
} else {
pr_error("port %i (%s): no WhiteRabbit instance defined\n",
port_i, name);
p->calib.phy_rx_min = val;
p->calib.phy_tx_min = p->calib.phy_rx_min = val;
}
p->calib.delta_tx_board = 0; /* never set */
p->calib.delta_rx_board = 0; /* never set */
......@@ -168,45 +186,6 @@ static int hal_port_init(int index)
p->t4_phase_transition = DEFAULT_T4_PHASE_TRANS;
p->clock_period = REF_CLOCK_PERIOD_PS;
/* enabling of ports is done by startup script */
{
static struct roletab { char *name; int value; } *rp, rt[] = {
{"auto", HEXP_PORT_MODE_WR_M_AND_S},
{"master", HEXP_PORT_MODE_WR_MASTER},
{"slave", HEXP_PORT_MODE_WR_SLAVE},
{"non-wr", HEXP_PORT_MODE_NON_WR},
{"none", HEXP_PORT_MODE_NONE},
{NULL, HEXP_PORT_MODE_NON_WR /* default,
* should exist and be last*/},
};
strcpy(s, "non-wr"); /* default if no string passed */
p->mode = HEXP_PORT_MODE_NON_WR;
error = libwr_cfg_convert2("PORT%02i_PARAMS", "role",
LIBWR_STRING, s, port_i);
if (error)
pr_error("port %i (%s): "
"no \"role=\" specified\n", port_i, name);
for (rp = rt; rp->name; rp++)
if (!strcasecmp(s, rp->name))
break;
p->mode = rp->value;
if (!rp->name) {
for (rp = rt; rp->name; rp++)
if (p->mode == rp->value)
break;
pr_error("port %i (%s): invalid role "
"\"%s\" specified; using mode %s\n", port_i,
name, s, rp->name);
}
pr_debug("Port %s: mode %s (%i)\n", p->name, rp->name,
p->mode);
}
/* Get fiber type */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "fiber",
LIBWR_INT, &p->fiber_index, port_i);
......@@ -941,7 +920,6 @@ static void update_sync_leds(void)
return;
for (i = 0; i < HAL_MAX_PORTS; i++) {
int ledValue;
/* Check:
* --port in use
......@@ -953,6 +931,8 @@ static void update_sync_leds(void)
if (ports[i].in_use
&& state_up(ports[i].state)
&& !strcmp(iface_name, ports[i].name)) {
int ledValue=0; /* default value */
if (update_count == servo.servo_snapshot.update_count) {
if (since_last_servo_update < 7)
since_last_servo_update++;
......@@ -960,15 +940,16 @@ static void update_sync_leds(void)
since_last_servo_update = 0;
update_count = servo.servo_snapshot.update_count;
}
/* Check:
* --port in slave mode
* --ppsi instance in slave state
* --servo is locked
* --not the standard PTP servo
* --WR of HA PTP servo
* --servo is updating
*/
ledValue=(ports[i].mode == HEXP_PORT_MODE_WR_SLAVE
ledValue=(servo.ppi->state == PPS_SLAVE
&& servo.servo_snapshot.servo_locked
&& servo.ppi->protocol_extension != PPSI_EXT_NONE
&& (servo.ppi->protocol_extension == PPSI_EXT_WR || servo.ppi->protocol_extension == PPSI_EXT_L1S)
&& since_last_servo_update < 7
) ? 1 : 0;
set_led_synced(i, ledValue);
......
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