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/connection.c
+++ new/usr/src/uts/common/io/ib/clients/rdsv3/connection.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 connection.c
7 7 * Oracle elects to have and use the contents of connection.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/types.h>
45 45 #include <sys/kmem.h>
46 46 #include <sys/rds.h>
47 47
48 48 #include <sys/ib/clients/rdsv3/rdsv3.h>
49 49 #include <sys/ib/clients/rdsv3/loop.h>
50 50 #include <sys/ib/clients/rdsv3/rdsv3_debug.h>
51 51
52 52 /* converting this to RCU is a chore for another day.. */
53 53 static krwlock_t rdsv3_conn_lock;
54 54 struct avl_tree rdsv3_conn_hash;
55 55 static struct kmem_cache *rdsv3_conn_slab = NULL;
56 56
57 57 #define rdsv3_conn_info_set(var, test, suffix) do { \
58 58 if (test) \
59 59 var |= RDS_INFO_CONNECTION_FLAG_##suffix; \
60 60 } while (0)
61 61
62 62
63 63 static struct rdsv3_connection *
64 64 rdsv3_conn_lookup(uint32_be_t laddr, uint32_be_t faddr, avl_index_t *pos)
65 65 {
66 66 struct rdsv3_connection *conn;
67 67 struct rdsv3_conn_info_s conn_info;
68 68 avl_index_t place = 0;
69 69
70 70 conn_info.c_laddr = laddr;
71 71 conn_info.c_faddr = faddr;
72 72
73 73 conn = avl_find(&rdsv3_conn_hash, &conn_info, &place);
74 74
75 75 RDSV3_DPRINTF5("rdsv3_conn_lookup",
76 76 "returning conn %p for %u.%u.%u.%u -> %u.%u.%u.%u",
77 77 conn, NIPQUAD(laddr), NIPQUAD(faddr));
78 78
79 79 if (pos != NULL)
80 80 *pos = place;
81 81
82 82 return (conn);
83 83 }
84 84
85 85 /*
86 86 * This is called by transports as they're bringing down a connection.
87 87 * It clears partial message state so that the transport can start sending
88 88 * and receiving over this connection again in the future. It is up to
89 89 * the transport to have serialized this call with its send and recv.
90 90 */
91 91 void
92 92 rdsv3_conn_reset(struct rdsv3_connection *conn)
93 93 {
94 94 RDSV3_DPRINTF2("rdsv3_conn_reset",
95 95 "connection %u.%u.%u.%u to %u.%u.%u.%u reset",
96 96 NIPQUAD(conn->c_laddr), NIPQUAD(conn->c_faddr));
97 97
98 98 rdsv3_stats_inc(s_conn_reset);
99 99 rdsv3_send_reset(conn);
100 100 conn->c_flags = 0;
101 101
102 102 /*
103 103 * Do not clear next_rx_seq here, else we cannot distinguish
104 104 * retransmitted packets from new packets, and will hand all
105 105 * of them to the application. That is not consistent with the
106 106 * reliability guarantees of RDS.
107 107 */
108 108 }
109 109
110 110 /*
111 111 * There is only every one 'conn' for a given pair of addresses in the
112 112 * system at a time. They contain messages to be retransmitted and so
113 113 * span the lifetime of the actual underlying transport connections.
114 114 *
115 115 * For now they are not garbage collected once they're created. They
116 116 * are torn down as the module is removed, if ever.
117 117 */
118 118 static struct rdsv3_connection *
119 119 __rdsv3_conn_create(uint32_be_t laddr, uint32_be_t faddr,
120 120 struct rdsv3_transport *trans, int gfp, int is_outgoing)
121 121 {
122 122 struct rdsv3_connection *conn, *parent = NULL;
123 123 avl_index_t pos;
124 124 int ret;
125 125
126 126 rw_enter(&rdsv3_conn_lock, RW_READER);
127 127 conn = rdsv3_conn_lookup(laddr, faddr, &pos);
128 128 if (conn &&
129 129 conn->c_loopback &&
130 130 conn->c_trans != &rdsv3_loop_transport &&
131 131 !is_outgoing) {
132 132 /*
133 133 * This is a looped back IB connection, and we're
134 134 * called by the code handling the incoming connect.
135 135 * We need a second connection object into which we
136 136 * can stick the other QP.
137 137 */
138 138 parent = conn;
139 139 conn = parent->c_passive;
140 140 }
141 141 rw_exit(&rdsv3_conn_lock);
142 142 if (conn)
143 143 goto out;
144 144
145 145 RDSV3_DPRINTF2("__rdsv3_conn_create", "Enter(%x -> %x)",
146 146 ntohl(laddr), ntohl(faddr));
147 147
148 148 conn = kmem_cache_alloc(rdsv3_conn_slab, gfp);
149 149 if (!conn) {
150 150 conn = ERR_PTR(-ENOMEM);
151 151 goto out;
152 152 }
153 153
154 154 /* see rdsv3_conn_constructor */
155 155 conn->c_laddr = laddr;
156 156 conn->c_faddr = faddr;
157 157
158 158 /*
159 159 * We don't allow sockets to send messages without binding.
160 160 * So, the IP address will already be there in the bind array.
161 161 * Mostly, this is a readonly operation.
162 162 * For now, passing GLOBAL_ZONEID.
163 163 */
164 164 conn->c_bucketp = rdsv3_find_ip_bucket(ntohl(laddr), GLOBAL_ZONEID);
165 165
166 166 ret = rdsv3_cong_get_maps(conn);
167 167 if (ret) {
168 168 kmem_cache_free(rdsv3_conn_slab, conn);
169 169 conn = ERR_PTR(ret);
170 170 goto out;
171 171 }
172 172
173 173 /*
174 174 * This is where a connection becomes loopback. If *any* RDS sockets
175 175 * can bind to the destination address then we'd rather the messages
176 176 * flow through loopback rather than either transport.
177 177 */
178 178 if (rdsv3_trans_get_preferred(faddr)) {
179 179 conn->c_loopback = 1;
180 180 if (is_outgoing && trans->t_prefer_loopback) {
181 181 /*
182 182 * "outgoing" connection - and the transport
183 183 * says it wants the connection handled by the
184 184 * loopback transport. This is what TCP does.
185 185 */
186 186 trans = &rdsv3_loop_transport;
187 187 }
188 188 }
189 189
190 190 conn->c_trans = trans;
191 191
192 192 ret = trans->conn_alloc(conn, gfp);
193 193 if (ret) {
194 194 kmem_cache_free(rdsv3_conn_slab, conn);
195 195 conn = ERR_PTR(ret);
196 196 goto out;
197 197 }
198 198
199 199 conn->c_state = RDSV3_CONN_DOWN;
200 200 conn->c_reconnect_jiffies = 0;
201 201 RDSV3_INIT_DELAYED_WORK(&conn->c_send_w, rdsv3_send_worker);
202 202 RDSV3_INIT_DELAYED_WORK(&conn->c_recv_w, rdsv3_recv_worker);
203 203 RDSV3_INIT_DELAYED_WORK(&conn->c_conn_w, rdsv3_connect_worker);
204 204 RDSV3_INIT_DELAYED_WORK(&conn->c_reap_w, rdsv3_reaper_worker);
205 205 RDSV3_INIT_WORK(&conn->c_down_w, rdsv3_shutdown_worker);
206 206 mutex_init(&conn->c_cm_lock, NULL, MUTEX_DRIVER, NULL);
207 207 conn->c_flags = 0;
208 208
209 209 RDSV3_DPRINTF2("__rdsv3_conn_create",
210 210 "allocated conn %p for %u.%u.%u.%u -> %u.%u.%u.%u over %s %s",
211 211 conn, NIPQUAD(laddr), NIPQUAD(faddr),
212 212 trans->t_name ? trans->t_name : "[unknown]",
213 213 is_outgoing ? "(outgoing)" : "");
214 214
215 215 /*
216 216 * Since we ran without holding the conn lock, someone could
217 217 * have created the same conn (either normal or passive) in the
218 218 * interim. We check while holding the lock. If we won, we complete
219 219 * init and return our conn. If we lost, we rollback and return the
220 220 * other one.
221 221 */
222 222 rw_enter(&rdsv3_conn_lock, RW_WRITER);
223 223 if (parent) {
224 224 /* Creating passive conn */
225 225 if (parent->c_passive) {
226 226 trans->conn_free(conn->c_transport_data);
227 227 kmem_cache_free(rdsv3_conn_slab, conn);
228 228 conn = parent->c_passive;
229 229 } else {
230 230 parent->c_passive = conn;
231 231 rdsv3_cong_add_conn(conn);
232 232 }
233 233 } else {
234 234 /* Creating normal conn */
235 235 struct rdsv3_connection *found;
236 236
237 237 found = rdsv3_conn_lookup(laddr, faddr, &pos);
238 238 if (found) {
239 239 trans->conn_free(conn->c_transport_data);
240 240 kmem_cache_free(rdsv3_conn_slab, conn);
241 241 conn = found;
242 242 } else {
243 243 avl_insert(&rdsv3_conn_hash, conn, pos);
244 244 rdsv3_cong_add_conn(conn);
245 245 rdsv3_queue_delayed_work(rdsv3_wq, &conn->c_reap_w,
246 246 RDSV3_REAPER_WAIT_JIFFIES);
247 247 }
248 248 }
249 249
250 250 rw_exit(&rdsv3_conn_lock);
251 251
252 252 RDSV3_DPRINTF2("__rdsv3_conn_create", "Return(conn: %p)", conn);
253 253
254 254 out:
255 255 return (conn);
256 256 }
257 257
258 258 struct rdsv3_connection *
259 259 rdsv3_conn_create(uint32_be_t laddr, uint32_be_t faddr,
260 260 struct rdsv3_transport *trans, int gfp)
261 261 {
262 262 return (__rdsv3_conn_create(laddr, faddr, trans, gfp, 0));
263 263 }
264 264
265 265 struct rdsv3_connection *
266 266 rdsv3_conn_create_outgoing(uint32_be_t laddr, uint32_be_t faddr,
267 267 struct rdsv3_transport *trans, int gfp)
268 268 {
269 269 return (__rdsv3_conn_create(laddr, faddr, trans, gfp, 1));
270 270 }
271 271
272 272 extern struct avl_tree rdsv3_conn_hash;
273 273
274 274 void
275 275 rdsv3_conn_shutdown(struct rdsv3_connection *conn)
276 276 {
277 277 RDSV3_DPRINTF2("rdsv3_conn_shutdown", "Enter(conn: %p)", conn);
278 278
279 279 /* shut it down unless it's down already */
280 280 if (!rdsv3_conn_transition(conn, RDSV3_CONN_DOWN, RDSV3_CONN_DOWN)) {
281 281 /*
282 282 * Quiesce the connection mgmt handlers before we start tearing
283 283 * things down. We don't hold the mutex for the entire
284 284 * duration of the shutdown operation, else we may be
285 285 * deadlocking with the CM handler. Instead, the CM event
286 286 * handler is supposed to check for state DISCONNECTING
287 287 */
288 288 mutex_enter(&conn->c_cm_lock);
289 289 if (!rdsv3_conn_transition(conn, RDSV3_CONN_UP,
290 290 RDSV3_CONN_DISCONNECTING) &&
291 291 !rdsv3_conn_transition(conn, RDSV3_CONN_ERROR,
292 292 RDSV3_CONN_DISCONNECTING)) {
293 293 RDSV3_DPRINTF2("rdsv3_conn_shutdown",
294 294 "shutdown called in state %d",
295 295 atomic_get(&conn->c_state));
296 296 rdsv3_conn_drop(conn);
297 297 mutex_exit(&conn->c_cm_lock);
298 298 return;
299 299 }
300 300 mutex_exit(&conn->c_cm_lock);
301 301
302 302 /* verify everybody's out of rds_send_xmit() */
303 303 mutex_enter(&conn->c_send_lock);
304 304 while (atomic_get(&conn->c_senders)) {
305 305 mutex_exit(&conn->c_send_lock);
306 306 delay(1);
307 307 mutex_enter(&conn->c_send_lock);
308 308 }
309 309
310 310 conn->c_trans->conn_shutdown(conn);
311 311 rdsv3_conn_reset(conn);
312 312 mutex_exit(&conn->c_send_lock);
↓ open down ↓ |
312 lines elided |
↑ open up ↑ |
313 313
314 314 if (!rdsv3_conn_transition(conn, RDSV3_CONN_DISCONNECTING,
315 315 RDSV3_CONN_DOWN)) {
316 316 /*
317 317 * This can happen - eg when we're in the middle of
318 318 * tearing down the connection, and someone unloads
319 319 * the rds module.
320 320 * Quite reproduceable with loopback connections.
321 321 * Mostly harmless.
322 322 */
323 -#ifndef __lock_lint
324 323 RDSV3_DPRINTF2("rdsv3_conn_shutdown",
325 324 "failed to transition to state DOWN, "
326 325 "current statis is: %d",
327 326 atomic_get(&conn->c_state));
328 327 rdsv3_conn_drop(conn);
329 -#endif
330 328 return;
331 329 }
332 330 }
333 331
334 332 /*
335 333 * Then reconnect if it's still live.
336 334 * The passive side of an IB loopback connection is never added
337 335 * to the conn hash, so we never trigger a reconnect on this
338 336 * conn - the reconnect is always triggered by the active peer.
339 337 */
340 338 rdsv3_cancel_delayed_work(&conn->c_conn_w);
341 339
342 340 {
343 341 struct rdsv3_conn_info_s conn_info;
344 342
345 343 conn_info.c_laddr = conn->c_laddr;
346 344 conn_info.c_faddr = conn->c_faddr;
347 345 if (avl_find(&rdsv3_conn_hash, &conn_info, NULL) == conn)
348 346 rdsv3_queue_reconnect(conn);
349 347 }
350 348 RDSV3_DPRINTF2("rdsv3_conn_shutdown", "Exit");
351 349 }
352 350
353 351 /*
354 352 * Stop and free a connection.
355 353 */
356 354 void
357 355 rdsv3_conn_destroy(struct rdsv3_connection *conn)
358 356 {
359 357 struct rdsv3_message *rm, *rtmp;
360 358 list_t to_be_dropped;
361 359
362 360 RDSV3_DPRINTF4("rdsv3_conn_destroy",
363 361 "freeing conn %p for %u.%u.%u.%u -> %u.%u.%u.%u",
364 362 conn, NIPQUAD(conn->c_laddr), NIPQUAD(conn->c_faddr));
365 363
366 364 avl_remove(&rdsv3_conn_hash, conn);
367 365
368 366 rdsv3_cancel_delayed_work(&conn->c_reap_w);
369 367 rdsv3_cancel_delayed_work(&conn->c_send_w);
370 368 rdsv3_cancel_delayed_work(&conn->c_recv_w);
371 369
372 370 rdsv3_conn_shutdown(conn);
373 371
374 372 /* tear down queued messages */
375 373
376 374 list_create(&to_be_dropped, sizeof (struct rdsv3_message),
377 375 offsetof(struct rdsv3_message, m_conn_item));
378 376
379 377 RDSV3_FOR_EACH_LIST_NODE_SAFE(rm, rtmp, &conn->c_retrans, m_conn_item) {
380 378 list_remove_node(&rm->m_conn_item);
381 379 list_insert_tail(&to_be_dropped, rm);
382 380 }
383 381
384 382 RDSV3_FOR_EACH_LIST_NODE_SAFE(rm, rtmp, &conn->c_send_queue,
385 383 m_conn_item) {
386 384 list_remove_node(&rm->m_conn_item);
387 385 list_insert_tail(&to_be_dropped, rm);
388 386 }
389 387
390 388 RDSV3_FOR_EACH_LIST_NODE_SAFE(rm, rtmp, &to_be_dropped, m_conn_item) {
391 389 clear_bit(RDSV3_MSG_ON_CONN, &rm->m_flags);
392 390 list_remove_node(&rm->m_conn_item);
393 391 rdsv3_message_put(rm);
394 392 }
395 393
396 394 if (conn->c_xmit_rm)
397 395 rdsv3_message_put(conn->c_xmit_rm);
398 396
399 397 conn->c_trans->conn_free(conn->c_transport_data);
400 398
401 399 /*
402 400 * The congestion maps aren't freed up here. They're
403 401 * freed by rdsv3_cong_exit() after all the connections
404 402 * have been freed.
405 403 */
406 404 rdsv3_cong_remove_conn(conn);
407 405
408 406 ASSERT(list_is_empty(&conn->c_retrans));
409 407 kmem_cache_free(rdsv3_conn_slab, conn);
410 408
411 409 }
412 410
413 411 /* ARGSUSED */
414 412 static void
415 413 rdsv3_conn_message_info(struct rsock *sock, unsigned int len,
416 414 struct rdsv3_info_iterator *iter,
417 415 struct rdsv3_info_lengths *lens,
418 416 int want_send)
419 417 {
420 418 struct list *list;
421 419 struct rdsv3_connection *conn;
422 420 struct rdsv3_message *rm;
423 421 unsigned int total = 0;
424 422
425 423 RDSV3_DPRINTF4("rdsv3_conn_message_info", "Enter");
426 424
427 425 len /= sizeof (struct rds_info_message);
428 426
429 427 rw_enter(&rdsv3_conn_lock, RW_READER);
430 428
431 429 if (avl_is_empty(&rdsv3_conn_hash)) {
432 430 /* no connections */
433 431 rw_exit(&rdsv3_conn_lock);
434 432 return;
435 433 }
436 434
437 435 conn = (struct rdsv3_connection *)avl_first(&rdsv3_conn_hash);
438 436
439 437 do {
440 438 if (want_send)
441 439 list = &conn->c_send_queue;
442 440 else
443 441 list = &conn->c_retrans;
444 442
445 443 mutex_enter(&conn->c_lock);
446 444
447 445 /* XXX too lazy to maintain counts.. */
448 446 RDSV3_FOR_EACH_LIST_NODE(rm, list, m_conn_item) {
449 447 total++;
450 448 if (total <= len)
451 449 rdsv3_inc_info_copy(&rm->m_inc, iter,
452 450 conn->c_laddr, conn->c_faddr, 0);
453 451 }
454 452
455 453 mutex_exit(&conn->c_lock);
456 454
457 455 conn = AVL_NEXT(&rdsv3_conn_hash, conn);
458 456 } while (conn != NULL);
459 457 rw_exit(&rdsv3_conn_lock);
460 458
461 459 lens->nr = total;
462 460 lens->each = sizeof (struct rds_info_message);
463 461
464 462 RDSV3_DPRINTF4("rdsv3_conn_message_info", "Return");
465 463 }
466 464
467 465 static void
468 466 rdsv3_conn_message_info_send(struct rsock *sock, unsigned int len,
469 467 struct rdsv3_info_iterator *iter,
470 468 struct rdsv3_info_lengths *lens)
471 469 {
472 470 rdsv3_conn_message_info(sock, len, iter, lens, 1);
473 471 }
474 472
475 473 static void
476 474 rdsv3_conn_message_info_retrans(struct rsock *sock,
477 475 unsigned int len,
478 476 struct rdsv3_info_iterator *iter,
479 477 struct rdsv3_info_lengths *lens)
480 478 {
481 479 rdsv3_conn_message_info(sock, len, iter, lens, 0);
482 480 }
483 481
484 482 /* ARGSUSED */
485 483 void
486 484 rdsv3_for_each_conn_info(struct rsock *sock, unsigned int len,
487 485 struct rdsv3_info_iterator *iter,
488 486 struct rdsv3_info_lengths *lens,
489 487 int (*visitor)(struct rdsv3_connection *, void *),
490 488 size_t item_len)
491 489 {
492 490 uint8_t *buffer;
493 491 struct rdsv3_connection *conn;
494 492
495 493 rw_enter(&rdsv3_conn_lock, RW_READER);
496 494
497 495 lens->nr = 0;
498 496 lens->each = item_len;
499 497
500 498 if (avl_is_empty(&rdsv3_conn_hash)) {
501 499 /* no connections */
502 500 rw_exit(&rdsv3_conn_lock);
503 501 return;
504 502 }
505 503
506 504 /* allocate a little extra as this can get cast to a uint64_t */
507 505 buffer = kmem_zalloc(item_len + 8, KM_SLEEP);
508 506
509 507 conn = (struct rdsv3_connection *)avl_first(&rdsv3_conn_hash);
510 508
511 509 do {
512 510 /* XXX no c_lock usage.. */
513 511 if (visitor(conn, buffer)) {
514 512 /*
515 513 * We copy as much as we can fit in the buffer,
516 514 * but we count all items so that the caller
517 515 * can resize the buffer.
518 516 */
519 517 if (len >= item_len) {
520 518 RDSV3_DPRINTF4("rdsv3_for_each_conn_info",
521 519 "buffer: %p iter: %p bytes: %d", buffer,
522 520 iter->addr + iter->offset, item_len);
523 521 rdsv3_info_copy(iter, buffer, item_len);
524 522 len -= item_len;
525 523 }
526 524 lens->nr++;
527 525 }
528 526 conn = AVL_NEXT(&rdsv3_conn_hash, conn);
529 527 } while (conn != NULL);
530 528 rw_exit(&rdsv3_conn_lock);
531 529
532 530 kmem_free(buffer, item_len + 8);
533 531 }
534 532
535 533 static int
536 534 rdsv3_conn_info_visitor(struct rdsv3_connection *conn, void *buffer)
537 535 {
538 536 struct rds_info_connection *cinfo = buffer;
539 537
540 538 cinfo->next_tx_seq = conn->c_next_tx_seq;
541 539 cinfo->next_rx_seq = conn->c_next_rx_seq;
542 540 cinfo->laddr = conn->c_laddr;
543 541 cinfo->faddr = conn->c_faddr;
544 542 (void) strncpy((char *)cinfo->transport, conn->c_trans->t_name,
545 543 sizeof (cinfo->transport));
546 544 cinfo->flags = 0;
547 545
548 546 rdsv3_conn_info_set(cinfo->flags,
549 547 MUTEX_HELD(&conn->c_send_lock), SENDING);
550 548
551 549 /* XXX Future: return the state rather than these funky bits */
552 550 rdsv3_conn_info_set(cinfo->flags,
553 551 atomic_get(&conn->c_state) == RDSV3_CONN_CONNECTING,
554 552 CONNECTING);
555 553 rdsv3_conn_info_set(cinfo->flags,
556 554 atomic_get(&conn->c_state) == RDSV3_CONN_UP,
557 555 CONNECTED);
558 556 return (1);
559 557 }
560 558
561 559 static void
562 560 rdsv3_conn_info(struct rsock *sock, unsigned int len,
563 561 struct rdsv3_info_iterator *iter, struct rdsv3_info_lengths *lens)
564 562 {
565 563 rdsv3_for_each_conn_info(sock, len, iter, lens,
566 564 rdsv3_conn_info_visitor, sizeof (struct rds_info_connection));
567 565 }
568 566
569 567 int
570 568 rdsv3_conn_init()
571 569 {
572 570 RDSV3_DPRINTF4("rdsv3_conn_init", "Enter");
573 571
574 572 rdsv3_conn_slab = kmem_cache_create("rdsv3_connection",
575 573 sizeof (struct rdsv3_connection), 0, rdsv3_conn_constructor,
576 574 rdsv3_conn_destructor, NULL, NULL, NULL, 0);
577 575 if (!rdsv3_conn_slab) {
578 576 RDSV3_DPRINTF2("rdsv3_conn_init",
579 577 "kmem_cache_create(rdsv3_conn_slab) failed");
580 578 return (-ENOMEM);
581 579 }
582 580
583 581 avl_create(&rdsv3_conn_hash, rdsv3_conn_compare,
584 582 sizeof (struct rdsv3_connection), offsetof(struct rdsv3_connection,
585 583 c_hash_node));
586 584
587 585 rw_init(&rdsv3_conn_lock, NULL, RW_DRIVER, NULL);
588 586
589 587 rdsv3_loop_init();
590 588
591 589 rdsv3_info_register_func(RDS_INFO_CONNECTIONS, rdsv3_conn_info);
592 590 rdsv3_info_register_func(RDS_INFO_SEND_MESSAGES,
593 591 rdsv3_conn_message_info_send);
594 592 rdsv3_info_register_func(RDS_INFO_RETRANS_MESSAGES,
595 593 rdsv3_conn_message_info_retrans);
596 594
597 595 RDSV3_DPRINTF4("rdsv3_conn_init", "Return");
598 596
599 597 return (0);
600 598 }
601 599
602 600 void
603 601 rdsv3_conn_exit()
604 602 {
605 603 RDSV3_DPRINTF4("rdsv3_conn_exit", "Enter");
606 604
607 605 rdsv3_loop_exit();
608 606
609 607 rw_destroy(&rdsv3_conn_lock);
610 608 avl_destroy(&rdsv3_conn_hash);
611 609
612 610 ASSERT(rdsv3_conn_slab);
613 611 kmem_cache_destroy(rdsv3_conn_slab);
614 612
615 613 RDSV3_DPRINTF4("rdsv3_conn_exit", "Return");
616 614 }
617 615
618 616 /*
619 617 * Force a disconnect
620 618 */
621 619 void
622 620 rdsv3_conn_drop(struct rdsv3_connection *conn)
623 621 {
624 622 conn->c_state = RDSV3_CONN_ERROR;
625 623 rdsv3_queue_work(rdsv3_wq, &conn->c_down_w);
626 624 }
↓ open down ↓ |
287 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX