2 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
13 * NON INFRINGEMENT. See the GNU General Public License for more
20 #include <linux/types.h>
22 #include <linux/uuid.h>
24 #define SIGNATURE_16(A, B) ((A) | ((B) << 8))
25 #define SIGNATURE_32(A, B, C, D) \
26 (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
27 #define VISOR_CHANNEL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L')
30 * enum channel_serverstate
31 * @CHANNELSRV_UNINITIALIZED: Channel is in an undefined state.
32 * @CHANNELSRV_READY: Channel has been initialized by server.
34 enum channel_serverstate {
35 CHANNELSRV_UNINITIALIZED = 0,
40 * enum channel_clientstate
41 * @CHANNELCLI_DETACHED:
42 * @CHANNELCLI_DISABLED: Client can see channel but is NOT allowed to use it
43 * unless given TBD* explicit request
44 * (should actually be < DETACHED).
45 * @CHANNELCLI_ATTACHING: Legacy EFI client request for EFI server to attach.
46 * @CHANNELCLI_ATTACHED: Idle, but client may want to use channel any time.
47 * @CHANNELCLI_BUSY: Client either wants to use or is using channel.
48 * @CHANNELCLI_OWNED: "No worries" state - client can access channel
51 enum channel_clientstate {
52 CHANNELCLI_DETACHED = 0,
53 CHANNELCLI_DISABLED = 1,
54 CHANNELCLI_ATTACHING = 2,
55 CHANNELCLI_ATTACHED = 3,
61 * Values for VISOR_CHANNEL_PROTOCOL.Features: This define exists so that
62 * a guest can look at the FeatureFlags in the io channel, and configure the
63 * driver to use interrupts or not based on this setting. All feature bits for
64 * all channels should be defined here. The io channel feature bits are defined
67 #define VISOR_DRIVER_ENABLES_INTS (0x1ULL << 1)
68 #define VISOR_CHANNEL_IS_POLLING (0x1ULL << 3)
69 #define VISOR_IOVM_OK_DRIVER_DISABLING_INTS (0x1ULL << 4)
70 #define VISOR_DRIVER_DISABLES_INTS (0x1ULL << 5)
71 #define VISOR_DRIVER_ENHANCED_RCVBUF_CHECKING (0x1ULL << 6)
74 * struct channel_header - Common Channel Header
75 * @signature: Signature.
76 * @legacy_state: DEPRECATED - being replaced by.
77 * @header_size: sizeof(struct channel_header).
78 * @size: Total size of this channel in bytes.
79 * @features: Flags to modify behavior.
80 * @chtype: Channel type: data, bus, control, etc..
81 * @partition_handle: ID of guest partition.
82 * @handle: Device number of this channel in client.
83 * @ch_space_offset: Offset in bytes to channel specific area.
84 * @version_id: Struct channel_header Version ID.
85 * @partition_index: Index of guest partition.
86 * @zone_uuid: Guid of Channel's zone.
87 * @cli_str_offset: Offset from channel header to null-terminated
88 * ClientString (0 if ClientString not present).
89 * @cli_state_boot: CHANNEL_CLIENTSTATE of pre-boot EFI client of this
91 * @cmd_state_cli: CHANNEL_COMMANDSTATE (overloaded in Windows drivers, see
92 * ServerStateUp, ServerStateDown, etc).
93 * @cli_state_os: CHANNEL_CLIENTSTATE of Guest OS client of this channel.
94 * @ch_characteristic: CHANNEL_CHARACTERISTIC_<xxx>.
95 * @cmd_state_srv: CHANNEL_COMMANDSTATE (overloaded in Windows drivers, see
96 * ServerStateUp, ServerStateDown, etc).
97 * @srv_state: CHANNEL_SERVERSTATE.
98 * @cli_error_boot: Bits to indicate err states for boot clients, so err
99 * messages can be throttled.
100 * @cli_error_os: Bits to indicate err states for OS clients, so err
101 * messages can be throttled.
102 * @filler: Pad out to 128 byte cacheline.
103 * @recover_channel: Please add all new single-byte values below here.
105 struct channel_header {
108 /* SrvState, CliStateBoot, and CliStateOS below */
113 u64 partition_handle;
123 u32 ch_characteristic;
132 #define VISOR_CHANNEL_ENABLE_INTS (0x1ULL << 0)
135 * struct signal_queue_header - Subheader for the Signal Type variation of the
137 * @version: SIGNAL_QUEUE_HEADER Version ID.
138 * @chtype: Queue type: storage, network.
139 * @size: Total size of this queue in bytes.
140 * @sig_base_offset: Offset to signal queue area.
141 * @features: Flags to modify behavior.
142 * @num_sent: Total # of signals placed in this queue.
143 * @num_overflows: Total # of inserts failed due to full queue.
144 * @signal_size: Total size of a signal for this queue.
145 * @max_slots: Max # of slots in queue, 1 slot is always empty.
146 * @max_signals: Max # of signals in queue (MaxSignalSlots-1).
147 * @head: Queue head signal #.
148 * @num_received: Total # of signals removed from this queue.
149 * @tail: Queue tail signal.
150 * @reserved1: Reserved field.
151 * @reserved2: Reserved field.
153 * @num_irq_received: Total # of Interrupts received. This is incremented by the
154 * ISR in the guest windows driver.
155 * @num_empty: Number of times that visor_signal_remove is called and
156 * returned Empty Status.
157 * @errorflags: Error bits set during SignalReinit to denote trouble with
159 * @filler: Pad out to 64 byte cacheline.
161 struct signal_queue_header {
180 u64 num_irq_received;
187 /* {414815ed-c58c-11da-95a9-00e08161165f} */
188 #define VISOR_VHBA_CHANNEL_GUID \
189 GUID_INIT(0x414815ed, 0xc58c, 0x11da, \
190 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
191 #define VISOR_VHBA_CHANNEL_GUID_STR \
192 "414815ed-c58c-11da-95a9-00e08161165f"