1 /******************************************************************************
4 * Unified network-device I/O interface for Xen guest OSes.
6 * Copyright (c) 2003-2004, Keir Fraser
9 #ifndef __XEN_PUBLIC_IO_NETIF_H__
10 #define __XEN_PUBLIC_IO_NETIF_H__
13 #include "../grant_table.h"
16 * Notifications after enqueuing any type of message should be conditional on
17 * the appropriate req_event or rsp_event field in the shared ring.
18 * If the client sends notification for rx requests then it should specify
19 * feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume
20 * that it cannot safely queue packets (as it may not be kicked to send them).
24 * This is the 'wire' format for packets:
25 * Request 1: netif_tx_request -- NETTXF_* (any flags)
26 * [Request 2: netif_tx_extra] (only if request 1 has NETTXF_extra_info)
27 * [Request 3: netif_tx_extra] (only if request 2 has XEN_NETIF_EXTRA_MORE)
28 * Request 4: netif_tx_request -- NETTXF_more_data
29 * Request 5: netif_tx_request -- NETTXF_more_data
31 * Request N: netif_tx_request -- 0
34 /* Protocol checksum field is blank in the packet (hardware offload)? */
35 #define _NETTXF_csum_blank (0)
36 #define NETTXF_csum_blank (1U<<_NETTXF_csum_blank)
38 /* Packet data has been validated against protocol checksum. */
39 #define _NETTXF_data_validated (1)
40 #define NETTXF_data_validated (1U<<_NETTXF_data_validated)
42 /* Packet continues in the next request descriptor. */
43 #define _NETTXF_more_data (2)
44 #define NETTXF_more_data (1U<<_NETTXF_more_data)
46 /* Packet to be followed by extra descriptor(s). */
47 #define _NETTXF_extra_info (3)
48 #define NETTXF_extra_info (1U<<_NETTXF_extra_info)
50 struct netif_tx_request {
51 grant_ref_t gref; /* Reference to buffer page */
52 uint16_t offset; /* Offset within buffer page */
53 uint16_t flags; /* NETTXF_* */
54 uint16_t id; /* Echoed in response message. */
55 uint16_t size; /* Packet size in bytes. */
57 typedef struct netif_tx_request netif_tx_request_t;
59 /* Types of netif_extra_info descriptors. */
60 #define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */
61 #define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */
62 #define XEN_NETIF_EXTRA_TYPE_MAX (2)
64 /* netif_extra_info flags. */
65 #define _XEN_NETIF_EXTRA_FLAG_MORE (0)
66 #define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
68 /* GSO types - only TCPv4 currently supported. */
69 #define XEN_NETIF_GSO_TYPE_TCPV4 (1)
72 * This structure needs to fit within both netif_tx_request and
73 * netif_rx_response for compatibility.
75 struct netif_extra_info {
76 uint8_t type; /* XEN_NETIF_EXTRA_TYPE_* */
77 uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */
82 * Maximum payload size of each segment. For example, for TCP this
83 * is just the path MSS.
88 * GSO type. This determines the protocol of the packet and any
89 * extra features required to segment the packet properly.
91 uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
93 /* Future expansion. */
97 * GSO features. This specifies any extra GSO features required
98 * to process this packet, such as ECN support for TCPv4.
100 uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
107 struct netif_tx_response {
109 int16_t status; /* NETIF_RSP_* */
111 typedef struct netif_tx_response netif_tx_response_t;
113 struct netif_rx_request {
114 uint16_t id; /* Echoed in response message. */
115 grant_ref_t gref; /* Reference to incoming granted frame */
117 typedef struct netif_rx_request netif_rx_request_t;
119 /* Packet data has been validated against protocol checksum. */
120 #define _NETRXF_data_validated (0)
121 #define NETRXF_data_validated (1U<<_NETRXF_data_validated)
123 /* Protocol checksum field is blank in the packet (hardware offload)? */
124 #define _NETRXF_csum_blank (1)
125 #define NETRXF_csum_blank (1U<<_NETRXF_csum_blank)
127 /* Packet continues in the next request descriptor. */
128 #define _NETRXF_more_data (2)
129 #define NETRXF_more_data (1U<<_NETRXF_more_data)
131 /* Packet to be followed by extra descriptor(s). */
132 #define _NETRXF_extra_info (3)
133 #define NETRXF_extra_info (1U<<_NETRXF_extra_info)
135 struct netif_rx_response {
137 uint16_t offset; /* Offset in page of start of received packet */
138 uint16_t flags; /* NETRXF_* */
139 int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
141 typedef struct netif_rx_response netif_rx_response_t;
144 * Generate netif ring structures and types.
147 DEFINE_RING_TYPES(netif_tx, struct netif_tx_request, struct netif_tx_response);
148 DEFINE_RING_TYPES(netif_rx, struct netif_rx_request, struct netif_rx_response);
150 #define NETIF_RSP_DROPPED -2
151 #define NETIF_RSP_ERROR -1
152 #define NETIF_RSP_OKAY 0
153 /* No response: used for auxiliary requests (e.g., netif_tx_extra). */
154 #define NETIF_RSP_NULL 1
164 * indent-tabs-mode: nil