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.


refactored memory map
[palacios.git] / palacios / src / devices / lnx_virtio_nic.c
index 7bcd9bb..1ddcd1a 100644 (file)
@@ -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;
@@ -204,6 +208,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 +226,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 +251,20 @@ 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 % 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;
 }
 
@@ -482,8 +501,8 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
     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 ++;
 
@@ -535,6 +554,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)) {
@@ -546,6 +566,20 @@ 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 % 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);