1 /* $NetBSD: netif.h,v 1.5 2007/10/17 19:58:31 garbled Exp $ */
2 /******************************************************************************
5 * Unified network-device I/O interface for Xen guest OSes.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Copyright (c) 2003-2004, Keir Fraser
28 #ifndef __XEN_PUBLIC_IO_NETIF_H__
29 #define __XEN_PUBLIC_IO_NETIF_H__
32 #include "../grant_table.h"
35 * Notifications after enqueuing any type of message should be conditional on
36 * the appropriate req_event or rsp_event field in the shared ring.
37 * If the client sends notification for rx requests then it should specify
38 * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
39 * that it cannot safely queue packets (as it may not be kicked to send them).
43 * This is the 'wire' format for packets:
44 * Request 1: netif_tx_request -- NETTXF_* (any flags)
45 * [Request 2: netif_tx_extra] (only if request 1 has NETTXF_extra_info)
46 * [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_MORE)
47 * Request 4: netif_tx_request -- NETTXF_more_data
48 * Request 5: netif_tx_request -- NETTXF_more_data
50 * Request N: netif_tx_request -- 0
53 /* Protocol checksum field is blank in the packet (hardware offload)? */
54 #define _NETTXF_csum_blank (0)
55 #define NETTXF_csum_blank (1U<<_NETTXF_csum_blank)
57 /* Packet data has been validated against protocol checksum. */
58 #define _NETTXF_data_validated (1)
59 #define NETTXF_data_validated (1U<<_NETTXF_data_validated)
61 /* Packet continues in the next request descriptor. */
62 #define _NETTXF_more_data (2)
63 #define NETTXF_more_data (1U<<_NETTXF_more_data)
65 /* Packet to be followed by extra descriptor(s). */
66 #define _NETTXF_extra_info (3)
67 #define NETTXF_extra_info (1U<<_NETTXF_extra_info)
69 struct netif_tx_request
{
70 grant_ref_t gref
; /* Reference to buffer page */
71 uint16_t offset
; /* Offset within buffer page */
72 uint16_t flags
; /* NETTXF_* */
73 uint16_t id
; /* Echoed in response message. */
74 uint16_t size
; /* Packet size in bytes. */
76 typedef struct netif_tx_request netif_tx_request_t
;
78 /* Types of netif_extra_info descriptors. */
79 #define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */
80 #define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */
81 #define XEN_NETIF_EXTRA_TYPE_MCAST_ADD (2) /* u.mcast */
82 #define XEN_NETIF_EXTRA_TYPE_MCAST_DEL (3) /* u.mcast */
83 #define XEN_NETIF_EXTRA_TYPE_MAX (4)
85 /* netif_extra_info flags. */
86 #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
87 #define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
89 /* GSO types - only TCPv4 currently supported. */
90 #define XEN_NETIF_GSO_TYPE_TCPV4 (1)
93 * This structure needs to fit within both netif_tx_request and
94 * netif_rx_response for compatibility.
96 struct netif_extra_info
{
97 uint8_t type
; /* XEN_NETIF_EXTRA_TYPE_* */
98 uint8_t flags
; /* XEN_NETIF_EXTRA_FLAG_* */
102 * XEN_NETIF_EXTRA_TYPE_GSO:
106 * Maximum payload size of each segment. For example, for TCP this
107 * is just the path MSS.
112 * GSO type. This determines the protocol of the packet and any
113 * extra features required to segment the packet properly.
115 uint8_t type
; /* XEN_NETIF_GSO_TYPE_* */
117 /* Future expansion. */
121 * GSO features. This specifies any extra GSO features required
122 * to process this packet, such as ECN support for TCPv4.
124 uint16_t features
; /* XEN_NETIF_GSO_FEAT_* */
128 * XEN_NETIF_EXTRA_TYPE_MCAST_{ADD,DEL}:
129 * Backend advertises availability via 'feature-multicast-control'
130 * xenbus node containing value '1'.
131 * Frontend requests this feature by advertising
132 * 'request-multicast-control' xenbus node containing value '1'.
133 * If multicast control is requested then multicast flooding is
134 * disabled and the frontend must explicitly register its interest
135 * in multicast groups using dummy transmit requests containing
136 * MCAST_{ADD,DEL} extra-info fragments.
139 uint8_t addr
[6]; /* Address to add/remove. */
145 typedef struct netif_extra_info netif_extra_info_t
;
147 struct netif_tx_response
{
149 int16_t status
; /* NETIF_RSP_* */
151 typedef struct netif_tx_response netif_tx_response_t
;
153 struct netif_rx_request
{
154 uint16_t id
; /* Echoed in response message. */
155 grant_ref_t gref
; /* Reference to incoming granted frame */
157 typedef struct netif_rx_request netif_rx_request_t
;
159 /* Packet data has been validated against protocol checksum. */
160 #define _NETRXF_data_validated (0)
161 #define NETRXF_data_validated (1U<<_NETRXF_data_validated)
163 /* Protocol checksum field is blank in the packet (hardware offload)? */
164 #define _NETRXF_csum_blank (1)
165 #define NETRXF_csum_blank (1U<<_NETRXF_csum_blank)
167 /* Packet continues in the next request descriptor. */
168 #define _NETRXF_more_data (2)
169 #define NETRXF_more_data (1U<<_NETRXF_more_data)
171 /* Packet to be followed by extra descriptor(s). */
172 #define _NETRXF_extra_info (3)
173 #define NETRXF_extra_info (1U<<_NETRXF_extra_info)
175 struct netif_rx_response
{
177 uint16_t offset
; /* Offset in page of start of received packet */
178 uint16_t flags
; /* NETRXF_* */
179 int16_t status
; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
181 typedef struct netif_rx_response netif_rx_response_t
;
184 * Generate netif ring structures and types.
187 DEFINE_RING_TYPES(netif_tx
, struct netif_tx_request
, struct netif_tx_response
);
188 DEFINE_RING_TYPES(netif_rx
, struct netif_rx_request
, struct netif_rx_response
);
190 #define NETIF_RSP_DROPPED -2
191 #define NETIF_RSP_ERROR -1
192 #define NETIF_RSP_OKAY 0
193 /* No response: used for auxiliary requests (e.g., netif_tx_extra). */
194 #define NETIF_RSP_NULL 1
204 * indent-tabs-mode: nil