xref: /titanic_50/usr/src/uts/common/inet/sctp/sctp_stack.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
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 /*
23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef	_INET_SCTP_SCTP_STACK_H
27 #define	_INET_SCTP_SCTP_STACK_H
28 
29 #include <sys/netstack.h>
30 #include <sys/taskq.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /* SCTP kstat */
37 typedef struct sctp_kstat_s {
38 	kstat_named_t	sctp_add_faddr;
39 	kstat_named_t	sctp_add_timer;
40 	kstat_named_t	sctp_conn_create;
41 	kstat_named_t	sctp_find_next_tq;
42 	kstat_named_t	sctp_fr_add_hdr;
43 	kstat_named_t	sctp_fr_not_found;
44 	kstat_named_t	sctp_output_failed;
45 	kstat_named_t	sctp_rexmit_failed;
46 	kstat_named_t	sctp_send_init_failed;
47 	kstat_named_t	sctp_send_cookie_failed;
48 	kstat_named_t	sctp_send_cookie_ack_failed;
49 	kstat_named_t	sctp_send_err_failed;
50 	kstat_named_t	sctp_send_sack_failed;
51 	kstat_named_t	sctp_send_shutdown_failed;
52 	kstat_named_t	sctp_send_shutdown_ack_failed;
53 	kstat_named_t	sctp_send_shutdown_comp_failed;
54 	kstat_named_t	sctp_send_user_abort_failed;
55 	kstat_named_t	sctp_send_asconf_failed;
56 	kstat_named_t	sctp_send_asconf_ack_failed;
57 	kstat_named_t	sctp_send_ftsn_failed;
58 	kstat_named_t	sctp_send_hb_failed;
59 	kstat_named_t	sctp_return_hb_failed;
60 	kstat_named_t	sctp_ss_rexmit_failed;
61 	kstat_named_t	sctp_cl_connect;
62 	kstat_named_t	sctp_cl_assoc_change;
63 	kstat_named_t	sctp_cl_check_addrs;
64 	kstat_named_t	sctp_reclaim_cnt;
65 	kstat_named_t	sctp_listen_cnt_drop;
66 } sctp_kstat_t;
67 
68 /*
69  * This struct contains only the counter part of sctp_kstat_t.  It is used
70  * in sctp_stats_cpu_t instead of sctp_kstat_t to save memory space.
71  */
72 typedef struct sctp_kstat_counter_s {
73 	uint64_t	sctp_add_faddr;
74 	uint64_t	sctp_add_timer;
75 	uint64_t	sctp_conn_create;
76 	uint64_t	sctp_find_next_tq;
77 	uint64_t	sctp_fr_add_hdr;
78 	uint64_t	sctp_fr_not_found;
79 	uint64_t	sctp_output_failed;
80 	uint64_t	sctp_rexmit_failed;
81 	uint64_t	sctp_send_init_failed;
82 	uint64_t	sctp_send_cookie_failed;
83 	uint64_t	sctp_send_cookie_ack_failed;
84 	uint64_t	sctp_send_err_failed;
85 	uint64_t	sctp_send_sack_failed;
86 	uint64_t	sctp_send_shutdown_failed;
87 	uint64_t	sctp_send_shutdown_ack_failed;
88 	uint64_t	sctp_send_shutdown_comp_failed;
89 	uint64_t	sctp_send_user_abort_failed;
90 	uint64_t	sctp_send_asconf_failed;
91 	uint64_t	sctp_send_asconf_ack_failed;
92 	uint64_t	sctp_send_ftsn_failed;
93 	uint64_t	sctp_send_hb_failed;
94 	uint64_t	sctp_return_hb_failed;
95 	uint64_t	sctp_ss_rexmit_failed;
96 	uint64_t	sctp_cl_connect;
97 	uint64_t	sctp_cl_assoc_change;
98 	uint64_t	sctp_cl_check_addrs;
99 	uint64_t	sctp_reclaim_cnt;
100 	uint64_t	sctp_listen_cnt_drop;
101 } sctp_kstat_counter_t;
102 
103 /* Per CPU SCTP statistics counters. */
104 typedef struct {
105 	int64_t			sctp_sc_assoc_cnt;
106 	mib2_sctp_t		sctp_sc_mib;
107 	sctp_kstat_counter_t	sctp_sc_stats;
108 } sctp_stats_cpu_t;
109 
110 #define	SCTP_KSTAT(sctps, x)		\
111 	((sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_stats.x++)
112 
113 #define	SCTPS_BUMP_MIB(sctps, x)	\
114 	BUMP_MIB(&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_mib, x)
115 
116 #define	SCTPS_UPDATE_MIB(sctps, x, y)	\
117 	UPDATE_MIB(&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_mib, x, y)
118 
119 /*
120  * SCTP stack instances
121  */
122 struct sctp_stack {
123 	netstack_t	*sctps_netstack;	/* Common netstack */
124 
125 	/* Protected by sctps_g_lock */
126 	struct list	sctps_g_list;	/* SCTP instance data chain */
127 	kmutex_t	sctps_g_lock;
128 
129 #define	SCTP_NUM_EPRIV_PORTS	64
130 	int		sctps_g_num_epriv_ports;
131 	in_port_t	sctps_g_epriv_ports[SCTP_NUM_EPRIV_PORTS];
132 	kmutex_t	sctps_epriv_port_lock;
133 	uint_t		sctps_next_port_to_try;
134 
135 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
136 	struct sctp_tf_s	*sctps_bind_fanout;
137 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
138 	struct sctp_tf_s	*sctps_listen_fanout;
139 	struct sctp_tf_s	*sctps_conn_fanout;
140 	uint_t			sctps_conn_hash_size;
141 
142 	/* holds sctp tunables */
143 	struct mod_prop_info_s	*sctps_propinfo_tbl;
144 
145 	/*
146 	 * This lock protects the SCTP recvq_tq_list array and
147 	 * recvq_tq_list_cur_sz.
148 	 */
149 	kmutex_t		sctps_rq_tq_lock;
150 	int			sctps_recvq_tq_list_max_sz;
151 	taskq_t			**sctps_recvq_tq_list;
152 
153 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
154 	uint32_t		sctps_recvq_tq_list_cur_sz;
155 	uint32_t		sctps_recvq_tq_list_cur;
156 
157 	/* Global list of SCTP ILLs */
158 	struct sctp_ill_hash_s	*sctps_g_ills;
159 	uint32_t		sctps_ills_count;
160 	krwlock_t		sctps_g_ills_lock;
161 
162 	/* Global list of SCTP IPIFs */
163 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
164 	uint32_t		sctps_g_ipifs_count;
165 	krwlock_t		sctps_g_ipifs_lock;
166 
167 	/* kstat exporting mib2_sctp_t and sctp_kstat_t data */
168 	kstat_t			*sctps_mibkp;
169 	kstat_t			*sctps_kstat;
170 
171 	/* Variables for handling kmem reclaim call back. */
172 	kmutex_t	sctps_reclaim_lock;
173 	boolean_t	sctps_reclaim;
174 	timeout_id_t	sctps_reclaim_tid;
175 	uint32_t	sctps_reclaim_period;
176 
177 	/* Listener association limit configuration. */
178 	kmutex_t	sctps_listener_conf_lock;
179 	list_t		sctps_listener_conf;
180 
181 	/*
182 	 * Per CPU stats
183 	 *
184 	 * sctps_sc: array of pointer to per CPU stats.  The i-th element in
185 	 *   the array represents the stats of the CPU with cpu_seqid.
186 	 * sctps_sc_cnt: number of CPU stats in the sctps_sc array.
187 	 */
188 	sctp_stats_cpu_t	**sctps_sc;
189 	int			sctps_sc_cnt;
190 };
191 
192 typedef struct sctp_stack sctp_stack_t;
193 
194 #ifdef	__cplusplus
195 }
196 #endif
197 
198 #endif	/* _INET_SCTP_SCTP_STACK_H */
199