X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fpalacios-vnet-brg.c;h=945909ae1cee142389e5390c25e2ba1531be5673;hb=471edd59ca70371e97cbad759e1710433f35990d;hp=309171d5624356ec714fb384f6b8ffee5be7966e;hpb=7ca1f3f6bcb065c7c28b98f049d4abbca21a7bc1;p=palacios.git diff --git a/linux_module/palacios-vnet-brg.c b/linux_module/palacios-vnet-brg.c index 309171d..945909a 100644 --- a/linux_module/palacios-vnet-brg.c +++ b/linux_module/palacios-vnet-brg.c @@ -32,9 +32,9 @@ #define VNET_SERVER_PORT 9000 -#define VNET_NOPROGRESS_LIMIT 1000 - -#define VNET_YIELD_TIME_USEC 1000 +#define VNET_ADAPTIVE_BRIDGE 1 // set this to one to have bridge go to sleep if there nothing to do... +#define VNET_NOPROGRESS_LIMIT 1000 // ... after this many iterations +#define VNET_YIELD_TIME_USEC 1000 // ... and go to sleep for this long struct vnet_link { uint32_t dst_ip; @@ -105,11 +105,11 @@ static void _delete_link(struct vnet_link * link){ link->sock->ops->release(link->sock); - spin_lock_irqsave(&(vnet_brg_s.lock), flags); + palacios_spinlock_lock_irqsave(&(vnet_brg_s.lock), flags); list_del(&(link->node)); vnet_htable_remove(vnet_brg_s.ip2link, (addr_t)&(link->dst_ip), 0); vnet_brg_s.num_links --; - spin_unlock_irqrestore(&(vnet_brg_s.lock), flags); + palacios_spinlock_unlock_irqrestore(&(vnet_brg_s.lock), flags); INFO("VNET Bridge: Link deleted, ip 0x%x, port: %d, idx: %d\n", link->dst_ip, @@ -173,18 +173,18 @@ static uint32_t _create_link(struct vnet_link * link) { link->sock_addr.sin_port = htons(link->dst_port); - if ((err = link->sock->ops->connect(link->sock, (struct sockaddr *)&(link->sock_addr), sizeof(struct sockaddr), 0) < 0)) { + if ((err = link->sock->ops->connect(link->sock, (struct sockaddr *)&(link->sock_addr), sizeof(struct sockaddr), 0)) < 0) { WARNING("Could not connect to remote VNET Server, error %d\n", err); return -1; } - spin_lock_irqsave(&(vnet_brg_s.lock), flags); + palacios_spinlock_lock_irqsave(&(vnet_brg_s.lock), flags); list_add(&(link->node), &(vnet_brg_s.link_list)); vnet_brg_s.num_links ++; link->idx = ++ vnet_brg_s.link_idx; vnet_htable_insert(vnet_brg_s.ip2link, (addr_t)&(link->dst_ip), (addr_t)link); - spin_unlock_irqrestore(&(vnet_brg_s.lock), flags); + palacios_spinlock_unlock_irqrestore(&(vnet_brg_s.lock), flags); INFO("VNET Bridge: Link created, ip 0x%x, port: %d, idx: %d, link: %p, protocol: %s\n", link->dst_ip, @@ -472,14 +472,14 @@ static int _udp_server(void * arg) { // adaptively select yielding strategy depending on // whether we are making progress - if (noprogress_count < VNET_NOPROGRESS_LIMIT) { + if ((!VNET_ADAPTIVE_BRIDGE) || (noprogress_count < VNET_NOPROGRESS_LIMIT)) { // Likely making progress, do fast yield so we // come back immediately if there is no other action palacios_yield_cpu(); } else { // Likely not making progress, do potentially slow // yield - we won't come back for until VNET_YIELD_TIME_USEC has passed - palacios_yield_cpu_timed(VNET_YIELD_TIME_USEC); + palacios_sleep_cpu(VNET_YIELD_TIME_USEC); } continue; @@ -556,7 +556,7 @@ int vnet_bridge_init(void) { memset(&vnet_brg_s, 0, sizeof(struct vnet_brg_state)); INIT_LIST_HEAD(&(vnet_brg_s.link_list)); - spin_lock_init(&(vnet_brg_s.lock)); + palacios_spinlock_init(&(vnet_brg_s.lock)); vnet_brg_s.serv_proto = UDP; @@ -610,6 +610,8 @@ void vnet_bridge_deinit(void){ vnet_brg_s.status = 0; + palacios_spinlock_deinit(&(vnet_brg_s.lock)); + INFO("VNET LNX Bridge Deinit Finished\n"); }