summaryrefslogtreecommitdiffstats
path: root/src/vlib/linux/pci.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-11-06 00:07:15 +0000
committerOle Tr�an <otroan@employees.org>2023-11-06 10:15:12 +0000
commit7444fd2a0d177796cacb7c040323cdc327afa97a (patch)
treedc7050e8171b3628c0368821d5d1c1e85b8c6bd8 /src/vlib/linux/pci.c
parent60529a8ef81d08c7aa0f7eaea402435b3c6d1eb6 (diff)
pci: remove unnecessary ioctl() call and improve logging in vfio_set_irqs
Type: improvement Change-Id: Ic8e2785bf375882defe5a1d299948d522cdd4895 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/linux/pci.c')
-rw-r--r--src/vlib/linux/pci.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index 62db8204182..0435d569bec 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -648,33 +648,14 @@ vfio_set_irqs (vlib_main_t * vm, linux_pci_device_t * p, u32 index, u32 start,
{
int data_len = efds ? count * sizeof (int) : 0;
u8 buf[sizeof (struct vfio_irq_set) + data_len];
- struct vfio_irq_info ii = { 0 };
struct vfio_irq_set *irq_set = (struct vfio_irq_set *) buf;
-
- ii.argsz = sizeof (struct vfio_irq_info);
- ii.index = index;
-
- if (ioctl (p->fd, VFIO_DEVICE_GET_IRQ_INFO, &ii) < 0)
- return clib_error_return_unix (0, "ioctl(VFIO_DEVICE_GET_IRQ_INFO) "
- "'%U'", format_vlib_pci_addr, &p->addr);
-
- log_debug (p, "%s index:%u count:%u flags: %s%s%s%s(0x%x)", __func__,
- ii.index, ii.count,
- ii.flags & VFIO_IRQ_INFO_EVENTFD ? "eventfd " : "",
- ii.flags & VFIO_IRQ_INFO_MASKABLE ? "maskable " : "",
- ii.flags & VFIO_IRQ_INFO_AUTOMASKED ? "automasked " : "",
- ii.flags & VFIO_IRQ_INFO_NORESIZE ? "noresize " : "", ii.flags);
-
- if (ii.count < start + count)
- return clib_error_return_unix (0, "vfio_set_irq: unexistng interrupt on "
- "'%U'", format_vlib_pci_addr, &p->addr);
-
-
if (efds)
{
+ int *data = (int *) irq_set->data;
flags |= VFIO_IRQ_SET_DATA_EVENTFD;
- clib_memcpy_fast (&irq_set->data, efds, data_len);
+ for (u32 i = 0; i < count; i++)
+ data[i] = efds[i];
}
else
flags |= VFIO_IRQ_SET_DATA_NONE;
@@ -689,11 +670,11 @@ vfio_set_irqs (vlib_main_t * vm, linux_pci_device_t * p, u32 index, u32 start,
irq_set->flags = flags;
if (ioctl (p->fd, VFIO_DEVICE_SET_IRQS, irq_set) < 0)
- return clib_error_return_unix (0, "%U:ioctl(VFIO_DEVICE_SET_IRQS) "
- "[index = %u, start = %u, count = %u, "
- "flags = 0x%x]",
+ return clib_error_return_unix (0, "%U:ioctl(VFIO_DEVICE_SET_IRQS)\n%U",
format_vlib_pci_addr, &p->addr,
- index, start, count, flags);
+ format_vfio_irq_set, irq_set);
+
+ log_debug (p, "%s:\n%U", __func__, format_vfio_irq_set, irq_set);
return 0;
}