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*6220Syz147064  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
243448Sdh155122  * Use is subject to license terms.
253448Sdh155122  */
263448Sdh155122 
273448Sdh155122 #ifndef	_INET_SCTP_SCTP_STACK_H
283448Sdh155122 #define	_INET_SCTP_SCTP_STACK_H
293448Sdh155122 
303448Sdh155122 #pragma ident	"%Z%%M%	%I%	%E% SMI"
313448Sdh155122 
323448Sdh155122 #include <sys/netstack.h>
33*6220Syz147064 #include <sys/taskq.h>
343448Sdh155122 
353448Sdh155122 #ifdef	__cplusplus
363448Sdh155122 extern "C" {
373448Sdh155122 #endif
383448Sdh155122 
393448Sdh155122 /* SCTP kstat */
403448Sdh155122 typedef struct sctp_kstat_s {
413448Sdh155122 	kstat_named_t	sctp_add_faddr;
423448Sdh155122 	kstat_named_t	sctp_add_timer;
433448Sdh155122 	kstat_named_t	sctp_conn_create;
443448Sdh155122 	kstat_named_t	sctp_find_next_tq;
453448Sdh155122 	kstat_named_t	sctp_fr_add_hdr;
463448Sdh155122 	kstat_named_t	sctp_fr_not_found;
473448Sdh155122 	kstat_named_t	sctp_output_failed;
483448Sdh155122 	kstat_named_t	sctp_rexmit_failed;
493448Sdh155122 	kstat_named_t	sctp_send_init_failed;
503448Sdh155122 	kstat_named_t	sctp_send_cookie_failed;
513448Sdh155122 	kstat_named_t	sctp_send_cookie_ack_failed;
523448Sdh155122 	kstat_named_t	sctp_send_err_failed;
533448Sdh155122 	kstat_named_t	sctp_send_sack_failed;
543448Sdh155122 	kstat_named_t	sctp_send_shutdown_failed;
553448Sdh155122 	kstat_named_t	sctp_send_shutdown_ack_failed;
563448Sdh155122 	kstat_named_t	sctp_send_shutdown_comp_failed;
573448Sdh155122 	kstat_named_t	sctp_send_user_abort_failed;
583448Sdh155122 	kstat_named_t	sctp_send_asconf_failed;
593448Sdh155122 	kstat_named_t	sctp_send_asconf_ack_failed;
603448Sdh155122 	kstat_named_t	sctp_send_ftsn_failed;
613448Sdh155122 	kstat_named_t	sctp_send_hb_failed;
623448Sdh155122 	kstat_named_t	sctp_return_hb_failed;
633448Sdh155122 	kstat_named_t	sctp_ss_rexmit_failed;
643448Sdh155122 	kstat_named_t	sctp_cl_connect;
653448Sdh155122 	kstat_named_t	sctp_cl_assoc_change;
663448Sdh155122 	kstat_named_t	sctp_cl_check_addrs;
673448Sdh155122 } sctp_kstat_t;
683448Sdh155122 
693448Sdh155122 #define	SCTP_KSTAT(sctps, x)	((sctps)->sctps_statistics.x.value.ui64++)
703448Sdh155122 
713448Sdh155122 /*
723448Sdh155122  * SCTP stack instances
733448Sdh155122  */
743448Sdh155122 struct sctp_stack {
753448Sdh155122 	netstack_t	*sctps_netstack;	/* Common netstack */
763448Sdh155122 
773448Sdh155122 	mib2_sctp_t		sctps_mib;
783448Sdh155122 
793448Sdh155122 	/* Protected by sctps_g_q_lock */
803448Sdh155122 	queue_t		*sctps_g_q;
813448Sdh155122 	uint_t		sctps_g_q_ref; /* Number of sctp_t's that use it */
823448Sdh155122 	kmutex_t	sctps_g_q_lock;
833448Sdh155122 	kcondvar_t	sctps_g_q_cv;
843448Sdh155122 	kthread_t	*sctps_g_q_creator;
853448Sdh155122 	struct __ldi_handle *sctps_g_q_lh;
863448Sdh155122 	cred_t		*sctps_g_q_cr;    /* For _inactive close call */
873448Sdh155122 	/* The default sctp_t for responding out of the blue packets. */
883448Sdh155122 	struct sctp_s	*sctps_gsctp;
893448Sdh155122 
903448Sdh155122 	/* Protected by sctps_g_lock */
913448Sdh155122 	struct list	sctps_g_list;	/* SCTP instance data chain */
923448Sdh155122 	kmutex_t	sctps_g_lock;
933448Sdh155122 
943448Sdh155122 #define	SCTP_NUM_EPRIV_PORTS	64
953448Sdh155122 	int		sctps_g_num_epriv_ports;
963448Sdh155122 	uint16_t	sctps_g_epriv_ports[SCTP_NUM_EPRIV_PORTS];
973448Sdh155122 	kmutex_t	sctps_epriv_port_lock;
983448Sdh155122 	uint_t		sctps_next_port_to_try;
993448Sdh155122 
1003448Sdh155122 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
1013448Sdh155122 	struct sctp_tf_s	*sctps_bind_fanout;
1023448Sdh155122 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
1033448Sdh155122 	struct sctp_tf_s	*sctps_listen_fanout;
1043448Sdh155122 	struct sctp_tf_s	*sctps_conn_fanout;
1053448Sdh155122 	uint_t			sctps_conn_hash_size;
1063448Sdh155122 
1073448Sdh155122 	/* Only modified during _init and _fini thus no locking is needed. */
1083448Sdh155122 	caddr_t			sctps_g_nd;
1093448Sdh155122 	struct sctpparam_s	*sctps_params;
1103448Sdh155122 	struct sctpparam_s	*sctps_wroff_xtra_param;
1113448Sdh155122 
1123448Sdh155122 /* This lock protects the SCTP recvq_tq_list array and recvq_tq_list_cur_sz. */
1133448Sdh155122 	kmutex_t		sctps_rq_tq_lock;
1143448Sdh155122 	int			sctps_recvq_tq_list_max_sz;
1153448Sdh155122 	taskq_t			**sctps_recvq_tq_list;
1163448Sdh155122 
1173448Sdh155122 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
1183448Sdh155122 	uint32_t		sctps_recvq_tq_list_cur_sz;
1193448Sdh155122 	uint32_t		sctps_recvq_tq_list_cur;
1203448Sdh155122 
1213448Sdh155122 	/* Global list of SCTP ILLs */
1223448Sdh155122 	struct sctp_ill_hash_s	*sctps_g_ills;
1233448Sdh155122 	uint32_t		sctps_ills_count;
1243448Sdh155122 	krwlock_t		sctps_g_ills_lock;
1253448Sdh155122 
1263448Sdh155122 	/* Global list of SCTP IPIFs */
1273448Sdh155122 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
1283448Sdh155122 	uint32_t		sctps_g_ipifs_count;
1293448Sdh155122 	krwlock_t		sctps_g_ipifs_lock;
1303448Sdh155122 
1313448Sdh155122 	/* kstat exporting sctp_mib data */
1323448Sdh155122 	kstat_t			*sctps_mibkp;
1333448Sdh155122 	kstat_t			*sctps_kstat;
1343448Sdh155122 	sctp_kstat_t		sctps_statistics;
1353448Sdh155122 };
1363448Sdh155122 typedef struct sctp_stack sctp_stack_t;
1373448Sdh155122 
1383448Sdh155122 #ifdef	__cplusplus
1393448Sdh155122 }
1403448Sdh155122 #endif
1413448Sdh155122 
1423448Sdh155122 #endif	/* _INET_SCTP_SCTP_STACK_H */
143