X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIScsiDxe%2FComponentName.c;h=063b3722921ac9f630a706835fe573b43b343e70;hp=9194ab9c66f0ef61bf4fd8ad5cf9b1238fc461c2;hb=c615a4bc7310c5a01ef2b178452e45203d293ff7;hpb=f69bf3f5bd2abc84df707f4e0c25a14fa88dacff diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c b/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c index 9194ab9c66..063b372292 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/ComponentName.c @@ -1,8 +1,8 @@ /** @file UEFI Component Name(2) protocol implementation for iSCSI. -Copyright (c) 2004 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -37,6 +37,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIScsiDriverNameTable[] = {NULL, NULL} }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *mIScsiControllerNameTable = NULL; + /** Retrieves a Unicode string that is the user readable name of the EFI Driver. @@ -82,6 +84,77 @@ IScsiComponentNameGetDriverName ( ); } +/** + Update the component name for the iSCSI instance. + + @param[in] IScsiExtScsiPassThru A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance. + + @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. + @retval EFI_INVALID_PARAMETER The input parameter is invalid. + @retval EFI_UNSUPPORTED Can't get the corresponding NIC info from the Controller handle. + +**/ +EFI_STATUS +UpdateName ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru + ) +{ + EFI_STATUS Status; + CHAR16 HandleName[150]; + ISCSI_DRIVER_DATA *Private; + EFI_MAC_ADDRESS MacAddress; + UINTN HwAddressSize; + UINT16 VlanId; + CHAR16 MacString[70]; + + if (IScsiExtScsiPassThru == NULL) { + return EFI_INVALID_PARAMETER; + } + + Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (IScsiExtScsiPassThru); + + // + // Get the mac string, it's the name of various variable + // + Status = NetLibGetMacAddress (Private->Controller, &MacAddress, &HwAddressSize); + if (EFI_ERROR (Status)) { + return Status; + } + VlanId = NetLibGetVlanId (Private->Controller); + IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, MacString); + + UnicodeSPrint ( + HandleName, + sizeof (HandleName), + L"iSCSI IPv4 (MacString=%s)", + MacString + ); + + if (mIScsiControllerNameTable != NULL) { + FreeUnicodeStringTable (mIScsiControllerNameTable); + mIScsiControllerNameTable = NULL; + } + + Status = AddUnicodeString2 ( + "eng", + gIScsiComponentName.SupportedLanguages, + &mIScsiControllerNameTable, + HandleName, + TRUE + ); + if (EFI_ERROR (Status)) { + return Status; + } + + return AddUnicodeString2 ( + "en", + gIScsiComponentName2.SupportedLanguages, + &mIScsiControllerNameTable, + HandleName, + FALSE + ); +} + /** Retrieves a Unicode string that is the user readable name of the controller that is being managed by an EFI Driver.Currently not implemented. @@ -111,7 +184,7 @@ IScsiComponentNameGetDriverName ( @retval EFI_SUCCESS The Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. @retval EFI_INVALID_PARAMETER Language is NULL. @retval EFI_INVALID_PARAMETER ControllerName is NULL. @@ -131,5 +204,80 @@ IScsiComponentNameGetControllerName ( OUT CHAR16 **ControllerName ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + + EFI_HANDLE IScsiController; + ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier; + + EFI_EXT_SCSI_PASS_THRU_PROTOCOL *IScsiExtScsiPassThru; + + if (ControllerHandle == NULL) { + return EFI_UNSUPPORTED; + } + + // + // Get the handle of the controller we are controling. + // + IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid); + if (IScsiController == NULL) { + return EFI_UNSUPPORTED; + } + + Status = gBS->OpenProtocol ( + IScsiController, + &gEfiCallerIdGuid, + (VOID **)&IScsiIdentifier, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return Status; + } + + if (ChildHandle != NULL) { + // + // Make sure this driver produced ChildHandle + // + Status = EfiTestChildHandle ( + ControllerHandle, + ChildHandle, + &gEfiTcp4ProtocolGuid + ); + if (!EFI_ERROR (Status)) { + // + // Retrieve an instance of a produced protocol from ChildHandle + // + Status = gBS->OpenProtocol ( + ChildHandle, + &gEfiExtScsiPassThruProtocolGuid, + (VOID **)&IScsiExtScsiPassThru, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Update the component name for this child handle. + // + Status = UpdateName (IScsiExtScsiPassThru); + if (EFI_ERROR (Status)) { + return Status; + } + } else { + return Status; + } + } + + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + mIScsiControllerNameTable, + ControllerName, + (BOOLEAN)(This == &gIScsiComponentName) + ); } +