]> xenbits.xensource.com Git - people/ssmith/nc2-2.6.27.git/commitdiff
Pre-allocate a pool of grant references when an interface starts up.
authorSteven Smith <ssmith@weybridge.uk.xensource.com>
Wed, 24 Jun 2009 12:46:11 +0000 (13:46 +0100)
committerSteven Smith <ssmith@weybridge.uk.xensource.com>
Tue, 30 Jun 2009 12:02:14 +0000 (13:02 +0100)
drivers/xen/netchannel2/bypass.c
drivers/xen/netchannel2/chan.c
drivers/xen/netchannel2/netchannel2_core.h

index 5e3e4452d15490b2a114121a481c782882be6873..4e268ec18ef1c1e7a38de0e358baa5cdf6371567 100644 (file)
@@ -563,7 +563,8 @@ void nc2_handle_bypass_frontend(struct netchannel2 *nc,
         init_waitqueue_head(&work->eventq);
         work->handle = work->frontend_setup_msg.common.handle;
         INIT_WORK(&work->work_item, initialise_bypass_frontend_work_item);
-        init_ring_pair(&work->rings);
+        if (init_ring_pair(&work->rings) < 0)
+            goto err;
         work->rings.filter_mac = 1;
         work->rings.interface = nc;
 
@@ -632,7 +633,8 @@ void nc2_handle_bypass_backend(struct netchannel2 *nc,
         init_waitqueue_head(&work->eventq);
         work->handle = work->backend_setup_msg.common.handle;
         INIT_WORK(&work->work_item, initialise_bypass_backend_work_item);
-        init_ring_pair(&work->rings);
+        if (init_ring_pair(&work->rings) < 0)
+            goto err;
         work->rings.filter_mac = 1;
         work->rings.interface = nc;
 
index 02f88dee5d8a7c87fa0ede5daaf8263e0b56cdaa..7f50f01611d6f70cbbf466621c7ea9431fb0eac3 100644 (file)
@@ -469,6 +469,8 @@ void cleanup_ring_pair(struct netchannel2_ring_pair *ncrp)
 
         drop_pending_tx_packets(ncrp);
         nc2_queue_purge(ncrp, &ncrp->release_on_flush_batcher);
+        if (ncrp->gref_pool != 0)
+                gnttab_free_grant_references(ncrp->gref_pool);
 }
 
 /* Stop and start functions for the ring rate/asymmetry limiter.  This
@@ -525,7 +527,7 @@ static void rate_limiter_start_ring(void *ctxt)
         spin_unlock_irqrestore(&pending_interfaces_lock, flags);
 }
 
-void init_ring_pair(struct netchannel2_ring_pair *ncrp)
+int init_ring_pair(struct netchannel2_ring_pair *ncrp)
 {
         unsigned x;
 
@@ -541,6 +543,11 @@ void init_ring_pair(struct netchannel2_ring_pair *ncrp)
         skb_queue_head_init(&ncrp->release_on_flush_batcher);
 
         init_waitqueue_head(&ncrp->waitq);
+
+        if (gnttab_alloc_grant_references(NR_TX_PACKETS,
+                                          &ncrp->gref_pool) < 0)
+                return -1;
+
         nc2_init_rate_limiter(&ncrp->limiter,
                               fls(50000/HZ),
                               20000,
@@ -549,6 +556,8 @@ void init_ring_pair(struct netchannel2_ring_pair *ncrp)
                               rate_limiter_start_ring,
                               ncrp);
         nc2_init_poller(ncrp);
+
+        return 0;
 }
 
 /* Create a new netchannel2 structure.  Call with no locks held.
@@ -636,7 +645,11 @@ struct netchannel2 *nc2_new(struct xenbus_device *xd)
         INIT_LIST_HEAD(&nc->alternate_rings);
 #endif
         skb_queue_head_init(&nc->pending_skbs);
-        init_ring_pair(&nc->rings);
+        if (init_ring_pair(&nc->rings) < 0) {
+                nc2_release(nc);
+                return NULL;
+        }
+
         nc->rings.interface = nc;
         INIT_LIST_HEAD(&nc->rx_buffers);
         INIT_LIST_HEAD(&nc->unused_rx_buffers);
index beb5cc8b316e1407edfb9dbbc81ab7addd4ce7e8..02f71589c90f78bb61ce1df0ea59ac6bda24c2f2 100644 (file)
@@ -330,6 +330,8 @@ struct netchannel2_ring_pair {
         int need_flush;
         domid_t otherend_id;
 
+        grant_ref_t gref_pool;
+
         struct nc2_rate_limiter limiter;
         uint8_t rlimit_disabled;
 
@@ -1068,7 +1070,7 @@ void _nc2_attach_rings(struct netchannel2_ring_pair *ncrp,
 void queue_packet_to_interface(struct sk_buff *skb,
                                struct netchannel2_ring_pair *ncrp);
 unsigned get_transmitted_packet_msg_size(struct sk_buff *skb);
-void init_ring_pair(struct netchannel2_ring_pair *ncrp);
+int init_ring_pair(struct netchannel2_ring_pair *ncrp);
 
 irqreturn_t nc2_int(int irq, void *dev_id);