Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
White Rabbit Switch - Software
Manage
Activity
Members
Labels
Plan
Issues
85
Issue boards
Milestones
Wiki
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
White Rabbit Switch - Software
Commits
91041b88
Commit
91041b88
authored
9 years ago
by
Adam Wujek
Browse files
Options
Downloads
Patches
Plain Diff
userspace/wrsw_rtud: preserve rtu and vlan entries over rtud restarts.
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
67c861c1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
userspace/libwr/include/libwr/rtu_shmem.h
+4
-1
4 additions, 1 deletion
userspace/libwr/include/libwr/rtu_shmem.h
userspace/wrsw_rtud/rtu_fd.c
+66
-15
66 additions, 15 deletions
userspace/wrsw_rtud/rtu_fd.c
with
70 additions
and
16 deletions
userspace/libwr/include/libwr/rtu_shmem.h
+
4
−
1
View file @
91041b88
...
...
@@ -92,10 +92,13 @@ struct rtu_vlan_table_entry {
};
/* This is the overall structure stored in shared memory */
#define RTU_SHMEM_VERSION 1
/* Version 1 */
#define RTU_SHMEM_VERSION 2
/* Version 2, added filters_offset and
* vlans_offset */
struct
rtu_shmem_header
{
struct
rtu_filtering_entry
*
filters
;
struct
rtu_vlan_table_entry
*
vlans
;
unsigned
long
filters_offset
;
unsigned
long
vlans_offset
;
};
#endif
/* __LIBWR_RTU_SHMEM_H__ */
This diff is collapsed.
Click to expand it.
userspace/wrsw_rtud/rtu_fd.c
+
66
−
15
View file @
91041b88
...
...
@@ -131,30 +131,81 @@ int rtu_fd_init(uint16_t poly, unsigned long aging)
WRS_SHM_WRITE
|
WRS_SHM_LOCKED
);
if
(
!
rtu_port_shmem
)
{
pr_error
(
"%s: Can't join shmem: %s
\n
"
,
__func__
,
strerror
(
errno
));
strerror
(
errno
));
return
-
1
;
}
/* Created at header->offset */
rtu_hdr
=
wrs_shm_alloc
(
rtu_port_shmem
,
sizeof
(
*
rtu_hdr
));
rtu_htab
=
wrs_shm_alloc
(
rtu_port_shmem
,
sizeof
(
*
rtu_htab
)
*
HTAB_ENTRIES
);
rtu_hdr
->
filters
=
(
struct
rtu_filtering_entry
*
)
rtu_htab
;
vlan_tab
=
wrs_shm_alloc
(
rtu_port_shmem
,
sizeof
(
*
vlan_tab
)
*
NUM_VLANS
);
rtu_hdr
->
vlans
=
vlan_tab
;
if
(
rtu_port_shmem
->
pidsequence
==
1
)
{
/* for first RTUd run */
pr_info
(
"Alloc rtu_hdr
\n
"
);
rtu_hdr
=
wrs_shm_alloc
(
rtu_port_shmem
,
sizeof
(
*
rtu_hdr
));
}
else
{
/* rtu_hdr was created at header->offset */
rtu_hdr
=
(
void
*
)
rtu_port_shmem
+
rtu_port_shmem
->
data_off
;
/* move data_size to have have similar behavior like
* wrs_shm_alloc, needed for future allocations */
/* force 8-alignment */
rtu_port_shmem
->
data_size
+=
(
sizeof
(
*
rtu_hdr
)
+
7
)
&
~
7
;
}
if
(
!
rtu_hdr
)
{
pr_error
(
"%s: Cannot allocate mem in shmem rtu_hdr
\n
"
,
__func__
);
return
-
1
;
}
if
(
!
rtu_hdr
->
filters
)
{
/* for first RTUd run */
pr_info
(
"Alloc rtu_htab
\n
"
);
rtu_htab
=
wrs_shm_alloc
(
rtu_port_shmem
,
sizeof
(
*
rtu_htab
)
*
HTAB_ENTRIES
);
rtu_hdr
->
filters
=
(
struct
rtu_filtering_entry
*
)
rtu_htab
;
rtu_hdr
->
filters_offset
=
(
void
*
)
rtu_htab
-
(
void
*
)
rtu_port_shmem
;
pr_info
(
"Clean filtering database.
\n
"
);
clean_fd
();
/* clean filtering database */
}
else
{
pr_info
(
"Use existing filtering table.
\n
"
);
/* next RTUd runs */
rtu_hdr
->
filters
=
(
void
*
)
rtu_port_shmem
+
rtu_hdr
->
filters_offset
;
rtu_htab
=
(
void
*
)
rtu_hdr
->
filters
;
/* move data_size to have have similar behavior like
* wrs_shm_alloc, needed for future allocations */
/* force 8-alignment */
rtu_port_shmem
->
data_size
+=
(
sizeof
(
*
rtu_htab
)
*
HTAB_ENTRIES
+
7
)
&
~
7
;
}
if
(
!
rtu_hdr
->
vlans
)
{
/* for first RTUd run */
pr_info
(
"Alloc vlan_tab
\n
"
);
vlan_tab
=
wrs_shm_alloc
(
rtu_port_shmem
,
sizeof
(
*
vlan_tab
)
*
NUM_VLANS
);
rtu_hdr
->
vlans
=
vlan_tab
;
rtu_hdr
->
vlans_offset
=
(
void
*
)
vlan_tab
-
(
void
*
)
rtu_port_shmem
;
pr_info
(
"Clean vlan database.
\n
"
);
clean_vd
();
/* clean VLAN database */
}
else
{
pr_info
(
"Use existing vlan table.
\n
"
);
/* next RTUd runs */
rtu_hdr
->
vlans
=
(
void
*
)
rtu_port_shmem
+
rtu_hdr
->
vlans_offset
;
vlan_tab
=
(
void
*
)
rtu_hdr
->
vlans
;
/* move data_size to have have similar behavior like
* wrs_shm_alloc, needed for future allocations */
/* force 8-alignment */
rtu_port_shmem
->
data_size
+=
(
sizeof
(
*
vlan_tab
)
*
NUM_VLANS
+
7
)
&
~
7
;
}
if
((
!
rtu_htab
)
||
(
!
vlan_tab
))
{
pr_error
(
"%s:
c
annot allocate mem in shmem
\n
"
,
__func__
);
pr_error
(
"%s:
C
annot allocate mem in shmem
\n
"
,
__func__
);
return
-
1
;
}
/* add version info */
rtu_port_shmem
->
version
=
RTU_SHMEM_VERSION
;
pr_info
(
"clean filtering database.
\n
"
);
clean_fd
();
// clean filtering database
pr_info
(
"clean vlan database.
\n
"
);
clean_vd
();
// clean VLAN database
pr_info
(
"clean aging map.
\n
"
);
rtu_read_aging_bitmap
(
bitmap
);
// clean aging registers
pr_info
(
"set aging time [%ld].
\n
"
,
aging
);
...
...
@@ -234,7 +285,7 @@ int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask,
/* Case 1: entry already present in the hashtable */
if
(
htab_search
(
mac
,
fid
,
&
ent
))
{
pr_debug
(
"Entry for mac %s already found."
,
pr_debug
(
"Entry for mac %s already found.
\n
"
,
mac_to_string
(
mac
));
if
(
at_existing_entry
==
ADD_TO_EXISTING
)
// enable multipath for redundancy
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment