File Index
Files and directories
Sign in
FILE

irqbypass.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/irqbypass.h C
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * IRQ offload/bypass manager
 4 *
 5 * Copyright (C) 2015 Red Hat, Inc.
 6 * Copyright (c) 2015 Linaro Ltd.
 7 */
 8#ifndef IRQBYPASS_H
 9#define IRQBYPASS_H
10
11#include <linux/list.h>
12
13struct eventfd_ctx;
14struct irq_bypass_consumer;
15
16/*
17 * Theory of operation
18 *
19 * The IRQ bypass manager is a simple set of lists and callbacks that allows
20 * IRQ producers (ex. physical interrupt sources) to be matched to IRQ
21 * consumers (ex. virtualization hardware that allows IRQ bypass or offload)
22 * via a shared eventfd_ctx.  Producers and consumers register independently.
23 * When a producer and consumer are paired, i.e. an eventfd match is found, the
24 * optional @stop callback will be called for each participant.  The pair will
25 * then be connected via the @add_* callbacks, and finally the optional @start
26 * callback will allow any final coordination.  When either participant is
27 * unregistered, the process is repeated using the @del_* callbacks in place of
28 * the @add_* callbacks.  eventfds must be unique per producer/consumer, 1:N
29 * pairings are not supported.
30 */
31
32struct irq_bypass_consumer;
33
34/**
35 * struct irq_bypass_producer - IRQ bypass producer definition
36 * @eventfd: eventfd context used to match producers and consumers
37 * @consumer: The connected consumer (NULL if no connection)
38 * @irq: Linux IRQ number for the producer device
39 * @add_consumer: Connect the IRQ producer to an IRQ consumer (optional)
40 * @del_consumer: Disconnect the IRQ producer from an IRQ consumer (optional)
41 * @stop: Perform any quiesce operations necessary prior to add/del (optional)
42 * @start: Perform any startup operations necessary after add/del (optional)
43 *
44 * The IRQ bypass producer structure represents an interrupt source for
45 * participation in possible host bypass, for instance an interrupt vector
46 * for a physical device assigned to a VM.
47 */
48struct irq_bypass_producer {
49	struct eventfd_ctx *eventfd;
50	struct irq_bypass_consumer *consumer;
51	int irq;
52	int (*add_consumer)(struct irq_bypass_producer *,
53			    struct irq_bypass_consumer *);
54	void (*del_consumer)(struct irq_bypass_producer *,
55			     struct irq_bypass_consumer *);
56	void (*stop)(struct irq_bypass_producer *);
57	void (*start)(struct irq_bypass_producer *);
58};
59
60/**
61 * struct irq_bypass_consumer - IRQ bypass consumer definition
62 * @eventfd: eventfd context used to match producers and consumers
63 * @producer: The connected producer (NULL if no connection)
64 * @add_producer: Connect the IRQ consumer to an IRQ producer
65 * @del_producer: Disconnect the IRQ consumer from an IRQ producer
66 * @stop: Perform any quiesce operations necessary prior to add/del (optional)
67 * @start: Perform any startup operations necessary after add/del (optional)
68 *
69 * The IRQ bypass consumer structure represents an interrupt sink for
70 * participation in possible host bypass, for instance a hypervisor may
71 * support offloads to allow bypassing the host entirely or offload
72 * portions of the interrupt handling to the VM.
73 */
74struct irq_bypass_consumer {
75	struct eventfd_ctx *eventfd;
76	struct irq_bypass_producer *producer;
77
78	int (*add_producer)(struct irq_bypass_consumer *,
79			    struct irq_bypass_producer *);
80	void (*del_producer)(struct irq_bypass_consumer *,
81			     struct irq_bypass_producer *);
82	void (*stop)(struct irq_bypass_consumer *);
83	void (*start)(struct irq_bypass_consumer *);
84};
85
86int irq_bypass_register_producer(struct irq_bypass_producer *producer,
87				 struct eventfd_ctx *eventfd, int irq);
88void irq_bypass_unregister_producer(struct irq_bypass_producer *producer);
89int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer,
90				 struct eventfd_ctx *eventfd);
91void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer);
92
93#endif /* IRQBYPASS_H */
~/ Read-only file preview.