Skip to content
Snippets Groups Projects
Commit bbc6b291 authored by Jean-Claude BAU's avatar Jean-Claude BAU
Browse files

VLANS: Change behavior and add raw configuration

parents fd042d17 87a2d1b6
Branches
Tags
No related merge requests found
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_vlans.in"
script_name="$0"
#decode script parameters
while getopts o: option
do
case "${option}" in
"o") OUTPUT_FILE=${OPTARG};;
esac
done
function is_profile_enabled() {
for profile in $profileList; do
if [ $profile == "$1" ]; then return 1 ; fi
done
return 0;
}
function print_header() {
echo -e "\nmenu \"VLANs\""
echo -e "\nconfig VLANS_ENABLE"
echo -e "\tbool \"Enable VLANs\""
echo -e "\tdefault n"
echo -e "\thelp"
echo -e "\t Enable VLAN configuration via dot-config"
echo -e "\nconfig VLANS_RAW_PORT_CONFIG"
echo -e "\tdepends on VLANS_ENABLE"
echo -e "\tbool \"Enable raw ports configuration\""
echo -e "\tdefault n"
echo -e "\thelp"
echo -e "\t Enable raw configuration for VLANS\n"
}
function print_footer() {
echo -e "\nendmenu # Menu VLANS"
}
function print_ports_header() {
echo -e "\nmenu \"Ports configuration\""
echo -e "\tdepends on VLANS_ENABLE"
}
function print_ports_footer() {
echo -e "\nendmenu # Menu Ports configuration"
}
function print_port_header() {
local portIdx=$1
echo -e "\ncomment \"========= P O R T ${portIdx} ============\""
}
function print_port_footer() {
local portIdx=$1
}
function print_port_config() {
local portIdx=$1
local portStr=`printf "%02d" $portIdx`
echo -e "\nchoice VLANS_PORT${portStr}_MODE\n"
echo -e "\tprompt \"VLAN mode\""
echo -e "\tdefault VLANS_PORT${portStr}_MODE_UNQUALIFIED"
help_vlan_port_mode
echo -e "\nconfig VLANS_PORT${portStr}_MODE_ACCESS"
echo -e "\tbool \"Access mode\""
echo -e "\thelp"
echo -e "\t Please check the help of VLANS_PORT${portStr}_MODE"
echo -e "\nconfig VLANS_PORT${portStr}_MODE_TRUNK"
echo -e "\tbool \"Trunk mode\""
echo -e "\thelp"
echo -e "\t Please check the help of VLANS_PORT${portStr}_MODE"
echo -e "\nconfig VLANS_PORT${portStr}_MODE_DISABLED"
echo -e "\tbool \"VLAN-disabled mode\""
echo -e "\thelp"
echo -e "\t Please check the help of VLANS_PORT${portStr}_MODE"
echo -e "\nconfig VLANS_PORT${portStr}_MODE_UNQUALIFIED"
echo -e "\tbool \"Unqualified mode\""
echo -e "\thelp"
echo -e "\t Please check the help of VLANS_PORT${portStr}_MODE"
echo -e "endchoice # choice VLANS_PORT${portStr}_MODE"
echo -e "\nchoice VLANS_PORT${portStr}_UNTAG"
echo -e "\tprompt \"Untag frames\""
echo -e "\tdefault VLANS_PORT${portStr}_UNTAG_ALL if VLANS_PORT${portStr}_MODE_ACCESS"
echo -e "\tdefault VLANS_PORT${portStr}_UNTAG_NONE"
echo -e "\tdepends on VLANS_PORT${portStr}_MODE_ACCESS || VLANS_RAW_PORT_CONFIG"
echo -e "\thelp"
echo -e "\t Decide whether VLAN-tags should be removed"
echo -e "\nconfig VLANS_PORT${portStr}_UNTAG_ALL"
echo -e "\tbool \"untag all\""
echo -e "\thelp"
echo -e "\t Untag all tagged frames."
echo -e "\nconfig VLANS_PORT${portStr}_UNTAG_NONE"
echo -e "\tbool \"untag none\""
echo -e "\thelp"
echo -e "\t Keep VLAN tags for all tagged frames."
echo -e "endchoice #choice VLANS_PORT${portStr}_UNTAG"
echo -e "\nconfig VLANS_PORT${portStr}_PRIO"
echo -e "\tint \"Priority\""
echo -e "\tdepends on VLANS_RAW_PORT_CONFIG || VLANS_PORT${portStr}_MODE_ACCESS || VLANS_PORT${portStr}_MODE_DISABLED || VLANS_PORT${portStr}_MODE_UNQUALIFIED"
echo -e "\tdefault -1"
echo -e "\trange -1 7"
echo -e "\thelp"
echo -e "\t Priority value used when tagging frames or to override priority passed"
echo -e "\t to RTU."
echo -e "\t -1 disables the priority overwrite. Valid values are from -1 to 7."
echo -e "\nconfig VLANS_PORT${portStr}_VID"
echo -e "\tstring \"VID\""
echo -e "\tdepends on VLANS_RAW_PORT_CONFIG || VLANS_PORT${portStr}_MODE_ACCESS"
echo -e "\tdefault \"\""
help_vlan_port_vid
echo -e "\nconfig VLANS_PORT${portStr}_PTP_VID"
echo -e "\tstring \"PTP VID\""
echo -e "\tdepends on VLANS_RAW_PORT_CONFIG || VLANS_PORT${portStr}_MODE_TRUNK || VLANS_PORT${portStr}_MODE_DISABLED || VLANS_PORT${portStr}_MODE_UNQUALIFIED"
echo -e "\tdefault VLANS_PORT${portStr}_VID if VLANS_PORT${portStr}_MODE_ACCESS"
echo -e "\tdefault \"\""
echo -e "\thelp"
echo -e "\t VID used for the PTP messages"
}
function help_vlan_port_mode() {
echo -e "\thelp"
echo -e "\t In terms of VLAN-tag, there are four types of VLAN-tags that can"
echo -e "\t extend the Ethernet Frame header:"
echo -e "\t * none - tag is not included in the Ethernet Frame"
echo -e "\t * priority - tag that has VID=0x0"
echo -e "\t * VLAN - tag that has VID in the range 0x001 to 0xFFE"
echo -e "\t * null - tag that has VID=0xFFF"
echo -e "\n\t The behaviour of each PMODE that can be set per-port depends on the"
echo -e "\t type of VLAN-tag in the received frame."
echo -e "\n\t - PMODE=access (0x0), frames with:"
echo -e "\t * no VLAN-tag : are admitted, tagged with the values of VID and"
echo -e "\t priority that are configured in PORT_VID and"
echo -e "\t PRIO_VAL respectively"
echo -e "\t * priority tag : are admitted, their tag is unchanged, the value of"
echo -e "\t VID provided to the RTU is overridden with the"
echo -e "\t configured in PORT_VID. If PRIO_VAL is not -1,"
echo -e "\t the value of priority provided to RTU is"
echo -e "\t overridden with the configured PRIO_VAL"
echo -e "\t * VLAN tag : are discarded"
echo -e "\t * null tag : are discarded"
echo -e "\n\t - PMODE=trunk (0x1), frames with:"
echo -e "\t * no VLAN-tag : are discarded"
echo -e "\t * priority tag : are discarded"
echo -e "\t * VLAN tag : are admitted; if PRIO_VAL is not -1, the value of"
echo -e "\t priority provided to RTU is overridden with"
echo -e "\t the configured PRIO_VAL"
echo -e "\t * null tag : are discarded"
echo -e "\n\t - PMODE=disabled (0x2), frames with:"
echo -e "\t * no VLAN-tag : are admitted. No other configuration is used even"
echo -e "\t if set."
echo -e "\t * priority tag : are admitted; if PRIO_VAL is not -1, the value of"
echo -e "\t priority provided to RTU is overridden with"
echo -e "\t the configured PRIO_VAL"
echo -e "\t * VLAN tag : are admitted; if PRIO_VAL is not -1, the value of"
echo -e "\t priority provided to RTU is overridden with"
echo -e "\t the configured PRIO_VAL"
echo -e "\t * null tag : are admitted; if PRIO_VAL is not -1, the value of"
echo -e "\t priority provided to RTU is overridden with"
echo -e "\t the configured PRIO_VAL"
echo -e "\n\t - PMODE=unqualified (0x3), frames with:"
echo -e "\t * no VLAN-tag : are admitted. No other configuration is used even"
echo -e "\t if set."
echo -e "\t * priority tag : are admitted. Their tag is unchanged, the value of"
echo -e "\t VID provided to the RTU is overridden with the"
echo -e "\t configured in PORT_VID. If PRIO_VAL is not -1,"
echo -e "\t the value of priority provided to RTU is"
echo -e "\t overridden with the configured PRIO_VAL"
echo -e "\t NOTE: providing a VID for this mode is not"
echo -e "\t supported in the dot-config"
echo -e "\t * VLAN tag : are admitted; if PRIO_VAL is not -1, the value of"
echo -e "\t priority provided to RTU is overridden with"
echo -e "\t the configured PRIO_VAL"
echo -e "\t * null tag : discarded."
}
function help_vlan_port_vid() {
echo -e "\thelp"
echo -e "\t This value based on the port's mode is used as:"
echo -e "\t --MODE_ACCESS - (mandatory) use as VID for tagging incoming frames and notify"
echo -e "\t the PPSI which VLAN shall it use for synchronization; only one VLAN"
echo -e "\t number shall be used in this mode"
echo -e "\t --MODE_TRUNK - (optional) notify the PPSI which VLAN shall it use for"
echo -e "\t synchronization; semicolon separated list is allowed"
echo -e "\t --MODE_DISABLED - (optional) notify the PPSI which VLANs shall it use for"
echo -e "\t synchronization; semicolon separated list is allowed"
echo -e "\t --MODE_UNQUALIFIED - (optional) notify the PPSI which VLANs shall it use for"
echo -e "\t synchronization; semicolon separated list is allowed;"
echo -e "\t The range of a valid VID is 0 to 4094"
}
function print_vlans_header () {
echo -e "\nmenu \"VLANs configuration\""
echo -e "\t depends on VLANS_ENABLE"
}
function print_vlans_footer () {
echo -e "\nendmenu"
}
function print_vlan_set_header() {
local vset=$1
local idx1=$2
local idx2=$3
echo -e "\nconfig VLANS_ENABLE_SET$vset"
echo -e "\tbool \"Enable configuration for VLANs $idx1-$idx2\""
echo -e "\tdefault n"
echo -e "\thelp"
echo -e "\nmenu \"Configuration for VLANs $idx1-$idx2\""
echo -e "\tdepends on VLANS_ENABLE_SET$vset"
}
function print_vlan_set_footer() {
local vset=$1
local idx1=$2
local idx2=$3
echo -e "endmenu #nmenu \"Configuration for VLANs $idx1-$idx2\""
}
function print_vlan_set_config() {
local vset=$1
local idx1=$2
local idx2=$3
local idx=$4
local vlanStr=`printf "%04d" $idx`
echo -e "\nconfig VLANS_VLAN${vlanStr}"
echo -e "\tstring \"VLAN${idx} configuration\""
echo -e "\tdefault \"\""
echo -e "\thelp"
echo -e "\t Provide the configuration for VLAN${idx}"
echo -e "\t Example:"
echo -e "\t fid=0,prio=4,drop=no,ports=1;2;3-5;7"
echo -e "\t Where:"
echo -e "\t --\"fid\" is a associated Filtering ID (FID) number. One FID can be"
echo -e "\t associated with many VIDs. RTU learning is performed per-FID."
echo -e "\t Associating many VIDs with a single FID allowed shared-VLANs"
echo -e "\t learning."
echo -e "\t --\"prio\" is a priority of a VLAN; can take values between -1 and 7"
echo -e "\t -1 disables priority override, any other valid value takes"
echo -e "\t precedence over port priority"
echo -e "\t --If \"drop\" is set to y, yes or 1 all frames belonging to this VID are"
echo -e "\t dropped (note that frame can belong to a VID as a consequence of"
echo -e "\t per-port Endpoint configuration); can take values y, yes, 1, n, no, 0"
echo -e "\t --\"ports\" is a list of ports separated with a semicolon sign (\";\");"
echo -e "\t ports ranges are supported (with a minus sign)"
}
function generate_configuration () {
print_header
print_ports_header
for p in `seq 1 $portCount`; do
print_port_header ${p}
print_port_config ${p}
print_port_footer ${p}
done
print_ports_footer
print_vlans_header
vlanSet=1
for s in "${vlan_sets[@]}" ; do
idx1=`echo "$s" | grep -o -e "^[0-9]*" `
idx2=`echo "$s" | grep -o -e "[0-9]*$" `
print_vlan_set_header $vlanSet $idx1 $idx2
for idx in `seq $idx1 $idx2`; do
print_vlan_set_config $vlanSet $idx1 $idx2 $idx
done
print_vlan_set_footer $vlanSet $idx1 $idx2
vlanSet=$(($vlanSet+1))
done
print_vlans_footer
print_footer
} >$OUTPUT_FILE
# Generation parameters
portCount=18
vlan_sets=("0:23" "23:100" "101:4094")
generate_configuration
#!/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 " NOTE: providing a VID for this mode is not"
echo " supported in the dot-config"
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 " string \"Port "$port_i" VID\""
echo " default \"\""
echo " help"
echo " This value based on the port's mode is used as:"
echo " --MODE_ACCESS - (mandatory) use as VID for tagging incoming frames and notify"
echo " the PPSI which VLAN shall it use for synchronization; only one VLAN"
echo " number shall be used in this mode"
echo " --MODE_TRUNK - (optional) notify the PPSI which VLAN shall it use for"
echo " synchronization; semicolon separated list is allowed"
echo " --MODE_DISABLED - (optional) notify the PPSI which VLANs shall it use for"
echo " synchronization; semicolon separated list is allowed"
echo " --MODE_UNQUALIFIED - (optional) notify the PPSI which VLANs shall it use for"
echo " synchronization; semicolon separated list is allowed;"
echo " The range of a valid VID is 0 to 4094"
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=1;2;3-5;7"
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, yes or 1 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, yes, 1, n, no, 0"
echo " --\"ports\" is a list of ports separated with a semicolon sign (\";\");"
echo " ports ranges are supported (with a minus 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"
......@@ -542,11 +542,12 @@ for i_port in {01..18}; do # scan all the physical ports
# add vlans
if [ "$CONFIG_VLANS_ENABLE" = "y" ]; then
unset ppsi_vlans;
unset port_vid;
unset port_mode_access;
unset port_mode_trunk;
unset port_mode_unqualified;
unset port_mode_disabled;
unset port_ptp_vid
# check port mode
port_mode_access=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_ACCESS")
......@@ -554,16 +555,22 @@ for i_port in {01..18}; do # scan all the physical ports
port_mode_unqualified=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_UNQUALIFIED")
port_mode_disabled=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_MODE_DISABLED")
port_vid=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_VID")
port_ptp_vid=$(eval "echo \$CONFIG_VLANS_PORT"$i_port"_PTP_VID")
if [ -z "$port_ptp_vid" ] ; then
port_ptp_vid=$port_vid
fi
# 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"
if [ "$port_ptp_vid" -ge 0 ] &> /dev/null \
&& [ "$port_ptp_vid" -le 4094 ] &> /dev/null; then
v="$inst_vn[vlan]"; eval ${v}="$port_ptp_vid"
else
echo "$script_name: Wrong value \"$ppsi_vlans\" in CONFIG_VLANS_PORT"$i_port"_VID" | tee $log_output
echo "$script_name: Wrong value \"$port_ptp_vid\" in CONFIG_VLANS_PORT"$i_port"_VID" | tee $log_output
continue;
fi
fi
......@@ -571,9 +578,8 @@ for i_port in {01..18}; do # scan all the physical ports
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//;/,}
if [ -n "$port_ptp_vid" ]; then
mod_vlans=${port_ptp_vid//;/,}
v="$inst_vn[vlan]"; eval ${v}="$mod_vlans"
fi
fi
......
......@@ -26,6 +26,7 @@
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <ctype.h>
#include <minipc.h>
#include <rtud_exports.h>
#include "regs/endpoint-regs.h"
......@@ -387,6 +388,25 @@ int main(int argc, char *argv[])
return 0;
}
static char *trimWhitespace(char *str)
{
char *end;
// Trim leading space
while(isspace((unsigned char)*str)) str++;
if(*str == 0) // All spaces?
return str;
// Trim trailing space
end = str + strlen(str) - 1;
while(end > str && isspace((unsigned char)*end)) end--;
// Write new null terminator character
end[1] = '\0';
return str;
}
static void set_p_pmode(int ep, int arg_mode)
{
vlans[ep].pmode = arg_mode;
......@@ -985,6 +1005,7 @@ static int read_dot_config(char *dot_config_file)
char *val_ch;
int i;
int mode;
int rawPortConfig;
int vlan0_port_mask = 0;
if (access(dot_config_file, R_OK)) {
......@@ -1035,6 +1056,10 @@ static int read_dot_config(char *dot_config_file)
return -2;
}
/* Check if raw configuration is enabled */
ret = libwr_cfg_get("VLANS_RAW_PORT_CONFIG");
rawPortConfig= ret && (!strcmp(ret, "y"));
for (port = 1; port <= NPORTS; port++) {
portmask = portmask | (1 << (port - 1));
mode = QMODE_INVALID;
......@@ -1073,8 +1098,10 @@ static int read_dot_config(char *dot_config_file)
}
/* check UNTAG all or none only for ACCESS
* for other modes use untag none by default */
if (mode == QMODE_ACCESS) {
* for other modes use untag none by default.
* If raw port configuration is enable, does not
* take care of the mode */
if (rawPortConfig || mode == QMODE_ACCESS) {
sprintf(buff, "VLANS_PORT%02d_UNTAG_ALL", port);
ret = libwr_cfg_get(buff);
if (ret && !strcmp(ret, "y")) {
......@@ -1099,28 +1126,51 @@ static int read_dot_config(char *dot_config_file)
}
/* update a mask for vlan0 */
if (mode != QMODE_ACCESS && mode != QMODE_TRUNK) {
if (rawPortConfig || (mode != QMODE_ACCESS && mode != QMODE_TRUNK) ) {
vlan0_port_mask |= 1 << (port - 1);
}
sprintf(buff, "VLANS_PORT%02d_PRIO", port);
val_ch = libwr_cfg_get(buff);
if (val_ch) {
if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s=%s\n", buff, val_ch);
set_p_prio(port - 1, val_ch);
// Priority
if (rawPortConfig || mode != QMODE_TRUNK) {
char *strPrio;
sprintf(buff, "VLANS_PORT%02d_PRIO", port);
val_ch = libwr_cfg_get(buff);
strPrio= val_ch ? trimWhitespace(val_ch) : "";
if (strPrio[0]!=0 ) {
if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s=%s\n", buff, strPrio);
set_p_prio(port - 1, strPrio);
} else {
if ( mode != QMODE_TRUNK ) {
pr_error("Priority not defined for the port (%d) in"
" TRUNK mode!\n", port);
}
if ( !rawPortConfig ) {
exit(1); /* Exit only if not raw port configuration */
}
}
}
if (mode == QMODE_ACCESS) {
// PVID
if (rawPortConfig || mode == QMODE_ACCESS) {
char *strVid;
sprintf(buff, "VLANS_PORT%02d_VID", port);
val_ch = libwr_cfg_get(buff);
if (val_ch) {
strVid= val_ch ? trimWhitespace(val_ch) : "";
if (strVid[0]!=0 ) {
if (wrs_msg_level >= LOG_DEBUG)
printf("Found %s=%s\n", buff, val_ch);
set_p_vid(port - 1, val_ch);
printf("Found %s=%s\n", buff, strVid);
set_p_vid(port - 1, strVid);
} else {
pr_error("VID not defined for the port (%d) in"
" ACCESS mode!\n", port);
exit(1);
if ( mode == QMODE_ACCESS )
pr_error("VID not defined for the port (%d) in"
" ACCESS mode!\n", port);
if ( !rawPortConfig ) {
exit(1); /* Exit only if not raw port configuration */
}
}
}
}
......
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