From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.62]) by mx.groups.io with SMTP id smtpd.web11.73100.1680534335411102248 for ; Mon, 03 Apr 2023 08:05:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=rNjrjhHW; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.93.62, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bv0ktFU1c0O2sxLlQhHGHDfAXY9paHa2VVSD3Efv5Cg1QPsW649JQ5i8puEC5JfOR1kDNdakJvn+X9rGzTmn3JLZdRpnFP63mWk1BtArrkH98L4inLRlKUEhrT3hmvG7MBP1+opyz6MLIJO7ljGFE/XvmTUf3A5HVkYgHSP/PCBvYz+PL0FCDMOu74OWRj0Odg6go+gpA0Eshv3ztyhWn0yffPzXq4MJyZdV6991OcnAQLAjVX4EjRRXP9adV3GEMs91LMwjG2CBuwddxU7IsAjnyS6CHmPQIrciMzNXTDRQWCUjmqWCZrJQQEuKzPDWALhM+oHdZ+Tzs9vZUhi9kA== 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=WZ4PGS6c6io1px5pq95mKv3calcsQgx0maK2pXs+Ee4=; b=e9x23gcCQVWvn6GwhHHbRir5Bw2aijC7MBp8b6eAqIeRKhauzU05Iyziz2mSHdNaxH2qa9lHQCRzDtmS8pEFDFpZeeTiWRMh26YavfsB3HcfhVtBVjIJCS5nBH5pOmOVS7MaFYVJh9AST12/NCO6kEuVwtYdOfE+vcPT+valYL7/1T2QzhvevApZ55Lokl9zTro+pdp2swA6yiMckTcas3YHGIdvtzFurgXEzMnkDbrLySDRig6xAhCu1zwG0tMNqCaLsJkdWSwXUEP5/9L/GiB3Rj1owcyQ3Jku/SkgBnEoNIrxGufgeS5tvw8h6mCcasR43fR3U0VKylGMIs8R4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io 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=WZ4PGS6c6io1px5pq95mKv3calcsQgx0maK2pXs+Ee4=; b=rNjrjhHWG9Yelv9TO98g+WWMX+84NrkLt8yBPErjO5ZNnVrfcHHqzdiS6mXaCM4lgtVzcnmSGbxNVe/XdxdPPJAyRmaq9IyHDg8Md7nBPqeWekaKW7tLrlnMNlLlA7wehW+fiFwPo8CX+8pQDcaXctavlQugFj8SMZvHbuwUSwo= Received: from DM6PR13CA0036.namprd13.prod.outlook.com (2603:10b6:5:bc::49) by DM4PR12MB6230.namprd12.prod.outlook.com (2603:10b6:8:a7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 15:05:33 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:bc:cafe::b5) by DM6PR13CA0036.outlook.office365.com (2603:10b6:5:bc::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.26 via Frontend Transport; Mon, 3 Apr 2023 15:05:32 +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 DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6277.16 via Frontend Transport; Mon, 3 Apr 2023 15:05:32 +0000 Received: from TPE-L1-ABNCHANG.amd.com (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.34; Mon, 3 Apr 2023 10:05:30 -0500 From: "Chang, Abner" To: CC: Isaac Oram , Abdul Lateef Attar , Nickle Wang , Igor Kulchytskyy Subject: [edk2-platforms][PATCH 07/14] ManageabilityPkg/KCS: KCS transport interface Date: Mon, 3 Apr 2023 23:04:52 +0800 Message-ID: <20230403150459.925-8-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230403150459.925-1-abner.chang@amd.com> References: <20230403150459.925-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com 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: DM6NAM11FT070:EE_|DM4PR12MB6230:EE_ X-MS-Office365-Filtering-Correlation-Id: 21523103-0d4a-473d-4f46-08db3454df23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LPRM5CPBQBHDtEAPgg9WxP+EQA6EIxqdwavJmEYFNpnh6uRzozlYTHmIUQSesCfzDyAt4rTJZ/FUva1WjujfzPrvqudHXdAsV5lCBAtZydDS8+QrHiVQywrAmZnGYOWAkXNIq7eUC03E3Q9/c9XyPLVayatmNFb99U8lZLv78nBPcSG0hI/5u+9VysMl0yJ7v8Wgah1mjMWP/bBrGqXeNEu4BEDnosElm4asHaHK5KVq3E+e186QY1lZ+d44J0vjuEYljvBKbcBZmAOptmQwAwjD/SGNH1UMZRABp/5ah8BuxuAo4wdHa4w8zE8lcOwrNI4qOvs7X/sDSEcjrQSu4oK+eKJVqgKZr4K85NAbm/YhNwqsmXpQ5Drq2t4vGHiZoahmxg3wPA0UwWSLXC2TOeNKp8AIo5Bw1IGK0V+i4s8DhGCZnDW3ZGoVhtEseLUsQ4dn/amIiqWM3blvTIhazdrClC+wIc0EhihUt09W74u4W+n8BnSpzBepvk4CwE9bMZjtsrsKGN9Xyd40Cuk6IfXQWwwcfHxTJ3NIEsruuz1g3bEryG8Zc28cHTVu/nRSjAbKYwMCekhJf7W3ZWtGPwWCK1wZKWPx/1zBXnxfY3rp2LLA+AEvFu7fzYoMW4hJHw9FzhrIKtcb7bvegxT9Dk479cqU44OXahLuYuxLMjmw6bdEwax0n1oOn2YG135/kGPu5p3VgSbYlmmX/buuNHlEzY8xrgLsFcsJf/YHvODpkFVm0Ey1xYn7GobIttTI 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:(13230028)(4636009)(346002)(396003)(136003)(39860400002)(376002)(451199021)(40470700004)(36840700001)(46966006)(5660300002)(426003)(336012)(86362001)(2616005)(82310400005)(356005)(186003)(83380400001)(47076005)(16526019)(1076003)(26005)(81166007)(82740400003)(36860700001)(40480700001)(8936002)(478600001)(54906003)(7696005)(41300700001)(36756003)(4326008)(6916009)(40460700003)(8676002)(70206006)(316002)(6666004)(70586007)(2876002)(2906002)(36900700001)(44824005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 15:05:32.7806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21523103-0d4a-473d-4f46-08db3454df23 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: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6230 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang - Return Maximum Transfer Unit for MCTP over KCS - Check the parameters Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../Common/ManageabilityTransportKcs.h | 2 +- .../Common/KcsCommon.c | 111 ++++++++++-------- .../Dxe/ManageabilityTransportKcs.c | 24 ++-- 3 files changed, 77 insertions(+), 60 deletions(-) diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Common/ManageabilityTransportKcs.h b/Features/ManageabilityPkg/Library/Man= ageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h index d6685c165e..8c6a64416a 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /ManageabilityTransportKcs.h +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /ManageabilityTransportKcs.h @@ -71,7 +71,7 @@ typedef struct { EFI_STATUS EFIAPI KcsTransportSendCommand ( - IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader, + IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader OPTIONAL, IN UINT16 TransmitHeaderSize, IN MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer OPTIONAL, IN UINT16 TransmitTrailerSize, diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Common/KcsCommon.c b/Features/ManageabilityPkg/Library/ManageabilityTransp= ortKcsLib/Common/KcsCommon.c index 14a7047447..6ff14f0c97 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /KcsCommon.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /KcsCommon.c @@ -99,14 +99,14 @@ ClearOBF ( Algorithm is based on flow chart provided in IPMI spec 2.0 Figure 9-6, KCS Interface BMC to SMS Write Transfer Flow Chart =20 - @param[in] TransmitHeader KCS packet header. - @param[in] TransmitHeaderSize KCS packet header size in byte. - @param[in] TransmitTrailer KCS packet trailer. - @param[in] TransmitTrailerSize KCS packet trailer size in byte. - @param[in] RequestData Command Request Data, could be NULL. - RequestDataSize must be zero, if Reque= stData - is NULL. - @param[in] RequestDataSize Size of Command Request Data. + @param[in] TransmitHeader KCS packet header. + @param[in] TransmitHeaderSize KCS packet header size in byte. + @param[in] TransmitTrailer KCS packet trailer. + @param[in] TransmitTrailerSize KCS packet trailer size in byte. + @param[in] RequestData Command Request Data, could be NUL= L. + RequestDataSize must be zero, if R= equestData + is NULL. + @param[in] RequestDataSize Size of Command Request Data. =20 @retval EFI_SUCCESS The command byte stream was successful= ly submit to the device and a response wa= s @@ -414,7 +414,7 @@ KcsTransportRead ( EFI_STATUS EFIAPI KcsTransportSendCommand ( - IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader, + IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader OPTIONAL, IN UINT16 TransmitHeaderSize, IN MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer OPTIONAL, IN UINT16 TransmitTrailerSize, @@ -427,6 +427,7 @@ KcsTransportSendCommand ( EFI_STATUS Status; UINT32 RspHeaderSize; IPMI_KCS_RESPONSE_HEADER RspHeader; + UINT32 ExpectedResponseDataSize; =20 if ((RequestData !=3D NULL) && (RequestDataSize =3D=3D 0)) { DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData and Request= DataSize\n", __FUNCTION__)); @@ -438,65 +439,71 @@ KcsTransportSendCommand ( return EFI_INVALID_PARAMETER; } =20 - if (TransmitHeader =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a: TransmitHeader is NULL\n", __FUNCTION__)); - return EFI_INVALID_PARAMETER; + // Print out the request payloads. + if ((TransmitHeader !=3D NULL) && (TransmitHeaderSize !=3D 0)) { + HelperManageabilityDebugPrint ((VOID *)TransmitHeader, (UINT32)Transmi= tHeaderSize, "KCS Transmit Header:\n"); } =20 - // - // Print out the request payloads. - HelperManageabilityDebugPrint ((VOID *)TransmitHeader, TransmitHeaderSiz= e, "KCS Transmit Header:\n"); if (RequestData !=3D NULL) { HelperManageabilityDebugPrint ((VOID *)RequestData, RequestDataSize, "= KCS Request Data:\n"); } =20 - if (TransmitTrailer !=3D NULL) { - HelperManageabilityDebugPrint ((VOID *)TransmitTrailer, TransmitTraile= rSize, "KCS Transmit Trailer:\n"); - } + if ((TransmitTrailer !=3D NULL) && (TransmitTrailerSize !=3D 0)) { + HelperManageabilityDebugPrint ((VOID *)TransmitTrailer, (UINT32)Transm= itTrailerSize, "KCS Transmit Trailer:\n"); + } + + if ((TransmitHeader !=3D NULL) || (RequestData !=3D NULL)) { + Status =3D KcsTransportWrite ( + TransmitHeader, + TransmitHeaderSize, + TransmitTrailer, + TransmitTrailerSize, + RequestData, + RequestDataSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "KCS Write Failed with Status(%r)", Status)); + return Status; + } =20 - Status =3D KcsTransportWrite ( - TransmitHeader, - TransmitHeaderSize, - TransmitTrailer, - TransmitTrailerSize, - RequestData, - RequestDataSize - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "IPMI KCS Write Failed with Status(%r)", Status))= ; - return Status; - } + // + // Read the response header + RspHeaderSize =3D sizeof (IPMI_KCS_RESPONSE_HEADER); + Status =3D KcsTransportRead ((UINT8 *)&RspHeader, &RspHeaderSiz= e); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "KCS read response header failed Status(%r), " \ + "RspNetFunctionLun =3D 0x%x, " \ + "Comamnd =3D 0x%x \n", + Status, + RspHeader.NetFunc, + RspHeader.Command + )); + return (Status); + } =20 - // - // Read the response header - RspHeaderSize =3D sizeof (IPMI_KCS_RESPONSE_HEADER); - Status =3D KcsTransportRead ((UINT8 *)&RspHeader, &RspHeaderSize)= ; - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "IPMI KCS read response header failed Status(%r), " \ - "RspNetFunctionLun =3D 0x%x, " \ - "Command =3D 0x%x \n", - Status, - RspHeader.NetFunc, - RspHeader.Command - )); - return (Status); + // + // Print out the response payloads. + HelperManageabilityDebugPrint ((VOID *)&RspHeader, RspHeaderSize, "KCS= Response Header:\n"); } =20 - // - // Print out the response payloads. - HelperManageabilityDebugPrint ((VOID *)&RspHeader, (UINT16)RspHeaderSize= , "KCS Response Header:\n"); - if ((ResponseData !=3D NULL) && (ResponseDataSize !=3D NULL) && (*Respon= seDataSize !=3D 0)) { - Status =3D KcsTransportRead ((UINT8 *)ResponseData, ResponseDataSize); + ExpectedResponseDataSize =3D *ResponseDataSize; + Status =3D KcsTransportRead ((UINT8 *)ResponseData, = ResponseDataSize); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "IPMI KCS response read Failed with Status(%r)"= , Status)); + DEBUG ((DEBUG_ERROR, "KCS response read Failed with Status(%r)", Sta= tus)); } =20 // // Print out the response payloads. - HelperManageabilityDebugPrint ((VOID *)ResponseData, *ResponseDataSize= , "KCS Response Data:\n"); + if (*ResponseDataSize !=3D 0) { + if (ExpectedResponseDataSize !=3D *ResponseDataSize) { + DEBUG ((DEBUG_ERROR, "Expected KCS response size : %d is not match= ed to returned size : %d.\n", ExpectedResponseDataSize, *ResponseDataSize))= ; + Status =3D EFI_DEVICE_ERROR; + } + HelperManageabilityDebugPrint ((VOID *)ResponseData, (UINT32)*Respon= seDataSize, "KCS Response Data:\n"); + } } else { *ResponseDataSize =3D 0; } diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Dxe/ManageabilityTransportKcs.c b/Features/ManageabilityPkg/Library/Manage= abilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c index a9eff886d0..db4e707b3a 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/Ma= nageabilityTransportKcs.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/Ma= nageabilityTransportKcs.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -225,13 +226,6 @@ KcsTransportTransmitReceive ( return; } =20 - // Transmit header is necessary for KCS transport, which could be - // NetFn, Command and etc. - if (TransferToken->TransmitHeader =3D=3D NULL) { - TransferToken->TransferStatus =3D EFI_INVALID_PARAMETER; - return; - } - Status =3D KcsTransportSendCommand ( TransferToken->TransmitHeader, TransferToken->TransmitHeaderSize, @@ -354,6 +348,22 @@ GetTransportCapability ( } =20 *TransportCapability =3D 0; + if (CompareGuid ( + TransportToken->ManageabilityProtocolSpecification, + &gManageabilityProtocolIpmiGuid + )) + { + *TransportCapability |=3D + (MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE <<= MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_BIT_POSITION); + } else if (CompareGuid ( + TransportToken->ManageabilityProtocolSpecification, + &gManageabilityProtocolMctpGuid + )) + { + *TransportCapability |=3D + (MCTP_KCS_MTU_IN_POWER_OF_2 << MANAGEABILITY_TRANSPORT_CAPABILITY_MA= XIMUM_PAYLOAD_BIT_POSITION); + } + return EFI_SUCCESS; } =20 --=20 2.37.1.windows.1