Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Software for White Rabbit PTP Core
Manage
Activity
Members
Labels
Plan
Issues
39
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
Software for White Rabbit PTP Core
Commits
71116c8a
Commit
71116c8a
authored
12 years ago
by
Grzegorz Daniluk
Browse files
Options
Downloads
Patches
Plain Diff
shell: sfp match command for getting SFP parameters from the SFP DB
parent
50868480
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dev/eeprom.c
+29
-0
29 additions, 0 deletions
dev/eeprom.c
include/eeprom.h
+7
-1
7 additions, 1 deletion
include/eeprom.h
shell/cmd_sfp.c
+21
-1
21 additions, 1 deletion
shell/cmd_sfp.c
with
57 additions
and
2 deletions
dev/eeprom.c
+
29
−
0
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
;
...
...
This diff is collapsed.
Click to expand it.
include/eeprom.h
+
7
−
1
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
);
...
...
This diff is collapsed.
Click to expand it.
shell/cmd_sfp.c
+
21
−
1
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
;
}
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