xref: /titanic_52/usr/src/uts/common/sys/ib/mgt/ibmf/ibmf_rmpp.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_IB_MGT_IBMF_IBMF_RMPP_H
28 #define	_SYS_IB_MGT_IBMF_IBMF_RMPP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * This file contains the IBMF RMPP implementation dependent structures
34  * and defines.
35  */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /* The RMPP context */
42 typedef struct _ibmf_rmpp_ctx_t {
43 	uint32_t		rmpp_wf;  /* first segment in window (send) */
44 	uint32_t		rmpp_wl;  /* last segment in window (send) */
45 	uint32_t		rmpp_ns;  /* next segment in window (send) */
46 	uint32_t		rmpp_es;  /* expected segment num (receive) */
47 	uint32_t		rmpp_is_ds;	/* direction change indicator */
48 	uint32_t		rmpp_nwl;	/* new window last */
49 	uint32_t		rmpp_pyld_len;	/* payload length */
50 	uint32_t		rmpp_state;	/* rmpp protocol state */
51 	uint32_t		rmpp_retry_cnt; /* retry count */
52 	uint32_t		rmpp_pkt_data_sz; /* data size in packet */
53 	uint32_t		rmpp_last_pkt_sz; /* data size in last packet */
54 	uint32_t		rmpp_num_pkts;	/* number of packets needed */
55 	size_t			rmpp_data_offset; /* offset in data buffer */
56 	uint32_t		rmpp_word3;	/* 3rd word of RMPP hdr */
57 	uint32_t		rmpp_word4;	/* 4th word of RMPP hdr */
58 	uint8_t			rmpp_type;	/* type of RMPP packet */
59 	uint8_t			rmpp_respt;	/* resp time for RMPP packet */
60 	uint8_t			rmpp_flags;	/* rmpp flags */
61 	uint8_t			rmpp_status;	/* status for RMPP packet */
62 } ibmf_rmpp_ctx_t;
63 
64 /* RMPP state definitions */
65 #define	IBMF_RMPP_STATE_UNDEFINED		0
66 #define	IBMF_RMPP_STATE_SENDER_ACTIVE		1
67 #define	IBMF_RMPP_STATE_SENDER_SWITCH		2
68 #define	IBMF_RMPP_STATE_RECEVR_ACTIVE		3
69 #define	IBMF_RMPP_STATE_RECEVR_TERMINATE	4
70 #define	IBMF_RMPP_STATE_ABORT			5
71 #define	IBMF_RMPP_STATE_DONE			6
72 
73 /* RMPP context flags definition */
74 #define	IBMF_CTX_RMPP_FLAGS_DYN_PYLD		8
75 
76 #define	IBMF_RMPP_DEFAULT_RRESPT		0x1F
77 #define	IBMF_RMPP_TERM_RRESPT			0xE
78 
79 #define	IBMF_RMPP_METHOD_RESP_BIT		0x80
80 
81 /* RMPP header (IB Architecture Specification 1.1, Section 13.6.2) */
82 #if defined(_BIT_FIELDS_HTOL)
83 typedef struct _ibmf_rmpp_hdr_t {
84 	uint8_t			rmpp_version;		/* RMPP version = 1 */
85 	uint8_t			rmpp_type;		/* RMPP packet type */
86 	uint8_t			rmpp_resp_time	:5;	/* response time val */
87 	uint8_t			rmpp_flags	:3;	/* RMPP flags */
88 	uint8_t			rmpp_status;		/* RMPP status */
89 
90 	uint32_t		rmpp_segnum;		/* packet ID */
91 
92 	/* Payload len for data or, NewWindowLast for ack packets */
93 	uint32_t		rmpp_pyldlen_nwl;
94 } ibmf_rmpp_hdr_t;
95 #else
96 typedef struct _ibmf_rmpp_hdr_t {
97 	uint8_t			rmpp_version;		/* RMPP version = 1 */
98 	uint8_t			rmpp_type;		/* RMPP packet type */
99 	uint8_t			rmpp_flags	:3;	/* RMPP flags */
100 	uint8_t			rmpp_resp_time	:5;	/* response time val */
101 	uint8_t			rmpp_status;		/* RMPP status */
102 
103 	uint32_t		rmpp_segnum;		/* packet ID */
104 
105 	/* Payload len for data or, NewWindowLast for ack packets */
106 	uint32_t		rmpp_pyldlen_nwl;
107 } ibmf_rmpp_hdr_t;
108 #endif
109 
110 _NOTE(READ_ONLY_DATA(ibmf_rmpp_hdr_t))
111 
112 /* RMPP header type definitions */
113 #define	IBMF_RMPP_TYPE_NONE		0
114 #define	IBMF_RMPP_TYPE_DATA		1
115 #define	IBMF_RMPP_TYPE_ACK		2
116 #define	IBMF_RMPP_TYPE_STOP		3
117 #define	IBMF_RMPP_TYPE_ABORT		4
118 
119 /* RMPP header flags definitions */
120 #define	IBMF_RMPP_FLAGS_ACTIVE		0x1
121 #define	IBMF_RMPP_FLAGS_FIRST_PKT	0x2
122 #define	IBMF_RMPP_FLAGS_LAST_PKT	0x4
123 
124 /* RMPP_header status definitions */
125 #define	IBMF_RMPP_STATUS_NORMAL		0	/* Normal */
126 #define	IBMF_RMPP_STATUS_RESX		1	/* Resources exhausted */
127 #define	IBMF_RMPP_STATUS_T2L		118	/* Total time too long */
128 
129 /* Inconsistent last and payload length */
130 #define	IBMF_RMPP_STATUS_ILPL		119
131 
132 /* Inconsistent first and segment number */
133 #define	IBMF_RMPP_STATUS_IFSN		120
134 
135 #define	IBMF_RMPP_STATUS_BADT		121	/* Bad RMPP type */
136 #define	IBMF_RMPP_STATUS_W2S		122	/* New window last too small */
137 #define	IBMF_RMPP_STATUS_S2B		123	/* Segment number too big */
138 #define	IBMF_RMPP_STATUS_IS		124	/* Illegal status */
139 #define	IBMF_RMPP_STATUS_UNV		125	/* Unsupported version */
140 #define	IBMF_RMPP_STATUS_TMR		126	/* Too many retries */
141 #define	IBMF_RMPP_STATUS_USP		127	/* Unspecified error */
142 
143 #define	IBMF_RMPP_VERSION		1
144 #define	IBMF_RMPP_DEFAULT_WIN_SZ	5
145 #define	IBMF_NO_BLOCK			0
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* _SYS_IB_MGT_IBMF_IBMF_RMPP_H */
152