net/mlx5_core: Use a macro in mlx5_command_str()

Use a macro instead of copying the OP name.

Signed-off-by: Amir Vadai <amirva@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Amir Vadai 2016-05-13 12:55:38 +00:00 committed by David S. Miller
parent 10cbc68434
commit 42ca502e17

View File

@ -406,178 +406,139 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
const char *mlx5_command_str(int command) const char *mlx5_command_str(int command)
{ {
#define MLX5_COMMAND_STR_CASE(__cmd) case MLX5_CMD_OP_ ## __cmd: return #__cmd
switch (command) { switch (command) {
case MLX5_CMD_OP_QUERY_HCA_VPORT_CONTEXT: MLX5_COMMAND_STR_CASE(QUERY_HCA_CAP);
return "QUERY_HCA_VPORT_CONTEXT"; MLX5_COMMAND_STR_CASE(QUERY_ADAPTER);
MLX5_COMMAND_STR_CASE(INIT_HCA);
case MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT: MLX5_COMMAND_STR_CASE(TEARDOWN_HCA);
return "MODIFY_HCA_VPORT_CONTEXT"; MLX5_COMMAND_STR_CASE(ENABLE_HCA);
MLX5_COMMAND_STR_CASE(DISABLE_HCA);
case MLX5_CMD_OP_QUERY_HCA_CAP: MLX5_COMMAND_STR_CASE(QUERY_PAGES);
return "QUERY_HCA_CAP"; MLX5_COMMAND_STR_CASE(MANAGE_PAGES);
MLX5_COMMAND_STR_CASE(SET_HCA_CAP);
case MLX5_CMD_OP_SET_HCA_CAP: MLX5_COMMAND_STR_CASE(QUERY_ISSI);
return "SET_HCA_CAP"; MLX5_COMMAND_STR_CASE(SET_ISSI);
MLX5_COMMAND_STR_CASE(CREATE_MKEY);
case MLX5_CMD_OP_QUERY_ADAPTER: MLX5_COMMAND_STR_CASE(QUERY_MKEY);
return "QUERY_ADAPTER"; MLX5_COMMAND_STR_CASE(DESTROY_MKEY);
MLX5_COMMAND_STR_CASE(QUERY_SPECIAL_CONTEXTS);
case MLX5_CMD_OP_INIT_HCA: MLX5_COMMAND_STR_CASE(PAGE_FAULT_RESUME);
return "INIT_HCA"; MLX5_COMMAND_STR_CASE(CREATE_EQ);
MLX5_COMMAND_STR_CASE(DESTROY_EQ);
case MLX5_CMD_OP_TEARDOWN_HCA: MLX5_COMMAND_STR_CASE(QUERY_EQ);
return "TEARDOWN_HCA"; MLX5_COMMAND_STR_CASE(GEN_EQE);
MLX5_COMMAND_STR_CASE(CREATE_CQ);
case MLX5_CMD_OP_ENABLE_HCA: MLX5_COMMAND_STR_CASE(DESTROY_CQ);
return "MLX5_CMD_OP_ENABLE_HCA"; MLX5_COMMAND_STR_CASE(QUERY_CQ);
MLX5_COMMAND_STR_CASE(MODIFY_CQ);
case MLX5_CMD_OP_DISABLE_HCA: MLX5_COMMAND_STR_CASE(CREATE_QP);
return "MLX5_CMD_OP_DISABLE_HCA"; MLX5_COMMAND_STR_CASE(DESTROY_QP);
MLX5_COMMAND_STR_CASE(RST2INIT_QP);
case MLX5_CMD_OP_QUERY_PAGES: MLX5_COMMAND_STR_CASE(INIT2RTR_QP);
return "QUERY_PAGES"; MLX5_COMMAND_STR_CASE(RTR2RTS_QP);
MLX5_COMMAND_STR_CASE(RTS2RTS_QP);
case MLX5_CMD_OP_MANAGE_PAGES: MLX5_COMMAND_STR_CASE(SQERR2RTS_QP);
return "MANAGE_PAGES"; MLX5_COMMAND_STR_CASE(2ERR_QP);
MLX5_COMMAND_STR_CASE(2RST_QP);
case MLX5_CMD_OP_CREATE_MKEY: MLX5_COMMAND_STR_CASE(QUERY_QP);
return "CREATE_MKEY"; MLX5_COMMAND_STR_CASE(SQD_RTS_QP);
MLX5_COMMAND_STR_CASE(INIT2INIT_QP);
case MLX5_CMD_OP_QUERY_MKEY: MLX5_COMMAND_STR_CASE(CREATE_PSV);
return "QUERY_MKEY"; MLX5_COMMAND_STR_CASE(DESTROY_PSV);
MLX5_COMMAND_STR_CASE(CREATE_SRQ);
case MLX5_CMD_OP_DESTROY_MKEY: MLX5_COMMAND_STR_CASE(DESTROY_SRQ);
return "DESTROY_MKEY"; MLX5_COMMAND_STR_CASE(QUERY_SRQ);
MLX5_COMMAND_STR_CASE(ARM_RQ);
case MLX5_CMD_OP_QUERY_SPECIAL_CONTEXTS: MLX5_COMMAND_STR_CASE(CREATE_XRC_SRQ);
return "QUERY_SPECIAL_CONTEXTS"; MLX5_COMMAND_STR_CASE(DESTROY_XRC_SRQ);
MLX5_COMMAND_STR_CASE(QUERY_XRC_SRQ);
case MLX5_CMD_OP_CREATE_EQ: MLX5_COMMAND_STR_CASE(ARM_XRC_SRQ);
return "CREATE_EQ"; MLX5_COMMAND_STR_CASE(CREATE_DCT);
MLX5_COMMAND_STR_CASE(DESTROY_DCT);
case MLX5_CMD_OP_DESTROY_EQ: MLX5_COMMAND_STR_CASE(DRAIN_DCT);
return "DESTROY_EQ"; MLX5_COMMAND_STR_CASE(QUERY_DCT);
MLX5_COMMAND_STR_CASE(ARM_DCT_FOR_KEY_VIOLATION);
case MLX5_CMD_OP_QUERY_EQ: MLX5_COMMAND_STR_CASE(QUERY_VPORT_STATE);
return "QUERY_EQ"; MLX5_COMMAND_STR_CASE(MODIFY_VPORT_STATE);
MLX5_COMMAND_STR_CASE(QUERY_ESW_VPORT_CONTEXT);
case MLX5_CMD_OP_CREATE_CQ: MLX5_COMMAND_STR_CASE(MODIFY_ESW_VPORT_CONTEXT);
return "CREATE_CQ"; MLX5_COMMAND_STR_CASE(QUERY_NIC_VPORT_CONTEXT);
MLX5_COMMAND_STR_CASE(MODIFY_NIC_VPORT_CONTEXT);
case MLX5_CMD_OP_DESTROY_CQ: MLX5_COMMAND_STR_CASE(QUERY_ROCE_ADDRESS);
return "DESTROY_CQ"; MLX5_COMMAND_STR_CASE(SET_ROCE_ADDRESS);
MLX5_COMMAND_STR_CASE(QUERY_HCA_VPORT_CONTEXT);
case MLX5_CMD_OP_QUERY_CQ: MLX5_COMMAND_STR_CASE(MODIFY_HCA_VPORT_CONTEXT);
return "QUERY_CQ"; MLX5_COMMAND_STR_CASE(QUERY_HCA_VPORT_GID);
MLX5_COMMAND_STR_CASE(QUERY_HCA_VPORT_PKEY);
case MLX5_CMD_OP_MODIFY_CQ: MLX5_COMMAND_STR_CASE(QUERY_VPORT_COUNTER);
return "MODIFY_CQ"; MLX5_COMMAND_STR_CASE(ALLOC_Q_COUNTER);
MLX5_COMMAND_STR_CASE(DEALLOC_Q_COUNTER);
case MLX5_CMD_OP_CREATE_QP: MLX5_COMMAND_STR_CASE(QUERY_Q_COUNTER);
return "CREATE_QP"; MLX5_COMMAND_STR_CASE(ALLOC_PD);
MLX5_COMMAND_STR_CASE(DEALLOC_PD);
case MLX5_CMD_OP_DESTROY_QP: MLX5_COMMAND_STR_CASE(ALLOC_UAR);
return "DESTROY_QP"; MLX5_COMMAND_STR_CASE(DEALLOC_UAR);
MLX5_COMMAND_STR_CASE(CONFIG_INT_MODERATION);
case MLX5_CMD_OP_RST2INIT_QP: MLX5_COMMAND_STR_CASE(ACCESS_REG);
return "RST2INIT_QP"; MLX5_COMMAND_STR_CASE(ATTACH_TO_MCG);
MLX5_COMMAND_STR_CASE(DETTACH_FROM_MCG);
case MLX5_CMD_OP_INIT2RTR_QP: MLX5_COMMAND_STR_CASE(GET_DROPPED_PACKET_LOG);
return "INIT2RTR_QP"; MLX5_COMMAND_STR_CASE(MAD_IFC);
MLX5_COMMAND_STR_CASE(QUERY_MAD_DEMUX);
case MLX5_CMD_OP_RTR2RTS_QP: MLX5_COMMAND_STR_CASE(SET_MAD_DEMUX);
return "RTR2RTS_QP"; MLX5_COMMAND_STR_CASE(NOP);
MLX5_COMMAND_STR_CASE(ALLOC_XRCD);
case MLX5_CMD_OP_RTS2RTS_QP: MLX5_COMMAND_STR_CASE(DEALLOC_XRCD);
return "RTS2RTS_QP"; MLX5_COMMAND_STR_CASE(ALLOC_TRANSPORT_DOMAIN);
MLX5_COMMAND_STR_CASE(DEALLOC_TRANSPORT_DOMAIN);
case MLX5_CMD_OP_SQERR2RTS_QP: MLX5_COMMAND_STR_CASE(QUERY_CONG_STATUS);
return "SQERR2RTS_QP"; MLX5_COMMAND_STR_CASE(MODIFY_CONG_STATUS);
MLX5_COMMAND_STR_CASE(QUERY_CONG_PARAMS);
case MLX5_CMD_OP_2ERR_QP: MLX5_COMMAND_STR_CASE(MODIFY_CONG_PARAMS);
return "2ERR_QP"; MLX5_COMMAND_STR_CASE(QUERY_CONG_STATISTICS);
MLX5_COMMAND_STR_CASE(ADD_VXLAN_UDP_DPORT);
case MLX5_CMD_OP_2RST_QP: MLX5_COMMAND_STR_CASE(DELETE_VXLAN_UDP_DPORT);
return "2RST_QP"; MLX5_COMMAND_STR_CASE(SET_L2_TABLE_ENTRY);
MLX5_COMMAND_STR_CASE(QUERY_L2_TABLE_ENTRY);
case MLX5_CMD_OP_QUERY_QP: MLX5_COMMAND_STR_CASE(DELETE_L2_TABLE_ENTRY);
return "QUERY_QP"; MLX5_COMMAND_STR_CASE(SET_WOL_ROL);
MLX5_COMMAND_STR_CASE(QUERY_WOL_ROL);
case MLX5_CMD_OP_MAD_IFC: MLX5_COMMAND_STR_CASE(CREATE_TIR);
return "MAD_IFC"; MLX5_COMMAND_STR_CASE(MODIFY_TIR);
MLX5_COMMAND_STR_CASE(DESTROY_TIR);
case MLX5_CMD_OP_INIT2INIT_QP: MLX5_COMMAND_STR_CASE(QUERY_TIR);
return "INIT2INIT_QP"; MLX5_COMMAND_STR_CASE(CREATE_SQ);
MLX5_COMMAND_STR_CASE(MODIFY_SQ);
case MLX5_CMD_OP_CREATE_PSV: MLX5_COMMAND_STR_CASE(DESTROY_SQ);
return "CREATE_PSV"; MLX5_COMMAND_STR_CASE(QUERY_SQ);
MLX5_COMMAND_STR_CASE(CREATE_RQ);
case MLX5_CMD_OP_DESTROY_PSV: MLX5_COMMAND_STR_CASE(MODIFY_RQ);
return "DESTROY_PSV"; MLX5_COMMAND_STR_CASE(DESTROY_RQ);
MLX5_COMMAND_STR_CASE(QUERY_RQ);
case MLX5_CMD_OP_CREATE_SRQ: MLX5_COMMAND_STR_CASE(CREATE_RMP);
return "CREATE_SRQ"; MLX5_COMMAND_STR_CASE(MODIFY_RMP);
MLX5_COMMAND_STR_CASE(DESTROY_RMP);
case MLX5_CMD_OP_DESTROY_SRQ: MLX5_COMMAND_STR_CASE(QUERY_RMP);
return "DESTROY_SRQ"; MLX5_COMMAND_STR_CASE(CREATE_TIS);
MLX5_COMMAND_STR_CASE(MODIFY_TIS);
case MLX5_CMD_OP_QUERY_SRQ: MLX5_COMMAND_STR_CASE(DESTROY_TIS);
return "QUERY_SRQ"; MLX5_COMMAND_STR_CASE(QUERY_TIS);
MLX5_COMMAND_STR_CASE(CREATE_RQT);
case MLX5_CMD_OP_ARM_RQ: MLX5_COMMAND_STR_CASE(MODIFY_RQT);
return "ARM_RQ"; MLX5_COMMAND_STR_CASE(DESTROY_RQT);
MLX5_COMMAND_STR_CASE(QUERY_RQT);
case MLX5_CMD_OP_CREATE_XRC_SRQ: MLX5_COMMAND_STR_CASE(SET_FLOW_TABLE_ROOT);
return "CREATE_XRC_SRQ"; MLX5_COMMAND_STR_CASE(CREATE_FLOW_TABLE);
MLX5_COMMAND_STR_CASE(DESTROY_FLOW_TABLE);
case MLX5_CMD_OP_DESTROY_XRC_SRQ: MLX5_COMMAND_STR_CASE(QUERY_FLOW_TABLE);
return "DESTROY_XRC_SRQ"; MLX5_COMMAND_STR_CASE(CREATE_FLOW_GROUP);
MLX5_COMMAND_STR_CASE(DESTROY_FLOW_GROUP);
case MLX5_CMD_OP_QUERY_XRC_SRQ: MLX5_COMMAND_STR_CASE(QUERY_FLOW_GROUP);
return "QUERY_XRC_SRQ"; MLX5_COMMAND_STR_CASE(SET_FLOW_TABLE_ENTRY);
MLX5_COMMAND_STR_CASE(QUERY_FLOW_TABLE_ENTRY);
case MLX5_CMD_OP_ARM_XRC_SRQ: MLX5_COMMAND_STR_CASE(DELETE_FLOW_TABLE_ENTRY);
return "ARM_XRC_SRQ";
case MLX5_CMD_OP_ALLOC_PD:
return "ALLOC_PD";
case MLX5_CMD_OP_DEALLOC_PD:
return "DEALLOC_PD";
case MLX5_CMD_OP_ALLOC_UAR:
return "ALLOC_UAR";
case MLX5_CMD_OP_DEALLOC_UAR:
return "DEALLOC_UAR";
case MLX5_CMD_OP_ATTACH_TO_MCG:
return "ATTACH_TO_MCG";
case MLX5_CMD_OP_DETTACH_FROM_MCG:
return "DETTACH_FROM_MCG";
case MLX5_CMD_OP_ALLOC_XRCD:
return "ALLOC_XRCD";
case MLX5_CMD_OP_DEALLOC_XRCD:
return "DEALLOC_XRCD";
case MLX5_CMD_OP_ACCESS_REG:
return "MLX5_CMD_OP_ACCESS_REG";
case MLX5_CMD_OP_SET_WOL_ROL:
return "SET_WOL_ROL";
case MLX5_CMD_OP_QUERY_WOL_ROL:
return "QUERY_WOL_ROL";
case MLX5_CMD_OP_ADD_VXLAN_UDP_DPORT:
return "ADD_VXLAN_UDP_DPORT";
case MLX5_CMD_OP_DELETE_VXLAN_UDP_DPORT:
return "DELETE_VXLAN_UDP_DPORT";
default: return "unknown command opcode"; default: return "unknown command opcode";
} }
} }