1 /******************************************************************************
2 * netif.h
3 *
4 * Unified network-device I/O interface for Xen guest OSes.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Copyright (c) 2003-2004, Keir Fraser
25 */
26
27 #ifndef __XEN_PUBLIC_IO_NETIF_H__
28 #define __XEN_PUBLIC_IO_NETIF_H__
29
30 #include "ring.h"
31 #include "../grant_table.h"
32
33 /*
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).
39 */
40
41 /*
42 * This is the 'wire' format for packets:
43 * Request 1: netif_tx_request -- NETTXF_* (any flags)
44 * [Request 2: netif_tx_extra] (only if request 1 has NETTXF_extra_info)
45 * [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_FLAG_MORE)
46 * Request 4: netif_tx_request -- NETTXF_more_data
47 * Request 5: netif_tx_request -- NETTXF_more_data
48 * ...
49 * Request N: netif_tx_request -- 0
50 */
51
52 /* Protocol checksum field is blank in the packet (hardware offload)? */
53 #define _NETTXF_csum_blank (0)
54 #define NETTXF_csum_blank (1U<<_NETTXF_csum_blank)
55
56 /* Packet data has been validated against protocol checksum. */
57 #define _NETTXF_data_validated (1)
58 #define NETTXF_data_validated (1U<<_NETTXF_data_validated)
59
60 /* Packet continues in the next request descriptor. */
61 #define _NETTXF_more_data (2)
62 #define NETTXF_more_data (1U<<_NETTXF_more_data)
63
64 /* Packet to be followed by extra descriptor(s). */
65 #define _NETTXF_extra_info (3)
66 #define NETTXF_extra_info (1U<<_NETTXF_extra_info)
67
68 struct netif_tx_request {
69 grant_ref_t gref; /* Reference to buffer page */
70 uint16_t offset; /* Offset within buffer page */
71 uint16_t flags; /* NETTXF_* */
72 uint16_t id; /* Echoed in response message. */
73 uint16_t size; /* For the first request in a packet, the packet
74 size in bytes. For subsequent requests, the
75 size of that request's associated data in bytes*/
76 };
77 typedef struct netif_tx_request netif_tx_request_t;
78
79 /* Types of netif_extra_info descriptors. */
80 #define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */
81 #define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */
82 #define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2) /* u.mcast */
83 #define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3) /* u.mcast */
84 #define XEN_NETIF_EXTRA_TYPE_MAX (4)
85
86 /* netif_extra_info flags. */
87 #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
88 #define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
89
90 /* GSO types - only TCPv4 currently supported. */
91 #define XEN_NETIF_GSO_TYPE_TCPV4 (1)
92
93 /*
94 * This structure needs to fit within both netif_tx_request and
95 * netif_rx_response for compatibility.
96 */
97 struct netif_extra_info {
98 uint8_t type; /* XEN_NETIF_EXTRA_TYPE_* */
99 uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */
100
101 union {
102 /*
103 * XEN_NETIF_EXTRA_TYPE_GSO:
104 */
105 struct {
106 /*
107 * Maximum payload size of each segment. For example, for TCP this
108 * is just the path MSS.
109 */
110 uint16_t size;
111
112 /*
113 * GSO type. This determines the protocol of the packet and any
114 * extra features required to segment the packet properly.
115 */
116 uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
117
118 /* Future expansion. */
119 uint8_t pad;
120
121 /*
122 * GSO features. This specifies any extra GSO features required
123 * to process this packet, such as ECN support for TCPv4.
124 */
125 uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
126 } gso;
127
128 /*
129 * XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}:
130 * Backend advertises availability via 'feature-multicast-control'
131 * xenbus node containing value '1'.
132 * Frontend requests this feature by advertising
133 * 'request-multicast-control' xenbus node containing value '1'.
134 * If multicast control is requested then multicast flooding is
135 * disabled and the frontend must explicitly register its interest
136 * in multicast groups using dummy transmit requests containing
137 * MCAST_{ADD,DEL} extra-info fragments.
138 */
139 struct {
140 uint8_t addr[6]; /* Address to add/remove. */
141 } mcast;
142
143 uint16_t pad[3];
144 } u;
145 };
146 typedef struct netif_extra_info netif_extra_info_t;
147
148 struct netif_tx_response {
149 uint16_t id;
150 int16_t status; /* NETIF_RSP_* */
151 };
152 typedef struct netif_tx_response netif_tx_response_t;
153
154 struct netif_rx_request {
155 uint16_t id; /* Echoed in response message. */
156 grant_ref_t gref; /* Reference to incoming granted frame */
157 };
158 typedef struct netif_rx_request netif_rx_request_t;
159
160 /* Packet data has been validated against protocol checksum. */
161 #define _NETRXF_data_validated (0)
162 #define NETRXF_data_validated (1U<<_NETRXF_data_validated)
163
164 /* Protocol checksum field is blank in the packet (hardware offload)? */
165 #define _NETRXF_csum_blank (1)
166 #define NETRXF_csum_blank (1U<<_NETRXF_csum_blank)
167
168 /* Packet continues in the next request descriptor. */
169 #define _NETRXF_more_data (2)
170 #define NETRXF_more_data (1U<<_NETRXF_more_data)
171
172 /* Packet to be followed by extra descriptor(s). */
173 #define _NETRXF_extra_info (3)
174 #define NETRXF_extra_info (1U<<_NETRXF_extra_info)
175
176 /* GSO Prefix descriptor. */
177 #define _NETRXF_gso_prefix (4)
178 #define NETRXF_gso_prefix (1U<<_NETRXF_gso_prefix)
179
180 struct netif_rx_response {
181 uint16_t id;
182 uint16_t offset; /* Offset in page of start of received packet */
183 uint16_t flags; /* NETRXF_* */
184 int16_t status; /* -ve: NETIF_RSP_* ; +ve: Rx'ed response size. */
185 };
186 typedef struct netif_rx_response netif_rx_response_t;
187
188 /*
189 * Generate netif ring structures and types.
190 */
191
192 DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
193 DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
194
195 #define NETIF_RSP_DROPPED -2
196 #define NETIF_RSP_ERROR -1
197 #define NETIF_RSP_OKAY 0
198 /* No response: used for auxiliary requests (e.g., netif_tx_extra). */
199 #define NETIF_RSP_NULL 1
200
201 #endif
202
203 /*
204 * Local variables:
205 * mode: C
206 * c-set-style: "BSD"
207 * c-basic-offset: 4
208 * tab-width: 4
209 * indent-tabs-mode: nil
210 * End:
211 */
Cache object: dc5394b2c3feb2dfd532fd00443c94d9
|