ia64/xen-unstable

view xen/include/public/io/netif.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
line source
1 /******************************************************************************
2 * netif.h
3 *
4 * Unified network-device I/O interface for Xen guest OSes.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser
7 */
9 #ifndef __XEN_PUBLIC_IO_NETIF_H__
10 #define __XEN_PUBLIC_IO_NETIF_H__
12 typedef struct netif_tx_request {
13 unsigned long addr; /* Machine address of packet. */
14 u16 csum_blank:1; /* Proto csum field blank? */
15 u16 id:15; /* Echoed in response message. */
16 u16 size; /* Packet size in bytes. */
17 } netif_tx_request_t;
19 typedef struct netif_tx_response {
20 u16 id;
21 s8 status;
22 } netif_tx_response_t;
24 typedef struct {
25 u16 id; /* Echoed in response message. */
26 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
27 grant_ref_t gref; /* 2: Reference to incoming granted frame */
28 #endif
29 } netif_rx_request_t;
31 typedef struct {
32 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
33 u32 addr; /* 0: Offset in page of start of received packet */
34 #else
35 unsigned long addr; /* Machine address of packet. */
36 #endif
37 u16 csum_valid:1; /* Protocol checksum is validated? */
38 u16 id:15;
39 s16 status; /* -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
40 } netif_rx_response_t;
42 /*
43 * We use a special capitalised type name because it is _essential_ that all
44 * arithmetic on indexes is done on an integer type of the correct size.
45 */
46 typedef u32 NETIF_RING_IDX;
48 /*
49 * Ring indexes are 'free running'. That is, they are not stored modulo the
50 * size of the ring buffer. The following macros convert a free-running counter
51 * into a value that can directly index a ring-buffer array.
52 */
53 #define MASK_NETIF_RX_IDX(_i) ((_i)&(NETIF_RX_RING_SIZE-1))
54 #define MASK_NETIF_TX_IDX(_i) ((_i)&(NETIF_TX_RING_SIZE-1))
56 #ifdef __x86_64__
57 /*
58 * This restriction can be lifted when we move netfront/netback to use
59 * grant tables. This will remove memory_t fields from the above structures
60 * and thus relax natural alignment restrictions.
61 */
62 #define NETIF_TX_RING_SIZE 128
63 #define NETIF_RX_RING_SIZE 128
64 #else
65 #define NETIF_TX_RING_SIZE 256
66 #define NETIF_RX_RING_SIZE 256
67 #endif
69 /* This structure must fit in a memory page. */
70 typedef struct netif_tx_interface {
71 /*
72 * Frontend places packets into ring at tx_req_prod.
73 * Frontend receives event when tx_resp_prod passes tx_event.
74 * 'req_cons' is a shadow of the backend's request consumer -- the frontend
75 * may use it to determine if all queued packets have been seen by the
76 * backend.
77 */
78 NETIF_RING_IDX req_prod;
79 NETIF_RING_IDX req_cons;
80 NETIF_RING_IDX resp_prod;
81 NETIF_RING_IDX event;
82 union {
83 netif_tx_request_t req;
84 netif_tx_response_t resp;
85 } ring[NETIF_TX_RING_SIZE];
86 } netif_tx_interface_t;
88 /* This structure must fit in a memory page. */
89 typedef struct netif_rx_interface {
90 /*
91 * Frontend places empty buffers into ring at rx_req_prod.
92 * Frontend receives event when rx_resp_prod passes rx_event.
93 */
94 NETIF_RING_IDX req_prod;
95 NETIF_RING_IDX resp_prod;
96 NETIF_RING_IDX event;
97 union {
98 netif_rx_request_t req;
99 netif_rx_response_t resp;
100 } ring[NETIF_RX_RING_SIZE];
101 } netif_rx_interface_t;
103 /* Descriptor status values */
104 #define NETIF_RSP_DROPPED -2
105 #define NETIF_RSP_ERROR -1
106 #define NETIF_RSP_OKAY 0
108 #endif