x86/irq: Check for valid irq descriptor in check_irq_vectors_for_cpu_disable()
[linux/fpc-iii.git] / include / xen / interface / io / netif.h
blob70054cc0708d0aed1bc4fa23ce6bec09d65435b8
1 /******************************************************************************
2 * netif.h
4 * Unified network-device I/O interface for Xen guest OSes.
6 * Copyright (c) 2003-2004, Keir Fraser
7 */
9 #ifndef __XEN_PUBLIC_IO_NETIF_H__
10 #define __XEN_PUBLIC_IO_NETIF_H__
12 #include <xen/interface/io/ring.h>
13 #include <xen/interface/grant_table.h>
16 * Older implementation of Xen network frontend / backend has an
17 * implicit dependency on the MAX_SKB_FRAGS as the maximum number of
18 * ring slots a skb can use. Netfront / netback may not work as
19 * expected when frontend and backend have different MAX_SKB_FRAGS.
21 * A better approach is to add mechanism for netfront / netback to
22 * negotiate this value. However we cannot fix all possible
23 * frontends, so we need to define a value which states the minimum
24 * slots backend must support.
26 * The minimum value derives from older Linux kernel's MAX_SKB_FRAGS
27 * (18), which is proved to work with most frontends. Any new backend
28 * which doesn't negotiate with frontend should expect frontend to
29 * send a valid packet using slots up to this value.
31 #define XEN_NETIF_NR_SLOTS_MIN 18
34 * Notifications after enqueuing any type of message should be conditional on
35 * the appropriate req_event or rsp_event field in the shared ring.
36 * If the client sends notification for rx requests then it should specify
37 * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
38 * that it cannot safely queue packets (as it may not be kicked to send them).
42 * "feature-split-event-channels" is introduced to separate guest TX
43 * and RX notificaion. Backend either doesn't support this feature or
44 * advertise it via xenstore as 0 (disabled) or 1 (enabled).
46 * To make use of this feature, frontend should allocate two event
47 * channels for TX and RX, advertise them to backend as
48 * "event-channel-tx" and "event-channel-rx" respectively. If frontend
49 * doesn't want to use this feature, it just writes "event-channel"
50 * node as before.
54 * Multiple transmit and receive queues:
55 * If supported, the backend will write the key "multi-queue-max-queues" to
56 * the directory for that vif, and set its value to the maximum supported
57 * number of queues.
58 * Frontends that are aware of this feature and wish to use it can write the
59 * key "multi-queue-num-queues", set to the number they wish to use, which
60 * must be greater than zero, and no more than the value reported by the backend
61 * in "multi-queue-max-queues".
63 * Queues replicate the shared rings and event channels.
64 * "feature-split-event-channels" may optionally be used when using
65 * multiple queues, but is not mandatory.
67 * Each queue consists of one shared ring pair, i.e. there must be the same
68 * number of tx and rx rings.
70 * For frontends requesting just one queue, the usual event-channel and
71 * ring-ref keys are written as before, simplifying the backend processing
72 * to avoid distinguishing between a frontend that doesn't understand the
73 * multi-queue feature, and one that does, but requested only one queue.
75 * Frontends requesting two or more queues must not write the toplevel
76 * event-channel (or event-channel-{tx,rx}) and {tx,rx}-ring-ref keys,
77 * instead writing those keys under sub-keys having the name "queue-N" where
78 * N is the integer ID of the queue for which those keys belong. Queues
79 * are indexed from zero. For example, a frontend with two queues and split
80 * event channels must write the following set of queue-related keys:
82 * /local/domain/1/device/vif/0/multi-queue-num-queues = "2"
83 * /local/domain/1/device/vif/0/queue-0 = ""
84 * /local/domain/1/device/vif/0/queue-0/tx-ring-ref = "<ring-ref-tx0>"
85 * /local/domain/1/device/vif/0/queue-0/rx-ring-ref = "<ring-ref-rx0>"
86 * /local/domain/1/device/vif/0/queue-0/event-channel-tx = "<evtchn-tx0>"
87 * /local/domain/1/device/vif/0/queue-0/event-channel-rx = "<evtchn-rx0>"
88 * /local/domain/1/device/vif/0/queue-1 = ""
89 * /local/domain/1/device/vif/0/queue-1/tx-ring-ref = "<ring-ref-tx1>"
90 * /local/domain/1/device/vif/0/queue-1/rx-ring-ref = "<ring-ref-rx1"
91 * /local/domain/1/device/vif/0/queue-1/event-channel-tx = "<evtchn-tx1>"
92 * /local/domain/1/device/vif/0/queue-1/event-channel-rx = "<evtchn-rx1>"
94 * If there is any inconsistency in the XenStore data, the backend may
95 * choose not to connect any queues, instead treating the request as an
96 * error. This includes scenarios where more (or fewer) queues were
97 * requested than the frontend provided details for.
99 * Mapping of packets to queues is considered to be a function of the
100 * transmitting system (backend or frontend) and is not negotiated
101 * between the two. Guests are free to transmit packets on any queue
102 * they choose, provided it has been set up correctly. Guests must be
103 * prepared to receive packets on any queue they have requested be set up.
107 * "feature-no-csum-offload" should be used to turn IPv4 TCP/UDP checksum
108 * offload off or on. If it is missing then the feature is assumed to be on.
109 * "feature-ipv6-csum-offload" should be used to turn IPv6 TCP/UDP checksum
110 * offload on or off. If it is missing then the feature is assumed to be off.
114 * "feature-gso-tcpv4" and "feature-gso-tcpv6" advertise the capability to
115 * handle large TCP packets (in IPv4 or IPv6 form respectively). Neither
116 * frontends nor backends are assumed to be capable unless the flags are
117 * present.
121 * This is the 'wire' format for packets:
122 * Request 1: xen_netif_tx_request -- XEN_NETTXF_* (any flags)
123 * [Request 2: xen_netif_extra_info] (only if request 1 has XEN_NETTXF_extra_info)
124 * [Request 3: xen_netif_extra_info] (only if request 2 has XEN_NETIF_EXTRA_MORE)
125 * Request 4: xen_netif_tx_request -- XEN_NETTXF_more_data
126 * Request 5: xen_netif_tx_request -- XEN_NETTXF_more_data
127 * ...
128 * Request N: xen_netif_tx_request -- 0
131 /* Protocol checksum field is blank in the packet (hardware offload)? */
132 #define _XEN_NETTXF_csum_blank (0)
133 #define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank)
135 /* Packet data has been validated against protocol checksum. */
136 #define _XEN_NETTXF_data_validated (1)
137 #define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated)
139 /* Packet continues in the next request descriptor. */
140 #define _XEN_NETTXF_more_data (2)
141 #define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data)
143 /* Packet to be followed by extra descriptor(s). */
144 #define _XEN_NETTXF_extra_info (3)
145 #define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info)
147 #define XEN_NETIF_MAX_TX_SIZE 0xFFFF
148 struct xen_netif_tx_request {
149 grant_ref_t gref; /* Reference to buffer page */
150 uint16_t offset; /* Offset within buffer page */
151 uint16_t flags; /* XEN_NETTXF_* */
152 uint16_t id; /* Echoed in response message. */
153 uint16_t size; /* Packet size in bytes. */
156 /* Types of xen_netif_extra_info descriptors. */
157 #define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */
158 #define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */
159 #define XEN_NETIF_EXTRA_TYPE_MAX (2)
161 /* xen_netif_extra_info flags. */
162 #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
163 #define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
165 /* GSO types */
166 #define XEN_NETIF_GSO_TYPE_NONE (0)
167 #define XEN_NETIF_GSO_TYPE_TCPV4 (1)
168 #define XEN_NETIF_GSO_TYPE_TCPV6 (2)
171 * This structure needs to fit within both netif_tx_request and
172 * netif_rx_response for compatibility.
174 struct xen_netif_extra_info {
175 uint8_t type; /* XEN_NETIF_EXTRA_TYPE_* */
176 uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */
178 union {
179 struct {
181 * Maximum payload size of each segment. For
182 * example, for TCP this is just the path MSS.
184 uint16_t size;
187 * GSO type. This determines the protocol of
188 * the packet and any extra features required
189 * to segment the packet properly.
191 uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
193 /* Future expansion. */
194 uint8_t pad;
197 * GSO features. This specifies any extra GSO
198 * features required to process this packet,
199 * such as ECN support for TCPv4.
201 uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
202 } gso;
204 uint16_t pad[3];
205 } u;
208 struct xen_netif_tx_response {
209 uint16_t id;
210 int16_t status; /* XEN_NETIF_RSP_* */
213 struct xen_netif_rx_request {
214 uint16_t id; /* Echoed in response message. */
215 grant_ref_t gref; /* Reference to incoming granted frame */
218 /* Packet data has been validated against protocol checksum. */
219 #define _XEN_NETRXF_data_validated (0)
220 #define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated)
222 /* Protocol checksum field is blank in the packet (hardware offload)? */
223 #define _XEN_NETRXF_csum_blank (1)
224 #define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank)
226 /* Packet continues in the next request descriptor. */
227 #define _XEN_NETRXF_more_data (2)
228 #define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data)
230 /* Packet to be followed by extra descriptor(s). */
231 #define _XEN_NETRXF_extra_info (3)
232 #define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info)
234 /* GSO Prefix descriptor. */
235 #define _XEN_NETRXF_gso_prefix (4)
236 #define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix)
238 struct xen_netif_rx_response {
239 uint16_t id;
240 uint16_t offset; /* Offset in page of start of received packet */
241 uint16_t flags; /* XEN_NETRXF_* */
242 int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
246 * Generate netif ring structures and types.
249 DEFINE_RING_TYPES(xen_netif_tx,
250 struct xen_netif_tx_request,
251 struct xen_netif_tx_response);
252 DEFINE_RING_TYPES(xen_netif_rx,
253 struct xen_netif_rx_request,
254 struct xen_netif_rx_response);
256 #define XEN_NETIF_RSP_DROPPED -2
257 #define XEN_NETIF_RSP_ERROR -1
258 #define XEN_NETIF_RSP_OKAY 0
259 /* No response: used for auxiliary requests (e.g., xen_netif_extra_info). */
260 #define XEN_NETIF_RSP_NULL 1
262 #endif