History

net/mlx5: Add query host params command

The QUERY_HOST_PARAMS command is used by an Embedded CPU Physical Function (ECPF) driver to identify and retrieve information about the PF on the host side. E.g, number of virtual functions and PCI BDF. The number of VFs can be changed on the fly, a function is added to query current number of VFs and will be used in downstream patches.

Bodong Wang committed 7 years ago

Commit c3a4e9f1 parent 22e939a4 files · +74 −0Browse files

Unified · Split

4 files
  1. drivers/net/ethernet/mellanox/mlx5/core/cmd.c +2 −0
  2. drivers/net/ethernet/mellanox/mlx5/core/ecpf.c +27 −0
  3. drivers/net/ethernet/mellanox/mlx5/core/ecpf.h +4 −0
  4. include/linux/mlx5/mlx5_ifc.h +41 −0
drivers/net/ethernet/mellanox/mlx5/core/cmd.c+2−0
@@ -316,6 +316,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op, · 315 unmodified lines
316316 case MLX5_CMD_OP_DESTROY_GENERAL_OBJECT:
317317 case MLX5_CMD_OP_DEALLOC_MEMIC:
318318 case MLX5_CMD_OP_PAGE_FAULT_RESUME:
319+ case MLX5_CMD_OP_QUERY_HOST_PARAMS:
319320 return MLX5_CMD_STAT_OK;
320321
321322 case MLX5_CMD_OP_QUERY_HCA_CAP:
@@ -627,6 +628,7 @@ const char *mlx5_command_str(int command) · 305 unmodified lines
627628 MLX5_COMMAND_STR_CASE(QUERY_MODIFY_HEADER_CONTEXT);
628629 MLX5_COMMAND_STR_CASE(ALLOC_MEMIC);
629630 MLX5_COMMAND_STR_CASE(DEALLOC_MEMIC);
631+ MLX5_COMMAND_STR_CASE(QUERY_HOST_PARAMS);
630632 default: return "unknown command opcode";
631633 }
632634 }
drivers/net/ethernet/mellanox/mlx5/core/ecpf.c+27−0
@@ -83,3 +83,30 @@ void mlx5_ec_cleanup(struct mlx5_core_dev *dev) · 82 unmodified lines
8383
8484 mlx5_peer_pf_cleanup(dev);
8585 }
86+
87+static int mlx5_query_host_params_context(struct mlx5_core_dev *dev,
88+ u32 *out, int outlen)
89+{
90+ u32 in[MLX5_ST_SZ_DW(query_host_params_in)] = {};
91+
92+ MLX5_SET(query_host_params_in, in, opcode,
93+ MLX5_CMD_OP_QUERY_HOST_PARAMS);
94+
95+ return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
96+}
97+
98+int mlx5_query_host_params_num_vfs(struct mlx5_core_dev *dev, int *num_vf)
99+{
100+ u32 out[MLX5_ST_SZ_DW(query_host_params_out)] = {};
101+ int err;
102+
103+ err = mlx5_query_host_params_context(dev, out, sizeof(out));
104+ if (err)
105+ return err;
106+
107+ *num_vf = MLX5_GET(query_host_params_out, out,
108+ host_params_context.host_num_of_vfs);
109+ mlx5_core_dbg(dev, "host_num_of_vfs %d\n", *num_vf);
110+
111+ return 0;
112+}
drivers/net/ethernet/mellanox/mlx5/core/ecpf.h+4−0
@@ -16,6 +16,7 @@ enum { · 15 unmodified lines
1616 bool mlx5_read_embedded_cpu(struct mlx5_core_dev *dev);
1717 int mlx5_ec_init(struct mlx5_core_dev *dev);
1818 void mlx5_ec_cleanup(struct mlx5_core_dev *dev);
19+int mlx5_query_host_params_num_vfs(struct mlx5_core_dev *dev, int *num_vf);
1920
2021 #else /* CONFIG_MLX5_ESWITCH */
2122
@@ -23,6 +24,9 @@ static inline bool · 1 unmodified line
2324 mlx5_read_embedded_cpu(struct mlx5_core_dev *dev) { return false; }
2425 static inline int mlx5_ec_init(struct mlx5_core_dev *dev) { return 0; }
2526 static inline void mlx5_ec_cleanup(struct mlx5_core_dev *dev) {}
27+static inline int
28+mlx5_query_host_params_num_vfs(struct mlx5_core_dev *dev, int *num_vf)
29+{ return -EOPNOTSUPP; }
2630
2731 #endif /* CONFIG_MLX5_ESWITCH */
2832
include/linux/mlx5/mlx5_ifc.h+41−0
@@ -142,6 +142,7 @@ enum { · 141 unmodified lines
142142 MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY = 0x725,
143143 MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY = 0x726,
144144 MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS = 0x727,
145+ MLX5_CMD_OP_QUERY_HOST_PARAMS = 0x740,
145146 MLX5_CMD_OP_QUERY_VPORT_STATE = 0x750,
146147 MLX5_CMD_OP_MODIFY_VPORT_STATE = 0x751,
147148 MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT = 0x752,
@@ -9522,4 +9523,44 @@ struct mlx5_ifc_mtrc_ctrl_bits { · 9374 unmodified lines
95229523 u8 reserved_at_80[0x180];
95239524 };
95249525
9526+struct mlx5_ifc_host_params_context_bits {
9527+ u8 host_number[0x8];
9528+ u8 reserved_at_8[0x8];
9529+ u8 host_num_of_vfs[0x10];
9530+
9531+ u8 reserved_at_20[0x10];
9532+ u8 host_pci_bus[0x10];
9533+
9534+ u8 reserved_at_40[0x10];
9535+ u8 host_pci_device[0x10];
9536+
9537+ u8 reserved_at_60[0x10];
9538+ u8 host_pci_function[0x10];
9539+
9540+ u8 reserved_at_80[0x180];
9541+};
9542+
9543+struct mlx5_ifc_query_host_params_in_bits {
9544+ u8 opcode[0x10];
9545+ u8 reserved_at_10[0x10];
9546+
9547+ u8 reserved_at_20[0x10];
9548+ u8 op_mod[0x10];
9549+
9550+ u8 reserved_at_40[0x40];
9551+};
9552+
9553+struct mlx5_ifc_query_host_params_out_bits {
9554+ u8 status[0x8];
9555+ u8 reserved_at_8[0x18];
9556+
9557+ u8 syndrome[0x20];
9558+
9559+ u8 reserved_at_40[0x40];
9560+
9561+ struct mlx5_ifc_host_params_context_bits host_params_context;
9562+
9563+ u8 reserved_at_280[0x180];
9564+};
9565+
95259566 #endif /* MLX5_IFC_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t