public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Nikita Leshenko <nikita.leshchenko@oracle.com>
To: edk2-devel@lists.01.org
Cc: liran.alon@oracle.com, Nikita Leshenko <nikita.leshchenko@oracle.com>
Subject: [PATCH 13/14] OvmfPkg/MptScsiDxe: Report multiple targets
Date: Thu, 31 Jan 2019 12:07:23 +0200	[thread overview]
Message-ID: <20190131100724.20907-14-nikita.leshchenko@oracle.com> (raw)
In-Reply-To: <20190131100724.20907-1-nikita.leshchenko@oracle.com>

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.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Aaron Young <aaron.young@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
---
 OvmfPkg/MptScsiDxe/MptScsi.c      | 27 ++++++++++++++++++++-------
 OvmfPkg/MptScsiDxe/MptScsiDxe.inf |  1 +
 OvmfPkg/OvmfPkg.dec               |  3 +++
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c
index a7dab0f71a..0b888a1c56 100644
--- a/OvmfPkg/MptScsiDxe/MptScsi.c
+++ b/OvmfPkg/MptScsiDxe/MptScsi.c
@@ -157,6 +157,7 @@ typedef struct {
   EFI_PCI_IO_PROTOCOL             *PciIo;
   UINT64                          OriginalPciAttributes;
   UINT32                          StallPerPollUsec;
+  UINT8                           MaxTarget;
   MPT_SCSI_IO_ERROR_REPLY         IoErrorReply;
   MPT_SCSI_REQUEST_WITH_SG        IoRequest;
 } MPT_SCSI_DEV;
@@ -245,6 +246,7 @@ MptScsiInit (
   EFI_STATUS Status;
 
   Dev->StallPerPollUsec = PcdGet32 (PcdMptScsiStallPerPollUsec);
+  Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit);
 
   Status = MptScsiReset (Dev);
   if (EFI_ERROR (Status)) {
@@ -254,7 +256,7 @@ MptScsiInit (
   MPT_IO_CONTROLLER_INIT_REQUEST Req = {
     .WhoInit = MPT_IOC_WHOINIT_ROM_BIOS,
     .Function = MPT_MESSAGE_HDR_FUNCTION_IOC_INIT,
-    .MaxDevices = 1,
+    .MaxDevices = Dev->MaxTarget + 1,
     .MaxBuses = 1,
     .ReplyFrameSize = sizeof (MPT_SCSI_IO_ERROR_REPLY),
   };
@@ -305,6 +307,7 @@ MptScsiInit (
 STATIC
 EFI_STATUS
 MptScsiPopulateRequest (
+  IN MPT_SCSI_DEV                                   *Dev,
   IN UINT8                                          Target,
   IN UINT64                                         Lun,
   IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
@@ -316,7 +319,7 @@ MptScsiPopulateRequest (
     return EFI_UNSUPPORTED;
   }
 
-  if (Target > 0 || Lun > 0) {
+  if (Target > Dev->MaxTarget || Lun > 0) {
     return EFI_INVALID_PARAMETER;
   }
 
@@ -504,7 +507,7 @@ MptScsiPassThru (
   //         Packet->DataDirection,
   //         Packet->InTransferLength, Packet->OutTransferLength));
 
-  Status = MptScsiPopulateRequest (*Target, Lun, Packet, &Dev->IoRequest);
+  Status = MptScsiPopulateRequest (Dev, *Target, Lun, Packet, &Dev->IoRequest);
   if (EFI_ERROR (Status)) {
     return Status;
   }
@@ -568,16 +571,22 @@ MptScsiGetNextTargetLun (
   IN OUT UINT64                                     *Lun
   )
 {
+  MPT_SCSI_DEV *Dev = MPT_SCSI_FROM_PASS_THRU (This);
+
   DEBUG ((EFI_D_INFO, "MptScsiGetNextTargetLun %d %d\n", **Target, *Lun));
 
-  // 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
@@ -588,15 +597,19 @@ MptScsiGetNextTarget (
   IN OUT UINT8                                     **Target
   )
 {
+  MPT_SCSI_DEV *Dev = MPT_SCSI_FROM_PASS_THRU (This);
+
   DEBUG ((EFI_D_INFO, "MptScsiGetNextTarget\n"));
 
-  // Currently support only target 0 LUN 0, so hardcode it
   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 5875d6c94b..3b6717c204 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 4ca98ff09f..3f088eca96 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -123,6 +123,9 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd|0x0|UINT32|0x1f
 
   gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiStallPerPollUsec|5|UINT32|0x28
+  ## Set the *inclusive* number of targets that MptScsi exposes for scan
+  #  by ScsiBusDxe.
+  gUefiOvmfPkgTokenSpaceGuid.PcdMptScsiMaxTargetLimit|7|UINT8|0x29
 
 [PcdsDynamic, PcdsDynamicEx]
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2
-- 
2.20.1



  parent reply	other threads:[~2019-01-31 10:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 10:07 OvmfPkg: Support booting from Fusion-MPT SCSI controllers Nikita Leshenko
2019-01-31 10:07 ` [PATCH 01/14] OvmfPkg/MptScsiDxe: Create empty driver Nikita Leshenko
2019-02-01  2:16   ` Bi, Dandan
2019-02-01 10:07     ` Laszlo Ersek
2019-02-01  9:57   ` Laszlo Ersek
2019-01-31 10:07 ` [PATCH 02/14] OvmfPkg/MptScsiDxe: Install DriverBinding Protocol Nikita Leshenko
2019-02-01 10:21   ` Laszlo Ersek
2019-01-31 10:07 ` [PATCH 03/14] OvmfPkg/MptScsiDxe: Report name of driver Nikita Leshenko
2019-02-01 10:25   ` Laszlo Ersek
2019-02-01 15:13     ` Carsey, Jaben
2019-01-31 10:07 ` [PATCH 04/14] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi Nikita Leshenko
2019-02-01 11:48   ` Laszlo Ersek
2019-01-31 10:07 ` [PATCH 05/14] OvmfPkg/MptScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Nikita Leshenko
2019-01-31 10:07 ` [PATCH 06/14] OvmfPkg/MptScsiDxe: Report one Target and one LUN Nikita Leshenko
2019-01-31 10:07 ` [PATCH 07/14] OvmfPkg/MptScsiDxe: Build DevicePath for discovered devices Nikita Leshenko
2019-01-31 10:07 ` [PATCH 08/14] OvmfPkg/MptScsiDxe: Implement GetTargetLun Nikita Leshenko
2019-01-31 10:07 ` [PATCH 09/14] OvmfPkg/MptScsiDxe: Open PciIo protocol for later use Nikita Leshenko
2019-01-31 10:07 ` [PATCH 10/14] OvmfPkg/MptScsiDxe: Set and restore PCI attributes Nikita Leshenko
2019-01-31 10:07 ` [PATCH 11/14] OvmfPkg/MptScsiDxe: Initialize hardware Nikita Leshenko
2019-02-01 12:14   ` Laszlo Ersek
2019-01-31 10:07 ` [PATCH 12/14] OvmfPkg/MptScsiDxe: Implement the PassThru method Nikita Leshenko
2019-02-01 12:55   ` Laszlo Ersek
2019-01-31 10:07 ` Nikita Leshenko [this message]
2019-01-31 10:07 ` [PATCH 14/14] OvmfPkg/MptScsiDxe: Support packets with pointers above 4G Nikita Leshenko
2019-02-01  9:48 ` OvmfPkg: Support booting from Fusion-MPT SCSI controllers Laszlo Ersek
2019-02-01 10:43 ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190131100724.20907-14-nikita.leshchenko@oracle.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox