ia64/xen-unstable

view linux-2.6.7-xen-sparse/include/asm-xen/netif.h @ 1820:3d4f8eb89670

bitkeeper revision 1.1106.1.2 (40faa780dekT3E5arFwcbQDu1MbX6g)

Cleaned up Xen's instruction emulator.
author kaf24@scramble.cl.cam.ac.uk
date Sun Jul 18 16:38:24 2004 +0000 (2004-07-18)
parents 002fc84add90
children
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 __SHARED_NETIF_H__
10 #define __SHARED_NETIF_H__
12 typedef struct {
13 memory_t addr; /* 0: Machine address of packet. */
14 MEMORY_PADDING;
15 u16 id; /* 8: Echoed in response message. */
16 u16 size; /* 10: Packet size in bytes. */
17 } PACKED netif_tx_request_t; /* 12 bytes */
19 typedef struct {
20 u16 id; /* 0 */
21 s8 status; /* 2 */
22 u8 __pad; /* 3 */
23 } PACKED netif_tx_response_t; /* 4 bytes */
25 typedef struct {
26 u16 id; /* 0: Echoed in response message. */
27 } PACKED netif_rx_request_t; /* 2 bytes */
29 typedef struct {
30 memory_t addr; /* 0: Machine address of packet. */
31 MEMORY_PADDING;
32 u16 id; /* 8: */
33 s16 status; /* 10: -ve: BLKIF_RSP_* ; +ve: Rx'ed pkt size. */
34 } PACKED netif_rx_response_t; /* 12 bytes */
36 /*
37 * We use a special capitalised type name because it is _essential_ that all
38 * arithmetic on indexes is done on an integer type of the correct size.
39 */
40 typedef u32 NETIF_RING_IDX;
42 /*
43 * Ring indexes are 'free running'. That is, they are not stored modulo the
44 * size of the ring buffer. The following macros convert a free-running counter
45 * into a value that can directly index a ring-buffer array.
46 */
47 #define MASK_NETIF_RX_IDX(_i) ((_i)&(NETIF_RX_RING_SIZE-1))
48 #define MASK_NETIF_TX_IDX(_i) ((_i)&(NETIF_TX_RING_SIZE-1))
50 #define NETIF_TX_RING_SIZE 256
51 #define NETIF_RX_RING_SIZE 256
53 /* This structure must fit in a memory page. */
54 typedef struct {
55 /*
56 * Frontend places packets into ring at tx_req_prod.
57 * Frontend receives event when tx_resp_prod passes tx_event.
58 */
59 NETIF_RING_IDX req_prod; /* 0 */
60 NETIF_RING_IDX resp_prod; /* 4 */
61 NETIF_RING_IDX event; /* 8 */
62 union { /* 12 */
63 netif_tx_request_t req;
64 netif_tx_response_t resp;
65 } PACKED ring[NETIF_TX_RING_SIZE];
66 } PACKED netif_tx_interface_t;
68 /* This structure must fit in a memory page. */
69 typedef struct {
70 /*
71 * Frontend places empty buffers into ring at rx_req_prod.
72 * Frontend receives event when rx_resp_prod passes rx_event.
73 */
74 NETIF_RING_IDX req_prod; /* 0 */
75 NETIF_RING_IDX resp_prod; /* 4 */
76 NETIF_RING_IDX event; /* 8 */
77 union { /* 12 */
78 netif_rx_request_t req;
79 netif_rx_response_t resp;
80 } PACKED ring[NETIF_RX_RING_SIZE];
81 } PACKED netif_rx_interface_t;
83 /* Descriptor status values */
84 #define NETIF_RSP_DROPPED -2
85 #define NETIF_RSP_ERROR -1
86 #define NETIF_RSP_OKAY 0
88 #endif