X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Flnx_virtio_nic.c;h=8721962c549702d3dbf11b27bfc085edeb4ff83d;hb=8300df0450154d7a2db08a7afbd2aca32ce38f70;hp=557d3e816083730429a6533a7aad935298b19373;hpb=a04b0778a7f74005560b99255de2c6d2df4d5292;p=palacios.releases.git diff --git a/palacios/src/devices/lnx_virtio_nic.c b/palacios/src/devices/lnx_virtio_nic.c index 557d3e8..8721962 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,12 +252,17 @@ 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 return 0; @@ -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,12 +568,17 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) { exit: #ifdef CONFIG_VNET_PROFILE - if (virtio->pkt_recv % 10000 == 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 v3_unlock_irqrestore(virtio->lock, flags);