xref: /qemu/include/hw/xen/interface/io/netif.h (revision a3434a2d56aee3018f4a0f55c7e0f0cda11f3d9e)
1*a3434a2dSAnthony PERARD /******************************************************************************
2*a3434a2dSAnthony PERARD  * netif.h
3*a3434a2dSAnthony PERARD  *
4*a3434a2dSAnthony PERARD  * Unified network-device I/O interface for Xen guest OSes.
5*a3434a2dSAnthony PERARD  *
6*a3434a2dSAnthony PERARD  * Permission is hereby granted, free of charge, to any person obtaining a copy
7*a3434a2dSAnthony PERARD  * of this software and associated documentation files (the "Software"), to
8*a3434a2dSAnthony PERARD  * deal in the Software without restriction, including without limitation the
9*a3434a2dSAnthony PERARD  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*a3434a2dSAnthony PERARD  * sell copies of the Software, and to permit persons to whom the Software is
11*a3434a2dSAnthony PERARD  * furnished to do so, subject to the following conditions:
12*a3434a2dSAnthony PERARD  *
13*a3434a2dSAnthony PERARD  * The above copyright notice and this permission notice shall be included in
14*a3434a2dSAnthony PERARD  * all copies or substantial portions of the Software.
15*a3434a2dSAnthony PERARD  *
16*a3434a2dSAnthony PERARD  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*a3434a2dSAnthony PERARD  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*a3434a2dSAnthony PERARD  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*a3434a2dSAnthony PERARD  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*a3434a2dSAnthony PERARD  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21*a3434a2dSAnthony PERARD  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22*a3434a2dSAnthony PERARD  * DEALINGS IN THE SOFTWARE.
23*a3434a2dSAnthony PERARD  *
24*a3434a2dSAnthony PERARD  * Copyright (c) 2003-2004, Keir Fraser
25*a3434a2dSAnthony PERARD  */
26*a3434a2dSAnthony PERARD 
27*a3434a2dSAnthony PERARD #ifndef __XEN_PUBLIC_IO_NETIF_H__
28*a3434a2dSAnthony PERARD #define __XEN_PUBLIC_IO_NETIF_H__
29*a3434a2dSAnthony PERARD 
30*a3434a2dSAnthony PERARD #include "ring.h"
31*a3434a2dSAnthony PERARD #include "../grant_table.h"
32*a3434a2dSAnthony PERARD 
33*a3434a2dSAnthony PERARD /*
34*a3434a2dSAnthony PERARD  * Older implementation of Xen network frontend / backend has an
35*a3434a2dSAnthony PERARD  * implicit dependency on the MAX_SKB_FRAGS as the maximum number of
36*a3434a2dSAnthony PERARD  * ring slots a skb can use. Netfront / netback may not work as
37*a3434a2dSAnthony PERARD  * expected when frontend and backend have different MAX_SKB_FRAGS.
38*a3434a2dSAnthony PERARD  *
39*a3434a2dSAnthony PERARD  * A better approach is to add mechanism for netfront / netback to
40*a3434a2dSAnthony PERARD  * negotiate this value. However we cannot fix all possible
41*a3434a2dSAnthony PERARD  * frontends, so we need to define a value which states the minimum
42*a3434a2dSAnthony PERARD  * slots backend must support.
43*a3434a2dSAnthony PERARD  *
44*a3434a2dSAnthony PERARD  * The minimum value derives from older Linux kernel's MAX_SKB_FRAGS
45*a3434a2dSAnthony PERARD  * (18), which is proved to work with most frontends. Any new backend
46*a3434a2dSAnthony PERARD  * which doesn't negotiate with frontend should expect frontend to
47*a3434a2dSAnthony PERARD  * send a valid packet using slots up to this value.
48*a3434a2dSAnthony PERARD  */
49*a3434a2dSAnthony PERARD #define XEN_NETIF_NR_SLOTS_MIN 18
50*a3434a2dSAnthony PERARD 
51*a3434a2dSAnthony PERARD /*
52*a3434a2dSAnthony PERARD  * Notifications after enqueuing any type of message should be conditional on
53*a3434a2dSAnthony PERARD  * the appropriate req_event or rsp_event field in the shared ring.
54*a3434a2dSAnthony PERARD  * If the client sends notification for rx requests then it should specify
55*a3434a2dSAnthony PERARD  * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
56*a3434a2dSAnthony PERARD  * that it cannot safely queue packets (as it may not be kicked to send them).
57*a3434a2dSAnthony PERARD  */
58*a3434a2dSAnthony PERARD 
59*a3434a2dSAnthony PERARD /*
60*a3434a2dSAnthony PERARD  * "feature-split-event-channels" is introduced to separate guest TX
61*a3434a2dSAnthony PERARD  * and RX notification. Backend either doesn't support this feature or
62*a3434a2dSAnthony PERARD  * advertises it via xenstore as 0 (disabled) or 1 (enabled).
63*a3434a2dSAnthony PERARD  *
64*a3434a2dSAnthony PERARD  * To make use of this feature, frontend should allocate two event
65*a3434a2dSAnthony PERARD  * channels for TX and RX, advertise them to backend as
66*a3434a2dSAnthony PERARD  * "event-channel-tx" and "event-channel-rx" respectively. If frontend
67*a3434a2dSAnthony PERARD  * doesn't want to use this feature, it just writes "event-channel"
68*a3434a2dSAnthony PERARD  * node as before.
69*a3434a2dSAnthony PERARD  */
70*a3434a2dSAnthony PERARD 
71*a3434a2dSAnthony PERARD /*
72*a3434a2dSAnthony PERARD  * Multiple transmit and receive queues:
73*a3434a2dSAnthony PERARD  * If supported, the backend will write the key "multi-queue-max-queues" to
74*a3434a2dSAnthony PERARD  * the directory for that vif, and set its value to the maximum supported
75*a3434a2dSAnthony PERARD  * number of queues.
76*a3434a2dSAnthony PERARD  * Frontends that are aware of this feature and wish to use it can write the
77*a3434a2dSAnthony PERARD  * key "multi-queue-num-queues", set to the number they wish to use, which
78*a3434a2dSAnthony PERARD  * must be greater than zero, and no more than the value reported by the backend
79*a3434a2dSAnthony PERARD  * in "multi-queue-max-queues".
80*a3434a2dSAnthony PERARD  *
81*a3434a2dSAnthony PERARD  * Queues replicate the shared rings and event channels.
82*a3434a2dSAnthony PERARD  * "feature-split-event-channels" may optionally be used when using
83*a3434a2dSAnthony PERARD  * multiple queues, but is not mandatory.
84*a3434a2dSAnthony PERARD  *
85*a3434a2dSAnthony PERARD  * Each queue consists of one shared ring pair, i.e. there must be the same
86*a3434a2dSAnthony PERARD  * number of tx and rx rings.
87*a3434a2dSAnthony PERARD  *
88*a3434a2dSAnthony PERARD  * For frontends requesting just one queue, the usual event-channel and
89*a3434a2dSAnthony PERARD  * ring-ref keys are written as before, simplifying the backend processing
90*a3434a2dSAnthony PERARD  * to avoid distinguishing between a frontend that doesn't understand the
91*a3434a2dSAnthony PERARD  * multi-queue feature, and one that does, but requested only one queue.
92*a3434a2dSAnthony PERARD  *
93*a3434a2dSAnthony PERARD  * Frontends requesting two or more queues must not write the toplevel
94*a3434a2dSAnthony PERARD  * event-channel (or event-channel-{tx,rx}) and {tx,rx}-ring-ref keys,
95*a3434a2dSAnthony PERARD  * instead writing those keys under sub-keys having the name "queue-N" where
96*a3434a2dSAnthony PERARD  * N is the integer ID of the queue for which those keys belong. Queues
97*a3434a2dSAnthony PERARD  * are indexed from zero. For example, a frontend with two queues and split
98*a3434a2dSAnthony PERARD  * event channels must write the following set of queue-related keys:
99*a3434a2dSAnthony PERARD  *
100*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/multi-queue-num-queues = "2"
101*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-0 = ""
102*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-0/tx-ring-ref = "<ring-ref-tx0>"
103*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-0/rx-ring-ref = "<ring-ref-rx0>"
104*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-0/event-channel-tx = "<evtchn-tx0>"
105*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-0/event-channel-rx = "<evtchn-rx0>"
106*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-1 = ""
107*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-1/tx-ring-ref = "<ring-ref-tx1>"
108*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-1/rx-ring-ref = "<ring-ref-rx1"
109*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-1/event-channel-tx = "<evtchn-tx1>"
110*a3434a2dSAnthony PERARD  * /local/domain/1/device/vif/0/queue-1/event-channel-rx = "<evtchn-rx1>"
111*a3434a2dSAnthony PERARD  *
112*a3434a2dSAnthony PERARD  * If there is any inconsistency in the XenStore data, the backend may
113*a3434a2dSAnthony PERARD  * choose not to connect any queues, instead treating the request as an
114*a3434a2dSAnthony PERARD  * error. This includes scenarios where more (or fewer) queues were
115*a3434a2dSAnthony PERARD  * requested than the frontend provided details for.
116*a3434a2dSAnthony PERARD  *
117*a3434a2dSAnthony PERARD  * Mapping of packets to queues is considered to be a function of the
118*a3434a2dSAnthony PERARD  * transmitting system (backend or frontend) and is not negotiated
119*a3434a2dSAnthony PERARD  * between the two. Guests are free to transmit packets on any queue
120*a3434a2dSAnthony PERARD  * they choose, provided it has been set up correctly. Guests must be
121*a3434a2dSAnthony PERARD  * prepared to receive packets on any queue they have requested be set up.
122*a3434a2dSAnthony PERARD  */
123*a3434a2dSAnthony PERARD 
124*a3434a2dSAnthony PERARD /*
125*a3434a2dSAnthony PERARD  * "feature-no-csum-offload" should be used to turn IPv4 TCP/UDP checksum
126*a3434a2dSAnthony PERARD  * offload off or on. If it is missing then the feature is assumed to be on.
127*a3434a2dSAnthony PERARD  * "feature-ipv6-csum-offload" should be used to turn IPv6 TCP/UDP checksum
128*a3434a2dSAnthony PERARD  * offload on or off. If it is missing then the feature is assumed to be off.
129*a3434a2dSAnthony PERARD  */
130*a3434a2dSAnthony PERARD 
131*a3434a2dSAnthony PERARD /*
132*a3434a2dSAnthony PERARD  * "feature-gso-tcpv4" and "feature-gso-tcpv6" advertise the capability to
133*a3434a2dSAnthony PERARD  * handle large TCP packets (in IPv4 or IPv6 form respectively). Neither
134*a3434a2dSAnthony PERARD  * frontends nor backends are assumed to be capable unless the flags are
135*a3434a2dSAnthony PERARD  * present.
136*a3434a2dSAnthony PERARD  */
137*a3434a2dSAnthony PERARD 
138*a3434a2dSAnthony PERARD /*
139*a3434a2dSAnthony PERARD  * "feature-multicast-control" and "feature-dynamic-multicast-control"
140*a3434a2dSAnthony PERARD  * advertise the capability to filter ethernet multicast packets in the
141*a3434a2dSAnthony PERARD  * backend. If the frontend wishes to take advantage of this feature then
142*a3434a2dSAnthony PERARD  * it may set "request-multicast-control". If the backend only advertises
143*a3434a2dSAnthony PERARD  * "feature-multicast-control" then "request-multicast-control" must be set
144*a3434a2dSAnthony PERARD  * before the frontend moves into the connected state. The backend will
145*a3434a2dSAnthony PERARD  * sample the value on this state transition and any subsequent change in
146*a3434a2dSAnthony PERARD  * value will have no effect. However, if the backend also advertises
147*a3434a2dSAnthony PERARD  * "feature-dynamic-multicast-control" then "request-multicast-control"
148*a3434a2dSAnthony PERARD  * may be set by the frontend at any time. In this case, the backend will
149*a3434a2dSAnthony PERARD  * watch the value and re-sample on watch events.
150*a3434a2dSAnthony PERARD  *
151*a3434a2dSAnthony PERARD  * If the sampled value of "request-multicast-control" is set then the
152*a3434a2dSAnthony PERARD  * backend transmit side should no longer flood multicast packets to the
153*a3434a2dSAnthony PERARD  * frontend, it should instead drop any multicast packet that does not
154*a3434a2dSAnthony PERARD  * match in a filter list.
155*a3434a2dSAnthony PERARD  * The list is amended by the frontend by sending dummy transmit requests
156*a3434a2dSAnthony PERARD  * containing XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL} extra-info fragments as
157*a3434a2dSAnthony PERARD  * specified below.
158*a3434a2dSAnthony PERARD  * Note that the filter list may be amended even if the sampled value of
159*a3434a2dSAnthony PERARD  * "request-multicast-control" is not set, however the filter should only
160*a3434a2dSAnthony PERARD  * be applied if it is set.
161*a3434a2dSAnthony PERARD  */
162*a3434a2dSAnthony PERARD 
163*a3434a2dSAnthony PERARD /*
164*a3434a2dSAnthony PERARD  * Control ring
165*a3434a2dSAnthony PERARD  * ============
166*a3434a2dSAnthony PERARD  *
167*a3434a2dSAnthony PERARD  * Some features, such as hashing (detailed below), require a
168*a3434a2dSAnthony PERARD  * significant amount of out-of-band data to be passed from frontend to
169*a3434a2dSAnthony PERARD  * backend. Use of xenstore is not suitable for large quantities of data
170*a3434a2dSAnthony PERARD  * because of quota limitations and so a dedicated 'control ring' is used.
171*a3434a2dSAnthony PERARD  * The ability of the backend to use a control ring is advertised by
172*a3434a2dSAnthony PERARD  * setting:
173*a3434a2dSAnthony PERARD  *
174*a3434a2dSAnthony PERARD  * /local/domain/X/backend/<domid>/<vif>/feature-ctrl-ring = "1"
175*a3434a2dSAnthony PERARD  *
176*a3434a2dSAnthony PERARD  * The frontend provides a control ring to the backend by setting:
177*a3434a2dSAnthony PERARD  *
178*a3434a2dSAnthony PERARD  * /local/domain/<domid>/device/vif/<vif>/ctrl-ring-ref = <gref>
179*a3434a2dSAnthony PERARD  * /local/domain/<domid>/device/vif/<vif>/event-channel-ctrl = <port>
180*a3434a2dSAnthony PERARD  *
181*a3434a2dSAnthony PERARD  * where <gref> is the grant reference of the shared page used to
182*a3434a2dSAnthony PERARD  * implement the control ring and <port> is an event channel to be used
183*a3434a2dSAnthony PERARD  * as a mailbox interrupt. These keys must be set before the frontend
184*a3434a2dSAnthony PERARD  * moves into the connected state.
185*a3434a2dSAnthony PERARD  *
186*a3434a2dSAnthony PERARD  * The control ring uses a fixed request/response message size and is
187*a3434a2dSAnthony PERARD  * balanced (i.e. one request to one response), so operationally it is much
188*a3434a2dSAnthony PERARD  * the same as a transmit or receive ring.
189*a3434a2dSAnthony PERARD  * Note that there is no requirement that responses are issued in the same
190*a3434a2dSAnthony PERARD  * order as requests.
191*a3434a2dSAnthony PERARD  */
192*a3434a2dSAnthony PERARD 
193*a3434a2dSAnthony PERARD /*
194*a3434a2dSAnthony PERARD  * Hash types
195*a3434a2dSAnthony PERARD  * ==========
196*a3434a2dSAnthony PERARD  *
197*a3434a2dSAnthony PERARD  * For the purposes of the definitions below, 'Packet[]' is an array of
198*a3434a2dSAnthony PERARD  * octets containing an IP packet without options, 'Array[X..Y]' means a
199*a3434a2dSAnthony PERARD  * sub-array of 'Array' containing bytes X thru Y inclusive, and '+' is
200*a3434a2dSAnthony PERARD  * used to indicate concatenation of arrays.
201*a3434a2dSAnthony PERARD  */
202*a3434a2dSAnthony PERARD 
203*a3434a2dSAnthony PERARD /*
204*a3434a2dSAnthony PERARD  * A hash calculated over an IP version 4 header as follows:
205*a3434a2dSAnthony PERARD  *
206*a3434a2dSAnthony PERARD  * Buffer[0..8] = Packet[12..15] (source address) +
207*a3434a2dSAnthony PERARD  *                Packet[16..19] (destination address)
208*a3434a2dSAnthony PERARD  *
209*a3434a2dSAnthony PERARD  * Result = Hash(Buffer, 8)
210*a3434a2dSAnthony PERARD  */
211*a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV4 0
212*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV4 \
213*a3434a2dSAnthony PERARD     (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV4)
214*a3434a2dSAnthony PERARD 
215*a3434a2dSAnthony PERARD /*
216*a3434a2dSAnthony PERARD  * A hash calculated over an IP version 4 header and TCP header as
217*a3434a2dSAnthony PERARD  * follows:
218*a3434a2dSAnthony PERARD  *
219*a3434a2dSAnthony PERARD  * Buffer[0..12] = Packet[12..15] (source address) +
220*a3434a2dSAnthony PERARD  *                 Packet[16..19] (destination address) +
221*a3434a2dSAnthony PERARD  *                 Packet[20..21] (source port) +
222*a3434a2dSAnthony PERARD  *                 Packet[22..23] (destination port)
223*a3434a2dSAnthony PERARD  *
224*a3434a2dSAnthony PERARD  * Result = Hash(Buffer, 12)
225*a3434a2dSAnthony PERARD  */
226*a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP 1
227*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP \
228*a3434a2dSAnthony PERARD     (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV4_TCP)
229*a3434a2dSAnthony PERARD 
230*a3434a2dSAnthony PERARD /*
231*a3434a2dSAnthony PERARD  * A hash calculated over an IP version 6 header as follows:
232*a3434a2dSAnthony PERARD  *
233*a3434a2dSAnthony PERARD  * Buffer[0..32] = Packet[8..23]  (source address ) +
234*a3434a2dSAnthony PERARD  *                 Packet[24..39] (destination address)
235*a3434a2dSAnthony PERARD  *
236*a3434a2dSAnthony PERARD  * Result = Hash(Buffer, 32)
237*a3434a2dSAnthony PERARD  */
238*a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV6 2
239*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV6 \
240*a3434a2dSAnthony PERARD     (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV6)
241*a3434a2dSAnthony PERARD 
242*a3434a2dSAnthony PERARD /*
243*a3434a2dSAnthony PERARD  * A hash calculated over an IP version 6 header and TCP header as
244*a3434a2dSAnthony PERARD  * follows:
245*a3434a2dSAnthony PERARD  *
246*a3434a2dSAnthony PERARD  * Buffer[0..36] = Packet[8..23]  (source address) +
247*a3434a2dSAnthony PERARD  *                 Packet[24..39] (destination address) +
248*a3434a2dSAnthony PERARD  *                 Packet[40..41] (source port) +
249*a3434a2dSAnthony PERARD  *                 Packet[42..43] (destination port)
250*a3434a2dSAnthony PERARD  *
251*a3434a2dSAnthony PERARD  * Result = Hash(Buffer, 36)
252*a3434a2dSAnthony PERARD  */
253*a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP 3
254*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP \
255*a3434a2dSAnthony PERARD     (1 << _XEN_NETIF_CTRL_HASH_TYPE_IPV6_TCP)
256*a3434a2dSAnthony PERARD 
257*a3434a2dSAnthony PERARD /*
258*a3434a2dSAnthony PERARD  * Hash algorithms
259*a3434a2dSAnthony PERARD  * ===============
260*a3434a2dSAnthony PERARD  */
261*a3434a2dSAnthony PERARD 
262*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_ALGORITHM_NONE 0
263*a3434a2dSAnthony PERARD 
264*a3434a2dSAnthony PERARD /*
265*a3434a2dSAnthony PERARD  * Toeplitz hash:
266*a3434a2dSAnthony PERARD  */
267*a3434a2dSAnthony PERARD 
268*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_HASH_ALGORITHM_TOEPLITZ 1
269*a3434a2dSAnthony PERARD 
270*a3434a2dSAnthony PERARD /*
271*a3434a2dSAnthony PERARD  * Control requests (struct xen_netif_ctrl_request)
272*a3434a2dSAnthony PERARD  * ================================================
273*a3434a2dSAnthony PERARD  *
274*a3434a2dSAnthony PERARD  * All requests have the following format:
275*a3434a2dSAnthony PERARD  *
276*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
277*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
278*a3434a2dSAnthony PERARD  * |    id     |   type    |         data[0]       |
279*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
280*a3434a2dSAnthony PERARD  * |         data[1]       |         data[2]       |
281*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----------------------+
282*a3434a2dSAnthony PERARD  *
283*a3434a2dSAnthony PERARD  * id: the request identifier, echoed in response.
284*a3434a2dSAnthony PERARD  * type: the type of request (see below)
285*a3434a2dSAnthony PERARD  * data[]: any data associated with the request (determined by type)
286*a3434a2dSAnthony PERARD  */
287*a3434a2dSAnthony PERARD 
288*a3434a2dSAnthony PERARD struct xen_netif_ctrl_request {
289*a3434a2dSAnthony PERARD     uint16_t id;
290*a3434a2dSAnthony PERARD     uint16_t type;
291*a3434a2dSAnthony PERARD 
292*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_INVALID               0
293*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS        1
294*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS        2
295*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_KEY          3
296*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE 4
297*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE 5
298*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING      6
299*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM    7
300*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE 8
301*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING      9
302*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING     10
303*a3434a2dSAnthony PERARD 
304*a3434a2dSAnthony PERARD     uint32_t data[3];
305*a3434a2dSAnthony PERARD };
306*a3434a2dSAnthony PERARD 
307*a3434a2dSAnthony PERARD /*
308*a3434a2dSAnthony PERARD  * Control responses (struct xen_netif_ctrl_response)
309*a3434a2dSAnthony PERARD  * ==================================================
310*a3434a2dSAnthony PERARD  *
311*a3434a2dSAnthony PERARD  * All responses have the following format:
312*a3434a2dSAnthony PERARD  *
313*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
314*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
315*a3434a2dSAnthony PERARD  * |    id     |   type    |         status        |
316*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
317*a3434a2dSAnthony PERARD  * |         data          |
318*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+
319*a3434a2dSAnthony PERARD  *
320*a3434a2dSAnthony PERARD  * id: the corresponding request identifier
321*a3434a2dSAnthony PERARD  * type: the type of the corresponding request
322*a3434a2dSAnthony PERARD  * status: the status of request processing
323*a3434a2dSAnthony PERARD  * data: any data associated with the response (determined by type and
324*a3434a2dSAnthony PERARD  *       status)
325*a3434a2dSAnthony PERARD  */
326*a3434a2dSAnthony PERARD 
327*a3434a2dSAnthony PERARD struct xen_netif_ctrl_response {
328*a3434a2dSAnthony PERARD     uint16_t id;
329*a3434a2dSAnthony PERARD     uint16_t type;
330*a3434a2dSAnthony PERARD     uint32_t status;
331*a3434a2dSAnthony PERARD 
332*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_SUCCESS           0
333*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     1
334*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER 2
335*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW   3
336*a3434a2dSAnthony PERARD 
337*a3434a2dSAnthony PERARD     uint32_t data;
338*a3434a2dSAnthony PERARD };
339*a3434a2dSAnthony PERARD 
340*a3434a2dSAnthony PERARD /*
341*a3434a2dSAnthony PERARD  * Static Grants (struct xen_netif_gref)
342*a3434a2dSAnthony PERARD  * =====================================
343*a3434a2dSAnthony PERARD  *
344*a3434a2dSAnthony PERARD  * A frontend may provide a fixed set of grant references to be mapped on
345*a3434a2dSAnthony PERARD  * the backend. The message of type XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING
346*a3434a2dSAnthony PERARD  * prior its usage in the command ring allows for creation of these mappings.
347*a3434a2dSAnthony PERARD  * The backend will maintain a fixed amount of these mappings.
348*a3434a2dSAnthony PERARD  *
349*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE lets a frontend query how many
350*a3434a2dSAnthony PERARD  * of these mappings can be kept.
351*a3434a2dSAnthony PERARD  *
352*a3434a2dSAnthony PERARD  * Each entry in the XEN_NETIF_CTRL_TYPE_{ADD,DEL}_GREF_MAPPING input table has
353*a3434a2dSAnthony PERARD  * the following format:
354*a3434a2dSAnthony PERARD  *
355*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
356*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
357*a3434a2dSAnthony PERARD  * | grant ref             |  flags    |  status   |
358*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
359*a3434a2dSAnthony PERARD  *
360*a3434a2dSAnthony PERARD  * grant ref: grant reference (IN)
361*a3434a2dSAnthony PERARD  * flags: flags describing the control operation (IN)
362*a3434a2dSAnthony PERARD  * status: XEN_NETIF_CTRL_STATUS_* (OUT)
363*a3434a2dSAnthony PERARD  *
364*a3434a2dSAnthony PERARD  * 'status' is an output parameter which does not require to be set to zero
365*a3434a2dSAnthony PERARD  * prior to its usage in the corresponding control messages.
366*a3434a2dSAnthony PERARD  */
367*a3434a2dSAnthony PERARD 
368*a3434a2dSAnthony PERARD struct xen_netif_gref {
369*a3434a2dSAnthony PERARD        grant_ref_t ref;
370*a3434a2dSAnthony PERARD        uint16_t flags;
371*a3434a2dSAnthony PERARD 
372*a3434a2dSAnthony PERARD #define _XEN_NETIF_CTRLF_GREF_readonly    0
373*a3434a2dSAnthony PERARD #define XEN_NETIF_CTRLF_GREF_readonly    (1U<<_XEN_NETIF_CTRLF_GREF_readonly)
374*a3434a2dSAnthony PERARD 
375*a3434a2dSAnthony PERARD        uint16_t status;
376*a3434a2dSAnthony PERARD };
377*a3434a2dSAnthony PERARD 
378*a3434a2dSAnthony PERARD /*
379*a3434a2dSAnthony PERARD  * Control messages
380*a3434a2dSAnthony PERARD  * ================
381*a3434a2dSAnthony PERARD  *
382*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM
383*a3434a2dSAnthony PERARD  * --------------------------------------
384*a3434a2dSAnthony PERARD  *
385*a3434a2dSAnthony PERARD  * This is sent by the frontend to set the desired hash algorithm.
386*a3434a2dSAnthony PERARD  *
387*a3434a2dSAnthony PERARD  * Request:
388*a3434a2dSAnthony PERARD  *
389*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_SET_HASH_ALGORITHM
390*a3434a2dSAnthony PERARD  *  data[0] = a XEN_NETIF_CTRL_HASH_ALGORITHM_* value
391*a3434a2dSAnthony PERARD  *  data[1] = 0
392*a3434a2dSAnthony PERARD  *  data[2] = 0
393*a3434a2dSAnthony PERARD  *
394*a3434a2dSAnthony PERARD  * Response:
395*a3434a2dSAnthony PERARD  *
396*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
397*a3434a2dSAnthony PERARD  *                                                     supported
398*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - The algorithm is not
399*a3434a2dSAnthony PERARD  *                                                     supported
400*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
401*a3434a2dSAnthony PERARD  *
402*a3434a2dSAnthony PERARD  * NOTE: Setting data[0] to XEN_NETIF_CTRL_HASH_ALGORITHM_NONE disables
403*a3434a2dSAnthony PERARD  *       hashing and the backend is free to choose how it steers packets
404*a3434a2dSAnthony PERARD  *       to queues (which is the default behaviour).
405*a3434a2dSAnthony PERARD  *
406*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS
407*a3434a2dSAnthony PERARD  * ----------------------------------
408*a3434a2dSAnthony PERARD  *
409*a3434a2dSAnthony PERARD  * This is sent by the frontend to query the types of hash supported by
410*a3434a2dSAnthony PERARD  * the backend.
411*a3434a2dSAnthony PERARD  *
412*a3434a2dSAnthony PERARD  * Request:
413*a3434a2dSAnthony PERARD  *
414*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_GET_HASH_FLAGS
415*a3434a2dSAnthony PERARD  *  data[0] = 0
416*a3434a2dSAnthony PERARD  *  data[1] = 0
417*a3434a2dSAnthony PERARD  *  data[2] = 0
418*a3434a2dSAnthony PERARD  *
419*a3434a2dSAnthony PERARD  * Response:
420*a3434a2dSAnthony PERARD  *
421*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not supported
422*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS       - Operation successful
423*a3434a2dSAnthony PERARD  *  data   = supported hash types (if operation was successful)
424*a3434a2dSAnthony PERARD  *
425*a3434a2dSAnthony PERARD  * NOTE: A valid hash algorithm must be selected before this operation can
426*a3434a2dSAnthony PERARD  *       succeed.
427*a3434a2dSAnthony PERARD  *
428*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS
429*a3434a2dSAnthony PERARD  * ----------------------------------
430*a3434a2dSAnthony PERARD  *
431*a3434a2dSAnthony PERARD  * This is sent by the frontend to set the types of hash that the backend
432*a3434a2dSAnthony PERARD  * should calculate. (See above for hash type definitions).
433*a3434a2dSAnthony PERARD  * Note that the 'maximal' type of hash should always be chosen. For
434*a3434a2dSAnthony PERARD  * example, if the frontend sets both IPV4 and IPV4_TCP hash types then
435*a3434a2dSAnthony PERARD  * the latter hash type should be calculated for any TCP packet and the
436*a3434a2dSAnthony PERARD  * former only calculated for non-TCP packets.
437*a3434a2dSAnthony PERARD  *
438*a3434a2dSAnthony PERARD  * Request:
439*a3434a2dSAnthony PERARD  *
440*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_SET_HASH_FLAGS
441*a3434a2dSAnthony PERARD  *  data[0] = bitwise OR of XEN_NETIF_CTRL_HASH_TYPE_* values
442*a3434a2dSAnthony PERARD  *  data[1] = 0
443*a3434a2dSAnthony PERARD  *  data[2] = 0
444*a3434a2dSAnthony PERARD  *
445*a3434a2dSAnthony PERARD  * Response:
446*a3434a2dSAnthony PERARD  *
447*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
448*a3434a2dSAnthony PERARD  *                                                     supported
449*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - One or more flag
450*a3434a2dSAnthony PERARD  *                                                     value is invalid or
451*a3434a2dSAnthony PERARD  *                                                     unsupported
452*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
453*a3434a2dSAnthony PERARD  *  data   = 0
454*a3434a2dSAnthony PERARD  *
455*a3434a2dSAnthony PERARD  * NOTE: A valid hash algorithm must be selected before this operation can
456*a3434a2dSAnthony PERARD  *       succeed.
457*a3434a2dSAnthony PERARD  *       Also, setting data[0] to zero disables hashing and the backend
458*a3434a2dSAnthony PERARD  *       is free to choose how it steers packets to queues.
459*a3434a2dSAnthony PERARD  *
460*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_SET_HASH_KEY
461*a3434a2dSAnthony PERARD  * --------------------------------
462*a3434a2dSAnthony PERARD  *
463*a3434a2dSAnthony PERARD  * This is sent by the frontend to set the key of the hash if the algorithm
464*a3434a2dSAnthony PERARD  * requires it. (See hash algorithms above).
465*a3434a2dSAnthony PERARD  *
466*a3434a2dSAnthony PERARD  * Request:
467*a3434a2dSAnthony PERARD  *
468*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_SET_HASH_KEY
469*a3434a2dSAnthony PERARD  *  data[0] = grant reference of page containing the key (assumed to
470*a3434a2dSAnthony PERARD  *            start at beginning of grant)
471*a3434a2dSAnthony PERARD  *  data[1] = size of key in octets
472*a3434a2dSAnthony PERARD  *  data[2] = 0
473*a3434a2dSAnthony PERARD  *
474*a3434a2dSAnthony PERARD  * Response:
475*a3434a2dSAnthony PERARD  *
476*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
477*a3434a2dSAnthony PERARD  *                                                     supported
478*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Key size is invalid
479*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW   - Key size is larger
480*a3434a2dSAnthony PERARD  *                                                     than the backend
481*a3434a2dSAnthony PERARD  *                                                     supports
482*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
483*a3434a2dSAnthony PERARD  *  data   = 0
484*a3434a2dSAnthony PERARD  *
485*a3434a2dSAnthony PERARD  * NOTE: Any key octets not specified are assumed to be zero (the key
486*a3434a2dSAnthony PERARD  *       is assumed to be empty by default) and specifying a new key
487*a3434a2dSAnthony PERARD  *       invalidates any previous key, hence specifying a key size of
488*a3434a2dSAnthony PERARD  *       zero will clear the key (which ensures that the calculated hash
489*a3434a2dSAnthony PERARD  *       will always be zero).
490*a3434a2dSAnthony PERARD  *       The maximum size of key is algorithm and backend specific, but
491*a3434a2dSAnthony PERARD  *       is also limited by the single grant reference.
492*a3434a2dSAnthony PERARD  *       The grant reference may be read-only and must remain valid until
493*a3434a2dSAnthony PERARD  *       the response has been processed.
494*a3434a2dSAnthony PERARD  *
495*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE
496*a3434a2dSAnthony PERARD  * -----------------------------------------
497*a3434a2dSAnthony PERARD  *
498*a3434a2dSAnthony PERARD  * This is sent by the frontend to query the maximum size of mapping
499*a3434a2dSAnthony PERARD  * table supported by the backend. The size is specified in terms of
500*a3434a2dSAnthony PERARD  * table entries.
501*a3434a2dSAnthony PERARD  *
502*a3434a2dSAnthony PERARD  * Request:
503*a3434a2dSAnthony PERARD  *
504*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_GET_HASH_MAPPING_SIZE
505*a3434a2dSAnthony PERARD  *  data[0] = 0
506*a3434a2dSAnthony PERARD  *  data[1] = 0
507*a3434a2dSAnthony PERARD  *  data[2] = 0
508*a3434a2dSAnthony PERARD  *
509*a3434a2dSAnthony PERARD  * Response:
510*a3434a2dSAnthony PERARD  *
511*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED - Operation not supported
512*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS       - Operation successful
513*a3434a2dSAnthony PERARD  *  data   = maximum number of entries allowed in the mapping table
514*a3434a2dSAnthony PERARD  *           (if operation was successful) or zero if a mapping table is
515*a3434a2dSAnthony PERARD  *           not supported (i.e. hash mapping is done only by modular
516*a3434a2dSAnthony PERARD  *           arithmetic).
517*a3434a2dSAnthony PERARD  *
518*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE
519*a3434a2dSAnthony PERARD  * -------------------------------------
520*a3434a2dSAnthony PERARD  *
521*a3434a2dSAnthony PERARD  * This is sent by the frontend to set the actual size of the mapping
522*a3434a2dSAnthony PERARD  * table to be used by the backend. The size is specified in terms of
523*a3434a2dSAnthony PERARD  * table entries.
524*a3434a2dSAnthony PERARD  * Any previous table is invalidated by this message and any new table
525*a3434a2dSAnthony PERARD  * is assumed to be zero filled.
526*a3434a2dSAnthony PERARD  *
527*a3434a2dSAnthony PERARD  * Request:
528*a3434a2dSAnthony PERARD  *
529*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE
530*a3434a2dSAnthony PERARD  *  data[0] = number of entries in mapping table
531*a3434a2dSAnthony PERARD  *  data[1] = 0
532*a3434a2dSAnthony PERARD  *  data[2] = 0
533*a3434a2dSAnthony PERARD  *
534*a3434a2dSAnthony PERARD  * Response:
535*a3434a2dSAnthony PERARD  *
536*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
537*a3434a2dSAnthony PERARD  *                                                     supported
538*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Table size is invalid
539*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
540*a3434a2dSAnthony PERARD  *  data   = 0
541*a3434a2dSAnthony PERARD  *
542*a3434a2dSAnthony PERARD  * NOTE: Setting data[0] to 0 means that hash mapping should be done
543*a3434a2dSAnthony PERARD  *       using modular arithmetic.
544*a3434a2dSAnthony PERARD  *
545*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING
546*a3434a2dSAnthony PERARD  * ------------------------------------
547*a3434a2dSAnthony PERARD  *
548*a3434a2dSAnthony PERARD  * This is sent by the frontend to set the content of the table mapping
549*a3434a2dSAnthony PERARD  * hash value to queue number. The backend should calculate the hash from
550*a3434a2dSAnthony PERARD  * the packet header, use it as an index into the table (modulo the size
551*a3434a2dSAnthony PERARD  * of the table) and then steer the packet to the queue number found at
552*a3434a2dSAnthony PERARD  * that index.
553*a3434a2dSAnthony PERARD  *
554*a3434a2dSAnthony PERARD  * Request:
555*a3434a2dSAnthony PERARD  *
556*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING
557*a3434a2dSAnthony PERARD  *  data[0] = grant reference of page containing the mapping (sub-)table
558*a3434a2dSAnthony PERARD  *            (assumed to start at beginning of grant)
559*a3434a2dSAnthony PERARD  *  data[1] = size of (sub-)table in entries
560*a3434a2dSAnthony PERARD  *  data[2] = offset, in entries, of sub-table within overall table
561*a3434a2dSAnthony PERARD  *
562*a3434a2dSAnthony PERARD  * Response:
563*a3434a2dSAnthony PERARD  *
564*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
565*a3434a2dSAnthony PERARD  *                                                     supported
566*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Table size or content
567*a3434a2dSAnthony PERARD  *                                                     is invalid
568*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_BUFFER_OVERFLOW   - Table size is larger
569*a3434a2dSAnthony PERARD  *                                                     than the backend
570*a3434a2dSAnthony PERARD  *                                                     supports
571*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
572*a3434a2dSAnthony PERARD  *  data   = 0
573*a3434a2dSAnthony PERARD  *
574*a3434a2dSAnthony PERARD  * NOTE: The overall table has the following format:
575*a3434a2dSAnthony PERARD  *
576*a3434a2dSAnthony PERARD  *          0     1     2     3     4     5     6     7  octet
577*a3434a2dSAnthony PERARD  *       +-----+-----+-----+-----+-----+-----+-----+-----+
578*a3434a2dSAnthony PERARD  *       |       mapping[0]      |       mapping[1]      |
579*a3434a2dSAnthony PERARD  *       +-----+-----+-----+-----+-----+-----+-----+-----+
580*a3434a2dSAnthony PERARD  *       |                       .                       |
581*a3434a2dSAnthony PERARD  *       |                       .                       |
582*a3434a2dSAnthony PERARD  *       |                       .                       |
583*a3434a2dSAnthony PERARD  *       +-----+-----+-----+-----+-----+-----+-----+-----+
584*a3434a2dSAnthony PERARD  *       |      mapping[N-2]     |      mapping[N-1]     |
585*a3434a2dSAnthony PERARD  *       +-----+-----+-----+-----+-----+-----+-----+-----+
586*a3434a2dSAnthony PERARD  *
587*a3434a2dSAnthony PERARD  *       where N is specified by a XEN_NETIF_CTRL_TYPE_SET_HASH_MAPPING_SIZE
588*a3434a2dSAnthony PERARD  *       message and each  mapping must specifies a queue between 0 and
589*a3434a2dSAnthony PERARD  *       "multi-queue-num-queues" (see above).
590*a3434a2dSAnthony PERARD  *       The backend may support a mapping table larger than can be
591*a3434a2dSAnthony PERARD  *       mapped by a single grant reference. Thus sub-tables within a
592*a3434a2dSAnthony PERARD  *       larger table can be individually set by sending multiple messages
593*a3434a2dSAnthony PERARD  *       with differing offset values. Specifying a new sub-table does not
594*a3434a2dSAnthony PERARD  *       invalidate any table data outside that range.
595*a3434a2dSAnthony PERARD  *       The grant reference may be read-only and must remain valid until
596*a3434a2dSAnthony PERARD  *       the response has been processed.
597*a3434a2dSAnthony PERARD  *
598*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE
599*a3434a2dSAnthony PERARD  * -----------------------------------------
600*a3434a2dSAnthony PERARD  *
601*a3434a2dSAnthony PERARD  * This is sent by the frontend to fetch the number of grefs that can be kept
602*a3434a2dSAnthony PERARD  * mapped in the backend.
603*a3434a2dSAnthony PERARD  *
604*a3434a2dSAnthony PERARD  * Request:
605*a3434a2dSAnthony PERARD  *
606*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_GET_GREF_MAPPING_SIZE
607*a3434a2dSAnthony PERARD  *  data[0] = queue index (assumed 0 for single queue)
608*a3434a2dSAnthony PERARD  *  data[1] = 0
609*a3434a2dSAnthony PERARD  *  data[2] = 0
610*a3434a2dSAnthony PERARD  *
611*a3434a2dSAnthony PERARD  * Response:
612*a3434a2dSAnthony PERARD  *
613*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
614*a3434a2dSAnthony PERARD  *                                                     supported
615*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - The queue index is
616*a3434a2dSAnthony PERARD  *                                                     out of range
617*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
618*a3434a2dSAnthony PERARD  *  data   = maximum number of entries allowed in the gref mapping table
619*a3434a2dSAnthony PERARD  *           (if operation was successful) or zero if it is not supported.
620*a3434a2dSAnthony PERARD  *
621*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING
622*a3434a2dSAnthony PERARD  * ------------------------------------
623*a3434a2dSAnthony PERARD  *
624*a3434a2dSAnthony PERARD  * This is sent by the frontend for backend to map a list of grant
625*a3434a2dSAnthony PERARD  * references.
626*a3434a2dSAnthony PERARD  *
627*a3434a2dSAnthony PERARD  * Request:
628*a3434a2dSAnthony PERARD  *
629*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING
630*a3434a2dSAnthony PERARD  *  data[0] = queue index
631*a3434a2dSAnthony PERARD  *  data[1] = grant reference of page containing the mapping list
632*a3434a2dSAnthony PERARD  *            (r/w and assumed to start at beginning of page)
633*a3434a2dSAnthony PERARD  *  data[2] = size of list in entries
634*a3434a2dSAnthony PERARD  *
635*a3434a2dSAnthony PERARD  * Response:
636*a3434a2dSAnthony PERARD  *
637*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
638*a3434a2dSAnthony PERARD  *                                                     supported
639*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Operation failed
640*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
641*a3434a2dSAnthony PERARD  *
642*a3434a2dSAnthony PERARD  * NOTE: Each entry in the input table has the format outlined
643*a3434a2dSAnthony PERARD  *       in struct xen_netif_gref.
644*a3434a2dSAnthony PERARD  *       Contrary to XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING, the struct
645*a3434a2dSAnthony PERARD  *       xen_netif_gref 'status' field is not used and therefore the response
646*a3434a2dSAnthony PERARD  *       'status' determines the success of this operation. In case of
647*a3434a2dSAnthony PERARD  *       failure none of grants mappings get added in the backend.
648*a3434a2dSAnthony PERARD  *
649*a3434a2dSAnthony PERARD  * XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING
650*a3434a2dSAnthony PERARD  * ------------------------------------
651*a3434a2dSAnthony PERARD  *
652*a3434a2dSAnthony PERARD  * This is sent by the frontend for backend to unmap a list of grant
653*a3434a2dSAnthony PERARD  * references.
654*a3434a2dSAnthony PERARD  *
655*a3434a2dSAnthony PERARD  * Request:
656*a3434a2dSAnthony PERARD  *
657*a3434a2dSAnthony PERARD  *  type    = XEN_NETIF_CTRL_TYPE_DEL_GREF_MAPPING
658*a3434a2dSAnthony PERARD  *  data[0] = queue index
659*a3434a2dSAnthony PERARD  *  data[1] = grant reference of page containing the mapping list
660*a3434a2dSAnthony PERARD  *            (r/w and assumed to start at beginning of page)
661*a3434a2dSAnthony PERARD  *  data[2] = size of list in entries
662*a3434a2dSAnthony PERARD  *
663*a3434a2dSAnthony PERARD  * Response:
664*a3434a2dSAnthony PERARD  *
665*a3434a2dSAnthony PERARD  *  status = XEN_NETIF_CTRL_STATUS_NOT_SUPPORTED     - Operation not
666*a3434a2dSAnthony PERARD  *                                                     supported
667*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER - Operation failed
668*a3434a2dSAnthony PERARD  *           XEN_NETIF_CTRL_STATUS_SUCCESS           - Operation successful
669*a3434a2dSAnthony PERARD  *  data   = number of entries that were unmapped
670*a3434a2dSAnthony PERARD  *
671*a3434a2dSAnthony PERARD  * NOTE: Each entry in the input table has the format outlined in struct
672*a3434a2dSAnthony PERARD  *       xen_netif_gref.
673*a3434a2dSAnthony PERARD  *       The struct xen_netif_gref 'status' field determines if the entry
674*a3434a2dSAnthony PERARD  *       was successfully removed.
675*a3434a2dSAnthony PERARD  *       The entries used are only the ones representing grant references that
676*a3434a2dSAnthony PERARD  *       were previously the subject of a XEN_NETIF_CTRL_TYPE_ADD_GREF_MAPPING
677*a3434a2dSAnthony PERARD  *       operation. Any other entries will have their status set to
678*a3434a2dSAnthony PERARD  *       XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER upon completion.
679*a3434a2dSAnthony PERARD  */
680*a3434a2dSAnthony PERARD 
681*a3434a2dSAnthony PERARD DEFINE_RING_TYPES(xen_netif_ctrl,
682*a3434a2dSAnthony PERARD                   struct xen_netif_ctrl_request,
683*a3434a2dSAnthony PERARD                   struct xen_netif_ctrl_response);
684*a3434a2dSAnthony PERARD 
685*a3434a2dSAnthony PERARD /*
686*a3434a2dSAnthony PERARD  * Guest transmit
687*a3434a2dSAnthony PERARD  * ==============
688*a3434a2dSAnthony PERARD  *
689*a3434a2dSAnthony PERARD  * This is the 'wire' format for transmit (frontend -> backend) packets:
690*a3434a2dSAnthony PERARD  *
691*a3434a2dSAnthony PERARD  *  Fragment 1: netif_tx_request_t  - flags = NETTXF_*
692*a3434a2dSAnthony PERARD  *                                    size = total packet size
693*a3434a2dSAnthony PERARD  * [Extra 1: netif_extra_info_t]    - (only if fragment 1 flags include
694*a3434a2dSAnthony PERARD  *                                     NETTXF_extra_info)
695*a3434a2dSAnthony PERARD  *  ...
696*a3434a2dSAnthony PERARD  * [Extra N: netif_extra_info_t]    - (only if extra N-1 flags include
697*a3434a2dSAnthony PERARD  *                                     XEN_NETIF_EXTRA_MORE)
698*a3434a2dSAnthony PERARD  *  ...
699*a3434a2dSAnthony PERARD  *  Fragment N: netif_tx_request_t  - (only if fragment N-1 flags include
700*a3434a2dSAnthony PERARD  *                                     NETTXF_more_data - flags on preceding
701*a3434a2dSAnthony PERARD  *                                     extras are not relevant here)
702*a3434a2dSAnthony PERARD  *                                    flags = 0
703*a3434a2dSAnthony PERARD  *                                    size = fragment size
704*a3434a2dSAnthony PERARD  *
705*a3434a2dSAnthony PERARD  * NOTE:
706*a3434a2dSAnthony PERARD  *
707*a3434a2dSAnthony PERARD  * This format slightly is different from that used for receive
708*a3434a2dSAnthony PERARD  * (backend -> frontend) packets. Specifically, in a multi-fragment
709*a3434a2dSAnthony PERARD  * packet the actual size of fragment 1 can only be determined by
710*a3434a2dSAnthony PERARD  * subtracting the sizes of fragments 2..N from the total packet size.
711*a3434a2dSAnthony PERARD  *
712*a3434a2dSAnthony PERARD  * Ring slot size is 12 octets, however not all request/response
713*a3434a2dSAnthony PERARD  * structs use the full size.
714*a3434a2dSAnthony PERARD  *
715*a3434a2dSAnthony PERARD  * tx request data (netif_tx_request_t)
716*a3434a2dSAnthony PERARD  * ------------------------------------
717*a3434a2dSAnthony PERARD  *
718*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
719*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
720*a3434a2dSAnthony PERARD  * | grant ref             | offset    | flags     |
721*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
722*a3434a2dSAnthony PERARD  * | id        | size      |
723*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+
724*a3434a2dSAnthony PERARD  *
725*a3434a2dSAnthony PERARD  * grant ref: Reference to buffer page.
726*a3434a2dSAnthony PERARD  * offset: Offset within buffer page.
727*a3434a2dSAnthony PERARD  * flags: NETTXF_*.
728*a3434a2dSAnthony PERARD  * id: request identifier, echoed in response.
729*a3434a2dSAnthony PERARD  * size: packet size in bytes.
730*a3434a2dSAnthony PERARD  *
731*a3434a2dSAnthony PERARD  * tx response (netif_tx_response_t)
732*a3434a2dSAnthony PERARD  * ---------------------------------
733*a3434a2dSAnthony PERARD  *
734*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
735*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
736*a3434a2dSAnthony PERARD  * | id        | status    | unused                |
737*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
738*a3434a2dSAnthony PERARD  * | unused                |
739*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+
740*a3434a2dSAnthony PERARD  *
741*a3434a2dSAnthony PERARD  * id: reflects id in transmit request
742*a3434a2dSAnthony PERARD  * status: NETIF_RSP_*
743*a3434a2dSAnthony PERARD  *
744*a3434a2dSAnthony PERARD  * Guest receive
745*a3434a2dSAnthony PERARD  * =============
746*a3434a2dSAnthony PERARD  *
747*a3434a2dSAnthony PERARD  * This is the 'wire' format for receive (backend -> frontend) packets:
748*a3434a2dSAnthony PERARD  *
749*a3434a2dSAnthony PERARD  *  Fragment 1: netif_rx_request_t  - flags = NETRXF_*
750*a3434a2dSAnthony PERARD  *                                    size = fragment size
751*a3434a2dSAnthony PERARD  * [Extra 1: netif_extra_info_t]    - (only if fragment 1 flags include
752*a3434a2dSAnthony PERARD  *                                     NETRXF_extra_info)
753*a3434a2dSAnthony PERARD  *  ...
754*a3434a2dSAnthony PERARD  * [Extra N: netif_extra_info_t]    - (only if extra N-1 flags include
755*a3434a2dSAnthony PERARD  *                                     XEN_NETIF_EXTRA_MORE)
756*a3434a2dSAnthony PERARD  *  ...
757*a3434a2dSAnthony PERARD  *  Fragment N: netif_rx_request_t  - (only if fragment N-1 flags include
758*a3434a2dSAnthony PERARD  *                                     NETRXF_more_data - flags on preceding
759*a3434a2dSAnthony PERARD  *                                     extras are not relevant here)
760*a3434a2dSAnthony PERARD  *                                    flags = 0
761*a3434a2dSAnthony PERARD  *                                    size = fragment size
762*a3434a2dSAnthony PERARD  *
763*a3434a2dSAnthony PERARD  * NOTE:
764*a3434a2dSAnthony PERARD  *
765*a3434a2dSAnthony PERARD  * This format slightly is different from that used for transmit
766*a3434a2dSAnthony PERARD  * (frontend -> backend) packets. Specifically, in a multi-fragment
767*a3434a2dSAnthony PERARD  * packet the size of the packet can only be determined by summing the
768*a3434a2dSAnthony PERARD  * sizes of fragments 1..N.
769*a3434a2dSAnthony PERARD  *
770*a3434a2dSAnthony PERARD  * Ring slot size is 8 octets.
771*a3434a2dSAnthony PERARD  *
772*a3434a2dSAnthony PERARD  * rx request (netif_rx_request_t)
773*a3434a2dSAnthony PERARD  * -------------------------------
774*a3434a2dSAnthony PERARD  *
775*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
776*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
777*a3434a2dSAnthony PERARD  * | id        | pad       | gref                  |
778*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
779*a3434a2dSAnthony PERARD  *
780*a3434a2dSAnthony PERARD  * id: request identifier, echoed in response.
781*a3434a2dSAnthony PERARD  * gref: reference to incoming granted frame.
782*a3434a2dSAnthony PERARD  *
783*a3434a2dSAnthony PERARD  * rx response (netif_rx_response_t)
784*a3434a2dSAnthony PERARD  * ---------------------------------
785*a3434a2dSAnthony PERARD  *
786*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
787*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
788*a3434a2dSAnthony PERARD  * | id        | offset    | flags     | status    |
789*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
790*a3434a2dSAnthony PERARD  *
791*a3434a2dSAnthony PERARD  * id: reflects id in receive request
792*a3434a2dSAnthony PERARD  * offset: offset in page of start of received packet
793*a3434a2dSAnthony PERARD  * flags: NETRXF_*
794*a3434a2dSAnthony PERARD  * status: -ve: NETIF_RSP_*; +ve: Rx'ed pkt size.
795*a3434a2dSAnthony PERARD  *
796*a3434a2dSAnthony PERARD  * NOTE: Historically, to support GSO on the frontend receive side, Linux
797*a3434a2dSAnthony PERARD  *       netfront does not make use of the rx response id (because, as
798*a3434a2dSAnthony PERARD  *       described below, extra info structures overlay the id field).
799*a3434a2dSAnthony PERARD  *       Instead it assumes that responses always appear in the same ring
800*a3434a2dSAnthony PERARD  *       slot as their corresponding request. Thus, to maintain
801*a3434a2dSAnthony PERARD  *       compatibility, backends must make sure this is the case.
802*a3434a2dSAnthony PERARD  *
803*a3434a2dSAnthony PERARD  * Extra Info
804*a3434a2dSAnthony PERARD  * ==========
805*a3434a2dSAnthony PERARD  *
806*a3434a2dSAnthony PERARD  * Can be present if initial request or response has NET{T,R}XF_extra_info,
807*a3434a2dSAnthony PERARD  * or previous extra request has XEN_NETIF_EXTRA_MORE.
808*a3434a2dSAnthony PERARD  *
809*a3434a2dSAnthony PERARD  * The struct therefore needs to fit into either a tx or rx slot and
810*a3434a2dSAnthony PERARD  * is therefore limited to 8 octets.
811*a3434a2dSAnthony PERARD  *
812*a3434a2dSAnthony PERARD  * NOTE: Because extra info data overlays the usual request/response
813*a3434a2dSAnthony PERARD  *       structures, there is no id information in the opposite direction.
814*a3434a2dSAnthony PERARD  *       So, if an extra info overlays an rx response the frontend can
815*a3434a2dSAnthony PERARD  *       assume that it is in the same ring slot as the request that was
816*a3434a2dSAnthony PERARD  *       consumed to make the slot available, and the backend must ensure
817*a3434a2dSAnthony PERARD  *       this assumption is true.
818*a3434a2dSAnthony PERARD  *
819*a3434a2dSAnthony PERARD  * extra info (netif_extra_info_t)
820*a3434a2dSAnthony PERARD  * -------------------------------
821*a3434a2dSAnthony PERARD  *
822*a3434a2dSAnthony PERARD  * General format:
823*a3434a2dSAnthony PERARD  *
824*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
825*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
826*a3434a2dSAnthony PERARD  * |type |flags| type specific data                |
827*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
828*a3434a2dSAnthony PERARD  * | padding for tx        |
829*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+
830*a3434a2dSAnthony PERARD  *
831*a3434a2dSAnthony PERARD  * type: XEN_NETIF_EXTRA_TYPE_*
832*a3434a2dSAnthony PERARD  * flags: XEN_NETIF_EXTRA_FLAG_*
833*a3434a2dSAnthony PERARD  * padding for tx: present only in the tx case due to 8 octet limit
834*a3434a2dSAnthony PERARD  *                 from rx case. Not shown in type specific entries
835*a3434a2dSAnthony PERARD  *                 below.
836*a3434a2dSAnthony PERARD  *
837*a3434a2dSAnthony PERARD  * XEN_NETIF_EXTRA_TYPE_GSO:
838*a3434a2dSAnthony PERARD  *
839*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
840*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
841*a3434a2dSAnthony PERARD  * |type |flags| size      |type | pad | features  |
842*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
843*a3434a2dSAnthony PERARD  *
844*a3434a2dSAnthony PERARD  * type: Must be XEN_NETIF_EXTRA_TYPE_GSO
845*a3434a2dSAnthony PERARD  * flags: XEN_NETIF_EXTRA_FLAG_*
846*a3434a2dSAnthony PERARD  * size: Maximum payload size of each segment. For example,
847*a3434a2dSAnthony PERARD  *       for TCP this is just the path MSS.
848*a3434a2dSAnthony PERARD  * type: XEN_NETIF_GSO_TYPE_*: This determines the protocol of
849*a3434a2dSAnthony PERARD  *       the packet and any extra features required to segment the
850*a3434a2dSAnthony PERARD  *       packet properly.
851*a3434a2dSAnthony PERARD  * features: EN_NETIF_GSO_FEAT_*: This specifies any extra GSO
852*a3434a2dSAnthony PERARD  *           features required to process this packet, such as ECN
853*a3434a2dSAnthony PERARD  *           support for TCPv4.
854*a3434a2dSAnthony PERARD  *
855*a3434a2dSAnthony PERARD  * XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}:
856*a3434a2dSAnthony PERARD  *
857*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
858*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
859*a3434a2dSAnthony PERARD  * |type |flags| addr                              |
860*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
861*a3434a2dSAnthony PERARD  *
862*a3434a2dSAnthony PERARD  * type: Must be XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}
863*a3434a2dSAnthony PERARD  * flags: XEN_NETIF_EXTRA_FLAG_*
864*a3434a2dSAnthony PERARD  * addr: address to add/remove
865*a3434a2dSAnthony PERARD  *
866*a3434a2dSAnthony PERARD  * XEN_NETIF_EXTRA_TYPE_HASH:
867*a3434a2dSAnthony PERARD  *
868*a3434a2dSAnthony PERARD  * A backend that supports teoplitz hashing is assumed to accept
869*a3434a2dSAnthony PERARD  * this type of extra info in transmit packets.
870*a3434a2dSAnthony PERARD  * A frontend that enables hashing is assumed to accept
871*a3434a2dSAnthony PERARD  * this type of extra info in receive packets.
872*a3434a2dSAnthony PERARD  *
873*a3434a2dSAnthony PERARD  *    0     1     2     3     4     5     6     7  octet
874*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
875*a3434a2dSAnthony PERARD  * |type |flags|htype| alg |LSB ---- value ---- MSB|
876*a3434a2dSAnthony PERARD  * +-----+-----+-----+-----+-----+-----+-----+-----+
877*a3434a2dSAnthony PERARD  *
878*a3434a2dSAnthony PERARD  * type: Must be XEN_NETIF_EXTRA_TYPE_HASH
879*a3434a2dSAnthony PERARD  * flags: XEN_NETIF_EXTRA_FLAG_*
880*a3434a2dSAnthony PERARD  * htype: Hash type (one of _XEN_NETIF_CTRL_HASH_TYPE_* - see above)
881*a3434a2dSAnthony PERARD  * alg: The algorithm used to calculate the hash (one of
882*a3434a2dSAnthony PERARD  *      XEN_NETIF_CTRL_HASH_TYPE_ALGORITHM_* - see above)
883*a3434a2dSAnthony PERARD  * value: Hash value
884*a3434a2dSAnthony PERARD  */
885*a3434a2dSAnthony PERARD 
886*a3434a2dSAnthony PERARD /* Protocol checksum field is blank in the packet (hardware offload)? */
887*a3434a2dSAnthony PERARD #define _NETTXF_csum_blank     (0)
888*a3434a2dSAnthony PERARD #define  NETTXF_csum_blank     (1U<<_NETTXF_csum_blank)
889*a3434a2dSAnthony PERARD 
890*a3434a2dSAnthony PERARD /* Packet data has been validated against protocol checksum. */
891*a3434a2dSAnthony PERARD #define _NETTXF_data_validated (1)
892*a3434a2dSAnthony PERARD #define  NETTXF_data_validated (1U<<_NETTXF_data_validated)
893*a3434a2dSAnthony PERARD 
894*a3434a2dSAnthony PERARD /* Packet continues in the next request descriptor. */
895*a3434a2dSAnthony PERARD #define _NETTXF_more_data      (2)
896*a3434a2dSAnthony PERARD #define  NETTXF_more_data      (1U<<_NETTXF_more_data)
897*a3434a2dSAnthony PERARD 
898*a3434a2dSAnthony PERARD /* Packet to be followed by extra descriptor(s). */
899*a3434a2dSAnthony PERARD #define _NETTXF_extra_info     (3)
900*a3434a2dSAnthony PERARD #define  NETTXF_extra_info     (1U<<_NETTXF_extra_info)
901*a3434a2dSAnthony PERARD 
902*a3434a2dSAnthony PERARD #define XEN_NETIF_MAX_TX_SIZE 0xFFFF
903*a3434a2dSAnthony PERARD struct netif_tx_request {
904*a3434a2dSAnthony PERARD     grant_ref_t gref;
905*a3434a2dSAnthony PERARD     uint16_t offset;
906*a3434a2dSAnthony PERARD     uint16_t flags;
907*a3434a2dSAnthony PERARD     uint16_t id;
908*a3434a2dSAnthony PERARD     uint16_t size;
909*a3434a2dSAnthony PERARD };
910*a3434a2dSAnthony PERARD typedef struct netif_tx_request netif_tx_request_t;
911*a3434a2dSAnthony PERARD 
912*a3434a2dSAnthony PERARD /* Types of netif_extra_info descriptors. */
913*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_NONE      (0)  /* Never used - invalid */
914*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_GSO       (1)  /* u.gso */
915*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2)  /* u.mcast */
916*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3)  /* u.mcast */
917*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_HASH      (4)  /* u.hash */
918*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_TYPE_MAX       (5)
919*a3434a2dSAnthony PERARD 
920*a3434a2dSAnthony PERARD /* netif_extra_info_t flags. */
921*a3434a2dSAnthony PERARD #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
922*a3434a2dSAnthony PERARD #define XEN_NETIF_EXTRA_FLAG_MORE  (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
923*a3434a2dSAnthony PERARD 
924*a3434a2dSAnthony PERARD /* GSO types */
925*a3434a2dSAnthony PERARD #define XEN_NETIF_GSO_TYPE_NONE         (0)
926*a3434a2dSAnthony PERARD #define XEN_NETIF_GSO_TYPE_TCPV4        (1)
927*a3434a2dSAnthony PERARD #define XEN_NETIF_GSO_TYPE_TCPV6        (2)
928*a3434a2dSAnthony PERARD 
929*a3434a2dSAnthony PERARD /*
930*a3434a2dSAnthony PERARD  * This structure needs to fit within both netif_tx_request_t and
931*a3434a2dSAnthony PERARD  * netif_rx_response_t for compatibility.
932*a3434a2dSAnthony PERARD  */
933*a3434a2dSAnthony PERARD struct netif_extra_info {
934*a3434a2dSAnthony PERARD     uint8_t type;
935*a3434a2dSAnthony PERARD     uint8_t flags;
936*a3434a2dSAnthony PERARD     union {
937*a3434a2dSAnthony PERARD         struct {
938*a3434a2dSAnthony PERARD             uint16_t size;
939*a3434a2dSAnthony PERARD             uint8_t type;
940*a3434a2dSAnthony PERARD             uint8_t pad;
941*a3434a2dSAnthony PERARD             uint16_t features;
942*a3434a2dSAnthony PERARD         } gso;
943*a3434a2dSAnthony PERARD         struct {
944*a3434a2dSAnthony PERARD             uint8_t addr[6];
945*a3434a2dSAnthony PERARD         } mcast;
946*a3434a2dSAnthony PERARD         struct {
947*a3434a2dSAnthony PERARD             uint8_t type;
948*a3434a2dSAnthony PERARD             uint8_t algorithm;
949*a3434a2dSAnthony PERARD             uint8_t value[4];
950*a3434a2dSAnthony PERARD         } hash;
951*a3434a2dSAnthony PERARD         uint16_t pad[3];
952*a3434a2dSAnthony PERARD     } u;
953*a3434a2dSAnthony PERARD };
954*a3434a2dSAnthony PERARD typedef struct netif_extra_info netif_extra_info_t;
955*a3434a2dSAnthony PERARD 
956*a3434a2dSAnthony PERARD struct netif_tx_response {
957*a3434a2dSAnthony PERARD     uint16_t id;
958*a3434a2dSAnthony PERARD     int16_t  status;
959*a3434a2dSAnthony PERARD };
960*a3434a2dSAnthony PERARD typedef struct netif_tx_response netif_tx_response_t;
961*a3434a2dSAnthony PERARD 
962*a3434a2dSAnthony PERARD struct netif_rx_request {
963*a3434a2dSAnthony PERARD     uint16_t    id;        /* Echoed in response message.        */
964*a3434a2dSAnthony PERARD     uint16_t    pad;
965*a3434a2dSAnthony PERARD     grant_ref_t gref;
966*a3434a2dSAnthony PERARD };
967*a3434a2dSAnthony PERARD typedef struct netif_rx_request netif_rx_request_t;
968*a3434a2dSAnthony PERARD 
969*a3434a2dSAnthony PERARD /* Packet data has been validated against protocol checksum. */
970*a3434a2dSAnthony PERARD #define _NETRXF_data_validated (0)
971*a3434a2dSAnthony PERARD #define  NETRXF_data_validated (1U<<_NETRXF_data_validated)
972*a3434a2dSAnthony PERARD 
973*a3434a2dSAnthony PERARD /* Protocol checksum field is blank in the packet (hardware offload)? */
974*a3434a2dSAnthony PERARD #define _NETRXF_csum_blank     (1)
975*a3434a2dSAnthony PERARD #define  NETRXF_csum_blank     (1U<<_NETRXF_csum_blank)
976*a3434a2dSAnthony PERARD 
977*a3434a2dSAnthony PERARD /* Packet continues in the next request descriptor. */
978*a3434a2dSAnthony PERARD #define _NETRXF_more_data      (2)
979*a3434a2dSAnthony PERARD #define  NETRXF_more_data      (1U<<_NETRXF_more_data)
980*a3434a2dSAnthony PERARD 
981*a3434a2dSAnthony PERARD /* Packet to be followed by extra descriptor(s). */
982*a3434a2dSAnthony PERARD #define _NETRXF_extra_info     (3)
983*a3434a2dSAnthony PERARD #define  NETRXF_extra_info     (1U<<_NETRXF_extra_info)
984*a3434a2dSAnthony PERARD 
985*a3434a2dSAnthony PERARD /* Packet has GSO prefix. Deprecated but included for compatibility */
986*a3434a2dSAnthony PERARD #define _NETRXF_gso_prefix     (4)
987*a3434a2dSAnthony PERARD #define  NETRXF_gso_prefix     (1U<<_NETRXF_gso_prefix)
988*a3434a2dSAnthony PERARD 
989*a3434a2dSAnthony PERARD struct netif_rx_response {
990*a3434a2dSAnthony PERARD     uint16_t id;
991*a3434a2dSAnthony PERARD     uint16_t offset;
992*a3434a2dSAnthony PERARD     uint16_t flags;
993*a3434a2dSAnthony PERARD     int16_t  status;
994*a3434a2dSAnthony PERARD };
995*a3434a2dSAnthony PERARD typedef struct netif_rx_response netif_rx_response_t;
996*a3434a2dSAnthony PERARD 
997*a3434a2dSAnthony PERARD /*
998*a3434a2dSAnthony PERARD  * Generate netif ring structures and types.
999*a3434a2dSAnthony PERARD  */
1000*a3434a2dSAnthony PERARD 
1001*a3434a2dSAnthony PERARD DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
1002*a3434a2dSAnthony PERARD DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
1003*a3434a2dSAnthony PERARD 
1004*a3434a2dSAnthony PERARD #define NETIF_RSP_DROPPED         -2
1005*a3434a2dSAnthony PERARD #define NETIF_RSP_ERROR           -1
1006*a3434a2dSAnthony PERARD #define NETIF_RSP_OKAY             0
1007*a3434a2dSAnthony PERARD /* No response: used for auxiliary requests (e.g., netif_extra_info_t). */
1008*a3434a2dSAnthony PERARD #define NETIF_RSP_NULL             1
1009*a3434a2dSAnthony PERARD 
1010*a3434a2dSAnthony PERARD #endif
1011