pci: improve vfio logging
Type: improvement Change-Id: Ic49a43651b80b79fa278e29964da5cb2ead2a818 Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:

committed by
Matthew Smith

parent
d1d90f5951
commit
0792bb451c
10
MAINTAINERS
10
MAINTAINERS
@ -60,6 +60,9 @@ M: Dave Barach <dave@barachs.net>
|
|||||||
M: Damjan Marion <damarion@cisco.com>
|
M: Damjan Marion <damarion@cisco.com>
|
||||||
F: src/vlib/
|
F: src/vlib/
|
||||||
E: src/vlib/buffer*.[ch]
|
E: src/vlib/buffer*.[ch]
|
||||||
|
E: src/vlib/pci/
|
||||||
|
E: src/vlib/linux/pci.[ch]
|
||||||
|
E: src/vlib/linux/vfio.[ch]
|
||||||
|
|
||||||
Vector Library - Buffer Management
|
Vector Library - Buffer Management
|
||||||
I: buffers
|
I: buffers
|
||||||
@ -67,6 +70,13 @@ M: Damjan Marion <damarion@cisco.com>
|
|||||||
M: Dave Barach <dave@barachs.net>
|
M: Dave Barach <dave@barachs.net>
|
||||||
F: src/vlib/buffer*.[ch]
|
F: src/vlib/buffer*.[ch]
|
||||||
|
|
||||||
|
Vector Library - PCI
|
||||||
|
I: pci
|
||||||
|
M: Damjan Marion <damarion@cisco.com>
|
||||||
|
F: src/vlib/pci/
|
||||||
|
F: src/vlib/linux/pci.[ch]
|
||||||
|
F: src/vlib/linux/vfio.[ch]
|
||||||
|
|
||||||
Binary API Libraries
|
Binary API Libraries
|
||||||
I: api
|
I: api
|
||||||
M: Dave Barach <dave@barachs.net>
|
M: Dave Barach <dave@barachs.net>
|
||||||
|
@ -966,13 +966,7 @@ add_device_vfio (vlib_main_t * vm, linux_pci_device_t * p,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pci_log_debug (vm, p, "%s region_info index:%u size:0x%lx offset:0x%lx "
|
pci_log_debug (vm, p, "%s %U", __func__, format_vfio_region_info, ®);
|
||||||
"flags: %s%s%s(0x%x)", __func__,
|
|
||||||
reg.index, reg.size, reg.offset,
|
|
||||||
reg.flags & VFIO_REGION_INFO_FLAG_READ ? "rd " : "",
|
|
||||||
reg.flags & VFIO_REGION_INFO_FLAG_WRITE ? "wr " : "",
|
|
||||||
reg.flags & VFIO_REGION_INFO_FLAG_MMAP ? "mmap " : "",
|
|
||||||
reg.flags);
|
|
||||||
|
|
||||||
p->config_offset = reg.offset;
|
p->config_offset = reg.offset;
|
||||||
p->config_fd = p->fd;
|
p->config_fd = p->fd;
|
||||||
@ -1087,23 +1081,28 @@ vlib_pci_region (vlib_main_t * vm, vlib_pci_dev_handle_t h, u32 bar, int *fd,
|
|||||||
}
|
}
|
||||||
else if (p->type == LINUX_PCI_DEVICE_TYPE_VFIO)
|
else if (p->type == LINUX_PCI_DEVICE_TYPE_VFIO)
|
||||||
{
|
{
|
||||||
struct vfio_region_info reg = { 0 };
|
struct vfio_region_info *r;
|
||||||
reg.argsz = sizeof (struct vfio_region_info);
|
u32 sz = sizeof (struct vfio_region_info);
|
||||||
reg.index = bar;
|
again:
|
||||||
if (ioctl (p->fd, VFIO_DEVICE_GET_REGION_INFO, ®) < 0)
|
r = clib_mem_alloc (sz);
|
||||||
|
clib_memset (r, 0, sz);
|
||||||
|
r->argsz = sz;
|
||||||
|
r->index = bar;
|
||||||
|
if (ioctl (p->fd, VFIO_DEVICE_GET_REGION_INFO, r) < 0)
|
||||||
return clib_error_return_unix (0, "ioctl(VFIO_DEVICE_GET_INFO) "
|
return clib_error_return_unix (0, "ioctl(VFIO_DEVICE_GET_INFO) "
|
||||||
"'%U'", format_vlib_pci_addr,
|
"'%U'", format_vlib_pci_addr,
|
||||||
&p->addr);
|
&p->addr);
|
||||||
|
if (sz != r->argsz)
|
||||||
|
{
|
||||||
|
sz = r->argsz;
|
||||||
|
clib_mem_free (r);
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
_fd = p->fd;
|
_fd = p->fd;
|
||||||
_size = reg.size;
|
_size = r->size;
|
||||||
_offset = reg.offset;
|
_offset = r->offset;
|
||||||
pci_log_debug (vm, p, "%s region_info index:%u size:0x%lx offset:0x%lx "
|
pci_log_debug (vm, p, "%s %U", __func__, format_vfio_region_info, r);
|
||||||
"flags: %s%s%s(0x%x)", __func__,
|
clib_mem_free (r);
|
||||||
reg.index, reg.size, reg.offset,
|
|
||||||
reg.flags & VFIO_REGION_INFO_FLAG_READ ? "rd " : "",
|
|
||||||
reg.flags & VFIO_REGION_INFO_FLAG_WRITE ? "wr " : "",
|
|
||||||
reg.flags & VFIO_REGION_INFO_FLAG_MMAP ? "mmap " : "",
|
|
||||||
reg.flags);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ASSERT (0);
|
ASSERT (0);
|
||||||
|
@ -246,6 +246,62 @@ linux_vfio_init (vlib_main_t * vm)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 *
|
||||||
|
format_vfio_region_info (u8 * s, va_list * args)
|
||||||
|
{
|
||||||
|
struct vfio_region_info *r = va_arg (*args, struct vfio_region_info *);
|
||||||
|
|
||||||
|
s = format (s, "region_info index:%u size:0x%lx offset:0x%lx flags:",
|
||||||
|
r->index, r->size, r->offset);
|
||||||
|
|
||||||
|
if (r->flags & VFIO_REGION_INFO_FLAG_READ)
|
||||||
|
s = format (s, " rd");
|
||||||
|
|
||||||
|
if (r->flags & VFIO_REGION_INFO_FLAG_WRITE)
|
||||||
|
s = format (s, " wr");
|
||||||
|
|
||||||
|
if (r->flags & VFIO_REGION_INFO_FLAG_MMAP)
|
||||||
|
s = format (s, " mmap");
|
||||||
|
|
||||||
|
#ifdef VFIO_REGION_INFO_FLAG_CAPS
|
||||||
|
if (r->flags & VFIO_REGION_INFO_FLAG_CAPS)
|
||||||
|
s = format (s, " caps");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
s = format (s, " (0x%x)", r->flags);
|
||||||
|
|
||||||
|
#ifdef VFIO_REGION_INFO_FLAG_CAPS
|
||||||
|
u32 cap_offset;
|
||||||
|
|
||||||
|
if ((r->flags & VFIO_REGION_INFO_FLAG_CAPS) == 0)
|
||||||
|
return s;
|
||||||
|
|
||||||
|
s = format (s, "\n caps:");
|
||||||
|
cap_offset = r->cap_offset;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
struct vfio_info_cap_header *cap = (void *) r + cap_offset;
|
||||||
|
#ifdef VFIO_REGION_INFO_CAP_SPARSE_MMAP
|
||||||
|
if (cap->id == VFIO_REGION_INFO_CAP_SPARSE_MMAP)
|
||||||
|
s = format (s, " sparse-mmap");
|
||||||
|
#endif
|
||||||
|
#ifdef VFIO_REGION_INFO_CAP_TYPE
|
||||||
|
if (cap->id == VFIO_REGION_INFO_CAP_TYPE)
|
||||||
|
s = format (s, " type");
|
||||||
|
#endif
|
||||||
|
#ifdef VFIO_REGION_INFO_CAP_MSIX_MAPPABLE
|
||||||
|
if (cap->id == VFIO_REGION_INFO_CAP_MSIX_MAPPABLE)
|
||||||
|
s = format (s, " msix-mappable");
|
||||||
|
#endif
|
||||||
|
cap_offset = cap->next;
|
||||||
|
}
|
||||||
|
while (cap_offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fd.io coding-style-patch-verification: ON
|
* fd.io coding-style-patch-verification: ON
|
||||||
*
|
*
|
||||||
|
@ -49,6 +49,8 @@ clib_error_t *vfio_map_physmem_page (vlib_main_t * vm, void *addr);
|
|||||||
clib_error_t *linux_vfio_group_get_device_fd (vlib_pci_addr_t * addr,
|
clib_error_t *linux_vfio_group_get_device_fd (vlib_pci_addr_t * addr,
|
||||||
int *fd, int *is_noiommu);
|
int *fd, int *is_noiommu);
|
||||||
|
|
||||||
|
format_function_t format_vfio_region_info;
|
||||||
|
|
||||||
|
|
||||||
#endif /* included_vlib_linux_vfio_h */
|
#endif /* included_vlib_linux_vfio_h */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user