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.


VNET code clean and rearrangement
[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 #ifdef __V3VEE__
26
27 #include <palacios/vmm.h>
28
29 typedef enum {MAC_ANY=0, MAC_NOT, MAC_NONE, MAC_ADDR} mac_type_t; //for 'src_mac_qual' and 'dst_mac_qual'
30 typedef enum {LINK_INTERFACE=0, LINK_EDGE, LINK_ANY} link_type_t; //for 'type' and 'src_type' in struct routing
31
32 #define VNET_HASH_SIZE 17
33 #define ETHERNET_HEADER_LEN 14
34 #define ETHERNET_MTU   1500
35 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN + ETHERNET_MTU)
36
37 #define VMM_DRIVERN 1
38 #define GUEST_DRIVERN 0
39
40 #define HOST_LNX_BRIDGE 1
41 #define CTL_VM_BRIDGE 2
42
43 //routing table entry
44 struct v3_vnet_route {
45     uint8_t src_mac[6];
46     uint8_t dst_mac[6];
47
48     uint8_t src_mac_qual;
49     uint8_t dst_mac_qual;
50
51     uint32_t dst_id; //link[dest] is the link to be used to send pkt
52     uint8_t dst_type; //EDGE|INTERFACE|ANY
53  
54     uint32_t src_id;
55     uint8_t src_type; //EDGE|INTERFACE|ANY
56 } __attribute__((packed));
57
58
59 struct v3_vnet_pkt {
60     uint32_t size; 
61     
62     uint8_t dst_type;
63     uint32_t dst_id;
64
65     /*
66      * IMPORTANT The next three fields must be grouped and packed together
67      *  They are used to generate a hash value 
68      */
69     union {
70         uint8_t hash_buf[VNET_HASH_SIZE];
71         struct {
72             uint8_t src_type;
73             uint32_t src_id;
74             uint8_t header[ETHERNET_HEADER_LEN];
75             uint8_t * data;
76         } __attribute__((packed));
77     } __attribute__((packed));
78 } __attribute__((packed));
79
80
81 struct v3_vnet_dev_ops {
82     int (*input)(struct v3_vm_info * vm, 
83                 struct v3_vnet_pkt * pkt, 
84                 void * dev_data);
85     void (*poll) (struct v3_vm_info * vm, void * dev_data);
86
87     void (*start_tx)(void * dev_data);
88     void (*stop_tx)(void * dev_data);
89 };
90
91 struct v3_vnet_bridge_ops {
92     int (*input)(struct v3_vm_info * vm, 
93                 struct v3_vnet_pkt * pkt,
94                 void * private_data);
95     void (*poll)(struct v3_vm_info * vm,  
96                 void * private_data);
97 };
98
99 int v3_init_vnet();     
100 int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void *private_data);
101 void v3_vnet_poll(struct v3_vm_info *vm);
102
103 int v3_vnet_add_route(struct v3_vnet_route route);
104 int v3_vnet_add_bridge(struct v3_vm_info * vm,
105                 struct v3_vnet_bridge_ops *ops,
106                 uint8_t type,
107                 void * priv_data);
108 int v3_vnet_add_dev(struct v3_vm_info *info, uint8_t mac[6], 
109                     struct v3_vnet_dev_ops *ops,
110                     void * priv_data);
111
112 #endif
113
114 #endif
115
116