xref: /onnv-gate/usr/src/uts/common/inet/sctp/sctp_stack.h (revision 12869:fb36eaeb6ee0)
13448Sdh155122 /*
23448Sdh155122  * CDDL HEADER START
33448Sdh155122  *
43448Sdh155122  * The contents of this file are subject to the terms of the
53448Sdh155122  * Common Development and Distribution License (the "License").
63448Sdh155122  * You may not use this file except in compliance with the License.
73448Sdh155122  *
83448Sdh155122  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93448Sdh155122  * or http://www.opensolaris.org/os/licensing.
103448Sdh155122  * See the License for the specific language governing permissions
113448Sdh155122  * and limitations under the License.
123448Sdh155122  *
133448Sdh155122  * When distributing Covered Code, include this CDDL HEADER in each
143448Sdh155122  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153448Sdh155122  * If applicable, add the following below this CDDL HEADER, with the
163448Sdh155122  * fields enclosed by brackets "[]" replaced with your own identifying
173448Sdh155122  * information: Portions Copyright [yyyy] [name of copyright owner]
183448Sdh155122  *
193448Sdh155122  * CDDL HEADER END
203448Sdh155122  */
213448Sdh155122 
223448Sdh155122 /*
23*12869SKacheong.Poon@Sun.COM  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
243448Sdh155122  */
253448Sdh155122 
263448Sdh155122 #ifndef	_INET_SCTP_SCTP_STACK_H
273448Sdh155122 #define	_INET_SCTP_SCTP_STACK_H
283448Sdh155122 
293448Sdh155122 #include <sys/netstack.h>
306220Syz147064 #include <sys/taskq.h>
313448Sdh155122 
323448Sdh155122 #ifdef	__cplusplus
333448Sdh155122 extern "C" {
343448Sdh155122 #endif
353448Sdh155122 
363448Sdh155122 /* SCTP kstat */
373448Sdh155122 typedef struct sctp_kstat_s {
383448Sdh155122 	kstat_named_t	sctp_add_faddr;
393448Sdh155122 	kstat_named_t	sctp_add_timer;
403448Sdh155122 	kstat_named_t	sctp_conn_create;
413448Sdh155122 	kstat_named_t	sctp_find_next_tq;
423448Sdh155122 	kstat_named_t	sctp_fr_add_hdr;
433448Sdh155122 	kstat_named_t	sctp_fr_not_found;
443448Sdh155122 	kstat_named_t	sctp_output_failed;
453448Sdh155122 	kstat_named_t	sctp_rexmit_failed;
463448Sdh155122 	kstat_named_t	sctp_send_init_failed;
473448Sdh155122 	kstat_named_t	sctp_send_cookie_failed;
483448Sdh155122 	kstat_named_t	sctp_send_cookie_ack_failed;
493448Sdh155122 	kstat_named_t	sctp_send_err_failed;
503448Sdh155122 	kstat_named_t	sctp_send_sack_failed;
513448Sdh155122 	kstat_named_t	sctp_send_shutdown_failed;
523448Sdh155122 	kstat_named_t	sctp_send_shutdown_ack_failed;
533448Sdh155122 	kstat_named_t	sctp_send_shutdown_comp_failed;
543448Sdh155122 	kstat_named_t	sctp_send_user_abort_failed;
553448Sdh155122 	kstat_named_t	sctp_send_asconf_failed;
563448Sdh155122 	kstat_named_t	sctp_send_asconf_ack_failed;
573448Sdh155122 	kstat_named_t	sctp_send_ftsn_failed;
583448Sdh155122 	kstat_named_t	sctp_send_hb_failed;
593448Sdh155122 	kstat_named_t	sctp_return_hb_failed;
603448Sdh155122 	kstat_named_t	sctp_ss_rexmit_failed;
613448Sdh155122 	kstat_named_t	sctp_cl_connect;
623448Sdh155122 	kstat_named_t	sctp_cl_assoc_change;
633448Sdh155122 	kstat_named_t	sctp_cl_check_addrs;
64*12869SKacheong.Poon@Sun.COM 	kstat_named_t	sctp_reclaim_cnt;
65*12869SKacheong.Poon@Sun.COM 	kstat_named_t	sctp_listen_cnt_drop;
663448Sdh155122 } sctp_kstat_t;
673448Sdh155122 
68*12869SKacheong.Poon@Sun.COM /*
69*12869SKacheong.Poon@Sun.COM  * This struct contains only the counter part of sctp_kstat_t.  It is used
70*12869SKacheong.Poon@Sun.COM  * in sctp_stats_cpu_t instead of sctp_kstat_t to save memory space.
71*12869SKacheong.Poon@Sun.COM  */
72*12869SKacheong.Poon@Sun.COM typedef struct sctp_kstat_counter_s {
73*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_add_faddr;
74*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_add_timer;
75*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_conn_create;
76*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_find_next_tq;
77*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_fr_add_hdr;
78*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_fr_not_found;
79*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_output_failed;
80*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_rexmit_failed;
81*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_init_failed;
82*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_cookie_failed;
83*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_cookie_ack_failed;
84*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_err_failed;
85*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_sack_failed;
86*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_shutdown_failed;
87*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_shutdown_ack_failed;
88*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_shutdown_comp_failed;
89*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_user_abort_failed;
90*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_asconf_failed;
91*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_asconf_ack_failed;
92*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_ftsn_failed;
93*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_send_hb_failed;
94*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_return_hb_failed;
95*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_ss_rexmit_failed;
96*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_cl_connect;
97*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_cl_assoc_change;
98*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_cl_check_addrs;
99*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_reclaim_cnt;
100*12869SKacheong.Poon@Sun.COM 	uint64_t	sctp_listen_cnt_drop;
101*12869SKacheong.Poon@Sun.COM } sctp_kstat_counter_t;
102*12869SKacheong.Poon@Sun.COM 
103*12869SKacheong.Poon@Sun.COM /* Per CPU SCTP statistics counters. */
104*12869SKacheong.Poon@Sun.COM typedef struct {
105*12869SKacheong.Poon@Sun.COM 	int64_t			sctp_sc_assoc_cnt;
106*12869SKacheong.Poon@Sun.COM 	mib2_sctp_t		sctp_sc_mib;
107*12869SKacheong.Poon@Sun.COM 	sctp_kstat_counter_t	sctp_sc_stats;
108*12869SKacheong.Poon@Sun.COM } sctp_stats_cpu_t;
109*12869SKacheong.Poon@Sun.COM 
110*12869SKacheong.Poon@Sun.COM #define	SCTP_KSTAT(sctps, x)		\
111*12869SKacheong.Poon@Sun.COM 	((sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_stats.x++)
112*12869SKacheong.Poon@Sun.COM 
113*12869SKacheong.Poon@Sun.COM #define	SCTPS_BUMP_MIB(sctps, x)	\
114*12869SKacheong.Poon@Sun.COM 	BUMP_MIB(&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_mib, x)
115*12869SKacheong.Poon@Sun.COM 
116*12869SKacheong.Poon@Sun.COM #define	SCTPS_UPDATE_MIB(sctps, x, y)	\
117*12869SKacheong.Poon@Sun.COM 	UPDATE_MIB(&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_mib, x, y)
1183448Sdh155122 
1193448Sdh155122 /*
1203448Sdh155122  * SCTP stack instances
1213448Sdh155122  */
1223448Sdh155122 struct sctp_stack {
1233448Sdh155122 	netstack_t	*sctps_netstack;	/* Common netstack */
1243448Sdh155122 
1253448Sdh155122 	/* Protected by sctps_g_lock */
1263448Sdh155122 	struct list	sctps_g_list;	/* SCTP instance data chain */
1273448Sdh155122 	kmutex_t	sctps_g_lock;
1283448Sdh155122 
1293448Sdh155122 #define	SCTP_NUM_EPRIV_PORTS	64
1303448Sdh155122 	int		sctps_g_num_epriv_ports;
13112016SGirish.Moodalbail@Sun.COM 	in_port_t	sctps_g_epriv_ports[SCTP_NUM_EPRIV_PORTS];
1323448Sdh155122 	kmutex_t	sctps_epriv_port_lock;
1333448Sdh155122 	uint_t		sctps_next_port_to_try;
1343448Sdh155122 
1353448Sdh155122 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
1363448Sdh155122 	struct sctp_tf_s	*sctps_bind_fanout;
1373448Sdh155122 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
1383448Sdh155122 	struct sctp_tf_s	*sctps_listen_fanout;
1393448Sdh155122 	struct sctp_tf_s	*sctps_conn_fanout;
1403448Sdh155122 	uint_t			sctps_conn_hash_size;
1413448Sdh155122 
14212016SGirish.Moodalbail@Sun.COM 	/* holds sctp tunables */
14312016SGirish.Moodalbail@Sun.COM 	struct mod_prop_info_s	*sctps_propinfo_tbl;
1443448Sdh155122 
145*12869SKacheong.Poon@Sun.COM 	/*
146*12869SKacheong.Poon@Sun.COM 	 * This lock protects the SCTP recvq_tq_list array and
147*12869SKacheong.Poon@Sun.COM 	 * recvq_tq_list_cur_sz.
148*12869SKacheong.Poon@Sun.COM 	 */
1493448Sdh155122 	kmutex_t		sctps_rq_tq_lock;
1503448Sdh155122 	int			sctps_recvq_tq_list_max_sz;
1513448Sdh155122 	taskq_t			**sctps_recvq_tq_list;
1523448Sdh155122 
1533448Sdh155122 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
1543448Sdh155122 	uint32_t		sctps_recvq_tq_list_cur_sz;
1553448Sdh155122 	uint32_t		sctps_recvq_tq_list_cur;
1563448Sdh155122 
1573448Sdh155122 	/* Global list of SCTP ILLs */
1583448Sdh155122 	struct sctp_ill_hash_s	*sctps_g_ills;
1593448Sdh155122 	uint32_t		sctps_ills_count;
1603448Sdh155122 	krwlock_t		sctps_g_ills_lock;
1613448Sdh155122 
1623448Sdh155122 	/* Global list of SCTP IPIFs */
1633448Sdh155122 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
1643448Sdh155122 	uint32_t		sctps_g_ipifs_count;
1653448Sdh155122 	krwlock_t		sctps_g_ipifs_lock;
1663448Sdh155122 
167*12869SKacheong.Poon@Sun.COM 	/* kstat exporting mib2_sctp_t and sctp_kstat_t data */
1683448Sdh155122 	kstat_t			*sctps_mibkp;
1693448Sdh155122 	kstat_t			*sctps_kstat;
170*12869SKacheong.Poon@Sun.COM 
171*12869SKacheong.Poon@Sun.COM 	/* Variables for handling kmem reclaim call back. */
172*12869SKacheong.Poon@Sun.COM 	kmutex_t	sctps_reclaim_lock;
173*12869SKacheong.Poon@Sun.COM 	boolean_t	sctps_reclaim;
174*12869SKacheong.Poon@Sun.COM 	timeout_id_t	sctps_reclaim_tid;
175*12869SKacheong.Poon@Sun.COM 	uint32_t	sctps_reclaim_period;
176*12869SKacheong.Poon@Sun.COM 
177*12869SKacheong.Poon@Sun.COM 	/* Listener association limit configuration. */
178*12869SKacheong.Poon@Sun.COM 	kmutex_t	sctps_listener_conf_lock;
179*12869SKacheong.Poon@Sun.COM 	list_t		sctps_listener_conf;
180*12869SKacheong.Poon@Sun.COM 
181*12869SKacheong.Poon@Sun.COM 	/*
182*12869SKacheong.Poon@Sun.COM 	 * Per CPU stats
183*12869SKacheong.Poon@Sun.COM 	 *
184*12869SKacheong.Poon@Sun.COM 	 * sctps_sc: array of pointer to per CPU stats.  The i-th element in
185*12869SKacheong.Poon@Sun.COM 	 *   the array represents the stats of the CPU with cpu_seqid.
186*12869SKacheong.Poon@Sun.COM 	 * sctps_sc_cnt: number of CPU stats in the sctps_sc array.
187*12869SKacheong.Poon@Sun.COM 	 */
188*12869SKacheong.Poon@Sun.COM 	sctp_stats_cpu_t	**sctps_sc;
189*12869SKacheong.Poon@Sun.COM 	int			sctps_sc_cnt;
1903448Sdh155122 };
191*12869SKacheong.Poon@Sun.COM 
1923448Sdh155122 typedef struct sctp_stack sctp_stack_t;
1933448Sdh155122 
1943448Sdh155122 #ifdef	__cplusplus
1953448Sdh155122 }
1963448Sdh155122 #endif
1973448Sdh155122 
1983448Sdh155122 #endif	/* _INET_SCTP_SCTP_STACK_H */
199