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
84
Issues
84
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
59188589
Commit
59188589
authored
Feb 22, 2018
by
Maciej Lipinski
Committed by
Adam Wujek
Sep 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtu_stat: added possibility to specify VID when adding MAC to RTU Table
parent
d8bce438
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
16 deletions
+46
-16
rtu_shmem.h
userspace/libwr/include/libwr/rtu_shmem.h
+3
-0
rtu_stat.c
userspace/tools/rtu_stat.c
+34
-14
rtud_exports.c
userspace/wrsw_rtud/rtud_exports.c
+8
-2
rtud_exports.h
userspace/wrsw_rtud/rtud_exports.h
+1
-0
No files found.
userspace/libwr/include/libwr/rtu_shmem.h
View file @
59188589
...
...
@@ -25,6 +25,9 @@ struct rtu_addr {
#define RTU_ENTRY_TYPE_DYNAMIC 1
#define RTU_ENTRY_TYPE_STATIC 0
/* When adding MAC entry, the Default VID is 0x0 */
#define RTU_ENTRY_VID_DEFAULT 0
/* helper to verify correctness of a rtu type */
static
inline
int
rtu_check_type
(
int
type
)
{
...
...
userspace/tools/rtu_stat.c
View file @
59188589
...
...
@@ -52,11 +52,11 @@ int rtudexp_clear_entries(int port, int type)
return
(
ret
<
0
)
?
ret
:
val
;
}
int
rtudexp_add_entry
(
const
char
*
mac
,
int
port_mask
,
int
type
)
int
rtudexp_add_entry
(
const
char
*
mac
,
int
port_mask
,
int
type
,
int
vid
)
{
int
val
,
ret
;
ret
=
minipc_call
(
rtud_ch
,
MINIPC_TIMEOUT
,
&
rtud_export_add_entry
,
&
val
,
mac
,
port_mask
,
type
);
&
val
,
mac
,
port_mask
,
type
,
vid
);
return
(
ret
<
0
)
?
ret
:
val
;
}
...
...
@@ -145,13 +145,20 @@ void show_help(char *prgname)
" MAC address on a given port mask with
\n
"
" an optional type (default %d-static)
\n
"
,
RTU_ENTRY_TYPE_STATIC
);
fprintf
(
stderr
,
" add <mac> <port> [<type>]: Add entry for a specific MAC address with an
\n
"
" optional type (default %d-static)
\n
"
,
RTU_ENTRY_TYPE_STATIC
);
fprintf
(
stderr
,
" add mask <mac> <port_mask> [<type>]: Add an entry for a specific
\n
"
fprintf
(
stderr
,
" add <mac> <port> [<type> <VID>]: Add entry for a specific MAC address with an
\n
"
" optional type (default %d-static) and VID (default %d);
\n
"
" if VID is specified, the type also has to be specified;
\n
"
" in order to add MAC to a VID, this VID must exist in the
\n
"
" VLAN Table
\n
"
,
RTU_ENTRY_TYPE_STATIC
,
RTU_ENTRY_VID_DEFAULT
);
fprintf
(
stderr
,
" add mask <mac> <port_mask> [<type> <VID>]: Add an entry for a specific
\n
"
" MAC address and multiple ports with
\n
"
" an optional type (default %d-static)
\n
"
,
RTU_ENTRY_TYPE_STATIC
);
" an optional type (default %d-static)
\n
"
" and VID (default %d); if VID is specified,
\n
"
" type also has to be specified;in order to
\n
"
" add MAC to a VID, this VID must exist in the
\n
"
" VLAN Table
\n
"
,
RTU_ENTRY_TYPE_STATIC
,
RTU_ENTRY_VID_DEFAULT
);
fprintf
(
stderr
,
" learning: Read status of learning process in RTU
\n
"
);
fprintf
(
stderr
,
" learning <enable|disable> [<port>]: Enable/disable learning process in RTU
\n
"
" for optional port, otherwise for all
\n
"
...
...
@@ -404,6 +411,7 @@ int main(int argc, char **argv)
int
n_wait
=
0
;
int
ret
;
int
type
;
int
vid
;
int
enable
;
uint32_t
mask
;
...
...
@@ -516,11 +524,11 @@ int main(int argc, char **argv)
exit
(
1
);
}
isok
=
1
;
/* ****************** add mask <mac> <port_mask> [<type>
] ******
************ */
/* ****************** add mask <mac> <port_mask> [<type>
, <VID>]
************ */
}
else
if
(
argc
>=
5
&&
!
strcmp
(
argv
[
1
],
"add"
)
&&
!
strcmp
(
argv
[
2
],
"mask"
))
{
/* rtu_stat add mask <mac> <port_mask> [<type>] */
/* rtu_stat add mask <mac> <port_mask> [<type>
, <VID>
] */
i
=
read_port_mask
(
argv
[
4
],
nports
);
/* interface number 1..18, CPU is 19 */
if
(
i
<
0
)
{
...
...
@@ -536,9 +544,15 @@ int main(int argc, char **argv)
fprintf
(
stderr
,
"rtu_stat: Unknown type %d
\n
"
,
type
);
exit
(
1
);
}
vid
=
atoidef
(
argc
,
argv
,
6
,
RTU_ENTRY_VID_DEFAULT
);
if
(
0
>
vid
||
vid
>
0xFFF
)
{
fprintf
(
stderr
,
"rtu_stat: Incorrect VID %d
\n
"
,
vid
);
exit
(
1
);
}
ret
=
rtudexp_add_entry
(
argv
[
3
],
/* MAC */
i
,
/* port mask */
type
/* type */
type
,
/* type */
vid
/* VID */
);
if
(
ret
>
0
)
printf
(
"Added %d entries for port mask 0x%x
\n
"
,
...
...
@@ -548,10 +562,10 @@ int main(int argc, char **argv)
exit
(
1
);
}
isok
=
1
;
/* ****************** add <mac> <port> [<type>
] ******
********************** */
/* ****************** add <mac> <port> [<type>
, <VID>]
********************** */
}
else
if
(
argc
>=
4
&&
!
strcmp
(
argv
[
1
],
"add"
))
{
/* rtu_stat add <mac> <port> [<type>] */
/* rtu_stat add <mac> <port> [<type>
, <VID>
] */
i
=
read_port
(
argv
[
3
],
nports
);
/* interface number 1..18, CPU is 19 */
if
(
i
<
0
)
{
...
...
@@ -567,9 +581,15 @@ int main(int argc, char **argv)
fprintf
(
stderr
,
"rtu_stat: Unknown type %d
\n
"
,
type
);
exit
(
1
);
}
vid
=
atoidef
(
argc
,
argv
,
5
,
RTU_ENTRY_VID_DEFAULT
);
if
(
0
>
vid
||
vid
>
0xFFF
)
{
fprintf
(
stderr
,
"rtu_stat: Incorrect VID %d
\n
"
,
vid
);
exit
(
1
);
}
ret
=
rtudexp_add_entry
(
argv
[
2
],
/* MAC */
1
<<
(
i
-
1
),
/* port mask */
type
/* type */
type
,
/* type */
vid
/* VID */
);
if
(
ret
>
0
)
printf
(
"Added %d entries for port %d (wri%d)
\n
"
,
...
...
userspace/wrsw_rtud/rtud_exports.c
View file @
59188589
...
...
@@ -81,12 +81,14 @@ int rtudexp_add_entry(const struct minipc_pd *pd, uint32_t * args, void *ret)
char
*
mac
;
uint32_t
port_mask
;
int
type
;
int
vid
;
int
*
p_ret
=
(
int
*
)
ret
;
/* force pointed to int type */
mac
=
(
char
*
)
args
;
args
=
minipc_get_next_arg
(
args
,
pd
->
args
[
0
]);
port_mask
=
(
int
)
args
[
0
];
type
=
(
int
)
args
[
1
];
vid
=
(
int
)
args
[
2
];
if
(
mac_verify
(
mac
))
{
pr_error
(
"%s is an invalid MAC format (XX:XX:XX:XX:XX:XX)
\n
"
,
...
...
@@ -105,11 +107,15 @@ int rtudexp_add_entry(const struct minipc_pd *pd, uint32_t * args, void *ret)
*
p_ret
=
-
1
;
return
*
p_ret
;
}
if
(
0
>
vid
||
vid
>
0xFFF
)
{
/* FID must be between 0x0 and 0xFFF*/
pr_error
(
"Wrong FID value 0x%x
\n
"
,
vid
);
*
p_ret
=
-
1
;
return
*
p_ret
;
}
pr_debug
(
"Request to add an entry with port mask 0x%x, MAC: %s, "
"type:%s
\n
"
,
port_mask
,
mac_to_string
(
mac_tmp
),
rtu_type_to_str
(
type
));
*
p_ret
=
rtu_fd_create_entry
(
mac_tmp
,
0
,
port_mask
,
type
,
*
p_ret
=
rtu_fd_create_entry
(
mac_tmp
,
vid
,
port_mask
,
type
,
OVERRIDE_EXISTING
);
return
*
p_ret
;
}
...
...
userspace/wrsw_rtud/rtud_exports.h
View file @
59188589
...
...
@@ -62,6 +62,7 @@ struct minipc_pd rtud_export_add_entry = {
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_STRING
,
char
*
),
/* MAC */
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
/* port mask */
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
/* type */
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
/* VID */
MINIPC_ARG_END
,
},
};
...
...
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