Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC Software Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
FMC Software Support
Commits
b02b1242
Commit
b02b1242
authored
Oct 20, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib|tools: lsfmc show FRU name
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
d4d431b5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
4 deletions
+110
-4
Makefile
tools/Makefile
+1
-1
Makefile
tools/lib/Makefile
+2
-2
ipmifru.c
tools/lib/ipmifru.c
+74
-0
lsfmc.c
tools/lsfmc.c
+33
-1
No files found.
tools/Makefile
View file @
b02b1242
...
...
@@ -14,7 +14,7 @@ LIB = ./lib/
TOOLS
=
lsfmc
\
fmc-slot-eeprom
CFLAGS
=
-ggdb
-I
.
-I
$(LIB)
-I
../kernel
-Wall
-Werror
$(EXTRACFLAGS)
CFLAGS
=
-ggdb
-I
.
-I
$(LIB)
-I
../
include/uapi/
-I
../
kernel
-Wall
-Werror
$(EXTRACFLAGS)
GIT_VERSION
:=
$(
shell
git describe
--dirty
--long
--tags
)
CFLAGS
+=
-DGIT_VERSION
=
"
\"
$(GIT_VERSION)
\"
"
...
...
tools/lib/Makefile
View file @
b02b1242
...
...
@@ -15,9 +15,9 @@ SO_VERSION_X := $(shell echo $(SO_VERSION_XYZ) | cut -d "." -f 1)
LIB
=
libfmc.a
LIBS
=
libfmc.so
LIBS_XYZ
=
$(LIBS)
.
$(SO_VERSION_XYZ)
LOBJ
:=
libfmc.o
LOBJ
:=
libfmc.o
ipmifru.o
CFLAGS
=
-Wall
-Werror
-ggdb
-O2
-I
.
-I
../include/uapi
CFLAGS
=
-Wall
-Werror
-ggdb
-O2
-I
.
-I
../
../
include/uapi
CFLAGS
+=
-fPIC
CFLAGS
+=
-DGIT_VERSION
=
"
\"
$(GIT_VERSION)
\"
"
CFLAGS
+=
$(EXTRACFLAGS)
...
...
tools/lib/ipmifru.c
0 → 100644
View file @
b02b1242
/*
* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*/
#include <stdlib.h>
#include <string.h>
#include <linux/ipmi/fru.h>
/* The fru parser is both user and kernel capable: it needs alloc */
static
void
*
fru_alloc
(
size_t
size
)
{
void
*
buf
=
malloc
(
size
);
if
(
!
buf
)
memset
(
buf
,
0
,
size
);
return
buf
;
}
/* Some internal helpers */
static
struct
fru_type_length
*
__fru_get_board_tl
(
struct
fru_common_header
*
header
,
int
nr
)
{
struct
fru_board_info_area
*
bia
;
struct
fru_type_length
*
tl
;
bia
=
fru_get_board_area
(
header
);
tl
=
bia
->
tl
;
while
(
nr
>
0
&&
!
fru_is_eof
(
tl
))
{
tl
=
fru_next_tl
(
tl
);
nr
--
;
}
if
(
fru_is_eof
(
tl
))
return
NULL
;
return
tl
;
}
static
char
*
__fru_alloc_get_tl
(
struct
fru_common_header
*
header
,
int
nr
)
{
struct
fru_type_length
*
tl
;
char
*
res
;
tl
=
__fru_get_board_tl
(
header
,
nr
);
if
(
!
tl
)
return
NULL
;
res
=
fru_alloc
(
fru_strlen
(
tl
)
+
1
);
if
(
!
res
)
return
NULL
;
return
fru_strcpy
(
res
,
tl
);
}
/* Get various stuff, trivial */
char
*
fru_get_board_manufacturer
(
struct
fru_common_header
*
header
)
{
return
__fru_alloc_get_tl
(
header
,
0
);
}
char
*
fru_get_product_name
(
struct
fru_common_header
*
header
)
{
return
__fru_alloc_get_tl
(
header
,
1
);
}
char
*
fru_get_serial_number
(
struct
fru_common_header
*
header
)
{
return
__fru_alloc_get_tl
(
header
,
2
);
}
char
*
fru_get_part_number
(
struct
fru_common_header
*
header
)
{
return
__fru_alloc_get_tl
(
header
,
3
);
}
tools/lsfmc.c
View file @
b02b1242
...
...
@@ -9,8 +9,9 @@
#include <string.h>
#include <libgen.h>
#include <getopt.h>
#include <errno.h>
#include <fmc/core.h>
#include <linux/ipmi/fru.h>
static
const
char
git_version
[]
=
"git version: "
GIT_VERSION
;
static
char
*
name
;
...
...
@@ -39,6 +40,36 @@ static void print_carrier_name(struct fmc_tkn *tkn)
fprintf
(
stdout
,
"
\t
carrier: %s
\n
"
,
carr_name
);
}
static
void
print_slot_name
(
struct
fmc_tkn
*
tkn
,
unsigned
int
id
)
{
char
*
fru
;
int
ret
;
fru
=
malloc
(
FRU_SIZE_MAX
);
if
(
!
fru
)
goto
err_alloc
;
ret
=
fmc_slot_eeprom_read
(
tkn
,
id
,
fru
,
FRU_SIZE_MAX
,
0
);
if
(
ret
<
0
)
goto
err_read
;
if
(
ret
==
FRU_SIZE_MAX
)
{
char
*
fmc_name
;
fmc_name
=
fru_get_product_name
((
struct
fru_common_header
*
)
fru
);
fprintf
(
stdout
,
"
\t\t
module: %s
\n
"
,
fmc_name
);
free
(
fmc_name
);
}
free
(
fru
);
return
;
err_read:
free
(
fru
);
err_alloc:
fprintf
(
stdout
,
"
\t\t
module: unknown (%s)
\n
"
,
fmc_strerror
(
errno
));
}
static
void
print_slot_flags
(
struct
fmc_tkn
*
tkn
,
unsigned
int
id
)
{
fputs
(
"
\t\t
flags:
\n
"
,
stdout
);
...
...
@@ -80,6 +111,7 @@ static void print_slot(struct fmc_tkn *tkn,
unsigned
int
carr_id
,
unsigned
int
id
)
{
fprintf
(
stdout
,
"
\t
- fmc-slot-%u.%u:
\n
"
,
carr_id
,
id
);
print_slot_name
(
tkn
,
id
);
if
(
verbose
>
0
)
print_slot_flags
(
tkn
,
id
);
if
(
verbose
>
1
)
{
...
...
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