These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / net / ethernet / mellanox / mlxsw / emad.h
1 /*
2  * drivers/net/ethernet/mellanox/mlxsw/emad.h
3  * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
4  * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
5  * Copyright (c) 2015 Jiri Pirko <jiri@mellanox.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the names of the copyright holders nor the names of its
16  *    contributors may be used to endorse or promote products derived from
17  *    this software without specific prior written permission.
18  *
19  * Alternatively, this software may be distributed under the terms of the
20  * GNU General Public License ("GPL") version 2 as published by the Free
21  * Software Foundation.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 #ifndef _MLXSW_EMAD_H
37 #define _MLXSW_EMAD_H
38
39 #define MLXSW_EMAD_MAX_FRAME_LEN 1518   /* Length in u8 */
40 #define MLXSW_EMAD_MAX_RETRY 5
41
42 /* EMAD Ethernet header */
43 #define MLXSW_EMAD_ETH_HDR_LEN 0x10     /* Length in u8 */
44 #define MLXSW_EMAD_EH_DMAC "\x01\x02\xc9\x00\x00\x01"
45 #define MLXSW_EMAD_EH_SMAC "\x00\x02\xc9\x01\x02\x03"
46 #define MLXSW_EMAD_EH_ETHERTYPE 0x8932
47 #define MLXSW_EMAD_EH_MLX_PROTO 0
48 #define MLXSW_EMAD_EH_PROTO_VERSION 0
49
50 /* EMAD TLV Types */
51 enum {
52         MLXSW_EMAD_TLV_TYPE_END,
53         MLXSW_EMAD_TLV_TYPE_OP,
54         MLXSW_EMAD_TLV_TYPE_DR,
55         MLXSW_EMAD_TLV_TYPE_REG,
56         MLXSW_EMAD_TLV_TYPE_USERDATA,
57         MLXSW_EMAD_TLV_TYPE_OOBETH,
58 };
59
60 /* OP TLV */
61 #define MLXSW_EMAD_OP_TLV_LEN 4         /* Length in u32 */
62
63 enum {
64         MLXSW_EMAD_OP_TLV_CLASS_REG_ACCESS = 1,
65         MLXSW_EMAD_OP_TLV_CLASS_IPC = 2,
66 };
67
68 enum mlxsw_emad_op_tlv_status {
69         MLXSW_EMAD_OP_TLV_STATUS_SUCCESS,
70         MLXSW_EMAD_OP_TLV_STATUS_BUSY,
71         MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED,
72         MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV,
73         MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED,
74         MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED,
75         MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED,
76         MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER,
77         MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE,
78         MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK,
79         MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR = 0x70,
80 };
81
82 static inline char *mlxsw_emad_op_tlv_status_str(u8 status)
83 {
84         switch (status) {
85         case MLXSW_EMAD_OP_TLV_STATUS_SUCCESS:
86                 return "operation performed";
87         case MLXSW_EMAD_OP_TLV_STATUS_BUSY:
88                 return "device is busy";
89         case MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED:
90                 return "version not supported";
91         case MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV:
92                 return "unknown TLV";
93         case MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED:
94                 return "register not supported";
95         case MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED:
96                 return "class not supported";
97         case MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED:
98                 return "method not supported";
99         case MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER:
100                 return "bad parameter";
101         case MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE:
102                 return "resource not available";
103         case MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK:
104                 return "acknowledged. retransmit";
105         case MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR:
106                 return "internal error";
107         default:
108                 return "*UNKNOWN*";
109         }
110 }
111
112 enum {
113         MLXSW_EMAD_OP_TLV_REQUEST,
114         MLXSW_EMAD_OP_TLV_RESPONSE
115 };
116
117 enum {
118         MLXSW_EMAD_OP_TLV_METHOD_QUERY = 1,
119         MLXSW_EMAD_OP_TLV_METHOD_WRITE = 2,
120         MLXSW_EMAD_OP_TLV_METHOD_SEND = 3,
121         MLXSW_EMAD_OP_TLV_METHOD_EVENT = 5,
122 };
123
124 /* END TLV */
125 #define MLXSW_EMAD_END_TLV_LEN 1        /* Length in u32 */
126
127 #endif