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
31
Issues
31
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
Software for White Rabbit PTP Core
Commits
7d3ac7a5
Commit
7d3ac7a5
authored
Apr 27, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell/sfp: move matching of the sfp to dev/sfp.c
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
469248b5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
15 deletions
+43
-15
sfp.c
dev/sfp.c
+27
-0
sfp.h
include/sfp.h
+3
-0
cmd_sfp.c
shell/cmd_sfp.c
+13
-15
No files found.
dev/sfp.c
View file @
7d3ac7a5
...
...
@@ -10,10 +10,13 @@
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include "syscon.h"
#include "i2c.h"
#include "sfp.h"
#include "storage.h"
/* Calibration data (from EEPROM if available) */
int32_t
sfp_alpha
=
73622176
;
/* default values if could not read EEPROM */
...
...
@@ -60,3 +63,27 @@ int sfp_read_part_id(char *part_id)
return
-
1
;
}
int
sfp_match
(
void
)
{
struct
s_sfpinfo
sfp
;
sfp_pn
[
0
]
=
'\0'
;
if
(
!
sfp_present
())
{
return
-
ENODEV
;
}
if
(
sfp_read_part_id
(
sfp_pn
))
{
return
-
EIO
;
}
strncpy
(
sfp
.
pn
,
sfp_pn
,
SFP_PN_LEN
);
if
(
storage_match_sfp
(
&
sfp
)
==
0
)
{
sfp_in_db
=
SFP_NOT_MATCHED
;
return
-
ENXIO
;
}
sfp_deltaTx
=
sfp
.
dTx
;
sfp_deltaRx
=
sfp
.
dRx
;
sfp_alpha
=
sfp
.
alpha
;
sfp_in_db
=
SFP_MATCHED
;
return
0
;
}
include/sfp.h
View file @
7d3ac7a5
...
...
@@ -29,4 +29,7 @@ int sfp_present(void);
/* Reads the part ID of the SFP from its configuration EEPROM */
int
sfp_read_part_id
(
char
*
part_id
);
/* Match plugged SFP with a DB entry */
int
sfp_match
(
void
);
#endif
shell/cmd_sfp.c
View file @
7d3ac7a5
...
...
@@ -34,8 +34,9 @@
static
int
cmd_sfp
(
const
char
*
args
[])
{
int8_t
sfpcount
=
1
,
i
,
temp
;
int8_t
sfpcount
=
1
,
i
,
temp
,
ret
;
struct
s_sfpinfo
sfp
;
if
(
!
args
[
0
])
{
pp_printf
(
"Wrong parameter
\n
"
);
return
-
EINVAL
;
...
...
@@ -87,32 +88,29 @@ static int cmd_sfp(const char *args[])
}
return
0
;
}
else
if
(
!
strcasecmp
(
args
[
0
],
"match"
))
{
sfp_pn
[
0
]
=
'\0'
;
if
(
!
sfp_present
()
)
{
ret
=
sfp_match
()
;
if
(
ret
==
-
ENODEV
)
{
pp_printf
(
"No SFP.
\n
"
);
return
-
ENODEV
;
return
ret
;
}
if
(
sfp_read_part_id
(
sfp_pn
)
)
{
if
(
ret
==
-
EIO
)
{
pp_printf
(
"SFP read error
\n
"
);
return
-
EIO
;
return
ret
;
}
/* SFP read correctly */
for
(
temp
=
0
;
temp
<
SFP_PN_LEN
;
++
temp
)
pp_printf
(
"%c"
,
sfp_pn
[
temp
]);
pp_printf
(
"
\n
"
);
strncpy
(
sfp
.
pn
,
sfp_pn
,
SFP_PN_LEN
);
if
(
storage_match_sfp
(
&
sfp
)
==
0
)
{
if
(
ret
==
-
ENXIO
)
{
pp_printf
(
"Could not match to DB
\n
"
);
sfp_in_db
=
SFP_NOT_MATCHED
;
return
-
ENXIO
;
return
ret
;
}
/* match successful */
pp_printf
(
"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
;
sfp_in_db
=
SFP_MATCHED
;
return
0
;
return
ret
;
}
else
if
(
args
[
1
]
&&
!
strcasecmp
(
args
[
0
],
"ena"
))
{
ep_sfp_enable
(
atoi
(
args
[
1
]));
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