ia64/xen-unstable

view xen-2.4.16/include/hypervisor-ifs/network.h @ 97:ce656d157bbf

bitkeeper revision 1.15.1.9 (3e2fd418NdZYqL3KPr6URqd77DwnJQ)

Add shadow ring in the RX direction to protect buffers from guest
tampering once they have been passed to the hypervisor. This
is under the umbrella of eventual zero-copy network code.
author akw27@plucky.localdomain
date Thu Jan 23 11:38:00 2003 +0000 (2003-01-23)
parents 8ce741992076
children de280362dfb0 cb2688ed1a23
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 int status; /* per descriptor status. */
21 } tx_entry_t;
23 typedef struct rx_entry_st {
24 unsigned long addr; /* virtual address */
25 unsigned long size; /* in bytes */
26 int status; /* per descriptor status. */
27 } rx_entry_t;
29 #define TX_RING_SIZE 1024
30 #define RX_RING_SIZE 1024
31 typedef struct net_ring_st {
32 /*
33 * Guest OS places packets into ring at tx_prod.
34 * Hypervisor removes at tx_cons.
35 * Ring is empty when tx_prod == tx_cons.
36 * Guest OS receives a DOMAIN_EVENT_NET_TX when tx_cons passes tx_event.
37 * Hypervisor may be prodded whenever tx_prod is updated, but this is
38 * only necessary when tx_cons == old_tx_prod (ie. transmitter stalled).
39 */
40 tx_entry_t *tx_ring;
41 unsigned int tx_prod, tx_cons, tx_event;
42 unsigned int tx_ring_size;
43 /*
44 * Guest OS places empty buffers into ring at rx_prod.
45 * Hypervisor fills buffers as rx_cons.
46 * Ring is empty when rx_prod == rx_cons.
47 * Guest OS receives a DOMAIN_EVENT_NET_RX when rx_cons passes rx_event.
48 * Hypervisor may be prodded whenever rx_prod is updated, but this is
49 * only necessary when rx_cons == old_rx_prod (ie. receiver stalled).
50 */
51 rx_entry_t *rx_ring;
52 unsigned int rx_prod, rx_cons, rx_event;
53 unsigned int rx_ring_size;
54 } net_ring_t;
56 /* Specify base of per-domain array. Get returned free slot in the array. */
57 //net_ring_t *create_net_vif(int domain);
59 /* Packet routing/filtering code follows:
60 */
62 #define NETWORK_ACTION_ACCEPT 0
63 #define NETWORK_ACTION_COUNT 1
65 #define NETWORK_PROTO_ANY 0
66 #define NETWORK_PROTO_IP 1
67 #define NETWORK_PROTO_TCP 2
68 #define NETWORK_PROTO_UDP 3
69 #define NETWORK_PROTO_ARP 4
71 typedef struct net_rule_st
72 {
73 u32 src_addr;
74 u32 dst_addr;
75 u16 src_port;
76 u16 dst_port;
77 u32 src_addr_mask;
78 u32 dst_addr_mask;
79 u16 src_port_mask;
80 u16 dst_port_mask;
81 u16 proto;
83 int src_interface;
84 int dst_interface;
85 u16 action;
86 } net_rule_t;
88 /* Network trap operations and associated structure.
89 * This presently just handles rule insertion and deletion, but will
90 * evenually have code to add and remove interfaces.
91 */
93 #define NETWORK_OP_ADDRULE 0
94 #define NETWORK_OP_DELETERULE 1
95 #define NETWORK_OP_GETRULELIST 2
97 typedef struct network_op_st
98 {
99 unsigned long cmd;
100 union
101 {
102 net_rule_t net_rule;
103 }
104 u;
105 } network_op_t;
107 typedef struct net_rule_ent_st
108 {
109 net_rule_t r;
110 struct net_rule_ent_st *next;
111 } net_rule_ent_t;
113 /* Drop a new rule down to the network tables. */
114 int add_net_rule(net_rule_t *rule);
117 /* Descriptor status values:
118 */
120 #define RING_STATUS_OK 0 // Everything is gravy.
121 #define RING_STATUS_ERR_CFU -1 // Copy from user problems.
123 #endif