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;
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;
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
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;
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,
rate_limiter_start_ring,
ncrp);
nc2_init_poller(ncrp);
+
+ return 0;
}
/* Create a new netchannel2 structure. Call with no locks held.
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);
int need_flush;
domid_t otherend_id;
+ grant_ref_t gref_pool;
+
struct nc2_rate_limiter limiter;
uint8_t rlimit_disabled;
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);