From nobody Tue Feb 10 15:45:29 2026 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+58091+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+58091+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1587751111; cv=none; d=zohomail.com; s=zohoarc; b=PhpYG80Ur18TKRP4rDxMHVyzoMrkNwQsk7k/tXndTvnREaEE9IxKTAPR+02hqTKM1qma/DiF2UVmdpri2quZmZQYSjVpVZor3MSgSmCqXXSTU4crdALguGZe2r/fknZ8ZPtoPbgRlq8rZIf6URO8Aj0Nx49ZCnj9KwI7Q4edwRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587751111; 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=IE97OrdcxFL/pcJyoDYsxhyr3lFgnjrhcXuTAP6vy+U=; b=kxFeEfw9Md0cMqyfF898HYq9NH5bXYvvCGZdbwKnWDJ+uLFl2dsLziadR2W6Qo+6Wj4KTLcP58EMVh6eD6l/0S+bklJ4czZfjzG5SjH2ANWMH+BvLMrKflpgiA9POzbCwA3gN5pZfwcMfgxVNwE5pOo6KVc6+lk0qD3QWuoM+zo= 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+58091+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 158775111132146.001956626964216; Fri, 24 Apr 2020 10:58:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id uxIxYY1788612x0Cx6zXQtTi; Fri, 24 Apr 2020 10:58:30 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.2056.1587751110418948418 for ; Fri, 24 Apr 2020 10:58:30 -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 03OHr2iA032957; Fri, 24 Apr 2020 17:58:27 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 30k7qe87xw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:58:27 +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 03OHmPmL126824; Fri, 24 Apr 2020 17:56:27 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 30gb1q7pke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:56:27 +0000 X-Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03OHuQI5007807; Fri, 24 Apr 2020 17:56:26 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Apr 2020 10:56:25 -0700 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [edk2-devel] [PATCH v5 07/12] OvmfPkg/MptScsiDxe: Build and decode DevicePath Date: Fri, 24 Apr 2020 20:59:22 +0300 Message-Id: <20200424175927.41210-8-nikita.leshchenko@oracle.com> In-Reply-To: <20200424175927.41210-1-nikita.leshchenko@oracle.com> References: <20200424175927.41210-1-nikita.leshchenko@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,nikita.leshchenko@oracle.com X-Gm-Message-State: ELdD7MGOnmtDRdDFjZrvSXJWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1587751111; bh=2mY7e2bPO0cyqGHYZApSc/hprnV2MNqN0fAEdbKf9pE=; h=Cc:Date:From:Reply-To:Subject:To; b=Ogl6ByFc1BsJKDts91SSdluU3By8Zwsk/1K16/MboUt9+oqZjAlqu7g6VCN50gH/Q9I Toa8k9jU0vERKEwBgwxHKvN3vlvVDZyXlzYGeYOjcAtzTi785s7AzbEn2rr40t2WME1Hz YRZVBDt/NdzVlCnfms2pYtS66iC1CmZzH4c= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Used to identify the individual disks in the hardware tree. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2390 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(-) 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // This device support 256 targets only, so it's enough to dereference + // the LSB of Target. + // + Dev =3D MPT_SCSI_FROM_PASS_THRU (This); + if (*Target > Dev->MaxTarget || Lun > 0) { + return EFI_NOT_FOUND; + } + + ScsiDevicePath =3D AllocateZeroPool (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 *Target; + ScsiDevicePath->Lun =3D (UINT16)Lun; + + *DevicePath =3D &ScsiDevicePath->Header; + return EFI_SUCCESS; } =20 STATIC @@ -159,7 +188,35 @@ MptScsiGetTargetLun ( OUT UINT64 *Lun ) { - return EFI_UNSUPPORTED; + MPT_SCSI_DEV *Dev; + SCSI_DEVICE_PATH *ScsiDevicePath; + + 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; + } + + Dev =3D MPT_SCSI_FROM_PASS_THRU (This); + ScsiDevicePath =3D (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 =3D (UINT8)ScsiDevicePath->Pun; + *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 (#58091): https://edk2.groups.io/g/devel/message/58091 Mute This Topic: https://groups.io/mt/73247326/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-