Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
bbc6b291
Commit
bbc6b291
authored
Mar 13, 2020
by
Jean-Claude BAU
Browse files
Options
Browse Files
Download
Plain Diff
VLANS: Change behavior and add raw configuration
parents
fd042d17
87a2d1b6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67471 additions
and
4803 deletions
+67471
-4803
Kconfig_vlans.in
Kconfig_vlans.in
+67086
-4550
gen_kconfig_port_timing.sh
userspace/host_tools/gen_kconfig_port_timing.sh
+0
-0
gen_kconfig_sfp_fiber.sh
userspace/host_tools/gen_kconfig_sfp_fiber.sh
+0
-0
gen_kconfig_vlans.sh
userspace/host_tools/gen_kconfig_vlans.sh
+304
-0
gen_vlan_kconf.sh
userspace/host_tools/gen_vlan_kconf.sh
+0
-228
assembly_ppsi_conf.sh
userspace/rootfs_override/wr/bin/assembly_ppsi_conf.sh
+15
-9
wrs_vlans.c
userspace/tools/wrs_vlans.c
+66
-16
No files found.
Kconfig_vlans.in
View file @
bbc6b291
This diff is collapsed.
Click to expand it.
gen_kconfig_port_timing.sh
→
userspace/host_tools/
gen_kconfig_port_timing.sh
View file @
bbc6b291
File moved
gen_kconfig_sfp_fiber.sh
→
userspace/host_tools/
gen_kconfig_sfp_fiber.sh
View file @
bbc6b291
File moved
userspace/host_tools/gen_kconfig_vlans.sh
0 → 100755
View file @
bbc6b291
This diff is collapsed.
Click to expand it.
userspace/host_tools/gen_vlan_kconf.sh
deleted
100755 → 0
View file @
fd042d17
#!/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"
userspace/rootfs_override/wr/bin/assembly_ppsi_conf.sh
View file @
bbc6b291
...
...
@@ -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
p
psi_vlans
;
unset
p
ort_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
[
"
$p
psi_vlans
"
-ge
0
]
&> /dev/null
\
&&
[
"
$p
psi_vlans
"
-le
4094
]
&> /dev/null
;
then
v
=
"
$inst_vn
[vlan]"
;
eval
${
v
}
=
"
$p
psi_vlans
"
if
[
"
$p
ort_ptp_vid
"
-ge
0
]
&> /dev/null
\
&&
[
"
$p
ort_ptp_vid
"
-le
4094
]
&> /dev/null
;
then
v
=
"
$inst_vn
[vlan]"
;
eval
${
v
}
=
"
$p
ort_ptp_vid
"
else
echo
"
$script_name
: Wrong value
\"
$p
psi_vlans
\"
in CONFIG_VLANS_PORT"
$i_port
"_VID"
|
tee
$log_output
echo
"
$script_name
: Wrong value
\"
$p
ort_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
...
...
userspace/tools/wrs_vlans.c
View file @
bbc6b291
...
...
@@ -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 */
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment