xref: /illumos-gate/usr/src/uts/common/sys/ib/mgt/ibmf/ibmf_rmpp.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
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 /*
31  * This file contains the IBMF RMPP implementation dependent structures
32  * and defines.
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /* The RMPP context */
40 typedef struct _ibmf_rmpp_ctx_t {
41 	uint32_t		rmpp_wf;  /* first segment in window (send) */
42 	uint32_t		rmpp_wl;  /* last segment in window (send) */
43 	uint32_t		rmpp_ns;  /* next segment in window (send) */
44 	uint32_t		rmpp_es;  /* expected segment num (receive) */
45 	uint32_t		rmpp_is_ds;	/* direction change indicator */
46 	uint32_t		rmpp_nwl;	/* new window last */
47 	uint32_t		rmpp_pyld_len;	/* payload length */
48 	uint32_t		rmpp_state;	/* rmpp protocol state */
49 	uint32_t		rmpp_retry_cnt; /* retry count */
50 	uint32_t		rmpp_pkt_data_sz; /* data size in packet */
51 	uint32_t		rmpp_last_pkt_sz; /* data size in last packet */
52 	uint32_t		rmpp_num_pkts;	/* number of packets needed */
53 	size_t			rmpp_data_offset; /* offset in data buffer */
54 	uint32_t		rmpp_word3;	/* 3rd word of RMPP hdr */
55 	uint32_t		rmpp_word4;	/* 4th word of RMPP hdr */
56 	uint8_t			rmpp_type;	/* type of RMPP packet */
57 	uint8_t			rmpp_respt;	/* resp time for RMPP packet */
58 	uint8_t			rmpp_flags;	/* rmpp flags */
59 	uint8_t			rmpp_status;	/* status for RMPP packet */
60 } ibmf_rmpp_ctx_t;
61 
62 /* RMPP state definitions */
63 #define	IBMF_RMPP_STATE_UNDEFINED		0
64 #define	IBMF_RMPP_STATE_SENDER_ACTIVE		1
65 #define	IBMF_RMPP_STATE_SENDER_SWITCH		2
66 #define	IBMF_RMPP_STATE_RECEVR_ACTIVE		3
67 #define	IBMF_RMPP_STATE_RECEVR_TERMINATE	4
68 #define	IBMF_RMPP_STATE_ABORT			5
69 #define	IBMF_RMPP_STATE_DONE			6
70 
71 /* RMPP context flags definition */
72 #define	IBMF_CTX_RMPP_FLAGS_DYN_PYLD		8
73 
74 #define	IBMF_RMPP_DEFAULT_RRESPT		0x1F
75 #define	IBMF_RMPP_TERM_RRESPT			0xE
76 
77 #define	IBMF_RMPP_METHOD_RESP_BIT		0x80
78 
79 /* RMPP header (IB Architecture Specification 1.1, Section 13.6.2) */
80 #if defined(_BIT_FIELDS_HTOL)
81 typedef struct _ibmf_rmpp_hdr_t {
82 	uint8_t			rmpp_version;		/* RMPP version = 1 */
83 	uint8_t			rmpp_type;		/* RMPP packet type */
84 	uint8_t			rmpp_resp_time	:5;	/* response time val */
85 	uint8_t			rmpp_flags	:3;	/* RMPP flags */
86 	uint8_t			rmpp_status;		/* RMPP status */
87 
88 	uint32_t		rmpp_segnum;		/* packet ID */
89 
90 	/* Payload len for data or, NewWindowLast for ack packets */
91 	uint32_t		rmpp_pyldlen_nwl;
92 } ibmf_rmpp_hdr_t;
93 #else
94 typedef struct _ibmf_rmpp_hdr_t {
95 	uint8_t			rmpp_version;		/* RMPP version = 1 */
96 	uint8_t			rmpp_type;		/* RMPP packet type */
97 	uint8_t			rmpp_flags	:3;	/* RMPP flags */
98 	uint8_t			rmpp_resp_time	:5;	/* response time val */
99 	uint8_t			rmpp_status;		/* RMPP status */
100 
101 	uint32_t		rmpp_segnum;		/* packet ID */
102 
103 	/* Payload len for data or, NewWindowLast for ack packets */
104 	uint32_t		rmpp_pyldlen_nwl;
105 } ibmf_rmpp_hdr_t;
106 #endif
107 
108 _NOTE(READ_ONLY_DATA(ibmf_rmpp_hdr_t))
109 
110 /* RMPP header type definitions */
111 #define	IBMF_RMPP_TYPE_NONE		0
112 #define	IBMF_RMPP_TYPE_DATA		1
113 #define	IBMF_RMPP_TYPE_ACK		2
114 #define	IBMF_RMPP_TYPE_STOP		3
115 #define	IBMF_RMPP_TYPE_ABORT		4
116 
117 /* RMPP header flags definitions */
118 #define	IBMF_RMPP_FLAGS_ACTIVE		0x1
119 #define	IBMF_RMPP_FLAGS_FIRST_PKT	0x2
120 #define	IBMF_RMPP_FLAGS_LAST_PKT	0x4
121 
122 /* RMPP_header status definitions */
123 #define	IBMF_RMPP_STATUS_NORMAL		0	/* Normal */
124 #define	IBMF_RMPP_STATUS_RESX		1	/* Resources exhausted */
125 #define	IBMF_RMPP_STATUS_T2L		118	/* Total time too long */
126 
127 /* Inconsistent last and payload length */
128 #define	IBMF_RMPP_STATUS_ILPL		119
129 
130 /* Inconsistent first and segment number */
131 #define	IBMF_RMPP_STATUS_IFSN		120
132 
133 #define	IBMF_RMPP_STATUS_BADT		121	/* Bad RMPP type */
134 #define	IBMF_RMPP_STATUS_W2S		122	/* New window last too small */
135 #define	IBMF_RMPP_STATUS_S2B		123	/* Segment number too big */
136 #define	IBMF_RMPP_STATUS_IS		124	/* Illegal status */
137 #define	IBMF_RMPP_STATUS_UNV		125	/* Unsupported version */
138 #define	IBMF_RMPP_STATUS_TMR		126	/* Too many retries */
139 #define	IBMF_RMPP_STATUS_USP		127	/* Unspecified error */
140 
141 #define	IBMF_RMPP_VERSION		1
142 #define	IBMF_RMPP_DEFAULT_WIN_SZ	5
143 #define	IBMF_NO_BLOCK			0
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* _SYS_IB_MGT_IBMF_IBMF_RMPP_H */
150