From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.10859.1582735250320718313 for ; Wed, 26 Feb 2020 08:40:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Tprb2iU9; spf=pass (domain: oracle.com, ip: 156.151.31.86, mailfrom: nikita.leshchenko@oracle.com) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01QGNVto078498; Wed, 26 Feb 2020 16:40:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=yRMvDzYcXT2aJ1L5z3tNY3F9MJP4AAvD06wZYTlwLOY=; b=Tprb2iU94ywlXiCcsaUcSPvBt63uz30/YXDR/h86PakoA3DnJtDs6egNbigJ0q7FkGSV MdOw8PhtKcuzH763BwDws4Y8O6nqu/PrU7ioMWsqCcHwYCKIETSHfuOx40/0IJzBLLdL wfj1f3EkvWLWRJMy53if8f+NeEJcJIHoajQM6W9QvnJE7ieNDjA1rmFiMdEMmKCv9+Wu 2O9qoP/Fk9GJQLfx27Eire+Fk2E/jRBM9FpaUmhd725cNVtGejGxnACzrG9Y/m6zmbU3 AQ2C8610RpNCs3NSDTyg8JdmqEfUrJGy5UOpxr2TumrUm2uHZQK1hrvcwtDMy5Q9JoB+ lA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2ydcsncvwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2020 16:40:49 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01QGMvvB077151; Wed, 26 Feb 2020 16:40:49 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2ydcsa6qf3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2020 16:40:49 +0000 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 01QGemcb010750; Wed, 26 Feb 2020 16:40:48 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Feb 2020 08:40:48 -0800 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: liran.alon@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, lersek@redhat.com, ard.biesheuvel@linaro.org, Nikita Leshenko Subject: [PATCH v2 13/13] OvmfPkg/MptScsiDxe: Report multiple targets Date: Wed, 26 Feb 2020 18:41:51 +0200 Message-Id: <20200226164151.125182-14-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200226164151.125182-1-nikita.leshchenko@oracle.com> References: <20200226164151.125182-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9543 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002260112 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9543 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002260112 Content-Transfer-Encoding: 8bit The controller supports up to 8 targets (Not reported by the controller, but based on the implementation of the virtual device), report them in GetNextTarget and GetNextTargetLun. The firmware will then try to communicate with them and create a block device for each one that responds. Support for multiple LUNs will be implemented in another series. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Nikita Leshenko Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Aaron Young Reviewed-by: Liran Alon --- OvmfPkg/MptScsiDxe/MptScsi.c | 26 ++++++++++++++++++-------- OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 1 + OvmfPkg/OvmfPkg.dec | 4 ++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 6c70112bbc..b7f5ea1b8a 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -51,6 +51,7 @@ typedef struct { EFI_PCI_IO_PROTOCOL *PciIo; UINT64 OriginalPciAttributes; UINT32 StallPerPollUsec; + UINT8 MaxTarget; MPT_SCSI_DMA_BUFFER *Dma; EFI_PHYSICAL_ADDRESS DmaPhysical; VOID *DmaMapping; @@ -163,6 +164,7 @@ MptScsiInit ( UINT32 Reply32; Dev->StallPerPollUsec = PcdGet32 (PcdMptScsiStallPerPollUsec); + Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit); Status = MptScsiReset (Dev); if (EFI_ERROR (Status)) { @@ -173,7 +175,7 @@ MptScsiInit ( ZeroMem (&Reply, sizeof (Reply)); Req.Data.WhoInit = MPT_IOC_WHOINIT_ROM_BIOS; Req.Data.Function = MPT_MESSAGE_HDR_FUNCTION_IOC_INIT; - Req.Data.MaxDevices = 1; + Req.Data.MaxDevices = Dev->MaxTarget + 1; Req.Data.MaxBuses = 1; Req.Data.ReplyFrameSize = sizeof (MPT_SCSI_IO_ERROR_REPLY); @@ -252,7 +254,7 @@ MptScsiPopulateRequest ( return EFI_UNSUPPORTED; } - if (Target > 0 || Lun > 0) { + if (Target > Dev->MaxTarget || Lun > 0) { return EFI_INVALID_PARAMETER; } @@ -523,16 +525,22 @@ MptScsiGetNextTargetLun ( IN OUT UINT64 *Lun ) { + MPT_SCSI_DEV *Dev = MPT_SCSI_FROM_PASS_THRU (This); + // - // Currently support only target 0 LUN 0, so hardcode it + // Currently support only LUN 0, so hardcode it // if (!IsTargetInitialized (*Target)) { **Target = 0; *Lun = 0; - return EFI_SUCCESS; + } else if (**Target < Dev->MaxTarget) { + **Target += 1; + *Lun = 0; } else { return EFI_NOT_FOUND; } + + return EFI_SUCCESS; } STATIC @@ -543,15 +551,17 @@ MptScsiGetNextTarget ( IN OUT UINT8 **Target ) { - // - // Currently support only target 0 LUN 0, so hardcode it - // + MPT_SCSI_DEV *Dev = MPT_SCSI_FROM_PASS_THRU (This); + if (!IsTargetInitialized (*Target)) { **Target = 0; - return EFI_SUCCESS; + } else if (**Target < Dev->MaxTarget) { + **Target += 1; } else { return EFI_NOT_FOUND; } + + return EFI_SUCCESS; } STATIC diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf index 9b090921b6..8453c73e60 100644 --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf @@ -43,3 +43,4 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiStallPerPollUsec ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiMaxTargetLimit ## CONSUMES diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 7e8097f995..1e17df0316 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -231,6 +231,10 @@ ## Microseconds to stall between polling for MptScsi request result gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiStallPerPollUsec|5|UINT32|0x36 + ## Set the *inclusive* number of targets that MptScsi exposes for scan + # by ScsiBusDxe. + gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiMaxTargetLimit|7|UINT8|0x37 + [PcdsDynamic, PcdsDynamicEx] gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 -- 2.20.1