Commit d8a817b8 authored by Adam Wujek's avatar Adam Wujek 💬

[Feature: 1101] Merge branch 'adam-vlans' adding VLANs configuration in dot-config

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents 62d2d84b 73f319c5
......@@ -276,6 +276,7 @@ config WRS_LOG_OTHER
--wrs_watchdog
--wrs_auxclk
--wrs_custom_boot_script.sh
--vlan.sh
This collective entry is to avoid number of entries in dot-config.
The string can be a pathname (e.g. /dev/kmsg) or a <facility>.<level>
spefification like "daemon.debug". An empty strings is used
......@@ -300,11 +301,11 @@ config PORT01_PARAMS
default "name=wri1,proto=raw,tx=223896,rx=226310,role=slave,fiber=0" if TIME_BC
default "name=wri1,proto=raw,tx=223896,rx=226310,role=master,fiber=0"
help
This item, and the following ones, are used to assign the
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 and type of fiber (number referring to the corresponding
FIBERXX_PARAMS) for each of the ports. Please refer to
the user manual for more information.
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
......@@ -314,6 +315,9 @@ config PORT01_PARAMS
not in DB, copper SFP connected, non 1GB SFP etc.
- none - disable White Rabbit and PTP on a portdisable White Rabbit
on a port, keep PTP
ppsi_vlans - colon separated list describing which vlans shall be
assigned to the particular ppsi instance
config PORT02_PARAMS
string "Parameters for port 2"
......@@ -858,3 +862,24 @@ config FAN_HYSTERESIS_PWM_VAL
endmenu
endmenu
menu "RTU HP mask"
config RTU_HP_MASK_ENABLE
bool "Set custom High Priority mask in RTU"
default n
help
Set the mask which priorities are considered High Priority (this
only concerns the traffic which is fast-forwarded).
config RTU_HP_MASK_VAL
string "HP mask"
default 0
depends on RTU_HP_MASK_ENABLE
help
Mask with priorities (eg. 0x9 => priority 4 and 0 are considered HP)
endmenu
source Kconfig_vlans.in
This diff is collapsed.
......@@ -1345,7 +1345,7 @@ ever erase this memory; if it happens, the system won't boot and
you'll be forced to re-flash it entirely, which requires access to the back
side of the switch..
NAND memory is used for user-data: tke boot loader configuration, the
NAND memory is used for user-data: the boot loader configuration, the
kernel and the filesystem.
This is how the memory is used:
......@@ -1652,6 +1652,11 @@ the processes (excluding the @sc{rt} subsystem).
used to pass a number of parameters to @i{rtud} and
make it perform actions.
@item rtud::hp_mask
Called by @i{rtu_stat} when setting which priorities are considered
High Priority (this only concerns the traffic which is fast-forwarded).
@end table
@c --------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -626,6 +626,10 @@ list of faults leading to a data error.
\item status of loading kernel modules
\item status of starting userspace daemons
\item status of execution of a custom boot script
\item status of setting up auxclk on connector clk2
\item status of setting up a limit on the Rx bandwidth of the traffic that
goes from WR ports to Linux (throttling)
\item status of setting up VLANs
\end{itemize}
\item [] \underline{SNMP objects}:\\
{\footnotesize
......@@ -642,6 +646,9 @@ list of faults leading to a data error.
\snmpadd{WR-SWITCH-MIB::wrsCustomBootScriptSource}\\
\snmpadd{WR-SWITCH-MIB::wrsCustomBootScriptSourceUrl}\\
\snmpadd{WR-SWITCH-MIB::wrsCustomBootScriptStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsAuxClkSetStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsThrottlingSetStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsVlansSetStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsBootSuccessful} \\
\snmpadd{WR-SWITCH-MIB::wrsOSStatus}\\
\snmpadd{WR-SWITCH-MIB::wrsMainSystemStatus} }
......
......@@ -55,7 +55,10 @@
errors, unable to read the hwinfo, unable to load the FPGA bitstream, unable
to load the LM32 software, any kernel modules or userspace daemons are
missing, failed to update firmware due to checksum error, unable to
download custom boot script, custom boot script fails during execution.\\
download custom boot script, custom boot script fails during execution,
fails setting up auxclk on connector clk2, fails setting up a limit on
the Rx bandwidth of the traffic that goes from WR ports to Linux
(throttling), fails setting up VLANs.\\
\underline{On error:}
\begin{pck_proc}
\item Dump state
......@@ -445,12 +448,19 @@
Status of the last firmware update}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsCustomBootScriptSource}{
Source of the custom script that can be executed once at boot time. It can
be used to setup a switch in a way not supported by dot-config.}
be used to setup a switch in a way not supported by dot-config}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsCustomBootScriptSourceUrl}{
Path to the custom boot script on a remote server (if local scripts is not
used).}
used)}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsCustomBootScriptStatus}{
Result of custom boot script execution.}
Result of custom boot script execution}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsAuxClkSetStatus}{
Result of setting up auxclk on connector clk2}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsThrottlingSetStatus}{
Result of setting up a limit on the Rx bandwidth of the traffic that
goes from WR ports to Linux (throttling)}
\snmpentrye{WR-SWITCH-MIB}{wrsBootStatusGroup}{wrsVlansSetStatus}{
Result of setting up auxclk on connector clk2}
\snmpentrye{WR-SWITCH-MIB}{wrsOperationStatus}{wrsTemperatureGroup}{}
\snmpentrye{WR-SWITCH-MIB}{wrsTemperatureGroup}{wrsTempFPGA}{}
......
Kconfig
Kconfig_vlans.in
dot-config
conf
mconf
......
......@@ -15,7 +15,7 @@ OBJDUMP = $(CROSS_COMPILE)objdump
CFLAGS = -D KBUILD_NO_NLS
# most of this is just copying stuff in
RFILES = Kconfig dot-config wrs_release_defconfig
RFILES = Kconfig Kconfig_vlans.in dot-config wrs_release_defconfig
XFILES = conf mconf nconf
FILES = $(RFILES) $(XFILES)
......
#!/bin/bash
# Adam Wujek, CERN
# Generate Kconfig entries for Vlans
# redirect the output to the proper file
echo "menu \"VLANs\""
echo "config VLANS_ENABLE"
echo " bool \"Enable VLANs\""
echo " default n"
echo " help"
echo " Enable VLAN configuration via dot-config"
echo ""
echo "menu \"Ports configuration\""
echo " depends on VLANS_ENABLE"
############# generate options for ports
for port_i in {1..18}; do
port_0i=$(printf "%02d" $port_i)
echo ""
echo "comment \"Port $port_i\""
echo "choice VLANS_PORT"$port_0i"_MODE"
echo " prompt \"Port "$port_i" VLAN mode\""
echo " default VLANS_PORT"$port_0i"_MODE_UNQUALIFIED"
echo " help"
if [ $port_i -eq 1 ]; then
echo " In terms of VLAN-tag, there are four types of VLAN-tags that can"
echo " extend the Ethernet Frame header:"
echo " * none - tag is not included in the Ethernet Frame"
echo " * priority - tag that has VID=0x0"
echo " * VLAN - tag that has VID in the range 0x001 to 0xFFE"
echo " * null - tag that has VID=0xFFF"
echo ""
echo " The behaviour of each PMODE that can be set per-port depends on the"
echo " type of VLAN-tag in the received frame."
echo ""
echo " - PMODE=access (0x0), frames with:"
echo " * no VLAN-tag : are admitted, tagged with the values of VID and"
echo " priority that are configured in PORT_VID and"
echo " PRIO_VAL respectively"
echo " * priority tag : are admitted, their tag is unchanged, the value of"
echo " VID provided to the RTU is overridden with the"
echo " configured in PORT_VID. If PRIO_VAL is not -1,"
echo " the value of priority provided to RTU is"
echo " overridden with the configured PRIO_VAL"
echo " * VLAN tag : are discarded"
echo " * null tag : are discarded"
echo ""
echo " - PMODE=trunk (0x1), frames with:"
echo " * no VLAN-tag : are discarded"
echo " * priority tag : are discarded"
echo " * VLAN tag : are admitted; if PRIO_VAL is not -1, the value of"
echo " priority provided to RTU is overridden with"
echo " the configured PRIO_VAL"
echo " * null tag : are discarded"
echo ""
echo " - PMODE=disabled (0x2), frames with:"
echo " * no VLAN-tag : are admitted. No other configuration is used even"
echo " if set."
echo " * priority tag : are admitted; if PRIO_VAL is not -1, the value of"
echo " priority provided to RTU is overridden with"
echo " the configured PRIO_VAL"
echo " * VLAN tag : are admitted; if PRIO_VAL is not -1, the value of"
echo " priority provided to RTU is overridden with"
echo " the configured PRIO_VAL"
echo " * null tag : are admitted; if PRIO_VAL is not -1, the value of"
echo " priority provided to RTU is overridden with"
echo " the configured PRIO_VAL"
echo ""
echo " - PMODE=unqualified (0x3), frames with:"
echo " * no VLAN-tag : are admitted. No other configuration is used even"
echo " if set."
echo " * priority tag : are admitted. Their tag is unchanged, the value of"
echo " VID provided to the RTU is overridden with the"
echo " configured in PORT_VID. If PRIO_VAL is not -1,"
echo " the value of priority provided to RTU is"
echo " overridden with the configured PRIO_VAL"
echo " * VLAN tag : are admitted; if PRIO_VAL is not -1, the value of"
echo " priority provided to RTU is overridden with"
echo " the configured PRIO_VAL"
echo " * null tag : discarded."
else
echo " Please check the help of VLANS_PORT01_MODE"
fi
echo ""
echo "config VLANS_PORT"$port_0i"_MODE_ACCESS"
echo " bool \"Access mode\""
echo " help"
echo " Please check the help of VLANS_PORT01_MODE"
echo ""
echo "config VLANS_PORT"$port_0i"_MODE_TRUNK"
echo " bool \"Trunk mode\""
echo " help"
echo " Please check the help of VLANS_PORT01_MODE"
echo ""
echo "config VLANS_PORT"$port_0i"_MODE_DISABLED"
echo " bool \"VLAN-disabled mode\""
echo " help"
echo " Please check the help of VLANS_PORT01_MODE"
echo ""
echo "config VLANS_PORT"$port_0i"_MODE_UNQUALIFIED"
echo " bool \"Unqualified mode\""
echo " help"
echo " Please check the help of VLANS_PORT01_MODE"
echo ""
echo "endchoice"
echo ""
echo "choice VLANS_PORT"$port_0i"_UNTAG"
echo " prompt \"Port "$port_i" untag frames\""
echo " default VLANS_PORT"$port_0i"_UNTAG_ALL"
echo " depends on VLANS_PORT"$port_0i"_MODE_ACCESS"
echo " help"
echo " Decide whether VLAN-tags should be removed"
echo ""
echo "config VLANS_PORT"$port_0i"_UNTAG_ALL"
echo " bool \"untag all\""
echo " help"
echo " Untag all tagged frames."
echo ""
echo "config VLANS_PORT"$port_0i"_UNTAG_NONE"
echo " bool \"untag none\""
echo " help"
echo " Keep VLAN tags for all tagged frames."
echo ""
echo "endchoice"
echo ""
echo "config VLANS_PORT"$port_0i"_PRIO"
echo " int \"Port "$port_i" priority\""
echo " default -1"
echo " range -1 7"
echo " help"
echo " Priority value used when tagging frames or to override priority passed"
echo " to RTU."
echo " -1 disables the priority overwrite. Valid values are from -1 to 7."
echo ""
echo "config VLANS_PORT"$port_0i"_VID"
echo " int \"Port "$port_i" VID\""
echo " default 0"
echo " range 0 4094"
echo " depends on VLANS_PORT"$port_0i"_MODE_ACCESS || VLANS_PORT"$port_0i"_MODE_UNQUALIFIED"
echo " help"
echo " VID value used when tagging frames or to override VID passed to RTU"
echo ""
done
echo "# Ports configuration"
echo "endmenu"
################## VLANS configuration
echo "menu \"VLANs configuration\""
echo " depends on VLANS_ENABLE"
echo ""
for set_i in {1..3}; do
if [ $set_i == "1" ]; then
vlan_min=0
vlan_max=22
fi
if [ $set_i == "2" ]; then
vlan_min=23
vlan_max=100
fi
if [ $set_i == "3" ]; then
vlan_min=101
vlan_max=4094
fi
vlan_min_0=$(printf "%04d" $vlan_min)
echo "config VLANS_ENABLE_SET"$set_i
echo " bool \"Enable configuration for VLANs "$vlan_min"-"$vlan_max"\""
echo " default n"
echo " help"
echo ""
echo "menu \"Configuration for VLANs "$vlan_min"-"$vlan_max"\""
echo " depends on VLANS_ENABLE_SET"$set_i
for ((vlan_i=$vlan_min;vlan_i<=$vlan_max;vlan_i++));do
vlan_0i=$(printf "%04d" $vlan_i)
echo "config VLANS_VLAN"$vlan_0i
echo " string \"VLAN"$vlan_i" configuration\""
echo " default \"\""
echo " help"
if [ $vlan_i -eq $vlan_min ]; then
# for the first VLAN in the menu print full help
echo " Provide the configuration for VLAN"$vlan_i
echo " Example:"
echo " fid="$vlan_min",prio=4,drop=no,ports="$set_i":18"
echo " Where:"
echo " --\"fid\" is a associated Filtering ID (FID) number. One FID can be"
echo " associated with many VIDs. RTU learning is performed per-FID."
echo " Associating many VIDs with a single FID allowed shared-VLANs"
echo " learning."
echo " --\"prio\" is a priority of a VLAN; can take values between -1 and 7"
echo " -1 disables priority override, any other valid value takes"
echo " precedence over port priority"
echo " --If \"drop\" is set to \"y\", all frames belonging to this VID are"
echo " dropped (note that frame can belong to a VID as a consequence of"
echo " per-port Endpoint configuration); can take values \"y\" and \"n\""
echo " --\"ports\" is a list of ports separated with the colon sign"
else
# for the rest just refer to the first VLAN in the menu
echo " Please check the help of VLANS_VLAN"$vlan_min_0
fi
echo ""
done
echo "# Configuration for VLANs "$vlan_min"-"$vlan_max""
echo "endmenu"
echo ""
echo ""
done
echo "# VLANs configuration"
echo "endmenu"
echo ""
echo "# VLANs"
echo "endmenu"
......@@ -5,9 +5,19 @@
#include <string.h>
#include <errno.h>
#include <stdarg.h>
/* for dirname and basename */
#include <libgen.h>
#include <libwr/wrs-msg.h>
#include <libwr/config.h>
#define READ_KCONFIG_MAX_DEPTH 10
struct kc {
char *name;
struct kc *next;
};
/* All strings here are strdup'd and then split; you can't free(3) them */
struct cfg_item {
char *name;
......@@ -137,36 +147,89 @@ int libwr_cfg_dump(FILE *output)
return 0;
}
int libwr_cfg_read_verify_file(char *dotconfig, char *kconfig)
static int libwr_cfg_read_kconfig(struct kc **all_configs,
char *kconfig_dirname,
char *kconfig_filename, int depth_level)
{
FILE *f;
int errors = 0;
char s[256], name[256];
struct cfg_item *c;
struct kc *kc;
int ret = 0;
int len;
struct kc {
char *name;
struct kc *next;
} *all_configs = NULL, *kc, *next;
/* Prevent infinite recursion */
if (depth_level >= READ_KCONFIG_MAX_DEPTH) {
pr_error("Maximum depth of Kconfig source reached\n");
return -1;
}
if (libwr_cfg_read_file(dotconfig))
/* Check the length of Kconfig path */
len = strlen(kconfig_dirname) + strlen(kconfig_filename);
if (len >= 256) {
pr_error("File path too long %d\n", len);
return -1;
}
snprintf(name, 256, "%s/%s", kconfig_dirname, kconfig_filename);
pr_debug("Opening Kconfig file %s/%s\n", kconfig_dirname,
kconfig_filename);
/* Read Kconfig and store all config names */
f = fopen(kconfig, "r");
f = fopen(name, "r");
if (!f)
return -1;
while (fgets(s, sizeof(s), f)) {
if (sscanf(s, "source %s", name) == 1) {
/* Recursive call for sourced files */
ret = libwr_cfg_read_kconfig(all_configs,
kconfig_dirname, name,
depth_level + 1);
if (ret)
break;
}
if (sscanf(s, "config %s", name) != 1)
continue;
kc = malloc(sizeof(*kc));
if (!kc)
return -1;
if (!kc) {
ret = -1;
break;
}
kc->name = strdup(name);
kc->next = all_configs;
all_configs = kc;
kc->next = *all_configs;
*all_configs = kc;
}
fclose(f);
return ret;
}
int libwr_cfg_read_verify_file(char *dotconfig, char *kconfig)
{
int errors = 0;
struct cfg_item *c;
struct kc *all_configs = NULL, *kc, *next;
int ret = 0;
char *kconfig_dup1 = NULL;
char *kconfig_dup2 = NULL;
char *kconfig_dirname;
char *kconfig_filename;
if (libwr_cfg_read_file(dotconfig))
return -1;
/* Spearate dirname and basename of Kconfig, use strdup as suggested
* in the man page */
kconfig_dup1 = strdup(kconfig);
kconfig_dup2 = strdup(kconfig);
kconfig_dirname = dirname(kconfig_dup1);
kconfig_filename = basename(kconfig_dup2);
/* Read Kconfig and store all config names */
ret = libwr_cfg_read_kconfig(&all_configs, kconfig_dirname,
kconfig_filename, 0);
if (ret) {
pr_error("Kconfig read error\n");
return ret;
}
/* Verify all configs, complain if missing */
for (c = libwr_cfg; c; c = c->next) {
......@@ -186,6 +249,12 @@ int libwr_cfg_read_verify_file(char *dotconfig, char *kconfig)
free(kc->name);
free(kc);
}
/* free allocated duplicates of kconfig's paths */
if (kconfig_dup1)
free(kconfig_dup1);
if (kconfig_dup2)
free(kconfig_dup2);
if (errors) {
errno = EINVAL;
return -1;
......
#!/bin/sh
tmpdir=/tmp
vlans_set_status_file="$tmpdir"/vlans_set_status
dotconfig=/wr/etc/dot-config
set -o pipefail
start() {
echo -n "Setting up VLANs: "
# set-up VLANs
/wr/etc/vlan_config.sh
if [ -f $dotconfig ]; then
. $dotconfig
else
echo "$0 unable to start wrs_throttling, unable to source " \
"dot-config ($dotconfig)!"
exit 1
fi
if [ $? -eq 0 ]; then
WRS_LOG=$CONFIG_WRS_LOG_OTHER
# if empty turn it to /dev/null
if [ -z $WRS_LOG ]; then
WRS_LOG="/dev/null";
fi
# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
else
# not a pathname: use verbatim
eval LOGPIPE=\" 2\>\&1 \| logger -t wr-switch -p $WRS_LOG\"
fi
# set-up VLANs
eval /wr/bin/wrs_vlans -f /wr/etc/dot-config $LOGPIPE
ret=$?
if [ $ret -eq 0 ]; then
echo "OK"
echo "ok" > $vlans_set_status_file
elif [ $ret -eq 2 ]; then
echo "Disabled"
echo "disabled" > $vlans_set_status_file
else
echo "Failed"
echo "failed" > $vlans_set_status_file
fi
}
......
......@@ -2,6 +2,9 @@
# Script read wrs_auxclk parameters from dot-config, then start wrs_auxclk.
tmpdir=/tmp
wrs_auxclk_set_status_file="$tmpdir"/wrs_auxclk_set_status
# First, read dot-config to get wrs_auxclk parameters
dotconfig=/wr/etc/dot-config
set -o pipefail
......@@ -55,6 +58,8 @@ eval /wr/bin/wrs_auxclk $p_freq $p_duty $p_cshift $p_sigdel $p_ppshift $LOGPIPE
ret=$?
if [ $ret -eq 0 ]; then
echo "OK"
echo "ok" > $wrs_auxclk_set_status_file
else
echo "Failed"
echo "failed" > $wrs_auxclk_set_status_file
fi
#!/bin/sh
tmpdir=/tmp
wrs_throttling_set_status_file="$tmpdir"/wrs_throttling_set_status
# this script shall be called before enabling the switching
dotconfig=/wr/etc/dot-config
......@@ -36,11 +39,14 @@ start() {
ret=$?
if [ $ret -eq 0 ]; then
echo "OK"
echo "ok" > $wrs_throttling_set_status_file
else
echo "Failed"
echo "failed" > $wrs_throttling_set_status_file
fi
else
echo "throttling disabled"
echo "Disabled"
echo "disabled" > $wrs_throttling_set_status_file
fi
}
......
......@@ -53,7 +53,7 @@
echo '<form method=POST>';
for($i = 0; $i < 18; $i++){
$single_line = explode(" ",$vlans_assignment[$i+1]); //info per endpoint line
$single_line = explode(" ",$vlans_assignment[$i+2]); //info per endpoint line
echo '<tr>';
echo '<th><center><b>'.($single_line[0]).'</b></center></th>';
......
......@@ -96,7 +96,7 @@
foreach($vlans as $line){
$counter++;
if($counter>=2 && !empty($line)){
if($counter>=3 && !empty($line)){
$line = explode(" ", $line);
echo '<tr align=center><td>'.($line[0]).'</td><td>'.$line[1]." (".$line[2].')</td><td>'.($line[4]).'</td><td bgcolor="'.$vlancolor[$line[5]%10].'">VLAN '.$line[5].'</td><td>'.$line[6].'</td></td></tr>';
......
......@@ -25,6 +25,7 @@ for i_zero in {01..18};do
unset p_name
unset p_proto
unset p_role
unset p_ppsi_vlans
# parse parameters
param_line=$(eval "echo \$CONFIG_PORT"$i_zero"_PARAMS")
IFS_OLD=$IFS
......@@ -36,13 +37,19 @@ for i_zero in {01..18};do
do
# split pairs
IFS='=' read param value <<< "$pair"
case $param in
case "$param" in
"name")
p_name="$value";;
"proto")
p_proto="$value";;
"role")
p_role="$value";;
"ppsi_vlans")
p_ppsi_vlans="$value";;
"rx"|"tx"|"fiber")
continue;;
*)
echo "Invalid parameter $param in CONFIG_PORT"$i_zero"_PARAMS" ;;
esac
done
......@@ -66,8 +73,13 @@ for i_zero in {01..18};do
if [ -n "$p_role" ]; then
echo "role $p_role" >> $OUTPUT_FILE
fi
#hardcode whiterabbit as extension
#hardcode whiterabbit as extension even for non-wr
echo "extension whiterabbit" >> $OUTPUT_FILE
# add vlans
if [ -n "$p_ppsi_vlans" ]; then
mod_vlans=${p_ppsi_vlans//:/,}
echo "vlan $mod_vlans" >> $OUTPUT_FILE
fi
# separate ports
echo "" >> $OUTPUT_FILE
......
#!/bin/sh
set -e
## vlan configuration
## fill this file with vlans configuration
## Please note:
## wri2 is marked as port 2 on the front panel of the switch
## in other words:
## --port 2 == wri2
## and:
## wri2 == port2
## example configuration:
# configure ports 1-4,6,8-18 as pvid 1
# /wr/bin/wrs_vlans --port 1-4,6,8-18 --pmode 0 --pvid 1
# configure ports 5,7 as pvid 2
# /wr/bin/wrs_vlans --port 5,7 --pmode 0 --pvid 2
## set VID=1 on all ports except 4 and 6
## - binary: 11 1111 1111 1010 1111
## - hex : 0x3FFAF
# /wr/bin/wrs_vlans --rvid 1 --rfid 1 --rmask 0x3FFAF
## set VID=2 at ports 5 and 7 - this is
## - binary: 00 0000 0000 0101 0000
## - hex : 0x00050
# /wr/bin/wrs_vlans --rvid 2 --rfid 2 --rmask 0x00050
## when VLANs are defined, comment out the line below
echo -n "no vlan configuration "
exit 0
......@@ -800,6 +800,71 @@ wrsCustomBootScriptStatus OBJECT-TYPE
errorMinor - cannot read the status file, problem is probably somewhere else"
::= { wrsBootStatusGroup 19 }
wrsAuxClkSetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
failed(2),
disabled(3),
error(4),
errorMinor(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of setting up auxclk on connector clk2
ok - successful set pu of the auxclk
failed - error while setting up the auxclk
disabled - the setting up of the auxclk disabled in dot-config
error - unsuported status
errorMinor - cannot read the status file, the problem is probably
somewhere else"
::= { wrsBootStatusGroup 20 }
wrsThrottlingSetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
failed(2),
disabled(3),
error(4),
errorMinor(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of setting up a limit on the Rx bandwidth of the traffic that
goes from WR ports to Linux.
ok - successful set up of the throttling
failed - error while setting up the throttling
disabled - the setting up of the throttling disabled in dot-config
error - unsuported status
errorMinor - cannot read the status file, the problem is probably
somewhere else"
::= { wrsBootStatusGroup 21 }
wrsVlansSetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
ok(1),
failed(2),
disabled(3),
error(4),
errorMinor(5)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Result of setting up VLANs
ok - successful set up of VLANs
failed - error while setting up VLANs
disabled - the setting up of VLANs disabled in dot-config
error - unsuported status
errorMinor - cannot read the status file, the problem is probably
somewhere else"
::= { wrsBootStatusGroup 22 }
-- wrsTemperatureGroup (.7.1.3)
wrsTemperatureGroup OBJECT IDENTIFIER ::= { wrsOperationStatus 3 }
......
......@@ -27,6 +27,10 @@
#define CUSTOM_BOOT_SCRIPT_SOURCE_FILE "/tmp/custom_boot_script_source"
#define CUSTOM_BOOT_SCRIPT_SOURCE_URL_FILE "/tmp/custom_boot_script_url"
#define WRS_AUXCLK_SET_STATUS_FILE "/tmp/wrs_auxclk_set_status"
#define WRS_THROTTLING_SET_STATUS_FILE "/tmp/wrs_throttling_set_status"
#define WRS_VLANS_SET_STATUS_FILE "/tmp/vlans_set_status"
/* Macros for fscanf function to read line with maximum of "x" characters
* without new line. Macro expands to something like: "%10[^\n]" */
#define LINE_READ_LEN_HELPER(x) "%"#x"[^\n]"
......@@ -56,6 +60,9 @@ static struct pickinfo wrsBootStatus_pickinfo[] = {
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsCustomBootScriptSource),
FIELD(wrsBootStatus_s, ASN_OCTET_STR, wrsCustomBootScriptSourceUrl),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsCustomBootScriptStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsAuxClkSetStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsThrottlingSetStatus),
FIELD(wrsBootStatus_s, ASN_INTEGER, wrsVlansSetStatus),
};
struct wrsBootStatus_s wrsBootStatus_s;
......@@ -670,6 +677,103 @@ static void get_custom_boot_script_status(void)
}
static void get_wrs_aux_clk_set_status(void)
{
char buff[21]; /* 1 for null char */
FILE *f;
f = fopen(WRS_AUXCLK_SET_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strcmp(buff, "ok"))
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_OK;
else if (!strcmp(buff, "failed"))
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_FAILED;
else if (!strcmp(buff, "disabled"))
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_DISABLED;
else /* unknown status */
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_ERROR;
} else {
/* file with status not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsAuxClkSetStatus =
WRS_AUXCLK_SET_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsAuxClkSetStatus: failed to "
"open " WRS_AUXCLK_SET_STATUS_FILE "\n");
}
}
static void get_wrs_throttling_set_status(void)
{
char buff[21]; /* 1 for null char */
FILE *f;
f = fopen(WRS_THROTTLING_SET_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strcmp(buff, "ok"))
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_OK;
else if (!strcmp(buff, "failed"))
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_FAILED;
else if (!strcmp(buff, "disabled"))
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_DISABLED;
else /* unknown status */
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_ERROR;
} else {
/* file with status not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsThrottlingSetStatus =
WRS_THROTTLING_SET_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsThrottlingSetStatus: failed"
"to open " WRS_THROTTLING_SET_STATUS_FILE "\n");
}
}
static void get_wrs_vlans_set_status(void)
{
char buff[21]; /* 1 for null char */
FILE *f;
f = fopen(WRS_VLANS_SET_STATUS_FILE, "r");
if (f) {
/* readline without newline */
fscanf(f, LINE_READ_LEN(20), buff);
fclose(f);
if (!strcmp(buff, "ok"))
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_OK;
else if (!strcmp(buff, "failed"))
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_FAILED;
else if (!strcmp(buff, "disabled"))
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_DISABLED;
else /* unknown status */
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_ERROR;
} else {
/* file with status not found, probably something else caused
* a problem */
wrsBootStatus_s.wrsVlansSetStatus =
WRS_VLANS_SET_STATUS_ERROR_MINOR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " wrsVlansSetStatus: failed"
"to open " WRS_VLANS_SET_STATUS_FILE "\n");
}
}
time_t wrsBootStatus_data_fill(void)
{
static time_t time_update;
......@@ -703,9 +807,18 @@ time_t wrsBootStatus_data_fill(void)
/* get info about the firmware update status */
get_fw_update_status();
/* get info about the firmware update status */
/* get info about the status of custom boot script execution */
get_custom_boot_script_status();
/* get info about the status of auxclk setting */
get_wrs_aux_clk_set_status();
/* get info about the status of wrs_throttling setting */
get_wrs_throttling_set_status();
/* get info about the status of vlans setup */
get_wrs_vlans_set_status();
/* there was an update, return current time */
return time_update;
}
......
......@@ -56,9 +56,27 @@
#define WRS_CUSTOM_BOOT_SCRIPT_STATUS_ERROR 6 /* error */
#define WRS_CUSTOM_BOOT_SCRIPT_STATUS_ERROR_MINOR 7 /* warning */
#define WRS_CUSTOM_BOOT_SCRIPT_SOURCE_URL_LEN 128
#define WRS_AUXCLK_SET_STATUS_OK 1 /* ok */
#define WRS_AUXCLK_SET_STATUS_FAILED 2 /* error */
#define WRS_AUXCLK_SET_STATUS_DISABLED 3 /* ok */
#define WRS_AUXCLK_SET_STATUS_ERROR 4 /* error */
#define WRS_AUXCLK_SET_STATUS_ERROR_MINOR 5 /* warning */
#define WRS_THROTTLING_SET_STATUS_OK 1 /* ok */
#define WRS_THROTTLING_SET_STATUS_FAILED 2 /* error */
#define WRS_THROTTLING_SET_STATUS_DISABLED 3 /* ok */
#define WRS_THROTTLING_SET_STATUS_ERROR 4 /* error */
#define WRS_THROTTLING_SET_STATUS_ERROR_MINOR 5 /* warning */
#define WRS_VLANS_SET_STATUS_OK 1 /* ok */
#define WRS_VLANS_SET_STATUS_FAILED 2 /* error */
#define WRS_VLANS_SET_STATUS_DISABLED 3 /* ok */
#define WRS_VLANS_SET_STATUS_ERROR 4 /* error */
#define WRS_VLANS_SET_STATUS_ERROR_MINOR 5 /* warning */
struct wrsBootStatus_s {
uint32_t wrsBootCnt; /* boots since power-on must be != 0 */
uint32_t wrsRebootCnt; /* soft reboots since hard reboot
......@@ -80,6 +98,9 @@ struct wrsBootStatus_s {
int32_t wrsCustomBootScriptSource;
char wrsCustomBootScriptSourceUrl[WRS_CUSTOM_BOOT_SCRIPT_SOURCE_URL_LEN + 1];
int32_t wrsCustomBootScriptStatus;
int32_t wrsAuxClkSetStatus;
int32_t wrsThrottlingSetStatus;
int32_t wrsVlansSetStatus;
};
extern struct wrsBootStatus_s wrsBootStatus_s;
......
......@@ -170,7 +170,6 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: unrecognized source of custom boot script\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptStatus == WRS_CUSTOM_BOOT_SCRIPT_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: custom boot script failed during execution\n",
......@@ -191,7 +190,6 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of custom boot script execution\n",
slog_obj_name);
}
if (b->wrsCustomBootScriptSource == WRS_CUSTOM_BOOT_SCRIPT_SOURCE_REMOTE
&& strnlen(b->wrsCustomBootScriptSourceUrl, WRS_CUSTOM_BOOT_SCRIPT_SOURCE_URL_LEN) == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
......@@ -199,6 +197,39 @@ time_t wrsOSStatus_data_fill(void)
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: setting up auxclk on connector clk2 failed\n",
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of setting up auxclk on connector clk2\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: setting up a throttling limit failed\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of setting up a throttling limit\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_FAILED) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: setting up a throttling limit failed\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_ERROR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: error in status file of setting up a throttling limit\n",
slog_obj_name);
}
/* check if warning */
if (!o->wrsBootSuccessful) {
......@@ -262,6 +293,21 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsCustomBootScriptStatus\n",
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsAuxClkSetStatus\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsThrottlingSetStatus\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_ERROR_MINOR) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING;
snmp_log(LOG_ERR, "SNMP: " SL_W " %s: Unable to read status file of wrsVlansSetStatus\n",
slog_obj_name);
}
}
/* check if any of fields equal to 0 */
......@@ -306,6 +352,21 @@ time_t wrsOSStatus_data_fill(void)
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsCustomBootScriptStatus not available\n",
slog_obj_name);
}
if (b->wrsAuxClkSetStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsAuxClkSetStatus not available\n",
slog_obj_name);
}
if (b->wrsThrottlingSetStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsThrottlingSetStatus not available\n",
slog_obj_name);
}
if (b->wrsVlansSetStatus == 0) {
o->wrsBootSuccessful = WRS_BOOT_SUCCESSFUL_WARNING_NA;
snmp_log(LOG_ERR, "SNMP: " SL_NA " %s: Status of wrsVlansSetStatus not available\n",
slog_obj_name);
}
}
if ((!o->wrsBootSuccessful)
......@@ -334,6 +395,12 @@ time_t wrsOSStatus_data_fill(void)
&& b->wrsCustomBootScriptStatus == WRS_CUSTOM_BOOT_SCRIPT_STATUS_OK
)
)
&& (b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_OK
|| b->wrsAuxClkSetStatus == WRS_AUXCLK_SET_STATUS_DISABLED)
&& (b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_OK
|| b->wrsThrottlingSetStatus == WRS_THROTTLING_SET_STATUS_DISABLED)
&& (b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_OK
|| b->wrsVlansSetStatus == WRS_VLANS_SET_STATUS_DISABLED)
)
) { /* OK, but check source */
/* additional check of source */
......
This diff is collapsed.
......@@ -41,16 +41,14 @@
#define PORT_MASK(x) (1<<(x))
#define NOPTS 15
#define OPT_HELP 'h'
#define OPT_DEBUG 'd'
#define OPT_CLEAR 3
#define OPT_LIST 4
#define OPT_P_PORT 10
#define OPT_P_QMODE 11
#define OPT_P_VID 12
#define OPT_P_PRIO 13
#define OPT_P_UMASK 14
#define OPT_P_UNTAG 14
#define OPT_P_LIST 15
#define OPT_RTU_VID 20
#define OPT_RTU_FID 21
......@@ -58,11 +56,40 @@
#define OPT_RTU_DROP 23
#define OPT_RTU_PRIO 24
#define OPT_RTU_DEL 25
#define OPT_RTU_HP_MASK 30
#define OPT_FILE_READ 'f'
#define PORT_PRIO_MIN 0
#define PORT_PRIO_MAX 7
#define PORT_PRIO_DISABLE -1
#define PORT_VID_MIN 0
#define PORT_VID_MAX 4094
#define RTU_VID_MIN 0
#define RTU_VID_MAX 4094
#define RTU_FID_MIN 0
#define RTU_FID_MAX 4094
#define RTU_PRIO_MIN 0
#define RTU_PRIO_MAX 7
#define RTU_PRIO_DISABLE -1
#define RTU_PMASK_MIN 0
#define RTU_PMASK_MAX ((1 << NPORTS) - 1)
/* struct for ranges of VLAN sets used in dot-config */
struct vlan_sets {
char *name;
int min;
int max;
};
struct s_port_vlans
{
int valid_mask;
char qmode;
char pmode;
char fix_prio;
char prio_val;
int vid;
......
......@@ -37,6 +37,7 @@
#include "rtu.h"
#include "rtu_fd.h"
#include "rtu_drv.h"
#include "rtu_ext_drv.h"
#include "rtud_exports.h"
#include <libwr/mac.h>
......@@ -278,6 +279,39 @@ int rtudexp_unrec(const struct minipc_pd *pd, uint32_t * args, void *ret)
return *p_ret;
}
int rtudexp_hp_mask(const struct minipc_pd *pd, uint32_t * args, void *ret)
{
int oper;
uint32_t hp_mask;
int *p_ret = (int *)ret; /* force pointed to int type */
oper = (int)args[0];
hp_mask = (int)args[1];
*p_ret = 0;
pr_debug("Request for HP mask\n");
switch (oper) {
case RTU_SET_HP_MASK:
if (hp_mask >= (1 << 8)) {
*p_ret = -1;
pr_error("Wrong HP mask 0x%x\n", hp_mask);
break;
}
rtux_set_hp_prio_mask(hp_mask);
pr_debug("Setting HP mask 0x%x\n", hp_mask);
break;
case RTU_GET_HP_MASK:
*p_ret = rtux_get_hp_prio_mask();
pr_debug("Got HP mask 0x%x\n", *p_ret);
break;
default:
pr_error("Wrong operation for HP mask %d\n", oper);
*p_ret = -1;
return *p_ret;
}
return *p_ret;
}
int rtudexp_vlan_entry(const struct minipc_pd *pd, uint32_t * args, void *ret)
{
int vid, fid, mask, drop, prio, has_prio, prio_override;
......@@ -314,6 +348,7 @@ int rtud_init_exports()
MINIPC_EXP_FUNC(rtud_export_learning_process, rtudexp_learning_process);
MINIPC_EXP_FUNC(rtud_export_unrec, rtudexp_unrec);
MINIPC_EXP_FUNC(rtud_export_vlan_entry, rtudexp_vlan_entry);
MINIPC_EXP_FUNC(rtud_export_hp_mask, rtudexp_hp_mask);
return 0;
}
......
......@@ -41,6 +41,9 @@
#define RTU_SET_UNREC 1
#define RTU_GET_UNREC 2
#define RTU_SET_HP_MASK 1
#define RTU_GET_HP_MASK 2
/* Export of a function to set remove entry in rtu */
struct minipc_pd rtud_export_clear_entries = {
.name = "clear_entries",
......@@ -118,4 +121,15 @@ struct minipc_pd rtud_export_vlan_entry = {
},
};
/* Export of a function to add vlan entry in rtu */
struct minipc_pd rtud_export_hp_mask = {
.name = "hp_mask",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), /* operation */
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int), /* HP mask */
MINIPC_ARG_END,
},
};
#endif
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