Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FMC Software Support
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
FMC Software Support
Commits
df78c372
Commit
df78c372
authored
4 years ago
by
Federico Vaga
Browse files
Options
Downloads
Patches
Plain Diff
lib|tools: get and show eeprom type
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
66db6b97
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/fmc/core.h
+4
-1
4 additions, 1 deletion
lib/fmc/core.h
lib/libfmc.c
+36
-0
36 additions, 0 deletions
lib/libfmc.c
tools/lsfmc.c
+17
-2
17 additions, 2 deletions
tools/lsfmc.c
with
57 additions
and
3 deletions
lib/fmc/core.h
+
4
−
1
View file @
df78c372
...
...
@@ -7,6 +7,7 @@
#ifndef _FMC_CORE_H
#define _FMC_CORE_H
#include
<stddef.h>
#include
<stdbool.h>
const
char
*
fmc_version_get
(
void
);
...
...
@@ -26,6 +27,8 @@ void fmc_carrier_close(struct fmc_tkn *tkn);
bool
fmc_slot_is_present
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
);
bool
fmc_slot_is_fru_valid
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
);
int
fmc_slot_geo_address
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
unsigned
int
*
ga
);
unsigned
int
*
ga
);
int
fmc_slot_eeprom_type_get
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
char
*
str
,
size_t
max_len
);
#endif
/* _FMC_CORE_H */
This diff is collapsed.
Click to expand it.
lib/libfmc.c
+
36
−
0
View file @
df78c372
...
...
@@ -7,6 +7,7 @@
#include
<stdlib.h>
#include
<stdio.h>
#include
<stdbool.h>
#include
<stddef.h>
#include
<unistd.h>
#include
<sys/types.h>
#include
<sys/stat.h>
...
...
@@ -29,6 +30,10 @@ const char *libfmc_version_full = "libfmc version:" GIT_VERSION;
#define BIT(_n) (1 << _n)
#endif
#ifndef MIN
#define MIN(_a,_b) (((_a) < (_b)) ? (_a) : (_b))
#endif
#define FMC_SLOT_PRESENT BIT(0)
#define FMC_SLOT_FRU_VALID BIT(1)
...
...
@@ -155,6 +160,21 @@ static int __fmc_slot_ga_get(struct fmc_carrier *carr,
return
err
;
}
static
int
__fmc_slot_eeprom_type_get
(
struct
fmc_carrier
*
carr
,
unsigned
int
slot_n
,
char
*
str
,
size_t
max_len
)
{
int
ret
;
ret
=
__fmc_sys_read_string
(
carr
,
slot_n
,
"eeprom_type"
,
str
,
max_len
);
if
(
ret
<
0
)
{
strncpy
(
str
,
"unknown"
,
MIN
(
strlen
(
"unknown"
),
max_len
));
return
ret
;
}
return
0
;
}
static
int
fmc_carrier_slots_init
(
struct
fmc_carrier
*
carr
)
{
char
pattern
[
MAX_PATH_LEN
];
...
...
@@ -182,6 +202,9 @@ static int fmc_carrier_slots_init(struct fmc_carrier *carr)
sscanf
(
basename
(
g
.
gl_pathv
[
i
]),
"fmc-slot-%*d.%d"
,
&
carr
->
slot
[
i
]
->
id
);
__fmc_slot_ga_get
(
carr
,
carr
->
slot
[
i
]
->
id
,
&
carr
->
slot
[
i
]
->
ga
);
__fmc_slot_eeprom_type_get
(
carr
,
carr
->
slot
[
i
]
->
id
,
carr
->
slot
[
i
]
->
eeprom_type
,
MAX_SYS_LEN
);
if
(
__fmc_slot_is_present
(
carr
,
carr
->
slot
[
i
]
->
id
))
carr
->
slot
[
i
]
->
flags
|=
FMC_SLOT_PRESENT
;
if
(
__fmc_slot_is_fru_valid
(
carr
,
carr
->
slot
[
i
]
->
id
))
...
...
@@ -250,6 +273,19 @@ int fmc_slot_geo_address(struct fmc_tkn *tkn, unsigned int slot_n,
return
0
;
}
int
fmc_slot_eeprom_type_get
(
struct
fmc_tkn
*
tkn
,
unsigned
int
slot_n
,
char
*
buf
,
size_t
count
)
{
struct
fmc_carrier
*
carrier
=
(
struct
fmc_carrier
*
)
tkn
;
struct
fmc_slot
*
slot
=
__fmc_slot_get
(
carrier
,
slot_n
);
if
(
!
slot
)
return
-
1
;
strncpy
(
buf
,
slot
->
eeprom_type
,
MIN
(
count
,
MAX_SYS_LEN
));
return
0
;
}
/**
* Open an FMC carrier
*
...
...
This diff is collapsed.
Click to expand it.
tools/lsfmc.c
+
17
−
2
View file @
df78c372
...
...
@@ -55,15 +55,30 @@ static void print_slot_geo_addr(struct fmc_tkn *tkn, unsigned int id)
fprintf
(
stdout
,
"
\t\t
geo-addr: 0x%02x
\n
"
,
ga
);
}
#define BUF_LEN 16
static
void
print_slot_eeprom_type
(
struct
fmc_tkn
*
tkn
,
unsigned
int
id
)
{
char
buf
[
BUF_LEN
];
int
err
;
err
=
fmc_slot_eeprom_type_get
(
tkn
,
id
,
buf
,
BUF_LEN
);
if
(
err
)
fputs
(
"
\t\t
eeprom-type: unknown,
\n
"
,
stdout
);
else
fprintf
(
stdout
,
"
\t\t
eeprom-type: %s
\n
"
,
buf
);
}
#undef BUFLEN
static
void
print_slot
(
struct
fmc_tkn
*
tkn
,
unsigned
int
carr_id
,
unsigned
int
id
)
{
fprintf
(
stdout
,
"
\t
- fmc-slot-%d.%d:
\n
"
,
carr_id
,
id
);
if
(
verbose
>
0
)
print_slot_flags
(
tkn
,
id
);
if
(
verbose
>
1
)
if
(
verbose
>
1
)
{
print_slot_geo_addr
(
tkn
,
id
);
fputc
(
'\n'
,
stdout
);
print_slot_eeprom_type
(
tkn
,
id
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
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