RDMA/CMA: add rdma_iw_cm_id() and rdma_res_to_id() helpers
authorSteve Wise <swise@opengridcomputing.com>
Thu, 10 May 2018 14:31:36 +0000 (07:31 -0700)
committerDoug Ledford <dledford@redhat.com>
Tue, 22 May 2018 18:32:30 +0000 (14:32 -0400)
Add a helper function for iwarp drivers to be able to map an
rdma_cm_id to an iw_cm_id.  This is useful for dumping driver specific
NLDEV/RESTRACK connection state.

Add a helper to return the rdma_cm_id pointer from the rdma_restack
pointer.  This is needed for rdma drivers to map a res entry back to
the public rdma_cm_id struct.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cma.c
include/rdma/rdma_cm.h

index a403e679c6c1474ec32829d5affa9a9b4e3b508c..441555a35525a94122cc1a54b342c16c3067ae37 100644 (file)
@@ -146,6 +146,34 @@ const void *rdma_consumer_reject_data(struct rdma_cm_id *id,
 }
 EXPORT_SYMBOL(rdma_consumer_reject_data);
 
+/**
+ * rdma_iw_cm_id() - return the iw_cm_id pointer for this cm_id.
+ * @id: Communication Identifier
+ */
+struct iw_cm_id *rdma_iw_cm_id(struct rdma_cm_id *id)
+{
+       struct rdma_id_private *id_priv;
+
+       id_priv = container_of(id, struct rdma_id_private, id);
+       if (id->device->node_type == RDMA_NODE_RNIC)
+               return id_priv->cm_id.iw;
+       return NULL;
+}
+EXPORT_SYMBOL(rdma_iw_cm_id);
+
+/**
+ * rdma_res_to_id() - return the rdma_cm_id pointer for this restrack.
+ * @res: rdma resource tracking entry pointer
+ */
+struct rdma_cm_id *rdma_res_to_id(struct rdma_restrack_entry *res)
+{
+       struct rdma_id_private *id_priv =
+               container_of(res, struct rdma_id_private, res);
+
+       return &id_priv->id;
+}
+EXPORT_SYMBOL(rdma_res_to_id);
+
 static void cma_add_one(struct ib_device *device);
 static void cma_remove_one(struct ib_device *device, void *client_data);
 
index 690934733ba793b1ff7606f26e646e72280882f1..c5c1435c129ab23c6a5ac9140a57f5da57b2224f 100644 (file)
@@ -420,4 +420,7 @@ const void *rdma_consumer_reject_data(struct rdma_cm_id *id,
 void rdma_read_gids(struct rdma_cm_id *cm_id, union ib_gid *sgid,
                    union ib_gid *dgid);
 
+struct iw_cm_id *rdma_iw_cm_id(struct rdma_cm_id *cm_id);
+struct rdma_cm_id *rdma_res_to_id(struct rdma_restrack_entry *res);
+
 #endif /* RDMA_CM_H */