diff mbox

[rdma-core,06/11] Expand create flow to take provider internal data

Message ID 1526553577-32273-7-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Yishai Hadas May 17, 2018, 10:39 a.m. UTC
From: Raed Salem <raeds@mellanox.com>

Downstream patch will use this to pass counters mapping as
provider internal data when creating a flow.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 libibverbs/cmd.c       | 16 ++++++++++++----
 libibverbs/driver.h    |  4 +++-
 providers/mlx4/verbs.c |  3 ++-
 providers/mlx5/verbs.c |  3 ++-
 4 files changed, 19 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c
index 0f102b4..9cd1ba5 100644
--- a/libibverbs/cmd.c
+++ b/libibverbs/cmd.c
@@ -1803,7 +1803,9 @@  static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec,
 
 int ibv_cmd_create_flow(struct ibv_qp *qp,
 			struct ibv_flow *flow_id,
-			struct ibv_flow_attr *flow_attr)
+			struct ibv_flow_attr *flow_attr,
+			void *ucmd,
+			size_t ucmd_size)
 {
 	struct ibv_create_flow *cmd;
 	struct ib_uverbs_destroy_flow  resp;
@@ -1815,8 +1817,8 @@  int ibv_cmd_create_flow(struct ibv_qp *qp,
 
 	cmd_size = sizeof(*cmd) + (flow_attr->num_of_specs *
 				  sizeof(struct ibv_kern_spec));
-	cmd = alloca(cmd_size);
-	memset(cmd, 0, cmd_size);
+	cmd = alloca(cmd_size + ucmd_size);
+	memset(cmd, 0, cmd_size + ucmd_size);
 
 	cmd->qp_handle = qp->handle;
 
@@ -1841,7 +1843,13 @@  int ibv_cmd_create_flow(struct ibv_qp *qp,
 	}
 
 	written_size = sizeof(*cmd) + cmd->flow_attr.size;
-	IBV_INIT_CMD_RESP_EX_VCMD(cmd, written_size, written_size, CREATE_FLOW,
+	if (ucmd) {
+		memcpy((char *)cmd + written_size, ucmd, ucmd_size);
+		written_size += ucmd_size;
+	}
+
+	IBV_INIT_CMD_RESP_EX_VCMD(cmd, written_size - ucmd_size,
+				  written_size, CREATE_FLOW,
 				  &resp, sizeof(resp));
 	if (write(qp->context->cmd_fd, cmd, written_size) != written_size)
 		goto err;
diff --git a/libibverbs/driver.h b/libibverbs/driver.h
index f296c6b..2780a56 100644
--- a/libibverbs/driver.h
+++ b/libibverbs/driver.h
@@ -514,7 +514,9 @@  int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t l
 
 int ibv_cmd_create_flow(struct ibv_qp *qp,
 				     struct ibv_flow *flow_id,
-				     struct ibv_flow_attr *flow_attr);
+				     struct ibv_flow_attr *flow_attr,
+				     void *ucmd,
+				     size_t ucmd_size);
 int ibv_cmd_destroy_flow(struct ibv_flow *flow_id);
 int ibv_cmd_create_wq(struct ibv_context *context,
 		      struct ibv_wq_init_attr *wq_init_attr,
diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
index 495f84e..4b5c06f 100644
--- a/providers/mlx4/verbs.c
+++ b/providers/mlx4/verbs.c
@@ -1543,7 +1543,8 @@  struct ibv_flow *mlx4_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow_
 	if (!flow_id)
 		return NULL;
 
-	ret = ibv_cmd_create_flow(qp, flow_id, flow_attr);
+	ret = ibv_cmd_create_flow(qp, flow_id, flow_attr,
+				  NULL, 0);
 	if (!ret)
 		return flow_id;
 
diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
index 71728c8..851493c 100644
--- a/providers/mlx5/verbs.c
+++ b/providers/mlx5/verbs.c
@@ -2942,7 +2942,8 @@  struct ibv_flow *mlx5_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow_
 	if (!flow_id)
 		return NULL;
 
-	ret = ibv_cmd_create_flow(qp, flow_id, flow_attr);
+	ret = ibv_cmd_create_flow(qp, flow_id, flow_attr,
+				  NULL, 0);
 	if (!ret)
 		return flow_id;