[openib-general] [PATCH 1/4] IB CM: Save and report remote UD QP attributes after SIDR

Sean Hefty sean.hefty at intel.com
Tue Jun 6 19:43:13 PDT 2006


Record remote QP information returned from SIDR.  Expose attributes through
a new API.  This functionality is similar to the ib_cm_init_qp_attr()
routine that exists for RC QPs.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: core/cm.c
===================================================================
--- core/cm.c	(revision 7758)
+++ core/cm.c	(working copy)
@@ -138,6 +138,7 @@ struct cm_id_private {
 	__be64 tid;
 	__be32 local_qpn;
 	__be32 remote_qpn;
+	__be32 remote_qkey;
 	enum ib_qp_type qp_type;
 	__be32 sq_psn;
 	__be32 rq_psn;
@@ -2836,6 +2837,9 @@ static int cm_sidr_rep_handler(struct cm
 	}
 	cm_id_priv->id.state = IB_CM_IDLE;
 	ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+
+	cm_id_priv->remote_qpn = cm_sidr_rep_get_qpn(sidr_rep_msg);
+	cm_id_priv->remote_qkey = sidr_rep_msg->qkey;
 	spin_unlock_irqrestore(&cm_id_priv->lock, flags);
 
 	cm_format_sidr_rep_event(work);
@@ -3230,6 +3234,29 @@ int ib_cm_init_qp_attr(struct ib_cm_id *
 }
 EXPORT_SYMBOL(ib_cm_init_qp_attr);
 
+int ib_cm_get_dst_attr(struct ib_cm_id *cm_id, struct ib_ah_attr *ah_attr,
+		       u32 *remote_qpn, u32 *remote_qkey)
+{
+	struct cm_id_private *cm_id_priv;
+	unsigned long flags;
+	int ret = 0;
+
+	cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+	spin_lock_irqsave(&cm_id_priv->lock, flags);
+	if (cm_id_priv->id.state != IB_CM_IDLE) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	*ah_attr = cm_id_priv->av.ah_attr;
+	*remote_qpn = be32_to_cpu(cm_id_priv->remote_qpn);
+	*remote_qkey = be32_to_cpu(cm_id_priv->remote_qkey);
+out:
+	spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+	return ret;
+}
+EXPORT_SYMBOL(ib_cm_get_dst_attr);
+
 static void cm_add_one(struct ib_device *device)
 {
 	struct cm_device *cm_dev;
Index: include/rdma/ib_cm.h
===================================================================
--- include/rdma/ib_cm.h	(revision 7758)
+++ include/rdma/ib_cm.h	(working copy)
@@ -521,6 +521,18 @@ int ib_cm_init_qp_attr(struct ib_cm_id *
 		       int *qp_attr_mask);
 
 /**
+ * ib_cm_get_dst_attr - Initializes the attributes for use in sending
+ *   to a specified UD QP.
+ * @cm_id: Communication identifier that was used for the SIDR REQ.
+ * @ah_attr: Address handle attributes that should be used to send to the
+ *   destination QP.
+ * @remote_qpn: Remote QPN of the destination QP.
+ * @remote_qkey: Remote QKey of the destination QP.
+ */
+int ib_cm_get_dst_attr(struct ib_cm_id *cm_id, struct ib_ah_attr *ah_attr,
+		       u32 *remote_qpn, u32 *remote_qkey);
+
+/**
  * ib_send_cm_apr - Sends an alternate path response message in response to
  *   a load alternate path request.
  * @cm_id: Connection identifier associated with the alternate path response.





More information about the general mailing list