19948a064SJiri Pirko /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 29948a064SJiri Pirko /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 34ec14b76SIdo Schimmel 44ec14b76SIdo Schimmel #ifndef _MLXSW_EMAD_H 54ec14b76SIdo Schimmel #define _MLXSW_EMAD_H 64ec14b76SIdo Schimmel 74ec14b76SIdo Schimmel #define MLXSW_EMAD_MAX_FRAME_LEN 1518 /* Length in u8 */ 84ec14b76SIdo Schimmel #define MLXSW_EMAD_MAX_RETRY 5 94ec14b76SIdo Schimmel 104ec14b76SIdo Schimmel /* EMAD Ethernet header */ 114ec14b76SIdo Schimmel #define MLXSW_EMAD_ETH_HDR_LEN 0x10 /* Length in u8 */ 124ec14b76SIdo Schimmel #define MLXSW_EMAD_EH_DMAC "\x01\x02\xc9\x00\x00\x01" 134ec14b76SIdo Schimmel #define MLXSW_EMAD_EH_SMAC "\x00\x02\xc9\x01\x02\x03" 144ec14b76SIdo Schimmel #define MLXSW_EMAD_EH_ETHERTYPE 0x8932 154ec14b76SIdo Schimmel #define MLXSW_EMAD_EH_MLX_PROTO 0 164ec14b76SIdo Schimmel #define MLXSW_EMAD_EH_PROTO_VERSION 0 174ec14b76SIdo Schimmel 184ec14b76SIdo Schimmel /* EMAD TLV Types */ 194ec14b76SIdo Schimmel enum { 204ec14b76SIdo Schimmel MLXSW_EMAD_TLV_TYPE_END, 214ec14b76SIdo Schimmel MLXSW_EMAD_TLV_TYPE_OP, 224ec14b76SIdo Schimmel MLXSW_EMAD_TLV_TYPE_DR, 234ec14b76SIdo Schimmel MLXSW_EMAD_TLV_TYPE_REG, 244ec14b76SIdo Schimmel MLXSW_EMAD_TLV_TYPE_USERDATA, 254ec14b76SIdo Schimmel MLXSW_EMAD_TLV_TYPE_OOBETH, 264ec14b76SIdo Schimmel }; 274ec14b76SIdo Schimmel 284ec14b76SIdo Schimmel /* OP TLV */ 294ec14b76SIdo Schimmel #define MLXSW_EMAD_OP_TLV_LEN 4 /* Length in u32 */ 304ec14b76SIdo Schimmel 314ec14b76SIdo Schimmel enum { 324ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_CLASS_REG_ACCESS = 1, 334ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_CLASS_IPC = 2, 344ec14b76SIdo Schimmel }; 354ec14b76SIdo Schimmel 364ec14b76SIdo Schimmel enum mlxsw_emad_op_tlv_status { 374ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_SUCCESS, 384ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_BUSY, 394ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED, 404ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV, 414ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED, 424ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED, 434ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED, 444ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER, 454ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE, 464ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK, 474ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR = 0x70, 484ec14b76SIdo Schimmel }; 494ec14b76SIdo Schimmel 504ec14b76SIdo Schimmel static inline char *mlxsw_emad_op_tlv_status_str(u8 status) 514ec14b76SIdo Schimmel { 524ec14b76SIdo Schimmel switch (status) { 534ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_SUCCESS: 544ec14b76SIdo Schimmel return "operation performed"; 554ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_BUSY: 564ec14b76SIdo Schimmel return "device is busy"; 574ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED: 584ec14b76SIdo Schimmel return "version not supported"; 594ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV: 604ec14b76SIdo Schimmel return "unknown TLV"; 614ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED: 624ec14b76SIdo Schimmel return "register not supported"; 634ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED: 644ec14b76SIdo Schimmel return "class not supported"; 654ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED: 664ec14b76SIdo Schimmel return "method not supported"; 674ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER: 684ec14b76SIdo Schimmel return "bad parameter"; 694ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE: 704ec14b76SIdo Schimmel return "resource not available"; 714ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK: 724ec14b76SIdo Schimmel return "acknowledged. retransmit"; 734ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR: 744ec14b76SIdo Schimmel return "internal error"; 754ec14b76SIdo Schimmel default: 764ec14b76SIdo Schimmel return "*UNKNOWN*"; 774ec14b76SIdo Schimmel } 784ec14b76SIdo Schimmel } 794ec14b76SIdo Schimmel 804ec14b76SIdo Schimmel enum { 814ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_REQUEST, 824ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_RESPONSE 834ec14b76SIdo Schimmel }; 844ec14b76SIdo Schimmel 854ec14b76SIdo Schimmel enum { 864ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_QUERY = 1, 874ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_WRITE = 2, 884ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_SEND = 3, 894ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_EVENT = 5, 904ec14b76SIdo Schimmel }; 914ec14b76SIdo Schimmel 924ec14b76SIdo Schimmel /* END TLV */ 934ec14b76SIdo Schimmel #define MLXSW_EMAD_END_TLV_LEN 1 /* Length in u32 */ 944ec14b76SIdo Schimmel 954ec14b76SIdo Schimmel #endif 96