Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


040006d5f7c0062264fabb228a205cf056fb6599
[palacios.git] / palacios / include / palacios / vmm_vnet.h
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2010, Lei Xia <lxia@northwestern.edu> 
11  * Copyright (c) 2009, Yuan Tang <ytang@northwestern.edu> 
12  * Copyright (c) 2010, The V3VEE Project <http://www.v3vee.org> 
13  * All rights reserved.
14  *
15  * Author: Lei Xia <lxia@northwestern.edu>
16  *         Yuan Tang <ytang@northwestern.edu>
17  *
18  * This is free software.  You are permitted to use,
19  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20  */
21
22 #ifndef __VNET_H__
23 #define __VNET_H__
24
25 #include <palacios/vmm.h>
26
27 #define MAC_ANY 0
28 #define MAC_NOT 1
29 #define MAC_NONE 2 
30 #define MAC_ADDR 3
31
32 #define LINK_INTERFACE 0
33 #define LINK_EDGE 1 
34 #define LINK_ANY 2
35
36 #define VNET_HASH_SIZE 17
37 #define ETHERNET_HEADER_LEN 14
38 #define ETHERNET_MTU   1500
39 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN + ETHERNET_MTU)
40
41 #define VMM_DRIVERN 1
42 #define GUEST_DRIVERN 0
43
44 #define HOST_LNX_BRIDGE 1
45 #define CTL_VM_BRIDGE 2
46
47 //routing table entry
48 struct v3_vnet_route {
49     uint8_t src_mac[6];
50     uint8_t dst_mac[6];
51
52     uint8_t src_mac_qual;
53     uint8_t dst_mac_qual;
54
55     uint32_t dst_id;
56     uint8_t dst_type;
57  
58     uint32_t src_id;
59     uint8_t src_type;
60 } __attribute__((packed));
61
62
63 struct v3_vnet_pkt {
64     uint32_t size; 
65     
66     uint8_t dst_type;
67     uint32_t dst_id;
68
69     /*
70      * IMPORTANT The next three fields must be grouped and packed together
71      *  They are used to generate a hash value 
72      */
73     union {
74         uint8_t hash_buf[VNET_HASH_SIZE];
75         struct {
76             uint8_t src_type;
77             uint32_t src_id;
78             uint8_t header[ETHERNET_HEADER_LEN];
79             uint8_t * data;
80         } __attribute__((packed));
81     } __attribute__((packed));
82 } __attribute__((packed));
83
84
85 struct v3_vnet_dev_ops {
86     int (*input)(struct v3_vm_info * vm, 
87                 struct v3_vnet_pkt * pkt, 
88                 void * dev_data);
89     void (*poll) (struct v3_vm_info * vm, void * dev_data);
90
91     void (*start_tx)(void * dev_data);
92     void (*stop_tx)(void * dev_data);
93 };
94
95 struct v3_vnet_bridge_ops {
96     int (*input)(struct v3_vm_info * vm, 
97                 struct v3_vnet_pkt * pkt,
98                 void * private_data);
99     void (*poll)(struct v3_vm_info * vm,  
100                 void * private_data);
101 };
102
103 int v3_init_vnet(void); 
104 void v3_deinit_vnet(void);
105
106 int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data);
107
108 void v3_vnet_poll(struct v3_vm_info * vm);
109
110 int v3_vnet_add_route(struct v3_vnet_route route);
111 int v3_vnet_add_bridge(struct v3_vm_info * vm,
112                 struct v3_vnet_bridge_ops * ops,
113                 uint8_t type,
114                 void * priv_data);
115
116
117 int v3_vnet_add_dev(struct v3_vm_info * info, uint8_t mac[6], 
118                     struct v3_vnet_dev_ops * ops,
119                     void * priv_data);
120 int v3_vnet_del_dev(int dev_id);
121
122
123 #endif
124
125