xref: /titanic_41/usr/src/uts/common/inet/tcp_impl.h (revision 500b1e787b108592a37e3d54dc9b5e676de5386d)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_TCP_IMPL_H
27 #define	_INET_TCP_IMPL_H
28 
29 /*
30  * TCP implementation private declarations.  These interfaces are
31  * used to build the IP module and are not meant to be accessed
32  * by any modules except IP itself.  They are undocumented and are
33  * subject to change without notice.
34  */
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #ifdef _KERNEL
41 
42 #include <inet/optcom.h>
43 #include <inet/tcp.h>
44 
45 #define	TCP_MOD_ID	5105
46 
47 /*
48  * Was this tcp created via socket() interface?
49  */
50 #define	TCP_IS_SOCKET(tcp)	((tcp)->tcp_issocket)
51 
52 /*
53  * Is this tcp not attached to any upper client?
54  */
55 #define	TCP_IS_DETACHED(tcp)	((tcp)->tcp_detached)
56 
57 #define	TCP_TIMER(tcp, f, tim)		\
58 	tcp_timeout(tcp->tcp_connp, f, tim)
59 #define	TCP_TIMER_CANCEL(tcp, id)	\
60 	tcp_timeout_cancel(tcp->tcp_connp, id)
61 
62 /*
63  * To restart the TCP retransmission timer.
64  */
65 #define	TCP_TIMER_RESTART(tcp, intvl) {					\
66 	if ((tcp)->tcp_timer_tid != 0)					\
67 		(void) TCP_TIMER_CANCEL((tcp), (tcp)->tcp_timer_tid);	\
68 	(tcp)->tcp_timer_tid = TCP_TIMER((tcp), tcp_timer,		\
69 	    MSEC_TO_TICK(intvl));					\
70 }
71 
72 /*
73  * Write-side flow-control is implemented via the per instance STREAMS
74  * write-side Q by explicitly setting QFULL to stop the flow of mblk_t(s)
75  * and clearing QFULL and calling qbackenable() to restart the flow based
76  * on the number of TCP unsent bytes (i.e. those not on the wire waiting
77  * for a remote ACK).
78  *
79  * This is different than a standard STREAMS kmod which when using the
80  * STREAMS Q the framework would automatictly flow-control based on the
81  * defined hiwat/lowat values as mblk_t's are enqueued/dequeued.
82  *
83  * As of FireEngine TCP write-side flow-control needs to take into account
84  * both the unsent tcp_xmit list bytes but also any squeue_t enqueued bytes
85  * (i.e. from tcp_wput() -> tcp_output()).
86  *
87  * This is accomplished by adding a new tcp_t fields, tcp_squeue_bytes, to
88  * count the number of bytes enqueued by tcp_wput() and the number of bytes
89  * dequeued and processed by tcp_output().
90  *
91  * So, the total number of bytes unsent is (squeue_bytes + unsent) with all
92  * flow-control uses of unsent replaced with the macro TCP_UNSENT_BYTES.
93  */
94 extern void	tcp_clrqfull(tcp_t *);
95 extern void	tcp_setqfull(tcp_t *);
96 
97 #define	TCP_UNSENT_BYTES(tcp) \
98 	((tcp)->tcp_squeue_bytes + (tcp)->tcp_unsent)
99 
100 /* Named Dispatch Parameter Management Structure */
101 typedef struct tcpparam_s {
102 	uint32_t	tcp_param_min;
103 	uint32_t	tcp_param_max;
104 	uint32_t	tcp_param_val;
105 	char		*tcp_param_name;
106 } tcpparam_t;
107 
108 
109 #define	tcps_time_wait_interval		tcps_params[0].tcp_param_val
110 #define	tcps_conn_req_max_q		tcps_params[1].tcp_param_val
111 #define	tcps_conn_req_max_q0		tcps_params[2].tcp_param_val
112 #define	tcps_conn_req_min		tcps_params[3].tcp_param_val
113 #define	tcps_conn_grace_period		tcps_params[4].tcp_param_val
114 #define	tcps_cwnd_max_			tcps_params[5].tcp_param_val
115 #define	tcps_dbg			tcps_params[6].tcp_param_val
116 #define	tcps_smallest_nonpriv_port	tcps_params[7].tcp_param_val
117 #define	tcps_ip_abort_cinterval		tcps_params[8].tcp_param_val
118 #define	tcps_ip_abort_linterval		tcps_params[9].tcp_param_val
119 #define	tcps_ip_abort_interval		tcps_params[10].tcp_param_val
120 #define	tcps_ip_notify_cinterval	tcps_params[11].tcp_param_val
121 #define	tcps_ip_notify_interval		tcps_params[12].tcp_param_val
122 #define	tcps_ipv4_ttl			tcps_params[13].tcp_param_val
123 #define	tcps_keepalive_interval_high	tcps_params[14].tcp_param_max
124 #define	tcps_keepalive_interval		tcps_params[14].tcp_param_val
125 #define	tcps_keepalive_interval_low	tcps_params[14].tcp_param_min
126 #define	tcps_maxpsz_multiplier		tcps_params[15].tcp_param_val
127 #define	tcps_mss_def_ipv4		tcps_params[16].tcp_param_val
128 #define	tcps_mss_max_ipv4		tcps_params[17].tcp_param_val
129 #define	tcps_mss_min			tcps_params[18].tcp_param_val
130 #define	tcps_naglim_def			tcps_params[19].tcp_param_val
131 #define	tcps_rexmit_interval_initial	tcps_params[20].tcp_param_val
132 #define	tcps_rexmit_interval_max	tcps_params[21].tcp_param_val
133 #define	tcps_rexmit_interval_min	tcps_params[22].tcp_param_val
134 #define	tcps_deferred_ack_interval	tcps_params[23].tcp_param_val
135 #define	tcps_snd_lowat_fraction		tcps_params[24].tcp_param_val
136 #define	tcps_dupack_fast_retransmit	tcps_params[25].tcp_param_val
137 #define	tcps_ignore_path_mtu		tcps_params[26].tcp_param_val
138 #define	tcps_smallest_anon_port		tcps_params[27].tcp_param_val
139 #define	tcps_largest_anon_port		tcps_params[28].tcp_param_val
140 #define	tcps_xmit_hiwat			tcps_params[29].tcp_param_val
141 #define	tcps_xmit_lowat			tcps_params[30].tcp_param_val
142 #define	tcps_recv_hiwat			tcps_params[31].tcp_param_val
143 #define	tcps_recv_hiwat_minmss		tcps_params[32].tcp_param_val
144 #define	tcps_fin_wait_2_flush_interval	tcps_params[33].tcp_param_val
145 #define	tcps_max_buf			tcps_params[34].tcp_param_val
146 #define	tcps_strong_iss			tcps_params[35].tcp_param_val
147 #define	tcps_rtt_updates		tcps_params[36].tcp_param_val
148 #define	tcps_wscale_always		tcps_params[37].tcp_param_val
149 #define	tcps_tstamp_always		tcps_params[38].tcp_param_val
150 #define	tcps_tstamp_if_wscale		tcps_params[39].tcp_param_val
151 #define	tcps_rexmit_interval_extra	tcps_params[40].tcp_param_val
152 #define	tcps_deferred_acks_max		tcps_params[41].tcp_param_val
153 #define	tcps_slow_start_after_idle	tcps_params[42].tcp_param_val
154 #define	tcps_slow_start_initial		tcps_params[43].tcp_param_val
155 #define	tcps_sack_permitted		tcps_params[44].tcp_param_val
156 #define	tcps_ipv6_hoplimit		tcps_params[45].tcp_param_val
157 #define	tcps_mss_def_ipv6		tcps_params[46].tcp_param_val
158 #define	tcps_mss_max_ipv6		tcps_params[47].tcp_param_val
159 #define	tcps_rev_src_routes		tcps_params[48].tcp_param_val
160 #define	tcps_local_dack_interval	tcps_params[49].tcp_param_val
161 #define	tcps_local_dacks_max		tcps_params[50].tcp_param_val
162 #define	tcps_ecn_permitted		tcps_params[51].tcp_param_val
163 #define	tcps_rst_sent_rate_enabled	tcps_params[52].tcp_param_val
164 #define	tcps_rst_sent_rate		tcps_params[53].tcp_param_val
165 #define	tcps_push_timer_interval	tcps_params[54].tcp_param_val
166 #define	tcps_use_smss_as_mss_opt	tcps_params[55].tcp_param_val
167 #define	tcps_keepalive_abort_interval_high	tcps_params[56].tcp_param_max
168 #define	tcps_keepalive_abort_interval		tcps_params[56].tcp_param_val
169 #define	tcps_keepalive_abort_interval_low	tcps_params[56].tcp_param_min
170 #define	tcps_dev_flow_ctl		tcps_params[57].tcp_param_val
171 #define	tcps_reass_timeout		tcps_params[58].tcp_param_val
172 
173 extern struct qinit tcp_rinitv4, tcp_rinitv6;
174 extern boolean_t do_tcp_fusion;
175 
176 extern int	tcp_maxpsz_set(tcp_t *, boolean_t);
177 extern void	tcp_timers_stop(tcp_t *);
178 extern void	tcp_rcv_enqueue(tcp_t *, mblk_t *, uint_t, cred_t *);
179 extern void	tcp_push_timer(void *);
180 extern timeout_id_t tcp_timeout(conn_t *, void (*)(void *), clock_t);
181 extern clock_t	tcp_timeout_cancel(conn_t *, timeout_id_t);
182 
183 extern void	tcp_fuse(tcp_t *, uchar_t *, tcpha_t *);
184 extern void	tcp_unfuse(tcp_t *);
185 extern boolean_t tcp_fuse_output(tcp_t *, mblk_t *, uint32_t);
186 extern void	tcp_fuse_output_urg(tcp_t *, mblk_t *);
187 extern boolean_t tcp_fuse_rcv_drain(queue_t *, tcp_t *, mblk_t **);
188 extern size_t	tcp_fuse_set_rcv_hiwat(tcp_t *, size_t);
189 extern int	tcp_fuse_maxpsz(tcp_t *);
190 extern void	tcp_fuse_backenable(tcp_t *);
191 extern int	tcp_rwnd_set(tcp_t *, uint32_t);
192 
193 /*
194  * Object to represent database of options to search passed to
195  * {sock,tpi}optcom_req() interface routine to take care of option
196  * management and associated methods.
197  */
198 extern optdb_obj_t	tcp_opt_obj;
199 extern uint_t		tcp_max_optsize;
200 
201 extern sock_lower_handle_t tcp_create(int, int, int, sock_downcalls_t **,
202     uint_t *, int *, int, cred_t *);
203 extern int tcp_fallback(sock_lower_handle_t, queue_t *, boolean_t,
204     so_proto_quiesced_cb_t);
205 
206 extern sock_downcalls_t sock_tcp_downcalls;
207 
208 
209 extern int	tcp_opt_default(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
210 extern int	tcp_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
211 extern int	tcp_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *,
212 		    uint_t *, uchar_t *, void *, cred_t *);
213 
214 #endif	/* _KERNEL */
215 
216 #ifdef	__cplusplus
217 }
218 #endif
219 
220 #endif	/* _INET_TCP_IMPL_H */
221