Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * IRQ offload/bypass manager
0004  *
0005  * Copyright (C) 2015 Red Hat, Inc.
0006  * Copyright (c) 2015 Linaro Ltd.
0007  */
0008 #ifndef IRQBYPASS_H
0009 #define IRQBYPASS_H
0010 
0011 #include <linux/list.h>
0012 
0013 struct irq_bypass_consumer;
0014 
0015 /*
0016  * Theory of operation
0017  *
0018  * The IRQ bypass manager is a simple set of lists and callbacks that allows
0019  * IRQ producers (ex. physical interrupt sources) to be matched to IRQ
0020  * consumers (ex. virtualization hardware that allows IRQ bypass or offload)
0021  * via a shared token (ex. eventfd_ctx).  Producers and consumers register
0022  * independently.  When a token match is found, the optional @stop callback
0023  * will be called for each participant.  The pair will then be connected via
0024  * the @add_* callbacks, and finally the optional @start callback will allow
0025  * any final coordination.  When either participant is unregistered, the
0026  * process is repeated using the @del_* callbacks in place of the @add_*
0027  * callbacks.  Match tokens must be unique per producer/consumer, 1:N pairings
0028  * are not supported.
0029  */
0030 
0031 /**
0032  * struct irq_bypass_producer - IRQ bypass producer definition
0033  * @node: IRQ bypass manager private list management
0034  * @token: opaque token to match between producer and consumer (non-NULL)
0035  * @irq: Linux IRQ number for the producer device
0036  * @add_consumer: Connect the IRQ producer to an IRQ consumer (optional)
0037  * @del_consumer: Disconnect the IRQ producer from an IRQ consumer (optional)
0038  * @stop: Perform any quiesce operations necessary prior to add/del (optional)
0039  * @start: Perform any startup operations necessary after add/del (optional)
0040  *
0041  * The IRQ bypass producer structure represents an interrupt source for
0042  * participation in possible host bypass, for instance an interrupt vector
0043  * for a physical device assigned to a VM.
0044  */
0045 struct irq_bypass_producer {
0046     struct list_head node;
0047     void *token;
0048     int irq;
0049     int (*add_consumer)(struct irq_bypass_producer *,
0050                 struct irq_bypass_consumer *);
0051     void (*del_consumer)(struct irq_bypass_producer *,
0052                  struct irq_bypass_consumer *);
0053     void (*stop)(struct irq_bypass_producer *);
0054     void (*start)(struct irq_bypass_producer *);
0055 };
0056 
0057 /**
0058  * struct irq_bypass_consumer - IRQ bypass consumer definition
0059  * @node: IRQ bypass manager private list management
0060  * @token: opaque token to match between producer and consumer (non-NULL)
0061  * @add_producer: Connect the IRQ consumer to an IRQ producer
0062  * @del_producer: Disconnect the IRQ consumer from an IRQ producer
0063  * @stop: Perform any quiesce operations necessary prior to add/del (optional)
0064  * @start: Perform any startup operations necessary after add/del (optional)
0065  *
0066  * The IRQ bypass consumer structure represents an interrupt sink for
0067  * participation in possible host bypass, for instance a hypervisor may
0068  * support offloads to allow bypassing the host entirely or offload
0069  * portions of the interrupt handling to the VM.
0070  */
0071 struct irq_bypass_consumer {
0072     struct list_head node;
0073     void *token;
0074     int (*add_producer)(struct irq_bypass_consumer *,
0075                 struct irq_bypass_producer *);
0076     void (*del_producer)(struct irq_bypass_consumer *,
0077                  struct irq_bypass_producer *);
0078     void (*stop)(struct irq_bypass_consumer *);
0079     void (*start)(struct irq_bypass_consumer *);
0080 };
0081 
0082 int irq_bypass_register_producer(struct irq_bypass_producer *);
0083 void irq_bypass_unregister_producer(struct irq_bypass_producer *);
0084 int irq_bypass_register_consumer(struct irq_bypass_consumer *);
0085 void irq_bypass_unregister_consumer(struct irq_bypass_consumer *);
0086 
0087 #endif /* IRQBYPASS_H */