staging: unisys: visorchannel: Make visorchannel_create take a gfp_t
[linux-2.6-block.git] / drivers / staging / unisys / common-spar / include / channels / controlvmchannel.h
1 /* Copyright (C) 2010 - 2013 UNISYS CORPORATION
2  * All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or (at
7  * your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12  * NON INFRINGEMENT.  See the GNU General Public License for more
13  * details.
14  */
15
16 #ifndef __CONTROLVMCHANNEL_H__
17 #define __CONTROLVMCHANNEL_H__
18
19 #include <linux/uuid.h>
20 #include "channel.h"
21 #include "controlframework.h"
22
23 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
24 #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID    \
25                 UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
26                         0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
27
28 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
29         ULTRA_CHANNEL_PROTOCOL_SIGNATURE
30 #define CONTROLVM_MESSAGE_MAX 64
31
32 /* Must increment this whenever you insert or delete fields within
33  * this channel struct.  Also increment whenever you change the meaning
34  * of fields within this channel struct so as to break pre-existing
35  * software.  Note that you can usually add fields to the END of the
36  * channel struct withOUT needing to increment this.
37  */
38 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1
39
40 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch)           \
41         spar_check_channel_client(ch, \
42                 SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
43                 "controlvm", \
44                 sizeof(struct spar_controlvm_channel_protocol), \
45                 ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
46                 ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
47
48 #define MAX_SERIAL_NUM  32
49
50 /* Defines for various channel queues */
51 #define CONTROLVM_QUEUE_REQUEST         0
52 #define CONTROLVM_QUEUE_RESPONSE        1
53 #define CONTROLVM_QUEUE_EVENT           2
54 #define CONTROLVM_QUEUE_ACK             3
55
56 /* Max num of messages stored during IOVM creation to be reused after crash */
57 #define CONTROLVM_CRASHMSG_MAX          2
58
59 /* Ids for commands that may appear in either queue of a ControlVm channel.
60  *
61  *  Commands that are initiated by the command partition (CP), by an IO or
62  *  console service partition (SP), or by a guest partition (GP)are:
63  *  - issued on the RequestQueue queue (q #0) in the ControlVm channel
64  *  - responded to on the ResponseQueue queue (q #1) in the ControlVm channel
65  *
66  *  Events that are initiated by an IO or console service partition (SP) or
67  *  by a guest partition (GP) are:
68  *  - issued on the EventQueue queue (q #2) in the ControlVm channel
69  *  - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
70  */
71 enum controlvm_id {
72         CONTROLVM_INVALID = 0,
73         /* SWITCH commands required Parameter: SwitchNumber */
74         /* BUS commands required Parameter: BusNumber */
75         CONTROLVM_BUS_CREATE = 0x101,                   /* CP --> SP, GP */
76         CONTROLVM_BUS_DESTROY = 0x102,                  /* CP --> SP, GP */
77         CONTROLVM_BUS_CONFIGURE = 0x104,                /* CP --> SP */
78         CONTROLVM_BUS_CHANGESTATE = 0x105,              /* CP --> SP, GP */
79         CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106,        /* SP, GP --> CP */
80 /* DEVICE commands required Parameter: BusNumber, DeviceNumber */
81
82         CONTROLVM_DEVICE_CREATE = 0x201,                /* CP --> SP, GP */
83         CONTROLVM_DEVICE_DESTROY = 0x202,               /* CP --> SP, GP */
84         CONTROLVM_DEVICE_CONFIGURE = 0x203,             /* CP --> SP */
85         CONTROLVM_DEVICE_CHANGESTATE = 0x204,           /* CP --> SP, GP */
86         CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205,     /* SP, GP --> CP */
87         CONTROLVM_DEVICE_RECONFIGURE = 0x206,           /* CP --> Boot */
88 /* CHIPSET commands */
89         CONTROLVM_CHIPSET_INIT = 0x301,                 /* CP --> SP, GP */
90         CONTROLVM_CHIPSET_STOP = 0x302,                 /* CP --> SP, GP */
91         CONTROLVM_CHIPSET_READY = 0x304,                /* CP --> SP */
92         CONTROLVM_CHIPSET_SELFTEST = 0x305,             /* CP --> SP */
93
94 };
95
96 struct irq_info {
97         u64 reserved1;
98
99          /* specifies interrupt handle. It is used to retrieve the
100           *   corresponding interrupt pin from Monitor; and the
101           *   interrupt pin is used to connect to the corresponding
102           *   interrupt.  Used by IOPart-GP only.
103           */
104         u64 recv_irq_handle;
105
106          /* specifies interrupt vector. It, interrupt pin, and shared are
107           *   used to connect to the corresponding interrupt.  Used by
108           *   IOPart-GP only.
109           */
110         u32 recv_irq_vector;
111
112     /* specifies if the recvInterrupt is shared.  It, interrupt pin
113      * and vector are used to connect to 0 = not shared; 1 = shared.
114      * the corresponding interrupt.  Used by IOPart-GP only.
115      */
116         u8 recv_irq_shared;
117         u8 reserved[3]; /* Natural alignment purposes */
118 };
119
120 struct pci_id {
121         u16 domain;
122         u8 bus;
123         u8 slot;
124         u8 func;
125         u8 reserved[3]; /* Natural alignment purposes */
126 };
127
128 struct efi_spar_indication  {
129         u64 boot_to_fw_ui:1;            /* Bit 0: Stop in uefi ui */
130         u64 clear_nvram:1;              /* Bit 1: Clear NVRAM */
131         u64 clear_cmos:1;               /* Bit 2: Clear CMOS */
132         u64 boot_to_tool:1;             /* Bit 3: Run install tool */
133         /* remaining bits are available */
134 };
135
136 enum ultra_chipset_feature {
137         ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
138         ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
139 };
140
141 /* This is the common structure that is at the beginning of every
142  *  ControlVm message (both commands and responses) in any ControlVm
143  *  queue.  Commands are easily distinguished from responses by
144  *  looking at the flags.response field.
145  */
146 struct controlvm_message_header  {
147         u32 id;         /* See CONTROLVM_ID. */
148         /* For requests, indicates the message type. */
149         /* For responses, indicates the type of message we are responding to. */
150
151         u32 message_size;       /* Includes size of this struct + size
152                                  * of message */
153         u32 segment_index;      /* Index of segment containing Vm
154                                  * message/information */
155         u32 completion_status;  /* Error status code or result of
156                                  * message completion */
157         struct  {
158                 u32 failed:1;              /* =1 in a response to * signify
159                                             * failure */
160                 u32 response_expected:1;   /* =1 in all messages that expect a
161                                             * response (Control ignores this
162                                             * bit) */
163                 u32 server:1;              /* =1 in all bus & device-related
164                                             * messages where the message
165                                             * receiver is to act as the bus or
166                                             * device server */
167                 u32 test_message:1;        /* =1 for testing use only
168                                             * (Control and Command ignore this
169                                             * bit) */
170                 u32 partial_completion:1;  /* =1 if there are forthcoming
171                                             * responses/acks associated
172                                             * with this message */
173                 u32 preserve:1;            /* =1 this is to let us know to
174                                             * preserve channel contents
175                                             * (for running guests)*/
176                 u32 writer_in_diag:1;      /* =1 the DiagWriter is active in the
177                                             * Diagnostic Partition*/
178         } flags;
179         u32 reserved;           /* Natural alignment */
180         u64 message_handle;     /* Identifies the particular message instance,
181                                  * and is used to match particular */
182         /* request instances with the corresponding response instance. */
183         u64 payload_vm_offset;  /* Offset of payload area from start of this
184                                  * instance of ControlVm segment */
185         u32 payload_max_bytes;  /* Maximum bytes allocated in payload
186                                  * area of ControlVm segment */
187         u32 payload_bytes;      /* Actual number of bytes of payload
188                                  * area to copy between IO/Command; */
189         /* if non-zero, there is a payload to copy. */
190 };
191
192 struct controlvm_packet_device_create  {
193         u32 bus_no;             /* bus # (0..n-1) from the msg receiver's end */
194         u32 dev_no;             /* bus-relative (0..n-1) device number */
195         u64 channel_addr;       /* Guest physical address of the channel, which
196                                  * can be dereferenced by the receiver of this
197                                  * ControlVm command */
198         u64 channel_bytes;      /* specifies size of the channel in bytes */
199         uuid_le data_type_uuid; /* specifies format of data in channel */
200         uuid_le dev_inst_uuid;  /* instance guid for the device */
201         struct irq_info intr;   /* specifies interrupt information */
202 };      /* for CONTROLVM_DEVICE_CREATE */
203
204 struct controlvm_packet_device_configure  {
205         u32 bus_no;           /* bus # (0..n-1) from the msg
206                                * receiver's perspective */
207         /* Control uses header SegmentIndex field to access bus number... */
208         u32 dev_no;           /* bus-relative (0..n-1) device number */
209 } ;     /* for CONTROLVM_DEVICE_CONFIGURE */
210
211 struct controlvm_message_device_create {
212         struct controlvm_message_header header;
213         struct controlvm_packet_device_create packet;
214 };      /* total 128 bytes */
215
216 struct controlvm_message_device_configure  {
217         struct controlvm_message_header header;
218         struct controlvm_packet_device_configure packet;
219 };      /* total 56 bytes */
220
221 /* This is the format for a message in any ControlVm queue. */
222 struct controlvm_message_packet  {
223         union  {
224                 struct  {
225                         u32 bus_no;     /* bus # (0..n-1) from the msg
226                                          * receiver's perspective */
227                         u32 dev_count;  /* indicates the max number of
228                                          * devices on this bus */
229                         u64 channel_addr;       /* Guest physical address of
230                                                  * the channel, which can be
231                                                  * dereferenced by the receiver
232                                                  * of this ControlVm command */
233                         u64 channel_bytes;      /* size of the channel */
234                         uuid_le bus_data_type_uuid;     /* indicates format of
235                                                          * data in bus channel*/
236                         uuid_le bus_inst_uuid;  /* instance uuid for the bus */
237                 } create_bus;   /* for CONTROLVM_BUS_CREATE */
238                 struct  {
239                         u32 bus_no;     /* bus # (0..n-1) from the msg
240                                          * receiver's perspective */
241                         u32 reserved;   /* Natural alignment purposes */
242                 } destroy_bus;  /* for CONTROLVM_BUS_DESTROY */
243                 struct  {
244                         u32 bus_no;     /* bus # (0..n-1) from the receiver's
245                                          * perspective */
246                         u32 reserved1;  /* for alignment purposes */
247                         u64 guest_handle;       /* This is used to convert
248                                                  * guest physical address to
249                                                  * physical address */
250                         u64 recv_bus_irq_handle;
251                                 /* specifies interrupt info. It is used by SP
252                                  * to register to receive interrupts from the
253                                  * CP. This interrupt is used for bus level
254                                  * notifications.  The corresponding
255                                  * sendBusInterruptHandle is kept in CP. */
256                 } configure_bus;        /* for CONTROLVM_BUS_CONFIGURE */
257                 /* for CONTROLVM_DEVICE_CREATE */
258                 struct controlvm_packet_device_create create_device;
259                 struct  {
260                         u32 bus_no;     /* bus # (0..n-1) from the msg
261                                          * receiver's perspective */
262                         u32 dev_no;     /* bus-relative (0..n-1) device # */
263                 } destroy_device;       /* for CONTROLVM_DEVICE_DESTROY */
264                 /* for CONTROLVM_DEVICE_CONFIGURE */
265                 struct controlvm_packet_device_configure configure_device;
266                 struct  {
267                         u32 bus_no;     /* bus # (0..n-1) from the msg
268                                          * receiver's perspective */
269                         u32 dev_no;     /* bus-relative (0..n-1) device # */
270                 } reconfigure_device;   /* for CONTROLVM_DEVICE_RECONFIGURE */
271                 struct  {
272                         u32 bus_no;
273                         struct spar_segment_state state;
274                         u8 reserved[2]; /* Natural alignment purposes */
275                 } bus_change_state;     /* for CONTROLVM_BUS_CHANGESTATE */
276                 struct  {
277                         u32 bus_no;
278                         u32 dev_no;
279                         struct spar_segment_state state;
280                         struct  {
281                                 u32 phys_device:1;      /* =1 if message is for
282                                                          * a physical device */
283                         } flags;
284                         u8 reserved[2]; /* Natural alignment purposes */
285                 } device_change_state;  /* for CONTROLVM_DEVICE_CHANGESTATE */
286                 struct  {
287                         u32 bus_no;
288                         u32 dev_no;
289                         struct spar_segment_state state;
290                         u8 reserved[6]; /* Natural alignment purposes */
291                 } device_change_state_event;
292                         /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
293                 struct  {
294                         u32 bus_count;  /* indicates the max number of busses */
295                         u32 switch_count; /* indicates the max number of
296                                            * switches if a service partition */
297                         enum ultra_chipset_feature features;
298                         u32 platform_number;    /* Platform Number */
299                 } init_chipset; /* for CONTROLVM_CHIPSET_INIT */
300                 struct  {
301                         u32 options;    /* reserved */
302                         u32 test;       /* bit 0 set to run embedded selftest */
303                 } chipset_selftest;     /* for CONTROLVM_CHIPSET_SELFTEST */
304                 u64 addr;       /* a physical address of something, that can be
305                                  * dereferenced by the receiver of this
306                                  * ControlVm command (depends on command id) */
307                 u64 handle;     /* a handle of something (depends on command
308                                  * id) */
309         };
310 };
311
312 /* All messages in any ControlVm queue have this layout. */
313 struct controlvm_message {
314         struct controlvm_message_header hdr;
315         struct controlvm_message_packet cmd;
316 };
317
318 struct spar_controlvm_channel_protocol {
319         struct channel_header header;
320         u64 gp_controlvm;       /* guest phys addr of this channel */
321         u64 gp_partition_tables;/* guest phys addr of partition tables */
322         u64 gp_diag_guest;      /* guest phys addr of diagnostic channel */
323         u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */
324         u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */
325         u64 gp_acpi_table;      /* guest phys addr of acpi table */
326         u64 gp_control_channel;/* guest phys addr of control channel */
327         u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */
328         u64 gp_nvram;   /* guest phys addr of NVRAM channel */
329         u64 request_payload_offset;     /* Offset to request payload area */
330         u64 event_payload_offset;       /* Offset to event payload area */
331         u32 request_payload_bytes;      /* Bytes available in request payload
332                                          * area */
333         u32 event_payload_bytes;/* Bytes available in event payload area */
334         u32 control_channel_bytes;
335         u32 nvram_channel_bytes;        /* Bytes in PartitionNvram segment */
336         u32 message_bytes;              /* sizeof(CONTROLVM_MESSAGE) */
337         u32 message_count;              /* CONTROLVM_MESSAGE_MAX */
338         u64 gp_smbios_table;            /* guest phys addr of SMBIOS tables */
339         u64 gp_physical_smbios_table;   /* guest phys addr of SMBIOS table  */
340         /* ULTRA_MAX_GUESTS_PER_SERVICE */
341         char gp_reserved[2688];
342
343         /* guest physical address of EFI firmware image base  */
344         u64 virtual_guest_firmware_image_base;
345
346         /* guest physical address of EFI firmware entry point  */
347         u64 virtual_guest_firmware_entry_point;
348
349         /* guest EFI firmware image size  */
350         u64 virtual_guest_firmware_image_size;
351
352         /* GPA = 1MB where EFI firmware image is copied to  */
353         u64 virtual_guest_firmware_boot_base;
354         u64 virtual_guest_image_base;
355         u64 virtual_guest_image_size;
356         u64 prototype_control_channel_offset;
357         u64 virtual_guest_partition_handle;
358
359         u16 restore_action;     /* Restore Action field to restore the guest
360                                  * partition */
361         u16 dump_action;        /* For Windows guests it shows if the visordisk
362                                  * is running in dump mode */
363         u16 nvram_fail_count;
364         u16 saved_crash_message_count;  /* = CONTROLVM_CRASHMSG_MAX */
365         u32 saved_crash_message_offset; /* Offset to request payload area needed
366                                          * for crash dump */
367         u32 installation_error; /* Type of error encountered during
368                                  * installation */
369         u32 installation_text_id;       /* Id of string to display */
370         u16 installation_remaining_steps;/* Number of remaining installation
371                                           * steps (for progress bars) */
372         u8 tool_action;         /* ULTRA_TOOL_ACTIONS Installation Action
373                                  * field */
374         u8 reserved;            /* alignment */
375         struct efi_spar_indication efi_spar_ind;
376         struct efi_spar_indication efi_spar_ind_supported;
377         u32 sp_reserved;
378         u8 reserved2[28];       /* Force signals to begin on 128-byte cache
379                                  * line */
380         struct signal_queue_header request_queue;/* Service or guest partition
381                                                   * uses this queue to send
382                                                   * requests to Control */
383         struct signal_queue_header response_queue;/* Control uses this queue to
384                                                    * respond to service or guest
385                                                    * partition requests */
386         struct signal_queue_header event_queue; /* Control uses this queue to
387                                                  * send events to service or
388                                                  * guest partition */
389         struct signal_queue_header event_ack_queue;/* Service or guest partition
390                                                     * uses this queue to ack
391                                                     * Control events */
392
393          /* Request fixed-size message pool - does not include payload */
394          struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX];
395
396          /* Response fixed-size message pool - does not include payload */
397          struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX];
398
399          /* Event fixed-size message pool - does not include payload */
400          struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX];
401
402          /* Ack fixed-size message pool - does not include payload */
403          struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX];
404
405          /* Message stored during IOVM creation to be reused after crash */
406          struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
407 };
408
409 /* Offsets for VM channel attributes */
410 #define VM_CH_REQ_QUEUE_OFFSET \
411         offsetof(struct spar_controlvm_channel_protocol, request_queue)
412 #define VM_CH_RESP_QUEUE_OFFSET \
413         offsetof(struct spar_controlvm_channel_protocol, response_queue)
414 #define VM_CH_EVENT_QUEUE_OFFSET \
415         offsetof(struct spar_controlvm_channel_protocol, event_queue)
416 #define VM_CH_ACK_QUEUE_OFFSET \
417         offsetof(struct spar_controlvm_channel_protocol, event_ack_queue)
418 #define VM_CH_REQ_MSG_OFFSET \
419         offsetof(struct spar_controlvm_channel_protocol, request_msg)
420 #define VM_CH_RESP_MSG_OFFSET \
421         offsetof(struct spar_controlvm_channel_protocol, response_msg)
422 #define VM_CH_EVENT_MSG_OFFSET \
423         offsetof(struct spar_controlvm_channel_protocol, event_msg)
424 #define VM_CH_ACK_MSG_OFFSET \
425         offsetof(struct spar_controlvm_channel_protocol, event_ack_msg)
426 #define VM_CH_CRASH_MSG_OFFSET \
427         offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg)
428
429 /* The following header will be located at the beginning of PayloadVmOffset for
430  * various ControlVm commands. The receiver of a ControlVm command with a
431  * PayloadVmOffset will dereference this address and then use connection_offset,
432  * initiator_offset, and target_offset to get the location of UTF-8 formatted
433  * strings that can be parsed to obtain command-specific information. The value
434  * of total_length should equal PayloadBytes. The format of the strings at
435  * PayloadVmOffset will take different forms depending on the message.
436  */
437 struct spar_controlvm_parameters_header {
438         u32 total_length;
439         u32 header_length;
440         u32 connection_offset;
441         u32 connection_length;
442         u32 initiator_offset;
443         u32 initiator_length;
444         u32 target_offset;
445         u32 target_length;
446         u32 client_offset;
447         u32 client_length;
448         u32 name_offset;
449         u32 name_length;
450         uuid_le id;
451         u32 revision;
452         u32 reserved;           /* Natural alignment */
453 };
454
455 #endif                          /* __CONTROLVMCHANNEL_H__ */