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.web12.12704.1586952232730798718 for ; Wed, 15 Apr 2020 05:03:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dxl7XiHj; 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=1586952231; 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=z9VHrkRcJJHBZkz4kf+J/fTjBNtR9ENuosQkr+9+DoU=; b=dxl7XiHjrm17hoynWBObIL+nRpKp3o509bc0xrJ8J5mbP706Q3h/4EDdeHscyY1maSCVE2 5CzogNzHfC8tfXCdjb9QOI4nj7LmX0ds93bJaJovUQQ44MAcTzhZC2aagaEwZxlRph/pYL Cwt+4UhjnILmMHAxKBzMXl4LCgq/1QE= 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-356-MdtsVVOeOgG2DF21uYX14g-1; Wed, 15 Apr 2020 08:03:46 -0400 X-MC-Unique: MdtsVVOeOgG2DF21uYX14g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 005AA107ACCC; Wed, 15 Apr 2020 12:03:45 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-155.ams2.redhat.com [10.36.112.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 409A9C0DB9; Wed, 15 Apr 2020 12:03:43 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v4 07/13] 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: <20200414173813.7715-1-nikita.leshchenko@oracle.com> <20200414173813.7715-8-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: <02085bc2-93cf-f2af-67b6-7dec9762436c@redhat.com> Date: Wed, 15 Apr 2020 14:03:42 +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: <20200414173813.7715-8-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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/14/20 19:38, Nikita Leshenko wrote: > Used to identify the individual disks in the hardware tree. > > 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 > Reviewed-by: Liran Alon > --- > OvmfPkg/MptScsiDxe/MptScsi.c | 57 ++++++++++++++++++++++++++++++++++-- > 1 file changed, 55 insertions(+), 2 deletions(-) > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 30fb084379db..69ab947c0da2 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -126,7 +126,34 @@ MptScsiBuildDevicePath ( > IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath > ) > { > - return EFI_UNSUPPORTED; > + 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. > + // > + if (*Target > 0 || 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 > @@ -139,7 +166,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); > + // > + // 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 > Reviewed-by: Laszlo Ersek