From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web10.1067.1588167878785676969 for ; Wed, 29 Apr 2020 06:44:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bsng81/E; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588167878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q4yELJk9VMK6YFyi1jlfeiJ0rgkGs8O/nlnr43jIPo0=; b=bsng81/EYEhW4xx/q/c2JUIIgy2h4DsLInSzdGTHEPWSgnnyXZLVOx/GGhXo2MXnveW5YO 9l3DcII6Hy6zkj7nutT9SFOnNIHIkI04WkwPVv+9C9HnnAO9jCHLEJa8nGxieww9iE6eXF 2Tfe0gfRcguLonb3LxVIY8jRV4F8x/A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-2LQ8nzY6MYqm4BI1VSgF_Q-1; Wed, 29 Apr 2020 09:44:36 -0400 X-MC-Unique: 2LQ8nzY6MYqm4BI1VSgF_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A31F318FF662; Wed, 29 Apr 2020 13:44:34 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-1.ams2.redhat.com [10.36.114.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51C6B5D9F5; Wed, 29 Apr 2020 13:44:33 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v5 07/12] OvmfPkg/MptScsiDxe: Build and decode DevicePath To: devel@edk2.groups.io, nikita.leshchenko@oracle.com Cc: liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Ard Biesheuvel References: <20200424175927.41210-1-nikita.leshchenko@oracle.com> <20200424175927.41210-8-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: <9fb20e4c-0f8d-6d4b-bf1c-da05bcdb9f48@redhat.com> Date: Wed, 29 Apr 2020 15:44:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200424175927.41210-8-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 04/24/20 19:59, Nikita Leshenko wrote: > Used to identify the individual disks in the hardware tree. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 > Signed-off-by: Nikita Leshenko > Reviewed-by: Liran Alon > Reviewed-by: Laszlo Ersek > --- > OvmfPkg/MptScsiDxe/MptScsi.c | 61 ++++++++++++++++++++++++++++++++++-- > 1 file changed, 59 insertions(+), 2 deletions(-) The updates look good, my R-b stands. Thanks Laszlo > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 5e0544c8d9d2..dc4b854659f9 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -146,7 +146,36 @@ MptScsiBuildDevicePath ( > IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath > ) > { > - return EFI_UNSUPPORTED; > + MPT_SCSI_DEV *Dev; > + SCSI_DEVICE_PATH *ScsiDevicePath; > + > + if (DevicePath == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // This device support 256 targets only, so it's enough to dereference > + // the LSB of Target. > + // > + Dev = MPT_SCSI_FROM_PASS_THRU (This); > + if (*Target > Dev->MaxTarget || Lun > 0) { > + return EFI_NOT_FOUND; > + } > + > + ScsiDevicePath = AllocateZeroPool (sizeof (*ScsiDevicePath)); > + if (ScsiDevicePath == NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + ScsiDevicePath->Header.Type = MESSAGING_DEVICE_PATH; > + ScsiDevicePath->Header.SubType = MSG_SCSI_DP; > + ScsiDevicePath->Header.Length[0] = (UINT8)sizeof (*ScsiDevicePath); > + ScsiDevicePath->Header.Length[1] = (UINT8)(sizeof (*ScsiDevicePath) >> 8); > + ScsiDevicePath->Pun = *Target; > + ScsiDevicePath->Lun = (UINT16)Lun; > + > + *DevicePath = &ScsiDevicePath->Header; > + return EFI_SUCCESS; > } > > STATIC > @@ -159,7 +188,35 @@ MptScsiGetTargetLun ( > OUT UINT64 *Lun > ) > { > - return EFI_UNSUPPORTED; > + MPT_SCSI_DEV *Dev; > + 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; > + } > + > + Dev = MPT_SCSI_FROM_PASS_THRU (This); > + ScsiDevicePath = (SCSI_DEVICE_PATH *)DevicePath; > + if (ScsiDevicePath->Pun > Dev->MaxTarget || > + ScsiDevicePath->Lun > 0) { > + return EFI_NOT_FOUND; > + } > + > + ZeroMem (*Target, TARGET_MAX_BYTES); > + // > + // 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 >