xref: /titanic_51/usr/src/uts/common/sys/idm/idm_so.h (revision 7014882c6a3672fd0e5d60200af8643ae53c5928)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _IDM_SO_H
27 #define	_IDM_SO_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/idm/idm_transport.h>
34 #include <sys/ksocket.h>
35 
36 /*
37  * Define TCP window size (send and receive buffer sizes)
38  */
39 
40 #define	IDM_RCVBUF_SIZE		(256 * 1024)
41 #define	IDM_SNDBUF_SIZE		(256 * 1024)
42 
43 /*
44  * Lower and upper bounds to use the 128k buffer cache.  Below the lower bound
45  * allocations will use the built-in Solaris buffer caches.  We don't expect
46  * to see allocations above the upper bound because SBD currently allocates
47  * 128k buffers.
48  */
49 
50 #define	IDM_SO_BUF_CACHE_LB	(32 * 1024)
51 #define	IDM_SO_BUF_CACHE_UB	(128 * 1024)
52 
53 /* sockets-specific portion of idm_svc_t */
54 typedef struct idm_so_svc_s {
55 	ksocket_t		is_so;
56 	kthread_t		*is_thread;
57 	kt_did_t		is_thread_did;
58 	boolean_t		is_thread_running;
59 } idm_so_svc_t;
60 
61 /* sockets-specific portion of idm_conn_t */
62 typedef struct idm_so_conn_s {
63 	ksocket_t		ic_so;
64 
65 	kthread_t		*ic_tx_thread;
66 	kt_did_t		ic_tx_thread_did;
67 	boolean_t		ic_tx_thread_running;
68 	kmutex_t		ic_tx_mutex;
69 	kcondvar_t		ic_tx_cv;
70 	list_t			ic_tx_list;	/* List of PDUs for transmit */
71 
72 	kthread_t		*ic_rx_thread;
73 	kt_did_t		ic_rx_thread_did;
74 	boolean_t		ic_rx_thread_running;
75 } idm_so_conn_t;
76 
77 void idm_so_init(idm_transport_t *it);
78 void idm_so_fini();
79 
80 /* used by idm_so_timed_socket_connect */
81 typedef struct idm_so_timed_socket_s {
82 	kcondvar_t	it_cv;
83 	boolean_t	it_callback_called;
84 	int		it_socket_error_code;
85 } idm_so_timed_socket_t;
86 
87 /* Socket functions */
88 
89 ksocket_t
90 idm_socreate(int domain, int type, int protocol);
91 
92 void idm_soshutdown(ksocket_t so);
93 
94 void idm_sodestroy(ksocket_t so);
95 
96 int idm_ss_compare(const struct sockaddr_storage *cmp_ss1,
97     const struct sockaddr_storage *cmp_ss2,
98     boolean_t v4_mapped_as_v4,
99     boolean_t compare_ports);
100 
101 int idm_get_ipaddr(idm_addr_list_t **);
102 
103 void idm_addr_to_sa(idm_addr_t *dportal,
104     struct sockaddr_storage *sa);
105 
106 #define	IDM_SA_NTOP_BUFSIZ (INET6_ADDRSTRLEN + sizeof ("[].65535") + 1)
107 
108 const char *idm_sa_ntop(const struct sockaddr_storage *sa,
109     char *buf, size_t size);
110 
111 int idm_sorecv(ksocket_t so, void *msg, size_t len);
112 
113 int idm_sosendto(ksocket_t so, void *buff, size_t len,
114     struct sockaddr *name, socklen_t namelen);
115 
116 int idm_iov_sosend(ksocket_t so, iovec_t *iop, int iovlen,
117     size_t total_len);
118 
119 int idm_iov_sorecv(ksocket_t so, iovec_t *iop, int iovlen,
120     size_t total_len);
121 
122 void idm_sotx_thread(void *arg);
123 void idm_sorx_thread(void *arg);
124 
125 
126 int idm_sotx_pdu_constructor(void *hdl, void *arg, int flags);
127 
128 void idm_sotx_pdu_destructor(void *pdu_void, void *arg);
129 
130 int idm_sorx_pdu_constructor(void *hdl, void *arg, int flags);
131 
132 void idm_sorx_pdu_destructor(void *pdu_void, void *arg);
133 
134 void idm_so_svc_port_watcher(void *arg);
135 
136 int idm_so_timed_socket_connect(ksocket_t ks,
137     struct sockaddr_storage *sa, int sa_sz, int login_max_usec);
138 
139 #ifdef	__cplusplus
140 }
141 #endif
142 
143 #endif /* _IDM_SO_H */
144