Path: blob/master/include/xen/interface/io/netif.h
10818 views
/******************************************************************************1* netif.h2*3* Unified network-device I/O interface for Xen guest OSes.4*5* Copyright (c) 2003-2004, Keir Fraser6*/78#ifndef __XEN_PUBLIC_IO_NETIF_H__9#define __XEN_PUBLIC_IO_NETIF_H__1011#include "ring.h"12#include "../grant_table.h"1314/*15* Notifications after enqueuing any type of message should be conditional on16* the appropriate req_event or rsp_event field in the shared ring.17* If the client sends notification for rx requests then it should specify18* feature 'feature-rx-notify' via xenbus. Otherwise the backend will assume19* that it cannot safely queue packets (as it may not be kicked to send them).20*/2122/*23* This is the 'wire' format for packets:24* Request 1: xen_netif_tx_request -- XEN_NETTXF_* (any flags)25* [Request 2: xen_netif_extra_info] (only if request 1 has XEN_NETTXF_extra_info)26* [Request 3: xen_netif_extra_info] (only if request 2 has XEN_NETIF_EXTRA_MORE)27* Request 4: xen_netif_tx_request -- XEN_NETTXF_more_data28* Request 5: xen_netif_tx_request -- XEN_NETTXF_more_data29* ...30* Request N: xen_netif_tx_request -- 031*/3233/* Protocol checksum field is blank in the packet (hardware offload)? */34#define _XEN_NETTXF_csum_blank (0)35#define XEN_NETTXF_csum_blank (1U<<_XEN_NETTXF_csum_blank)3637/* Packet data has been validated against protocol checksum. */38#define _XEN_NETTXF_data_validated (1)39#define XEN_NETTXF_data_validated (1U<<_XEN_NETTXF_data_validated)4041/* Packet continues in the next request descriptor. */42#define _XEN_NETTXF_more_data (2)43#define XEN_NETTXF_more_data (1U<<_XEN_NETTXF_more_data)4445/* Packet to be followed by extra descriptor(s). */46#define _XEN_NETTXF_extra_info (3)47#define XEN_NETTXF_extra_info (1U<<_XEN_NETTXF_extra_info)4849struct xen_netif_tx_request {50grant_ref_t gref; /* Reference to buffer page */51uint16_t offset; /* Offset within buffer page */52uint16_t flags; /* XEN_NETTXF_* */53uint16_t id; /* Echoed in response message. */54uint16_t size; /* Packet size in bytes. */55};5657/* Types of xen_netif_extra_info descriptors. */58#define XEN_NETIF_EXTRA_TYPE_NONE (0) /* Never used - invalid */59#define XEN_NETIF_EXTRA_TYPE_GSO (1) /* u.gso */60#define XEN_NETIF_EXTRA_TYPE_MAX (2)6162/* xen_netif_extra_info flags. */63#define _XEN_NETIF_EXTRA_FLAG_MORE (0)64#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)6566/* GSO types - only TCPv4 currently supported. */67#define XEN_NETIF_GSO_TYPE_TCPV4 (1)6869/*70* This structure needs to fit within both netif_tx_request and71* netif_rx_response for compatibility.72*/73struct xen_netif_extra_info {74uint8_t type; /* XEN_NETIF_EXTRA_TYPE_* */75uint8_t flags; /* XEN_NETIF_EXTRA_FLAG_* */7677union {78struct {79/*80* Maximum payload size of each segment. For81* example, for TCP this is just the path MSS.82*/83uint16_t size;8485/*86* GSO type. This determines the protocol of87* the packet and any extra features required88* to segment the packet properly.89*/90uint8_t type; /* XEN_NETIF_GSO_TYPE_* */9192/* Future expansion. */93uint8_t pad;9495/*96* GSO features. This specifies any extra GSO97* features required to process this packet,98* such as ECN support for TCPv4.99*/100uint16_t features; /* XEN_NETIF_GSO_FEAT_* */101} gso;102103uint16_t pad[3];104} u;105};106107struct xen_netif_tx_response {108uint16_t id;109int16_t status; /* XEN_NETIF_RSP_* */110};111112struct xen_netif_rx_request {113uint16_t id; /* Echoed in response message. */114grant_ref_t gref; /* Reference to incoming granted frame */115};116117/* Packet data has been validated against protocol checksum. */118#define _XEN_NETRXF_data_validated (0)119#define XEN_NETRXF_data_validated (1U<<_XEN_NETRXF_data_validated)120121/* Protocol checksum field is blank in the packet (hardware offload)? */122#define _XEN_NETRXF_csum_blank (1)123#define XEN_NETRXF_csum_blank (1U<<_XEN_NETRXF_csum_blank)124125/* Packet continues in the next request descriptor. */126#define _XEN_NETRXF_more_data (2)127#define XEN_NETRXF_more_data (1U<<_XEN_NETRXF_more_data)128129/* Packet to be followed by extra descriptor(s). */130#define _XEN_NETRXF_extra_info (3)131#define XEN_NETRXF_extra_info (1U<<_XEN_NETRXF_extra_info)132133/* GSO Prefix descriptor. */134#define _XEN_NETRXF_gso_prefix (4)135#define XEN_NETRXF_gso_prefix (1U<<_XEN_NETRXF_gso_prefix)136137struct xen_netif_rx_response {138uint16_t id;139uint16_t offset; /* Offset in page of start of received packet */140uint16_t flags; /* XEN_NETRXF_* */141int16_t status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */142};143144/*145* Generate netif ring structures and types.146*/147148DEFINE_RING_TYPES(xen_netif_tx,149struct xen_netif_tx_request,150struct xen_netif_tx_response);151DEFINE_RING_TYPES(xen_netif_rx,152struct xen_netif_rx_request,153struct xen_netif_rx_response);154155#define XEN_NETIF_RSP_DROPPED -2156#define XEN_NETIF_RSP_ERROR -1157#define XEN_NETIF_RSP_OKAY 0158/* No response: used for auxiliary requests (e.g., xen_netif_extra_info). */159#define XEN_NETIF_RSP_NULL 1160161#endif162163164