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,
22664b3dd9SShalom Toledo MLXSW_EMAD_TLV_TYPE_STRING,
23664b3dd9SShalom Toledo MLXSW_EMAD_TLV_TYPE_REG,
24*695f7306SAmit Cohen MLXSW_EMAD_TLV_TYPE_LATENCY,
254ec14b76SIdo Schimmel };
264ec14b76SIdo Schimmel
274ec14b76SIdo Schimmel /* OP TLV */
284ec14b76SIdo Schimmel #define MLXSW_EMAD_OP_TLV_LEN 4 /* Length in u32 */
294ec14b76SIdo Schimmel
304ec14b76SIdo Schimmel enum {
314ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_CLASS_REG_ACCESS = 1,
324ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_CLASS_IPC = 2,
334ec14b76SIdo Schimmel };
344ec14b76SIdo Schimmel
354ec14b76SIdo Schimmel enum mlxsw_emad_op_tlv_status {
364ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_SUCCESS,
374ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_BUSY,
384ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED,
394ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV,
404ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED,
414ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED,
424ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED,
434ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER,
444ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE,
454ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK,
464ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR = 0x70,
474ec14b76SIdo Schimmel };
484ec14b76SIdo Schimmel
mlxsw_emad_op_tlv_status_str(u8 status)494ec14b76SIdo Schimmel static inline char *mlxsw_emad_op_tlv_status_str(u8 status)
504ec14b76SIdo Schimmel {
514ec14b76SIdo Schimmel switch (status) {
524ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_SUCCESS:
534ec14b76SIdo Schimmel return "operation performed";
544ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_BUSY:
554ec14b76SIdo Schimmel return "device is busy";
564ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED:
574ec14b76SIdo Schimmel return "version not supported";
584ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV:
594ec14b76SIdo Schimmel return "unknown TLV";
604ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED:
614ec14b76SIdo Schimmel return "register not supported";
624ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED:
634ec14b76SIdo Schimmel return "class not supported";
644ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED:
654ec14b76SIdo Schimmel return "method not supported";
664ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER:
674ec14b76SIdo Schimmel return "bad parameter";
684ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE:
694ec14b76SIdo Schimmel return "resource not available";
704ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK:
714ec14b76SIdo Schimmel return "acknowledged. retransmit";
724ec14b76SIdo Schimmel case MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR:
734ec14b76SIdo Schimmel return "internal error";
744ec14b76SIdo Schimmel default:
754ec14b76SIdo Schimmel return "*UNKNOWN*";
764ec14b76SIdo Schimmel }
774ec14b76SIdo Schimmel }
784ec14b76SIdo Schimmel
794ec14b76SIdo Schimmel enum {
804ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_REQUEST,
814ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_RESPONSE
824ec14b76SIdo Schimmel };
834ec14b76SIdo Schimmel
844ec14b76SIdo Schimmel enum {
854ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_QUERY = 1,
864ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_WRITE = 2,
874ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_SEND = 3,
884ec14b76SIdo Schimmel MLXSW_EMAD_OP_TLV_METHOD_EVENT = 5,
894ec14b76SIdo Schimmel };
904ec14b76SIdo Schimmel
91664b3dd9SShalom Toledo /* STRING TLV */
92664b3dd9SShalom Toledo #define MLXSW_EMAD_STRING_TLV_LEN 33 /* Length in u32 */
93664b3dd9SShalom Toledo
94*695f7306SAmit Cohen /* LATENCY TLV */
95*695f7306SAmit Cohen #define MLXSW_EMAD_LATENCY_TLV_LEN 7 /* Length in u32 */
96*695f7306SAmit Cohen
974ec14b76SIdo Schimmel /* END TLV */
984ec14b76SIdo Schimmel #define MLXSW_EMAD_END_TLV_LEN 1 /* Length in u32 */
994ec14b76SIdo Schimmel
1004ec14b76SIdo Schimmel #endif
101