From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.groups.io with SMTP id smtpd.web11.3884.1585050107234440235 for ; Tue, 24 Mar 2020 04:41:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YufOrdri; spf=pass (domain: redhat.com, ip: 63.128.21.74, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585050106; 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=gnHou0YBO9zdB84I865bspBIjNZvGRDSVQKESmigXW0=; b=YufOrdrim1DXj1Mo7kXejABJvGHkbzUcJLa+QKJbsOY2Yz7fp6rExhBrRW4o1Q/BRdTY4f ba+H9PrUMzj61iDnTqu4pIXvG+HiRCGAw187InZgX0JvmccOclZ0t8W0A9oFU/lUPcMZok abkc+iWY+HSiGnz8b3sm4bH1H/tbc04= 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-438-tPG6a5qFOyaow32k8C0gDQ-1; Tue, 24 Mar 2020 07:41:43 -0400 X-MC-Unique: tPG6a5qFOyaow32k8C0gDQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57F881937FD5; Tue, 24 Mar 2020 11:41:42 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-139.ams2.redhat.com [10.36.115.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97A2D60CD0; Tue, 24 Mar 2020 11:41:40 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 04/17] OvmfPkg/PvScsiDxe: Probe PCI devices and look for PvScsi To: devel@edk2.groups.io, liran.alon@oracle.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org References: <20200316150113.104630-1-liran.alon@oracle.com> <20200316150113.104630-5-liran.alon@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Tue, 24 Mar 2020 12:41:34 +0100 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: <20200316150113.104630-5-liran.alon@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 03/16/20 16:01, Liran Alon wrote: > PvScsiControllerSupported() is called on handles passed in > by the ConnectController() boot service and if the handle is the > PVSCSI controller, the function would return success. A success > return value will attach our driver to the device. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 > Reviewed-by: Nikita Leshenko > Signed-off-by: Liran Alon > --- > OvmfPkg/Include/IndustryStandard/PvScsi.h | 21 ++++++++++ > OvmfPkg/PvScsiDxe/PvScsi.c | 49 ++++++++++++++++++++++- > OvmfPkg/PvScsiDxe/PvScsi.inf | 5 +++ > 3 files changed, 74 insertions(+), 1 deletion(-) > create mode 100644 OvmfPkg/Include/IndustryStandard/PvScsi.h > > diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/IndustryStandard/PvScsi.h > new file mode 100644 > index 000000000000..004c0af84989 > --- /dev/null > +++ b/OvmfPkg/Include/IndustryStandard/PvScsi.h > @@ -0,0 +1,21 @@ > +/** @file > + > + VMware PVSCSI Device specific type and macro definitions. > + > + Copyright (C) 2020, Oracle and/or its affiliates. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef __PVSCSI_H_ > +#define __PVSCSI_H_ > + > +// > +// Device offsets and constants > +// > + > +#define PCI_VENDOR_ID_VMWARE (0x15ad) > +#define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0) > + > +#endif // __PVSCSI_H_ > diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c > index 0c81e645de08..f1fffe962233 100644 > --- a/OvmfPkg/PvScsiDxe/PvScsi.c > +++ b/OvmfPkg/PvScsiDxe/PvScsi.c > @@ -9,7 +9,11 @@ > > **/ > > +#include > +#include > +#include > #include > +#include > > // > // Higher versions will be used before lower, 0x10-0xffffffef is the version > @@ -30,7 +34,50 @@ PvScsiDriverBindingSupported ( > IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL > ) > { > - return EFI_UNSUPPORTED; > + EFI_STATUS Status; > + EFI_PCI_IO_PROTOCOL *PciIo; > + PCI_TYPE00 Pci; > + > + Status = gBS->OpenProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + (VOID **)&PciIo, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status = PciIo->Pci.Read ( > + PciIo, > + EfiPciIoWidthUint32, > + 0, > + sizeof(Pci) / sizeof(UINT32), (1) Please insert a space character before each opening parenthesis. > + &Pci > + ); > + if (EFI_ERROR (Status)) { > + goto Done; (2) Wrong indentation. > + } > + > + if ((Pci.Hdr.VendorId != PCI_VENDOR_ID_VMWARE) || > + (Pci.Hdr.DeviceId != PCI_DEVICE_ID_VMWARE_PVSCSI)) { > + Status = EFI_UNSUPPORTED; > + goto Done; (3) Wrong indentation. > + } > + > + Status = EFI_SUCCESS; > + > +Done: > + gBS->CloseProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + ControllerHandle > + ); > + > + return Status; > } > > STATIC > diff --git a/OvmfPkg/PvScsiDxe/PvScsi.inf b/OvmfPkg/PvScsiDxe/PvScsi.inf > index d1d0e963f96d..c1f0663832ed 100644 > --- a/OvmfPkg/PvScsiDxe/PvScsi.inf > +++ b/OvmfPkg/PvScsiDxe/PvScsi.inf > @@ -22,7 +22,12 @@ > > [Packages] > MdePkg/MdePkg.dec > + OvmfPkg/OvmfPkg.dec > > [LibraryClasses] > + UefiBootServicesTableLib > UefiDriverEntryPoint > UefiLib > + > +[Protocols] > + gEfiPciIoProtocolGuid ## TO_START > With (1) through (3) addressed: Reviewed-by: Laszlo Ersek Thanks Laszlo