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
87a2d1b6
Commit
87a2d1b6
authored
Mar 11, 2020
by
Jean-Claude BAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VLANS: Change behavior for priority, vid and ptp vid
parent
f8c4444f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
201 additions
and
75 deletions
+201
-75
Kconfig_vlans.in
Kconfig_vlans.in
+127
-55
gen_kconfig_vlans.sh
userspace/host_tools/gen_kconfig_vlans.sh
+8
-4
wrs_vlans.c
userspace/tools/wrs_vlans.c
+66
-16
No files found.
Kconfig_vlans.in
View file @
87a2d1b6
This diff is collapsed.
Click to expand it.
userspace/host_tools/gen_kconfig_vlans.sh
View file @
87a2d1b6
...
...
@@ -35,7 +35,7 @@ function print_header() {
echo
-e
"
\t
Enable VLAN configuration via dot-config"
echo
-e
"
\n
config VLANS_RAW_PORT_CONFIG"
echo
-e
"
\t
depends on VLANS_ENABLE"
echo
-e
"
\t
bool
\"
Enable raw
configuration for VLANS
\"
"
echo
-e
"
\t
bool
\"
Enable raw
ports configuration
\"
"
echo
-e
"
\t
default n"
echo
-e
"
\t
help"
echo
-e
"
\t
Enable raw configuration for VLANS
\n
"
...
...
@@ -96,7 +96,8 @@ function print_port_config() {
echo
-e
"
\n
choice VLANS_PORT
${
portStr
}
_UNTAG"
echo
-e
"
\t
prompt
\"
Untag frames
\"
"
echo
-e
"
\t
default VLANS_PORT
${
portStr
}
_UNTAG_ALL"
echo
-e
"
\t
default VLANS_PORT
${
portStr
}
_UNTAG_ALL if VLANS_PORT
${
portStr
}
_MODE_ACCESS"
echo
-e
"
\t
default VLANS_PORT
${
portStr
}
_UNTAG_NONE"
echo
-e
"
\t
depends on VLANS_PORT
${
portStr
}
_MODE_ACCESS || VLANS_RAW_PORT_CONFIG"
echo
-e
"
\t
help"
echo
-e
"
\t
Decide whether VLAN-tags should be removed"
...
...
@@ -115,6 +116,7 @@ function print_port_config() {
echo
-e
"
\n
config VLANS_PORT
${
portStr
}
_PRIO"
echo
-e
"
\t
int
\"
Priority
\"
"
echo
-e
"
\t
depends on VLANS_RAW_PORT_CONFIG || VLANS_PORT
${
portStr
}
_MODE_ACCESS || VLANS_PORT
${
portStr
}
_MODE_DISABLED || VLANS_PORT
${
portStr
}
_MODE_UNQUALIFIED"
echo
-e
"
\t
default -1"
echo
-e
"
\t
range -1 7"
echo
-e
"
\t
help"
...
...
@@ -124,13 +126,15 @@ function print_port_config() {
echo
-e
"
\n
config VLANS_PORT
${
portStr
}
_VID"
echo
-e
"
\t
string
\"
VID
\"
"
echo
-e
"
\t
depends on VLANS_RAW_PORT_CONFIG || VLANS_PORT
${
portStr
}
_MODE_ACCESS"
echo
-e
"
\t
default
\"\"
"
help_vlan_port_vid
echo
-e
"
\n
config VLANS_PORT
${
portStr
}
_PTP_VID"
echo
-e
"
\t
string
\"
PTP VID
\"
"
echo
-e
"
\t
depends on VLANS_RAW_PORT_CONFIG"
echo
-e
"
\t
default VLANS_PORT
${
portStr
}
_VID"
echo
-e
"
\t
depends on VLANS_RAW_PORT_CONFIG || VLANS_PORT
${
portStr
}
_MODE_TRUNK || VLANS_PORT
${
portStr
}
_MODE_DISABLED || VLANS_PORT
${
portStr
}
_MODE_UNQUALIFIED"
echo
-e
"
\t
default VLANS_PORT
${
portStr
}
_VID if VLANS_PORT
${
portStr
}
_MODE_ACCESS"
echo
-e
"
\t
default
\"\"
"
echo
-e
"
\t
help"
echo
-e
"
\t
VID used for the PTP messages"
...
...
userspace/tools/wrs_vlans.c
View file @
87a2d1b6
...
...
@@ -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