ib_core: changes to support XRC RCV qp's
PATCH v2 1/4 ib_core: changes to support XRC RCV qp's
The core layer does reference counting on XRC RCV qp's, and also is responsible for distributing async events generated for XRC RCV qp's to all registered processes.
Methods: ib_create_xrc_rcv_qp, ib_destroy_xrc_rcv_qp, ib_reg_xrc_rcv_qp and ib_unreg_xrc_rcv_qp -- and a XRC RCV QP cleanup function called when a process terminates (this function removes all registrations for that process, and destroys any XRC RCV QPs which have no processes registered after the cleanup).
All other functions serve to support keeping track of the XRC RCV qp's (in a radix tree), and to distribute the async events.
--- drivers/infiniband/core/device.c | 6 +- drivers/infiniband/core/verbs.c | 275 ++++++++++++++++++++++++++++++++++++++ include/rdma/ib_verbs.h | 45 ++++++ 3 files changed, 325 insertions(+), 1 deletions(-)
drivers/infiniband/core/device.c +5 -1
@@ -172,9 +172,13 @@ static int end_port(struct ib_device *de*/ struct ib_device *ib_alloc_device (size_t size) { +struct ib_device *ibdev;BUG_ON (size <sizeof (struct ib_device )); -return kzalloc (size,GFP_KERNEL ); + ibdev =kzalloc (size,GFP_KERNEL ); +if (ibdev) +ib_xrc_rcv_qp_table_init (ibdev); +return ibdev; }EXPORT_SYMBOL (ib_alloc_device);
drivers/infiniband/core/verbs.c +279 -0
288 lines not on this page · raw message
include/rdma/ib_verbs.h +45 -0
85 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 201005181455.02623.jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
drivers/infiniband/core/verbs.c int ib_dealloc_xrcd(struct ib_xrcd *xrcd · line 1046
Quoted 5 lines
drivers/infiniband/core/verbs.c +5
-0+struct ib_xrc_rcv_qp_table_entry * +ib_xrc_rcv_tbl_find (struct ib_device *dev,u32 qpn) +{ +return radix_tree_lookup (&dev->xrc_rcv_qp_table, qpn); +}
nit - but do we need a wrapper around this single call?
Quoted 17 lines
drivers/infiniband/core/verbs.c +17
-0+int ib_xrc_rcv_qp_table_add_reg_entry (struct ib_device *dev,u32 qpn, +void *context) +{ +struct ib_xrc_rcv_reg_entry *reg_entry, *tmp; +struct ib_xrc_rcv_qp_table_entry *qp; +unsigned long flags; +int err = -EINVAL , found =0 ; + + reg_entry =kzalloc (sizeof *reg_entry,GFP_KERNEL ); +if (!reg_entry) +return -ENOMEM ; + reg_entry->context = context; + +spin_lock_irqsave (&dev->xrc_rcv_qp_table_lock, flags); + qp =ib_xrc_rcv_tbl_find (dev, qpn); +if (unlikely (!qp)) + goto free_out;
drivers/infiniband/core/verbs.c int ib_dealloc_xrcd(struct ib_xrcd *xrcd · line 1115
Quoted 10 lines
drivers/infiniband/core/verbs.c +10
-0+list_for_each_entry (tmp, &qp->list, list) +if (tmp->context == context) { + found =1 ; +break ; + } +/* add only a single entry per user context */ +if (unlikely (found)) { + err =0 ; + goto free_out; + }
Maybe this becomes clear later, but can a user add multiple entries? Can't we just consider this a usage error? Actually, why does it matter if the same context is added multiple times?
Quoted 27 lines
drivers/infiniband/core/verbs.c +26
-0+atomic_inc (&qp->xrcd->usecnt); +list_add_tail (®_entry->list, &qp->list); +spin_unlock_irqrestore (&dev->xrc_rcv_qp_table_lock, flags); +return 0 ; + +free_out: +spin_unlock_irqrestore (&dev->xrc_rcv_qp_table_lock, flags); +kfree (reg_entry); +return err; +} +EXPORT_SYMBOL (ib_xrc_rcv_qp_table_add_reg_entry); +int ib_xrc_rcv_qp_table_remove (struct ib_device *dev,u32 qpn) +{ +struct ib_xrc_rcv_reg_entry *reg_entry, *tmp; +struct ib_xrc_rcv_qp_table_entry *qp; +struct list_head xrc_local; +unsigned long flags; + +INIT_LIST_HEAD (&xrc_local); + +spin_lock_irqsave (&dev->xrc_rcv_qp_table_lock, flags); + + qp =ib_xrc_rcv_tbl_find (dev, qpn); +if (unlikely (!qp)) + goto out; +/* ASSERT(!list_empty(&qp->list)); */
drivers/infiniband/core/verbs.c int ib_dealloc_xrcd(struct ib_xrcd *xrcd · line 1199
Quoted 10 lines
drivers/infiniband/core/verbs.c +10
-0+list_replace_init (&qp->list, &xrc_local); +radix_tree_delete (&dev->xrc_rcv_qp_table, qpn); +spin_unlock_irqrestore (&dev->xrc_rcv_qp_table_lock, flags); + + dev->destroy_xrc_rcv_qp (qp->xrcd, qpn); +kfree (qp); +list_for_each_entry_safe (reg_entry, tmp, &xrc_local, list) { +list_del (®_entry->list); +kfree (reg_entry); +atomic_dec (&qp->xrcd->usecnt);
qp was just freed a few lines up
- Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 21985B556C0D42658109996B406ADC15-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org
Quoted 7 lines · Sean Hefty
drivers/infiniband/core/verbs.c int ib_dealloc_xrcd(struct ib_xrcd *xrcd · line 1046
Quoted 5 lines
drivers/infiniband/core/verbs.c +5
-0+struct ib_xrc_rcv_qp_table_entry * +ib_xrc_rcv_tbl_find (struct ib_device *dev,u32 qpn) +{ +return radix_tree_lookup (&dev->xrc_rcv_qp_table, qpn); +}nit - but do we need a wrapper around this single call?
I prefer it this way, so that we have a complete xrc_rcv_table interface.
Quoted 6 lines
Quoted 6 lines
drivers/infiniband/core/verbs.c +6
-0+list_for_each_entry (tmp, &qp->list, list) +if (tmp->context == context) { + found =1 ; +break ; + } +/* add only a single entry per user context */
Quoted 8 lines
drivers/infiniband/core/verbs.c int ib_dealloc_xrcd(struct ib_xrcd *xrcd · line 1115
Quoted 4 lines
drivers/infiniband/core/verbs.c +4
-0+if (unlikely (found)) { + err =0 ; + goto free_out; + }Maybe this becomes clear later, but can a user add multiple entries? Can't we just consider this a usage error? Actually, why does it matter if the same context is added multiple times?
This list of entries is also used to disperse XRC RCV qp events to all registered processes -- and we only want a single event dispatched per process.
Quoted 8 lines
drivers/infiniband/core/verbs.c int ib_dealloc_xrcd(struct ib_xrcd *xrcd · line 1199
Quoted 6 lines
drivers/infiniband/core/verbs.c +6
-0+ dev->destroy_xrc_rcv_qp (qp->xrcd, qpn); +kfree (qp); +list_for_each_entry_safe (reg_entry, tmp, &xrc_local, list) { +list_del (®_entry->list); +kfree (reg_entry); +atomic_dec (&qp->xrcd->usecnt);qp was just freed a few lines up
Ouch! Thanks for the catch, Sean. I'll fix it before resubmitting.
Regards,
Jack
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html