than pulling from the main pool for every packet.
}
EXPORT_SYMBOL_GPL(gnttab_free_grant_references);
+int gnttab_suballoc_grant_references(u16 count, grant_ref_t *old_head,
+ grant_ref_t *new_head)
+{
+ grant_ref_t cursor;
+ unsigned nr_allocated;
+
+ *new_head = cursor = *old_head;
+ if (cursor == GNTTAB_LIST_END)
+ return -ENOSPC;
+ nr_allocated = 1;
+ while (nr_allocated < count) {
+ cursor = gnttab_entry(cursor);
+ if (cursor == GNTTAB_LIST_END)
+ return -ENOSPC;
+ nr_allocated++;
+ }
+ *old_head = gnttab_entry(cursor);
+ gnttab_entry(cursor) = GNTTAB_LIST_END;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(gnttab_suballoc_grant_references);
+
+void gnttab_subfree_grant_references(grant_ref_t head, grant_ref_t *pool)
+{
+ grant_ref_t cursor;
+
+ for (cursor = head;
+ gnttab_entry(cursor) != GNTTAB_LIST_END;
+ cursor = gnttab_entry(cursor))
+ ;
+ gnttab_entry(cursor) = *pool;
+ *pool = head;
+}
+EXPORT_SYMBOL_GPL(gnttab_subfree_grant_references);
+
int gnttab_alloc_grant_references(u16 count, grant_ref_t *head)
{
int h = get_free_entries(count);
}
/* Grab the grant references. */
- err = gnttab_alloc_grant_references(skb_co->nr_fragments, &gref_pool);
+ err = gnttab_suballoc_grant_references(skb_co->nr_fragments,
+ &ncrp->gref_pool,
+ &gref_pool);
if (err < 0) {
release_txp_slot(ncrp, skb);
/* Leave skb_co->nr_fragments set, so that we don't
while (!nc2_end_foreign_access_ref(gref, 1)) {
cpu_relax();
}
- gnttab_free_grant_reference(gref);
+ gnttab_release_grant_reference(&ncrp->gref_pool, gref);
}
} else if (skb_co->type == NC2_PACKET_TYPE_receiver_map) {
while (1) {
if (r == 0) {
printk(KERN_WARNING "Failed to end remote access to packet memory.\n");
} else {
- gnttab_free_grant_reference(gref);
+ gnttab_release_grant_reference(&ncrp->gref_pool,
+ gref);
}
}
} else if (skb_co->gref_pool != 0) {
- gnttab_free_grant_references(skb_co->gref_pool);
+ gnttab_subfree_grant_references(skb_co->gref_pool,
+ &ncrp->gref_pool);
}
if (tp != NULL)
*/
int gnttab_alloc_grant_references(u16 count, grant_ref_t *pprivate_head);
+int gnttab_suballoc_grant_references(u16 count, grant_ref_t *old_head,
+ grant_ref_t *new_head);
+
void gnttab_free_grant_reference(grant_ref_t ref);
void gnttab_free_grant_references(grant_ref_t head);
+void gnttab_subfree_grant_references(grant_ref_t head, grant_ref_t *pool);
+
int gnttab_empty_grant_references(const grant_ref_t *pprivate_head);
int gnttab_claim_grant_reference(grant_ref_t *pprivate_head);