ia64/xen-unstable

view xen-2.4.16/include/hypervisor-ifs/network.h @ 77:024aa2a06c1e

bitkeeper revision 1.7.3.52 (3e1019294uiW6rByAS_Bs30dgMr6AA)

debug
author lynx@idefix.cl.cam.ac.uk
date Mon Dec 30 10:00:09 2002 +0000 (2002-12-30)
parents 2c9f83193041
children 46df14441a61 78ce779f901c 8ce741992076
line source
1 /******************************************************************************
2 * network.h
3 *
4 * ring data structures for buffering messages between hypervisor and
5 * guestos's. As it stands this is only used for network buffer exchange.
6 *
7 * This file also contains structures and interfaces for the per-domain
8 * routing/filtering tables in the hypervisor.
9 *
10 */
12 #ifndef __RING_H__
13 #define __RING_H__
15 #include <linux/types.h>
17 typedef struct tx_entry_st {
18 unsigned long addr; /* virtual address */
19 unsigned long size; /* in bytes */
20 } tx_entry_t;
22 typedef struct rx_entry_st {
23 unsigned long addr; /* virtual address */
24 unsigned long size; /* in bytes */
25 } rx_entry_t;
27 #define TX_RING_SIZE 1024
28 #define RX_RING_SIZE 1024
29 typedef struct net_ring_st {
30 /*
31 * Guest OS places packets into ring at tx_prod.
32 * Hypervisor removes at tx_cons.
33 * Ring is empty when tx_prod == tx_cons.
34 * Guest OS receives a DOMAIN_EVENT_NET_TX when tx_cons passes tx_event.
35 * Hypervisor may be prodded whenever tx_prod is updated, but this is
36 * only necessary when tx_cons == old_tx_prod (ie. transmitter stalled).
37 */
38 tx_entry_t *tx_ring;
39 unsigned int tx_prod, tx_cons, tx_event;
40 unsigned int tx_ring_size;
41 /*
42 * Guest OS places empty buffers into ring at rx_prod.
43 * Hypervisor fills buffers as rx_cons.
44 * Ring is empty when rx_prod == rx_cons.
45 * Guest OS receives a DOMAIN_EVENT_NET_RX when rx_cons passes rx_event.
46 * Hypervisor may be prodded whenever rx_prod is updated, but this is
47 * only necessary when rx_cons == old_rx_prod (ie. receiver stalled).
48 */
49 rx_entry_t *rx_ring;
50 unsigned int rx_prod, rx_cons, rx_event;
51 unsigned int rx_ring_size;
52 } net_ring_t;
54 /* Specify base of per-domain array. Get returned free slot in the array. */
55 net_ring_t *create_net_vif(int domain);
57 /* Packet routing/filtering code follows:
58 */
60 #define NETWORK_ACTION_ACCEPT 0
61 #define NETWORK_ACTION_COUNT 1
63 #define NETWORK_PROTO_IP 0
64 #define NETWORK_PROTO_TCP 1
65 #define NETWORK_PROTO_UDP 2
66 #define NETWORK_PROTO_ARP 3
68 typedef struct net_rule_st
69 {
70 u32 src_addr;
71 u32 dst_addr;
72 u16 src_port;
73 u16 dst_port;
74 u32 src_addr_mask;
75 u32 dst_addr_mask;
76 u16 src_port_mask;
77 u16 dst_port_mask;
78 u16 proto;
80 u16 src_interface;
81 u16 dst_interface;
82 u16 action;
83 } net_rule_t;
85 /* Network trap operations and associated structure.
86 * This presently just handles rule insertion and deletion, but will
87 * evenually have code to add and remove interfaces.
88 */
90 #define NETWORK_OP_ADDRULE 0
91 #define NETWORK_OP_DELETERULE 1
92 #define NETWORK_OP_GETRULELIST 2
94 typedef struct network_op_st
95 {
96 unsigned long cmd;
97 union
98 {
99 net_rule_t net_rule;
100 }
101 u;
102 } network_op_t;
104 typedef struct net_rule_ent_st
105 {
106 net_rule_t r;
107 struct net_rule_ent_st *next;
108 } net_rule_ent_t;
110 /* Drop a new rule down to the network tables. */
111 int add_net_rule(net_rule_t *rule);
113 #endif