Skip to content

Commit

Permalink
vfio/device: add vfio_set_irq_from_start
Browse files Browse the repository at this point in the history
To register IRQ eventfd from a specific IRQ, this patch added
vfio_set_irq_from_start helper to receive start IRQ number along with
count.

Signed-off-by: Minwoo Im <[email protected]>
  • Loading branch information
minwooim committed Nov 19, 2024
1 parent a261331 commit d5102dc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions include/vfn/vfio/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ struct vfio_device {
*/
int vfio_set_irq(struct vfio_device *dev, int *eventfds, int count);

/**
* vfio_set_irq_from_start - Enable IRQs through eventfds from the given start
* @dev: &struct vfio_device
* @eventfds: array of eventfds
* @start: start irq number
* @count: number of eventfds
*
* Enable interrupts for a range of vectors. See linux/vfio.h for documentation
* on the format of @eventfds.
*
* Return: ``0`` on success, ``-1`` on error and sets ``errno``.
*/
int vfio_set_irq_from_start(struct vfio_device *dev, int *eventfds, int start, int count);

/**
* vfio_disable_irq - Disable all IRQs
* @dev: &struct vfio_device
Expand Down
15 changes: 13 additions & 2 deletions src/vfio/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#include "ccan/minmax/minmax.h"
#include "ccan/str/str.h"

int vfio_set_irq(struct vfio_device *dev, int *eventfds, int count)
static int __vfio_set_irq(struct vfio_device *dev, int *eventfds, int start,
int count)
{
struct vfio_irq_set *irq_set;
size_t irq_set_size;
Expand All @@ -59,7 +60,7 @@ int vfio_set_irq(struct vfio_device *dev, int *eventfds, int count)
.argsz = (uint32_t)irq_set_size,
.flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER,
.index = dev->irq_info.index,
.start = 0,
.start = start,
.count = count,
};

Expand All @@ -75,6 +76,16 @@ int vfio_set_irq(struct vfio_device *dev, int *eventfds, int count)

return 0;
}
int vfio_set_irq(struct vfio_device *dev, int *eventfds, int count)
{
return __vfio_set_irq(dev, eventfds, 0, count);
}

int vfio_set_irq_from_start(struct vfio_device *dev, int *eventfds, int start,
int count)
{
return __vfio_set_irq(dev, eventfds, start, count);
}

int vfio_disable_irq(struct vfio_device *dev)
{
Expand Down

0 comments on commit d5102dc

Please sign in to comment.