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
87
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
8726581b
Commit
8726581b
authored
4 weeks ago
by
Adam Wujek
Browse files
Options
Downloads
Patches
Plain Diff
[FEATURE:
#374
] userspace/tools/wrs_sfp_dump: print summary in table
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
40a5f3d0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
userspace/libwr/i2c_sfp.c
+1
-1
1 addition, 1 deletion
userspace/libwr/i2c_sfp.c
userspace/libwr/include/libwr/sfp_lib.h
+3
-0
3 additions, 0 deletions
userspace/libwr/include/libwr/sfp_lib.h
userspace/tools/wrs_sfp_dump.c
+73
-2
73 additions, 2 deletions
userspace/tools/wrs_sfp_dump.c
with
77 additions
and
3 deletions
userspace/libwr/i2c_sfp.c
+
1
−
1
View file @
8726581b
...
...
@@ -299,7 +299,7 @@ int shw_sfp_header_verify(struct shw_sfp_header *head)
!
shw_sfp_header_verify_ext
(
head
))
?
0
:
-
1
;
}
static
inline
int
getSfpTxWaveLength
(
struct
shw_sfp_header
*
head
)
{
int
getSfpTxWaveLength
(
struct
shw_sfp_header
*
head
)
{
return
(
head
->
tx_wavelength
[
0
]
<<
8
)
+
head
->
tx_wavelength
[
1
];
}
...
...
This diff is collapsed.
Click to expand it.
userspace/libwr/include/libwr/sfp_lib.h
+
3
−
0
View file @
8726581b
...
...
@@ -218,4 +218,7 @@ void shw_sfp_dom_dump(struct shw_sfp_dom * dom);
struct
shw_sfp_caldata
*
shw_sfp_get_cal_data
(
int
num
,
struct
shw_sfp_header
*
head
);
/* Return TX Wavelength from SFP header */
int
getSfpTxWaveLength
(
struct
shw_sfp_header
*
head
);
#endif
/* __LIBWR_SHW_SFPLIB_H */
This diff is collapsed.
Click to expand it.
userspace/tools/wrs_sfp_dump.c
+
73
−
2
View file @
8726581b
#include
<stdlib.h>
#include
<unistd.h>
#include
<math.h>
#include
<arpa/inet.h>
#include
<libwr/switch_hw.h>
#include
<libwr/wrs-msg.h>
#include
<libwr/shw_io.h>
...
...
@@ -48,6 +51,7 @@ void print_info(char *prgname)
" -x Dump sfp/DOM header also in hex
\n
"
" -b Dump SFP database from HAL
\n
"
" -m Dump SFP basic parameters with matching information (marked with
\"
+
\"
) from HAL
\n
"
" -s Dump SFP (with DOM) summary as table.
\n
"
" -t <on|off|0|1|s> Enable(1), disable(1) or check status of SFP's TX pin; Use with -L or -I
\n
"
" -q Decrease verbosity
\n
"
" -v Increase verbosity
\n
"
...
...
@@ -369,6 +373,61 @@ static void dump_sfp_database_match_reason_from_hal(int dump_port, int nports, s
};
}
static
void
sfp_summary_print_header
(
void
)
{
printf
(
" @ DOM
\n
"
);
printf
(
" # | Vendor Name | Part Number | Rev | Vendor Serial | TX WL @ Temp | Volt | BiasCur | TX Power | RX Power
\n
"
);
printf
(
" | | | | | (nm) @ (C) | (V) | (mA) | mW (dBm) | mW (dBm)
\n
"
);
printf
(
"---+------------------+------------------+------+------------------+-------+---------+-------+---------+-----------------+----------------
\n
"
);
}
static
void
sfp_summary_print_entry
(
int
i
,
struct
shw_sfp_header
*
sfp_hdr_p
,
struct
shw_sfp_dom
*
sfp_dom_p
)
{
int
tmp_i
;
double
tmp_f
;
printf
(
"%2d"
,
i
);
printf
(
" | %16.16s"
,
sfp_hdr_p
->
vendor_name
);
printf
(
" | %16.16s"
,
sfp_hdr_p
->
vendor_pn
);
printf
(
" | %4.4s"
,
sfp_hdr_p
->
vendor_rev
);
printf
(
" | %16.16s"
,
sfp_hdr_p
->
vendor_serial
);
/* DOM */
if
((
tmp_i
=
getSfpTxWaveLength
(
sfp_hdr_p
)))
{
printf
(
" | %5d"
,
getSfpTxWaveLength
(
sfp_hdr_p
));
}
else
{
printf
(
" | %5s"
,
""
);
}
if
((
tmp_f
=
(
int16_t
)
ntohs
(
sfp_dom_p
->
temp
)
/
(
float
)
256
))
{
printf
(
" @ %7.3f"
,
tmp_f
);
}
else
{
printf
(
" @ %7s"
,
""
);
}
if
((
tmp_f
=
ntohs
(
sfp_dom_p
->
vcc
)
/
(
float
)
10000
))
{
printf
(
" | %5.3f"
,
tmp_f
);
}
else
{
printf
(
" | %5s"
,
""
);
}
if
((
tmp_f
=
ntohs
(
sfp_dom_p
->
tx_bias
)
/
(
float
)
500
))
{
printf
(
" | %7.3f"
,
tmp_f
);
}
else
{
printf
(
" | %7s"
,
""
);
}
if
((
tmp_f
=
(
ntohs
(
sfp_dom_p
->
tx_pow
))
/
(
float
)
10000
))
{
printf
(
" | %6.4f (%6.2f)"
,
tmp_f
,
10
*
log10
(
tmp_f
));
}
else
{
printf
(
" | %15s"
,
""
);
}
if
((
tmp_f
=
(
ntohs
(
sfp_dom_p
->
rx_pow
))
/
(
float
)
10000
))
{
printf
(
" | %6.4f (%6.2f)"
,
tmp_f
,
10
*
log10
(
tmp_f
));
}
else
{
printf
(
" | %15s"
,
""
);
}
printf
(
"
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
c
;
...
...
@@ -389,6 +448,7 @@ int main(int argc, char **argv)
int
sfp_tx_enable
=
0
;
int
dump_sfp_database
=
0
;
int
dump_sfp_database_match_reason
=
0
;
int
dump_sfp_summary
=
0
;
/* local copy of sfp eeprom */
struct
hal_port_calibration
hal_sfp_calib_lc
[
HAL_MAX_PORTS
];
...
...
@@ -396,7 +456,7 @@ int main(int argc, char **argv)
nports
=
18
;
dump_port
=
1
;
while
((
c
=
getopt
(
argc
,
argv
,
"a:hqvp:xVf:LIdH:t:bm"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"a:hqvp:xVf:LIdH:t:bm
s
"
))
!=
-
1
)
{
switch
(
c
)
{
case
'p'
:
dump_port
=
atoi
(
optarg
);
...
...
@@ -443,6 +503,9 @@ int main(int argc, char **argv)
case
'm'
:
dump_sfp_database_match_reason
=
1
;
break
;
case
's'
:
dump_sfp_summary
=
1
;
break
;
case
'L'
:
/* HAL mode */
sfp_data_source
=
READ_HAL
;
...
...
@@ -583,8 +646,14 @@ int main(int argc, char **argv)
}
if
(
dump_sfp_summary
)
{
sfp_summary_print_header
();
}
for
(
i
=
dump_port
;
i
<=
nports
;
i
++
)
{
printf
(
"========= port %d =========
\n
"
,
i
);
if
(
!
dump_sfp_summary
)
{
printf
(
"========= port %d =========
\n
"
,
i
);
}
if
(
sfp_data_source
==
READ_I2C
)
{
memset
(
&
sfp_hdr
,
0
,
sizeof
(
sfp_hdr
));
sfp_hdr_p
=
&
sfp_hdr
;
...
...
@@ -604,6 +673,8 @@ int main(int argc, char **argv)
}
else
if
(
err
<
0
)
{
pr_error
(
"Failed to read SFP configuration header on "
"port %d
\n
"
,
i
);
}
else
if
(
dump_sfp_summary
)
{
sfp_summary_print_entry
(
i
,
sfp_hdr_p
,
sfp_dom_p
);
}
else
{
shw_sfp_print_header
(
sfp_hdr_p
);
if
(
dump_hex_header
)
{
...
...
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