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.
Unified · Split
| @@ -316,6 +316,7 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op, · 315 unmodified lines | |||
| 316 | case MLX5_CMD_OP_DESTROY_GENERAL_OBJECT: | 316 | case MLX5_CMD_OP_DESTROY_GENERAL_OBJECT: |
| 317 | case MLX5_CMD_OP_DEALLOC_MEMIC: | 317 | case MLX5_CMD_OP_DEALLOC_MEMIC: |
| 318 | case MLX5_CMD_OP_PAGE_FAULT_RESUME: | 318 | case MLX5_CMD_OP_PAGE_FAULT_RESUME: |
| 319 | case MLX5_CMD_OP_QUERY_HOST_PARAMS: | ||
| 319 | return MLX5_CMD_STAT_OK; | 320 | return MLX5_CMD_STAT_OK; |
| 320 | 321 | ||
| 321 | case MLX5_CMD_OP_QUERY_HCA_CAP: | 322 | case MLX5_CMD_OP_QUERY_HCA_CAP: |
| @@ -627,6 +628,7 @@ const char *mlx5_command_str(int command) · 305 unmodified lines | |||
| 627 | MLX5_COMMAND_STR_CASE(QUERY_MODIFY_HEADER_CONTEXT); | 628 | MLX5_COMMAND_STR_CASE(QUERY_MODIFY_HEADER_CONTEXT); |
| 628 | MLX5_COMMAND_STR_CASE(ALLOC_MEMIC); | 629 | MLX5_COMMAND_STR_CASE(ALLOC_MEMIC); |
| 629 | MLX5_COMMAND_STR_CASE(DEALLOC_MEMIC); | 630 | MLX5_COMMAND_STR_CASE(DEALLOC_MEMIC); |
| 631 | MLX5_COMMAND_STR_CASE(QUERY_HOST_PARAMS); | ||
| 630 | default: return "unknown command opcode"; | 632 | default: return "unknown command opcode"; |
| 631 | } | 633 | } |
| 632 | } | 634 | } |
| @@ -83,3 +83,30 @@ void mlx5_ec_cleanup(struct mlx5_core_dev *dev) · 82 unmodified lines | |||
| 83 | 83 | ||
| 84 | mlx5_peer_pf_cleanup(dev); | 84 | mlx5_peer_pf_cleanup(dev); |
| 85 | } | 85 | } |
| 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 | } | ||
| @@ -16,6 +16,7 @@ enum { · 15 unmodified lines | |||
| 16 | bool mlx5_read_embedded_cpu(struct mlx5_core_dev *dev); | 16 | bool mlx5_read_embedded_cpu(struct mlx5_core_dev *dev); |
| 17 | int mlx5_ec_init(struct mlx5_core_dev *dev); | 17 | int mlx5_ec_init(struct mlx5_core_dev *dev); |
| 18 | void mlx5_ec_cleanup(struct mlx5_core_dev *dev); | 18 | 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); | ||
| 19 | 20 | ||
| 20 | #else /* CONFIG_MLX5_ESWITCH */ | 21 | #else /* CONFIG_MLX5_ESWITCH */ |
| 21 | 22 | ||
| @@ -23,6 +24,9 @@ static inline bool · 1 unmodified line | |||
| 23 | mlx5_read_embedded_cpu(struct mlx5_core_dev *dev) { return false; } | 24 | mlx5_read_embedded_cpu(struct mlx5_core_dev *dev) { return false; } |
| 24 | static inline int mlx5_ec_init(struct mlx5_core_dev *dev) { return 0; } | 25 | static inline int mlx5_ec_init(struct mlx5_core_dev *dev) { return 0; } |
| 25 | static inline void mlx5_ec_cleanup(struct mlx5_core_dev *dev) {} | 26 | 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; } | ||
| 26 | 30 | ||
| 27 | #endif /* CONFIG_MLX5_ESWITCH */ | 31 | #endif /* CONFIG_MLX5_ESWITCH */ |
| 28 | 32 | ||
| @@ -142,6 +142,7 @@ enum { · 141 unmodified lines | |||
| 142 | MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY = 0x725, | 142 | MLX5_CMD_OP_QUERY_XRQ_DC_PARAMS_ENTRY = 0x725, |
| 143 | MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY = 0x726, | 143 | MLX5_CMD_OP_SET_XRQ_DC_PARAMS_ENTRY = 0x726, |
| 144 | MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS = 0x727, | 144 | MLX5_CMD_OP_QUERY_XRQ_ERROR_PARAMS = 0x727, |
| 145 | MLX5_CMD_OP_QUERY_HOST_PARAMS = 0x740, | ||
| 145 | MLX5_CMD_OP_QUERY_VPORT_STATE = 0x750, | 146 | MLX5_CMD_OP_QUERY_VPORT_STATE = 0x750, |
| 146 | MLX5_CMD_OP_MODIFY_VPORT_STATE = 0x751, | 147 | MLX5_CMD_OP_MODIFY_VPORT_STATE = 0x751, |
| 147 | MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT = 0x752, | 148 | MLX5_CMD_OP_QUERY_ESW_VPORT_CONTEXT = 0x752, |
| @@ -9522,4 +9523,44 @@ struct mlx5_ifc_mtrc_ctrl_bits { · 9374 unmodified lines | |||
| 9522 | u8 reserved_at_80[0x180]; | 9523 | u8 reserved_at_80[0x180]; |
| 9523 | }; | 9524 | }; |
| 9524 | 9525 | ||
| 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 | |||
| 9525 | #endif /* MLX5_IFC_H */ | 9566 | #endif /* MLX5_IFC_H */ |