xref: /illumos-gate/usr/src/uts/common/sys/ib/clients/eoib/eib.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _SYS_IB_EOIB_EIB_H
27 #define	_SYS_IB_EOIB_EIB_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  *
35  * EoIB Encapsulation Header Layout
36  *
37  *  31 30 29 28 27 26 25 24     22 21 20 ... 16 15                      0
38  * +-----+-----+-----+-----+--+---+--+---------+-------------------------+
39  * | sig | ver | TCP | IP  |  |fcs|ms| segment |       segment id        |
40  * |     |     | chk | chk |  |   |  | offset  |                         |
41  * +-----+-----+-----+-----+--+---+--+---------+-------------------------+
42  *
43  */
44 #define	EIB_ENCAP_HDR_SZ		4
45 
46 #define	EIB_ENCAP_SIGN_MASK		0x3
47 #define	EIB_ENCAP_SIGN_SHIFT		30
48 #define	EIB_ENCAP_VER_MASK		0x3
49 #define	EIB_ENCAP_VER_SHIFT		28
50 #define	EIB_ENCAP_TCPCHK_MASK		0x3
51 #define	EIB_ENCAP_TCPCHK_SHIFT		26
52 #define	EIB_ENCAP_IPCHK_MASK		0x3
53 #define	EIB_ENCAP_IPCHK_SHIFT		24
54 #define	EIB_ENCAP_FCS_B_SHIFT		22
55 #define	EIB_ENCAP_MS_B_SHIFT		21
56 #define	EIB_ENCAP_SEGOFF_MASK		0x1F
57 #define	EIB_ENCAP_SEGOFF_SHIFT		16
58 #define	EIB_ENCAP_SEGID_MASK		0xFFFF
59 
60 /*
61  * Bit fields values definitions
62  */
63 #define	EIB_EH_SIGNATURE		3
64 #define	EIB_EH_VERSION			0
65 #define	EIB_EH_CSUM_UNKNOWN		0
66 #define	EIB_EH_TCPCSUM_OK		1
67 #define	EIB_EH_UDPCSUM_OK		2
68 #define	EIB_EH_CSUM_BAD			3
69 #define	EIB_EH_IPCSUM_OK		1
70 
71 /*
72  * Some shortcuts
73  */
74 #define	EIB_TX_ENCAP_HDR		0xC0000000
75 #define	EIB_RX_ENCAP_TCPIP_OK		0xC5000000
76 #define	EIB_RX_ENCAP_UDPIP_OK		0xC9000000
77 
78 /*
79  * Driver name
80  */
81 #define	EIB_DRV_NAME			"eoib"
82 
83 /*
84  * Currently, the gateway responds to login requests on the qpn that carried
85  * the solication request, rather than on the qpn that carried the login
86  * request.  This means that EoIB nexus receives the acknowledgements from
87  * gateways to login requests made by the individual EoIB instances, and must
88  * pass this login ack information back to the appropriate EoIB instance.
89  *
90  * Now, the only field in the login ack packet that could identify the
91  * individual EoIB instance is the vNIC id field, but this is a 16-bit field,
92  * with the MSB reserved to indicate whether the mac/vlan is host-managed
93  * or gateway-managed.  This leaves us with just 15-bits to encode the EoIB
94  * device instance and its Solaris vnic instance.  For now, we divide this
95  * field as a 6-bit vnic instance number (max Solaris vnics is 64) and a
96  * 9-bit device instance number (max EoIB pseudo-NICs in a system is 512).
97  *
98  * The long-term solution is to get the gateway to respond directly to the
99  * login requestor, so the requestor can use all 15-bits to identify its
100  * Solaris vnic instance (max 32K) and leave the device instance limit to
101  * the system limit.
102  */
103 #define	EIB_DVI_SHIFT			6
104 #define	EIB_DVI_MASK			0x1FF
105 #define	EIB_VNI_MASK			0x03F
106 
107 #define	EIB_VNIC_INSTANCE(id)		((id) & EIB_VNI_MASK)
108 #define	EIB_DEVI_INSTANCE(id)		(((id) >> EIB_DVI_SHIFT) & EIB_DVI_MASK)
109 #define	EIB_VNIC_ID(dvi, vni)		\
110 	((((dvi) & EIB_DVI_MASK) << EIB_DVI_SHIFT) | ((vni) & EIB_VNI_MASK))
111 
112 /*
113  * Making VHUB_ID from vlan and portid
114  */
115 #define	EIB_VHUB_ID(portid, vlan)	\
116 	((((uint_t)(portid) & 0xfff) << 12) | ((uint_t)(vlan) & 0xfff))
117 
118 /*
119  * NDI Events that individual EoIB instance will be interested in
120  */
121 #define	EIB_NDI_EVENT_GW_AVAILABLE	"SUNW,eoib:gateway-available"
122 #define	EIB_NDI_EVENT_LOGIN_ACK		"SUNW,eoib:vnic-login-ack"
123 #define	EIB_NDI_EVENT_GW_INFO_UPDATE	"SUNW,eoib:gateway-info-update"
124 
125 /*
126  * Properties for each eoib node created
127  */
128 #define	EIB_PROP_HCA_GUID		"hca-guid"
129 #define	EIB_PROP_HCA_PORTNUM		"hca-port#"
130 #define	EIB_PROP_GW_SYS_GUID		"gw-system-guid"
131 #define	EIB_PROP_GW_GUID		"gw-guid"
132 #define	EIB_PROP_GW_SN_PREFIX		"gw-sn-prefix"
133 #define	EIB_PROP_GW_ADV_PERIOD		"gw-adv-period"
134 #define	EIB_PROP_GW_KA_PERIOD		"gw-ka-period"
135 #define	EIB_PROP_VNIC_KA_PERIOD		"vnic-ka-period"
136 #define	EIB_PROP_GW_CTRL_QPN		"gw-ctrl-qpn"
137 #define	EIB_PROP_GW_LID			"gw-lid"
138 #define	EIB_PROP_GW_PORTID		"gw-portid"
139 #define	EIB_PROP_GW_NUM_NET_VNICS	"gw-num-net-vnics"
140 #define	EIB_PROP_GW_AVAILABLE		"gw-available?"
141 #define	EIB_PROP_GW_HOST_VNICS		"gw-host-vnics?"
142 #define	EIB_PROP_GW_SL			"gw-sl"
143 #define	EIB_PROP_GW_N_RSS_QPN		"gw-n-rss-qpn"
144 #define	EIB_PROP_GW_SYS_NAME		"gw-system-name"
145 #define	EIB_PROP_GW_PORT_NAME		"gw-port-name"
146 #define	EIB_PROP_GW_VENDOR_ID		"gw-vendor-id"
147 
148 /*
149  * Gateway information passed by eibnx to eoib.  The lengths of character
150  * strings should be longer than what is defined for these objects in fip.h,
151  * to accomodate the terminating null.
152  */
153 #define	EIB_GW_SYSNAME_LEN		40
154 #define	EIB_GW_PORTNAME_LEN		12
155 #define	EIB_GW_VENDOR_LEN		12
156 
157 typedef struct eib_gw_info_s {
158 	ib_guid_t	gi_system_guid;
159 	ib_guid_t	gi_guid;
160 	ib_sn_prefix_t	gi_sn_prefix;
161 	uint32_t	gi_adv_period;
162 	uint32_t	gi_ka_period;
163 	uint32_t	gi_vnic_ka_period;
164 	ib_qpn_t	gi_ctrl_qpn;
165 	ib_lid_t	gi_lid;
166 	uint16_t	gi_portid;
167 	uint16_t	gi_num_net_vnics;
168 	uint8_t		gi_flag_available;
169 	uint8_t		gi_is_host_adm_vnics;
170 	uint8_t		gi_sl;
171 	uint8_t		gi_n_rss_qpn;
172 	uint8_t		gi_system_name[EIB_GW_SYSNAME_LEN];
173 	uint8_t		gi_port_name[EIB_GW_PORTNAME_LEN];
174 	uint8_t		gi_vendor_id[EIB_GW_VENDOR_LEN];
175 } eib_gw_info_t;
176 
177 /*
178  * Softint priority levels to use for data and control/admin cq handling
179  * in EoIB leaf and nexus drivers
180  */
181 #define	EIB_SOFTPRI_DATA		(DDI_INTR_SOFTPRI_MIN)
182 #define	EIB_SOFTPRI_CTL			(DDI_INTR_SOFTPRI_MIN + 1)
183 #define	EIB_SOFTPRI_ADM			(DDI_INTR_SOFTPRI_MIN + 1)
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif	/* _SYS_IB_EOIB_EIB_H */
190