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
dfe39cf4
Commit
dfe39cf4
authored
Jul 24, 2013
by
Maciej Lipinski
Committed by
Alessandro Rubini
May 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tool] adding dump of VLANs to rtu_stat tool (needs wrsw_rtud modifications)
parent
87e79c83
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
162 additions
and
10 deletions
+162
-10
rtu_stat.c
userspace/tools/rtu_stat.c
+67
-10
rtud_exports.c
userspace/wrsw_rtud/rtud_exports.c
+53
-0
rtud_exports.h
userspace/wrsw_rtud/rtud_exports.h
+42
-0
No files found.
userspace/tools/rtu_stat.c
View file @
dfe39cf4
...
...
@@ -36,12 +36,20 @@
static
struct
minipc_ch
*
rtud_ch
;
static
hexp_port_list_t
plist
;
// forwarding entries
void
rtudexp_get_fd_list
(
rtudexp_fd_list_t
*
list
,
int
start_from
)
{
minipc_call
(
rtud_ch
,
MINIPC_TIMEOUT
,
&
rtud_export_get_fd_list
,
list
,
start_from
);
}
// vlan entries
void
rtudexp_get_vd_list
(
rtudexp_vd_list_t
*
list
,
int
current
)
{
minipc_call
(
rtud_ch
,
MINIPC_TIMEOUT
,
&
rtud_export_get_vd_list
,
list
,
current
);
}
int
rtudexp_clear_entries
(
int
netif
,
int
force
)
{
...
...
@@ -57,10 +65,17 @@ int rtudexp_add_entry(const char *eha, int port, int mode)
return
(
ret
<
0
)
?
ret
:
val
;
}
int
rtudexp_vlan_entry
(
int
vid
,
int
fid
,
const
char
*
ch_mask
,
int
drop
)
{
int
val
,
ret
;
int
mask
;
sscanf
(
ch_mask
,
"%x"
,
&
mask
);
ret
=
minipc_call
(
rtud_ch
,
MINIPC_TIMEOUT
,
&
rtud_export_vlan_entry
,
&
val
,
vid
,
fid
,
mask
,
drop
);
return
(
ret
<
0
)
?
ret
:
val
;
}
#define RTU_MAX_ENTRIES 8192
#define NUM_VLANS 4096
void
fetch_rtu_fd
(
rtudexp_fd_entry_t
*
d
,
int
*
n_entries
)
...
...
@@ -81,6 +96,20 @@ void fetch_rtu_fd(rtudexp_fd_entry_t *d, int *n_entries)
*
n_entries
=
n
;
}
int
fetch_rtu_vd
(
rtudexp_vd_entry_t
*
d
,
int
*
n_entries
)
{
int
start
=
0
,
n
=
0
;
rtudexp_vd_list_t
list
;
do
{
rtudexp_get_vd_list
(
&
list
,
start
);
memcpy
(
d
+
n
,
list
.
list
,
sizeof
(
rtudexp_vd_entry_t
)
*
list
.
num_entries
);
start
=
list
.
next
;
n
+=
list
.
num_entries
;
}
while
(
start
>
0
);
*
n_entries
=
n
;
}
/**
* \brief Write mac address into a buffer to avoid concurrent access on static variable.
*/
...
...
@@ -136,7 +165,8 @@ void show_help(char *prgname)
" help: Show this message
\n
"
" list: List the routing table (same as empty command)
\n
"
" remove <ifnum> [<force>]: Remove all dynamic entries for one interface
\n
"
" add <mac (XX:XX:XX:XX:XX)> <ifnum> [<mode>]: Add entry for a specific MAC address
\n
"
);
" add <mac (XX:XX:XX:XX:XX)> <ifnum> [<mode>]: Add entry for a specific MAC address
\n
"
" vlan <vid> <fid> <hex mask> [<drop>]: Add VLAN entry with vid, fid, mask and drop flag
\n
"
);
exit
(
1
);
}
...
...
@@ -145,8 +175,9 @@ int main(int argc, char **argv)
{
rtudexp_fd_entry_t
fd_list
[
RTU_MAX_ENTRIES
];
rtudexp_vd_entry_t
vd_list
[
NUM_VLANS
];
int
n_entries
;
int
n_
fd_entries
,
n_vd_
entries
;
int
i
,
isok
;
if
(
halexp_client_init
()
<
0
)
...
...
@@ -164,7 +195,6 @@ int main(int argc, char **argv)
return
-
1
;
}
minipc_set_logfile
(
rtud_ch
,
stderr
);
isok
=
0
;
if
(
argc
>
1
)
{
...
...
@@ -179,6 +209,12 @@ int main(int argc, char **argv)
if
((
argc
>
3
)
&&
(
rtudexp_add_entry
(
argv
[
2
],
atoi
(
argv
[
3
]),
atoidef
(
argv
[
4
],
0
))
==
0
))
isok
=
1
;
else
printf
(
"Could not %s entry for %s
\n
"
,
argv
[
2
],
argv
[
3
]);
}
else
if
(
strcmp
(
argv
[
1
],
"vlan"
)
==
0
)
{
if
((
argc
>
3
)
&&
(
rtudexp_vlan_entry
(
atoi
(
argv
[
2
]),
atoi
(
argv
[
3
]),
argv
[
4
],
atoidef
(
argv
[
5
],
0
))
==
0
))
isok
=
1
;
else
printf
(
"Could not %s entry for %s
\n
"
,
argv
[
2
],
argv
[
3
]);
exit
(
1
);
}
else
if
(
strcmp
(
argv
[
1
],
"list"
)
==
0
)
isok
=
1
;
//Does not continue
...
...
@@ -188,18 +224,18 @@ int main(int argc, char **argv)
}
halexp_query_ports
(
&
plist
);
fetch_rtu_fd
(
fd_list
,
&
n_entries
);
fetch_rtu_fd
(
fd_list
,
&
n_
fd_
entries
);
qsort
(
fd_list
,
n_entries
,
sizeof
(
rtudexp_fd_entry_t
),
cmp_entries
);
qsort
(
fd_list
,
n_
fd_
entries
,
sizeof
(
rtudexp_fd_entry_t
),
cmp_entries
);
printf
(
"RTU Filtering Database Dump: %d rules
\n
"
,
n_entries
);
printf
(
"RTU Filtering Database Dump: %d rules
\n
"
,
n_
fd_
entries
);
printf
(
"
\n
"
);
printf
(
"MAC Dst.ports FID Type Age [s]
\n
"
);
printf
(
"----------------------------------------------------------------------------------
\n
"
);
char
mac_buf
[
ETH_ALEN_STR
];
for
(
i
=
0
;
i
<
n_entries
;
i
++
)
for
(
i
=
0
;
i
<
n_
fd_
entries
;
i
++
)
{
printf
(
"%-25s %-12s %2d %s (hash %03x:%x) "
,
mac_to_buffer
(
fd_list
[
i
].
mac
,
mac_buf
),
...
...
@@ -213,6 +249,27 @@ int main(int argc, char **argv)
else
printf
(
"-
\n
"
);
}
printf
(
"
\n
"
);
fetch_rtu_vd
(
vd_list
,
&
n_vd_entries
);
printf
(
"RTU VLAN Table Dump: %d active VIDs defined
\n
"
,
n_vd_entries
);
printf
(
"
\n
"
);
printf
(
" VID FID MASK DROP PRIO PRIO_OVERRIDE
\n
"
);
printf
(
"-----------------------------------------------------------
\n
"
);
for
(
i
=
0
;
i
<
n_vd_entries
;
i
++
)
{
printf
(
"%4d %4d 0x%8x "
,
vd_list
[
i
].
vid
,
vd_list
[
i
].
fid
,
vd_list
[
i
].
port_mask
);
if
(
vd_list
[
i
].
drop
==
0
)
printf
(
"NO "
);
else
printf
(
"YES"
);
if
(
vd_list
[
i
].
has_prio
==
0
)
printf
(
" -- "
);
else
printf
(
" %1d "
,
vd_list
[
i
].
prio
);
if
(
vd_list
[
i
].
prio_override
==
0
)
printf
(
" NO "
);
else
printf
(
" YES "
);
printf
(
"
\n
"
);
}
printf
(
"
\n
"
);
return
0
;
}
userspace/wrsw_rtud/rtud_exports.c
View file @
dfe39cf4
...
...
@@ -84,6 +84,43 @@ int rtudexp_get_fd_list(const struct minipc_pd *pd,
list
->
next
=
(
i
<
8
?
0
:
start_from
+
i
);
return
0
;
}
/* The exported vlan */
int
rtudexp_get_vd_list
(
const
struct
minipc_pd
*
pd
,
uint32_t
*
args
,
void
*
ret
)
{
int
i
=
0
;
rtudexp_vd_list_t
*
list
=
ret
;
int
current
=
args
[
0
];
TRACE
(
TRACE_INFO
,
"GetVDList start=%d"
,
current
);
do
{
struct
vlan_table_entry
*
ent
=
rtu_vlan_entry_get
(
current
);
if
(
!
ent
)
break
;
if
(
ent
->
drop
==
0
)
{
list
->
list
[
i
].
vid
=
current
;
list
->
list
[
i
].
port_mask
=
ent
->
port_mask
;
list
->
list
[
i
].
drop
=
ent
->
drop
;
list
->
list
[
i
].
fid
=
ent
->
fid
;
list
->
list
[
i
].
has_prio
=
ent
->
has_prio
;
list
->
list
[
i
].
prio_override
=
ent
->
prio_override
;
list
->
list
[
i
].
prio
=
ent
->
prio
;
i
++
;
}
current
++
;
if
(
current
==
NUM_VLANS
)
break
;
}
while
(
i
<
8
);
list
->
num_entries
=
i
;
list
->
next
=
(
i
<
8
?
0
:
current
);
return
0
;
}
int
rtudexp_clear_entries
(
const
struct
minipc_pd
*
pd
,
...
...
@@ -133,6 +170,20 @@ int rtudexp_add_entry(const struct minipc_pd *pd,
return
*
p_ret
;
}
int
rtudexp_vlan_entry
(
const
struct
minipc_pd
*
pd
,
uint32_t
*
args
,
void
*
ret
)
{
int
vid
,
fid
,
mask
,
drop
;
int
*
p_ret
=
(
int
*
)
ret
;
//force pointed to int type
*
p_ret
=
0
;
vid
=
(
int
)
args
[
0
];
fid
=
(
int
)
args
[
1
];
mask
=
(
int
)
args
[
2
];
drop
=
(
int
)
args
[
3
];
rtu_fd_create_vlan_entry
(
vid
,
(
uint32_t
)
mask
,
(
uint8_t
)
fid
,
0
/*prio*/
,
0
/*has_prio*/
,
0
/*prio_override*/
,
drop
/*drop */
);
return
*
p_ret
;
}
int
rtud_init_exports
()
{
...
...
@@ -145,8 +196,10 @@ int rtud_init_exports()
minipc_fileno
(
rtud_ch
));
MINIPC_EXP_FUNC
(
rtud_export_get_fd_list
,
rtudexp_get_fd_list
);
MINIPC_EXP_FUNC
(
rtud_export_get_vd_list
,
rtudexp_get_vd_list
);
MINIPC_EXP_FUNC
(
rtud_export_clear_entries
,
rtudexp_clear_entries
);
MINIPC_EXP_FUNC
(
rtud_export_add_entry
,
rtudexp_add_entry
);
MINIPC_EXP_FUNC
(
rtud_export_vlan_entry
,
rtudexp_vlan_entry
);
return
0
;
}
...
...
userspace/wrsw_rtud/rtud_exports.h
View file @
dfe39cf4
...
...
@@ -52,6 +52,26 @@ typedef struct {
int
next
;
}
rtudexp_fd_list_t
;
///// VLAN export
typedef
struct
{
int
vid
;
uint32_t
port_mask
;
uint8_t
fid
;
uint8_t
prio
;
int
has_prio
;
int
prio_override
;
int
drop
;
}
rtudexp_vd_entry_t
;
typedef
struct
{
rtudexp_vd_entry_t
list
[
8
];
int
num_entries
;
int
next
;
}
rtudexp_vd_list_t
;
/* Export this function: it returns a structure */
struct
minipc_pd
rtud_export_get_fd_list
=
{
.
name
=
"get_fd_list"
,
...
...
@@ -62,6 +82,16 @@ struct minipc_pd rtud_export_get_fd_list = {
MINIPC_ARG_END
,
},
};
/* Export this function: it returns a structure */
struct
minipc_pd
rtud_export_get_vd_list
=
{
.
name
=
"get_vd_list"
,
.
retval
=
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_STRUCT
,
rtudexp_vd_list_t
),
.
args
=
{
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_END
,
},
};
/* Export of a function to set remove entry in rtu */
struct
minipc_pd
rtud_export_clear_entries
=
{
...
...
@@ -87,5 +117,17 @@ struct minipc_pd rtud_export_add_entry = {
},
};
/* Export of a function to add vlan entry in rtu */
struct
minipc_pd
rtud_export_vlan_entry
=
{
.
name
=
"vlan_entry"
,
.
retval
=
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
.
args
=
{
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_ENCODE
(
MINIPC_ATYPE_INT
,
int
),
MINIPC_ARG_END
,
},
};
#endif
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