2022-04-05 00:38:34

by Matthew Rosato

[permalink] [raw]
Subject: [PATCH v5 17/21] vfio-pci/zdev: add function handle to clp base capability

The function handle is a system-wide unique identifier for a zPCI
device. It is used as input for various zPCI operations.

Signed-off-by: Matthew Rosato <[email protected]>
---
drivers/vfio/pci/vfio_pci_zdev.c | 5 +++--
include/uapi/linux/vfio_zdev.h | 3 +++
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c
index ea4c0d2b0663..4a653ce480c7 100644
--- a/drivers/vfio/pci/vfio_pci_zdev.c
+++ b/drivers/vfio/pci/vfio_pci_zdev.c
@@ -23,14 +23,15 @@ static int zpci_base_cap(struct zpci_dev *zdev, struct vfio_info_cap *caps)
{
struct vfio_device_info_cap_zpci_base cap = {
.header.id = VFIO_DEVICE_INFO_CAP_ZPCI_BASE,
- .header.version = 1,
+ .header.version = 2,
.start_dma = zdev->start_dma,
.end_dma = zdev->end_dma,
.pchid = zdev->pchid,
.vfn = zdev->vfn,
.fmb_length = zdev->fmb_length,
.pft = zdev->pft,
- .gid = zdev->pfgid
+ .gid = zdev->pfgid,
+ .fh = zdev->fh
};

return vfio_info_add_capability(caps, &cap.header, sizeof(cap));
diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h
index b4309397b6b2..78c022af3d29 100644
--- a/include/uapi/linux/vfio_zdev.h
+++ b/include/uapi/linux/vfio_zdev.h
@@ -29,6 +29,9 @@ struct vfio_device_info_cap_zpci_base {
__u16 fmb_length; /* Measurement Block Length (in bytes) */
__u8 pft; /* PCI Function Type */
__u8 gid; /* PCI function group ID */
+ /* End of version 1 */
+ __u32 fh; /* PCI function handle */
+ /* End of version 2 */
};

/**
--
2.27.0


2022-04-21 11:16:44

by Pierre Morel

[permalink] [raw]
Subject: Re: [PATCH v5 17/21] vfio-pci/zdev: add function handle to clp base capability



On 4/4/22 19:43, Matthew Rosato wrote:
> The function handle is a system-wide unique identifier for a zPCI
> device. It is used as input for various zPCI operations.

The comment is a little too much obvious.
May be add something like.
"
With the legacy instruction interception the PCI instructions used to be
executed by the host.
With PCI instruction interpretation, the guest needs to use the real
function handle.
Let's give it to the guest.
"
Or something like that.

With a better comment:

Reviewed-by: Pierre Morel <[email protected]>

>
> Signed-off-by: Matthew Rosato <[email protected]>
> ---
> drivers/vfio/pci/vfio_pci_zdev.c | 5 +++--
> include/uapi/linux/vfio_zdev.h | 3 +++
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c
> index ea4c0d2b0663..4a653ce480c7 100644
> --- a/drivers/vfio/pci/vfio_pci_zdev.c
> +++ b/drivers/vfio/pci/vfio_pci_zdev.c
> @@ -23,14 +23,15 @@ static int zpci_base_cap(struct zpci_dev *zdev, struct vfio_info_cap *caps)
> {
> struct vfio_device_info_cap_zpci_base cap = {
> .header.id = VFIO_DEVICE_INFO_CAP_ZPCI_BASE,
> - .header.version = 1,
> + .header.version = 2,
> .start_dma = zdev->start_dma,
> .end_dma = zdev->end_dma,
> .pchid = zdev->pchid,
> .vfn = zdev->vfn,
> .fmb_length = zdev->fmb_length,
> .pft = zdev->pft,
> - .gid = zdev->pfgid
> + .gid = zdev->pfgid,
> + .fh = zdev->fh
> };
>
> return vfio_info_add_capability(caps, &cap.header, sizeof(cap));
> diff --git a/include/uapi/linux/vfio_zdev.h b/include/uapi/linux/vfio_zdev.h
> index b4309397b6b2..78c022af3d29 100644
> --- a/include/uapi/linux/vfio_zdev.h
> +++ b/include/uapi/linux/vfio_zdev.h
> @@ -29,6 +29,9 @@ struct vfio_device_info_cap_zpci_base {
> __u16 fmb_length; /* Measurement Block Length (in bytes) */
> __u8 pft; /* PCI Function Type */
> __u8 gid; /* PCI function group ID */
> + /* End of version 1 */
> + __u32 fh; /* PCI function handle */
> + /* End of version 2 */
> };
>
> /**
>

--
Pierre Morel
IBM Lab Boeblingen