]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/tools/vxge/vxge_cmn.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / tools / vxge / vxge_cmn.h
1 /*-
2  * Copyright(c) 2002-2011 Exar Corp.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification are permitted provided the following conditions are met:
7  *
8  *    1. Redistributions of source code must retain the above copyright notice,
9  *       this list of conditions and the following disclaimer.
10  *
11  *    2. Redistributions in binary form must reproduce the above copyright
12  *       notice, this list of conditions and the following disclaimer in the
13  *       documentation and/or other materials provided with the distribution.
14  *
15  *    3. Neither the name of the Exar Corporation 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  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*$FreeBSD$*/
32
33 #ifndef _VXGE_CMN_H_
34 #define _VXGE_CMN_H_
35
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <unistd.h>
40 #include <errno.h>
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <sys/ioctl.h>
44 #include <net/if.h>
45 #include <netinet/in.h>
46 #include <arpa/inet.h>
47 #include <fcntl.h>
48
49 #if BYTE_ORDER == BIG_ENDIAN
50 #define VXGE_OS_HOST_BIG_ENDIAN
51 #else
52 #define VXGE_OS_HOST_LITTLE_ENDIAN
53 #endif
54
55 #if defined(VXGE_OS_HOST_BIG_ENDIAN)
56
57 #define GET_OFFSET_STATS(index)         statsInfo[(index)].be_offset
58 #define GET_OFFSET_PCICONF(index)       pciconfInfo[(index)].be_offset
59
60 #else
61
62 #define GET_OFFSET_STATS(index)         statsInfo[(index)].le_offset
63 #define GET_OFFSET_PCICONF(index)       pciconfInfo[(index)].le_offset
64
65 #endif
66
67 #define vxge_mem_free(x)        \
68         if (NULL != x) { free(x); x = NULL; }
69
70 typedef uint8_t u8;
71 typedef uint16_t u16;
72 typedef uint32_t u32;
73 typedef unsigned long long u64;
74 typedef u_long ulong_t;
75
76 typedef enum _vxge_query_device_info_e {
77
78         VXGE_GET_PCI_CONF = 100,
79         VXGE_GET_MRPCIM_STATS = 101,
80         VXGE_GET_DEVICE_STATS = 102,
81         VXGE_GET_DEVICE_HWINFO = 103,
82         VXGE_GET_DRIVER_STATS = 104,
83         VXGE_GET_INTR_STATS = 105,
84         VXGE_GET_VERSION = 106,
85         VXGE_GET_TCODE = 107,
86         VXGE_GET_VPATH_COUNT = 108,
87         VXGE_GET_BANDWIDTH = 109,
88         VXGE_SET_BANDWIDTH = 110,
89         VXGE_GET_PORT_MODE = 111,
90         VXGE_SET_PORT_MODE = 112
91
92 } vxge_query_device_info_e;
93
94 /* Register type enumaration */
95 typedef enum vxge_hal_mgmt_reg_type_e {
96
97         vxge_hal_mgmt_reg_type_legacy = 0,
98         vxge_hal_mgmt_reg_type_toc = 1,
99         vxge_hal_mgmt_reg_type_common = 2,
100         vxge_hal_mgmt_reg_type_memrepair = 3,
101         vxge_hal_mgmt_reg_type_pcicfgmgmt = 4,
102         vxge_hal_mgmt_reg_type_mrpcim = 5,
103         vxge_hal_mgmt_reg_type_srpcim = 6,
104         vxge_hal_mgmt_reg_type_vpmgmt = 7,
105         vxge_hal_mgmt_reg_type_vpath = 8
106
107 } vxge_hal_mgmt_reg_type_e;
108
109 typedef enum vxge_hal_xmac_nwif_dp_mode {
110
111         VXGE_HAL_DP_NP_MODE_DEFAULT,
112         VXGE_HAL_DP_NP_MODE_LINK_AGGR,
113         VXGE_HAL_DP_NP_MODE_ACTIVE_PASSIVE,
114         VXGE_HAL_DP_NP_MODE_SINGLE_PORT,
115         VXGE_HAL_DP_NP_MODE_DUAL_PORT,
116         VXGE_HAL_DP_NP_MODE_DISABLE_PORT_MGMT
117
118 } vxge_hal_xmac_nwif_dp_mode;
119
120 typedef enum vxge_hal_xmac_nwif_behavior_on_failure {
121
122         VXGE_HAL_XMAC_NWIF_OnFailure_NoMove,
123         VXGE_HAL_XMAC_NWIF_OnFailure_OtherPort,
124         VXGE_HAL_XMAC_NWIF_OnFailure_OtherPortBackOnRestore
125
126 } vxge_hal_xmac_nwif_behavior_on_failure;
127
128 #define VXGE_HAL_MGMT_REG_COUNT_LEGACY          7
129 #define VXGE_HAL_MGMT_REG_COUNT_TOC             11
130 #define VXGE_HAL_MGMT_REG_COUNT_COMMON          65
131 #define VXGE_HAL_MGMT_REG_COUNT_PCICFGMGMT      3
132 #define VXGE_HAL_MGMT_REG_COUNT_MRPCIM          1370
133 #define VXGE_HAL_MGMT_REG_COUNT_SRPCIM          48
134 #define VXGE_HAL_MGMT_REG_COUNT_VPMGMT          29
135 #define VXGE_HAL_MGMT_REG_COUNT_VPATH           139
136 #define VXGE_HAL_MGMT_STATS_COUNT_DRIVER        17
137 #define VXGE_HAL_MGMT_STATS_COUNT               160
138 #define VXGE_HAL_MGMT_STATS_COUNT_SW            54
139 #define VXGE_HAL_MGMT_STATS_COUNT_EXTENDED      56
140 #define VXGE_MAX_BANDWIDTH                      10000
141
142 #define VXGE_HAL_MAX_VIRTUAL_PATHS              17
143 #define ETH_LENGTH_OF_ADDRESS                   6
144
145 typedef char macaddr[ETH_LENGTH_OF_ADDRESS];
146
147 #define VXGE_PRINT(fd, fmt...) {        \
148         fprintf(fd, fmt);               \
149         fprintf(fd, "\n");              \
150         printf(fmt);                    \
151         printf("\n");                   \
152 }
153
154 /* Read & Write Register */
155 typedef struct _vxge_register_info_t {
156
157         u64     value;
158         u64     offset;
159         char    option[2];
160
161 } vxge_register_info_t;
162
163 /* Register Dump */
164 typedef struct _vxge_pci_bar0_t {
165         char    name[64];
166         u64     offset;
167         u32     size;
168
169 } vxge_pci_bar0_t;
170
171 typedef struct _vxge_stats_driver_info_t {
172
173         char    name[32];
174         u64     value;
175
176 } vxge_stats_driver_info_t;
177
178 typedef struct _vxge_hal_device_pmd_info_t {
179
180         u32     type;
181         u32     unused;
182         char    vendor[24];
183         char    part_num[24];
184         char    ser_num[24];
185
186 } vxge_hal_device_pmd_info_t;
187
188 typedef struct _vxge_hal_device_version_t {
189
190         u32     major;
191         u32     minor;
192         u32     build;
193         char    version[32];
194
195 } vxge_hal_device_version_t;
196
197 typedef struct _vxge_hal_device_date_t {
198
199         u32     day;
200         u32     month;
201         u32     year;
202         char    date[16];
203
204 } vxge_hal_device_date_t;
205
206 typedef struct _vxge_hal_device_hw_info_t {
207
208         u32     host_type;
209         u64     function_mode;
210         u32     func_id;
211         u64     vpath_mask;
212
213         vxge_hal_device_version_t fw_version;
214         vxge_hal_device_date_t fw_date;
215         vxge_hal_device_version_t flash_version;
216         vxge_hal_device_date_t flash_date;
217
218         char    serial_number[24];
219         char    part_number[24];
220         char    product_description[72];
221         u32     unused;
222         u32     ports;
223
224         vxge_hal_device_pmd_info_t pmd_port0;
225         vxge_hal_device_pmd_info_t pmd_port1;
226
227         macaddr mac_addrs[VXGE_HAL_MAX_VIRTUAL_PATHS];
228         macaddr mac_addr_masks[VXGE_HAL_MAX_VIRTUAL_PATHS];
229
230 } vxge_hal_device_hw_info_t;
231
232 typedef struct _vxge_device_hw_info_t {
233
234         vxge_hal_device_hw_info_t hw_info;
235         u32     port_mode;
236         u32     port_failure;
237
238 } vxge_device_hw_info_t;
239
240 typedef struct _vxge_bw_info_t {
241
242         char    query;
243         u64     func_id;
244         int     priority;
245         int     bandwidth;
246
247 } vxge_bw_info_t;
248
249 typedef struct _vxge_port_info_t {
250
251         char    query;
252         int     port_mode;
253         int     port_failure;
254
255 } vxge_port_info_t;
256
257 u32     vxge_get_num_vpath(void);
258 void    vxge_null_terminate(char *, size_t);
259
260 #endif  /* _VXGE_CMN_H_ */