1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2 /* Copyright (c) 2020 Mellanox Technologies Ltd */
3
4 #include <linux/mlx5/driver.h>
5 #include "priv.h"
6
mlx5_cmd_alloc_sf(struct mlx5_core_dev * dev,u16 function_id)7 int mlx5_cmd_alloc_sf(struct mlx5_core_dev *dev, u16 function_id)
8 {
9 u32 out[MLX5_ST_SZ_DW(alloc_sf_out)] = {};
10 u32 in[MLX5_ST_SZ_DW(alloc_sf_in)] = {};
11
12 MLX5_SET(alloc_sf_in, in, opcode, MLX5_CMD_OP_ALLOC_SF);
13 MLX5_SET(alloc_sf_in, in, function_id, function_id);
14
15 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
16 }
17
mlx5_cmd_dealloc_sf(struct mlx5_core_dev * dev,u16 function_id)18 int mlx5_cmd_dealloc_sf(struct mlx5_core_dev *dev, u16 function_id)
19 {
20 u32 out[MLX5_ST_SZ_DW(dealloc_sf_out)] = {};
21 u32 in[MLX5_ST_SZ_DW(dealloc_sf_in)] = {};
22
23 MLX5_SET(dealloc_sf_in, in, opcode, MLX5_CMD_OP_DEALLOC_SF);
24 MLX5_SET(dealloc_sf_in, in, function_id, function_id);
25
26 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
27 }
28
mlx5_cmd_sf_enable_hca(struct mlx5_core_dev * dev,u16 func_id)29 int mlx5_cmd_sf_enable_hca(struct mlx5_core_dev *dev, u16 func_id)
30 {
31 u32 out[MLX5_ST_SZ_DW(enable_hca_out)] = {};
32 u32 in[MLX5_ST_SZ_DW(enable_hca_in)] = {};
33
34 MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
35 MLX5_SET(enable_hca_in, in, function_id, func_id);
36 MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0);
37 return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
38 }
39
mlx5_cmd_sf_disable_hca(struct mlx5_core_dev * dev,u16 func_id)40 int mlx5_cmd_sf_disable_hca(struct mlx5_core_dev *dev, u16 func_id)
41 {
42 u32 out[MLX5_ST_SZ_DW(disable_hca_out)] = {};
43 u32 in[MLX5_ST_SZ_DW(disable_hca_in)] = {};
44
45 MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
46 MLX5_SET(disable_hca_in, in, function_id, func_id);
47 MLX5_SET(enable_hca_in, in, embedded_cpu_function, 0);
48 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
49 }
50