From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 71CE3C6FA8B for ; Thu, 22 Sep 2022 07:20:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3571884A6B; Thu, 22 Sep 2022 09:20:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="gWRJHuCB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 767F384A40; Thu, 22 Sep 2022 09:20:01 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2052.outbound.protection.outlook.com [40.107.101.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 48FC484BBE for ; Thu, 22 Sep 2022 09:19:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=michal.simek@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DL5TX1By1Cpx0tCGKnsCXKwJ+mBQI9lUP9TiRo31o5sR7F6iOZihXi5VODeGMf0jLU8Cn0LyvH/9sUSbxVTJyZ9MkjVUoGWHvPZjkB8/DDgkM+3N/ytyUJqdP7rjBacL/71Qi4H+EvQLLp5kE1AaOQppfhgbe6vEPrRjHjnfbtXL322zodwPKFC4ekKw4k8sOy0TdLvjKXo1lzvI591E5veHD61b513YBSWXD+gwsyLha7A3DKxAEFYQYK6CQB7nEzj14cSDEbYfZ5jRd2ODoWhYi3BUlBVK0T+NxVMjMlYkAIiQrvq30K3yJ9p8wiBqwDtIAKlt4a9pQb5g8ZH3SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mOlp40ELw3KH2Rhu2ncK9IxPRAHxTVsSCCEAcnVzpR8=; b=e8Iep3Fi61xRH8JjLWHoa+T2XdlXifzGrcS9Y8iaYebAmiz+by9RXO75A9K++CS5f3yO92n+XzorLppYG7sLvxQEi6QUlu6ALUJ3Y3w+G9cJW5CaD87hlVlhwP3cjXLsB2UkbEP6gYVV7sYPQM/epkb9TCUyn+xmTEj8bwtOwNzvgu5xAvTdhj3kXV6sgy6CzoJBrHT8JRb8uhW1lRMukhrjYAfKci8wP3WiBHEa11cSF10pqOA8gva1Rmt06jesCzqtWBQBFmXt5SfO6vTFKoJONxU6VjUQW4W9VqUxHksSjdHAwrhrti9bIT9CCh8gc/jJlI45K0sFrTXiwde+4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=quicinc.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mOlp40ELw3KH2Rhu2ncK9IxPRAHxTVsSCCEAcnVzpR8=; b=gWRJHuCBenbxlwxYWrnREys8yc+bk3a2aHB/BlhYBqd1yZRP+AS19G+19hS/+vLxmGFffRQB8dfNWRncCdp9nxDmBEWlnSUi/jpQBCQ3Phv5YREzYj/qBKzE466DNqeVrWJfmvy2C+BB/9mXezh3mAD2DwnGL8rEkUkohvK3X20= Received: from DM6PR14CA0046.namprd14.prod.outlook.com (2603:10b6:5:18f::23) by DM4PR12MB6158.namprd12.prod.outlook.com (2603:10b6:8:a9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.16; Thu, 22 Sep 2022 07:19:53 +0000 Received: from DS1PEPF0000B076.namprd05.prod.outlook.com (2603:10b6:5:18f:cafe::5) by DM6PR14CA0046.outlook.office365.com (2603:10b6:5:18f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21 via Frontend Transport; Thu, 22 Sep 2022 07:19:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF0000B076.mail.protection.outlook.com (10.167.17.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5654.11 via Frontend Transport; Thu, 22 Sep 2022 07:19:53 +0000 Received: from [10.254.241.52] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 22 Sep 2022 02:19:47 -0500 Message-ID: Date: Thu, 22 Sep 2022 09:19:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH v4 4/6] cmd: fru: add product info area parsing support Content-Language: en-US To: Jae Hyun Yoo , Ovidiu Panait , Simon Glass , Mario Six , Masahisa Kojima , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Heinrich Schuchardt , Ashok Reddy Soma , Thomas Huth , Huang Jianan , Chris Morgan , Roland Gaudig , Patrick Delaunay , Alexandru Gagniuc CC: Jamie Iles , Graeme Gregory , =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , References: <20220825164245.1606958-1-quic_jaehyoo@quicinc.com> <20220825164245.1606958-5-quic_jaehyoo@quicinc.com> <67b81d7f-db4b-32b8-f701-5c758ab2358b@amd.com> From: Michal Simek In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000B076:EE_|DM4PR12MB6158:EE_ X-MS-Office365-Filtering-Correlation-Id: c573d623-9f37-464d-bd86-08da9c6ad825 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DPudq8YZPwl1FAzepLFValZM2Uh248FLfrRCKwxb36ofjaTk66yt0mpVkEoMTCN8ntoYqhucH4spa/jID5mYj5HAnzBQ8ChMZM/sxTD47BCIMRu/kfDScGCHBwP9r6qciA+WjCuWpb/ofQUckBMDFhMt2pzL0bQzf6aZ2yDYvRbCumisN62CUxXnLbh7LUQhP1UbkZnvEA6D0aRUGTmV5a7C9c5cOteUp2CyvJ6cux+teutzj9B7RtvEddVQeI9W4lyPAYFNJYOcSw6UyjJNJWMJ/ox//sxcQbky16j6+z6KbnJaJJ8l9DKq0szb3MjGHwxB5XoJ5bQyJYVpQYvzddWcjcsTBoA6QxYZ1tKWCinAXXk5LMNOE4T3air4ITercjiGK4IGkX9Kn94G9jDU+2zdMnq+WTcxD06NIwb9or48Bq2TELCrZtQNi6TgHS9Fepxd9ebYTuXjuNpTB4GweAntxFClVDTNT1okUmmCRSb41W7pw3ICbWQeBIQkEJW/bxSJUaeUze5u5E7+MuNpnlhs8mRsDOSFOv34AFZhFkGgkXLaX+9hhSMNB68/lOgsmT+D/4DjCmFeAOkbDcfb/lYgSXk22xTqZTasFro1hucEX+LhlhXbaWc6EDQIzAMdJXkl3jDNoUq6f5/LSaH0wdnrGe8mU+geBrS8zL2R7//TwchEWc5sw3fBofIGo5O5WB7oJpJ4P0mQIXixaF1WOdmrfy193A0WP/R/z5BGjrGVGbtVWIQsVoWEBurIGRpShLketOEyVklgTNyK2KZODl5oysaojnZUi3wSh36bfofP3+paPFBq+rzgqvVuTpi2L5lK/nuMS6dnybQF2vC4aAQ9u/gTD4YcE2u50CLgh/4= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199015)(36840700001)(40470700004)(81166007)(44832011)(26005)(40460700003)(8936002)(31686004)(2906002)(41300700001)(7416002)(6666004)(2616005)(426003)(54906003)(70206006)(110136005)(4326008)(53546011)(8676002)(16576012)(921005)(70586007)(316002)(356005)(82740400003)(83380400001)(478600001)(16526019)(31696002)(5660300002)(40480700001)(86362001)(32650700002)(82310400005)(336012)(36860700001)(36756003)(186003)(43740500002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 07:19:53.2071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c573d623-9f37-464d-bd86-08da9c6ad825 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000B076.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6158 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 >>> --- >>> 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 - 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 \n" >>> -    "              [custom ...] - Generate FRU\n" >>> -    "              format with board info area filled based on\n" >>> +    "fru generate -b \n" >>> +    "                [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. is pointing to place where FRU is\n" >>>       "                generated.\n" >>> +    "fru generate -p \n" >>> +    "                \n" >>> +    "                [custom ...] - Generate FRU format with\n" >>> +    "                product info area filled based on parameters. \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. Thanks, Michal