[golan] Add Connect-IB, ConnectX-4 and ConnectX-4 Lx (Infiniband) support
[ipxe.git] / src / drivers / infiniband / mlx_utils / mlx_lib / mlx_nvconfig / mlx_nvconfig.h
1 #ifndef MLX_NVCONFIG_H_
2 #define MLX_NVCONFIG_H_
3
4 /*
5 * Copyright (C) 2015 Mellanox Technologies Ltd.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */
22
23 FILE_LICENCE ( GPL2_OR_LATER );
24
25 #include "../mlx_reg_access/mlx_reg_access.h"
26 #include "../../include/public/mlx_utils.h"
27
28 typedef enum {
29 NVRAM_TLV_CLASS_GLOBAL = 0,
30 NVRAM_TLV_CLASS_PHYSICAL_PORT = 1,
31 NVRAM_TLV_CLASS_HOST = 3,
32 } NVRAM_CLASS_CODE;
33
34 struct nvconfig_tlv_type_per_port {
35 mlx_uint32 param_idx :16;
36 mlx_uint32 port :8;
37 mlx_uint32 param_class :8;
38 };
39
40 struct nvconfig_tlv_type_per_host {
41 mlx_uint32 param_idx :10;
42 mlx_uint32 function :8;
43 mlx_uint32 host :6;
44 mlx_uint32 param_class :8;
45 };
46
47 struct nvconfig_tlv_type_global {
48 mlx_uint32 param_idx :24;
49 mlx_uint32 param_class :8;
50 };
51
52 struct nvconfig_tlv_mapping{
53 mlx_uint16 tlv_type;
54 mlx_uint16 real_tlv_type;
55 NVRAM_CLASS_CODE class_code;
56 mlx_boolean fw_reset_needed;
57 };
58
59 union nvconfig_tlv_type {
60 struct nvconfig_tlv_type_per_port per_port;
61 struct nvconfig_tlv_type_per_host per_host;
62 struct nvconfig_tlv_type_global global;
63 };
64
65
66 struct nvconfig_nvqc {
67 union nvconfig_tlv_type tlv_type;
68 /* -------------- */
69 mlx_uint32 support_rd :1; /*the configuration item is supported and can be read */
70 mlx_uint32 support_wr :1; /*the configuration item is supported and can be updated */
71 mlx_uint32 reserved1 :2;
72 mlx_uint32 version :4; /*The maximum version of the configuration item currently supported by the firmware. */
73 mlx_uint32 reserved2 :24;
74 };
75
76
77 struct nvconfig_header {
78 mlx_uint32 length :9; /*Size of configuration item data in bytes between 0..256 */
79 mlx_uint32 reserved0 :3;
80 mlx_uint32 version :4; /* Configuration item version */
81 mlx_uint32 reserved1 :7;
82
83 mlx_uint32 def_en :1; /*Choose whether to access the default value or the user-defined value.
84 0x0 Read or write the user-defined value.
85 0x1 Read the default value (only valid for reads).*/
86
87 mlx_uint32 rd_en :1; /*enables reading the TLV by lower priorities
88 0 - TLV can be read by the subsequent lifecycle priorities.
89 1 - TLV cannot be read by the subsequent lifecycle priorities. */
90 mlx_uint32 over_en :1; /*enables overwriting the TLV by lower priorities
91 0 - Can only be overwritten by the current lifecycle priority
92 1 - Allowed to be overwritten by subsequent lifecycle priorities */
93 mlx_uint32 header_type :2;
94 mlx_uint32 priority :2;
95 mlx_uint32 valid :2;
96 /* -------------- */
97 union nvconfig_tlv_type tlv_type;;
98 /* -------------- */
99 mlx_uint32 crc :16;
100 mlx_uint32 reserved :16;
101 };
102
103 #define NVCONFIG_MAX_TLV_SIZE 256
104
105 struct nvconfig_nvda {
106 struct nvconfig_header nv_header;
107 mlx_uint8 data[NVCONFIG_MAX_TLV_SIZE];
108 };
109
110
111 mlx_status
112 nvconfig_query_capability(
113 IN mlx_utils *utils,
114 IN mlx_uint8 port,
115 IN mlx_uint16 tlv_type,
116 OUT mlx_boolean *read_supported,
117 OUT mlx_boolean *write_supported
118 );
119
120
121 mlx_status
122 nvconfig_nvdata_invalidate(
123 IN mlx_utils *utils,
124 IN mlx_uint8 port,
125 IN mlx_uint16 tlv_type
126 );
127
128 mlx_status
129 nvconfig_nvdata_access(
130 IN mlx_utils *utils,
131 IN mlx_uint8 port,
132 IN mlx_uint16 tlv_type,
133 IN REG_ACCESS_OPT opt,
134 IN mlx_size data_size,
135 IN NV_DEFAULT_OPT def_en,
136 IN OUT mlx_uint8 *version,
137 IN OUT mlx_void *data
138 );
139
140 #endif /* MLX_NVCONFIG_H_ */