blob: 1551b5b2f4c2a9ecb639bd6fe67be91f2e6d5bc6 [file] [log] [blame]
Alex Williamsonf73f8172015-09-18 22:29:39 +08001/*
2 * IRQ offload/bypass manager
3 *
4 * Copyright (C) 2015 Red Hat, Inc.
5 * Copyright (c) 2015 Linaro Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef IRQBYPASS_H
12#define IRQBYPASS_H
13
14#include <linux/list.h>
15
16struct irq_bypass_consumer;
17
18/*
19 * Theory of operation
20 *
21 * The IRQ bypass manager is a simple set of lists and callbacks that allows
22 * IRQ producers (ex. physical interrupt sources) to be matched to IRQ
23 * consumers (ex. virtualization hardware that allows IRQ bypass or offload)
24 * via a shared token (ex. eventfd_ctx). Producers and consumers register
25 * independently. When a token match is found, the optional @stop callback
26 * will be called for each participant. The pair will then be connected via
27 * the @add_* callbacks, and finally the optional @start callback will allow
28 * any final coordination. When either participant is unregistered, the
29 * process is repeated using the @del_* callbacks in place of the @add_*
30 * callbacks. Match tokens must be unique per producer/consumer, 1:N pairings
31 * are not supported.
32 */
33
34/**
35 * struct irq_bypass_producer - IRQ bypass producer definition
36 * @node: IRQ bypass manager private list management
37 * @token: opaque token to match between producer and consumer
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 list_head node;
50 void *token;
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 * @node: IRQ bypass manager private list management
63 * @token: opaque token to match between producer and consumer
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 list_head node;
76 void *token;
77 int (*add_producer)(struct irq_bypass_consumer *,
78 struct irq_bypass_producer *);
79 void (*del_producer)(struct irq_bypass_consumer *,
80 struct irq_bypass_producer *);
81 void (*stop)(struct irq_bypass_consumer *);
82 void (*start)(struct irq_bypass_consumer *);
83};
84
85int irq_bypass_register_producer(struct irq_bypass_producer *);
86void irq_bypass_unregister_producer(struct irq_bypass_producer *);
87int irq_bypass_register_consumer(struct irq_bypass_consumer *);
88void irq_bypass_unregister_consumer(struct irq_bypass_consumer *);
89
90#endif /* IRQBYPASS_H */