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.


ec4fc1055342a15bc7bb7d5d644f724f758fb65b
[palacios.git] / palacios / include / vnet / 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_CORE_H__
23 #define __VNET_CORE_H__
24
25 #include <palacios/vmm.h>
26 #include <palacios/vmm_ethernet.h>
27 #include <vnet/vnet_host_interface.h>
28
29 #define MAC_NOSET       0
30 #define MAC_ANY         11
31 #define MAC_NOT         12
32 #define MAC_NONE        13 
33 #define MAC_ADDR        14
34
35 #define LINK_NOSET      0
36 #define LINK_INTERFACE  11
37 #define LINK_EDGE       12 
38 #define LINK_ANY        13
39
40 #define VNET_HASH_SIZE  17
41
42 extern int v3_vnet_debug;
43
44 struct v3_vnet_route {
45     uint8_t src_mac[ETH_ALEN];
46     uint8_t dst_mac[ETH_ALEN];
47
48     uint8_t src_mac_qual;
49     uint8_t dst_mac_qual;
50
51     int dst_id;
52     uint8_t dst_type;
53  
54     int src_id;
55     uint8_t src_type;
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 vnet_stat{
82     uint64_t tx_bytes;
83     uint32_t tx_pkts;
84     uint64_t rx_bytes;
85     uint32_t rx_pkts;
86 };
87
88
89 struct v3_vnet_bridge_ops {
90     int (*input)(struct v3_vm_info * vm, 
91                 struct v3_vnet_pkt * pkt,
92                 void * private_data);
93     void (*poll)(struct v3_vm_info * vm,  
94                 void * private_data);
95 };
96
97 #define HOST_LNX_BRIDGE 1
98 #define CTL_VM_BRIDGE   2
99
100 int v3_vnet_add_bridge(struct v3_vm_info * vm,
101                 struct v3_vnet_bridge_ops * ops,
102                 uint8_t type,
103                 void * priv_data);
104 int v3_vnet_add_route(struct v3_vnet_route route);
105 int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data, int synchronize);
106 int v3_vnet_find_dev(uint8_t  * mac);
107 int v3_vnet_stat(struct vnet_stat * stats);
108
109 #ifdef __V3VEE__
110
111 struct v3_vnet_dev_ops {
112     int (*input)(struct v3_vm_info * vm, 
113                 struct v3_vnet_pkt * pkt, 
114                 void * dev_data);
115 };
116
117 int v3_init_vnet(void); 
118 void v3_deinit_vnet(void);
119
120 int v3_vnet_add_dev(struct v3_vm_info * info, uint8_t * mac, 
121                     struct v3_vnet_dev_ops * ops,
122                     void * priv_data);
123 int v3_vnet_del_dev(int dev_id);
124
125
126 #endif
127
128 #endif
129
130