1
/******************************************************************************
4
* ring data structures for buffering messages between hypervisor and
5
* guestos's. As it stands this is only used for network buffer exchange.
7
* This file also contains structures and interfaces for the per-domain
8
* routing/filtering tables in the hypervisor.
16
* Command values for block_io_op()
19
#define NETOP_PUSH_BUFFERS 0 /* Notify Xen of new buffers on the rings. */
20
#define NETOP_FLUSH_BUFFERS 1 /* Flush all pending request buffers. */
21
#define NETOP_RESET_RINGS 2 /* Reset ring indexes on a quiescent vif. */
22
#define NETOP_GET_VIF_INFO 3 /* Query information for this vif. */
23
typedef struct netop_st {
24
unsigned int cmd; /* NETOP_xxx */
25
unsigned int vif; /* VIF index */
28
unsigned long ring_mfn; /* Page frame containing net_ring_t. */
29
unsigned char vmac[6]; /* Virtual Ethernet MAC address. */
35
typedef struct tx_req_entry_st
38
unsigned short size; /* packet size in bytes */
39
unsigned long addr; /* machine address of packet */
42
typedef struct tx_resp_entry_st
48
typedef union tx_entry_st
55
typedef struct rx_req_entry_st
58
unsigned long addr; /* machine address of PTE to swizzle */
61
typedef struct rx_resp_entry_st
64
unsigned short size; /* received packet size in bytes */
65
unsigned char status; /* per descriptor status */
66
unsigned char offset; /* offset in page of received pkt */
69
typedef union rx_entry_st
76
#define TX_RING_SIZE 256
77
#define RX_RING_SIZE 256
79
#define MAX_DOMAIN_VIFS 8
81
/* This structure must fit in a memory page. */
82
typedef struct net_ring_st
84
tx_entry_t tx_ring[TX_RING_SIZE];
85
rx_entry_t rx_ring[RX_RING_SIZE];
88
typedef struct net_idx_st
91
* Guest OS places packets into ring at tx_req_prod.
92
* Guest OS receives EVENT_NET when tx_resp_prod passes tx_event.
93
* Guest OS places empty buffers into ring at rx_req_prod.
94
* Guest OS receives EVENT_NET when rx_rssp_prod passes rx_event.
96
unsigned int tx_req_prod, tx_resp_prod, tx_event;
97
unsigned int rx_req_prod, rx_resp_prod, rx_event;
101
* Packet routing/filtering code follows:
104
#define NETWORK_ACTION_ACCEPT 0
105
#define NETWORK_ACTION_COUNT 1
107
#define NETWORK_PROTO_ANY 0
108
#define NETWORK_PROTO_IP 1
109
#define NETWORK_PROTO_TCP 2
110
#define NETWORK_PROTO_UDP 3
111
#define NETWORK_PROTO_ARP 4
113
typedef struct net_rule_st
124
unsigned long src_vif;
125
unsigned long dst_vif;
129
#define VIF_DOMAIN_MASK 0xfffff000UL
130
#define VIF_DOMAIN_SHIFT 12
131
#define VIF_INDEX_MASK 0x00000fffUL
132
#define VIF_INDEX_SHIFT 0
134
/* These are specified in the index if the dom is SPECIAL. */
135
#define VIF_SPECIAL 0xfffff000UL
136
#define VIF_UNKNOWN_INTERFACE (VIF_SPECIAL | 0)
137
#define VIF_PHYSICAL_INTERFACE (VIF_SPECIAL | 1)
138
#define VIF_ANY_INTERFACE (VIF_SPECIAL | 2)
140
typedef struct vif_query_st
143
int *buf; /* reply buffer -- guest virtual address */
146
typedef struct vif_getinfo_st
151
/* domain & vif are supplied by dom0, the rest are response fields */
152
long long total_bytes_sent;
153
long long total_bytes_received;
154
long long total_packets_sent;
155
long long total_packets_received;
157
/* Current scheduling parameters */
158
unsigned long credit_bytes;
159
unsigned long credit_usec;
163
* Set parameters associated with a VIF. Currently this is only scheduling
164
* parameters --- permit 'credit_bytes' to be transmitted every 'credit_usec'.
166
typedef struct vif_setparams_st
170
unsigned long credit_bytes;
171
unsigned long credit_usec;
174
/* Network trap operations and associated structure.
175
* This presently just handles rule insertion and deletion, but will
176
* evenually have code to add and remove interfaces.
179
#define NETWORK_OP_ADDRULE 0
180
#define NETWORK_OP_DELETERULE 1
181
#define NETWORK_OP_GETRULELIST 2
182
#define NETWORK_OP_VIFQUERY 3
183
#define NETWORK_OP_VIFGETINFO 4
184
#define NETWORK_OP_VIFSETPARAMS 5
186
typedef struct network_op_st
192
vif_query_t vif_query;
193
vif_getinfo_t vif_getinfo;
194
vif_setparams_t vif_setparams;
199
typedef struct net_rule_ent_st
202
struct net_rule_ent_st *next;
205
/* Drop a new rule down to the network tables. */
206
int add_net_rule(net_rule_t *rule);
208
/* Descriptor status values */
209
#define RING_STATUS_OK 0 /* Everything is gravy. */
210
#define RING_STATUS_BAD_PAGE 1 /* What they gave us was pure evil */
211
#define RING_STATUS_DROPPED 2 /* Unrouteable packet */