Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


moved timer injection to track total time instead of guest time
[palacios-OLD.git] / palacios / src / devices / lnx_virtio_nic.c
index c626708..88d3a59 100644 (file)
@@ -204,6 +204,7 @@ static int handle_pkt_tx(struct guest_info *core, struct virtio_net_state * virt
     struct virtio_queue * q = &(virtio_state->tx_vq);
     struct virtio_net_hdr * hdr = NULL;
 
+    PrintDebug("Virtio NIC: TX: running on cpu: %d\n", V3_Get_CPU());
 
     while (q->cur_avail_idx != q->avail->index) {
        struct vring_desc * hdr_desc = NULL;
@@ -221,7 +222,7 @@ static int handle_pkt_tx(struct guest_info *core, struct virtio_net_state * virt
 
        hdr = (struct virtio_net_hdr*)hdr_addr;
        desc_idx = hdr_desc->next;
-       
+
        for (i = 0; i < desc_cnt - 1; i++) {    
            struct vring_desc * buf_desc = &(q->desc[desc_idx]);
            if (pkt_tx(core, virtio_state, buf_desc) == -1) {
@@ -246,6 +247,15 @@ static int handle_pkt_tx(struct guest_info *core, struct virtio_net_state * virt
        virtio_state->virtio_cfg.pci_isr = 0x1;
     }
 
+#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);
+    }
+#endif
+
     return 0;
 }
 
@@ -478,12 +488,12 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
     uint32_t data_len = size;
     uint32_t offset = 0;
     unsigned long flags;
-    int ret_val;
+    int ret_val = -1;
     int raw = 1;
 
     flags = v3_lock_irqsave(virtio->lock);
-       
-    PrintDebug("VIRTIO NIC: receiving packet to virtio nic %p, size:%d\n", virtio, size);
+
+    PrintDebug("VIRTIO NIC: RX on cpu %d to virtio nic %p, size:%d\n", V3_Get_CPU(), virtio, size);
 
     virtio->pkt_recv ++;
 
@@ -495,7 +505,6 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
 
     if (q->ring_avail_addr == 0) {
        PrintError("Queue is not set\n");
-       ret_val = -1;
        goto exit;
     }
 
@@ -536,6 +545,7 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
        q->cur_avail_idx++;
     } else {
        virtio->pkt_drop++;
+       goto exit;
     }
 
     if (!(q->avail->flags & VIRTIO_NO_IRQ_FLAG)) {
@@ -547,6 +557,15 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
     ret_val = offset;
 
 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);
+    }
+#endif
 
     v3_unlock_irqrestore(virtio->lock, flags);