From: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
To: "Michal Simek" <michal.simek@amd.com>,
"Ovidiu Panait" <ovidiu.panait@windriver.com>,
"Simon Glass" <sjg@chromium.org>,
"Mario Six" <mario.six@gdsys.cc>,
"Masahisa Kojima" <masahisa.kojima@linaro.org>,
"Pali Rohár" <pali@kernel.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Ashok Reddy Soma" <ashok.reddy.soma@xilinx.com>,
"Thomas Huth" <thuth@redhat.com>,
"Huang Jianan" <jnhuang95@gmail.com>,
"Chris Morgan" <macromorgan@hotmail.com>,
"Roland Gaudig" <roland.gaudig@weidmueller.com>,
"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
"Alexandru Gagniuc" <mr.nuke.me@gmail.com>
Cc: "Jamie Iles" <quic_jiles@quicinc.com>,
"Graeme Gregory" <quic_ggregory@quicinc.com>,
"Cédric Le Goater" <clg@kaod.org>,
u-boot@lists.denx.de
Subject: Re: [PATCH v4 4/6] cmd: fru: add product info area parsing support
Date: Thu, 22 Sep 2022 09:15:30 -0700 [thread overview]
Message-ID: <c75600f6-70ca-5bbb-fc0a-dd524f4f85b9@quicinc.com> (raw)
In-Reply-To: <d799b37d-dfa2-4a85-819a-0ea22862eb4f@amd.com>
Hello Michal,
On 9/22/2022 12:19 AM, Michal Simek wrote:
> Hi,
>
> On 9/22/22 08:39, Jae Hyun Yoo wrote:
>> Hello Michal,
>>
>> On 9/21/2022 6:52 AM, Michal Simek wrote:
>>>
>>>
>>> On 8/25/22 18:42, Jae Hyun Yoo wrote:
>>>> Add product info area parsing support. Custom board fields can be
>>>> added dynamically using linked list so that each board support can
>>>> utilize them in their own custom way.
>>>>
>>>> Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
>>>> ---
>>>> Changes from v3:
>>>> * None.
>>>>
>>>> Changes from v2:
>>>> * Changed 'struct fru_board_info_member' to 'struct
>>>> fru_common_info_member'.
>>>>
>>>> Changes from v1:
>>>> * Refactored using linked list instead of calling a custom parsing
>>>> callback.
>>>>
>>>> Changes from RFC:
>>>> * Added manufacturer custom product info fields parsing flow.
>>>>
>>>> cmd/fru.c | 28 ++++--
>>>> include/fru.h | 34 ++++++-
>>>> lib/fru_ops.c | 244
>>>> +++++++++++++++++++++++++++++++++++++++++++++++---
>>>> 3 files changed, 286 insertions(+), 20 deletions(-)
>>>>
>>>> diff --git a/cmd/fru.c b/cmd/fru.c
>>>> index b2cadbec9780..42bdaae09449 100644
>>>> --- a/cmd/fru.c
>>>> +++ b/cmd/fru.c
>>>> @@ -43,11 +43,22 @@ static int do_fru_display(struct cmd_tbl *cmdtp,
>>>> int flag, int argc,
>>>> static int do_fru_generate(struct cmd_tbl *cmdtp, int flag, int argc,
>>>> char *const argv[])
>>>> {
>>>> + int (*fru_generate)(const void *addr, int argc, char*const
>>>> argv[]);
>>>> unsigned long addr;
>>>> const void *buf;
>>>> - int ret;
>>>> + int ret, maxargs;
>>>> +
>>>> + if (!strncmp(argv[2], "-b", 3)) {
>>>> + fru_generate = fru_board_generate;
>>>> + maxargs = cmdtp->maxargs +FRU_BOARD_AREA_TOTAL_FIELDS;
>>>> + } else if (!strncmp(argv[2], "-p", 3)) {
>>>> + fru_generate = fru_product_generate;
>>>> + maxargs = cmdtp->maxargs +FRU_PRODUCT_AREA_TOTAL_FIELDS;
>>>> + } else {
>>>> + return CMD_RET_USAGE;
>>>> + }
>>>> - if (argc < cmdtp->maxargs)
>>>> + if (argc < maxargs)
>>>> return CMD_RET_USAGE;
>>>> addr = hextoul(argv[3], NULL);
>>>> @@ -62,7 +73,7 @@ static int do_fru_generate(struct cmd_tbl *cmdtp,
>>>> int flag, int argc,
>>>> static struct cmd_tbl cmd_fru_sub[] = {
>>>> U_BOOT_CMD_MKENT(capture, 3, 0, do_fru_capture, "", ""),
>>>> U_BOOT_CMD_MKENT(display, 2, 0, do_fru_display, "", ""),
>>>> - U_BOOT_CMD_MKENT(board_gen, 8, 0, do_fru_generate, "", ""),
>>>> + U_BOOT_CMD_MKENT(generate, 4, 0, do_fru_generate, "", ""),
>>>> };
>>>> static int do_fru(struct cmd_tbl *cmdtp, int flag, int argc,
>>>> @@ -90,11 +101,16 @@ static char fru_help_text[] =
>>>> "capture <addr> - Parse and capture FRU table present at
>>>> address.\n"
>>>> "fru display - Displays content of FRU table that was captured
>>>> using\n"
>>>> " fru capture command\n"
>>>> - "fru board_gen <addr> <manufacturer> <board name> <serial
>>>> number>\n"
>>>> - " <part number> <file id> [custom ...] - Generate
>>>> FRU\n"
>>>> - " format with board info area filled based on\n"
>>>> + "fru generate -b <addr> <manufacturer> <board name> <serial
>>>> number>\n"
>>>> + " <part number> <file id> [custom ...] -
>>>> Generate FRU\n"
>>>> + " format with board info area filled based on\n"
>>>
>>> this simply means that all previous user custom scripts will stop to
>>> work.
>>> No problem to deprecated board_gen but with any transition time. It
>>> means keep origin option, create new one and add deprecate message to
>>> origin that scripts should be converted. After 3-4 releases we can
>>> remove it which should be enough time for users to do transition.
>>
>> I agree with you. I'll add the old command back in the next version and
>> will keep for 3-4 releases before deprecating the command.
>>
>>>> " parameters. <addr> is pointing to place where
>>>> FRU is\n"
>>>> " generated.\n"
>>>> + "fru generate -p <addr> <manufacturer> <product name> <part
>>>> number>\n"
>>>> + " <version number> <serial number> <asset
>>>> number>\n"
>>>> + " <file id> [custom ...] - Generate FRU format
>>>> with\n"
>>>> + " product info area filled based on parameters.
>>>> <addr>\n"
>>>> + " is pointing to place where FRU is generated.\n"
>>>
>>> Are you going to use this product generation. I mean it is fine how
>>> it is but maybe in future would make sense to have -b and -p together
>>> to be able to generate both of these fields.
>>> Definitely showing product information is key part here at least for me.
>>
>> Yes, that makes sense. I'll change these commands to 'gen_board' and
>> 'gen_product' with adding back the previous command 'board_gen' to keep
>> its compatibility. A command which can generate both board and product
>> into a single FRU could be added later using a separate series.
>>
>>>> ;
>>>> #endif
>>>> diff --git a/include/fru.h b/include/fru.h
>>>> index b158b80b5866..2b19033a3843 100644
>>>> --- a/include/fru.h
>>>> +++ b/include/fru.h
>>>> @@ -31,7 +31,13 @@ struct fru_board_info_header {
>>>> u8 time[3];
>>>> } __packed;
>>>> -struct fru_board_info_member {
>>>> +struct fru_product_info_header {
>>>> + u8 ver;
>>>> + u8 len;
>>>> + u8 lang_code;
>>>> +} __packed;
>>>> +
>>>> +struct fru_common_info_member {
>>>> u8 type_len;
>>>> u8 *name;
>>>> } __packed;
>>>> @@ -64,6 +70,27 @@ struct fru_board_data {
>>>> struct list_head custom_fields;
>>>> };
>>>> +struct fru_product_data {
>>>> + u8 ver;
>>>> + u8 len;
>>>> + u8 lang_code;
>>>> + u8 manufacturer_type_len;
>>>> + u8 manufacturer_name[FRU_INFO_FIELD_LEN_MAX];
>>>> + u8 product_name_type_len;
>>>> + u8 product_name[FRU_INFO_FIELD_LEN_MAX];
>>>> + u8 part_number_type_len;
>>>> + u8 part_number[FRU_INFO_FIELD_LEN_MAX];
>>>> + u8 version_number_type_len;
>>>> + u8 version_number[FRU_INFO_FIELD_LEN_MAX];
>>>> + u8 serial_number_type_len;
>>>> + u8 serial_number[FRU_INFO_FIELD_LEN_MAX];
>>>> + u8 asset_number_type_len;
>>>> + u8 asset_number[FRU_INFO_FIELD_LEN_MAX];
>>>> + u8 file_id_type_len;
>>>> + u8 file_id[FRU_INFO_FIELD_LEN_MAX];
>>>> + struct list_head custom_fields;
>>>> +};
>>>> +
>>>> struct fru_multirec_hdr {
>>>> u8 rec_type;
>>>> u8 type;
>>>> @@ -85,6 +112,7 @@ struct fru_multirec_node {
>>>> struct fru_table {
>>>> struct fru_common_hdr hdr;
>>>> struct fru_board_data brd;
>>>> + struct fru_product_data prd;
>>>> struct list_head multi_recs;
>>>> bool captured;
>>>> };
>>>> @@ -102,13 +130,15 @@ struct fru_table {
>>>> /* This should be minimum of fields */
>>>> #define FRU_BOARD_AREA_TOTAL_FIELDS 5
>>>> +#define FRU_PRODUCT_AREA_TOTAL_FIELDS 7
>>>> #define FRU_TYPELEN_TYPE_SHIFT 6
>>>> #define FRU_TYPELEN_TYPE_BINARY 0
>>>> #define FRU_TYPELEN_TYPE_ASCII8 3
>>>> int fru_display(int verbose);
>>>> int fru_capture(const void *addr);
>>>> -int fru_generate(const void *addr, int argc, char *const argv[]);
>>>> +int fru_board_generate(const void *addr, int argc, char *const
>>>> argv[]);
>>>> +int fru_product_generate(const void *addr, int argc, char *const
>>>> argv[]);
>>>> u8 fru_checksum(u8 *addr, u8 len);
>>>> int fru_check_type_len(u8 type_len, u8 language, u8 *type);
>>>> const struct fru_table *fru_get_fru_data(void);
>>>> diff --git a/lib/fru_ops.c b/lib/fru_ops.c
>>>> index a25ebccd110d..978d5f8e8a19 100644
>>>> --- a/lib/fru_ops.c
>>>> +++ b/lib/fru_ops.c
>>>> @@ -16,9 +16,18 @@
>>>> struct fru_table fru_data __section(".data") = {
>>>> .brd.custom_fields = LIST_HEAD_INIT(fru_data.brd.custom_fields),
>>>> + .prd.custom_fields = LIST_HEAD_INIT(fru_data.prd.custom_fields),
>>>> .multi_recs = LIST_HEAD_INIT(fru_data.multi_recs),
>>>> };
>>>> +static const char * const fru_typecode_str[] = {
>>>> + "Binary/Unspecified",
>>>> + "BCD plus",
>>>> + "6-bit ASCII",
>>>> + "8-bit ASCII",
>>>> + "2-byte UNICODE"
>>>> +};
>>>
>>> This can be done via separate patch to make this one smaller and
>>> easier to review.
>>
>> It's just moved out from 'fru_display_board' function because it can be
>> used for both 'fru_display_board' and 'fru_display_product' functions.
>> Definately it's a part of this patch and I don't think that it should be
>> submitted using a seperate patch.
>
> No doubt that that it can stay here. It is more about to have just small
> patches which is much much easier to review. It means if one patch moves
> this structure to common location for using for product area generation.
> I need to review 20 LOC. And this patch is smaller which is again easier
> to review without distraction from obvious/easy going changes.
Okay. I'll split this small piece as a separate one.
Thanks,
Jae
next prev parent reply other threads:[~2022-09-22 16:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 16:42 [PATCH v4 0/6] cmd/fru: move FRU handling support to common region Jae Hyun Yoo
2022-08-25 16:42 ` [PATCH v4 1/6] xilinx: common: refactor FRU handling support Jae Hyun Yoo
2022-09-21 13:40 ` Michal Simek
2022-09-22 6:39 ` Jae Hyun Yoo
2022-09-22 7:29 ` Michal Simek
2022-09-22 16:22 ` Jae Hyun Yoo
2022-08-25 16:42 ` [PATCH v4 2/6] cmd: fru: move FRU handling support to common region Jae Hyun Yoo
2022-08-25 16:42 ` [PATCH v4 3/6] cmd: fru: fix a sandbox segfault issue Jae Hyun Yoo
2022-09-21 13:07 ` Michal Simek
2022-09-22 6:39 ` Jae Hyun Yoo
2022-08-25 16:42 ` [PATCH v4 4/6] cmd: fru: add product info area parsing support Jae Hyun Yoo
2022-09-21 13:52 ` Michal Simek
2022-09-22 6:39 ` Jae Hyun Yoo
2022-09-22 7:19 ` Michal Simek
2022-09-22 16:15 ` Jae Hyun Yoo [this message]
2022-08-25 16:42 ` [PATCH v4 5/6] doc: fru: add documentation for the fru command and APIs Jae Hyun Yoo
2022-09-21 13:54 ` Michal Simek
2022-09-22 6:40 ` Jae Hyun Yoo
2022-08-25 16:42 ` [PATCH v4 6/6] test: cmd: fru: add unit test for the fru command Jae Hyun Yoo
2022-09-15 14:01 ` [PATCH v4 0/6] cmd/fru: move FRU handling support to common region Jae Hyun Yoo
2022-09-15 14:38 ` Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c75600f6-70ca-5bbb-fc0a-dd524f4f85b9@quicinc.com \
--to=quic_jaehyoo@quicinc.com \
--cc=ashok.reddy.soma@xilinx.com \
--cc=clg@kaod.org \
--cc=jnhuang95@gmail.com \
--cc=macromorgan@hotmail.com \
--cc=mario.six@gdsys.cc \
--cc=masahisa.kojima@linaro.org \
--cc=michal.simek@amd.com \
--cc=mr.nuke.me@gmail.com \
--cc=ovidiu.panait@windriver.com \
--cc=pali@kernel.org \
--cc=patrick.delaunay@foss.st.com \
--cc=quic_ggregory@quicinc.com \
--cc=quic_jiles@quicinc.com \
--cc=roland.gaudig@weidmueller.com \
--cc=sjg@chromium.org \
--cc=thuth@redhat.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).