xref: /illumos-gate/usr/src/uts/common/inet/sctp/sctp_stack.h (revision 34a0f871d192b33b865455a8812a3d34c1866315)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_INET_SCTP_SCTP_STACK_H
28 #define	_INET_SCTP_SCTP_STACK_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/netstack.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /* SCTP kstat */
39 typedef struct sctp_kstat_s {
40 	kstat_named_t	sctp_add_faddr;
41 	kstat_named_t	sctp_add_timer;
42 	kstat_named_t	sctp_conn_create;
43 	kstat_named_t	sctp_find_next_tq;
44 	kstat_named_t	sctp_fr_add_hdr;
45 	kstat_named_t	sctp_fr_not_found;
46 	kstat_named_t	sctp_output_failed;
47 	kstat_named_t	sctp_rexmit_failed;
48 	kstat_named_t	sctp_send_init_failed;
49 	kstat_named_t	sctp_send_cookie_failed;
50 	kstat_named_t	sctp_send_cookie_ack_failed;
51 	kstat_named_t	sctp_send_err_failed;
52 	kstat_named_t	sctp_send_sack_failed;
53 	kstat_named_t	sctp_send_shutdown_failed;
54 	kstat_named_t	sctp_send_shutdown_ack_failed;
55 	kstat_named_t	sctp_send_shutdown_comp_failed;
56 	kstat_named_t	sctp_send_user_abort_failed;
57 	kstat_named_t	sctp_send_asconf_failed;
58 	kstat_named_t	sctp_send_asconf_ack_failed;
59 	kstat_named_t	sctp_send_ftsn_failed;
60 	kstat_named_t	sctp_send_hb_failed;
61 	kstat_named_t	sctp_return_hb_failed;
62 	kstat_named_t	sctp_ss_rexmit_failed;
63 	kstat_named_t	sctp_cl_connect;
64 	kstat_named_t	sctp_cl_assoc_change;
65 	kstat_named_t	sctp_cl_check_addrs;
66 } sctp_kstat_t;
67 
68 #define	SCTP_KSTAT(sctps, x)	((sctps)->sctps_statistics.x.value.ui64++)
69 
70 /*
71  * SCTP stack instances
72  */
73 struct sctp_stack {
74 	netstack_t	*sctps_netstack;	/* Common netstack */
75 
76 	mib2_sctp_t		sctps_mib;
77 
78 	/* Protected by sctps_g_q_lock */
79 	queue_t		*sctps_g_q;
80 	uint_t		sctps_g_q_ref; /* Number of sctp_t's that use it */
81 	kmutex_t	sctps_g_q_lock;
82 	kcondvar_t	sctps_g_q_cv;
83 	kthread_t	*sctps_g_q_creator;
84 	struct __ldi_handle *sctps_g_q_lh;
85 	cred_t		*sctps_g_q_cr;    /* For _inactive close call */
86 	/* The default sctp_t for responding out of the blue packets. */
87 	struct sctp_s	*sctps_gsctp;
88 
89 	/* Protected by sctps_g_lock */
90 	struct list	sctps_g_list;	/* SCTP instance data chain */
91 	kmutex_t	sctps_g_lock;
92 
93 #define	SCTP_NUM_EPRIV_PORTS	64
94 	int		sctps_g_num_epriv_ports;
95 	uint16_t	sctps_g_epriv_ports[SCTP_NUM_EPRIV_PORTS];
96 	kmutex_t	sctps_epriv_port_lock;
97 	uint_t		sctps_next_port_to_try;
98 
99 	mblk_t		 *sctps_pad_mp;	/* pad unaligned data chunks */
100 
101 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
102 	struct sctp_tf_s	*sctps_bind_fanout;
103 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
104 	struct sctp_tf_s	*sctps_listen_fanout;
105 	struct sctp_tf_s	*sctps_conn_fanout;
106 	uint_t			sctps_conn_hash_size;
107 
108 	/* Only modified during _init and _fini thus no locking is needed. */
109 	caddr_t			sctps_g_nd;
110 	struct sctpparam_s	*sctps_params;
111 	struct sctpparam_s	*sctps_wroff_xtra_param;
112 
113 /* This lock protects the SCTP recvq_tq_list array and recvq_tq_list_cur_sz. */
114 	kmutex_t		sctps_rq_tq_lock;
115 	int			sctps_recvq_tq_list_max_sz;
116 	taskq_t			**sctps_recvq_tq_list;
117 
118 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
119 	uint32_t		sctps_recvq_tq_list_cur_sz;
120 	uint32_t		sctps_recvq_tq_list_cur;
121 
122 	/* Global list of SCTP ILLs */
123 	struct sctp_ill_hash_s	*sctps_g_ills;
124 	uint32_t		sctps_ills_count;
125 	krwlock_t		sctps_g_ills_lock;
126 
127 	/* Global list of SCTP IPIFs */
128 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
129 	uint32_t		sctps_g_ipifs_count;
130 	krwlock_t		sctps_g_ipifs_lock;
131 
132 	/* kstat exporting sctp_mib data */
133 	kstat_t			*sctps_mibkp;
134 	kstat_t			*sctps_kstat;
135 	sctp_kstat_t		sctps_statistics;
136 };
137 typedef struct sctp_stack sctp_stack_t;
138 
139 #ifdef	__cplusplus
140 }
141 #endif
142 
143 #endif	/* _INET_SCTP_SCTP_STACK_H */
144