[PATCH 8/9] RDMA/uverbs: Use UVERBS_ATTR_MIN_SIZE correctly and uniformly

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

 



From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>

This newer macro allows specifying a lower bound on the accepted size, and
has an 'unlimited' upper bound. Due to this it never checks for trailing
zeroing so it doesn't make any sense to combine it with MIN_SZ_OR_ZERO, so
drop MIN_SZ_OR_ZERO when they are used together

There were a couple of places that open coded this pattern, switch them to
use the clearer UVERBS_ATTR_MIN_SIZE for clarity.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
 .../infiniband/core/uverbs_std_types_counters.c |  3 +--
 drivers/infiniband/hw/mlx5/devx.c               | 16 ++++------------
 include/rdma/uverbs_ioctl.h                     | 17 +++++++++--------
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/infiniband/core/uverbs_std_types_counters.c b/drivers/infiniband/core/uverbs_std_types_counters.c
index a2ea5d0f586fec..89e691a48102a4 100644
--- a/drivers/infiniband/core/uverbs_std_types_counters.c
+++ b/drivers/infiniband/core/uverbs_std_types_counters.c
@@ -137,7 +137,6 @@ DECLARE_UVERBS_NAMED_METHOD_DESTROY(
 			UVERBS_ACCESS_DESTROY,
 			UA_MANDATORY));
 
-#define MAX_COUNTERS_BUFF_SIZE USHRT_MAX
 DECLARE_UVERBS_NAMED_METHOD(
 	UVERBS_METHOD_COUNTERS_READ,
 	UVERBS_ATTR_IDR(UVERBS_ATTR_READ_COUNTERS_HANDLE,
@@ -145,7 +144,7 @@ DECLARE_UVERBS_NAMED_METHOD(
 			UVERBS_ACCESS_READ,
 			UA_MANDATORY),
 	UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_READ_COUNTERS_BUFF,
-			    UVERBS_ATTR_SIZE(0, MAX_COUNTERS_BUFF_SIZE),
+			    UVERBS_ATTR_MIN_SIZE(0),
 			    UA_MANDATORY),
 	UVERBS_ATTR_PTR_IN(UVERBS_ATTR_READ_COUNTERS_FLAGS,
 			   UVERBS_ATTR_TYPE(__u32),
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index 3d0859783f6b92..62df8c85a9d1f9 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -1034,13 +1034,11 @@ DECLARE_UVERBS_NAMED_METHOD(
 		MLX5_IB_ATTR_DEVX_OTHER_CMD_IN,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_in_cmd_hdr)),
 		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO,
 		UA_ALLOC_AND_COPY),
 	UVERBS_ATTR_PTR_OUT(
 		MLX5_IB_ATTR_DEVX_OTHER_CMD_OUT,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_out_cmd_hdr)),
-		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO));
+		UA_MANDATORY));
 
 DECLARE_UVERBS_NAMED_METHOD(
 	MLX5_IB_METHOD_DEVX_OBJ_CREATE,
@@ -1052,13 +1050,11 @@ DECLARE_UVERBS_NAMED_METHOD(
 		MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_IN,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_in_cmd_hdr)),
 		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO,
 		UA_ALLOC_AND_COPY),
 	UVERBS_ATTR_PTR_OUT(
 		MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_out_cmd_hdr)),
-		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO));
+		UA_MANDATORY));
 
 DECLARE_UVERBS_NAMED_METHOD(
 	MLX5_IB_METHOD_DEVX_OBJ_DESTROY,
@@ -1077,13 +1073,11 @@ DECLARE_UVERBS_NAMED_METHOD(
 		MLX5_IB_ATTR_DEVX_OBJ_MODIFY_CMD_IN,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_in_cmd_hdr)),
 		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO,
 		UA_ALLOC_AND_COPY),
 	UVERBS_ATTR_PTR_OUT(
 		MLX5_IB_ATTR_DEVX_OBJ_MODIFY_CMD_OUT,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_out_cmd_hdr)),
-		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO));
+		UA_MANDATORY));
 
 DECLARE_UVERBS_NAMED_METHOD(
 	MLX5_IB_METHOD_DEVX_OBJ_QUERY,
@@ -1095,13 +1089,11 @@ DECLARE_UVERBS_NAMED_METHOD(
 		MLX5_IB_ATTR_DEVX_OBJ_QUERY_CMD_IN,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_in_cmd_hdr)),
 		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO,
 		UA_ALLOC_AND_COPY),
 	UVERBS_ATTR_PTR_OUT(
 		MLX5_IB_ATTR_DEVX_OBJ_QUERY_CMD_OUT,
 		UVERBS_ATTR_MIN_SIZE(MLX5_ST_SZ_BYTES(general_obj_out_cmd_hdr)),
-		UA_MANDATORY,
-		UA_MIN_SZ_OR_ZERO));
+		UA_MANDATORY));
 
 DECLARE_UVERBS_GLOBAL_METHODS(MLX5_IB_OBJECT_DEVX,
 			      &UVERBS_METHOD(MLX5_IB_METHOD_DEVX_OTHER),
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h
index bead387fed7f32..8d4007a1361b9c 100644
--- a/include/rdma/uverbs_ioctl.h
+++ b/include/rdma/uverbs_ioctl.h
@@ -207,8 +207,11 @@ struct uverbs_object_tree_def {
 	.u.ptr.min_len = ((uintptr_t)(&((_type *)0)->_last + 1)), .u.ptr.len = sizeof(_type)
 #define UVERBS_ATTR_SIZE(_min_len, _len)			\
 	.u.ptr.min_len = _min_len, .u.ptr.len = _len
-#define UVERBS_ATTR_MIN_SIZE(_min_len)				\
-	UVERBS_ATTR_SIZE(_min_len, USHRT_MAX)
+/*
+ * Specifies at least min_len bytes must be passed in, but the amount can be
+ * larger, up to the protocol maximum size. No check for zeroing is done.
+ */
+#define UVERBS_ATTR_MIN_SIZE(_min_len) UVERBS_ATTR_SIZE(_min_len, USHRT_MAX)
 
 /* Use in the '...' of any UVERBS_ATTR */
 #define UA_ALLOC_AND_COPY .alloc_and_copy = 1
@@ -267,13 +270,11 @@ struct uverbs_object_tree_def {
  */
 #define UVERBS_ATTR_UHW()                                                      \
 	UVERBS_ATTR_PTR_IN(UVERBS_ATTR_UHW_IN,                                 \
-			   UVERBS_ATTR_SIZE(0, USHRT_MAX),		       \
-			   UA_OPTIONAL,					       \
-			   UA_MIN_SZ_OR_ZERO),				       \
+			   UVERBS_ATTR_MIN_SIZE(0),			       \
+			   UA_OPTIONAL),				       \
 	UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_UHW_OUT,                               \
-			    UVERBS_ATTR_SIZE(0, USHRT_MAX),		       \
-			    UA_OPTIONAL,				       \
-			    UA_MIN_SZ_OR_ZERO),				       \
+			    UVERBS_ATTR_MIN_SIZE(0),			       \
+			    UA_OPTIONAL)
 
 /*
  * =======================================
-- 
2.17.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