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.


Merge branch 'devel' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios...
[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) 2009, Lei Xia <lxia@northwestern.edu> 
11  * Copyright (c) 2009, Yuan Tang <ytang@northwestern.edu> 
12  * Copyright (c) 2009, 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
33 #define VNET_HASH_SIZE 17
34 #define ETHERNET_HEADER_LEN 14
35 #define ETHERNET_DATA_MAX   1500
36 #define ETHERNET_PACKET_LEN (ETHERNET_HEADER_LEN + ETHERNET_DATA_MAX)
37
38 //routing table entry
39 struct v3_vnet_route {
40     uint8_t src_mac[6];
41     uint8_t dst_mac[6];
42
43     uint8_t src_mac_qual;
44     uint8_t dst_mac_qual;
45
46     uint32_t dst_id; //link[dest] is the link to be used to send pkt
47     uint8_t dst_type; //EDGE|INTERFACE|ANY
48  
49     uint32_t src_id;
50     uint8_t src_type; //EDGE|INTERFACE|ANY
51 } __attribute__((packed));
52
53
54 struct v3_vnet_pkt {
55     uint32_t size; 
56     
57     uint8_t dst_type;
58     uint32_t dst_id;
59
60     /*
61      * IMPORTANT The next three fields must be grouped and packed together
62      *  They are used to generate a hash value 
63      */
64     union {
65         uint8_t hash_buf[VNET_HASH_SIZE];
66         struct {
67             uint8_t src_type;
68             uint32_t src_id;
69             uint8_t data[ETHERNET_PACKET_LEN];
70         } __attribute__((packed));
71     } __attribute__((packed));
72 } __attribute__((packed));
73
74
75 #ifdef CONFIG_VNET_PROFILE
76 struct v3_vnet_profile{
77     uint64_t  time_copy_from_guest;
78     uint64_t  time_route_lookup;
79     uint64_t  time_mallocfree;
80     uint64_t  time_copy_to_guest;
81     uint64_t  total_handle_time;
82     uint64_t  memcpy_time;
83
84     uint64_t  total_exit_time;
85     bool print;
86
87     uint64_t virtio_handle_start;
88 };
89 #endif
90
91
92 int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void *private_data);
93
94 int v3_vnet_add_route(struct v3_vnet_route route);
95
96 //int v3_vnet_del_route();
97
98
99
100 int V3_init_vnet();
101
102 int v3_vnet_add_bridge(struct v3_vm_info * vm,
103                                 int (*input)(struct v3_vm_info * vm, struct v3_vnet_pkt * pkt, void * private_data), 
104                                 void * priv_data);
105
106 int v3_vnet_add_dev(struct v3_vm_info *info, uint8_t mac[6], 
107                     int (*dev_input)(struct v3_vm_info * vm, struct v3_vnet_pkt * pkt, void * private_data), 
108                     void * priv_data);
109
110
111
112 #endif
113
114 #endif
115
116