ia64/xen-unstable

view xen/include/public/event_channel.h @ 5691:88c2d410979f

I updated the vcpu_to_cpu string creation to include a field separator,
which gets rid of the -1 -> # hack and works for cpus > 9.

I ran into some issues with stale vcpu_to_cpu lists when running the
hotplug subprogram. I would take a vcpu offline, and then issue the
command to bring it back and the vcpu_to_cpu list would not have changed
to indicate the the vcpu actually went down. If I injected a xm list -v
(which always showed the correct mapping) then subsequent hotplug
commands would see the state change and fire off the hotplug request. I
don't know that not sending the event when not changing state saves that
much work so I took the state check out and now just send the hotplug
event directly.

> Also the whole hotplug stuff is still missing interrupt re-routing
> when a vcpu is taken down. To do this, we need an evtchn operation to
> change the vcpu affinity of a port by changing notify_vcpu_id.

I don't fully understand all of the mappings that are happening, so this
part of the patch might be way off. In any case, I've added a new
evtchn op to set the notify_vcpu_id field of a channel. I updated the
HOTPLUG_CPU code to use the new routines when bringing cpus up and down.
When taking down a cpu, I route the IPI irq channels to CPU 0, and when
the cpu comes up, it re-routes the channels back to the awakened CPU.

