~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/hypervisor-ifs/network.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 */
11
 
 
12
 
#ifndef __RING_H__
13
 
#define __RING_H__
14
 
 
15
 
/*
16
 
 * Command values for block_io_op()
17
 
 */
18
 
 
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 */
26
 
    union {
27
 
        struct {
28
 
            unsigned long ring_mfn; /* Page frame containing net_ring_t. */
29
 
            unsigned char vmac[6];  /* Virtual Ethernet MAC address.     */
30
 
        } get_vif_info;
31
 
    } u;
32
 
} netop_t;
33
 
 
34
 
 
35
 
typedef struct tx_req_entry_st
36
 
{
37
 
    unsigned short id;
38
 
    unsigned short size;   /* packet size in bytes */
39
 
    unsigned long  addr;   /* machine address of packet */
40
 
} tx_req_entry_t;
41
 
 
42
 
typedef struct tx_resp_entry_st
43
 
{
44
 
    unsigned short id;
45
 
    unsigned char  status;
46
 
} tx_resp_entry_t;
47
 
 
48
 
typedef union tx_entry_st
49
 
{
50
 
    tx_req_entry_t  req;
51
 
    tx_resp_entry_t resp;
52
 
} tx_entry_t;
53
 
 
54
 
 
55
 
typedef struct rx_req_entry_st
56
 
{
57
 
    unsigned short id;
58
 
    unsigned long  addr;   /* machine address of PTE to swizzle */
59
 
} rx_req_entry_t;
60
 
 
61
 
typedef struct rx_resp_entry_st
62
 
{
63
 
    unsigned short id;
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 */
67
 
} rx_resp_entry_t;
68
 
 
69
 
typedef union rx_entry_st
70
 
{
71
 
    rx_req_entry_t  req;
72
 
    rx_resp_entry_t resp;
73
 
} rx_entry_t;
74
 
 
75
 
 
76
 
#define TX_RING_SIZE 256
77
 
#define RX_RING_SIZE 256
78
 
 
79
 
#define MAX_DOMAIN_VIFS 8
80
 
 
81
 
/* This structure must fit in a memory page. */
82
 
typedef struct net_ring_st
83
 
{
84
 
    tx_entry_t tx_ring[TX_RING_SIZE];
85
 
    rx_entry_t rx_ring[RX_RING_SIZE];
86
 
} net_ring_t;
87
 
 
88
 
typedef struct net_idx_st
89
 
{
90
 
    /*
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.
95
 
     */
96
 
    unsigned int tx_req_prod, tx_resp_prod, tx_event;
97
 
    unsigned int rx_req_prod, rx_resp_prod, rx_event;
98
 
} net_idx_t;
99
 
 
100
 
/*
101
 
 * Packet routing/filtering code follows:
102
 
 */
103
 
 
104
 
#define NETWORK_ACTION_ACCEPT   0
105
 
#define NETWORK_ACTION_COUNT    1
106
 
 
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
112
 
 
113
 
typedef struct net_rule_st 
114
 
{
115
 
    u32  src_addr;
116
 
    u32  dst_addr;
117
 
    u16  src_port;
118
 
    u16  dst_port;
119
 
    u32  src_addr_mask;
120
 
    u32  dst_addr_mask;
121
 
    u16  src_port_mask;
122
 
    u16  dst_port_mask;
123
 
    u16  proto;
124
 
    unsigned long src_vif;
125
 
    unsigned long dst_vif;
126
 
    u16  action;
127
 
} net_rule_t;
128
 
 
129
 
#define VIF_DOMAIN_MASK  0xfffff000UL
130
 
#define VIF_DOMAIN_SHIFT 12
131
 
#define VIF_INDEX_MASK   0x00000fffUL
132
 
#define VIF_INDEX_SHIFT  0
133
 
 
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)
139
 
 
140
 
typedef struct vif_query_st
141
 
{
142
 
    domid_t  domain;
143
 
    int     *buf;   /* reply buffer -- guest virtual address */
144
 
} vif_query_t;
145
 
 
146
 
typedef struct vif_getinfo_st
147
 
{
148
 
    domid_t             domain;
149
 
    unsigned int        vif;
150
 
 
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;
156
 
 
157
 
    /* Current scheduling parameters */
158
 
    unsigned long credit_bytes;
159
 
    unsigned long credit_usec;
160
 
} vif_getinfo_t;
161
 
 
162
 
/*
163
 
 * Set parameters associated with a VIF. Currently this is only scheduling
164
 
 * parameters --- permit 'credit_bytes' to be transmitted every 'credit_usec'.
165
 
 */
166
 
typedef struct vif_setparams_st
167
 
{
168
 
    domid_t             domain;
169
 
    unsigned int        vif;
170
 
    unsigned long       credit_bytes;
171
 
    unsigned long       credit_usec;
172
 
} vif_setparams_t;
173
 
 
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.
177
 
 */
178
 
 
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
185
 
 
186
 
typedef struct network_op_st 
187
 
{
188
 
    unsigned long cmd;
189
 
    union
190
 
    {
191
 
        net_rule_t net_rule;
192
 
        vif_query_t vif_query;
193
 
        vif_getinfo_t vif_getinfo;
194
 
        vif_setparams_t vif_setparams;
195
 
    }
196
 
    u;
197
 
} network_op_t;
198
 
 
199
 
typedef struct net_rule_ent_st
200
 
{
201
 
    net_rule_t r;
202
 
    struct net_rule_ent_st *next;
203
 
} net_rule_ent_t;
204
 
 
205
 
/* Drop a new rule down to the network tables. */
206
 
int add_net_rule(net_rule_t *rule);
207
 
 
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 */
212
 
 
213
 
#endif