xref: /titanic_41/usr/src/uts/common/sys/tpicommon.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_TPICOMMON_H
28 #define	_SYS_TPICOMMON_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/feature_tests.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * WARNING: This header should not ever be included directly by application
40  * programs. It exists so that common definitions can be included by other
41  * system header files which define a documented interface. The interfaces
42  * that share and expose the definitions in this file are:
43  *
44  *	(1) TLI interface <tiuser.h>  (which includes <sys/tiuser.h> which
45  *				   includes this file)
46  *	(2) XTI interface <xti.h>
47  *	(3) Kernel Streams TPI message based inteface <sys/tihdr.h>
48  */
49 
50 
51 /*
52  * The following are "t_errno" error codes needed by both the kernel
53  * level transport providers and the user level interfaces.
54  */
55 
56 #define	TBADADDR	1	/* Incorrect address format */
57 #define	TBADOPT		2	/* Incorrect options format */
58 #define	TACCES		3	/* Illegal permissions */
59 #define	TBADF		4	/* Illegal file descriptor */
60 #define	TNOADDR		5	/* Couldn't allocate address */
61 #define	TOUTSTATE	6	/* Routine will place interface out of state */
62 #define	TBADSEQ		7	/* Illegal called/calling sequence number */
63 #define	TSYSERR		8	/* System error */
64 #define	TLOOK		9	/* An event requires attention */
65 #define	TBADDATA	10	/* Illegal amount of data */
66 #define	TBUFOVFLW	11	/* Buffer not large enough */
67 #define	TFLOW		12	/* Can't send message - (blocked) */
68 #define	TNODATA		13	/* No message currently available */
69 #define	TNODIS		14	/* Disconnect message not found */
70 #define	TNOUDERR	15	/* Unitdata error message not found */
71 #define	TBADFLAG	16	/* Incorrect flags specified */
72 #define	TNOREL		17	/* Orderly release message not found */
73 #define	TNOTSUPPORT	18	/* Primitive not supported by provider */
74 #define	TSTATECHNG	19	/* State is in process of changing */
75 /*
76  * Following new error codes added to namespace with introduction of XTI
77  */
78 #define	TNOSTRUCTYPE	20	/* Unsupported structure type requested */
79 #define	TBADNAME	21	/* Invalid transport provider name */
80 #define	TBADQLEN	22	/* Listener queue length limit is zero */
81 #define	TADDRBUSY	23	/* Transport address is in use */
82 #define	TINDOUT		24	/* Outstanding connection indications */
83 #define	TPROVMISMATCH	25
84 			/* Listener-acceptor transport provider mismatch */
85 
86 #define	TRESQLEN	26
87 /* Connection acceptor has listen queue length limit greater than zero */
88 
89 #define	TRESADDR	27
90 /* Connection acceptor-listener addresses not same but required by transport */
91 
92 #define	TQFULL		28	/* Incoming connection queue is full */
93 #define	TPROTO		29	/* Protocol error on transport primitive */
94 
95 /*
96  * Service type defines - used with T_info_ack
97  */
98 #define	T_COTS	   1	/* connection oriented transport service	*/
99 #define	T_COTS_ORD 2	/* connection oriented w/ orderly release	*/
100 #define	T_CLTS	   3	/* connectionless transport service		*/
101 /*
102  * NOT FOR PUBLIC USE, Solaris internal only.
103  * This value of nc_semantics is strictly for use of Remote Direct
104  * Memory Access provider interfaces in Solaris only and not for
105  * general use. Do not use this value for general purpose user or
106  * kernel programming. If used the behavior is undefined.
107  * This is a PRIVATE interface to be used by Solaris kRPC only.
108  */
109 #define	T_RDMA	   4	/* rdma transport service			*/
110 
111 
112 /*
113  * The following are the flag definitions needed by the
114  * user level library routines.
115  */
116 
117 /*
118  * flags for option management request primitives
119  * Note:
120  * - This namespace is distinct from the namespace for data
121  *   primitives.
122  * - Flags T_NEGOTIATE, T_CHECK, T_DEFAULT, T_CURRENT
123  *   are associated with an option request
124  * - Flags T_SUCCESS, T_FAILURE, T_PARTSUCCESS, T_READONLY,
125  *   T_NOTSUPPORT are associated with results of option request.
126  */
127 #define	T_NEGOTIATE	0x004	/* set opts request	*/
128 #define	T_CHECK		0x008	/* check opts request	*/
129 #define	T_DEFAULT	0x010	/* get default opts request */
130 #define	T_SUCCESS	0x020	/* successful result */
131 #define	T_FAILURE	0x040	/* failure result */
132 #define	T_CURRENT	0x080	/* get current options request */
133 #define	T_PARTSUCCESS	0x100	/* partial success result */
134 #define	T_READONLY	0x200	/* read-only result */
135 #define	T_NOTSUPPORT	0x400	/* not supported result */
136 
137 
138 /*
139  * General purpose defines - used in multiple options context.
140  * They (T_YES and T_NO) need to be bitwise distinct from T_GARBAGE
141  * used with TCP level options by XTI for historical XTI specification
142  * reasons.
143  * (T_GARBAGE declared in <sys/xti_inet.h> included by <xti.h>).
144  */
145 #define	T_YES			1
146 #define	T_NO			0
147 
148 /*
149  * Values used with struct T_info_ack fields
150  */
151 #define	T_INFINITE		-1
152 #define	T_INVALID		-2
153 
154 /*
155  * Constants used with option management "name" or "value" fields.
156  */
157 
158 /*
159  * XTI defined value reserved for stating 'unspecified' value used
160  * in some option namespaces.
161  */
162 #define	T_UNSPEC	(~0-2)	/* applicable to ulong_t, long, char */
163 
164 /*
165  * XTI inspired option management defined an option name T_ALLOPT
166  * to imply all options of a certain level.
167  * No option name (for any level) should be defined with constant value of
168  * T_ALLOPT (0).
169  */
170 #define	T_ALLOPT	0	/* all options at any level */
171 
172 /*
173  * An option specification consists of an opthdr, followed by the value of
174  * the option.  An options buffer contains one or more options.  The len
175  * field of opthdr specifies the length of the option value in bytes.  This
176  * length must be a multiple of sizeof (t_scalar_t) (use OPTLEN macro).
177  * This is an antique definition which is used (unofficially) by TLI but
178  * superceded in XTI.
179  */
180 /*
181  * The opthdr types are now t_uscalar_t - inspired by XTI
182  */
183 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
184 struct opthdr {
185 	t_uscalar_t	level;	/* protocol level affected */
186 	t_uscalar_t	name;	/* option to modify */
187 	t_uscalar_t	len;	/* length of option value */
188 };
189 
190 #define	OPTLEN(x) ((((x) + sizeof (t_uscalar_t) - 1) / \
191 		    sizeof (t_uscalar_t)) * sizeof (t_uscalar_t))
192 #define	OPTVAL(opt) ((char *)(opt + 1))
193 #endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
194 
195 #ifdef	__cplusplus
196 }
197 #endif
198 
199 #endif	/* _SYS_TPICOMMON_H */
200