Browse Source

IB/rdmavt: add modify queue pair driver helpers

Low level drivers need to be able to check incoming attributes as well as be
able to adjust their private data on queue pair modification.  Add 2 driver
callbacks, check_modify_qp and modify_qp, to facilitate this.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Ira Weiny 9 years ago
parent
commit
e85ec33d82
2 changed files with 14 additions and 0 deletions
  1. 7 0
      drivers/infiniband/sw/rdmavt/qp.c
  2. 7 0
      include/rdma/rdma_vt.h

+ 7 - 0
drivers/infiniband/sw/rdmavt/qp.c

@@ -970,6 +970,10 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 				attr_mask, link))
 				attr_mask, link))
 		goto inval;
 		goto inval;
 
 
+	if (rdi->driver_f.check_modify_qp &&
+	    rdi->driver_f.check_modify_qp(qp, attr, attr_mask, udata))
+		goto inval;
+
 	if (attr_mask & IB_QP_AV) {
 	if (attr_mask & IB_QP_AV) {
 		if (attr->ah_attr.dlid >= be16_to_cpu(IB_MULTICAST_LID_BASE))
 		if (attr->ah_attr.dlid >= be16_to_cpu(IB_MULTICAST_LID_BASE))
 			goto inval;
 			goto inval;
@@ -1166,6 +1170,9 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC)
 	if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC)
 		qp->s_max_rd_atomic = attr->max_rd_atomic;
 		qp->s_max_rd_atomic = attr->max_rd_atomic;
 
 
+	if (rdi->driver_f.modify_qp)
+		rdi->driver_f.modify_qp(qp, attr, attr_mask, udata);
+
 	spin_unlock(&qp->s_lock);
 	spin_unlock(&qp->s_lock);
 	spin_unlock_irq(&qp->r_lock);
 	spin_unlock_irq(&qp->r_lock);
 
 

+ 7 - 0
include/rdma/rdma_vt.h

@@ -256,6 +256,13 @@ struct rvt_driver_provided {
 			      struct rvt_ah *);
 			      struct rvt_ah *);
 	int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
 	int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
 			 enum ib_qp_type type, u8 port, gfp_t gfp);
 			 enum ib_qp_type type, u8 port, gfp_t gfp);
+	/**
+	 * Return 0 if modification is valid, -errno otherwise
+	 */
+	int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
+			       int attr_mask, struct ib_udata *udata);
+	void (*modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
+			  int attr_mask, struct ib_udata *udata);
 };
 };
 
 
 struct rvt_dev_info {
 struct rvt_dev_info {