Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
Software for White Rabbit PTP Core
Commits
71116c8a
Commit
71116c8a
authored
Jul 18, 2012
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell: sfp match command for getting SFP parameters from the SFP DB
parent
50868480
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
eeprom.c
dev/eeprom.c
+29
-0
eeprom.h
include/eeprom.h
+7
-1
cmd_sfp.c
shell/cmd_sfp.c
+21
-1
No files found.
dev/eeprom.c
View file @
71116c8a
...
...
@@ -145,6 +145,35 @@ int32_t eeprom_get_sfp(uint8_t i2cif, uint8_t i2c_addr, struct s_sfpinfo* sfp, u
return
sfpcount
;
}
int8_t
eeprom_match_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
)
{
uint8_t
sfpcount
=
1
;
int8_t
i
,
temp
;
struct
s_sfpinfo
dbsfp
;
for
(
i
=
0
;
i
<
sfpcount
;
++
i
)
{
temp
=
eeprom_get_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
dbsfp
,
0
,
i
);
if
(
!
i
)
{
sfpcount
=
temp
;
//only in first round valid sfpcount is returned from eeprom_get_sfp
if
(
sfpcount
==
0
||
sfpcount
==
0xFF
)
return
0
;
else
if
(
sfpcount
<
0
)
return
sfpcount
;
}
if
(
!
strncmp
(
dbsfp
.
pn
,
sfp
->
pn
,
16
)
)
{
sfp
->
dTx
=
dbsfp
.
dTx
;
sfp
->
dRx
=
dbsfp
.
dRx
;
sfp
->
alpha
=
dbsfp
.
alpha
;
return
1
;
}
}
return
0
;
}
int8_t
eeprom_get_sfpinfo
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
struct
s_sfpinfo
*
sfpinfo
,
uint16_t
section_sz
)
{
uint8_t
*
buf
;
...
...
include/eeprom.h
View file @
71116c8a
...
...
@@ -3,6 +3,7 @@
#define SFP_SECTION_PATTERN 0xdeadbeef
#define SFPS_MAX 4
#define SFP_PN_LEN 16
#define EE_BASE_SFP 4*1024
#define EE_BASE_INIT 4*1024+SFPS_MAX*29
...
...
@@ -11,9 +12,13 @@
#define EE_RET_CHKSUM -3
#define EE_RET_POSERR -4
extern
int32_t
sfp_alpha
;
extern
int32_t
sfp_deltaTx
;
extern
int32_t
sfp_deltaRx
;
struct
s_sfpinfo
{
char
pn
[
16
];
char
pn
[
SFP_PN_LEN
];
int32_t
alpha
;
int32_t
dTx
;
int32_t
dRx
;
...
...
@@ -26,6 +31,7 @@ int eeprom_write(uint8_t i2cif, uint8_t i2c_addr, uint32_t offset, uint8_t *buf,
int32_t
eeprom_sfpdb_erase
(
uint8_t
i2cif
,
uint8_t
i2c_addr
);
int32_t
eeprom_sfp_section
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
size_t
size
,
uint16_t
*
section_sz
);
int8_t
eeprom_match_sfp
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
struct
s_sfpinfo
*
sfp
);
int8_t
eeprom_get_sfpinfo
(
uint8_t
i2cif
,
uint8_t
i2c_addr
,
uint32_t
offset
,
struct
s_sfpinfo
*
sfpinfo
,
uint16_t
section_sz
);
int8_t
access_eeprom
(
char
*
sfp_pn
,
int32_t
*
alpha
,
int32_t
*
deltaTx
,
int32_t
*
deltaRx
);
...
...
shell/cmd_sfp.c
View file @
71116c8a
...
...
@@ -6,6 +6,7 @@
Subcommands:
add vendor_type delta_tx delta_rx alpha - adds an SFP to the database, with given alpha/delta_rx/delta_rx values
show - shows the SFP database
match - tries to get calibration parameters from DB for a detected SFP
erase - cleans the SFP database
detect - detects the transceiver type
*/
...
...
@@ -20,10 +21,10 @@ int cmd_sfp(const char *args[])
{
int8_t
sfpcount
=
1
,
i
,
temp
;
struct
s_sfpinfo
sfp
;
static
char
pn
[
SFP_PN_LEN
+
1
]
=
"
\0
"
;
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"detect"
))
{
char
pn
[
17
];
if
(
!
sfp_present
())
mprintf
(
"No SFP.
\n
"
);
else
...
...
@@ -85,6 +86,25 @@ int cmd_sfp(const char *args[])
mprintf
(
" dTx: %d, dRx: %d, alpha: %d
\n
"
,
sfp
.
dTx
,
sfp
.
dRx
,
sfp
.
alpha
);
}
}
else
if
(
args
[
0
]
&&
!
strcasecmp
(
args
[
0
],
"match"
))
{
if
(
pn
[
0
]
==
'\0'
)
{
mprintf
(
"Run sfp detect first
\n
"
);
return
0
;
}
strncpy
(
sfp
.
pn
,
pn
,
SFP_PN_LEN
);
if
(
eeprom_match_sfp
(
WRPC_FMC_I2C
,
FMC_EEPROM_ADR
,
&
sfp
)
>
0
)
{
mprintf
(
"SFP matched, dTx=%d, dRx=%d, alpha=%d
\n
"
,
sfp
.
dTx
,
sfp
.
dRx
,
sfp
.
alpha
);
sfp_deltaTx
=
sfp
.
dTx
;
sfp_deltaRx
=
sfp
.
dRx
;
sfp_alpha
=
sfp
.
alpha
;
}
else
mprintf
(
"Could not match to DB
\n
"
);
return
0
;
}
return
0
;
}
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