@@ -110,6 +110,16 @@ typedef struct privcmd_map_hva_to_gpfns {
int add_mapping;
} privcmd_map_hva_to_gpfns_t;
+typedef struct privcmd_p2pdma_distance {
+ __u32 provider_bus;
+ __u32 provider_slot;
+ __u32 provider_func;
+ __u32 client_bus;
+ __u32 client_slot;
+ __u32 client_func;
+ __u32 distance;
+} privcmd_p2pdma_distance_t;
+
/*
* @cmd: IOCTL_PRIVCMD_HYPERCALL
* @arg: &privcmd_hypercall_t
@@ -131,6 +141,8 @@ typedef struct privcmd_map_hva_to_gpfns {
_IOC(_IOC_NONE, 'P', 7, sizeof(privcmd_mmap_resource_t))
#define IOCTL_PRIVCMD_PCIDEV_GET_GSI \
_IOC(_IOC_NONE, 'P', 10, sizeof(privcmd_pcidev_get_gsi_t))
+#define IOCTL_PRIVCMD_P2PDMA_DISTANCE \
+ _IOC(_IOC_NONE, 'P', 11, sizeof(privcmd_p2pdma_distance_t))
#define IOCTL_PRIVCMD_MAP_HVA_TO_GPFNS \
_IOC(_IOC_NONE, 'P', 13, sizeof(privcmd_map_hva_to_gpfns_t))
#define IOCTL_PRIVCMD_UNIMPLEMENTED \
@@ -1654,6 +1654,23 @@ int xc_physdev_unmap_pirq(xc_interface *xch,
int xc_pcidev_get_gsi(xc_interface *xch, uint32_t sbdf);
+int xc_physdev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func);
+
+int xc_pcidev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func);
+
+
/*
* LOGGING AND ERROR REPORTING
*/
@@ -60,6 +60,17 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
return ptr;
}
+int xc_pcidev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func)
+{
+ return -1;
+}
+
int xc_pcidev_get_gsi(xc_interface *xch, uint32_t sbdf)
{
errno = ENOSYS;
@@ -66,6 +66,30 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
return ptr;
}
+int xc_pcidev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func)
+{
+ privcmd_p2pdma_distance_t p2pdma_distance = {
+ .provider_bus = bus,
+ .provider_slot = slot,
+ .provider_func = func,
+ .client_bus = c_bus,
+ .client_slot = c_slot,
+ .client_func = c_func,
+ .distance = -1,
+ };
+ if (!ioctl(xencall_fd(xch->xcall), IOCTL_PRIVCMD_P2PDMA_DISTANCE, &p2pdma_distance)) {
+ return p2pdma_distance.distance;
+ }
+
+ return -1;
+}
+
int xc_pcidev_get_gsi(xc_interface *xch, uint32_t sbdf)
{
int ret;
@@ -47,6 +47,17 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
return memalign(alignment, size);
}
+int xc_pcidev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func)
+{
+ return -1;
+}
+
int xc_pcidev_get_gsi(xc_interface *xch, uint32_t sbdf)
{
errno = ENOSYS;
@@ -63,6 +63,17 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
return valloc(size);
}
+int xc_pcidev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func)
+{
+ return -1;
+}
+
int xc_pcidev_get_gsi(xc_interface *xch, uint32_t sbdf)
{
errno = ENOSYS;
@@ -138,3 +138,15 @@ int xc_physdev_unmap_pirq(xc_interface *xch,
return rc;
}
+int xc_physdev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func)
+{
+ return xc_pcidev_p2pdma_distance(xch, bus, slot, func,
+ c_bus, c_slot, c_func);
+}
+
@@ -32,6 +32,17 @@ void *xc_memalign(xc_interface *xch, size_t alignment, size_t size)
return memalign(alignment, size);
}
+int xc_pcidev_p2pdma_distance(xc_interface *xch,
+ uint32_t bus,
+ uint32_t slot,
+ uint32_t func,
+ uint32_t c_bus,
+ uint32_t c_slot,
+ uint32_t c_func)
+{
+ return -1;
+}
+
int xc_pcidev_get_gsi(xc_interface *xch, uint32_t sbdf)
{
errno = ENOSYS;
To implement dGPU prime feature, virtgpu driver need to get p2pdma_distance of two GPU from host side. This adds a new privcmd ioctl to get the real p2pdma_distance of two pci devices in the host with pci notations sent from guest side. Signed-off-by: Julia Zhang <julia.zhang@amd.com> --- tools/include/xen-sys/Linux/privcmd.h | 12 ++++++++++++ tools/include/xenctrl.h | 17 +++++++++++++++++ tools/libs/ctrl/xc_freebsd.c | 11 +++++++++++ tools/libs/ctrl/xc_linux.c | 24 ++++++++++++++++++++++++ tools/libs/ctrl/xc_minios.c | 11 +++++++++++ tools/libs/ctrl/xc_netbsd.c | 11 +++++++++++ tools/libs/ctrl/xc_physdev.c | 12 ++++++++++++ tools/libs/ctrl/xc_solaris.c | 11 +++++++++++ 8 files changed, 109 insertions(+)