xref: /titanic_50/usr/src/uts/common/inet/sctp/sctp_stack.h (revision 321502cd0930b1eb6d4805e17f16234f3e3ff4b2)
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 	/* SCTP bind hash list - all sctp_t with state >= BOUND. */
100 	struct sctp_tf_s	*sctps_bind_fanout;
101 	/* SCTP listen hash list - all sctp_t with state == LISTEN. */
102 	struct sctp_tf_s	*sctps_listen_fanout;
103 	struct sctp_tf_s	*sctps_conn_fanout;
104 	uint_t			sctps_conn_hash_size;
105 
106 	/* Only modified during _init and _fini thus no locking is needed. */
107 	caddr_t			sctps_g_nd;
108 	struct sctpparam_s	*sctps_params;
109 	struct sctpparam_s	*sctps_wroff_xtra_param;
110 
111 /* This lock protects the SCTP recvq_tq_list array and recvq_tq_list_cur_sz. */
112 	kmutex_t		sctps_rq_tq_lock;
113 	int			sctps_recvq_tq_list_max_sz;
114 	taskq_t			**sctps_recvq_tq_list;
115 
116 	/* Current number of recvq taskq.  At least 1 for the default taskq. */
117 	uint32_t		sctps_recvq_tq_list_cur_sz;
118 	uint32_t		sctps_recvq_tq_list_cur;
119 
120 	/* Global list of SCTP ILLs */
121 	struct sctp_ill_hash_s	*sctps_g_ills;
122 	uint32_t		sctps_ills_count;
123 	krwlock_t		sctps_g_ills_lock;
124 
125 	/* Global list of SCTP IPIFs */
126 	struct sctp_ipif_hash_s	*sctps_g_ipifs;
127 	uint32_t		sctps_g_ipifs_count;
128 	krwlock_t		sctps_g_ipifs_lock;
129 
130 	/* kstat exporting sctp_mib data */
131 	kstat_t			*sctps_mibkp;
132 	kstat_t			*sctps_kstat;
133 	sctp_kstat_t		sctps_statistics;
134 };
135 typedef struct sctp_stack sctp_stack_t;
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _INET_SCTP_SCTP_STACK_H */
142