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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Raed Salem <raeds@xxxxxxxxxxxx>

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

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

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;
 };
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux