[edk2-devel] [PATCH v3 08/13] OvmfPkg/MptScsiDxe: Implement GetTargetLun

Liran Alon liran.alon at oracle.com
Wed Mar 4 23:51:05 UTC 2020


On 04/03/2020 21:22, Nikita Leshenko wrote:
> Currently we accept only Pun=0 and Lun=0, but we will relax this in a
> later patch.
>
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390
> Signed-off-by: Nikita Leshenko <nikita.leshchenko at oracle.com>
> ---
>   OvmfPkg/MptScsiDxe/MptScsi.c | 28 +++++++++++++++++++++++++++-
>   1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c
> index cba564b5f648..a77599dd4b27 100644
> --- a/OvmfPkg/MptScsiDxe/MptScsi.c
> +++ b/OvmfPkg/MptScsiDxe/MptScsi.c
> @@ -169,7 +169,33 @@ MptScsiGetTargetLun (
>     OUT UINT64                                       *Lun
>     )
>   {
> -  return EFI_UNSUPPORTED;
> +  SCSI_DEVICE_PATH *ScsiDevicePath;
> +
> +  if (DevicePath == NULL ||
> +      Target == NULL || *Target == NULL || Lun == NULL) {
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if (DevicePath->Type    != MESSAGING_DEVICE_PATH ||
> +      DevicePath->SubType != MSG_SCSI_DP) {
> +    return EFI_UNSUPPORTED;
> +  }
> +
> +  ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath;
> +  if (ScsiDevicePath->Pun > 0 ||
> +      ScsiDevicePath->Lun > 0) {
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  ZeroMem (*Target, TARGET_MAX_BYTES);

Why do you need to ZeroMem() if you only use the first byte of Target? 
Seems redundant.

In addition, I suggest squashing this patch with the previous one as 
GetTargetLun() and BuildDevicePath() kinda complement each other.

Reviewed-by: Liran Alon <liran.alon at oracle.com>

> +  //
> +  // This device support 256 targets only, so it's enough to set the LSB
> +  // of Target.
> +  //
> +  **Target = (UINT8)ScsiDevicePath->Pun;
> +  *Lun = ScsiDevicePath->Lun;
> +
> +  return EFI_SUCCESS;
>   }
>   
>   STATIC

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#55509): https://edk2.groups.io/g/devel/message/55509
Mute This Topic: https://groups.io/mt/71733501/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list