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
7355ae4c
Commit
7355ae4c
authored
Aug 14, 2021
by
Adam Wujek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/tools/wrs_dump_shmem: add labels to some hal info
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
f858c2e8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
46 deletions
+114
-46
Makefile
userspace/tools/Makefile
+1
-0
wrs_dump_shmem.c
userspace/tools/wrs_dump_shmem.c
+105
-45
wrs_dump_shmem.h
userspace/tools/wrs_dump_shmem.h
+8
-1
No files found.
userspace/tools/Makefile
View file @
7355ae4c
...
...
@@ -43,6 +43,7 @@ CFLAGS += -Wall \
-Wstrict-prototypes
\
-I
$(LINUX)
/arch/arm/mach-at91/include
\
-I
../wrsw_rtud
\
-I
../wrsw_hal
\
-I
../mini-rpc
\
-I
../libsdb
\
-I
../include
\
...
...
userspace/tools/wrs_dump_shmem.c
View file @
7355ae4c
...
...
@@ -18,6 +18,7 @@
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
#include "time_lib.h"
#include "hal_port_fsm_pllP.h"
/* be safe, in case some other header had them slightly differently */
#undef container_of
...
...
@@ -96,21 +97,21 @@ static int dump_all_rtu_entries = 0; /* rtu exports 4096 vlans and 2048 htab
#define REL_DIFF_FRACBITS 62
#define REL_DIFF_FRACMASK 0x3fffffffffffffff
void
decode_relative_difference
(
RelativeDifference
rd
,
int32_t
*
nsecs
,
uint64_t
*
sub_yocto
)
{
int64_t
fraction
;
uint64_t
bitWeight
=
500000000000000000
;
uint64_t
mask
;
*
sub_yocto
=
0
;
*
nsecs
=
(
int32_t
)(
rd
>>
REL_DIFF_FRACBITS
);
fraction
=
(
int64_t
)
rd
&
REL_DIFF_FRACMASK
;
for
(
mask
=
(
uint64_t
)
1
<<
(
REL_DIFF_FRACBITS
-
1
);
mask
!=
0
;
mask
>>=
1
)
{
if
(
mask
&
fraction
)
*
sub_yocto
+=
bitWeight
;
bitWeight
/=
2
;
}
int
print_labels
=
1
;
void
print_str
(
char
*
s
)
{
if
(
print_labels
==
0
)
return
;
printf
(
" (%s)"
,
s
);
}
/* create fancy macro to shorten the switch statements, assign val as a string to p */
#define ENUM_TO_P_IN_CASE(val, p) \
case val: \
p = #val;\
break;
void
dump_one_field
(
void
*
addr
,
struct
dump_info
*
info
,
char
*
info_prefix
)
{
void
*
p
=
addr
+
info
->
offset
;
...
...
@@ -120,6 +121,7 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
int
i
;
int
value
;
char
pname
[
128
];
char
*
char_p
;
if
(
info_prefix
!=
NULL
)
sprintf
(
pname
,
"%s.%s"
,
info_prefix
,
info
->
name
);
...
...
@@ -203,13 +205,13 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
i
=
*
(
uint8_t
*
)
p
;
switch
(
i
)
{
case
0
:
printf
(
"
no(%d
)
\n
"
,
i
);
printf
(
"
%d (no
)
\n
"
,
i
);
break
;
case
1
:
printf
(
"
yes(%d
)
\n
"
,
i
);
printf
(
"
%d (yes
)
\n
"
,
i
);
break
;
default:
printf
(
"
Unknown(%d
)
\n
"
,
i
);
printf
(
"
%d (Unknown
)
\n
"
,
i
);
}
break
;
...
...
@@ -255,24 +257,25 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
printf
(
"%.3f mW
\n
"
,
ntohs
(
*
(
short
*
)
p
)
/
(
float
)
10000
);
break
;
case
dump_type_port_mode
:
switch
(
*
(
uint32_t
*
)
p
)
{
i
=
*
(
uint32_t
*
)
p
;
switch
(
i
)
{
case
HEXP_PORT_MODE_WR_MASTER
:
printf
(
"
WR Master
\n
"
);
printf
(
"
%d (WR Master)
\n
"
,
i
);
break
;
case
HEXP_PORT_MODE_WR_SLAVE
:
printf
(
"
WR Slave
\n
"
);
printf
(
"
%d (WR Slave)
\n
"
,
i
);
break
;
case
HEXP_PORT_MODE_NON_WR
:
printf
(
"
Non-WR
\n
"
);
printf
(
"
%d (Non-WR)
\n
"
,
i
);
break
;
case
HEXP_PORT_MODE_NONE
:
printf
(
"
None
\n
"
);
printf
(
"
%d (None)
\n
"
,
i
);
break
;
case
HEXP_PORT_MODE_WR_M_AND_S
:
printf
(
"
Auto
\n
"
);
printf
(
"
%d (Auto)
\n
"
,
i
);
break
;
default:
printf
(
"
Undefined
\n
"
);
printf
(
"
%d (Undefined)
\n
"
,
i
);
break
;
}
break
;
...
...
@@ -367,6 +370,63 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
break
;
}
case
dump_type_shmemState
:
i
=
*
(
uint32_t
*
)
p
;
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
HAL_SHMEM_STATE_NOT_INITITALIZED
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_SHMEM_STATE_INITITALIZING
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_SHMEM_STATE_INITITALIZED
,
char_p
);
default:
char_p
=
"Unknown"
;
}
printf
(
"%d"
,
i
);
print_str
(
char_p
);
printf
(
"
\n
"
);
break
;
case
dump_type_hal_mode
:
i
=
*
(
uint32_t
*
)
p
;
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
HAL_TIMING_MODE_GRAND_MASTER
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_TIMING_MODE_FREE_MASTER
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_TIMING_MODE_BC
,
char_p
);
default:
char_p
=
"Unknown"
;
}
printf
(
"%d"
,
i
);
print_str
(
char_p
);
printf
(
"
\n
"
);
break
;
case
dump_type_hal_fsm
:
i
=
*
(
uint32_t
*
)
p
;
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
HAL_PORT_STATE_INIT
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_PORT_STATE_DISABLED
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_PORT_STATE_LINK_DOWN
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_PORT_STATE_LINK_UP
,
char_p
);
default:
char_p
=
"Unknown"
;
}
printf
(
"%d"
,
i
);
print_str
(
char_p
);
printf
(
"
\n
"
);
break
;
case
dump_type_hal_pllfsm
:
i
=
*
(
uint32_t
*
)
p
;
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
HAL_PORT_PLL_STATE_UNLOCKED
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_PORT_PLL_STATE_LOCKING
,
char_p
);
ENUM_TO_P_IN_CASE
(
HAL_PORT_PLL_STATE_LOCKED
,
char_p
);
default:
char_p
=
"Unknown"
;
}
printf
(
"%d"
,
i
);
print_str
(
char_p
);
printf
(
"
\n
"
);
break
;
default:
dump_one_field_ppsi_wrs
(
info
->
type
,
info
->
size
,
p
,
value
);
break
;
...
...
@@ -390,9 +450,9 @@ void dump_many_fields(void *addr, struct dump_info *info, int ninfo, char *prefi
#define DUMP_STRUCT struct hal_shmem_header
struct
dump_info
hal_shmem_info
[]
=
{
DUMP_FIELD
(
int
,
nports
),
DUMP_FIELD
(
int
,
shmemState
),
DUMP_FIELD
(
int
,
hal_mode
),
DUMP_FIELD
(
int
,
read_sfp_diag
),
DUMP_FIELD
(
shmemState
,
shmemState
),
DUMP_FIELD
(
hal_mode
,
hal_mode
),
DUMP_FIELD
(
yes_no
,
read_sfp_diag
),
DUMP_FIELD
(
sensor_temp
,
temp
.
fpga
),
DUMP_FIELD
(
sensor_temp
,
temp
.
pll
),
DUMP_FIELD
(
sensor_temp
,
temp
.
psl
),
...
...
@@ -403,16 +463,16 @@ struct dump_info hal_shmem_info [] = {
#undef DUMP_STRUCT
#define DUMP_STRUCT struct hal_port_state
struct
dump_info
hal_port_info
[]
=
{
DUMP_FIELD
(
int
,
in_use
),
DUMP_FIELD
(
yes_no
,
in_use
),
DUMP_FIELD_SIZE
(
char
,
name
,
16
),
DUMP_FIELD_SIZE
(
bina
,
hw_addr
,
6
),
DUMP_FIELD
(
int
,
hw_index
),
DUMP_FIELD
(
int
,
fd
),
DUMP_FIELD
(
int
,
hw_addr_auto
),
DUMP_FIELD
(
int
,
fsm
.
st
.
state
),
DUMP_FIELD
(
int
,
pllFsm
.
st
.
state
),
DUMP_FIELD
(
hal_fsm
,
fsm
.
st
.
state
),
DUMP_FIELD
(
hal_pllfsm
,
pllFsm
.
st
.
state
),
DUMP_FIELD
(
int
,
fiber_index
),
DUMP_FIELD
(
int
,
locked
),
DUMP_FIELD
(
yes_no
,
locked
),
/* these fields are defined as uint32_t but we prefer %i to %x */
DUMP_FIELD
(
int
,
calib
.
phy_rx_min
),
DUMP_FIELD
(
int
,
calib
.
phy_tx_min
),
...
...
@@ -420,8 +480,8 @@ struct dump_info hal_port_info [] = {
DUMP_FIELD
(
int
,
calib
.
delta_rx_phy
),
DUMP_FIELD
(
int
,
calib
.
delta_tx_board
),
DUMP_FIELD
(
int
,
calib
.
delta_rx_board
),
DUMP_FIELD
(
int
,
calib
.
rx_calibrated
),
DUMP_FIELD
(
int
,
calib
.
tx_calibrated
),
DUMP_FIELD
(
yes_no
,
calib
.
rx_calibrated
),
DUMP_FIELD
(
yes_no
,
calib
.
tx_calibrated
),
DUMP_FIELD
(
int
,
calib
.
bitslide_ps
),
...
...
@@ -445,28 +505,28 @@ struct dump_info hal_port_info [] = {
DUMP_FIELD
(
sfp_dom_rx_power
,
calib
.
sfp_dom_raw
.
rx_pow
),
DUMP_FIELD
(
uint32_t
,
phase_val
),
DUMP_FIELD
(
int
,
phase_val_valid
),
DUMP_FIELD
(
int
,
tx_cal_pending
),
DUMP_FIELD
(
int
,
rx_cal_pending
),
DUMP_FIELD
(
yes_no
,
phase_val_valid
),
DUMP_FIELD
(
yes_no
,
tx_cal_pending
),
DUMP_FIELD
(
yes_no
,
rx_cal_pending
),
DUMP_FIELD
(
int
,
lock_state
),
DUMP_FIELD
(
uint32_t
,
clock_period
),
DUMP_FIELD
(
uint32_t
,
t2_phase_transition
),
DUMP_FIELD
(
uint32_t
,
t4_phase_transition
),
DUMP_FIELD
(
int
,
t24p_from_config
),
DUMP_FIELD
(
uint32_t
,
ep_base
),
DUMP_FIELD
(
int
,
sfpPresent
),
DUMP_FIELD
(
yes_no
,
sfpPresent
),
DUMP_FIELD
(
yes_no
,
has_sfp_diag
),
DUMP_FIELD
(
yes_no
,
monitor
),
/* PPSi instance information */
DUMP_FIELD
(
int
,
portMode
),
DUMP_FIELD
(
int
,
synchronized
),
DUMP_FIELD
(
yes_no
,
synchronized
),
DUMP_FIELD
(
int
,
portInfoUpdated
),
/* Events to process */
DUMP_FIELD
(
int
,
evt_reset
),
DUMP_FIELD
(
int
,
evt_lock
),
DUMP_FIELD
(
int
,
evt_linkUp
),
DUMP_FIELD
(
yes_no
,
evt_reset
),
DUMP_FIELD
(
yes_no
,
evt_lock
),
DUMP_FIELD
(
yes_no
,
evt_linkUp
),
};
...
...
@@ -582,16 +642,16 @@ struct dump_info htab_info[] = {
DUMP_FIELD
(
unsigned_char
,
fid
),
DUMP_FIELD
(
uint32_t
,
port_mask_src
),
DUMP_FIELD
(
uint32_t
,
port_mask_dst
),
DUMP_FIELD
(
int
,
drop_when_source
),
DUMP_FIELD
(
int
,
drop_when_dest
),
DUMP_FIELD
(
int
,
drop_unmatched_src_ports
),
DUMP_FIELD
(
yes_no
,
drop_when_source
),
DUMP_FIELD
(
yes_no
,
drop_when_dest
),
DUMP_FIELD
(
yes_no
,
drop_unmatched_src_ports
),
DUMP_FIELD
(
unsigned
,
last_access_t
),
DUMP_FIELD
(
yes_no
,
force_remove
),
DUMP_FIELD
(
unsigned_char
,
prio_src
),
DUMP_FIELD
(
int
,
has_prio_src
),
DUMP_FIELD
(
yes_no
,
has_prio_src
),
DUMP_FIELD
(
int
,
prio_override_src
),
DUMP_FIELD
(
unsigned_char
,
prio_dst
),
DUMP_FIELD
(
int
,
has_prio_dst
),
DUMP_FIELD
(
yes_no
,
has_prio_dst
),
DUMP_FIELD
(
int
,
prio_override_dst
),
DUMP_FIELD
(
rtu_filtering_entry_dynamic
,
dynamic
),
DUMP_FIELD
(
int
,
age
),
...
...
userspace/tools/wrs_dump_shmem.h
View file @
7355ae4c
...
...
@@ -68,7 +68,10 @@ enum dump_type {
dump_type_rtu_filtering_entry_dynamic
,
dump_type_rtu_qmode
,
dump_type_array_int
,
dump_type_shmemState
,
dump_type_hal_mode
,
dump_type_hal_fsm
,
dump_type_hal_pllfsm
,
};
...
...
@@ -99,6 +102,10 @@ typedef struct timeval timeval;
typedef
int
spll_mode
;
typedef
int
spll_seq_state
;
typedef
int
spll_align_state
;
typedef
int
shmemState
;
typedef
int
hal_mode
;
typedef
int
hal_fsm
;
typedef
int
hal_pllfsm
;
/*
* A structure to dump fields. This is meant to simplify things, see use here
*/
...
...
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