X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fvnet%2Fvnet.h;h=ae1289681719a2a3fff120b5b0ab0a434f426b23;hb=3586c3bd6260bf79c57baebf66a26d7e8158d411;hp=ec4fc1055342a15bc7bb7d5d644f724f758fb65b;hpb=8ca1d3b4d7a7266a92ef99afeee99097da838ae8;p=palacios.git diff --git a/palacios/include/vnet/vnet.h b/palacios/include/vnet/vnet.h index ec4fc10..ae12896 100644 --- a/palacios/include/vnet/vnet.h +++ b/palacios/include/vnet/vnet.h @@ -1,3 +1,4 @@ + /* * This file is part of the Palacios Virtual Machine Monitor developed * by the V3VEE Project with funding from the United States National @@ -19,12 +20,13 @@ * redistribute, and modify it as specified in the file "V3VEE_LICENSE". */ -#ifndef __VNET_CORE_H__ -#define __VNET_CORE_H__ +#ifndef __VNET_H__ +#define __VNET_H__ -#include #include -#include +#include +#include +#include #define MAC_NOSET 0 #define MAC_ANY 11 @@ -39,7 +41,36 @@ #define VNET_HASH_SIZE 17 -extern int v3_vnet_debug; +#define VNET_MAX_HEADER_LEN 128 + +/* + A VNET header is the data that needs to be + prefaced to an outgoing packet for a specific + MAC pair and qualifiers +*/ +struct v3_vnet_header { + // this header is for data that match + uint8_t src_mac[ETH_ALEN]; + uint8_t dst_mac[ETH_ALEN]; + + uint8_t src_mac_qual; + uint8_t dst_mac_qual; + +#define VNET_HEADER_NOMATCH 0 // Could not find a header +#define VNET_HEADER_NONE 1 // There is no header, send/receive without change +#define VNET_HEADER_RAW 2 // Prepend the following data on a send, remove this much data on a receive +#define VNET_HEADER_UDP 3 // Prepend this UDP header and then send this as a UDP packet / dual on receive +#define VNET_HEADER_TCP 4 // Prepend this TCP header and then send this as a TCP segment / dual on receive +#define VNET_HEADER_VXLAN 5 // Prepend this UDP header + VXLAN ID / dual on receive + + uint32_t header_type; + + uint32_t header_len; + uint8_t header_data[VNET_MAX_HEADER_LEN]; + + +} __attribute__((packed)); + struct v3_vnet_route { uint8_t src_mac[ETH_ALEN]; @@ -53,6 +84,7 @@ struct v3_vnet_route { int src_id; uint8_t src_type; + } __attribute__((packed)); @@ -88,21 +120,26 @@ struct vnet_stat{ struct v3_vnet_bridge_ops { int (*input)(struct v3_vm_info * vm, - struct v3_vnet_pkt * pkt, - void * private_data); + struct v3_vnet_pkt * pkt, + void * private_data); void (*poll)(struct v3_vm_info * vm, - void * private_data); + void * private_data); }; #define HOST_LNX_BRIDGE 1 #define CTL_VM_BRIDGE 2 int v3_vnet_add_bridge(struct v3_vm_info * vm, - struct v3_vnet_bridge_ops * ops, - uint8_t type, - void * priv_data); + struct v3_vnet_bridge_ops * ops, + uint8_t type, + void * priv_data); + +void v3_vnet_del_bridge(uint8_t type); + int v3_vnet_add_route(struct v3_vnet_route route); -int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data, int synchronize); +void v3_vnet_del_route(uint32_t route_idx); + +int v3_vnet_send_pkt(struct v3_vnet_pkt * pkt, void * private_data); int v3_vnet_find_dev(uint8_t * mac); int v3_vnet_stat(struct vnet_stat * stats); @@ -110,7 +147,12 @@ int v3_vnet_stat(struct vnet_stat * stats); struct v3_vnet_dev_ops { int (*input)(struct v3_vm_info * vm, - struct v3_vnet_pkt * pkt, + struct v3_vnet_pkt * pkt, + void * dev_data); + + /* return >0 means there are more pkts in the queue to be sent */ + int (*poll)(struct v3_vm_info * vm, + int quote, void * dev_data); }; @@ -118,10 +160,15 @@ int v3_init_vnet(void); void v3_deinit_vnet(void); int v3_vnet_add_dev(struct v3_vm_info * info, uint8_t * mac, - struct v3_vnet_dev_ops * ops, + struct v3_vnet_dev_ops * ops, int quote, int poll_state, void * priv_data); int v3_vnet_del_dev(int dev_id); +int v3_vnet_query_header(uint8_t src_mac[6], + uint8_t dest_mac[6], + int recv, + struct v3_vnet_header *header); + #endif