mlx4: implement XRC RCV qp's
Subsystems (2)
PATCH 4/4 mlx4: implement XRC RCV qp's
Support for XRC RCV-only QP (requested by userspace, but resides in kernel space).
--- drivers/infiniband/hw/mlx4/cq.c | 2 +- drivers/infiniband/hw/mlx4/main.c | 64 ++++++- drivers/infiniband/hw/mlx4/mlx4_ib.h | 16 ++ drivers/infiniband/hw/mlx4/qp.c | 304 +++++++++++++++++++++++++++++++++- 4 files changed, 374 insertions(+), 12 deletions(-)
drivers/infiniband/hw/mlx4/cq.c +1 -1
@@ -175,7 +175,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vectorif (entries <1 || entries > dev->dev->caps.max_cqes)return ERR_PTR (-EINVAL ); - cq =kmalloc (sizeof *cq,GFP_KERNEL ); + cq =kzalloc (sizeof *cq,GFP_KERNEL );if (!cq)return ERR_PTR (-ENOMEM );
drivers/infiniband/hw/mlx4/main.c +55 -9
115 lines not on this page · raw message
drivers/infiniband/hw/mlx4/mlx4_ib.h +16 -0
@@ -59,6 +59,8 @@ struct mlx4_ib_pd {struct mlx4_ib_xrcd {struct ib_xrcd ibxrcd;u32 xrcdn; +struct ib_pd *pd; +struct ib_cq *cq; };struct mlx4_ib_cq_buf {
@@ -115,6 +117,7 @@ struct mlx4_ib_wq {enum mlx4_ib_qp_flags {MLX4_IB_QP_LSO =1 <<0 ,MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK =1 <<1 , +MLX4_IB_XRC_RCV =1 <<2 , };struct mlx4_ib_qp {
@@ -137,6 +140,7 @@ struct mlx4_ib_qp {int buf_size;struct mutex mutex;u32 flags; +struct list_head xrc_reg_list;u16 xrcdn;u8 port;u8 alt_port;
@@ -181,6 +185,7 @@ struct mlx4_ib_dev {spinlock_t sm_lock;struct mutex cap_mask_mutex; +struct mutex xrc_reg_mutex;bool ib_active; };
@@ -329,6 +334,17 @@ int mlx4_ib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, int npages, u64 iova);int mlx4_ib_unmap_fmr (struct list_head *fmr_list);int mlx4_ib_fmr_dealloc (struct ib_fmr *fmr); +int mlx4_ib_create_xrc_rcv_qp (struct ib_qp_init_attr *init_attr, +u32 *qp_num); +int mlx4_ib_modify_xrc_rcv_qp (struct ib_xrcd *xrcd,u32 qp_num, +struct ib_qp_attr *attr,int attr_mask); +int mlx4_ib_query_xrc_rcv_qp (struct ib_xrcd *xrcd,u32 qp_num, +struct ib_qp_attr *attr,int attr_mask, +struct ib_qp_init_attr *init_attr); +int mlx4_ib_reg_xrc_rcv_qp (struct ib_xrcd *xrcd,void *context,u32 qp_num); +int mlx4_ib_unreg_xrc_rcv_qp (struct ib_xrcd *xrcd,void *context,u32 qp_num); +int mlx4_ib_destroy_xrc_rcv_qp (struct ib_xrcd *xrcd,void *context,u32 qp_num); +static inline int mlx4_ib_ah_grh_present (struct mlx4_ib_ah *ah) {
drivers/infiniband/hw/mlx4/qp.c +302 -2
331 lines not on this page · raw message
Signature · 6 lines
1.6.3.2 -- 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
drivers/infiniband/hw/mlx4/cq.c struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector · line 178
Quoted 6 lines
drivers/infiniband/hw/mlx4/cq.c +1
-1@@ -175,7 +175,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vectorif (entries <1 || entries > dev->dev->caps.max_cqes)return ERR_PTR (-EINVAL ); - cq =kmalloc (sizeof *cq,GFP_KERNEL ); + cq =kzalloc (sizeof *cq,GFP_KERNEL );
What's the reason for this change?
drivers/infiniband/hw/mlx4/main.c static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev, · line 484
Quoted 3 lines
drivers/infiniband/hw/mlx4/main.c +2
-0@@ -477,23 +483,51 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev, + pd =mlx4_ib_alloc_pd (ibdev,NULL ,NULL ); + cq =mlx4_ib_create_cq (ibdev,1 ,0 ,NULL ,NULL );
Why does every xrcd get a PD and a CQ now? Just in case someone wants to create a rcv QP? (The spec is unclear on this -- for "create XRC target QP" it says "A set of initial QP attributes must be specified by the Consumer," but then doesn't mention anything in the input modifiers, so it's not clear what PD/CQ is supposed to be used)
drivers/infiniband/hw/mlx4/main.c static void *mlx4_ib_add(struct mlx4_dev *dev) · line 708
Quoted 4 lines
drivers/infiniband/hw/mlx4/main.c +1
-1+ (1ull <<IB_USER_VERBS_CMD_DESTROY_XRC_RCV_QP ); } -
This seems to be repairing whitespace damage from the previous patch.
Quoted 4 lines
drivers/infiniband/hw/mlx4/qp.c +3
-0+int mlx4_ib_reg_xrc_rcv_qp(struct ib_xrcd *xrcd, void *context, u32 qp_num) + mutex_lock(&mibqp->mutex); +list_for_each_entry (tmp, &mibqp->xrc_reg_list, list)
drivers/infiniband/hw/mlx4/qp.c out: · line 2222
Quoted 10 lines
drivers/infiniband/hw/mlx4/qp.c +10
-0+if (tmp->context == context) { +mutex_unlock (&mibqp->mutex); +kfree (ctx_entry); +mutex_unlock (&to_mdev (xrcd->device)->xrc_reg_mutex); +return 0 ; + } + + ctx_entry->context = context; +list_add_tail (&ctx_entry->list, &mibqp->xrc_reg_list); +mutex_unlock (&mibqp->mutex);
This list handling looks completely generic and is what I was saying should probably be in the core uverbs module.
drivers/infiniband/hw/mlx4/qp.c out: · line 2088
Quoted 3 lines
drivers/infiniband/hw/mlx4/qp.c +3
-0+int mlx4_ib_query_xrc_rcv_qp (struct ib_xrcd *ibxrcd,u32 qp_num, +struct ib_qp_attr *qp_attr,int qp_attr_mask, +struct ib_qp_init_attr *qp_init_attr)
Virtually all of this function seems identical to the existing query QP operation. We should avoid the mass duplication of code.
Also I'm not clear why this function takes a qp_num instead of a QP handle. Why does the consumer have to pass in the XRCD? The IB spec XRC annex just shows the QP handle as input to this verb. Is it because the reg_xrc_rcv_qp doesn't give a QP handle back?
Finally, in this implementation, what happens if the consumer passes in a QP that isn't an XRC rcv QP?
drivers/infiniband/hw/mlx4/qp.c out: · line 2111
Quoted 10 lines
drivers/infiniband/hw/mlx4/qp.c +10
-0+ mqp =__mlx4_qp_lookup (dev->dev, qp_num); +if (unlikely (!mqp)) { +printk (KERN_WARNING "mlx4_ib_reg_xrc_rcv_qp: " +"unknown QPN %06x\n" , qp_num); + goto err_out; + } + + qp =to_mibqp (mqp); +if (xrcd->xrcdn !=to_mxrcd (qp->ibqp.xrcd)->xrcdn) + goto err_out;
In other words is that dereference of ->xrcdn safe if ibqp.xrcd is not set? (And the error message talks about reg_xrc_rcv_qp instead of query)
Signature · 6 lines
Roland Dreier <[email protected]> || For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/index.html -- 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
Quoted 8 lines · Roland Dreier
drivers/infiniband/hw/mlx4/cq.c struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector · line 178
Quoted 6 lines
drivers/infiniband/hw/mlx4/cq.c +1
-1@@ -175,7 +175,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vectorif (entries <1 || entries > dev->dev->caps.max_cqes)return ERR_PTR (-EINVAL ); - cq =kmalloc (sizeof *cq,GFP_KERNEL ); + cq =kzalloc (sizeof *cq,GFP_KERNEL );What's the reason for this change?
Because mlx4_ib_create_cq is used in mlx4_ib_alloc_xrcd (to allocate the dummy cq), and I did not want to worry about unitialized data being present in the struct ib_cq portion of struct mlx4_ib_cq.
Quoted 6 lines
drivers/infiniband/hw/mlx4/main.c static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev, · line 484
Quoted 3 lines
drivers/infiniband/hw/mlx4/main.c +2
-0@@ -477,23 +483,51 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev, + pd =mlx4_ib_alloc_pd (ibdev,NULL ,NULL ); + cq =mlx4_ib_create_cq (ibdev,1 ,0 ,NULL ,NULL );Why does every xrcd get a PD and a CQ now? Just in case someone wants to create a rcv QP?
Yes. This way, we have a dummy PD and CQ available to satisfy the ConnectX requirement that every QP have a PD and CQ.
Quoted 6 lines
(The spec is unclear on this -- for "create XRC
target QP" it says "A set of initial QP attributes must be specified by the Consumer," but then doesn't mention anything in the input modifiers, so it's not clear what PD/CQ is supposed to be used)From the XRC Annex to the IB Spec:
A12.5.2.3 XRC TARGET QP
A12.5.2.3.1 CREATE XRC TARGET QP
Description:
Creates a XRC Target QP for the specified HCA.
A set of initial QP attributes must be specified by the Consumer. On success, a handle to the newly created XRC QP and the XRC QP number are returned.
Input Modifiers:
Same as RC QP except for:
==> no SQ or RQ or SRQ (WQEs, num of s/g elements, CQs, signaling type, etc.)
no need for initiator resources (initiator depth)
==> no PD
add XRC domain to be associated with this QP.
Quoted 6 lines
drivers/infiniband/hw/mlx4/main.c static void *mlx4_ib_add(struct mlx4_dev *dev) · line 708
Quoted 4 lines
drivers/infiniband/hw/mlx4/main.c +1
-1+ (1ull <<IB_USER_VERBS_CMD_DESTROY_XRC_RCV_QP ); } -This seems to be repairing whitespace damage from the previous patch.
I will fix both patches.
Quoted 17 lines
Quoted 4 lines
drivers/infiniband/hw/mlx4/qp.c +3
-0+int mlx4_ib_reg_xrc_rcv_qp(struct ib_xrcd *xrcd, void *context, u32 qp_num) + mutex_lock(&mibqp->mutex); +list_for_each_entry (tmp, &mibqp->xrc_reg_list, list)drivers/infiniband/hw/mlx4/qp.c out: · line 2222
Quoted 10 lines
drivers/infiniband/hw/mlx4/qp.c +10
-0+if (tmp->context == context) { +mutex_unlock (&mibqp->mutex); +kfree (ctx_entry); +mutex_unlock (&to_mdev (xrcd->device)->xrc_reg_mutex); +return 0 ; + } + + ctx_entry->context = context; +list_add_tail (&ctx_entry->list, &mibqp->xrc_reg_list); +mutex_unlock (&mibqp->mutex);This list handling looks completely generic and is what I was saying should probably be in the core uverbs module.
This list is used to send async events for this xrc rcv QP to all processes using the QP (either registered for the qp, or the creating process).
Moving this to the core layer would require significant modifications. I responded to this in my response to your first mail.
Quoted 11 lines
drivers/infiniband/hw/mlx4/qp.c out: · line 2088
Quoted 3 lines
drivers/infiniband/hw/mlx4/qp.c +3
-0+int mlx4_ib_query_xrc_rcv_qp (struct ib_xrcd *ibxrcd,u32 qp_num, +struct ib_qp_attr *qp_attr,int qp_attr_mask, +struct ib_qp_init_attr *qp_init_attr)Virtually all of this function seems identical to the existing query QP operation. We should avoid the mass duplication of code.
Also I'm not clear why this function takes a
qp_numinstead of a QP handle. Why does the consumer have to pass in the XRCD? The IB spec XRC annex just shows the QP handle as input to this verb. Is it because thereg_xrc_rcv_qpdoesn't give a QP handle back?
Yes, I considered the handle to be the pair (xrc domain, qp_number).
Quoted 4 lines
Finally, in this implementation, what happens if the consumer passes in a QP that isn't an XRC rcv QP?
Quoted 13 lines
drivers/infiniband/hw/mlx4/qp.c out: · line 2111
Quoted 10 lines
drivers/infiniband/hw/mlx4/qp.c +10
-0+ mqp =__mlx4_qp_lookup (dev->dev, qp_num); +if (unlikely (!mqp)) { +printk (KERN_WARNING "mlx4_ib_reg_xrc_rcv_qp: " +"unknown QPN %06x\n" , qp_num); + goto err_out; + } + + qp =to_mibqp (mqp); +if (xrcd->xrcdn !=to_mxrcd (qp->ibqp.xrcd)->xrcdn) + goto err_out;In other words is that dereference of ->xrcdn safe if ibqp.xrcd is not set? (And the error message talks about
reg_xrc_rcv_qpinstead of query)
You are correct -- I will fix both of these (error msg and unprotected dereference).
--
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