1f4b3ec61Sdh /*
2f4b3ec61Sdh  * CDDL HEADER START
3f4b3ec61Sdh  *
4f4b3ec61Sdh  * The contents of this file are subject to the terms of the
5f4b3ec61Sdh  * Common Development and Distribution License (the "License").
6f4b3ec61Sdh  * You may not use this file except in compliance with the License.
7f4b3ec61Sdh  *
8f4b3ec61Sdh  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9f4b3ec61Sdh  * or http://www.opensolaris.org/os/licensing.
10f4b3ec61Sdh  * See the License for the specific language governing permissions
11f4b3ec61Sdh  * and limitations under the License.
12f4b3ec61Sdh  *
13f4b3ec61Sdh  * When distributing Covered Code, include this CDDL HEADER in each
14f4b3ec61Sdh  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15f4b3ec61Sdh  * If applicable, add the following below this CDDL HEADER, with the
16f4b3ec61Sdh  * fields enclosed by brackets "[]" replaced with your own identifying
17f4b3ec61Sdh  * information: Portions Copyright [yyyy] [name of copyright owner]
18f4b3ec61Sdh  *
19f4b3ec61Sdh  * CDDL HEADER END
20f4b3ec61Sdh  */
21f4b3ec61Sdh 
22f4b3ec61Sdh /*
23*2ea701aaSyz  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24f4b3ec61Sdh  * Use is subject to license terms.
25f4b3ec61Sdh  */
26f4b3ec61Sdh 
27f4b3ec61Sdh #ifndef	_INET_SCTP_SCTP_STACK_H
28f4b3ec61Sdh #define	_INET_SCTP_SCTP_STACK_H
29f4b3ec61Sdh 
30f4b3ec61Sdh #pragma ident	"%Z%%M%	%I%	%E% SMI"
31f4b3ec61Sdh 
32f4b3ec61Sdh #include <sys/netstack.h>
33*2ea701aaSyz #include <sys/taskq.h>
34f4b3ec61Sdh 
35f4b3ec61Sdh #ifdef	__cplusplus
36f4b3ec61Sdh extern "C" {
37f4b3ec61Sdh #endif
38f4b3ec61Sdh 
39f4b3ec61Sdh /* SCTP kstat */
40f4b3ec61Sdh typedef struct sctp_kstat_s {
41f4b3ec61Sdh 	kstat_named_t	sctp_add_faddr;
42f4b3ec61Sdh 	kstat_named_t	sctp_add_timer;
43f4b3ec61Sdh 	kstat_named_t	sctp_conn_create;
44f4b3ec61Sdh 	kstat_named_t	sctp_find_next_tq;
45f4b3ec61Sdh 	kstat_named_t	sctp_fr_add_hdr;
46f4b3ec61Sdh 	kstat_named_t	sctp_fr_not_found;
47f4b3ec61Sdh 	kstat_named_t	sctp_output_failed;
48f4b3ec61Sdh 	kstat_named_t	sctp_rexmit_failed;
49f4b3ec61Sdh 	kstat_named_t	sctp_send_init_failed;
50f4b3ec61Sdh 	kstat_named_t	sctp_send_cookie_failed;
51f4b3ec61Sdh 	kstat_named_t	sctp_send_cookie_ack_failed;
52f4b3ec61Sdh 	kstat_named_t	sctp_send_err_failed;
53f4b3ec61Sdh 	kstat_named_t	sctp_send_sack_failed;
54f4b3ec61Sdh 	kstat_named_t	sctp_send_shutdown_failed;
55f4b3ec61Sdh 	kstat_named_t	sctp_send_shutdown_ack_failed;
56f4b3ec61Sdh 	kstat_named_t	sctp_send_shutdown_comp_failed;
57f4b3ec61Sdh 	kstat_named_t	sctp_send_user_abort_failed;
58f4b3ec61Sdh 	kstat_named_t	sctp_send_asconf_failed;
59f4b3ec61Sdh 	kstat_named_t	sctp_send_asconf_ack_failed;
60f4b3ec61Sdh 	kstat_named_t	sctp_send_ftsn_failed;
61f4b3ec61Sdh 	kstat_named_t	sctp_send_hb_failed;
62f4b3ec61Sdh 	kstat_named_t	sctp_return_hb_failed;
63f4b3ec61Sdh 	kstat_named_t	sctp_ss_rexmit_failed;
64f4b3ec61Sdh 	kstat_named_t	sctp_cl_connect;
65f4b3ec61Sdh 	kstat_named_t	sctp_cl_assoc_change;
66f4b3ec61Sdh 	kstat_named_t	sctp_cl_check_addrs;
67f4b3ec61Sdh } sctp_kstat_t;
68f4b3ec61Sdh 
69f4b3ec61Sdh #define	SCTP_KSTAT(sctps, x)	((sctps)->sctps_statistics.x.value.ui64++)
70f4b3ec61Sdh 
71f4b3ec61Sdh /*
72f4b3ec61Sdh  * SCTP stack instances
73f4b3ec61Sdh  */
74f4b3ec61Sdh struct sctp_stack {
75f4b3ec61Sdh 	netstack_t	*sctps_netstack;	/* Common netstack */
76f4b3ec61Sdh 
77f4b3ec61Sdh 	mib2_sctp_t		sctps_mib;
78f4b3ec61Sdh 
79f4b3ec61Sdh 	/* Protected by sctps_g_q_lock */
80f4b3ec61Sdh 	queue_t		*sctps_g_q;
81f4b3ec61Sdh 	uint_t		sctps_g_q_ref; /* Number of sctp_t's that use it */
82f4b3ec61Sdh 	kmutex_t	sctps_g_q_lock;
83f4b3ec61Sdh 	kcondvar_t	sctps_g_q_cv;
84f4b3ec61Sdh 	kthread_t	*sctps_g_q_creator;
85f4b3ec61Sdh 	struct __ldi_handle *sctps_g_q_lh;
86f4b3ec61Sdh 	cred_t		*sctps_g_q_cr;    /* For _inactive close call */
87f4b3ec61Sdh 	/* The default sctp_t for responding out of the blue packets. */
88f4b3ec61Sdh 	struct sctp_s	*sctps_gsctp;
89f4b3ec61Sdh 
90f4b3ec61Sdh 	/* Protected by sctps_g_lock */
91f4b3ec61Sdh 	struct list	sctps_g_list;	/* SCTP instance data chain */
92f4b3ec61Sdh 	kmutex_t	sctps_g_lock;
93f4b3ec61Sdh 
94f4b3ec61Sdh #define	SCTP_NUM_EPRIV_PORTS	64
95f4b3ec61Sdh 	int		sctps_g_num_epriv_ports;
96f4b3ec61Sdh 	uint16_t	sctps_g_epriv_ports[SCTP_NUM_EPRIV_PORTS];
97f4b3ec61Sdh 	kmutex_t	sctps_epriv_port_lock;
98f4b3ec61Sdh 	uint_t		sctps_next_port_to_try;
99f4b3ec61Sdh 
100f4b3ec61Sdh 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
101f4b3ec61Sdh 	struct sctp_tf_s	*sctps_bind_fanout;
102f4b3ec61Sdh 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
103f4b3ec61Sdh 	struct sctp_tf_s	*sctps_listen_fanout;
104f4b3ec61Sdh 	struct sctp_tf_s	*sctps_conn_fanout;
105f4b3ec61Sdh 	uint_t			sctps_conn_hash_size;
106f4b3ec61Sdh 
107f4b3ec61Sdh 	/* Only modified during _init and _fini thus no locking is needed. */
108f4b3ec61Sdh 	caddr_t			sctps_g_nd;
109f4b3ec61Sdh 	struct sctpparam_s	*sctps_params;
110f4b3ec61Sdh 	struct sctpparam_s	*sctps_wroff_xtra_param;
111f4b3ec61Sdh 
112f4b3ec61Sdh /* This lock protects the SCTP recvq_tq_list array and recvq_tq_list_cur_sz. */
113f4b3ec61Sdh 	kmutex_t		sctps_rq_tq_lock;
114f4b3ec61Sdh 	int			sctps_recvq_tq_list_max_sz;
115f4b3ec61Sdh 	taskq_t			**sctps_recvq_tq_list;
116f4b3ec61Sdh 
117f4b3ec61Sdh 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
118f4b3ec61Sdh 	uint32_t		sctps_recvq_tq_list_cur_sz;
119f4b3ec61Sdh 	uint32_t		sctps_recvq_tq_list_cur;
120f4b3ec61Sdh 
121f4b3ec61Sdh 	/* Global list of SCTP ILLs */
122f4b3ec61Sdh 	struct sctp_ill_hash_s	*sctps_g_ills;
123f4b3ec61Sdh 	uint32_t		sctps_ills_count;
124f4b3ec61Sdh 	krwlock_t		sctps_g_ills_lock;
125f4b3ec61Sdh 
126f4b3ec61Sdh 	/* Global list of SCTP IPIFs */
127f4b3ec61Sdh 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
128f4b3ec61Sdh 	uint32_t		sctps_g_ipifs_count;
129f4b3ec61Sdh 	krwlock_t		sctps_g_ipifs_lock;
130f4b3ec61Sdh 
131f4b3ec61Sdh 	/* kstat exporting sctp_mib data */
132f4b3ec61Sdh 	kstat_t			*sctps_mibkp;
133f4b3ec61Sdh 	kstat_t			*sctps_kstat;
134f4b3ec61Sdh 	sctp_kstat_t		sctps_statistics;
135f4b3ec61Sdh };
136f4b3ec61Sdh typedef struct sctp_stack sctp_stack_t;
137f4b3ec61Sdh 
138f4b3ec61Sdh #ifdef	__cplusplus
139f4b3ec61Sdh }
140f4b3ec61Sdh #endif
141f4b3ec61Sdh 
142f4b3ec61Sdh #endif	/* _INET_SCTP_SCTP_STACK_H */
143