2 * Copyright (c) 2004-2005 Mellanox Technologies Ltd. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
39 #include <mtl_types.h>
\r
41 typedef u_int8_t IB_port_t;
\r
42 #define NULL_IB_PORT 0xFF
\r
44 typedef u_int16_t IB_lid_t;
\r
45 typedef u_int8_t IB_gid_t[16]; /* GID (aka IPv6) H-to-L (big) (network) endianess */
\r
47 /* IB-spec. Vol.1 (chapter 4): LID ranges */
\r
48 #define MIN_UC_LID 0x0001 /* Unicast LID limits */
\r
49 #define MAX_UC_LID 0xBFFF
\r
50 #define MIN_MC_LID 0xC000 /* Multicast limits */
\r
51 #define MAX_MC_LID 0xFFFE
\r
52 #define PERMIS_LID 0xFFFF /* Permissive DLID */
\r
54 /* Special Multicast QP num */
\r
55 #define IB_MULTICAST_QP 0xFFFFFF
\r
56 #define IB_VALID_MULTICAST_GID(gid) ((gid)[0] == 0xFF)
\r
57 #define IB_VALID_MULTICAST_LID(lid) (((lid) >= MIN_MC_LID) && ((lid) <= MIN_MC_LID))
\r
60 typedef u_int32_t IB_wqpn_t; /* Work QP number: Only 24 LSbits */
\r
61 typedef u_int32_t IB_eecn_t; /* EE Context number: Only 24 LSbits */
\r
62 typedef u_int8_t IB_guid_t[8]; /* EUI-64: Big-Endinan (H-to-L) */
\r
63 typedef u_int8_t IB_gid_prefix_t[8]; /* EUI-64: Big-Endinan (H-to-L) */
\r
64 typedef u_int8_t IB_sl_t; /* 0-15 */
\r
65 typedef u_int8_t IB_vl_t; /* 0-15 */
\r
66 typedef u_int8_t IB_arbitration_weight_t;
\r
67 typedef enum{PRIO_HIGH=0,PRIO_LOW=1} IB_arbitration_prio_t;
\r
68 typedef u_int8_t IB_high_prio_limit_t;
\r
69 typedef u_int64_t IB_virt_addr_t;
\r
70 typedef u_int32_t IB_rkey_t;
\r
71 typedef u_int16_t IB_pkey_t;
\r
72 typedef u_int32_t IB_qkey_t;
\r
74 /*** Note *** The following enum must be maintained zero based without holes */
\r
75 enum { IB_TS_RC, IB_TS_RD, IB_TS_UC, IB_TS_UD, IB_TS_RAW };
\r
76 typedef u_int32_t IB_ts_t;
\r
80 #define INVALID_PKEY ((IB_pkey_t)0) /* invalid PKEY. 0x8000 is also invalid but we'll use 0 */
\r
82 typedef u_int32_t IB_psn_t;
\r
84 typedef u_int8_t IB_link_width_t; /* Set to a combination of following masks ("OR"ed) */
\r
88 #define W_SET2SUPPORTED 255 /* Set LinkWidthEnabled to LinkWidthSupported */
\r
90 /* 9.7.6.1.3 DETECTING LOST ACKNOWLEDGE MESSAGES AND TIMEOUTS (C9-140)*/
\r
91 #define IB_LOCAL_ACK_TIMEOUT_NUM_BITS 5
\r
93 /* IB-spec. 9.7.5.2.8, table 45
\r
94 * RNR timer values symbols/macros use the convention: IB_RNR_NAK_TIMER_MMM_mm
\r
95 * for the encoding of MMM.mm milliseconds
\r
97 #define IB_RNR_NAK_TIMER_NUM_BITS 5
\r
99 IB_RNR_NAK_TIMER_655_36 = 0,
\r
100 IB_RNR_NAK_TIMER_0_01 = 1,
\r
101 IB_RNR_NAK_TIMER_0_02 = 2,
\r
102 IB_RNR_NAK_TIMER_0_03 = 3,
\r
103 IB_RNR_NAK_TIMER_0_04 = 4,
\r
104 IB_RNR_NAK_TIMER_0_06 = 5,
\r
105 IB_RNR_NAK_TIMER_0_08 = 6,
\r
106 IB_RNR_NAK_TIMER_0_12 = 7,
\r
107 IB_RNR_NAK_TIMER_0_16 = 8,
\r
108 IB_RNR_NAK_TIMER_0_24 = 9,
\r
109 IB_RNR_NAK_TIMER_0_32 = 10,
\r
110 IB_RNR_NAK_TIMER_0_48 = 11,
\r
111 IB_RNR_NAK_TIMER_0_64 = 12,
\r
112 IB_RNR_NAK_TIMER_0_96 = 13,
\r
113 IB_RNR_NAK_TIMER_1_28 = 14,
\r
114 IB_RNR_NAK_TIMER_1_92 = 15,
\r
115 IB_RNR_NAK_TIMER_2_56 = 16,
\r
116 IB_RNR_NAK_TIMER_3_84 = 17,
\r
117 IB_RNR_NAK_TIMER_5_12 = 18,
\r
118 IB_RNR_NAK_TIMER_7_68 = 19,
\r
119 IB_RNR_NAK_TIMER_10_24 = 20,
\r
120 IB_RNR_NAK_TIMER_15_36 = 21,
\r
121 IB_RNR_NAK_TIMER_20_48 = 22,
\r
122 IB_RNR_NAK_TIMER_30_72 = 23,
\r
123 IB_RNR_NAK_TIMER_40_96 = 24,
\r
124 IB_RNR_NAK_TIMER_61_44 = 25,
\r
125 IB_RNR_NAK_TIMER_81_92 = 26,
\r
126 IB_RNR_NAK_TIMER_122_88 = 27,
\r
127 IB_RNR_NAK_TIMER_163_84 = 28,
\r
128 IB_RNR_NAK_TIMER_245_76 = 29,
\r
129 IB_RNR_NAK_TIMER_327_68 = 30,
\r
130 IB_RNR_NAK_TIMER_491_52 = 31
\r
132 typedef u_int32_t IB_rnr_nak_timer_code_t;
\r
140 PORT_NOP=0, /* No state change */
\r
148 PHY_NOP=0, /* No state change */
\r
152 PHY_PORT_CONF_TRAINING=4,
\r
154 PHY_LINK_ERR_REC0=6
\r
157 enum{MTU256=1,MTU512=2,MTU1024=3,MTU2048=4,MTU4096=5};
\r
158 typedef u_int32_t IB_mtu_t;
\r
160 typedef enum{VL0=1,VL0_1=2,VL0_3=3,VL0_7=4,VL0_14=5} IB_vl_cap_t;
\r
162 typedef u_int8_t IB_static_rate_t; /* IPD encoding: IB-spec. 9.11.1, table 63 */
\r
164 typedef enum{NODE_CA=1,NODE_SWITCH=2,NODE_ROUTER=3} IB_node_type_t;
\r
166 typedef u_int16_t IB_dev_id_t;
\r
170 /* 1: */ IB_CAP_MASK_IS_SM = (1<<1),
\r
171 /* 2: */ IB_CAP_MASK_IS_NOTICE_SUP = (1<<2),
\r
172 /* 3: */ IB_CAP_MASK_IS_TRAP_SUP = (1<<3),
\r
174 /* 5: */ IB_CAP_MASK_IS_AUTO_MIGR_SUP = (1<<5),
\r
175 /* 6: */ IB_CAP_MASK_IS_SL_MAP_SUP = (1<<6),
\r
176 /* 7: */ IB_CAP_MASK_IS_MKEY_NVRAM = (1<<7),
\r
177 /* 8: */ IB_CAP_MASK_IS_PKEY_NVRAM = (1<<8),
\r
178 /* 9: */ IB_CAP_MASK_IS_LED_INFO_SUP = (1<<9),
\r
179 /*10: */ IB_CAP_MASK_IS_SM_DISABLED = (1<<10),
\r
180 /*11: */ IB_CAP_MASK_IS_SYS_IMAGE_GUID_SUP = (1<<11),
\r
181 /*12: */ IB_CAP_MASK_IS_PKEY_SW_EXT_PORT_TRAP_SUP = (1<<12),
\r
182 /*13 - 15: RESERVED */
\r
183 /*16: */ IB_CAP_MASK_IS_CONN_MGMT_SUP = (1<<16),
\r
184 /*17: */ IB_CAP_MASK_IS_SNMP_TUNN_SUP = (1<<17),
\r
185 /*18: */ IB_CAP_MASK_IS_REINIT_SUP = (1<<18),
\r
186 /*19: */ IB_CAP_MASK_IS_DEVICE_MGMT_SUP = (1<<19),
\r
187 /*20: */ IB_CAP_MASK_IS_VENDOR_CLS_SUP = (1<<20),
\r
188 /*21: */ IB_CAP_MASK_IS_DR_NOTICE_SUP = (1<<21),
\r
189 /*22: */ IB_CAP_MASK_IS_CAP_MASK_NOTICE_SUP = (1<<22),
\r
190 /*23: */ IB_CAP_MASK_IS_BOOT_MGMT_SUP = (1<<23)
\r
191 /*24 - 31: RESERVED */
\r
192 } IB_capability_mask_bits_t;
\r
195 typedef u_int32_t IB_port_cap_mask_t; /* To be used with flags in IB_capability_mask_bits_t */
\r
197 #define IB_CAP_MASK_CLR_ALL(mask) ((mask)=0)
\r
198 #define IB_CAP_MASK_SET(mask,attr) ((mask)|=(attr))
\r
199 #define IB_CAP_MASK_CLR(mask,attr) ((mask)&=(~(attr)))
\r
200 #define IB_CAP_IS_SET(mask,attr) (((mask)&(attr))!=0)
\r
202 * This is an internal representation of PortInfo.
\r
203 * It does not map directly to PortInfo bits.
\r
205 struct IB_port_info_st {
\r
207 IB_gid_prefix_t gid_prefix; /* Big-endinan (H-to-L) */
\r
209 IB_lid_t master_sm_lid;
\r
210 IB_port_cap_mask_t capability_mask;
\r
211 u_int16_t diag_code;
\r
212 u_int16_t m_key_lease_period;
\r
213 IB_port_t local_port_num;
\r
214 IB_link_width_t link_width_enabled;
\r
215 IB_link_width_t link_width_supported;
\r
216 IB_link_width_t link_width_active;
\r
217 IB_link_speed_t link_speed_supported;
\r
218 IB_port_state_t port_state;
\r
219 IB_phy_state_t phy_state;
\r
220 IB_phy_state_t down_default_state;
\r
221 u_int8_t m_key_protect; /* 0-3 */
\r
222 u_int8_t lmc; /* 0-7 */
\r
223 IB_link_speed_t link_speed_active;
\r
224 IB_link_speed_t link_speed_enabled;
\r
225 IB_mtu_t neighbor_mtu;
\r
226 IB_sl_t master_sm_sl; /* 0-15 */
\r
227 IB_vl_cap_t vl_cap;
\r
228 u_int8_t vl_high_limit;
\r
229 u_int8_t vl_arbitration_high_cap;
\r
230 u_int8_t vl_arbitration_low_cap;
\r
232 u_int8_t vl_stall_count; /* 0-7 */
\r
233 u_int8_t hoq_life; /* 0-31 */
\r
234 IB_vl_cap_t operational_vl;
\r
235 MT_bool partition_enforcement_inbound;
\r
236 MT_bool partition_enforcement_outbound;
\r
237 MT_bool filter_raw_inbound;
\r
238 MT_bool filter_raw_outbound;
\r
239 u_int16_t m_key_violations;
\r
240 u_int16_t p_key_violations;
\r
241 u_int16_t q_key_violations;
\r
242 u_int8_t guid_cap; /* 0-15 */
\r
243 u_int8_t subnet_t_o; /* SubnetTimeOut: 0-31 */
\r
244 u_int8_t resp_time_val; /* 0-15 */
\r
245 u_int8_t local_phy_errs; /* 0-15 */
\r
246 u_int8_t overrun_errs; /* 0-15 */
\r
249 struct IB_node_info_st {
\r
250 u_int8_t base_version;
\r
251 u_int8_t class_version;
\r
252 IB_node_type_t node_type;
\r
253 u_int8_t num_ports;
\r
254 IB_guid_t node_guid;
\r
255 IB_guid_t port_guid;
\r
256 u_int16_t partition_cap;
\r
257 IB_dev_id_t dev_id;
\r
259 IB_port_t local_port_num;
\r
260 u_int32_t vendor_id; /* Only 24 LS-bits are valid */
\r
263 typedef u_int8_t IB_node_description_t[64]; /* consider other UNICODE string representation */
\r
265 struct IB_switch_info_st {
\r
266 u_int16_t linear_fdb_cap;
\r
267 u_int16_t random_fdb_cap;
\r
268 u_int16_t mcast_fdb_cap;
\r
269 u_int16_t linear_fdb_top;
\r
270 IB_port_t default_port;
\r
271 IB_port_t default_mcast_primary_port;
\r
272 IB_port_t default_mcast_not_primary_port;
\r
273 u_int8_t lifetime_val; /* Only 5 LS-bits are valid */
\r
274 MT_bool port_state_change;
\r
275 u_int16_t lids_per_port;
\r
276 u_int16_t partition_enforcement_cap;
\r
277 MT_bool inbound_enforcement_cap;
\r
278 MT_bool outbound_enforcement_cap;
\r
279 MT_bool filter_raw_packet_inbound_cap;
\r
280 MT_bool filter_raw_packet_outbound_cap;
\r
283 typedef struct IB_grh_st {
\r
284 u_int8_t IP_version; /* Only 4 LS-bits */
\r
285 u_int8_t traffic_class;
\r
286 u_int32_t flow_label; /* Only 20 LS-bits */
\r
287 u_int16_t payload_length;
\r
288 u_int8_t next_header;
\r
289 u_int8_t hop_limit;
\r
290 IB_gid_t sgid; /* H-to-L (big) (network) endianess */
\r
294 /* IB headers sizes in bytes */
\r
295 #define IB_LRH_LEN 8
\r
296 #define IB_GRH_LEN 40 /* size of the GRH (in the actual packet) */
\r
297 #define IB_BTH_LEN 12
\r
298 #define IB_DETH_LEN 8
\r
299 #define IB_MAD_LEN 256 /* size of a MAD payload */
\r
302 struct IB_vl_weight_element_st {
\r
304 IB_arbitration_weight_t weight;
\r
306 #define SET_END_OF_VL_WEIGHT_TAB(vlw) (vlw).weight = 0
\r
307 #define IS_END_OF_VL_WEIGHT_TAB(vlw) ((vlw).weight == 0)
\r
308 #define IB_MAX_VL_ARBITRATION_ENTRIES 64
\r
313 IB_COMP_LOC_LEN_ERR,
\r
314 IB_COMP_LOC_QP_OP_ERR,
\r
315 IB_COMP_LOC_EE_OP_ERR,
\r
316 IB_COMP_LOC_PROT_ERR,
\r
317 IB_COMP_WR_FLUSH_ERR,
\r
318 IB_COMP_MW_BIND_ERR,
\r
319 IB_COMP_BAD_RESP_ERR,
\r
320 IB_COMP_LOC_ACCS_ERR,
\r
321 IB_COMP_REM_INV_REQ_ERR,
\r
322 IB_COMP_REM_ACCESS_ERR,
\r
323 IB_COMP_REM_OP_ERR,
\r
324 IB_COMP_RETRY_EXC_ERR,
\r
325 IB_COMP_RNR_RETRY_EXC_ERR,
\r
326 IB_COMP_LOC_RDD_VIOL_ERR,
\r
327 IB_COMP_REM_INV_RD_REQ_ERR,
\r
328 IB_COMP_REM_ABORT_ERR,
\r
329 IB_COMP_INV_EECN_ERR,
\r
330 IB_COMP_INV_EEC_STATE_ERR,
\r
331 /* IB_COMP_LOC_TOUT,*/ /* Use IB_COMP_RETRY_EXC_ERR instead */
\r
332 /* IB_COMP_RNR_TOUT,*/ /* Use IB_COMP_RNR_RETRY_EXC_ERR instead */
\r
335 IB_COMP_GENERAL_ERR
\r
336 } IB_comp_status_t;
\r
338 #define IB_PSN_MAX ((int32_t)0xffffff)
\r
339 #define IB_PSN_ADD(a,b) (((int32_t)(a)+(int32_t)(b))& IB_PSN_MAX)
\r
340 #define IB_PSN_SUB(a,b) (((int32_t)(a)-(int32_t)(b))& IB_PSN_MAX)
\r
341 /* a <= b, that is b follows a: FIXME: might be off by one here */
\r
342 #define IB_PSN_LE(a,b) (IB_PSN_SUB((b),(a)) <= IB_PSN_MAX/2)
\r
343 #define IB_PSN_GE(a,b) (IB_PSN_LE((b),(a)))
\r
345 #define IB_PSN_IS_VALID(a) ((((int32_t)(a)) & (~ IB_PSN_MAX)) == 0 )
\r
346 #define IB_PSN_IS_INVALID(a) (((int32_t)(a)) & (~ IB_PSN_MAX))
\r
350 * xCA interface general data strcutures.
\r
356 typedef void* IB_wrid_t;
\r
357 #define IB_INVALID_WRID 0
\r
362 u_int32_t ibva_l; /* TBD - remove this in the future */
\r
363 u_int32_t ibva_h; /* TBD - remove this in the near future */
\r
380 u_int32_t byte_count; /* Sum of size of all s/g entries */
\r
381 u_int32_t entry_count; /* Number of s/g entries in list */
\r
383 enum {IB_SGE_VIRT, IB_SGE_PHYS} addr_type;
\r
392 IB_WR_RDMA_WRITE_WITH_IMM,
\r
394 IB_WR_SEND_WITH_IMM,
\r
396 IB_WR_ATOMIC_CMP_AND_SWP,
\r
397 IB_WR_ATOMIC_FETCH_AND_ADD,
\r
401 /* Address Vector */
\r
403 IB_sl_t sl; /* Service Level 4 bits */
\r
404 IB_lid_t dlid; /* Destination LID */
\r
405 u_int8_t src_path_bits; /* Source path bits 7 bits */
\r
406 IB_static_rate_t static_rate; /* Maximum static rate : 6 bits */
\r
408 MT_bool grh_flag; /* Send GRH flag */
\r
409 /* For global destination or Multicast address:*/
\r
410 u_int8_t traffic_class; /* TClass 8 bits */
\r
411 u_int32_t flow_label; /* Flow Label 20 bits */
\r
412 u_int8_t hop_limit; /* Hop Limit 8 bits */
\r
413 u_int8_t sgid_index; /* SGID index in SGID table */
\r
414 IB_gid_t dgid; /* Destination GID */
\r
424 #endif /* H_IB_DEFS_H */
\r