From: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: ian@xensource.com
author iap10@freefall.cl.cam.ac.uk
date Wed Jul 06 22:23:18 2005 +0000 (2005-07-06)
parents 2b6c1a809807
children 707fcf42a5ae 579d1e771025 c1a7ed266c7e
line source
1 /******************************************************************************
2 * event_channel.h
3 *
4 * Event channels between domains.
5 *
6 * Copyright (c) 2003-2004, K A Fraser.
7 */
9 #ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__
10 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
12 /*
13 * EVTCHNOP_alloc_unbound: Prepare a local port for binding to <dom>.
14 * <port> may be wildcarded by setting to zero, in which case a fresh port
15 * will be allocated, and the field filled in on return.
16 */
17 #define EVTCHNOP_alloc_unbound 6
18 typedef struct evtchn_alloc_unbound {
19 /* IN parameters */
20 domid_t dom;
21 /* IN/OUT parameters */
22 u32 port;
23 } evtchn_alloc_unbound_t;
25 /*
26 * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between
27 * <dom1> and <dom2>. Either <port1> or <port2> may be wildcarded by setting to
28 * zero. On successful return both <port1> and <port2> are filled in and
29 * <dom1,port1> is fully bound to <dom2,port2>.
30 *
31 * NOTES:
32 * 1. A wildcarded port is allocated from the relevant domain's free list
33 * (i.e., some port that was previously EVTCHNSTAT_closed). However, if the
34 * remote port pair is already fully bound then a port is not allocated,
35 * and instead the existing local port is returned to the caller.
36 * 2. If the caller is unprivileged then <dom1> must be DOMID_SELF.
37 * 3. If the caller is unprivileged and <dom2,port2> is EVTCHNSTAT_closed
38 * then <dom2> must be DOMID_SELF.
39 * 4. If either port is already bound then it must be bound to the other
40 * specified domain and port (if not wildcarded).
41 * 5. If either port is awaiting binding (EVTCHNSTAT_unbound) then it must
42 * be awaiting binding to the other domain, and the other port pair must
43 * be closed or unbound.
44 */
45 #define EVTCHNOP_bind_interdomain 0
46 typedef struct evtchn_bind_interdomain {
47 /* IN parameters. */
48 domid_t dom1, dom2;
49 /* IN/OUT parameters. */
50 u32 port1, port2;
51 } evtchn_bind_interdomain_t;
53 /*
54 * EVTCHNOP_bind_virq: Bind a local event channel to IRQ <irq> on calling vcpu.
55 * NOTES:
56 * 1. A virtual IRQ may be bound to at most one event channel per vcpu.
57 * 2. The allocated event channel is bound to the calling vcpu. The binding
58 * may not be changed.
59 */
60 #define EVTCHNOP_bind_virq 1
61 typedef struct evtchn_bind_virq {
62 /* IN parameters. */
63 u32 virq;
64 /* OUT parameters. */
65 u32 port;
66 } evtchn_bind_virq_t;
68 /*
69 * EVTCHNOP_bind_pirq: Bind a local event channel to IRQ <irq>.
70 * NOTES:
71 * 1. A physical IRQ may be bound to at most one event channel per domain.
72 * 2. Only a sufficiently-privileged domain may bind to a physical IRQ.
73 */
74 #define EVTCHNOP_bind_pirq 2
75 typedef struct evtchn_bind_pirq {
76 /* IN parameters. */
77 u32 pirq;
78 #define BIND_PIRQ__WILL_SHARE 1
79 u32 flags; /* BIND_PIRQ__* */
80 /* OUT parameters. */
81 u32 port;
82 } evtchn_bind_pirq_t;
84 /*
85 * EVTCHNOP_bind_ipi: Bind a local event channel to receive events.
86 * NOTES:
87 * 1. The allocated event channel is bound to the calling vcpu. The binding
88 * may not be changed.
89 */
90 #define EVTCHNOP_bind_ipi 7
91 typedef struct evtchn_bind_ipi {
92 /* IN parameters. */
93 u32 ipi_vcpu;
94 /* OUT parameters. */
95 u32 port;
96 } evtchn_bind_ipi_t;
98 /*
99 * EVTCHNOP_close: Close the communication channel which has an endpoint at
100 * <dom, port>. If the channel is interdomain then the remote end is placed in
101 * the unbound state (EVTCHNSTAT_unbound), awaiting a new connection.
102 * NOTES:
103 * 1. <dom> may be specified as DOMID_SELF.
104 * 2. Only a sufficiently-privileged domain may close an event channel
105 * for which <dom> is not DOMID_SELF.
106 */
107 #define EVTCHNOP_close 3
108 typedef struct evtchn_close {
109 /* IN parameters. */
110 domid_t dom;
111 u32 port;
112 /* No OUT parameters. */
113 } evtchn_close_t;
115 /*
116 * EVTCHNOP_send: Send an event to the remote end of the channel whose local
117 * endpoint is <DOMID_SELF, local_port>.
118 */
119 #define EVTCHNOP_send 4
120 typedef struct evtchn_send {
121 /* IN parameters. */
122 u32 local_port;
123 /* No OUT parameters. */
124 } evtchn_send_t;
126 /*
127 * EVTCHNOP_status: Get the current status of the communication channel which
128 * has an endpoint at <dom, port>.
129 * NOTES:
130 * 1. <dom> may be specified as DOMID_SELF.
131 * 2. Only a sufficiently-privileged domain may obtain the status of an event
132 * channel for which <dom> is not DOMID_SELF.
133 */
134 #define EVTCHNOP_status 5
135 typedef struct evtchn_status {
136 /* IN parameters */
137 domid_t dom;
138 u32 port;
139 /* OUT parameters */
140 #define EVTCHNSTAT_closed 0 /* Channel is not in use. */
141 #define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/
142 #define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
143 #define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
144 #define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
145 #define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */
146 u32 status;
147 union {
148 struct {
149 domid_t dom;
150 } unbound; /* EVTCHNSTAT_unbound */
151 struct {
152 domid_t dom;
153 u32 port;
154 } interdomain; /* EVTCHNSTAT_interdomain */
155 u32 pirq; /* EVTCHNSTAT_pirq */
156 u32 virq; /* EVTCHNSTAT_virq */
157 u32 ipi_vcpu; /* EVTCHNSTAT_ipi */
158 } u;
159 } evtchn_status_t;
161 #define EVTCHNOP_rebind 8
162 typedef struct {
163 /* IN parameters. */
164 u32 port; /* 0 */
165 u32 vcpu; /* 4 */
166 } evtchn_rebind_t; /* 8 bytes */
168 typedef struct evtchn_op {
169 u32 cmd; /* EVTCHNOP_* */
170 union {
171 evtchn_alloc_unbound_t alloc_unbound;
172 evtchn_bind_interdomain_t bind_interdomain;
173 evtchn_bind_virq_t bind_virq;
174 evtchn_bind_pirq_t bind_pirq;
175 evtchn_bind_ipi_t bind_ipi;
176 evtchn_close_t close;
177 evtchn_send_t send;
178 evtchn_status_t status;
179 evtchn_rebind_t rebind;
180 } u;
181 } evtchn_op_t;
183 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */