diff mbox

[rdma-core,02/11] verbs: Use ccan bitmap instead of u64 bit mask for unsupported IOCTLs

Message ID 1526553577-32273-3-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>

Using ccan bitmap to enlarge IOCTL unsupported mask beyond 64 bit.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 libibverbs/cmd_fallback.c | 10 +++-------
 libibverbs/ibverbs.h      |  5 ++++-
 2 files changed, 7 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/libibverbs/cmd_fallback.c b/libibverbs/cmd_fallback.c
index a829088..7caa28d 100644
--- a/libibverbs/cmd_fallback.c
+++ b/libibverbs/cmd_fallback.c
@@ -84,14 +84,10 @@  enum write_fallback _execute_ioctl_fallback(struct ibv_context *ctx,
 					    struct ibv_command_buffer *cmdb,
 					    int *ret)
 {
-	uint64_t cmd_val = 1ULL << cmd_bit;
-
-	BUILD_ASSERT(sizeof(struct verbs_context_ops) / sizeof(void *) < 64);
-
 	struct verbs_ex_private *priv =
 		container_of(ctx, struct verbs_context, context)->priv;
 
-	if (priv->unsupported_ioctls & cmd_val)
+	if (bitmap_test_bit(priv->unsupported_ioctls, cmd_bit))
 		return _check_legacy(cmdb, ret);
 
 	*ret = execute_ioctl(ctx, cmdb);
@@ -101,7 +97,7 @@  enum write_fallback _execute_ioctl_fallback(struct ibv_context *ctx,
 
 	if (*ret == ENOTTY) {
 		/* ENOTTY means the ioctl framework is entirely absent */
-		priv->unsupported_ioctls = UINT64_MAX;
+		bitmap_fill(priv->unsupported_ioctls, VERBS_OPS_NUM);
 		return _check_legacy(cmdb, ret);
 	}
 
@@ -110,7 +106,7 @@  enum write_fallback _execute_ioctl_fallback(struct ibv_context *ctx,
 		 * EPROTONOSUPPORT means we have the ioctl framework but this
 		 * specific method is not supported
 		 */
-		priv->unsupported_ioctls |= cmd_val;
+		bitmap_set_bit(priv->unsupported_ioctls, cmd_bit);
 		return _check_legacy(cmdb, ret);
 	}
 
diff --git a/libibverbs/ibverbs.h b/libibverbs/ibverbs.h
index b493808..4da9282 100644
--- a/libibverbs/ibverbs.h
+++ b/libibverbs/ibverbs.h
@@ -40,9 +40,12 @@ 
 
 #include <valgrind/memcheck.h>
 
+#include <ccan/bitmap.h>
+
 #define INIT		__attribute__((constructor))
 
 #define PFX		"libibverbs: "
+#define VERBS_OPS_NUM (sizeof(struct verbs_context_ops) / sizeof(void *))
 
 struct ibv_abi_compat_v2 {
 	struct ibv_comp_channel	channel;
@@ -61,7 +64,7 @@  struct verbs_ex_private {
 	struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context,
 					  struct ibv_cq_init_attr_ex *init_attr);
 
-	uint64_t unsupported_ioctls;
+	BITMAP_DECLARE(unsupported_ioctls, VERBS_OPS_NUM);
 	uint32_t driver_id;
 };