xref: /titanic_50/usr/src/lib/libbc/inc/include/nettli/tcp_tlivar.h (revision 5d54f3d8999eac1762fe0a8c7177d20f1f201fae)
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 /*
24  * Copyright 1988 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_TCP_TLIVAR_
29 #define	_TCP_TLIVAR_
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 /*
34  * Data structure definitions for the streams interface
35  * to the socket-based TCP implementation.
36  */
37 
38 /*
39  * Socket Information block contains the special socket wakeup
40  * hooks. When a block of tt_sockinfo is allocated, the wupalt.wup_arg
41  * points to the beginning of tt_sockinfo.
42  */
43 
44 struct tt_sockinfo {
45 	struct	wupalt	ts_sowakeup;	/* special sock wakeup hook */
46 	u_long		ts_seqnum;	/* connection sequence number */
47 	long		ts_flags;	/* see below */
48 	struct tt_softc *ts_ttp;	/* back ptr to dev-instance handle */
49 };
50 /*
51  * No connection assoicated with this socket
52  */
53 #define	TT_TS_NOTUSED	0x00
54 /*
55  * This socket is connected or pending connection
56  */
57 #define	TT_TS_INUSE	0x01
58 
59 /*
60  * Per-device instance state information.
61  *
62  * To aid in handling resource starvation situations, we pre-allocate two
63  * messages for reporting errors.  Tt_merror is used as a last resort, when
64  * attempts to allocate a normal error reply fail.  It's allocated in the
65  * open routine and freed in the close routine.  The routines that produce
66  * response messages try to keep tt_errack pre-allocated, but don't insist
67  * that it always be valid.  This strategy attempts to minimize the
68  * probability of having to fall back on the drastic measure of using the
69  * M_ERROR message.
70  */
71 struct tt_softc {
72 	/* The tt_unit & tt_unitnext fields aren't yet used. */
73 	struct tt_softc	*tt_next;	/* link to next device instance */
74 	u_short		tt_unit;	/* instance number */
75 	u_short		tt_unitnext;	/* next unit # to be used on open */
76 
77 	queue_t		*tt_rq;		/* cross-link to read queue */
78 	struct socket	*tt_so;		/* socket for this device instance */
79 	mblk_t		*tt_merror;	/* pre-allocated M_ERROR message */
80 	mblk_t		*tt_errack;	/* pre-allocated T_error_ack message */
81 	u_int		tt_state;	/* current state of the tli automaton */
82 	long		tt_seqnext;	/* next sequence number to assign */
83 	u_long		tt_flags;	/* see below */
84 	u_long		tt_event;	/* service event inidication */
85 	struct	proc	*tt_auxprocp;	/* Aux proc handle */
86 	struct	in_addr	tt_laddr;	/* saved local address */
87 	u_short		tt_lport;	/* saved local port number */
88 };
89 
90 /*
91  * Flag (tt_flags) bits private to the driver.
92  */
93 #define	TT_OPEN		0x01	/* device instance is currently open */
94 #define	TT_ERROR	0x02	/* in error state -- unusable */
95 #define	TT_CLOSE	0x04	/* this device instance is closed */
96 #define	TT_TIMER	0x08	/* scheduled wakeup timer is already set */
97 /*
98  * Event (tt_event) bits private to the driver.
99  */
100 #define	TTE_EVENT	0x01	/* aux proc service wanted indication */
101 #define	TTE_ONQUEUE	0x02	/* set if this ttp has wakeup-event pending */
102 
103 /*
104  * Internet style address for TLI
105  */
106 struct	taddr_in {
107 	short   sin_family;
108 	u_short sin_port;
109 	struct  in_addr sin_addr;
110 };
111 
112 /*
113  * For use with direct-read only
114  *  when:
115  *    - TI is in the correct state
116  *    - there are data to be read
117  *    - socket is in state to receive
118  *    - socket buffer not locked (we are running this
119  *            at interrupt level !)
120  *    - the auxproc is not running
121  */
122 #define	TT_DIRECT_READ(ttp, so) { \
123 	extern int tcptli_auxproc_running; \
124 	if (((ttp)->tt_state & TL_DATAXFER) && \
125 		((so)->so_rcv.sb_cc != 0) && \
126 		(!((so)->so_state & SS_CANTRCVMORE)) && \
127 		(!((so)->so_rcv.sb_flags & SB_LOCK)) && \
128 		(!tcptli_auxproc_running)) \
129 		if (tcptli_Ercv((ttp))) \
130 			return; \
131 }
132 
133 #ifdef	TLIDEBUG
134 extern	tcptli_debug;
135 #define	TCPTLI_PRINTF if (tcptli_debug) printf
136 #else
137 #define	TCPTLI_PRINTF
138 #endif	/* TLIDEBUG */
139 
140 #endif	/* _TCP_TLIVAR_ */
141