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