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*6e91bba0SGirish Moodalbail  * Copyright 2010 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 #include <sys/netstack.h>
312ea701aaSyz #include <sys/taskq.h>
32f4b3ec61Sdh 
33f4b3ec61Sdh #ifdef	__cplusplus
34f4b3ec61Sdh extern "C" {
35f4b3ec61Sdh #endif
36f4b3ec61Sdh 
37f4b3ec61Sdh /* SCTP kstat */
38f4b3ec61Sdh typedef struct sctp_kstat_s {
39f4b3ec61Sdh 	kstat_named_t	sctp_add_faddr;
40f4b3ec61Sdh 	kstat_named_t	sctp_add_timer;
41f4b3ec61Sdh 	kstat_named_t	sctp_conn_create;
42f4b3ec61Sdh 	kstat_named_t	sctp_find_next_tq;
43f4b3ec61Sdh 	kstat_named_t	sctp_fr_add_hdr;
44f4b3ec61Sdh 	kstat_named_t	sctp_fr_not_found;
45f4b3ec61Sdh 	kstat_named_t	sctp_output_failed;
46f4b3ec61Sdh 	kstat_named_t	sctp_rexmit_failed;
47f4b3ec61Sdh 	kstat_named_t	sctp_send_init_failed;
48f4b3ec61Sdh 	kstat_named_t	sctp_send_cookie_failed;
49f4b3ec61Sdh 	kstat_named_t	sctp_send_cookie_ack_failed;
50f4b3ec61Sdh 	kstat_named_t	sctp_send_err_failed;
51f4b3ec61Sdh 	kstat_named_t	sctp_send_sack_failed;
52f4b3ec61Sdh 	kstat_named_t	sctp_send_shutdown_failed;
53f4b3ec61Sdh 	kstat_named_t	sctp_send_shutdown_ack_failed;
54f4b3ec61Sdh 	kstat_named_t	sctp_send_shutdown_comp_failed;
55f4b3ec61Sdh 	kstat_named_t	sctp_send_user_abort_failed;
56f4b3ec61Sdh 	kstat_named_t	sctp_send_asconf_failed;
57f4b3ec61Sdh 	kstat_named_t	sctp_send_asconf_ack_failed;
58f4b3ec61Sdh 	kstat_named_t	sctp_send_ftsn_failed;
59f4b3ec61Sdh 	kstat_named_t	sctp_send_hb_failed;
60f4b3ec61Sdh 	kstat_named_t	sctp_return_hb_failed;
61f4b3ec61Sdh 	kstat_named_t	sctp_ss_rexmit_failed;
62f4b3ec61Sdh 	kstat_named_t	sctp_cl_connect;
63f4b3ec61Sdh 	kstat_named_t	sctp_cl_assoc_change;
64f4b3ec61Sdh 	kstat_named_t	sctp_cl_check_addrs;
65f4b3ec61Sdh } sctp_kstat_t;
66f4b3ec61Sdh 
67f4b3ec61Sdh #define	SCTP_KSTAT(sctps, x)	((sctps)->sctps_statistics.x.value.ui64++)
68f4b3ec61Sdh 
69f4b3ec61Sdh /*
70f4b3ec61Sdh  * SCTP stack instances
71f4b3ec61Sdh  */
72f4b3ec61Sdh struct sctp_stack {
73f4b3ec61Sdh 	netstack_t	*sctps_netstack;	/* Common netstack */
74f4b3ec61Sdh 
75f4b3ec61Sdh 	mib2_sctp_t		sctps_mib;
76f4b3ec61Sdh 
77f4b3ec61Sdh 	/* Protected by sctps_g_lock */
78f4b3ec61Sdh 	struct list	sctps_g_list;	/* SCTP instance data chain */
79f4b3ec61Sdh 	kmutex_t	sctps_g_lock;
80f4b3ec61Sdh 
81f4b3ec61Sdh #define	SCTP_NUM_EPRIV_PORTS	64
82f4b3ec61Sdh 	int		sctps_g_num_epriv_ports;
83*6e91bba0SGirish Moodalbail 	in_port_t	sctps_g_epriv_ports[SCTP_NUM_EPRIV_PORTS];
84f4b3ec61Sdh 	kmutex_t	sctps_epriv_port_lock;
85f4b3ec61Sdh 	uint_t		sctps_next_port_to_try;
86f4b3ec61Sdh 
87f4b3ec61Sdh 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
88f4b3ec61Sdh 	struct sctp_tf_s	*sctps_bind_fanout;
89f4b3ec61Sdh 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
90f4b3ec61Sdh 	struct sctp_tf_s	*sctps_listen_fanout;
91f4b3ec61Sdh 	struct sctp_tf_s	*sctps_conn_fanout;
92f4b3ec61Sdh 	uint_t			sctps_conn_hash_size;
93f4b3ec61Sdh 
94*6e91bba0SGirish Moodalbail 	/* holds sctp tunables */
95*6e91bba0SGirish Moodalbail 	struct mod_prop_info_s	*sctps_propinfo_tbl;
96f4b3ec61Sdh 
97f4b3ec61Sdh /* This lock protects the SCTP recvq_tq_list array and recvq_tq_list_cur_sz. */
98f4b3ec61Sdh 	kmutex_t		sctps_rq_tq_lock;
99f4b3ec61Sdh 	int			sctps_recvq_tq_list_max_sz;
100f4b3ec61Sdh 	taskq_t			**sctps_recvq_tq_list;
101f4b3ec61Sdh 
102f4b3ec61Sdh 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
103f4b3ec61Sdh 	uint32_t		sctps_recvq_tq_list_cur_sz;
104f4b3ec61Sdh 	uint32_t		sctps_recvq_tq_list_cur;
105f4b3ec61Sdh 
106f4b3ec61Sdh 	/* Global list of SCTP ILLs */
107f4b3ec61Sdh 	struct sctp_ill_hash_s	*sctps_g_ills;
108f4b3ec61Sdh 	uint32_t		sctps_ills_count;
109f4b3ec61Sdh 	krwlock_t		sctps_g_ills_lock;
110f4b3ec61Sdh 
111f4b3ec61Sdh 	/* Global list of SCTP IPIFs */
112f4b3ec61Sdh 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
113f4b3ec61Sdh 	uint32_t		sctps_g_ipifs_count;
114f4b3ec61Sdh 	krwlock_t		sctps_g_ipifs_lock;
115f4b3ec61Sdh 
116f4b3ec61Sdh 	/* kstat exporting sctp_mib data */
117f4b3ec61Sdh 	kstat_t			*sctps_mibkp;
118f4b3ec61Sdh 	kstat_t			*sctps_kstat;
119f4b3ec61Sdh 	sctp_kstat_t		sctps_statistics;
120f4b3ec61Sdh };
121f4b3ec61Sdh typedef struct sctp_stack sctp_stack_t;
122f4b3ec61Sdh 
123f4b3ec61Sdh #ifdef	__cplusplus
124f4b3ec61Sdh }
125f4b3ec61Sdh #endif
126f4b3ec61Sdh 
127f4b3ec61Sdh #endif	/* _INET_SCTP_SCTP_STACK_H */
128