From: Lei Xia Date: Fri, 12 Mar 2010 16:38:43 +0000 (-0600) Subject: Merge branch 'devel' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=331eb3b042d3456e1eaf33eb9e32606774b715fb;p=palacios.git Merge branch 'devel' of ssh://palacios@newskysaw.cs.northwestern.edu/home/palacios/palacios into devel Conflicts: palacios/src/devices/lnx_virtio_vnet.c --- 331eb3b042d3456e1eaf33eb9e32606774b715fb diff --cc palacios/include/palacios/vm_guest.h index f918da6,f918da6..9ed1e20 --- a/palacios/include/palacios/vm_guest.h +++ b/palacios/include/palacios/vm_guest.h @@@ -41,8 -41,8 +41,9 @@@ #endif -- -- ++#ifdef CONFIG_VNET ++#include ++#endif #ifdef CONFIG_SYMBIOTIC @@@ -113,6 -113,6 +114,10 @@@ struct guest_info struct v3_vm_info * vm_info; // the logical cpu this guest context is executing on int cpu_id; ++ ++#ifdef CONFIG_VNET_PROFILE ++ struct v3_vnet_profile vnet_times; ++#endif }; diff --cc palacios/include/palacios/vmm_vnet.h index 51f501b,51f501b..52fc932 --- a/palacios/include/palacios/vmm_vnet.h +++ b/palacios/include/palacios/vmm_vnet.h @@@ -26,8 -26,8 +26,8 @@@ #include --typedef enum {MAC_ANY, MAC_NOT, MAC_NONE} mac_type_t; //for 'src_mac_qual' and 'dst_mac_qual' --typedef enum {LINK_INTERFACE, LINK_EDGE, LINK_ANY} link_type_t; //for 'type' and 'src_type' in struct routing ++typedef enum {MAC_ANY=0, MAC_NOT, MAC_NONE, MAC_ADDR} mac_type_t; //for 'src_mac_qual' and 'dst_mac_qual' ++typedef enum {LINK_INTERFACE=0, LINK_EDGE, LINK_ANY} link_type_t; //for 'type' and 'src_type' in struct routing #define VNET_HASH_SIZE 17 diff --cc palacios/src/devices/lnx_virtio_nic.c index 37f8cc5,37f8cc5..84e8f0d --- a/palacios/src/devices/lnx_virtio_nic.c +++ b/palacios/src/devices/lnx_virtio_nic.c @@@ -146,7 -146,7 +146,7 @@@ static int pkt_tx(struct guest_info *co return -1; } -- if (virtio->net_ops->send(buf, len, (void *)core, NULL) == -1) { ++ if (virtio->net_ops->send(buf, len, virtio->backend_data, NULL) == -1) { return -1; } diff --cc palacios/src/devices/lnx_virtio_vnet.c index 34cff72,9ae5125..8d01d72 --- a/palacios/src/devices/lnx_virtio_vnet.c +++ b/palacios/src/devices/lnx_virtio_vnet.c @@@ -75,21 -75,28 +75,27 @@@ struct vnet_ctrl_hdr uint32_t num_cmds; } __attribute__((packed)); - static int vnetbrg_reset(struct virtio_vnet_state * vnet_brg) { - + struct vnet_virtio_pkt { + uint32_t link_id; + uint32_t pkt_size; + uint8_t pkt[1500]; + }; - memset(vnet_brg->queue, 0, sizeof(struct virtio_queue) * 2); + static int virtio_reset(struct virtio_vnet_state * vnet_state) { - vnet_brg->cur_queue = &(vnet_brg->queue[0]); + memset(vnet_state->queue, 0, sizeof(struct virtio_queue) * 2); - vnet_brg->virtio_cfg.status = 0; - vnet_brg->virtio_cfg.pci_isr = 0; + vnet_state->cur_queue = &(vnet_state->queue[0]); - vnet_brg->queue[0].queue_size = QUEUE_SIZE; - vnet_brg->queue[1].queue_size = QUEUE_SIZE; - vnet_brg->queue[2].queue_size = QUEUE_SIZE; + vnet_state->virtio_cfg.status = 0; + vnet_state->virtio_cfg.pci_isr = 0; - memset(&(vnet_brg->vnet_cfg), 0, sizeof(struct vnet_config)); - v3_lock_init(&(vnet_brg->lock)); + vnet_state->queue[0].queue_size = QUEUE_SIZE; + vnet_state->queue[1].queue_size = QUEUE_SIZE; + vnet_state->queue[2].queue_size = QUEUE_SIZE; + + memset(&(vnet_state->vnet_cfg), 0, sizeof(struct vnet_config)); + v3_lock_init(&(vnet_state->lock)); return 0; } @@@ -397,11 -326,11 +325,10 @@@ static int handle_pkt_kick(struct guest return 0; } - static int vnetbrg_io_write(struct guest_info * core, uint16_t port, void * src, uint_t length, void * private_data) { - struct virtio_vnet_state * vnet_brg = (struct virtio_vnet_state *)private_data; - int port_idx = port % vnet_brg->io_range_size; - + static int virtio_io_write(struct guest_info * core, uint16_t port, void * src, uint_t length, void * private_data) { + struct virtio_vnet_state * vnet_state = (struct virtio_vnet_state *)private_data; + int port_idx = port % vnet_state->io_range_size; - PrintDebug("VNET Bridge: VIRTIO VNET Write for port %d len=%d, value=%x\n", port, length, *(uint32_t *)src); PrintDebug("VNET Bridge: port idx=%d\n", port_idx); diff --cc palacios/src/devices/vnet_nic.c index 70e45c3,70e45c3..94c8a42 --- a/palacios/src/devices/vnet_nic.c +++ b/palacios/src/devices/vnet_nic.c @@@ -35,12 -35,12 +35,13 @@@ struct vnet_nic_state { char mac[6]; -- struct guest_info * core; ++ struct v3_vm_info * vm; struct v3_dev_net_ops net_ops; ++ int vnet_dev_id; }; #if 0 --//used when virtio_nic get a packet from guest and send it to the backend ++//Malloc/Free version of send static int vnet_send(uint8_t * buf, uint32_t len, void * private_data, struct vm_device *dest_dev){ struct v3_vnet_pkt * pkt = NULL; struct guest_info *core = (struct guest_info *)private_data; @@@ -109,14 -109,14 +110,8 @@@ //alternative way, no malloc/free static int vnet_send(uint8_t * buf, uint32_t len, void * private_data, struct vm_device *dest_dev){ struct v3_vnet_pkt pkt; -- struct guest_info *core = (struct guest_info *)private_data; -- --#ifdef CONFIG_DEBUG_VNET_NIC -- { -- PrintDebug("Virtio VNET-NIC: send pkt size: %d\n", len); -- v3_hexdump(buf, len, NULL, 0); -- } --#endif ++ struct vnet_nic_state *vnetnic = (struct vnet_nic_state *)private_data; ++ struct guest_info *core = &(vnetnic->vm->cores[0]); #ifdef CONFIG_VNET_PROFILE uint64_t start, end; @@@ -125,9 -125,9 +120,18 @@@ pkt.size = len; pkt.src_type = LINK_INTERFACE; -- pkt.src_id = 0; ++ pkt.src_id = vnetnic->vnet_dev_id; memcpy(pkt.data, buf, pkt.size); ++#ifdef CONFIG_DEBUG_VNET_NIC ++ { ++ PrintDebug("Virtio VNET-NIC: send pkt size: %d, pkt src_id: %d, src_type: %d\n", ++ len, pkt.src_id, pkt.src_type); ++ v3_hexdump(buf, len, NULL, 0); ++ } ++#endif ++ ++ #ifdef CONFIG_VNET_PROFILE rdtscll(end); core->vnet_times.time_copy_from_guest = end - core->vnet_times.virtio_handle_start; @@@ -250,6 -250,6 +254,7 @@@ static int vnet_nic_init(struct v3_vm_i vnetnic->net_ops.send = vnet_send; memcpy(vnetnic->mac, mac, 6); ++ vnetnic->vm = vm; if (v3_dev_connect_net(vm, v3_cfg_val(frontend_cfg, "tag"), &(vnetnic->net_ops), frontend_cfg, vnetnic) == -1) { @@@ -264,12 -264,12 +269,44 @@@ if ((vnet_dev_id = register_to_vnet(vm, vnetnic, name, vnetnic->mac)) == -1) { PrintError("Vnet-nic device %s (mac: %s) fails to registered to VNET\n", name, macstr); } ++ vnetnic->vnet_dev_id = vnet_dev_id; PrintDebug("Vnet-nic device %s (mac: %s, %ld) registered to VNET\n", name, macstr, *((ulong_t *)vnetnic->mac)); --//for temporary hack --#if 0 ++//for temporary hack for vnet bridge test ++#if 1 ++ { ++ uchar_t zeromac[6] = {0,0,0,0,0,0}; ++ ++ if(!strcmp(name, "vnet_nic")){ ++ struct v3_vnet_route route; ++ ++ route.dst_id = vnet_dev_id; ++ route.dst_type = LINK_INTERFACE; ++ route.src_id = 0; ++ route.src_type = LINK_EDGE; ++ memcpy(route.dst_mac, zeromac, 6); ++ route.dst_mac_qual = MAC_ANY; ++ memcpy(route.src_mac, zeromac, 6); ++ route.src_mac_qual = MAC_ANY; ++ v3_vnet_add_route(route); ++ ++ ++ route.dst_id = 0; ++ route.dst_type = LINK_EDGE; ++ route.src_id = vnet_dev_id; ++ route.src_type = LINK_INTERFACE; ++ memcpy(route.dst_mac, zeromac, 6); ++ route.dst_mac_qual = MAC_ANY; ++ memcpy(route.src_mac, zeromac, 6); ++ route.src_mac_qual = MAC_ANY; ++ ++ v3_vnet_add_route(route); ++ } ++ } ++#endif ++#if 0 //temporay hacking for vnet virtio bridge { uchar_t tapmac[6] = {0x00,0x02,0x55,0x67,0x42,0x39}; //for Intel-VT test HW //uchar_t tapmac[6] = {0x6e,0xa8,0x75,0xf4,0x82,0x95}; @@@ -307,7 -307,7 +344,6 @@@ v3_vnet_add_route(route); } } -- #endif return 0; diff --cc palacios/src/palacios/vm_guest_mem.c index 3f6be1e,3f6be1e..2aa7c58 --- a/palacios/src/palacios/vm_guest_mem.c +++ b/palacios/src/palacios/vm_guest_mem.c @@@ -63,8 -63,8 +63,6 @@@ int host_pa_to_host_va(addr_t host_pa, return 0; } -- -- int guest_pa_to_host_pa(struct guest_info * info, addr_t guest_pa, addr_t * host_pa) { struct v3_shadow_region * shdw_reg = v3_get_shadow_region(info->vm_info, info->cpu_id, guest_pa); @@@ -79,7 -79,7 +77,7 @@@ (void *)guest_pa, v3_shdw_region_type_to_str(shdw_reg->host_type)); return -1; } -- ++ *host_pa = v3_get_shadow_addr(shdw_reg, info->cpu_id, guest_pa); return 0; diff --cc palacios/src/palacios/vmx_handler.c index 60b3134,60b3134..f24324e --- a/palacios/src/palacios/vmx_handler.c +++ b/palacios/src/palacios/vmx_handler.c @@@ -38,7 -38,7 +38,6 @@@ -- /* At this point the GPRs are already copied into the guest_info state */ int v3_handle_vmx_exit(struct guest_info * info, struct vmx_exit_info * exit_info) { struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data); @@@ -51,6 -51,6 +50,11 @@@ v3_print_vmcs(); */ ++#ifdef CONFIG_VNET_PROFILE ++ uint64_t start, end; ++ rdtscll(start); ++#endif ++ #ifdef CONFIG_TELEMETRY if (info->vm_info->enable_telemetry) { v3_telemetry_start_exit(info); @@@ -228,6 -228,6 +232,23 @@@ } #endif ++#ifdef CONFIG_VNET_PROFILE ++ rdtscll(end); ++ info->vnet_times.total_exit_time = end - start; ++ if(info->vnet_times.print) ++ PrintError("Vnet_profiling: total_exit_time: %ld, total_handle_time: %ld memcpy_time: %ld copy_from_guest: %ld copy_to_guest: %ld malloc_free: %ld, route_lookup: %ld\n", ++ (long)info->vnet_times.total_exit_time, ++ (long)info->vnet_times.total_handle_time, ++ (long)info->vnet_times.memcpy_time, ++ (long)info->vnet_times.time_copy_from_guest, ++ (long)info->vnet_times.time_copy_to_guest, ++ (long)info->vnet_times.time_mallocfree, ++ (long)info->vnet_times.time_route_lookup); ++ ++ info->vnet_times.print = false; ++#endif ++ ++ return 0; } diff --cc utils/guest_creator/default.xml index 1751b2a,1751b2a..da43f53 --- a/utils/guest_creator/default.xml +++ b/utils/guest_creator/default.xml @@@ -3,12 -3,12 +3,12 @@@ -- 256 ++ 512 enable -- 100 ++ 1000 @@@ -29,7 -29,7 +29,7 @@@ -- ++ @@@ -72,6 -72,6 +72,26 @@@ pci0 southbridge ++ ++ ++ pci0 ++ ++ ++ ++ pci0 ++ ++ ++ ++ pci0 ++ ++ ++ ++ pci0 ++ 0x8086 ++ 0x100e ++ 59 ++ ++ -- -- harddisk -- ++--> ide