diff mbox

[v3,3/6] rdma_cm: add rdma_consumer_reject_data helper function

Message ID 7690d653aefbf9ff51dfa6c1ebef57b47616be23.1477336045.git.swise@opengridcomputing.com (mailing list archive)
State Superseded
Headers show

Commit Message

Steve Wise Oct. 24, 2016, 6:59 p.m. UTC
rdma_consumer_reject_data() will return the private data pointer
and length if any is available.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---
 drivers/infiniband/core/cma.c | 16 ++++++++++++++++
 include/rdma/rdma_cm.h        | 10 ++++++++++
 2 files changed, 26 insertions(+)

Comments

Sagi Grimberg Oct. 25, 2016, 4:36 p.m. UTC | #1
Looks good,

Reviewed-by: Sagi Grimberg <sagi@grimbeg.me>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoph Hellwig Oct. 25, 2016, 5:01 p.m. UTC | #2
On Mon, Oct 24, 2016 at 11:59:03AM -0700, Steve Wise wrote:
> rdma_consumer_reject_data() will return the private data pointer
> and length if any is available.
> 
> Signed-off-by: Steve Wise <swise@opengridcomputing.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 0d88c9d..2536d42 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -128,6 +128,22 @@  bool rdma_is_consumer_reject(struct rdma_cm_id *id, int reason)
 }
 EXPORT_SYMBOL(rdma_is_consumer_reject);
 
+const void *rdma_consumer_reject_data(struct rdma_cm_id *id,
+				      struct rdma_cm_event *ev, u8 *data_len)
+{
+	void *p;
+
+	if (rdma_is_consumer_reject(id, ev->status)) {
+		*data_len = ev->param.conn.private_data_len;
+		p = ev->param.conn.private_data;
+	} else {
+		*data_len = 0;
+		p = NULL;
+	}
+	return p;
+}
+EXPORT_SYMBOL(rdma_consumer_reject_data);
+
 static void cma_add_one(struct ib_device *device);
 static void cma_remove_one(struct ib_device *device, void *client_data);
 
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index 62039c2..d3968b5 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -403,4 +403,14 @@  const char *__attribute_const__ rdma_reject_msg(struct rdma_cm_id *id,
  */
 bool rdma_is_consumer_reject(struct rdma_cm_id *id, int reason);
 
+/**
+ * rdma_consumer_reject_data - return the consumer reject private data and
+ *			       length, if any.
+ * @id: Communication identifier that received the REJECT event.
+ * @ev: RDMA CM reject event.
+ * @data_len: Pointer to the resulting length of the consumer data.
+ */
+const void *rdma_consumer_reject_data(struct rdma_cm_id *id,
+				      struct rdma_cm_event *ev, u8 *data_len);
+
 #endif /* RDMA_CM_H */