From: Lei Xia Date: Wed, 4 May 2011 16:30:58 +0000 (-0500) Subject: fix the threads function calls using new vnet host interfaces X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ca1d3b4d7a7266a92ef99afeee99097da838ae8;p=palacios.git fix the threads function calls using new vnet host interfaces --- diff --git a/palacios/include/vnet/vnet.h b/palacios/include/vnet/vnet.h index 0f8c793..ec4fc10 100644 --- a/palacios/include/vnet/vnet.h +++ b/palacios/include/vnet/vnet.h @@ -24,6 +24,7 @@ #include #include +#include #define MAC_NOSET 0 #define MAC_ANY 11 diff --git a/palacios/include/vnet/vnet_host_interface.h b/palacios/include/vnet/vnet_host_interface.h index 768cdd1..cef3047 100644 --- a/palacios/include/vnet/vnet_host_interface.h +++ b/palacios/include/vnet/vnet_host_interface.h @@ -17,28 +17,35 @@ * redistribute, and modify it as specified in the file "V3VEE_LICENSE". */ -#ifndef __VNET_INTERFACE_H__ -#define __VNET_INTERFACE_H__ +#ifndef __VNET_HOST_INTERFACE_H__ +#define __VNET_HOST_INTERFACE_H__ -struct v3_thread { +struct vnet_thread { + void * host_thread; + void * data; }; -v3_thread * v3_thread_create(int (*func)(void *), void *arg, char * name); -void v3_thread_sleep(int cond); -void v3_thread_wakeup(v3_thread *); -void v3_thread_kill(v3_thread *); -void v3_thread_stop(v3_thread *); -void v3_thread_continue(v3_thread *); +struct vnet_timer { + void * host_timer; + void * data; +}; + +struct vnet_thread * vnet_thread_create(int (*func)(void *), void *arg, char * name); +void vnet_thread_sleep(int cond); +void vnet_thread_wakeup(struct vnet_thread *); +void vnet_thread_kill(struct vnet_thread *); +void vnet_thread_stop(struct vnet_thread *); +void vnet_thread_continue(struct vnet_thread *); -void udelay(unsigned long usecs); +void vnet_udelay(unsigned long usecs); // I know there is timer in palacios, but it has to be binded to specific VM, and the granularity is not // guaranteed // I need a timer that is global, not related to any specific VM, and also fine-granularity -v3_timer * v3_create_timer(int interval /*in us*/, void (*timer_fun)(uint64_t eclipsed_cycles, void * priv_data), void * pri_data); -int v3_del_timer(v3_timer *); -int v3_start_timer(v3_timer *); -int v3_stop_timer(v3_timer *); +struct vnet_timer * vnet_create_timer(int interval /*in us*/, void (*timer_fun)(uint64_t eclipsed_cycles, void * priv_data), void * pri_data); +int vnet_del_timer(struct vnet_timer *); +int vnet_start_timer(struct vnet_timer *); +int vnet_stop_timer(struct vnet_timer *); #endif diff --git a/palacios/src/devices/lnx_virtio_nic.c b/palacios/src/devices/lnx_virtio_nic.c index fca709d..507ffc2 100644 --- a/palacios/src/devices/lnx_virtio_nic.c +++ b/palacios/src/devices/lnx_virtio_nic.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -127,7 +127,7 @@ struct virtio_net_state { uint8_t mergeable_rx_bufs; struct v3_timer * timer; - void * poll_thread; + struct vnet_thread * poll_thread; struct nic_statistics stats; @@ -406,7 +406,7 @@ static int virtio_io_write(struct guest_info *core, virtio_setup_queue(core, virtio, &virtio->tx_vq, pfn, page_addr); if(virtio->tx_notify == 0){ disable_cb(&virtio->tx_vq); - V3_THREAD_WAKEUP(virtio->poll_thread); + vnet_thread_wakeup(virtio->poll_thread); } break; case 2: @@ -725,7 +725,7 @@ static int virtio_tx_flush(void * args){ handle_pkt_tx(&(virtio->vm->cores[0]), virtio); v3_yield(NULL); }else { - V3_THREAD_SLEEP(); + vnet_thread_sleep(0); } } @@ -831,7 +831,7 @@ static void virtio_nic_timer(struct guest_info * core, V3_Print("Virtio NIC: Switch TX to VMM driven mode\n"); disable_cb(&(net_state->tx_vq)); net_state->tx_notify = 0; - V3_THREAD_WAKEUP(net_state->poll_thread); + vnet_thread_wakeup(net_state->poll_thread); } if(tx_rate < RATE_LOWER_THRESHOLD && net_state->tx_notify == 0){ @@ -894,7 +894,7 @@ static int connect_fn(struct v3_vm_info * info, ops->frontend_data = net_state; memcpy(ops->fnt_mac, virtio->mac, ETH_ALEN); - net_state->poll_thread = V3_CREATE_THREAD(virtio_tx_flush, (void *)net_state, "Virtio_Poll"); + net_state->poll_thread = vnet_thread_create(virtio_tx_flush, (void *)net_state, "Virtio_Poll"); return 0; } diff --git a/palacios/src/devices/lnx_virtio_vnet.c b/palacios/src/devices/lnx_virtio_vnet.c index 85535e8..e604b9e 100644 --- a/palacios/src/devices/lnx_virtio_vnet.c +++ b/palacios/src/devices/lnx_virtio_vnet.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/palacios/src/devices/vnet_nic.c b/palacios/src/devices/vnet_nic.c index 80b8fea..bf0bf91 100644 --- a/palacios/src/devices/vnet_nic.c +++ b/palacios/src/devices/vnet_nic.c @@ -19,7 +19,7 @@ */ //backend device for Virtio NIC -#include +#include #include #include #include diff --git a/palacios/src/vnet/vnet_core.c b/palacios/src/vnet/vnet_core.c index 9bf044a..5d454e8 100644 --- a/palacios/src/vnet/vnet_core.c +++ b/palacios/src/vnet/vnet_core.c @@ -108,7 +108,7 @@ static struct { v3_lock_t lock; struct vnet_stat stats; - void * pkt_flush_thread; + struct vnet_thread * pkt_flush_thread; struct vnet_queue pkt_q; @@ -708,7 +708,6 @@ int v3_vnet_add_bridge(struct v3_vm_info * vm, return 0; } -#if 0 static int vnet_tx_flush(void *args){ unsigned long flags; struct queue_entry * entry; @@ -743,7 +742,6 @@ static int vnet_tx_flush(void *args){ } } } -#endif int v3_init_vnet() { memset(&vnet_state, 0, sizeof(vnet_state)); @@ -766,7 +764,7 @@ int v3_init_vnet() { v3_lock_init(&(vnet_state.pkt_q.lock)); - //vnet_state.pkt_flush_thread = V3_CREATE_THREAD(vnet_tx_flush, NULL, "VNET_Pkts"); + vnet_state.pkt_flush_thread = vnet_thread_create(vnet_tx_flush, NULL, "VNET_Pkts"); PrintDebug("VNET/P Core is initiated\n");