Reviewed-by: Nickle Wang <nick...@nvidia.com>

Regards,
Nickle

> -----Original Message-----
> From: abner.ch...@amd.com <abner.ch...@amd.com>
> Sent: Tuesday, April 18, 2023 3:16 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram <isaac.w.o...@intel.com>; Abdul Lateef Attar
> <abdat...@amd.com>; Nickle Wang <nick...@nvidia.com>; Igor Kulchytskyy
> <ig...@ami.com>
> Subject: [edk2-platforms][PATCH V2 03/14] ManageabilityPkg: Add HeaderSize
> and TrailerSize
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang <abner.ch...@amd.com>
> 
> Add HeaderSize and TrailerSize in
> MANAGEABILITY_TRANSFER_TOKEN structure.
> Manageability transport interface may used by multiple protocols which have
> different header and trailer of payload. (e.g. MCTP over KCS and IPMI over 
> KCS).
> 
> Signed-off-by: Abner Chang <abner.ch...@amd.com>
> Cc: Isaac Oram <isaac.w.o...@intel.com>
> Cc: Abdul Lateef Attar <abdat...@amd.com>
> Cc: Nickle Wang <nick...@nvidia.com>
> Cc: Igor Kulchytskyy <ig...@ami.com>
> ---
>  .../Library/ManageabilityTransportLib.h       |   2 +
>  .../Common/ManageabilityTransportKcs.h        |  20 ++-
>  .../IpmiProtocol/Common/IpmiProtocolCommon.h  |  36 +++--
>  .../Common/KcsCommon.c                        | 152 ++++++++++++------
>  .../Dxe/ManageabilityTransportKcs.c           |  14 +-
>  .../IpmiProtocol/Common/IpmiProtocolCommon.c  |  63 +++++---
>  Features/ManageabilityPkg/Readme.md           |  10 ++
>  7 files changed, 194 insertions(+), 103 deletions(-)
> 
> diff --git
> a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
> b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
> index d86d0d87d5..04072aee89 100644
> --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
> +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLi
> +++ b.h
> @@ -168,10 +168,12 @@ struct _MANAGEABILITY_TRANSFER_TOKEN {
>                                                                            
> ///< which is sent discretely of payload.
>                                                                            
> ///< This field can be NULL if the
> transport
>                                                                            
> ///< doesn't require this.
> +  UINT16                                       TransmitHeaderSize;        
> ///< Transmit header
> size in byte.
>    MANAGEABILITY_TRANSPORT_TRAILER              TransmitTrailer;           
> ///< This
> is the transport-specific trailer
>                                                                            
> ///< which is sent discretely of payload.
>                                                                            
> ///< This field can be NULL if the
> transport
>                                                                            
> ///< doesn't require this.
> +  UINT16                                       TransmitTrailerSize;       
> ///< Transmit trailer size
> in byte.
>    MANAGEABILITY_TRANSMIT_PACKAGE               TransmitPackage;           
> ///<
> The payload sent to transport interface.
>    MANAGEABILITY_RECEIVE_PACKAGE                ReceivePackage;            
> ///< The
> buffer to receive the response.
>    EFI_STATUS                                   TransferStatus;            
> ///< The EFI Status of the
> transfer.
> diff --git
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/
> ManageabilityTransportKcs.h
> b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/
> ManageabilityTransportKcs.h
> index 2cdf60ba7e..d6685c165e 100644
> ---
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/
> ManageabilityTransportKcs.h
> +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Com
> +++ mon/ManageabilityTransportKcs.h
> @@ -41,8 +41,10 @@ typedef struct {
>  /**
>    This service communicates with BMC using KCS protocol.
> 
> -  @param[in]      NetFunction           Net function of the command.
> -  @param[in]      Command               IPMI Command.
> +  @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.
>    @param[in]      RequestDataSize       Size of Command Request Data.
>    @param[out]     ResponseData          Command Response Data. The completion
> @@ -69,12 +71,14 @@ typedef struct {
>  EFI_STATUS
>  EFIAPI
>  KcsTransportSendCommand (
> -  IN  UINT8      NetFunction,
> -  IN  UINT8      Command,
> -  IN  UINT8      *RequestData OPTIONAL,
> -  IN  UINT32     RequestDataSize,
> -  OUT UINT8      *ResponseData OPTIONAL,
> -  IN OUT UINT32  *ResponseDataSize OPTIONAL
> +  IN  MANAGEABILITY_TRANSPORT_HEADER   TransmitHeader,
> +  IN  UINT16                           TransmitHeaderSize,
> +  IN  MANAGEABILITY_TRANSPORT_TRAILER  TransmitTrailer OPTIONAL,
> +  IN  UINT16                           TransmitTrailerSize,
> +  IN  UINT8                            *RequestData OPTIONAL,
> +  IN  UINT32                           RequestDataSize,
> +  OUT UINT8                            *ResponseData OPTIONAL,
> +  IN OUT UINT32                        *ResponseDataSize OPTIONAL
>    );
> 
>  /**
> diff --git
> a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC
> ommon.h
> b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC
> ommon.h
> index 5a7236e9a6..8bf16e6277 100644
> ---
> a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC
> ommon.h
> +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtoc
> +++ olCommon.h
> @@ -44,21 +44,23 @@ SetupIpmiTransportHardwareInformation (
>    This functions setup the final header/body/trailer packets for
>    the acquired transport interface.
> 
> -  @param[in]         TransportToken  The transport interface.
> -  @param[in]         NetFunction     IPMI function.
> -  @param[in]         Command         IPMI command.
> -  @param[out]        PacketHeader    The pointer to receive header of 
> request.
> -  @param[in, out]    PacketBody      The request body.
> -                                     When IN, it is the caller's request 
> body.
> -                                     When OUT and NULL, the request body is 
> not
> -                                     changed.
> -                                     Whee out and non-NULL, the request body 
> is
> -                                     changed to comfort the transport 
> interface.
> -  @param[in, out]    PacketBodySize  The request body size.
> -                                     When IN and non-zero, it is the new data
> -                                     length of request body.
> -                                     When IN and zero, the request body is 
> unchanged.
> -  @param[out]        PacketTrailer   The pointer to receive trailer of 
> request.
> +  @param[in]         TransportToken     The transport interface.
> +  @param[in]         NetFunction        IPMI function.
> +  @param[in]         Command            IPMI command.
> +  @param[out]        PacketHeader       The pointer to receive header of 
> request.
> +  @param[out]        PacketHeaderSize   Pinter to receive packet header size 
> in
> byte.
> +  @param[in, out]    PacketBody         The request body.
> +                                        When IN, it is the caller's request 
> body.
> +                                        When OUT and NULL, the request body 
> is not
> +                                        changed.
> +                                        Whee out and non-NULL, the request 
> body is
> +                                        changed to comfort the transport 
> interface.
> +  @param[in, out]    PacketBodySize     The request body size.
> +                                        When IN and non-zero, it is the new 
> data
> +                                        length of request body.
> +                                        When IN and zero, the request body 
> is unchanged.
> +  @param[out]        PacketTrailer      The pointer to receive trailer of 
> request.
> +  @param[out]        PacketTrailerSize  Pinter to receive packet trailer 
> size in byte.
> 
>    @retval EFI_SUCCESS            Request packet is returned.
>    @retval EFI_UNSUPPORTED        Request packet is not returned because
> @@ -70,9 +72,11 @@ SetupIpmiRequestTransportPacket (
>    IN   UINT8                            NetFunction,
>    IN   UINT8                            Command,
>    OUT  MANAGEABILITY_TRANSPORT_HEADER   *PacketHeader OPTIONAL,
> +  OUT  UINT16                           *PacketHeaderSize,
>    IN OUT UINT8                          **PacketBody OPTIONAL,
>    IN OUT UINT32                         *PacketBodySize OPTIONAL,
> -  OUT  MANAGEABILITY_TRANSPORT_TRAILER  *PacketTrailer OPTIONAL
> +  OUT  MANAGEABILITY_TRANSPORT_TRAILER  *PacketTrailer OPTIONAL,
> +  OUT  UINT16                           *PacketTrailerSize
>    );
> 
>  /**
> diff --git
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/
> KcsCommon.c
> b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/
> KcsCommon.c
> index 17e2b8f231..14a7047447 100644
> ---
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/
> KcsCommon.c
> +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Com
> +++ mon/KcsCommon.c
> @@ -11,6 +11,7 @@
>  #include <Library/BaseMemoryLib.h>
>  #include <Library/IoLib.h>
>  #include <Library/DebugLib.h>
> +#include <Library/ManageabilityTransportHelperLib.h>
>  #include <Library/MemoryAllocationLib.h>  #include <Library/TimerLib.h>
> 
> @@ -98,8 +99,10 @@ 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
> 
> -  @param[in]  NetFunction           Net function of the command.
> -  @param[in]  Command               IPMI Command.
> +  @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 
> RequestData
>                                      is NULL.
> @@ -122,10 +125,12 @@ ClearOBF (
>  **/
>  EFI_STATUS
>  KcsTransportWrite (
> -  IN  UINT8   NetFunction,
> -  IN  UINT8   Command,
> -  IN  UINT8   *RequestData OPTIONAL,
> -  IN  UINT32  RequestDataSize
> +  IN  MANAGEABILITY_TRANSPORT_HEADER   TransmitHeader,
> +  IN  UINT16                           TransmitHeaderSize,
> +  IN  MANAGEABILITY_TRANSPORT_TRAILER  TransmitTrailer OPTIONAL,
> +  IN  UINT16                           TransmitTrailerSize,
> +  IN  UINT8                            *RequestData OPTIONAL,
> +  IN  UINT32                           RequestDataSize
>    )
>  {
>    EFI_STATUS  Status;
> @@ -134,37 +139,63 @@ KcsTransportWrite (
>    UINT8       *BufferPtr;
> 
>    // Validation on RequestData and RequestDataSize.
> -  if ((RequestData == NULL && RequestDataSize != 0) ||
> -      (RequestData != NULL && RequestDataSize == 0)
> -      ) {
> +  if (((RequestData == NULL) && (RequestDataSize != 0)) ||
> +      ((RequestData != NULL) && (RequestDataSize == 0))
> +      )
> +  {
>      DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData or
> RequestDataSize.\n", __FUNCTION__));
>      return EFI_INVALID_PARAMETER;
>    }
> 
> -  Length = sizeof (NetFunction) + sizeof (Command);
> +  // Validation on TransmitHeader and TransmitHeaderSize.
> +  if (((TransmitHeader == NULL) && (TransmitHeaderSize != 0)) ||
> +      ((TransmitHeader != NULL) && (TransmitHeaderSize == 0))
> +      )
> +  {
> +    DEBUG ((DEBUG_ERROR, "%a: Mismatched values of TransmitHeader or
> TransmitHeaderSize.\n", __FUNCTION__));
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  // Validation on TransmitHeader and TransmitHeaderSize.
> +  if (((TransmitTrailer == NULL) && (TransmitTrailerSize != 0)) ||
> +      ((TransmitTrailer != NULL) && (TransmitTrailerSize == 0))
> +      )
> +  {
> +    DEBUG ((DEBUG_ERROR, "%a: Mismatched values of TransmitTrailer or
> TransmitTrailerSize.\n", __FUNCTION__));
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Length = TransmitHeaderSize;
>    if (RequestData != NULL) {
>      Length = Length + RequestDataSize;
>    }
> 
> +  if ((TransmitTrailer != NULL) && (TransmitTrailerSize != 0)) {
> +    Length += TransmitTrailerSize;
> +  }
> +
>    Buffer = AllocateZeroPool (Length);
>    if (Buffer == NULL) {
>      return EFI_OUT_OF_RESOURCES;
>    }
> 
>    //
> -  // Buffer[0] = NetFunction
> -  // Buffer[1] = Command
> -  // Buffer [2..RequestDataSize] = RequestData
> +  // Buffer[0..(TransmitHeaderSize - 1)] = TransmitHeader  // Buffer
> + [TransmitHeader..(TransmitHeader + RequestDataSize - 1)] = RequestData
> + // Buffer [(TransmitHeader + RequestDataSize)..(TransmitHeader +
> + RequestDataSize + TransmitTrailerSize - 1)] = TransmitTrailer
>    //
>    BufferPtr = Buffer;
> -  CopyMem (BufferPtr, &NetFunction, sizeof (NetFunction));
> -  BufferPtr += sizeof (NetFunction);
> -  CopyMem (BufferPtr, &Command, sizeof (Command));
> -  BufferPtr += sizeof (Command);
> -  if (Length > (sizeof (NetFunction) + sizeof (Command))) {
> +  CopyMem ((VOID *)BufferPtr, (VOID *)TransmitHeader,
> + TransmitHeaderSize);  BufferPtr += TransmitHeaderSize;  if
> + (RequestData != NULL) {
>      CopyMem (BufferPtr, RequestData, RequestDataSize);
>    }
> 
> +  BufferPtr += RequestDataSize;
> +  if (TransmitTrailer != NULL) {
> +    CopyMem (BufferPtr, (VOID *)TransmitTrailer, TransmitTrailerSize);
> + }
> +
>    BufferPtr = Buffer;
> 
>    // Step 1. wait for IBF to get clear
> @@ -293,10 +324,11 @@ KcsTransportRead (
>    EFI_STATUS  Status;
>    UINT32      ReadLength;
> 
> -  if (DataByte == NULL || *Length == 0) {
> +  if ((DataByte == NULL) || (*Length == 0)) {
>      DEBUG ((DEBUG_ERROR, "%a: Either DataByte is NULL or Length is 0.\n",
> __FUNCTION__));
>      return EFI_INVALID_PARAMETER;
>    }
> +
>    ReadLength = 0;
>    while (ReadLength < *Length) {
>      // Step 1. wait for IBF to get clear @@ -350,8 +382,10 @@ 
> KcsTransportRead
> (
>  /**
>    This service communicates with BMC using KCS protocol.
> 
> -  @param[in]      NetFunction           Net function of the command.
> -  @param[in]      Command               IPMI Command.
> +  @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.
>    @param[in]      RequestDataSize       Size of Command Request Data.
>    @param[out]     ResponseData          Command Response Data. The completion
> @@ -380,12 +414,14 @@ KcsTransportRead (  EFI_STATUS  EFIAPI
> KcsTransportSendCommand (
> -  IN  UINT8      NetFunction,
> -  IN  UINT8      Command,
> -  IN  UINT8      *RequestData OPTIONAL,
> -  IN  UINT32     RequestDataSize,
> -  OUT UINT8      *ResponseData OPTIONAL,
> -  IN OUT UINT32  *ResponseDataSize OPTIONAL
> +  IN  MANAGEABILITY_TRANSPORT_HEADER   TransmitHeader,
> +  IN  UINT16                           TransmitHeaderSize,
> +  IN  MANAGEABILITY_TRANSPORT_TRAILER  TransmitTrailer OPTIONAL,
> +  IN  UINT16                           TransmitTrailerSize,
> +  IN  UINT8                            *RequestData OPTIONAL,
> +  IN  UINT32                           RequestDataSize,
> +  OUT UINT8                            *ResponseData OPTIONAL,
> +  IN OUT UINT32                        *ResponseDataSize OPTIONAL
>    )
>  {
>    EFI_STATUS                Status;
> @@ -393,30 +429,41 @@ KcsTransportSendCommand (
>    IPMI_KCS_RESPONSE_HEADER  RspHeader;
> 
>    if ((RequestData != NULL) && (RequestDataSize == 0)) {
> -    DEBUG((DEBUG_ERROR, "%a: Mismatched values of RequestData and
> RequestDataSize\n", __FUNCTION__));
> +    DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData and
> + RequestDataSize\n", __FUNCTION__));
>      return EFI_INVALID_PARAMETER;
>    }
> 
>    if ((ResponseData != NULL) && ((ResponseDataSize != NULL) &&
> (*ResponseDataSize == 0))) {
> -    DEBUG((DEBUG_ERROR, "%a: Mismatched values of ResponseData and
> ResponseDataSize\n", __FUNCTION__));
> +    DEBUG ((DEBUG_ERROR, "%a: Mismatched values of ResponseData and
> ResponseDataSize\n", __FUNCTION__));
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if (TransmitHeader == NULL) {
> +    DEBUG ((DEBUG_ERROR, "%a: TransmitHeader is NULL\n",
> + __FUNCTION__));
>      return EFI_INVALID_PARAMETER;
>    }
> 
> +  //
> +  // Print out the request payloads.
> +  HelperManageabilityDebugPrint ((VOID *)TransmitHeader,
> + TransmitHeaderSize, "KCS Transmit Header:\n");  if (RequestData != NULL) {
> +    HelperManageabilityDebugPrint ((VOID *)RequestData,
> + RequestDataSize, "KCS Request Data:\n");  }
> +
> +  if (TransmitTrailer != NULL) {
> +    HelperManageabilityDebugPrint ((VOID *)TransmitTrailer,
> + TransmitTrailerSize, "KCS Transmit Trailer:\n");  }
> +
>    Status = KcsTransportWrite (
> -             (NetFunction << 2),
> -             Command,
> +             TransmitHeader,
> +             TransmitHeaderSize,
> +             TransmitTrailer,
> +             TransmitTrailerSize,
>               RequestData,
>               RequestDataSize
>               );
>    if (EFI_ERROR (Status)) {
> -    DEBUG ((
> -      DEBUG_ERROR,
> -      "IPMI KCS Write Failed with Status(%r) for NetFunction(0x%x)," \
> -      " Command(0x%x).\n",
> -      Status,
> -      NetFunction,
> -      Command
> -      ));
> +    DEBUG ((DEBUG_ERROR, "IPMI KCS Write Failed with Status(%r)",
> + Status));
>      return Status;
>    }
> 
> @@ -429,7 +476,7 @@ KcsTransportSendCommand (
>        DEBUG_ERROR,
>        "IPMI KCS read response header failed Status(%r), " \
>        "RspNetFunctionLun = 0x%x, " \
> -      "Comamnd = 0x%x \n",
> +      "Command = 0x%x \n",
>        Status,
>        RspHeader.NetFunc,
>        RspHeader.Command
> @@ -437,16 +484,21 @@ KcsTransportSendCommand (
>      return (Status);
>    }
> 
> -  Status = KcsTransportRead ((UINT8 *)ResponseData, ResponseDataSize);
> -  if (EFI_ERROR (Status)) {
> -    DEBUG ((
> -      DEBUG_ERROR,
> -      "IPMI KCS response read Failed with Status(%r) for NetFunction(0x%x)," 
> \
> -      " Command(0x%x).\n",
> -      Status,
> -      NetFunction,
> -      Command
> -      ));
> +  //
> +  // Print out the response payloads.
> +  HelperManageabilityDebugPrint ((VOID *)&RspHeader,
> + (UINT16)RspHeaderSize, "KCS Response Header:\n");
> +
> +  if ((ResponseData != NULL) && (ResponseDataSize != NULL) &&
> (*ResponseDataSize != 0)) {
> +    Status = KcsTransportRead ((UINT8 *)ResponseData, ResponseDataSize);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "IPMI KCS response read Failed with Status(%r)",
> Status));
> +    }
> +
> +    //
> +    // Print out the response payloads.
> +    HelperManageabilityDebugPrint ((VOID *)ResponseData,
> + *ResponseDataSize, "KCS Response Data:\n");  } else {
> +    *ResponseDataSize = 0;
>    }
> 
>    return Status;
> diff --git
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/Mana
> geabilityTransportKcs.c
> b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/Mana
> geabilityTransportKcs.c
> index 7d85378fc1..c236354605 100644
> ---
> a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/Mana
> geabilityTransportKcs.c
> +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe
> +++ /ManageabilityTransportKcs.c
> @@ -218,23 +218,25 @@ KcsTransportTransmitReceive (
>    IN  MANAGEABILITY_TRANSFER_TOKEN   *TransferToken
>    )
>  {
> -  EFI_STATUS                           Status;
> -  MANAGEABILITY_IPMI_TRANSPORT_HEADER  *TransmitHeader;
> +  EFI_STATUS  Status;
> 
>    if ((TransportToken == NULL) || (TransferToken == NULL)) {
>      DEBUG ((DEBUG_ERROR, "%a: Invalid transport token or transfer token.\n",
> __FUNCTION__));
>      return;
>    }
> 
> -  TransmitHeader = (MANAGEABILITY_IPMI_TRANSPORT_HEADER
> *)TransferToken->TransmitHeader;
> -  if (TransmitHeader == NULL) {
> +  // Transmit header is necessary for KCS transport, which could be  //
> + NetFn, Command and etc.
> +  if (TransferToken->TransmitHeader == NULL) {
>      TransferToken->TransferStatus = EFI_INVALID_PARAMETER;
>      return;
>    }
> 
>    Status = KcsTransportSendCommand (
> -             TransmitHeader->NetFn,
> -             TransmitHeader->Command,
> +             TransferToken->TransmitHeader,
> +             TransferToken->TransmitHeaderSize,
> +             TransferToken->TransmitTrailer,
> +             TransferToken->TransmitTrailerSize,
>               TransferToken->TransmitPackage.TransmitPayload,
>               TransferToken->TransmitPackage.TransmitSizeInByte,
>               TransferToken->ReceivePackage.ReceiveBuffer,
> diff --git
> a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC
> ommon.c
> b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC
> ommon.c
> index 82bae58292..b055bad7da 100644
> ---
> a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC
> ommon.c
> +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtoc
> +++ olCommon.c
> @@ -65,21 +65,23 @@ SetupIpmiTransportHardwareInformation (
>    This functions setup the final header/body/trailer packets for
>    the acquired transport interface.
> 
> -  @param[in]         TransportToken  The transport interface.
> -  @param[in]         NetFunction     IPMI function.
> -  @param[in]         Command         IPMI command.
> -  @param[out]        PacketHeader    The pointer to receive header of 
> request.
> -  @param[in, out]    PacketBody      The request body.
> -                                     When IN, it is the caller's request 
> body.
> -                                     When OUT and NULL, the request body is 
> not
> -                                     changed.
> -                                     When OUT and non-NULL, the request body 
> is
> -                                     changed to conform the transport 
> interface.
> -  @param[in, out]    PacketBodySize  The request body size.
> -                                     When OUT and non-zero, it is the new 
> data
> -                                     length of request body.
> -                                     When OUT and zero, the request body is 
> unchanged.
> -  @param[out]        PacketTrailer   The pointer to receive trailer of 
> request.
> +  @param[in]         TransportToken     The transport interface.
> +  @param[in]         NetFunction        IPMI function.
> +  @param[in]         Command            IPMI command.
> +  @param[out]        PacketHeader       The pointer to receive header of 
> request.
> +  @param[out]        PacketHeaderSize   Pinter to receive packet header size 
> in
> byte.
> +  @param[in, out]    PacketBody         The request body.
> +                                        When IN, it is the caller's request 
> body.
> +                                        When OUT and NULL, the request body 
> is not
> +                                        changed.
> +                                        Whee out and non-NULL, the request 
> body is
> +                                        changed to comfort the transport 
> interface.
> +  @param[in, out]    PacketBodySize     The request body size.
> +                                        When IN and non-zero, it is the new 
> data
> +                                        length of request body.
> +                                        When IN and zero, the request body 
> is unchanged.
> +  @param[out]        PacketTrailer      The pointer to receive trailer of 
> request.
> +  @param[out]        PacketTrailerSize  Pinter to receive packet trailer 
> size in byte.
> 
>    @retval EFI_SUCCESS            Request packet is returned.
>    @retval EFI_UNSUPPORTED        Request packet is not returned because
> @@ -91,9 +93,11 @@ SetupIpmiRequestTransportPacket (
>    IN   UINT8                            NetFunction,
>    IN   UINT8                            Command,
>    OUT  MANAGEABILITY_TRANSPORT_HEADER   *PacketHeader OPTIONAL,
> +  OUT  UINT16                           *PacketHeaderSize,
>    IN OUT UINT8                          **PacketBody OPTIONAL,
>    IN OUT UINT32                         *PacketBodySize OPTIONAL,
> -  OUT  MANAGEABILITY_TRANSPORT_TRAILER  *PacketTrailer OPTIONAL
> +  OUT  MANAGEABILITY_TRANSPORT_TRAILER  *PacketTrailer OPTIONAL,
> +  OUT  UINT16                           *PacketTrailerSize
>    )
>  {
>    MANAGEABILITY_IPMI_TRANSPORT_HEADER  *IpmiHeader; @@ -105,18
> +109,24 @@ SetupIpmiRequestTransportPacket (
>        return EFI_OUT_OF_RESOURCES;
>      }
> 
> +    *PacketHeaderSize   = 0;
> +    *PacketTrailerSize  = 0;
>      IpmiHeader->Command = Command;
>      IpmiHeader->Lun     = 0;
>      IpmiHeader->NetFn   = NetFunction;
>      if (PacketHeader != NULL) {
> -      *PacketHeader = (MANAGEABILITY_TRANSPORT_HEADER *)IpmiHeader;
> +      *PacketHeader     = (MANAGEABILITY_TRANSPORT_HEADER *)IpmiHeader;
> +      *PacketHeaderSize = sizeof (MANAGEABILITY_IPMI_TRANSPORT_HEADER);
>      }
> +
>      if (PacketTrailer != NULL) {
>        *PacketTrailer = NULL;
>      }
> +
>      if (PacketBody != NULL) {
>        *PacketBody = NULL;
>      }
> +
>      if (PacketBodySize != NULL) {
>        *PacketBodySize = 0;
>      }
> @@ -124,6 +134,7 @@ SetupIpmiRequestTransportPacket (
>      DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.",
> __FUNCTION__));
>      ASSERT (FALSE);
>    }
> +
>    return EFI_SUCCESS;
>  }
> 
> @@ -164,6 +175,8 @@ CommonIpmiSubmitCommand (
>    MANAGEABILITY_TRANSPORT_HEADER             IpmiTransportHeader;
>    MANAGEABILITY_TRANSPORT_TRAILER            IpmiTransportTrailer;
>    MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS
> TransportAdditionalStatus;
> +  UINT16                                     HeaderSize;
> +  UINT16                                     TrailerSize;
> 
>    if (TransportToken == NULL) {
>      DEBUG ((DEBUG_ERROR, "%a: No transport toke for IPMI\n",
> __FUNCTION__)); @@ -179,8 +192,8 @@ CommonIpmiSubmitCommand (
>      return Status;
>    }
> 
> -  ThisRequestData       = RequestData;
> -  ThisRequestDataSize   = RequestDataSize;
> +  ThisRequestData      = RequestData;
> +  ThisRequestDataSize  = RequestDataSize;
>    IpmiTransportHeader  = NULL;
>    IpmiTransportTrailer = NULL;
>    Status               = SetupIpmiRequestTransportPacket (
> @@ -188,9 +201,11 @@ CommonIpmiSubmitCommand (
>                             NetFunction,
>                             Command,
>                             &IpmiTransportHeader,
> +                           &HeaderSize,
>                             &ThisRequestData,
>                             &ThisRequestDataSize,
> -                           &IpmiTransportTrailer
> +                           &IpmiTransportTrailer,
> +                           &TrailerSize
>                             );
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a: Fail to build packets - (%r)\n", __FUNCTION__,
> Status)); @@ -198,12 +213,13 @@ CommonIpmiSubmitCommand (
>    }
> 
>    ZeroMem (&TransferToken, sizeof (MANAGEABILITY_TRANSFER_TOKEN));
> -  TransferToken.TransmitHeader  = IpmiTransportHeader;
> -  TransferToken.TransmitTrailer = IpmiTransportTrailer;
> +  TransferToken.TransmitHeader      = IpmiTransportHeader;
> +  TransferToken.TransmitHeaderSize  = HeaderSize;
> +  TransferToken.TransmitTrailer     = IpmiTransportTrailer;
> +  TransferToken.TransmitTrailerSize = TrailerSize;
> 
>    // Transmit packet.
>    if ((ThisRequestData == NULL) || (ThisRequestDataSize == 0)) {
> -
>      // Transmit parameter were not changed by
> SetupIpmiRequestTransportPacket().
>      TransferToken.TransmitPackage.TransmitPayload    = RequestData;
>      TransferToken.TransmitPackage.TransmitSizeInByte = RequestDataSize; @@
> -247,5 +263,6 @@ CommonIpmiSubmitCommand (
>    if (ResponseDataSize != NULL) {
>      *ResponseDataSize = TransferToken.ReceivePackage.ReceiveSizeInByte;
>    }
> +
>    return Status;
>  }
> diff --git a/Features/ManageabilityPkg/Readme.md
> b/Features/ManageabilityPkg/Readme.md
> index 2ecee96313..81c9322b98 100644
> --- a/Features/ManageabilityPkg/Readme.md
> +++ b/Features/ManageabilityPkg/Readme.md
> @@ -99,7 +99,9 @@ library to compliant with the framework of
> ManageabilityPkg design.
>      struct _MANAGEABILITY_TRANSFER_TOKEN {
>        EFI_EVENT                                  ReceiveEvent;
>        MANAGEABILITY_TRANSPORT_HEADER             TransmitHeader;
> +      UINT16                                     TransmitHeaderSize;
>        MANAGEABILITY_TRANSPORT_TRAILER            TransmitTrailer;
> +      UINT16                                     TransmitTrailerSize;
>        MANAGEABILITY_TRANSMIT_PACKAGE             TransmitPackage;
>        MANAGEABILITY_RECEIVE_PACKAGE              ReceivePackage;
>        EFI_STATUS                                 TransferStatus;
> @@ -124,6 +126,10 @@ library to compliant with the framework of
> ManageabilityPkg design.
>      manageability transport library to make the transport implementation
> agnostic to the
>      manageability protocol specification.
> 
> +* ***TransmitHeaderSize***
> +
> +    This indicates the size of TransmitHeader.
> +
>  * ***TransmitTrailer***
> 
>      The transmit trailer may be different according to the disparate 
> transport
> @@ -131,6 +137,10 @@ library to compliant with the framework of
> ManageabilityPkg design.
>      manageability transport library to make the transport implementation
> agnostic to the
>      manageability protocol specification.
> 
> +* ***TransmitTrailerSize***
> +
> +    This indicates the size of TransmitTrailer.
> +
>  * ***TransmitPackage***
> 
>      The buffer of packet to transmit, this could be a value of NULL if the
> manageability
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103279): https://edk2.groups.io/g/devel/message/103279
Mute This Topic: https://groups.io/mt/98339113/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Reply via email to