X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Flnx_virtio_nic.c;h=8993066ba8f526c62ca0f179825fddfdd74aff00;hb=964e7836a6227341b5d895a830b7e36ad6debffb;hp=88d3a59eb9fff132b0aa0740a007ab75ab8cfdfc;hpb=966e433fd935e1ad837960e1b245d8506b2cf515;p=palacios.git diff --git a/palacios/src/devices/lnx_virtio_nic.c b/palacios/src/devices/lnx_virtio_nic.c index 88d3a59..8993066 100644 --- a/palacios/src/devices/lnx_virtio_nic.c +++ b/palacios/src/devices/lnx_virtio_nic.c @@ -82,6 +82,10 @@ struct virtio_net_state { ulong_t pkt_sent, pkt_recv, pkt_drop; +#if 1 //for temporary performance testing purpose + long last_sent_time, last_recv_time; +#endif + struct v3_dev_net_ops * net_ops; v3_lock_t lock; @@ -137,7 +141,7 @@ static int pkt_tx(struct guest_info *core, struct virtio_net_state * virtio, str PrintDebug("Virtio NIC: Virtio Pkt Sending, net_state: %p, pkt size: %d\n", virtio, len); - if (guest_pa_to_host_va(core, buf_desc->addr_gpa, (addr_t *)&(buf)) == -1) { + if (v3_gpa_to_hva(core, buf_desc->addr_gpa, (addr_t *)&(buf)) == -1) { PrintError("Could not translate buffer address\n"); return -1; } @@ -170,7 +174,7 @@ static int copy_data_to_desc(struct guest_info *core, uint32_t len; uint8_t * desc_buf = NULL; - if (guest_pa_to_host_va(core, desc->addr_gpa, (addr_t *)&(desc_buf)) == -1) { + if (v3_gpa_to_hva(core, desc->addr_gpa, (addr_t *)&(desc_buf)) == -1) { PrintError("Could not translate buffer address\n"); return -1; } @@ -215,7 +219,7 @@ static int handle_pkt_tx(struct guest_info *core, struct virtio_net_state * virt int i = 0; hdr_desc = &(q->desc[desc_idx]); - if (guest_pa_to_host_va(core, hdr_desc->addr_gpa, &(hdr_addr)) == -1) { + if (v3_gpa_to_hva(core, hdr_desc->addr_gpa, &(hdr_addr)) == -1) { PrintError("Could not translate block header address\n"); return -1; } @@ -248,11 +252,16 @@ static int handle_pkt_tx(struct guest_info *core, struct virtio_net_state * virt } #ifdef CONFIG_VNET_PROFILE - if (virtio_state->pkt_sent % 10000 == 0){ - PrintError("Virtio NIC: sent: %ld, rxed: %ld, dropped: %ld\n", - virtio_state->pkt_sent, - virtio_state->pkt_recv, - virtio_state->pkt_drop); + if (virtio_state->pkt_sent % 50000 == 0){ + long cur_time, time; + rdtscll(cur_time); + time = cur_time - virtio_state->last_sent_time; + PrintError("Virtio NIC: last sent 50000 cycles: %ld\n",time); + //PrintError("Virtio NIC: sent: %ld, rxed: %ld, dropped: %ld\n", + // virtio_state->pkt_sent, + // virtio_state->pkt_recv, + // virtio_state->pkt_drop); + rdtscll(virtio_state->last_sent_time); } #endif @@ -275,17 +284,17 @@ static int virtio_setup_queue(struct guest_info *core, // round up to next page boundary. queue->ring_used_addr = (queue->ring_used_addr + 0xfff) & ~0xfff; - if (guest_pa_to_host_va(core, queue->ring_desc_addr, (addr_t *)&(queue->desc)) == -1) { + if (v3_gpa_to_hva(core, queue->ring_desc_addr, (addr_t *)&(queue->desc)) == -1) { PrintError("Could not translate ring descriptor address\n"); return -1; } - if (guest_pa_to_host_va(core, queue->ring_avail_addr, (addr_t *)&(queue->avail)) == -1) { + if (v3_gpa_to_hva(core, queue->ring_avail_addr, (addr_t *)&(queue->avail)) == -1) { PrintError("Could not translate ring available address\n"); return -1; } - if (guest_pa_to_host_va(core, queue->ring_used_addr, (addr_t *)&(queue->used)) == -1) { + if (v3_gpa_to_hva(core, queue->ring_used_addr, (addr_t *)&(queue->used)) == -1) { PrintError("Could not translate ring used address\n"); return -1; } @@ -515,7 +524,7 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) { struct vring_desc * hdr_desc = NULL; hdr_desc = &(q->desc[hdr_idx]); - if (guest_pa_to_host_va(&(virtio->virtio_dev->vm->cores[0]), hdr_desc->addr_gpa, &(hdr_addr)) == -1) { + if (v3_gpa_to_hva(&(virtio->virtio_dev->vm->cores[0]), hdr_desc->addr_gpa, &(hdr_addr)) == -1) { PrintError("Could not translate receive buffer address\n"); ret_val = -1; goto exit; @@ -559,11 +568,16 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) { exit: #ifdef CONFIG_VNET_PROFILE - if (virtio->pkt_recv % 100000 == 0){ - PrintError("Virtio NIC: sent: %ld, rxed: %ld, dropped: %ld\n", - virtio->pkt_sent, - virtio->pkt_recv, - virtio->pkt_drop); + if (virtio->pkt_recv % 50000 == 0){ + long cur_time, time; + rdtscll(cur_time); + time = cur_time - virtio->last_recv_time; + PrintError("Virtio NIC: last recv 50000 cycles: %ld\n",time); + //PrintError("Virtio NIC: sent: %ld, rxed: %ld, dropped: %ld\n", + //virtio->pkt_sent, + //virtio->pkt_recv, + //virtio->pkt_drop); + rdtscll(virtio->last_recv_time); } #endif @@ -672,9 +686,9 @@ static int connect_fn(struct v3_vm_info * info, static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus")); struct virtio_dev_state * virtio_state = NULL; - char * name = v3_cfg_val(cfg, "name"); + char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", name); + PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", dev_id); if (pci_bus == NULL) { PrintError("Virtio NIC: VirtIO devices require a PCI Bus"); @@ -688,14 +702,14 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state->pci_bus = pci_bus; virtio_state->vm = vm; - struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state); + struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state); if (v3_attach_device(vm, dev) == -1) { - PrintError("Virtio NIC: Could not attach device %s\n", name); + PrintError("Virtio NIC: Could not attach device %s\n", dev_id); return -1; } - if (v3_dev_add_net_frontend(vm, name, connect_fn, (void *)virtio_state) == -1) { - PrintError("Virtio NIC: Could not register %s as net frontend\n", name); + if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) { + PrintError("Virtio NIC: Could not register %s as net frontend\n", dev_id); return -1; }