xref: /onnv-gate/usr/src/uts/common/sys/ib/clients/rds/rdsib_protocol.h (revision 8082:f52c9d98dc8c)
13302Sagiri /*
23302Sagiri  * CDDL HEADER START
33302Sagiri  *
43302Sagiri  * The contents of this file are subject to the terms of the
53302Sagiri  * Common Development and Distribution License (the "License").
63302Sagiri  * You may not use this file except in compliance with the License.
73302Sagiri  *
83302Sagiri  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93302Sagiri  * or http://www.opensolaris.org/os/licensing.
103302Sagiri  * See the License for the specific language governing permissions
113302Sagiri  * and limitations under the License.
123302Sagiri  *
133302Sagiri  * When distributing Covered Code, include this CDDL HEADER in each
143302Sagiri  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153302Sagiri  * If applicable, add the following below this CDDL HEADER, with the
163302Sagiri  * fields enclosed by brackets "[]" replaced with your own identifying
173302Sagiri  * information: Portions Copyright [yyyy] [name of copyright owner]
183302Sagiri  *
193302Sagiri  * CDDL HEADER END
203302Sagiri  */
213302Sagiri /*
22*8082SRamaswamy.Tummala@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233302Sagiri  * Use is subject to license terms.
243302Sagiri  */
253302Sagiri /*
263302Sagiri  * Copyright (c) 2005 SilverStorm Technologies, Inc. All rights reserved.
273302Sagiri  *
283302Sagiri  * This software is available to you under a choice of one of two
293302Sagiri  * licenses.  You may choose to be licensed under the terms of the GNU
303302Sagiri  * General Public License (GPL) Version 2, available from the file
313302Sagiri  * COPYING in the main directory of this source tree, or the
323302Sagiri  * OpenIB.org BSD license below:
333302Sagiri  *
343302Sagiri  *     Redistribution and use in source and binary forms, with or
353302Sagiri  *     without modification, are permitted provided that the following
363302Sagiri  *     conditions are met:
373302Sagiri  *
383302Sagiri  *	- Redistributions of source code must retain the above
393302Sagiri  *	  copyright notice, this list of conditions and the following
403302Sagiri  *	  disclaimer.
413302Sagiri  *
423302Sagiri  *	- Redistributions in binary form must reproduce the above
433302Sagiri  *	  copyright notice, this list of conditions and the following
443302Sagiri  *	  disclaimer in the documentation and/or other materials
453302Sagiri  *	  provided with the distribution.
463302Sagiri  *
473302Sagiri  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
483302Sagiri  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
493302Sagiri  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
503302Sagiri  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
513302Sagiri  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
523302Sagiri  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
533302Sagiri  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
543302Sagiri  * SOFTWARE.
553302Sagiri  *
563302Sagiri  */
573302Sagiri /*
583302Sagiri  * Sun elects to include this software in Sun product
593302Sagiri  * under the OpenIB BSD license.
603302Sagiri  *
613302Sagiri  *
623302Sagiri  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
633302Sagiri  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
643302Sagiri  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
653302Sagiri  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
663302Sagiri  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
673302Sagiri  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
683302Sagiri  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
693302Sagiri  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
703302Sagiri  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
713302Sagiri  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
723302Sagiri  * POSSIBILITY OF SUCH DAMAGE.
733302Sagiri  */
743302Sagiri 
753302Sagiri #ifndef _RDSIB_PROTOCOL_H
763302Sagiri #define	_RDSIB_PROTOCOL_H
773302Sagiri 
783302Sagiri #ifdef __cplusplus
793302Sagiri extern "C" {
803302Sagiri #endif
813302Sagiri 
823302Sagiri #include <netinet/in.h>
833302Sagiri 
844804Sagiri #define	RDS_VERSION	4
853302Sagiri 
863302Sagiri /*
873302Sagiri  * RDS Well known service id
883302Sagiri  * Format: 0x1h00144Fhhhhhhhh
893302Sagiri  *         "00144F" is the Sun OUI
903302Sagiri  * 'h' can be any hex-decimal digit.
913302Sagiri  */
923302Sagiri #define	RDS_SERVICE_ID		0x1000144F00000001ULL
933302Sagiri 
945342Sagiri /* Max number of nodes supported with the default configuration */
955342Sagiri #define	RDS_MAX_NODES	8
965342Sagiri 
973302Sagiri /* packet size */
983302Sagiri #define	RDS_USER_DATA_BUFFER_SIZE	4096 /* 4K */
993302Sagiri 
1003302Sagiri /* per session */
1013302Sagiri #define	RDS_MAX_DATA_RECV_BUFFERS	3000
1023302Sagiri #define	RDS_MAX_DATA_SEND_BUFFERS	2000
1033302Sagiri #define	RDS_MAX_CTRL_RECV_BUFFERS	100
1043302Sagiri #define	RDS_MAX_CTRL_SEND_BUFFERS	50
1053302Sagiri 
1063302Sagiri /* RQ low water mark in percentage. More RWR have to be posted */
1073302Sagiri #define	RDS_DATA_RECV_BUFFER_LWM	90
1083302Sagiri #define	RDS_CTRL_RECV_BUFFER_LWM	50
1093302Sagiri 
1103302Sagiri /*
1113302Sagiri  * High water mark in percentage of pkts pending on sockets.
1123302Sagiri  * Incoming traffic should be controlled or stopped for all sockets
1133302Sagiri  * or some sockets that are above their quota
1143302Sagiri  */
1153302Sagiri #define	RDS_PENDING_RX_PKTS_HWM	75
1163302Sagiri 
1173302Sagiri /*
1183302Sagiri  * Only interoperate with homogeneous Solaris (x32, x64, sparcv9).
1193302Sagiri  */
1203302Sagiri #if defined(__sparcv9)
1213302Sagiri #define	RDS_THIS_ARCH	1
1223302Sagiri #elif defined(__amd64)
1233302Sagiri #define	RDS_THIS_ARCH	2
1243302Sagiri #elif defined(__i386)
1253302Sagiri #define	RDS_THIS_ARCH	3
1263302Sagiri #else
1273302Sagiri #error "ISA not supported"
1283302Sagiri #endif
1293302Sagiri 
1303302Sagiri /*
1313302Sagiri  * CM Private Data
1323302Sagiri  *
1333302Sagiri  * This data is sent with the CM REQ message by the initiater of the
1343302Sagiri  * RC channel.
1353302Sagiri  *
1364804Sagiri  * cm_ip_pvt - ibt_ip_cm_info_t
1373302Sagiri  * version - RDS version
1383302Sagiri  * arch - only interoperate with homogeneous Solaris (x32, x64, sparcv9).
1393302Sagiri  * eptype - RDS_EP_TYPE_CTRL or RDS_EP_TYPE_DATA
1404804Sagiri  * failover - flag to indicate failover.
1414804Sagiri  * last_bufid - used during failover, indicates the last buffer the remote
1424804Sagiri  *     received.
1433302Sagiri  * user_buffer_size - Packet size on the sending node. This is also the size
1443302Sagiri  *     of the SGL buffer used in the send and receive WRs. This should be
1453302Sagiri  *     same size on the both active and passive nodes.
1464804Sagiri  * ack_rkey - RKEY for the RDMA acknowledgement buffer.
1474804Sagiri  * ack_addr - Registered MR address to receive RDMA acknowledgement.
1483302Sagiri  */
1493302Sagiri typedef struct rds_cm_private_data_s {
1504703Shiremath 	uint8_t		cmp_ip_pvt[IBT_IP_HDR_PRIV_DATA_SZ];
1513302Sagiri 	uint8_t		cmp_version;
1523302Sagiri 	uint8_t		cmp_arch;
1533302Sagiri 	uint8_t		cmp_eptype;
1543302Sagiri 	uint8_t		cmp_failover;
1553302Sagiri 	uintptr_t	cmp_last_bufid;
1563302Sagiri 	uint32_t	cmp_user_buffer_size;
1573302Sagiri 	ibt_rkey_t	cmp_ack_rkey;
1583302Sagiri 	uintptr_t	cmp_ack_addr;
1593302Sagiri } rds_cm_private_data_t;
1603302Sagiri 
1613302Sagiri /*
1623302Sagiri  * Data Header
1633302Sagiri  * This header is transmitted with every WR.
1643302Sagiri  *
1653302Sagiri  * bufid - Ponter to the send buffer that is used to send this packet.
1663302Sagiri  * datalen - Number of bytes of data (not including the header)
1673302Sagiri  * npkts - number of remaining pkts(including this one) for the message.
1683302Sagiri  *         It is set to 1 for single packet messages.
1693302Sagiri  * psn - Packet sequence number(starts at 0). Zero for single packet messages.
1703302Sagiri  * sendport - Port number of the sending socket
1713302Sagiri  * recvport - Port number of the receiving socket
1723302Sagiri  */
1733302Sagiri typedef struct rds_data_hdr_s {
1743302Sagiri 	uintptr_t		dh_bufid;
1753302Sagiri 	uint32_t		dh_datalen;
1763302Sagiri 	uint32_t		dh_npkts;
1773302Sagiri 	uint32_t		dh_psn;
1783302Sagiri 	in_port_t		dh_sendport;
1793302Sagiri 	in_port_t		dh_recvport;
1803302Sagiri } rds_data_hdr_t;
1813302Sagiri 
1823302Sagiri #define	RDS_DATA_HDR_SZ		sizeof (rds_data_hdr_t)
1833302Sagiri 
1843302Sagiri /*
1853302Sagiri  * List of control commands sent on a session:
1863302Sagiri  *
1873302Sagiri  * STALL: This command is sent to inform remote RDS that a port is stalled.
1883302Sagiri  *	  Always sent on all existing sessions.
1893302Sagiri  * UNSTALL: This command is sent to inform remote RDS that a port is unstalled.
1903302Sagiri  *	  Always sent on all existing sessions.
1913302Sagiri  * STALL_PORTS: Inform remote RDS that all local ports are stalled.
1923302Sagiri  * UNSTALL_PORTS: Inform remote RDS that all local ports are unstalled.
1933302Sagiri  * HEARTBEAT: Sent to check if the connection is still alive
1943302Sagiri  */
1953302Sagiri #define	RDS_CTRL_CODE_STALL		1
1963302Sagiri #define	RDS_CTRL_CODE_UNSTALL		2
1973302Sagiri #define	RDS_CTRL_CODE_STALL_PORTS	3
1983302Sagiri #define	RDS_CTRL_CODE_UNSTALL_PORTS	4
1993302Sagiri #define	RDS_CTRL_CODE_HEARTBEAT		5
200*8082SRamaswamy.Tummala@Sun.COM #define	RDS_CTRL_CODE_CLOSE_SESSION	6
2013302Sagiri 
2023302Sagiri /*
2033302Sagiri  * RDS ctrl packet
2043302Sagiri  *
2053302Sagiri  * port - Socket to be stalled/unstalled
2063302Sagiri  * code - STALL/UNSTALL (other codes are currently not used)
2073302Sagiri  */
2083302Sagiri 
2093302Sagiri typedef struct rds_ctrl_pkt_s {
2103302Sagiri 	uint16_t	rcp_port;
2113302Sagiri 	uint8_t		rcp_code;
2123302Sagiri } rds_ctrl_pkt_t;
2133302Sagiri 
2143302Sagiri #define	RDS_CTRLPKT_SIZE	sizeof (rds_ctrl_pkt_t)
2153302Sagiri 
2163302Sagiri #ifdef __cplusplus
2173302Sagiri }
2183302Sagiri #endif
2193302Sagiri 
2203302Sagiri #endif	/* _RDSIB_PROTOCOL_H */
221