rdsib_protocol.h revision 4703:bb31c50bb3ab
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
81extern "C" {
82#endif
83
84#include <netinet/in.h>
85
86#define	RDS_VERSION	3
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/* packet size */
97#define	RDS_USER_DATA_BUFFER_SIZE	4096 /* 4K */
98
99/* Max memory that can be used for sending and receiving data pkts */
100/* per RDS */
101#define	RDS_MAX_RECV_MEMORY		96000 /* KB */
102
103/* per session */
104#define	RDS_MAX_DATA_RECV_BUFFERS	3000
105#define	RDS_MAX_DATA_SEND_BUFFERS	2000
106#define	RDS_MAX_CTRL_RECV_BUFFERS	100
107#define	RDS_MAX_CTRL_SEND_BUFFERS	50
108
109/* RQ low water mark in percentage. More RWR have to be posted */
110#define	RDS_DATA_RECV_BUFFER_LWM	90
111#define	RDS_CTRL_RECV_BUFFER_LWM	50
112
113/*
114 * High water mark in percentage of pkts pending on sockets.
115 * Incoming traffic should be controlled or stopped for all sockets
116 * or some sockets that are above their quota
117 */
118#define	RDS_PENDING_RX_PKTS_HWM	75
119
120/*
121 * Only interoperate with homogeneous Solaris (x32, x64, sparcv9).
122 */
123#if defined(__sparcv9)
124#define	RDS_THIS_ARCH	1
125#elif defined(__amd64)
126#define	RDS_THIS_ARCH	2
127#elif defined(__i386)
128#define	RDS_THIS_ARCH	3
129#else
130#error "ISA not supported"
131#endif
132
133/*
134 * CM Private Data
135 *
136 * This data is sent with the CM REQ message by the initiater of the
137 * RC channel.
138 *
139 * version - RDS version
140 * arch - only interoperate with homogeneous Solaris (x32, x64, sparcv9).
141 * remip - IP address of the passive/remote node
142 * localip - IP address of the active/local node
143 * eptype - RDS_EP_TYPE_CTRL or RDS_EP_TYPE_DATA
144 * user_buffer_size - Packet size on the sending node. This is also the size
145 *     of the SGL buffer used in the send and receive WRs. This should be
146 *     same size on the both active and passive nodes.
147 */
148typedef struct rds_cm_private_data_s {
149	uint8_t		cmp_ip_pvt[IBT_IP_HDR_PRIV_DATA_SZ];
150	uint8_t		cmp_version;
151	uint8_t		cmp_arch;
152	uint8_t		cmp_eptype;
153	uint8_t		cmp_failover;
154	ipaddr_t	cmp_remip;
155	ipaddr_t	cmp_localip;
156	uintptr_t	cmp_last_bufid;
157	uint32_t	cmp_user_buffer_size;
158	ibt_rkey_t	cmp_ack_rkey;
159	uintptr_t	cmp_ack_addr;
160} rds_cm_private_data_t;
161
162/*
163 * Data Header
164 * This header is transmitted with every WR.
165 *
166 * bufid - Ponter to the send buffer that is used to send this packet.
167 * datalen - Number of bytes of data (not including the header)
168 * npkts - number of remaining pkts(including this one) for the message.
169 *         It is set to 1 for single packet messages.
170 * psn - Packet sequence number(starts at 0). Zero for single packet messages.
171 * sendport - Port number of the sending socket
172 * recvport - Port number of the receiving socket
173 */
174typedef struct rds_data_hdr_s {
175	uintptr_t		dh_bufid;
176	uint32_t		dh_datalen;
177	uint32_t		dh_npkts;
178	uint32_t		dh_psn;
179	in_port_t		dh_sendport;
180	in_port_t		dh_recvport;
181} rds_data_hdr_t;
182
183#define	RDS_DATA_HDR_SZ		sizeof (rds_data_hdr_t)
184
185/*
186 * List of control commands sent on a session:
187 *
188 * STALL: This command is sent to inform remote RDS that a port is stalled.
189 *	  Always sent on all existing sessions.
190 * UNSTALL: This command is sent to inform remote RDS that a port is unstalled.
191 *	  Always sent on all existing sessions.
192 * STALL_PORTS: Inform remote RDS that all local ports are stalled.
193 * UNSTALL_PORTS: Inform remote RDS that all local ports are unstalled.
194 * HEARTBEAT: Sent to check if the connection is still alive
195 */
196#define	RDS_CTRL_CODE_STALL		1
197#define	RDS_CTRL_CODE_UNSTALL		2
198#define	RDS_CTRL_CODE_STALL_PORTS	3
199#define	RDS_CTRL_CODE_UNSTALL_PORTS	4
200#define	RDS_CTRL_CODE_HEARTBEAT		5
201
202/*
203 * RDS ctrl packet
204 *
205 * port - Socket to be stalled/unstalled
206 * code - STALL/UNSTALL (other codes are currently not used)
207 */
208
209typedef struct rds_ctrl_pkt_s {
210	uint16_t	rcp_port;
211	uint8_t		rcp_code;
212} rds_ctrl_pkt_t;
213
214#define	RDS_CTRLPKT_SIZE	sizeof (rds_ctrl_pkt_t)
215
216#ifdef __cplusplus
217}
218#endif
219
220#endif	/* _RDSIB_PROTOCOL_H */
221