| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Xen Event Channels (internal header) |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Citrix Systems R&D Ltd. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This source code is licensed under the GNU General Public License, |
|---|
| 7 | | - * Version 2 or later. See the file COPYING for more details. |
|---|
| 8 | 6 | */ |
|---|
| 9 | 7 | #ifndef __EVENTS_INTERNAL_H__ |
|---|
| 10 | 8 | #define __EVENTS_INTERNAL_H__ |
|---|
| 11 | | - |
|---|
| 12 | | -/* Interrupt types. */ |
|---|
| 13 | | -enum xen_irq_type { |
|---|
| 14 | | - IRQT_UNBOUND = 0, |
|---|
| 15 | | - IRQT_PIRQ, |
|---|
| 16 | | - IRQT_VIRQ, |
|---|
| 17 | | - IRQT_IPI, |
|---|
| 18 | | - IRQT_EVTCHN |
|---|
| 19 | | -}; |
|---|
| 20 | | - |
|---|
| 21 | | -/* |
|---|
| 22 | | - * Packed IRQ information: |
|---|
| 23 | | - * type - enum xen_irq_type |
|---|
| 24 | | - * event channel - irq->event channel mapping |
|---|
| 25 | | - * cpu - cpu this event channel is bound to |
|---|
| 26 | | - * index - type-specific information: |
|---|
| 27 | | - * PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM |
|---|
| 28 | | - * guest, or GSI (real passthrough IRQ) of the device. |
|---|
| 29 | | - * VIRQ - virq number |
|---|
| 30 | | - * IPI - IPI vector |
|---|
| 31 | | - * EVTCHN - |
|---|
| 32 | | - */ |
|---|
| 33 | | -struct irq_info { |
|---|
| 34 | | - struct list_head list; |
|---|
| 35 | | - struct list_head eoi_list; |
|---|
| 36 | | - short refcnt; |
|---|
| 37 | | - short spurious_cnt; |
|---|
| 38 | | - short type; /* type */ |
|---|
| 39 | | - u8 mask_reason; /* Why is event channel masked */ |
|---|
| 40 | | -#define EVT_MASK_REASON_EXPLICIT 0x01 |
|---|
| 41 | | -#define EVT_MASK_REASON_TEMPORARY 0x02 |
|---|
| 42 | | -#define EVT_MASK_REASON_EOI_PENDING 0x04 |
|---|
| 43 | | - u8 is_active; /* Is event just being handled? */ |
|---|
| 44 | | - unsigned irq; |
|---|
| 45 | | - unsigned int evtchn; /* event channel */ |
|---|
| 46 | | - unsigned short cpu; /* cpu bound */ |
|---|
| 47 | | - unsigned short eoi_cpu; /* EOI must happen on this cpu */ |
|---|
| 48 | | - unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */ |
|---|
| 49 | | - u64 eoi_time; /* Time in jiffies when to EOI. */ |
|---|
| 50 | | - raw_spinlock_t lock; |
|---|
| 51 | | - |
|---|
| 52 | | - union { |
|---|
| 53 | | - unsigned short virq; |
|---|
| 54 | | - enum ipi_vector ipi; |
|---|
| 55 | | - struct { |
|---|
| 56 | | - unsigned short pirq; |
|---|
| 57 | | - unsigned short gsi; |
|---|
| 58 | | - unsigned char vector; |
|---|
| 59 | | - unsigned char flags; |
|---|
| 60 | | - uint16_t domid; |
|---|
| 61 | | - } pirq; |
|---|
| 62 | | - } u; |
|---|
| 63 | | -}; |
|---|
| 64 | | - |
|---|
| 65 | | -#define PIRQ_NEEDS_EOI (1 << 0) |
|---|
| 66 | | -#define PIRQ_SHAREABLE (1 << 1) |
|---|
| 67 | | -#define PIRQ_MSI_GROUP (1 << 2) |
|---|
| 68 | 9 | |
|---|
| 69 | 10 | struct evtchn_loop_ctrl; |
|---|
| 70 | 11 | |
|---|
| .. | .. |
|---|
| 72 | 13 | unsigned (*max_channels)(void); |
|---|
| 73 | 14 | unsigned (*nr_channels)(void); |
|---|
| 74 | 15 | |
|---|
| 75 | | - int (*setup)(struct irq_info *info); |
|---|
| 16 | + int (*setup)(evtchn_port_t port); |
|---|
| 76 | 17 | void (*remove)(evtchn_port_t port, unsigned int cpu); |
|---|
| 77 | | - void (*bind_to_cpu)(struct irq_info *info, unsigned cpu); |
|---|
| 18 | + void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu, |
|---|
| 19 | + unsigned int old_cpu); |
|---|
| 78 | 20 | |
|---|
| 79 | | - void (*clear_pending)(unsigned port); |
|---|
| 80 | | - void (*set_pending)(unsigned port); |
|---|
| 81 | | - bool (*is_pending)(unsigned port); |
|---|
| 82 | | - void (*mask)(unsigned port); |
|---|
| 83 | | - void (*unmask)(unsigned port); |
|---|
| 21 | + void (*clear_pending)(evtchn_port_t port); |
|---|
| 22 | + void (*set_pending)(evtchn_port_t port); |
|---|
| 23 | + bool (*is_pending)(evtchn_port_t port); |
|---|
| 24 | + void (*mask)(evtchn_port_t port); |
|---|
| 25 | + void (*unmask)(evtchn_port_t port); |
|---|
| 84 | 26 | |
|---|
| 85 | 27 | void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl); |
|---|
| 86 | 28 | void (*resume)(void); |
|---|
| .. | .. |
|---|
| 91 | 33 | |
|---|
| 92 | 34 | extern const struct evtchn_ops *evtchn_ops; |
|---|
| 93 | 35 | |
|---|
| 94 | | -extern int **evtchn_to_irq; |
|---|
| 95 | | -int get_evtchn_to_irq(unsigned int evtchn); |
|---|
| 36 | +int get_evtchn_to_irq(evtchn_port_t evtchn); |
|---|
| 96 | 37 | void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl); |
|---|
| 97 | 38 | |
|---|
| 98 | | -struct irq_info *info_for_irq(unsigned irq); |
|---|
| 99 | | -unsigned cpu_from_irq(unsigned irq); |
|---|
| 100 | | -unsigned cpu_from_evtchn(unsigned int evtchn); |
|---|
| 39 | +unsigned int cpu_from_evtchn(evtchn_port_t evtchn); |
|---|
| 101 | 40 | |
|---|
| 102 | 41 | static inline unsigned xen_evtchn_max_channels(void) |
|---|
| 103 | 42 | { |
|---|
| .. | .. |
|---|
| 108 | 47 | * Do any ABI specific setup for a bound event channel before it can |
|---|
| 109 | 48 | * be unmasked and used. |
|---|
| 110 | 49 | */ |
|---|
| 111 | | -static inline int xen_evtchn_port_setup(struct irq_info *info) |
|---|
| 50 | +static inline int xen_evtchn_port_setup(evtchn_port_t evtchn) |
|---|
| 112 | 51 | { |
|---|
| 113 | 52 | if (evtchn_ops->setup) |
|---|
| 114 | | - return evtchn_ops->setup(info); |
|---|
| 53 | + return evtchn_ops->setup(evtchn); |
|---|
| 115 | 54 | return 0; |
|---|
| 116 | 55 | } |
|---|
| 117 | 56 | |
|---|
| .. | .. |
|---|
| 122 | 61 | evtchn_ops->remove(evtchn, cpu); |
|---|
| 123 | 62 | } |
|---|
| 124 | 63 | |
|---|
| 125 | | -static inline void xen_evtchn_port_bind_to_cpu(struct irq_info *info, |
|---|
| 126 | | - unsigned cpu) |
|---|
| 64 | +static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn, |
|---|
| 65 | + unsigned int cpu, |
|---|
| 66 | + unsigned int old_cpu) |
|---|
| 127 | 67 | { |
|---|
| 128 | | - evtchn_ops->bind_to_cpu(info, cpu); |
|---|
| 68 | + evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu); |
|---|
| 129 | 69 | } |
|---|
| 130 | 70 | |
|---|
| 131 | | -static inline void clear_evtchn(unsigned port) |
|---|
| 71 | +static inline void clear_evtchn(evtchn_port_t port) |
|---|
| 132 | 72 | { |
|---|
| 133 | 73 | evtchn_ops->clear_pending(port); |
|---|
| 134 | 74 | } |
|---|
| 135 | 75 | |
|---|
| 136 | | -static inline void set_evtchn(unsigned port) |
|---|
| 76 | +static inline void set_evtchn(evtchn_port_t port) |
|---|
| 137 | 77 | { |
|---|
| 138 | 78 | evtchn_ops->set_pending(port); |
|---|
| 139 | 79 | } |
|---|
| 140 | 80 | |
|---|
| 141 | | -static inline bool test_evtchn(unsigned port) |
|---|
| 81 | +static inline bool test_evtchn(evtchn_port_t port) |
|---|
| 142 | 82 | { |
|---|
| 143 | 83 | return evtchn_ops->is_pending(port); |
|---|
| 144 | 84 | } |
|---|
| 145 | 85 | |
|---|
| 146 | | -static inline void mask_evtchn(unsigned port) |
|---|
| 86 | +static inline void mask_evtchn(evtchn_port_t port) |
|---|
| 147 | 87 | { |
|---|
| 148 | 88 | return evtchn_ops->mask(port); |
|---|
| 149 | 89 | } |
|---|
| 150 | 90 | |
|---|
| 151 | | -static inline void unmask_evtchn(unsigned port) |
|---|
| 91 | +static inline void unmask_evtchn(evtchn_port_t port) |
|---|
| 152 | 92 | { |
|---|
| 153 | 93 | return evtchn_ops->unmask(port); |
|---|
| 154 | 94 | } |
|---|