From: Abner Chang <abner.ch...@amd.com> Update GetTransportCapability to support Maximum Transfer Unit (MTU) of transport interface.
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 | 31 ++++++++++++++----- .../Common/ManageabilityTransportKcs.h | 2 ++ .../IpmiProtocol/Pei/IpmiPpiInternal.h | 8 +++-- .../BaseManageabilityTransportNull.c | 18 +++++++---- .../Dxe/ManageabilityTransportKcs.c | 25 +++++++++------ .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c | 20 +++++++++--- .../Universal/IpmiProtocol/Pei/IpmiPpi.c | 15 +++++++-- .../Universal/IpmiProtocol/Smm/IpmiProtocol.c | 21 ++++++++++--- 8 files changed, 103 insertions(+), 37 deletions(-) diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h index c022b4ac5c..ad6cd1a464 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h @@ -14,6 +14,9 @@ #define MANAGEABILITY_TRANSPORT_TOKEN_VERSION ((MANAGEABILITY_TRANSPORT_TOKEN_VERSION_MAJOR << 8) |\ MANAGEABILITY_TRANSPORT_TOKEN_VERSION_MINOR) +#define MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(a) (1 << ((a & MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_MASK) >>\ + MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_BIT_POSITION)) + typedef struct _MANAGEABILITY_TRANSPORT_FUNCTION_V1_0 MANAGEABILITY_TRANSPORT_FUNCTION_V1_0; typedef struct _MANAGEABILITY_TRANSPORT MANAGEABILITY_TRANSPORT; typedef struct _MANAGEABILITY_TRANSPORT_TOKEN MANAGEABILITY_TRANSPORT_TOKEN; @@ -68,8 +71,17 @@ typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS; /// Additional transport interface features. /// typedef UINT32 MANAGEABILITY_TRANSPORT_CAPABILITY; +/// Bit 0 #define MANAGEABILITY_TRANSPORT_CAPABILITY_MULTIPLE_TRANSFER_TOKENS 0x00000001 +/// Bit 1 #define MANAGEABILITY_TRANSPORT_CAPABILITY_ASYNCHRONOUS_TRANSFER 0x00000002 +/// Bit 2 - Reserved +/// Bit 7:3 - Transport interface maximum payload size, which is (2 ^ bit[7:3] - 1) +/// bit[7:3] means no maximum payload. +#define MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_MASK 0x000000f8 +#define MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_BIT_POSITION 3 + #define MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE 0x00 +/// Bit 8:31 - Reserved /// /// Definitions of Manageability transport interface functions. @@ -187,15 +199,20 @@ AcquireTransportSession ( ); /** - This function returns the transport capabilities. - - @param [out] TransportFeature Pointer to receive transport capabilities. - See the definitions of - MANAGEABILITY_TRANSPORT_CAPABILITY. - + This function returns the transport capabilities according to + the manageability protocol. + + @param [in] TransportToken Transport token acquired from manageability + transport library. + @param [out] TransportFeature Pointer to receive transport capabilities. + See the definitions of + MANAGEABILITY_TRANSPORT_CAPABILITY. + @retval EFI_SUCCESS TransportCapability is returned successfully. + @retval EFI_INVALID_PARAMETER TransportToken is not a valid token. **/ -VOID +EFI_STATUS GetTransportCapability ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, OUT MANAGEABILITY_TRANSPORT_CAPABILITY *TransportCapability ); diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h index f1758ffd8f..2cdf60ba7e 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h @@ -32,6 +32,8 @@ typedef struct { #define IPMI_KCS_GET_STATE(s) (s >> 6) #define IPMI_KCS_SET_STATE(s) (s << 6) +#define MCTP_KCS_MTU_IN_POWER_OF_2 8 + /// 5 sec, according to IPMI spec #define IPMI_KCS_TIMEOUT_5_SEC 5000*1000 #define IPMI_KCS_TIMEOUT_1MS 1000 diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h index bbe0c8c5cb..7b6ab0f529 100644 --- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h @@ -17,9 +17,11 @@ #define MANAGEABILITY_IPMI_PPI_INTERNAL_FROM_LINK(a) CR (a, PEI_IPMI_PPI_INTERNAL, PeiIpmiPpi, MANAGEABILITY_IPMI_PPI_INTERNAL_SIGNATURE) typedef struct { - UINT32 Signature; - MANAGEABILITY_TRANSPORT_TOKEN *TransportToken; - PEI_IPMI_PPI PeiIpmiPpi; + UINT32 Signature; + MANAGEABILITY_TRANSPORT_TOKEN *TransportToken; + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; + UINT32 TransportMaximumPayload; + PEI_IPMI_PPI PeiIpmiPpi; } PEI_IPMI_PPI_INTERNAL; #endif // MANAGEABILITY_IPMI_PPI_INTERNAL_H_ diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c b/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c index 49fc8c0f71..3aa68578a6 100644 --- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c @@ -31,19 +31,25 @@ AcquireTransportSession ( } /** - This function returns the transport capabilities. - - @param [out] TransportFeature Pointer to receive transport capabilities. - See the definitions of - MANAGEABILITY_TRANSPORT_CAPABILITY. + This function returns the transport capabilities according to + the manageability protocol. + @param [in] TransportToken Transport token acquired from manageability + transport library. + @param [out] TransportFeature Pointer to receive transport capabilities. + See the definitions of + MANAGEABILITY_TRANSPORT_CAPABILITY. + @retval EFI_SUCCESS TransportCapability is returned successfully. + @retval EFI_INVALID_PARAMETER TransportToken is not a valid token. **/ -VOID +EFI_STATUS GetTransportCapability ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, OUT MANAGEABILITY_TRANSPORT_CAPABILITY *TransportCapability ) { *TransportCapability = 0; + return EFI_SUCCESS; } /** diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c index ab416e5449..25d6e49886 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c @@ -329,21 +329,28 @@ AcquireTransportSession ( } /** - This function returns the transport capabilities. - - @param [out] TransportFeature Pointer to receive transport capabilities. - See the definitions of - MANAGEABILITY_TRANSPORT_CAPABILITY. - + This function returns the transport capabilities according to + the manageability protocol. + + @param [in] TransportToken Transport token acquired from manageability + transport library. + @param [out] TransportFeature Pointer to receive transport capabilities. + See the definitions of + MANAGEABILITY_TRANSPORT_CAPABILITY. + @retval EFI_SUCCESS TransportCapability is returned successfully. + @retval EFI_INVALID_PARAMETER TransportToken is not a valid token. **/ -VOID +EFI_STATUS GetTransportCapability ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, OUT MANAGEABILITY_TRANSPORT_CAPABILITY *TransportCapability ) { - if (TransportCapability != NULL) { - *TransportCapability = 0; + if (TransportToken == NULL || TransportCapability == NULL) { + return EFI_INVALID_PARAMETER; } + *TransportCapability = 0; + return EFI_SUCCESS; } /** diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c index 05175ee448..c30132419d 100644 --- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c @@ -17,9 +17,9 @@ #include "IpmiProtocolCommon.h" -MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken = NULL; -CHAR16 *mTransportName; - +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken = NULL; +CHAR16 *mTransportName; +UINT32 TransportMaximumPayload; MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; /** @@ -92,8 +92,6 @@ DxeIpmiEntry ( MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; - GetTransportCapability (&TransportCapability); - Status = HelperAcquireManageabilityTransport ( &gManageabilityProtocolIpmiGuid, &mTransportToken @@ -102,6 +100,18 @@ DxeIpmiEntry ( DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IPMI protocol - %r\n", __FUNCTION__, Status)); return Status; } + Status = GetTransportCapability (mTransportToken, &TransportCapability); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", __FUNCTION__)); + return Status; + } + TransportMaximumPayload = MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(TransportCapability); + if (TransportMaximumPayload == (1 << MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE)) { + DEBUG ((DEBUG_INFO, "%a: Transport interface maximum payload is undefined.\n", __FUNCTION__)); + } else { + TransportMaximumPayload -= 1; + DEBUG ((DEBUG_INFO, "%a: Transport interface for IPMI protocol has maximum payload %x.\n", __FUNCTION__, TransportMaximumPayload)); + } mTransportName = HelperManageabilitySpecName (mTransportToken->Transport->ManageabilityTransportSpecification); DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTransportName)); diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c index f839cd7387..0dda6d2d47 100644 --- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c @@ -87,7 +87,6 @@ PeiIpmiEntry ( CHAR16 *TransportName; PEI_IPMI_PPI_INTERNAL *PeiIpmiPpiinternal; EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; - MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION HardwareInformation; @@ -109,7 +108,6 @@ PeiIpmiEntry ( PpiDescriptor->Guid = &gPeiIpmiPpiGuid; PpiDescriptor->Ppi = &PeiIpmiPpiinternal->PeiIpmiPpi; - GetTransportCapability (&TransportCapability); Status = HelperAcquireManageabilityTransport ( &gManageabilityProtocolIpmiGuid, &PeiIpmiPpiinternal->TransportToken @@ -118,6 +116,19 @@ PeiIpmiEntry ( DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IPMI protocol - %r\n", __FUNCTION__, Status)); return Status; } + Status = GetTransportCapability (PeiIpmiPpiinternal->TransportToken, &PeiIpmiPpiinternal->TransportCapability); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", __FUNCTION__)); + return Status; + } + + PeiIpmiPpiinternal->TransportMaximumPayload = MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(PeiIpmiPpiinternal->TransportCapability); + if (PeiIpmiPpiinternal->TransportMaximumPayload == (1 << MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE)) { + DEBUG((DEBUG_INFO, "%a: Transport interface maximum payload is undefined.\n", __FUNCTION__)); + } else { + PeiIpmiPpiinternal->TransportMaximumPayload -= 1; + DEBUG((DEBUG_INFO, "%a: Transport interface for IPMI protocol has maximum payload 0x%x.\n", __FUNCTION__, PeiIpmiPpiinternal->TransportMaximumPayload)); + } TransportName = HelperManageabilitySpecName (PeiIpmiPpiinternal->TransportToken->Transport->ManageabilityTransportSpecification); DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, TransportName)); diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c index 87a5436bdf..86dee2fa24 100644 --- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c @@ -18,9 +18,9 @@ #include "IpmiProtocolCommon.h" -MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken = NULL; -CHAR16 *mTransportName; - +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken = NULL; +CHAR16 *mTransportName; +UINT32 TransportMaximumPayload; MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION mHardwareInformation; /** @@ -93,8 +93,6 @@ SmmIpmiEntry ( MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; - GetTransportCapability (&TransportCapability); - Status = HelperAcquireManageabilityTransport ( &gManageabilityProtocolIpmiGuid, &mTransportToken @@ -104,6 +102,19 @@ SmmIpmiEntry ( return Status; } + Status = GetTransportCapability (mTransportToken, &TransportCapability); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", __FUNCTION__)); + return Status; + } + TransportMaximumPayload = MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(TransportCapability); + if (TransportMaximumPayload == (1 << MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE)) { + DEBUG((DEBUG_INFO, "%a: Transport interface maximum payload is undefined.\n", __FUNCTION__)); + } else { + TransportMaximumPayload -= 1; + DEBUG((DEBUG_INFO, "%a: Transport interface for IPMI protocol has maximum payload 0x%x.\n", __FUNCTION__, TransportMaximumPayload)); + } + mTransportName = HelperManageabilitySpecName (mTransportToken->Transport->ManageabilityTransportSpecification); DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTransportName)); -- 2.37.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102416): https://edk2.groups.io/g/devel/message/102416 Mute This Topic: https://groups.io/mt/98037366/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-