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 332B7C00144 for ; Fri, 29 Jul 2022 11:12:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 89CB683FB3; Fri, 29 Jul 2022 13:12:10 +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="uyOcn077"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC85C83FB3; Fri, 29 Jul 2022 13:12:09 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) (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 CF60C83FA6 for ; Fri, 29 Jul 2022 13:12:06 +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=OVZBMgkVBLXAwVm3mL4aYs3wswLwepXxCMGrbT+Ryt845evDUAZKU9jjF68DEuzRuyGy7/Kis/Tde7phmyJTZFpbhC43hA7p7GsATrK3cGD/3AM+GwlmNFSHAhTuaLrVOpZxJXMBjMIeLDqLUP9s07SuB8xf5QLZphiPba7+P0ukQ3rgsEJglV/Duzn0Oc0XHimBBNUj0JG/cgTWJwptTds6Pho+0iEn0v2Fu0sOgYRF2JDxn4nugnrDh7mRWoJJsOZoDbVvagjk26mR1YjYKTRGj6fN0Dj6cp1PrvA6HWf/QY1lI3uhm/yZbP14c34yo0QS1nJ5VNgxpGS2cUlB3Q== 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=ITBfVNr5UJ+pRSPINUSFK1ADYYcOXjMokM5GD1snaaU=; b=arH8fqlh8FTW/VDFt/RHlXe4A5VboE2P4n3+xnEt/DdNj9cHjQHO4t/JGP0XE03mx7MuPHsEYrBdL5qvIQPivW9VfPn/12P3VAqjgMaIDUHZnBPdqsTJ90oIjqxZ6qlPZiLg6UGd0bq/EKcsJrxIN09ZD28KHyrp6tmWFDuKsrqtiqCR2KECuDTM0WR7QE8p7rpLdbcoyshERJ5IHYwMY4A3/mlIN1He1mudKihFYC30ED1sRRda/r3ZJiyPV34MY+I/JgrH5a98uddSyieWMkETr/Lg8qgyGjLjeXsyAgcmJLWSfYl+/2iXv3TLgU4cAo7itkbdmo92kH/6aKw87A== 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=ITBfVNr5UJ+pRSPINUSFK1ADYYcOXjMokM5GD1snaaU=; b=uyOcn077JaI6gPFYclJiIj1cZMrjLlgMiiz4zEI+Qev38snPWnsclAXvx5Sogviy00KsyyNXMWNrYYxFazjOENntuLDOpCv328OgBTMlJ0fJR5njWVODmgPgZghO5XKnR2R6ZUmmtnBGfMUiyk1adckIZfYZp/Jr/CIKiAFjWRk= Received: from DS7PR03CA0081.namprd03.prod.outlook.com (2603:10b6:5:3bb::26) by MN0PR12MB5788.namprd12.prod.outlook.com (2603:10b6:208:377::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.24; Fri, 29 Jul 2022 11:12:00 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3bb:cafe::ec) by DS7PR03CA0081.outlook.office365.com (2603:10b6:5:3bb::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.24 via Frontend Transport; Fri, 29 Jul 2022 11:12:00 +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 DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Fri, 29 Jul 2022 11:12:00 +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; Fri, 29 Jul 2022 06:11:54 -0500 Message-ID: <684ff6aa-401b-e736-5bfb-2dd9be4992b2@amd.com> Date: Fri, 29 Jul 2022 13:11:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [RFC PATCH 2/2] cmd/fru: add product info area parsing support Content-Language: en-US To: Jae Hyun Yoo , Ovidiu Panait , Simon Glass , 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: <20220726235005.135686-1-quic_jaehyoo@quicinc.com> <20220726235005.135686-3-quic_jaehyoo@quicinc.com> From: Michal Simek In-Reply-To: <20220726235005.135686-3-quic_jaehyoo@quicinc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a72b1fdd-417e-42be-f7e7-08da71532887 X-MS-TrafficTypeDiagnostic: MN0PR12MB5788:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OAY5nFHESxjVPeXSXLOZ0BqnN+5IQYriZf6Ew5GJqXC43JiEk8Ce1fYRZdJY/IViLqb2H/BSeO3UJ7AOT67jBL04eRgXsIuGJuWu70qHgA+sNfBA/7uYD38YE/Eo233pRQ5gm06bnn6d7TrFiMGo9aSrqacjpREbn3cpayw1FuWoam2hVoOIMbt7BWy+4XH8uC1xB/h00khfvHAiGdXBgUWwVoCnE3Sqxafa2JN8htzmBEgUBpFJAtqm6tOBr2Vl107edvujvRxYLtCXa5bIkzSCzZkvUqhtbbSSetgpV8hs2lgwId8Mgz1+/rzbl5HkNUl97c9TajvWLOujy8zfTj0pAoIiRTM0VuCOAv2xUMGlYRius9nFDhutpqAKydl0inZXGTAMFFMWFitfQxiq1kSGWH+BoPFQg7B+25+VuOPqutSvA1XIJjeCBJRfp+3o/5/NNav1yVRIt7ZHfCTbB/2nMWpsBKRixKPs/BP5TCnfdZpGiO3kIni6uH55VM7L1Rjt8nXQW9l7wg8//GEmCuPGBW4XqPjwWV8A0rUNNzK0C3FIfCsSTzUzPLkiVWvf6aFxv1Q/bkRfvPAA85p1Pn4sexYrvrSfORwVrneISLNjwCTl8yIASGUxil5q000shCidWl3VMi7CRzJxPYov7vxkKvixhdmLWG/D8JgrRNIKOjccqH6qt4GX4ZYbD0X9j/2jw4q0mwHEYccin1hJxH1oqv1P0AOQrZcLfUSG1ws3mjxzcP+q73dEnw5Th8Z9W1GYuD0rvQ7YFfV+e1kErNDIovjTGS6zj7J5Wrn/0Oyb/spnAi+WZN8l8kjRDs/cZrzigJkFHwYGO6yGRk+16LazoOsSAt35hFdBpgLHi3iqZMIAponeUAu6tYxaFhtyuLNm10k2YxG6gMLiNO90tw== 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:(13230016)(4636009)(376002)(396003)(136003)(346002)(39860400002)(40470700004)(36840700001)(40460700003)(31686004)(82310400005)(41300700001)(110136005)(36756003)(356005)(186003)(31696002)(2616005)(54906003)(16576012)(478600001)(40480700001)(16526019)(316002)(26005)(8676002)(86362001)(7416002)(44832011)(53546011)(5660300002)(336012)(426003)(70206006)(4326008)(82740400003)(83380400001)(8936002)(921005)(2906002)(32650700002)(36860700001)(81166007)(70586007)(36900700001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2022 11:12:00.1476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a72b1fdd-417e-42be-f7e7-08da71532887 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: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5788 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 On 7/27/22 01:50, Jae Hyun Yoo wrote: > Add product info area parsing support. > > Signed-off-by: Jae Hyun Yoo > --- > common/fru_ops.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++- > include/fru.h | 22 ++++++++ > 2 files changed, 155 insertions(+), 1 deletion(-) > > diff --git a/common/fru_ops.c b/common/fru_ops.c > index 0c5e264226ed..93d4970620f4 100644 > --- a/common/fru_ops.c > +++ b/common/fru_ops.c > @@ -218,6 +218,57 @@ static int fru_parse_board(unsigned long addr) > return 0; > } > > +static int fru_parse_product(unsigned long addr) > +{ > + u8 i, type; > + int len; > + u8 *data, *term, *limit; > + > + memcpy(&fru_data.prd.ver, (void *)addr, 6); > + addr += 3; > + data = (u8 *)&fru_data.prd.manufacturer_type_len; > + > + /* Record max structure limit not to write data over allocated space */ > + limit = (u8 *)&fru_data.prd + sizeof(struct fru_product_data); > + > + for (i = 0; ; i++, data += FRU_BOARD_MAX_LEN) { > + len = fru_check_type_len(*(u8 *)addr, fru_data.prd.lang_code, > + &type); > + /* > + * Stop cature if it end of fields > + */ > + if (len == -EINVAL) > + break; > + > + /* Stop when amount of chars is more then fields to record */ > + if (data + len > limit) > + break; > + /* This record type/len field */ > + *data++ = *(u8 *)addr; > + > + /* Add offset to match data */ > + addr += 1; > + > + /* If len is 0 it means empty field that's why skip writing */ > + if (!len) > + continue; > + > + /* Record data field */ > + memcpy(data, (u8 *)addr, len); > + term = data + (u8)len; > + *term = 0; > + addr += len; > + } > + > + if (i < FRU_PRODUCT_AREA_TOTAL_FIELDS) { > + printf("Product area require minimum %d fields\n", > + FRU_PRODUCT_AREA_TOTAL_FIELDS); > + return -EINVAL; > + } > + > + return 0; > +} > + > __weak int fru_parse_multirec(unsigned long addr) > { > u8 hdr_len = sizeof(struct fru_multirec_hdr); > @@ -265,6 +316,9 @@ int fru_capture(unsigned long addr) > if (hdr->off_board) > fru_parse_board(addr + fru_cal_area_len(hdr->off_board)); > > + if (hdr->off_product) > + fru_parse_product(addr + fru_cal_area_len(hdr->off_product)); > + > if (hdr->off_multirec) > fru_parse_multirec(addr + fru_cal_area_len(hdr->off_multirec)); > > @@ -352,6 +406,78 @@ static int fru_display_board(struct fru_board_data *brd, int verbose) > return 0; > } > > +static int fru_display_product(struct fru_product_data *prd, int verbose) > +{ > + u8 type; > + int len; > + u8 *data; > + static const char * const typecode[] = { > + "Binary/Unspecified", > + "BCD plus", > + "6-bit ASCII", > + "8-bit ASCII", > + "2-byte UNICODE" > + }; This should be generic for all records and should be shared. Thanks, Michal