1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2 /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 3 4 #ifndef _MLXSW_EMAD_H 5 #define _MLXSW_EMAD_H 6 7 #define MLXSW_EMAD_MAX_FRAME_LEN 1518 /* Length in u8 */ 8 #define MLXSW_EMAD_MAX_RETRY 5 9 10 /* EMAD Ethernet header */ 11 #define MLXSW_EMAD_ETH_HDR_LEN 0x10 /* Length in u8 */ 12 #define MLXSW_EMAD_EH_DMAC "\x01\x02\xc9\x00\x00\x01" 13 #define MLXSW_EMAD_EH_SMAC "\x00\x02\xc9\x01\x02\x03" 14 #define MLXSW_EMAD_EH_ETHERTYPE 0x8932 15 #define MLXSW_EMAD_EH_MLX_PROTO 0 16 #define MLXSW_EMAD_EH_PROTO_VERSION 0 17 18 /* EMAD TLV Types */ 19 enum { 20 MLXSW_EMAD_TLV_TYPE_END, 21 MLXSW_EMAD_TLV_TYPE_OP, 22 MLXSW_EMAD_TLV_TYPE_DR, 23 MLXSW_EMAD_TLV_TYPE_REG, 24 MLXSW_EMAD_TLV_TYPE_USERDATA, 25 MLXSW_EMAD_TLV_TYPE_OOBETH, 26 }; 27 28 /* OP TLV */ 29 #define MLXSW_EMAD_OP_TLV_LEN 4 /* Length in u32 */ 30 31 enum { 32 MLXSW_EMAD_OP_TLV_CLASS_REG_ACCESS = 1, 33 MLXSW_EMAD_OP_TLV_CLASS_IPC = 2, 34 }; 35 36 enum mlxsw_emad_op_tlv_status { 37 MLXSW_EMAD_OP_TLV_STATUS_SUCCESS, 38 MLXSW_EMAD_OP_TLV_STATUS_BUSY, 39 MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED, 40 MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV, 41 MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED, 42 MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED, 43 MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED, 44 MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER, 45 MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE, 46 MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK, 47 MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR = 0x70, 48 }; 49 50 static inline char *mlxsw_emad_op_tlv_status_str(u8 status) 51 { 52 switch (status) { 53 case MLXSW_EMAD_OP_TLV_STATUS_SUCCESS: 54 return "operation performed"; 55 case MLXSW_EMAD_OP_TLV_STATUS_BUSY: 56 return "device is busy"; 57 case MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED: 58 return "version not supported"; 59 case MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV: 60 return "unknown TLV"; 61 case MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED: 62 return "register not supported"; 63 case MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED: 64 return "class not supported"; 65 case MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED: 66 return "method not supported"; 67 case MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER: 68 return "bad parameter"; 69 case MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE: 70 return "resource not available"; 71 case MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK: 72 return "acknowledged. retransmit"; 73 case MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR: 74 return "internal error"; 75 default: 76 return "*UNKNOWN*"; 77 } 78 } 79 80 enum { 81 MLXSW_EMAD_OP_TLV_REQUEST, 82 MLXSW_EMAD_OP_TLV_RESPONSE 83 }; 84 85 enum { 86 MLXSW_EMAD_OP_TLV_METHOD_QUERY = 1, 87 MLXSW_EMAD_OP_TLV_METHOD_WRITE = 2, 88 MLXSW_EMAD_OP_TLV_METHOD_SEND = 3, 89 MLXSW_EMAD_OP_TLV_METHOD_EVENT = 5, 90 }; 91 92 /* END TLV */ 93 #define MLXSW_EMAD_END_TLV_LEN 1 /* Length in u32 */ 94 95 #endif 96