aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2016-06-01 16:05:38 +0300
committerDoug Ledford <dledford@redhat.com>2016-06-04 22:30:19 -0400
commit169a6efad9e5c50b87e2820740ecfda63878f7ca (patch)
tree9648d8df6bc8ad564dc088e7fe1ac997d892bc3d
parentc2e36f6797f4466b8cea1df53db11c5c23bd3b2a (diff)
downloadlibibverbs-169a6efad9e5c50b87e2820740ecfda63878f7ca.tar.gz
Create a single threaded CQ
When a CQ is used only from one thread, there's no need to waste cycles on locking. Since this series introduces a mechanism which allows the vendor to introduce different polling functions per CQ, it allows the vendor to implement both locking and lockless CQs and assign them accordingly. Adding a new creation flag for this. Signed-off-by: Matan Barak <matanb@mellanox.com> Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--include/infiniband/verbs.h12
-rw-r--r--man/ibv_create_cq_ex.38
-rw-r--r--src/cmd.c4
3 files changed, 23 insertions, 1 deletions
diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index cc9ad4a..d4b48c0 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -1185,7 +1185,13 @@ struct ibv_context {
};
enum ibv_cq_init_attr_mask {
- IBV_CQ_INIT_ATTR_MASK_RESERVED = 0 << 1
+ IBV_CQ_INIT_ATTR_MASK_FLAGS = 1 << 0,
+ IBV_CQ_INIT_ATTR_MASK_RESERVED = 1 << 1
+};
+
+enum ibv_create_cq_attr_flags {
+ IBV_CREATE_CQ_ATTR_SINGLE_THREADED = 1 << 0,
+ IBV_CREATE_CQ_ATTR_RESERVED = 1 << 1,
};
struct ibv_cq_init_attr_ex {
@@ -1207,6 +1213,10 @@ struct ibv_cq_init_attr_ex {
* enum ibv_cq_init_attr_mask
*/
uint32_t comp_mask;
+ /* create cq attr flags - one or more flags from
+ * enum ibv_create_cq_attr_flags
+ */
+ uint32_t flags;
};
enum verbs_context_mask {
diff --git a/man/ibv_create_cq_ex.3 b/man/ibv_create_cq_ex.3
index b6cc6f6..ecaeb0a 100644
--- a/man/ibv_create_cq_ex.3
+++ b/man/ibv_create_cq_ex.3
@@ -41,6 +41,14 @@ enum ibv_wc_flags_ex {
IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7, /* Require completion timestamp in WC /*
};
+enum ibv_cq_init_attr_mask {
+ IBV_CQ_INIT_ATTR_MASK_FLAGS = 1 << 0,
+};
+
+enum ibv_create_cq_attr_flags {
+ IBV_CREATE_CQ_ATTR_SINGLE_THREADED = 1 << 0, /* This CQ is used from a single threaded, thus no locking is required */
+};
+
.SH "Polling an extended CQ"
In order to poll an extended CQ efficiently, a user could use the following functions.
diff --git a/src/cmd.c b/src/cmd.c
index 647fbbb..5cd3e78 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -486,6 +486,10 @@ int ibv_cmd_create_cq_ex(struct ibv_context *context,
if (cmd_core_size >= offsetof(struct ibv_create_cq_ex, flags) +
sizeof(cmd->flags)) {
+ if ((cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS) &&
+ (cq_attr->flags & ~(IBV_CREATE_CQ_ATTR_RESERVED - 1)))
+ return EOPNOTSUPP;
+
if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)
cmd->flags |= IBV_CREATE_CQ_EX_KERNEL_FLAG_COMPLETION_TIMESTAMP;
}