From nobody Tue Nov 26 08:25:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56540+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56540+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425531; cv=none; d=zohomail.com; s=zohoarc; b=MFDnbSfDDAGyEv3GhlEdALQO66e6Ozwcx4nBTJga8k9j4OO1+GOgk/qTAniWUWwsKiVAgK65T3x4BpJFn0EbtQtKB9beBqnHvead+cRyrrIPKjtuAHR1+OJ0/vA31Zv1EgaC1DG+XaNfDgELjpCG0wv5TQei4drj2vtOiQP+fZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425531; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l5kR41eav7LYlPj58IoiPBJYq4PK5J07oXk+sDL3fjM=; b=AwprbZe8T/qJNAtHIGWDMSoiIlCOsOH25qTbCM48sZILX1hYwz7CmlgSDRARmycgrI8u8g0Fb0VNHcZIhuF4g4ZadhZgIQIIJ/7EWCYVeIZZUpvQfUGxB+F+SCsBd2BEJVFClVUH/MiAupzwJV9H/QhNpEC/dvmmaZKRaDr58l8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56540+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425531896282.7683697474622; Sat, 28 Mar 2020 12:58:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id L6wyYY1788612x3eNbLwlUEG; Sat, 28 Mar 2020 12:58:51 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web12.14051.1585425531011277631 for ; Sat, 28 Mar 2020 12:58:51 -0700 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJmQVY032604; Sat, 28 Mar 2020 19:58:50 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 301y7mhf8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:50 +0000 X-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJpwtp166287; Sat, 28 Mar 2020 19:58:50 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 301ups6h68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:50 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02SJwnnu024974; Sat, 28 Mar 2020 19:58:49 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:48 -0700 From: "Liran Alon" To: devel@edk2.groups.io, lersek@redhat.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org, Liran Alon Subject: [edk2-devel] [PATCH v3 07/17] OvmfPkg/PvScsiDxe: Translate Target & LUN to/from DevicePath Date: Sat, 28 Mar 2020 23:00:50 +0300 Message-Id: <20200328200100.60786-8-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: BACVgTUfnZh609zMyReSwOxKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425531; bh=PDt37W9F4sa8INLppiKKUVEZtL1ZDGCSVCy1ikHqbFU=; h=Cc:Date:From:Reply-To:Subject:To; b=w3P6bYIA3gb/ybEB5tIbxss33YgHa5MRmU7pFXNiK6f5fi9VR6POYNMr7yYZ1fpkmpb Io5aVdD1dObK1sKSfpJKaP5V+DQL927555PrRBUea+vn+QRneKXrgBKd/nYAMic8yhr4p j/R4iJJc7/0CbRjBfzhXvAEUwX2Eq8IUB6E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Implement EXT_SCSI_PASS_THRU.BuildDevicePath() and EXT_SCSI_PASS_THRU.GetTargetLun(). Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon --- OvmfPkg/PvScsiDxe/PvScsi.c | 61 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 7f51ada19a1a..76fc1eb910f2 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -137,7 +137,38 @@ PvScsiBuildDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ) { - return EFI_UNSUPPORTED; + UINT8 TargetValue; + PVSCSI_DEV *Dev; + SCSI_DEVICE_PATH *ScsiDevicePath; + + if (DevicePath =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // We only use first byte of target identifer + // + TargetValue =3D *Target; + + Dev =3D PVSCSI_FROM_PASS_THRU (This); + if (TargetValue > Dev->MaxTarget || Lun > Dev->MaxLun) { + return EFI_NOT_FOUND; + } + + ScsiDevicePath =3D AllocatePool (sizeof (*ScsiDevicePath)); + if (ScsiDevicePath =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ScsiDevicePath->Header.Type =3D MESSAGING_DEVICE_PATH; + ScsiDevicePath->Header.SubType =3D MSG_SCSI_DP; + ScsiDevicePath->Header.Length[0] =3D (UINT8)sizeof (*ScsiDevicePath); + ScsiDevicePath->Header.Length[1] =3D (UINT8)(sizeof (*ScsiDevicePath) >>= 8); + ScsiDevicePath->Pun =3D TargetValue; + ScsiDevicePath->Lun =3D (UINT16)Lun; + + *DevicePath =3D &ScsiDevicePath->Header; + return EFI_SUCCESS; } =20 STATIC @@ -150,7 +181,33 @@ PvScsiGetTargetLun ( OUT UINT64 *Lun ) { - return EFI_UNSUPPORTED; + SCSI_DEVICE_PATH *ScsiDevicePath; + PVSCSI_DEV *Dev; + + if (DevicePath =3D=3D NULL || Target =3D=3D NULL || *Target =3D=3D NULL = || Lun =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (DevicePath->Type !=3D MESSAGING_DEVICE_PATH || + DevicePath->SubType !=3D MSG_SCSI_DP) { + return EFI_UNSUPPORTED; + } + + ScsiDevicePath =3D (SCSI_DEVICE_PATH *)DevicePath; + Dev =3D PVSCSI_FROM_PASS_THRU (This); + if (ScsiDevicePath->Pun > Dev->MaxTarget || + ScsiDevicePath->Lun > Dev->MaxLun) { + return EFI_NOT_FOUND; + } + + // + // We only use first byte of target identifer + // + **Target =3D (UINT8)ScsiDevicePath->Pun; + ZeroMem (*Target + 1, TARGET_MAX_BYTES - 1); + *Lun =3D ScsiDevicePath->Lun; + + return EFI_SUCCESS; } =20 STATIC --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56540): https://edk2.groups.io/g/devel/message/56540 Mute This Topic: https://groups.io/mt/72617132/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-