Print this page
8368 remove warlock leftovers from usr/src/uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/ib/clients/rdsv3/loop.c
+++ new/usr/src/uts/common/io/ib/clients/rdsv3/loop.c
1 1 /*
2 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3 3 */
4 4
5 5 /*
6 6 * This file contains code imported from the OFED rds source file loop.c
7 7 * Oracle elects to have and use the contents of loop.c under and governed
8 8 * by the OpenIB.org BSD license (see below for full license text). However,
9 9 * the following notice accompanied the original version of this file:
10 10 */
11 11
12 12 /*
13 13 * Copyright (c) 2006 Oracle. All rights reserved.
14 14 *
15 15 * This software is available to you under a choice of one of two
16 16 * licenses. You may choose to be licensed under the terms of the GNU
17 17 * General Public License (GPL) Version 2, available from the file
18 18 * COPYING in the main directory of this source tree, or the
19 19 * OpenIB.org BSD license below:
20 20 *
21 21 * Redistribution and use in source and binary forms, with or
22 22 * without modification, are permitted provided that the following
23 23 * conditions are met:
24 24 *
25 25 * - Redistributions of source code must retain the above
26 26 * copyright notice, this list of conditions and the following
27 27 * disclaimer.
28 28 *
29 29 * - Redistributions in binary form must reproduce the above
30 30 * copyright notice, this list of conditions and the following
31 31 * disclaimer in the documentation and/or other materials
32 32 * provided with the distribution.
33 33 *
34 34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35 35 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36 36 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37 37 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
38 38 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
39 39 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 40 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 41 * SOFTWARE.
42 42 *
43 43 */
44 44 #include <sys/rds.h>
45 45
46 46 #include <sys/ib/clients/rdsv3/rdsv3.h>
47 47 #include <sys/ib/clients/rdsv3/loop.h>
48 48 #include <sys/ib/clients/rdsv3/rdsv3_debug.h>
49 49
50 50 kmutex_t loop_conns_lock;
51 51 list_t loop_conns;
52 52
53 53 /*
54 54 * This 'loopback' transport is a special case for flows that originate
55 55 * and terminate on the same machine.
56 56 *
57 57 * Connection build-up notices if the destination address is thought of
58 58 * as a local address by a transport. At that time it decides to use the
59 59 * loopback transport instead of the bound transport of the sending socket.
60 60 *
61 61 * The loopback transport's sending path just hands the sent rds_message
62 62 * straight to the receiving path via an embedded rds_incoming.
63 63 */
64 64
65 65 /*
66 66 * Usually a message transits both the sender and receiver's conns as it
67 67 * flows to the receiver. In the loopback case, though, the receive path
68 68 * is handed the sending conn so the sense of the addresses is reversed.
69 69 */
70 70 static int
71 71 rdsv3_loop_xmit(struct rdsv3_connection *conn, struct rdsv3_message *rm,
72 72 unsigned int hdr_off, unsigned int sg,
73 73 unsigned int off)
74 74 {
75 75 /* Do not send cong updates to loopback */
76 76 if (rm->m_inc.i_hdr.h_flags & RDSV3_FLAG_CONG_BITMAP) {
77 77 rdsv3_cong_map_updated(conn->c_fcong, ~(uint64_t)0);
78 78 return (sizeof (struct rdsv3_header) + RDSV3_CONG_MAP_BYTES);
79 79 }
80 80 ASSERT(!(hdr_off || sg || off));
81 81
82 82 RDSV3_DPRINTF4("rdsv3_loop_xmit", "Enter(conn: %p, rm: %p)", conn, rm);
83 83
84 84 rdsv3_inc_init(&rm->m_inc, conn, conn->c_laddr);
85 85 /* For the embedded inc. Matching put is in loop_inc_free() */
86 86 rdsv3_message_addref(rm);
87 87
88 88 rdsv3_recv_incoming(conn, conn->c_laddr, conn->c_faddr, &rm->m_inc,
89 89 KM_NOSLEEP);
90 90
91 91 rdsv3_send_drop_acked(conn, ntohll(rm->m_inc.i_hdr.h_sequence),
92 92 NULL);
93 93
94 94 rdsv3_inc_put(&rm->m_inc);
95 95
96 96 RDSV3_DPRINTF4("rdsv3_loop_xmit", "Return(conn: %p, rm: %p)", conn, rm);
97 97
98 98 return (sizeof (struct rdsv3_header) +
99 99 ntohl(rm->m_inc.i_hdr.h_len));
100 100 }
101 101
102 102 /*
103 103 * See rds_loop_xmit(). Since our inc is embedded in the rm, we
104 104 * make sure the rm lives at least until the inc is done.
105 105 */
106 106 static void
107 107 rdsv3_loop_inc_free(struct rdsv3_incoming *inc)
108 108 {
109 109 struct rdsv3_message *rm = container_of(inc, struct rdsv3_message,
110 110 m_inc);
111 111 rdsv3_message_put(rm);
112 112 }
113 113
114 114 static int
115 115 rdsv3_loop_xmit_cong_map(struct rdsv3_connection *conn,
116 116 struct rdsv3_cong_map *map,
117 117 unsigned long offset)
118 118 {
119 119 RDSV3_DPRINTF4("rdsv3_loop_xmit_cong_map", "Enter(conn: %p)", conn);
120 120
121 121 ASSERT(!offset);
122 122 ASSERT(map == conn->c_lcong);
123 123
124 124 rdsv3_cong_map_updated(conn->c_fcong, ~(uint64_t)0);
125 125
126 126 RDSV3_DPRINTF4("rdsv3_loop_xmit_cong_map", "Return(conn: %p)", conn);
127 127
128 128 return (sizeof (struct rdsv3_header) + RDSV3_CONG_MAP_BYTES);
129 129 }
130 130
131 131 /* we need to at least give the thread something to succeed */
132 132 /* ARGSUSED */
133 133 static int
134 134 rdsv3_loop_recv(struct rdsv3_connection *conn)
135 135 {
136 136 return (0);
137 137 }
138 138
139 139 struct rdsv3_loop_connection {
140 140 struct list_node loop_node;
141 141 struct rdsv3_connection *conn;
142 142 };
143 143
144 144 /*
145 145 * Even the loopback transport needs to keep track of its connections,
146 146 * so it can call rdsv3_conn_destroy() on them on exit. N.B. there are
147 147 * 1+ loopback addresses (127.*.*.*) so it's not a bug to have
148 148 * multiple loopback conns allocated, although rather useless.
149 149 */
150 150 /* ARGSUSED */
151 151 static int
152 152 rdsv3_loop_conn_alloc(struct rdsv3_connection *conn, int gfp)
153 153 {
154 154 struct rdsv3_loop_connection *lc;
155 155
156 156 RDSV3_DPRINTF4("rdsv3_loop_conn_alloc", "Enter(conn: %p)", conn);
157 157
158 158 lc = kmem_zalloc(sizeof (struct rdsv3_loop_connection), KM_NOSLEEP);
159 159 if (!lc)
160 160 return (-ENOMEM);
161 161
162 162 list_link_init(&lc->loop_node);
163 163 lc->conn = conn;
164 164 conn->c_transport_data = lc;
165 165
166 166 mutex_enter(&loop_conns_lock);
167 167 list_insert_tail(&loop_conns, lc);
168 168 mutex_exit(&loop_conns_lock);
169 169
170 170 RDSV3_DPRINTF4("rdsv3_loop_conn_alloc", "Return(conn: %p)", conn);
171 171
172 172 return (0);
173 173 }
174 174
175 175 static void
176 176 rdsv3_loop_conn_free(void *arg)
177 177 {
178 178 struct rdsv3_loop_connection *lc = arg;
179 179 RDSV3_DPRINTF5("rdsv3_loop_conn_free", "lc %p\n", lc);
180 180 list_remove_node(&lc->loop_node);
181 181 kmem_free(lc, sizeof (struct rdsv3_loop_connection));
182 182 }
183 183
184 184 static int
185 185 rdsv3_loop_conn_connect(struct rdsv3_connection *conn)
186 186 {
187 187 rdsv3_connect_complete(conn);
188 188 return (0);
189 189 }
190 190
191 191 /* ARGSUSED */
192 192 static void
193 193 rdsv3_loop_conn_shutdown(struct rdsv3_connection *conn)
194 194 {
195 195 }
196 196
197 197 void
198 198 rdsv3_loop_exit(void)
199 199 {
200 200 struct rdsv3_loop_connection *lc, *_lc;
201 201 list_t tmp_list;
202 202
203 203 RDSV3_DPRINTF4("rdsv3_loop_exit", "Enter");
204 204
205 205 list_create(&tmp_list, sizeof (struct rdsv3_loop_connection),
206 206 offsetof(struct rdsv3_loop_connection, loop_node));
207 207
208 208 /* avoid calling conn_destroy with irqs off */
209 209 mutex_enter(&loop_conns_lock);
210 210 list_splice(&loop_conns, &tmp_list);
211 211 mutex_exit(&loop_conns_lock);
212 212
213 213 RDSV3_FOR_EACH_LIST_NODE_SAFE(lc, _lc, &tmp_list, loop_node) {
214 214 ASSERT(!lc->conn->c_passive);
215 215 rdsv3_conn_destroy(lc->conn);
216 216 }
217 217
218 218 list_destroy(&loop_conns);
219 219 mutex_destroy(&loop_conns_lock);
↓ open down ↓ |
219 lines elided |
↑ open up ↑ |
220 220
221 221 RDSV3_DPRINTF4("rdsv3_loop_exit", "Return");
222 222 }
223 223
224 224 /*
225 225 * This is missing .xmit_* because loop doesn't go through generic
226 226 * rdsv3_send_xmit() and doesn't call rdsv3_recv_incoming(). .listen_stop and
227 227 * .laddr_check are missing because transport.c doesn't iterate over
228 228 * rdsv3_loop_transport.
229 229 */
230 -#ifndef __lock_lint
231 230 struct rdsv3_transport rdsv3_loop_transport = {
232 231 .xmit = rdsv3_loop_xmit,
233 232 .xmit_cong_map = rdsv3_loop_xmit_cong_map,
234 233 .recv = rdsv3_loop_recv,
235 234 .conn_alloc = rdsv3_loop_conn_alloc,
236 235 .conn_free = rdsv3_loop_conn_free,
237 236 .conn_connect = rdsv3_loop_conn_connect,
238 237 .conn_shutdown = rdsv3_loop_conn_shutdown,
239 238 .inc_copy_to_user = rdsv3_message_inc_copy_to_user,
240 239 .inc_free = rdsv3_loop_inc_free,
241 240 .t_name = "loopback",
242 241 };
243 -#else
244 -struct rdsv3_transport rdsv3_loop_transport;
245 -#endif
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX