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;
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;
}
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;
}
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;
}
}
#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
// 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;
}
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;
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
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");
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;
}