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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * Copyright (c) 2005 SilverStorm Technologies, Inc. All rights reserved.
27  *
28  * This software is available to you under a choice of one of two
29  * licenses.  You may choose to be licensed under the terms of the GNU
30  * General Public License (GPL) Version 2, available from the file
31  * COPYING in the main directory of this source tree, or the
32  * OpenIB.org BSD license below:
33  *
34  *     Redistribution and use in source and binary forms, with or
35  *     without modification, are permitted provided that the following
36  *     conditions are met:
37  *
38  *	- Redistributions of source code must retain the above
39  *	  copyright notice, this list of conditions and the following
40  *	  disclaimer.
41  *
42  *	- Redistributions in binary form must reproduce the above
43  *	  copyright notice, this list of conditions and the following
44  *	  disclaimer in the documentation and/or other materials
45  *	  provided with the distribution.
46  *
47  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
51  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
52  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
53  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54  * SOFTWARE.
55  *
56  */
57 /*
58  * Sun elects to include this software in Sun product
59  * under the OpenIB BSD license.
60  *
61  *
62  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
63  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
66  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
67  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
68  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
69  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
70  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
71  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
72  * POSSIBILITY OF SUCH DAMAGE.
73  */
74 
75 #ifndef _RDSIB_PROTOCOL_H
76 #define	_RDSIB_PROTOCOL_H
77 
78 #pragma ident	"%Z%%M%	%I%	%E% SMI"
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 #include <netinet/in.h>
85 
86 #define	RDS_VERSION	4
87 
88 /*
89  * RDS Well known service id
90  * Format: 0x1h00144Fhhhhhhhh
91  *         "00144F" is the Sun OUI
92  * 'h' can be any hex-decimal digit.
93  */
94 #define	RDS_SERVICE_ID		0x1000144F00000001ULL
95 
96 /* Max number of nodes supported with the default configuration */
97 #define	RDS_MAX_NODES	8
98 
99 /* packet size */
100 #define	RDS_USER_DATA_BUFFER_SIZE	4096 /* 4K */
101 
102 /* per session */
103 #define	RDS_MAX_DATA_RECV_BUFFERS	3000
104 #define	RDS_MAX_DATA_SEND_BUFFERS	2000
105 #define	RDS_MAX_CTRL_RECV_BUFFERS	100
106 #define	RDS_MAX_CTRL_SEND_BUFFERS	50
107 
108 /* RQ low water mark in percentage. More RWR have to be posted */
109 #define	RDS_DATA_RECV_BUFFER_LWM	90
110 #define	RDS_CTRL_RECV_BUFFER_LWM	50
111 
112 /*
113  * High water mark in percentage of pkts pending on sockets.
114  * Incoming traffic should be controlled or stopped for all sockets
115  * or some sockets that are above their quota
116  */
117 #define	RDS_PENDING_RX_PKTS_HWM	75
118 
119 /*
120  * Only interoperate with homogeneous Solaris (x32, x64, sparcv9).
121  */
122 #if defined(__sparcv9)
123 #define	RDS_THIS_ARCH	1
124 #elif defined(__amd64)
125 #define	RDS_THIS_ARCH	2
126 #elif defined(__i386)
127 #define	RDS_THIS_ARCH	3
128 #else
129 #error "ISA not supported"
130 #endif
131 
132 /*
133  * CM Private Data
134  *
135  * This data is sent with the CM REQ message by the initiater of the
136  * RC channel.
137  *
138  * cm_ip_pvt - ibt_ip_cm_info_t
139  * version - RDS version
140  * arch - only interoperate with homogeneous Solaris (x32, x64, sparcv9).
141  * eptype - RDS_EP_TYPE_CTRL or RDS_EP_TYPE_DATA
142  * failover - flag to indicate failover.
143  * last_bufid - used during failover, indicates the last buffer the remote
144  *     received.
145  * user_buffer_size - Packet size on the sending node. This is also the size
146  *     of the SGL buffer used in the send and receive WRs. This should be
147  *     same size on the both active and passive nodes.
148  * ack_rkey - RKEY for the RDMA acknowledgement buffer.
149  * ack_addr - Registered MR address to receive RDMA acknowledgement.
150  */
151 typedef struct rds_cm_private_data_s {
152 	uint8_t		cmp_ip_pvt[IBT_IP_HDR_PRIV_DATA_SZ];
153 	uint8_t		cmp_version;
154 	uint8_t		cmp_arch;
155 	uint8_t		cmp_eptype;
156 	uint8_t		cmp_failover;
157 	uintptr_t	cmp_last_bufid;
158 	uint32_t	cmp_user_buffer_size;
159 	ibt_rkey_t	cmp_ack_rkey;
160 	uintptr_t	cmp_ack_addr;
161 } rds_cm_private_data_t;
162 
163 /*
164  * Data Header
165  * This header is transmitted with every WR.
166  *
167  * bufid - Ponter to the send buffer that is used to send this packet.
168  * datalen - Number of bytes of data (not including the header)
169  * npkts - number of remaining pkts(including this one) for the message.
170  *         It is set to 1 for single packet messages.
171  * psn - Packet sequence number(starts at 0). Zero for single packet messages.
172  * sendport - Port number of the sending socket
173  * recvport - Port number of the receiving socket
174  */
175 typedef struct rds_data_hdr_s {
176 	uintptr_t		dh_bufid;
177 	uint32_t		dh_datalen;
178 	uint32_t		dh_npkts;
179 	uint32_t		dh_psn;
180 	in_port_t		dh_sendport;
181 	in_port_t		dh_recvport;
182 } rds_data_hdr_t;
183 
184 #define	RDS_DATA_HDR_SZ		sizeof (rds_data_hdr_t)
185 
186 /*
187  * List of control commands sent on a session:
188  *
189  * STALL: This command is sent to inform remote RDS that a port is stalled.
190  *	  Always sent on all existing sessions.
191  * UNSTALL: This command is sent to inform remote RDS that a port is unstalled.
192  *	  Always sent on all existing sessions.
193  * STALL_PORTS: Inform remote RDS that all local ports are stalled.
194  * UNSTALL_PORTS: Inform remote RDS that all local ports are unstalled.
195  * HEARTBEAT: Sent to check if the connection is still alive
196  */
197 #define	RDS_CTRL_CODE_STALL		1
198 #define	RDS_CTRL_CODE_UNSTALL		2
199 #define	RDS_CTRL_CODE_STALL_PORTS	3
200 #define	RDS_CTRL_CODE_UNSTALL_PORTS	4
201 #define	RDS_CTRL_CODE_HEARTBEAT		5
202 
203 /*
204  * RDS ctrl packet
205  *
206  * port - Socket to be stalled/unstalled
207  * code - STALL/UNSTALL (other codes are currently not used)
208  */
209 
210 typedef struct rds_ctrl_pkt_s {
211 	uint16_t	rcp_port;
212 	uint8_t		rcp_code;
213 } rds_ctrl_pkt_t;
214 
215 #define	RDS_CTRLPKT_SIZE	sizeof (rds_ctrl_pkt_t)
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif	/* _RDSIB_PROTOCOL_H */
222