aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/mlx5/driver.h
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2020-04-05 20:57:00 +0300
committerLeon Romanovsky <leonro@mellanox.com>2020-04-19 15:53:17 +0300
commitbb7fc863729b45f0fbcdea991d0465d855ffd831 (patch)
tree8b18914c25ac6581da2773f0efbdd1d50c182cfb /include/linux/mlx5/driver.h
parentLinux 5.7-rc1 (diff)
downloadwireguard-linux-bb7fc863729b45f0fbcdea991d0465d855ffd831.tar.xz
wireguard-linux-bb7fc863729b45f0fbcdea991d0465d855ffd831.zip
net/mlx5: Provide simplified command interfaces
Many mlx5_cmd_exec() callers are not interested in the output from that command or have standard in/out structures. Those callers simply allocate those structure on the stack and use sizeof() to provide in/out arguments. In this naive approach provide simplified versions of mlx5_cmd_exec(). Reviewed-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Diffstat (limited to 'include/linux/mlx5/driver.h')
-rw-r--r--include/linux/mlx5/driver.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 6f8f79ef829b..1caddfa85c4d 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -903,6 +903,19 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
int mlx5_cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
int out_size);
+
+#define mlx5_cmd_exec_inout(dev, ifc_cmd, in, out) \
+ ({ \
+ mlx5_cmd_exec(dev, in, MLX5_ST_SZ_BYTES(ifc_cmd##_in), out, \
+ MLX5_ST_SZ_BYTES(ifc_cmd##_out)); \
+ })
+
+#define mlx5_cmd_exec_in(dev, ifc_cmd, in) \
+ ({ \
+ u32 _out[MLX5_ST_SZ_DW(ifc_cmd##_out)] = {}; \
+ mlx5_cmd_exec_inout(dev, ifc_cmd, in, _out); \
+ })
+
int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
void *out, int out_size);
void mlx5_cmd_mbox_status(void *out, u8 *status, u32 *syndrome);