diff --git a/libibverbs/cmd_cq.c b/libibverbs/cmd_cq.c index 5642d301d..97c0ceae6 100644 --- a/libibverbs/cmd_cq.c +++ b/libibverbs/cmd_cq.c @@ -127,6 +127,32 @@ static int ibv_icmd_create_cq(struct ibv_context *context, int cqe, return 0; } +static int ibv_icmd_create_cq_ex(struct ibv_context *context, + const struct ibv_cq_init_attr_ex *cq_attr, + struct verbs_cq *cq, + struct ibv_command_buffer *cmdb, + uint32_t cmd_flags) +{ + uint32_t flags = 0; + + if (!check_comp_mask(cq_attr->comp_mask, + IBV_CQ_INIT_ATTR_MASK_FLAGS | + IBV_CQ_INIT_ATTR_MASK_PD)) + return EOPNOTSUPP; + + if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP || + cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP_WALLCLOCK) + flags |= IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION; + + if ((cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS) && + cq_attr->flags & IBV_CREATE_CQ_ATTR_IGNORE_OVERRUN) + flags |= IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN; + + return ibv_icmd_create_cq(context, cq_attr->cqe, cq_attr->channel, + cq_attr->comp_vector, flags, + &cq->cq, cmdb, cmd_flags); +} + int ibv_cmd_create_cq(struct ibv_context *context, int cqe, struct ibv_comp_channel *channel, int comp_vector, struct ibv_cq *cq, struct ibv_create_cq *cmd, @@ -153,24 +179,25 @@ int ibv_cmd_create_cq_ex(struct ibv_context *context, DECLARE_CMD_BUFFER_COMPAT(cmdb, UVERBS_OBJECT_CQ, UVERBS_METHOD_CQ_CREATE, cmd, cmd_size, resp, resp_size); - uint32_t flags = 0; - - if (!check_comp_mask(cq_attr->comp_mask, - IBV_CQ_INIT_ATTR_MASK_FLAGS | - IBV_CQ_INIT_ATTR_MASK_PD)) - return EOPNOTSUPP; - if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP || - cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP_WALLCLOCK) - flags |= IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION; + return ibv_icmd_create_cq_ex(context, cq_attr, cq, cmdb, cmd_flags); +} - if ((cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS) && - cq_attr->flags & IBV_CREATE_CQ_ATTR_IGNORE_OVERRUN) - flags |= IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN; +int ibv_cmd_create_cq_ex2(struct ibv_context *context, + const struct ibv_cq_init_attr_ex *cq_attr, + struct verbs_cq *cq, + struct ibv_create_cq_ex *cmd, + size_t cmd_size, + struct ib_uverbs_ex_create_cq_resp *resp, + size_t resp_size, + uint32_t cmd_flags, + struct ibv_command_buffer *driver) +{ + DECLARE_CMD_BUFFER_LINK_COMPAT(cmdb, UVERBS_OBJECT_CQ, + UVERBS_METHOD_CQ_CREATE, + driver, cmd, cmd_size, resp, resp_size); - return ibv_icmd_create_cq(context, cq_attr->cqe, cq_attr->channel, - cq_attr->comp_vector, flags, - &cq->cq, cmdb, cmd_flags); + return ibv_icmd_create_cq_ex(context, cq_attr, cq, cmdb, cmd_flags); } int ibv_cmd_destroy_cq(struct ibv_cq *cq) diff --git a/libibverbs/cmd_write.h b/libibverbs/cmd_write.h index 647b16152..cdfa1ddd3 100644 --- a/libibverbs/cmd_write.h +++ b/libibverbs/cmd_write.h @@ -96,6 +96,13 @@ void _write_set_uhw(struct ibv_command_buffer *cmdb, const void *req, _write_set_uhw(_name, cmd, sizeof(*cmd), cmd_size, resp, \ sizeof(*resp), resp_size) +#define DECLARE_CMD_BUFFER_LINK_COMPAT(_name, _object_id, _method_id, \ + _link, cmd, cmd_size, \ + resp, resp_size) \ + DECLARE_COMMAND_BUFFER_LINK(_name, _object_id, _method_id, 2, _link); \ + _write_set_uhw(_name, cmd, sizeof(*cmd), cmd_size, resp, \ + sizeof(*resp), resp_size) + /* * The fallback scheme keeps track of which ioctls succeed in a per-context * bitmap. If ENOTTY or EPROTONOSUPPORT is seen then the ioctl is never diff --git a/libibverbs/driver.h b/libibverbs/driver.h index 9b5cca742..ba3560bcc 100644 --- a/libibverbs/driver.h +++ b/libibverbs/driver.h @@ -575,6 +575,15 @@ int ibv_cmd_create_cq_ex(struct ibv_context *context, struct ib_uverbs_ex_create_cq_resp *resp, size_t resp_size, uint32_t cmd_flags); +int ibv_cmd_create_cq_ex2(struct ibv_context *context, + const struct ibv_cq_init_attr_ex *cq_attr, + struct verbs_cq *cq, + struct ibv_create_cq_ex *cmd, + size_t cmd_size, + struct ib_uverbs_ex_create_cq_resp *resp, + size_t resp_size, + uint32_t cmd_flags, + struct ibv_command_buffer *driver); int ibv_cmd_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc); int ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only); int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe, diff --git a/libibverbs/libibverbs.map.in b/libibverbs/libibverbs.map.in index 3ebcad094..11268cefd 100644 --- a/libibverbs/libibverbs.map.in +++ b/libibverbs/libibverbs.map.in @@ -184,6 +184,7 @@ IBVERBS_PRIVATE_@IBVERBS_PABI_VERSION@ { ibv_cmd_create_counters; ibv_cmd_create_cq; ibv_cmd_create_cq_ex; + ibv_cmd_create_cq_ex2; ibv_cmd_create_flow; ibv_cmd_create_flow_action_esp; ibv_cmd_create_qp;