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.


removed instrumentation
[palacios-OLD.git] / palacios / src / palacios / vmm_vnet_core.c
index 4b54d71..c3d9603 100644 (file)
@@ -26,7 +26,7 @@
 #include <palacios/vmm_sprintf.h>
 #include <palacios/vmm_ethernet.h>
 
-#ifndef CONFIG_DEBUG_VNET
+#ifndef V3_CONFIG_DEBUG_VNET
 #undef PrintDebug
 #define PrintDebug(fmt, args...)
 #endif
@@ -84,10 +84,11 @@ struct route_list {
 struct queue_entry{
     uint8_t use;
     struct v3_vnet_pkt pkt;
-    uint8_t data[ETHERNET_PACKET_LEN];
+    uint8_t * data;
+    uint32_t size_alloc;
 };
 
-#define VNET_QUEUE_SIZE 10240
+#define VNET_QUEUE_SIZE 1024
 struct vnet_queue {
        struct queue_entry buf[VNET_QUEUE_SIZE];
        int head, tail;
@@ -115,7 +116,7 @@ static struct {
 } vnet_state;
        
 
-#ifdef CONFIG_DEBUG_VNET
+#ifdef V3_CONFIG_DEBUG_VNET
 static inline void mac_to_string(uint8_t * mac, char * buf) {
     snprintf(buf, 100, "%2x:%2x:%2x:%2x:%2x:%2x", 
             mac[0], mac[1], mac[2],
@@ -249,7 +250,7 @@ int v3_vnet_add_route(struct v3_vnet_route route) {
     new_route = (struct vnet_route_info *)V3_Malloc(sizeof(struct vnet_route_info));
     memset(new_route, 0, sizeof(struct vnet_route_info));
 
-#ifdef CONFIG_DEBUG_VNET
+#ifdef V3_CONFIG_DEBUG_VNET
     PrintDebug("VNET/P Core: add_route_entry:\n");
     print_route(&route);
 #endif
@@ -280,7 +281,7 @@ int v3_vnet_add_route(struct v3_vnet_route route) {
     v3_unlock_irqrestore(vnet_state.lock, flags);
    
 
-#ifdef CONFIG_DEBUG_VNET
+#ifdef V3_CONFIG_DEBUG_VNET
     dump_routes();
 #endif
 
@@ -323,7 +324,7 @@ static struct route_list * match_route(const struct v3_vnet_pkt * pkt) {
     //    uint8_t src_type = pkt->src_type;
     //  uint32_t src_link = pkt->src_id;
 
-#ifdef CONFIG_DEBUG_VNET
+#ifdef V3_CONFIG_DEBUG_VNET
     {
        char dst_str[100];
        char src_str[100];
@@ -520,6 +521,7 @@ static int vnet_pkt_enqueue(struct v3_vnet_pkt * pkt){
     unsigned long flags;
     struct queue_entry * entry;
     struct vnet_queue * q = &(vnet_state.pkt_q);
+    uint16_t num_pages;
 
     flags = v3_lock_irqsave(q->lock);
 
@@ -538,6 +540,20 @@ static int vnet_pkt_enqueue(struct v3_vnet_pkt * pkt){
     /* this is ugly, but should happen very unlikely */
     while(entry->use);
 
+    if(entry->size_alloc < pkt->size){
+       if(entry->data != NULL){
+           V3_FreePages(V3_PAddr(entry->data), (entry->size_alloc / PAGE_SIZE));
+           entry->data = NULL;
+       }
+
+       num_pages = 1 + (pkt->size / PAGE_SIZE);
+       entry->data = V3_VAddr(V3_AllocPages(num_pages));
+       if(entry->data == NULL){
+           return -1;
+       }
+       entry->size_alloc = PAGE_SIZE * num_pages;
+    }
+
     entry->pkt.data = entry->data;
     memcpy(&(entry->pkt), pkt, sizeof(struct v3_vnet_pkt));
     memcpy(entry->data, pkt->data, pkt->size);
@@ -719,6 +735,8 @@ static int vnet_tx_flush(void *args){
            /* this is ugly, but should happen very unlikely */
            while(!entry->use);
            vnet_tx_one_pkt(&(entry->pkt), NULL);
+
+           /* asynchronizely release allocated memory for buffer entry here */     
            entry->use = 0;
 
            V3_Net_Print(2, "vnet_tx_flush: pkt (size %d)\n", entry->pkt.size);