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
2fb4ba58
Commit
2fb4ba58
authored
Oct 15, 2020
by
Michal Wasiak
Committed by
Adam Wujek
Oct 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
snmp: add helper function to read ports data from rtu's shmem
Signed-off-by:
Michal Wasiak
<
michal.wasiak@gmail.com
>
parent
82f4d97f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
snmp_shmem.c
userspace/snmpd/snmp_shmem.c
+31
-0
snmp_shmem.h
userspace/snmpd/snmp_shmem.h
+2
-0
No files found.
userspace/snmpd/snmp_shmem.c
View file @
2fb4ba58
...
...
@@ -314,6 +314,37 @@ int shmem_rtu_read_htab(struct rtu_filtering_entry *rtu_htab_local, int *read_en
return
0
;
}
int
shmem_rtu_read_ports
(
struct
rtu_port_entry
*
ports_tab_local
,
int
*
nports
)
{
unsigned
ii
;
unsigned
retries
=
0
;
struct
rtu_port_entry
*
rtu_ports_shm
;
struct
rtu_shmem_header
*
rtu_hdr
;
rtu_hdr
=
(
void
*
)
rtud_head
+
rtud_head
->
data_off
;
rtu_ports_shm
=
wrs_shm_follow
(
rtud_head
,
rtu_hdr
->
rtu_ports
);
if
(
!
rtu_ports_shm
)
return
-
2
;
/* read data, with the sequential lock to have all data consistent */
while
(
1
)
{
ii
=
wrs_shm_seqbegin
(
rtud_head
);
memcpy
(
ports_tab_local
,
rtu_ports_shm
,
HAL_MAX_PORTS
*
sizeof
(
*
rtu_ports_shm
));
*
nports
=
rtu_hdr
->
rtu_nports
;
retries
++
;
if
(
retries
>
100
)
{
pr_error
(
"couldn't read consistent data from RTU's "
"shmem. Use inconsistent
\n
"
);
break
;
/* use inconsistent data */
}
if
(
!
wrs_shm_seqretry
(
rtud_head
,
ii
))
break
;
/* consistent read */
usleep
(
1000
);
}
return
0
;
}
/* Compare entries by by MAC */
int
cmp_rtu_entries_mac
(
const
void
*
p1
,
const
void
*
p2
)
{
...
...
userspace/snmpd/snmp_shmem.h
View file @
2fb4ba58
...
...
@@ -29,6 +29,8 @@ int shmem_ready_ppsi(void);
int
shmem_ready_rtud
(
void
);
int
shmem_rtu_read_htab
(
struct
rtu_filtering_entry
*
rtu_htab_local
,
int
*
read_entries
);
int
shmem_rtu_read_vlans
(
struct
rtu_vlan_table_entry
*
vlan_tab_local
);
int
shmem_rtu_read_ports
(
struct
rtu_port_entry
*
ports_tab_local
,
int
*
nports
);
/* Compare entries by by MAC */
int
cmp_rtu_entries_mac
(
const
void
*
p1
,
const
void
*
p2
);
/* Compare rtu entries by FID then by MAC */
...
...
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