2 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
3 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Copyright (C) 2005 Cluster File Systems, Inc. All rights reserved.
6 * Author: Eric Barton <eeb@bartonsoftware.com>
8 * This file is part of the Lustre file system, http://www.lustre.org
9 * Lustre is a trademark of Cluster File Systems, Inc.
11 * This file is confidential source code owned by Cluster File Systems.
12 * No viewing, modification, compilation, redistribution, or any other
13 * form of use is permitted except through a signed license agreement.
15 * If you have not signed such an agreement, then you have no rights to
16 * this file. Please destroy it immediately and contact CFS.
24 .lnd_startup = ptllnd_startup,
25 .lnd_shutdown = ptllnd_shutdown,
26 .lnd_ctl = ptllnd_ctl,
27 .lnd_send = ptllnd_send,
28 .lnd_recv = ptllnd_recv,
29 .lnd_eager_recv = ptllnd_eager_recv,
30 .lnd_notify = ptllnd_notify,
31 .lnd_wait = ptllnd_wait,
32 .lnd_setasync = ptllnd_setasync,
35 static int ptllnd_ni_count = 0;
37 static struct list_head ptllnd_idle_history;
38 static struct list_head ptllnd_history_list;
41 ptllnd_history_fini(void)
45 while (!list_empty(&ptllnd_idle_history)) {
46 he = list_entry(ptllnd_idle_history.next,
47 ptllnd_he_t, he_list);
49 list_del(&he->he_list);
50 LIBCFS_FREE(he, sizeof(*he));
53 while (!list_empty(&ptllnd_history_list)) {
54 he = list_entry(ptllnd_history_list.next,
55 ptllnd_he_t, he_list);
57 list_del(&he->he_list);
58 LIBCFS_FREE(he, sizeof(*he));
63 ptllnd_history_init(void)
70 CFS_INIT_LIST_HEAD(&ptllnd_idle_history);
71 CFS_INIT_LIST_HEAD(&ptllnd_history_list);
73 rc = ptllnd_parse_int_tunable(&n, "PTLLND_HISTORY", 0);
77 for (i = 0; i < n; i++) {
78 LIBCFS_ALLOC(he, sizeof(*he));
80 ptllnd_history_fini();
84 list_add(&he->he_list, &ptllnd_idle_history);
87 PTLLND_HISTORY("Init");
93 ptllnd_history(const char *fn, const char *file, const int line,
101 if (!list_empty(&ptllnd_idle_history)) {
102 he = list_entry(ptllnd_idle_history.next,
103 ptllnd_he_t, he_list);
104 } else if (!list_empty(&ptllnd_history_list)) {
105 he = list_entry(ptllnd_history_list.next,
106 ptllnd_he_t, he_list);
111 list_del(&he->he_list);
112 list_add_tail(&he->he_list, &ptllnd_history_list);
118 gettimeofday(&he->he_time, NULL);
121 vsnprintf(he->he_msg, sizeof(he->he_msg), fmt, ap);
126 ptllnd_dump_history(void)
130 PTLLND_HISTORY("dumping...");
132 while (!list_empty(&ptllnd_history_list)) {
133 he = list_entry(ptllnd_history_list.next,
134 ptllnd_he_t, he_list);
136 list_del(&he->he_list);
138 CDEBUG(D_WARNING, "%d %d.%06d (%s:%d:%s()) %s\n", he->he_seq,
139 (int)he->he_time.tv_sec, (int)he->he_time.tv_usec,
140 he->he_file, he->he_line, he->he_fn, he->he_msg);
142 list_add_tail(&he->he_list, &ptllnd_idle_history);
145 PTLLND_HISTORY("complete");
149 ptllnd_assert_wire_constants (void)
151 /* Wire protocol assertions generated by 'wirecheck'
152 * running on Linux fedora 2.6.11-co-0.6.4 #1 Mon Jun 19 05:36:13 UTC 2006 i686 i686 i386 GNU
153 * with gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) */
157 CLASSERT (PTL_RESERVED_MATCHBITS == 0x100);
158 CLASSERT (LNET_MSG_MATCHBITS == 0);
159 CLASSERT (PTLLND_MSG_MAGIC == 0x50746C4E);
160 CLASSERT (PTLLND_MSG_VERSION == 0x04);
161 CLASSERT (PTLLND_RDMA_OK == 0x00);
162 CLASSERT (PTLLND_RDMA_FAIL == 0x01);
163 CLASSERT (PTLLND_MSG_TYPE_INVALID == 0x00);
164 CLASSERT (PTLLND_MSG_TYPE_PUT == 0x01);
165 CLASSERT (PTLLND_MSG_TYPE_GET == 0x02);
166 CLASSERT (PTLLND_MSG_TYPE_IMMEDIATE == 0x03);
167 CLASSERT (PTLLND_MSG_TYPE_NOOP == 0x04);
168 CLASSERT (PTLLND_MSG_TYPE_HELLO == 0x05);
169 CLASSERT (PTLLND_MSG_TYPE_NAK == 0x06);
171 /* Checks for struct kptl_msg_t */
172 CLASSERT ((int)sizeof(kptl_msg_t) == 136);
173 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_magic) == 0);
174 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_magic) == 4);
175 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_version) == 4);
176 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_version) == 2);
177 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_type) == 6);
178 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_type) == 1);
179 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_credits) == 7);
180 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_credits) == 1);
181 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_nob) == 8);
182 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_nob) == 4);
183 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_cksum) == 12);
184 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_cksum) == 4);
185 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcnid) == 16);
186 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcnid) == 8);
187 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcstamp) == 24);
188 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcstamp) == 8);
189 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstnid) == 32);
190 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstnid) == 8);
191 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dststamp) == 40);
192 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dststamp) == 8);
193 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcpid) == 48);
194 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcpid) == 4);
195 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstpid) == 52);
196 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstpid) == 4);
197 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.immediate) == 56);
198 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.immediate) == 72);
199 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.rdma) == 56);
200 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.rdma) == 80);
201 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.hello) == 56);
202 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.hello) == 12);
204 /* Checks for struct kptl_immediate_msg_t */
205 CLASSERT ((int)sizeof(kptl_immediate_msg_t) == 72);
206 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_hdr) == 0);
207 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_hdr) == 72);
208 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_payload[13]) == 85);
209 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_payload[13]) == 1);
211 /* Checks for struct kptl_rdma_msg_t */
212 CLASSERT ((int)sizeof(kptl_rdma_msg_t) == 80);
213 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_hdr) == 0);
214 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_hdr) == 72);
215 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_matchbits) == 72);
216 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_matchbits) == 8);
218 /* Checks for struct kptl_hello_msg_t */
219 CLASSERT ((int)sizeof(kptl_hello_msg_t) == 12);
220 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_matchbits) == 0);
221 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_matchbits) == 8);
222 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_max_msg_size) == 8);
223 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_max_msg_size) == 4);
227 ptllnd_parse_int_tunable(int *value, char *name, int dflt)
229 char *env = getenv(name);
237 *value = strtoull(env, &end, 0);
241 CERROR("Can't parse tunable %s=%s\n", name, env);
246 ptllnd_get_tunables(lnet_ni_t *ni)
248 ptllnd_ni_t *plni = ni->ni_data;
254 /* Other tunable defaults depend on this */
255 rc = ptllnd_parse_int_tunable(&plni->plni_debug, "PTLLND_DEBUG", 0);
259 rc = ptllnd_parse_int_tunable(&plni->plni_portal,
260 "PTLLND_PORTAL", PTLLND_PORTAL);
264 rc = ptllnd_parse_int_tunable(&temp,
265 "PTLLND_PID", PTLLND_PID);
268 plni->plni_ptllnd_pid = (ptl_pid_t)temp;
270 rc = ptllnd_parse_int_tunable(&plni->plni_peer_credits,
271 "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
275 rc = ptllnd_parse_int_tunable(&max_msg_size,
276 "PTLLND_MAX_MSG_SIZE",
277 PTLLND_MAX_ULND_MSG_SIZE);
281 rc = ptllnd_parse_int_tunable(&msgs_per_buffer,
282 "PTLLND_MSGS_PER_BUFFER", 64);
286 rc = ptllnd_parse_int_tunable(&plni->plni_msgs_spare,
287 "PTLLND_MSGS_SPARE", 256);
291 rc = ptllnd_parse_int_tunable(&plni->plni_peer_hash_size,
292 "PTLLND_PEER_HASH_SIZE", 101);
297 rc = ptllnd_parse_int_tunable(&plni->plni_eq_size,
298 "PTLLND_EQ_SIZE", 1024);
302 rc = ptllnd_parse_int_tunable(&plni->plni_checksum,
303 "PTLLND_CHECKSUM", 0);
307 rc = ptllnd_parse_int_tunable(&plni->plni_max_tx_history,
309 plni->plni_debug ? 1024 : 0);
313 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_protocol_mismatch,
314 "PTLLND_ABORT_ON_PROTOCOL_MISMATCH", 1);
318 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_nak,
319 "PTLLND_ABORT_ON_NAK", 0);
323 rc = ptllnd_parse_int_tunable(&plni->plni_dump_on_nak,
324 "PTLLND_DUMP_ON_NAK", plni->plni_debug);
328 rc = ptllnd_parse_int_tunable(&plni->plni_watchdog_interval,
329 "PTLLND_WATCHDOG_INTERVAL", 1);
332 if (plni->plni_watchdog_interval <= 0)
333 plni->plni_watchdog_interval = 1;
335 rc = ptllnd_parse_int_tunable(&plni->plni_timeout,
336 "PTLLND_TIMEOUT", 50);
340 rc = ptllnd_parse_int_tunable(&plni->plni_long_wait,
342 plni->plni_debug ? 5 : plni->plni_timeout);
345 plni->plni_long_wait *= 1000; /* convert to mS */
347 plni->plni_max_msg_size = max_msg_size & ~7;
348 if (plni->plni_max_msg_size < PTLLND_MIN_BUFFER_SIZE)
349 plni->plni_max_msg_size = PTLLND_MIN_BUFFER_SIZE;
350 CLASSERT ((PTLLND_MIN_BUFFER_SIZE & 7) == 0);
351 CLASSERT (sizeof(kptl_msg_t) <= PTLLND_MIN_BUFFER_SIZE);
353 plni->plni_buffer_size = plni->plni_max_msg_size * msgs_per_buffer;
355 CDEBUG(D_NET, "portal = %d\n",plni->plni_portal);
356 CDEBUG(D_NET, "ptllnd_pid = %d\n",plni->plni_ptllnd_pid);
357 CDEBUG(D_NET, "max_msg_size = %d\n",max_msg_size);
358 CDEBUG(D_NET, "msgs_per_buffer = %d\n",msgs_per_buffer);
359 CDEBUG(D_NET, "msgs_spare = %d\n",plni->plni_msgs_spare);
360 CDEBUG(D_NET, "peer_hash_size = %d\n",plni->plni_peer_hash_size);
361 CDEBUG(D_NET, "eq_size = %d\n",plni->plni_eq_size);
362 CDEBUG(D_NET, "max_msg_size = %d\n",plni->plni_max_msg_size);
363 CDEBUG(D_NET, "buffer_size = %d\n",plni->plni_buffer_size);
369 ptllnd_create_buffer (lnet_ni_t *ni)
371 ptllnd_ni_t *plni = ni->ni_data;
372 ptllnd_buffer_t *buf;
374 LIBCFS_ALLOC(buf, sizeof(*buf));
376 CERROR("Can't allocate buffer descriptor\n");
382 CFS_INIT_LIST_HEAD(&buf->plb_list);
384 LIBCFS_ALLOC(buf->plb_buffer, plni->plni_buffer_size);
385 if (buf->plb_buffer == NULL) {
386 CERROR("Can't allocate buffer size %d\n",
387 plni->plni_buffer_size);
388 LIBCFS_FREE(buf, sizeof(*buf));
392 list_add(&buf->plb_list, &plni->plni_buffers);
393 plni->plni_nbuffers++;
399 ptllnd_destroy_buffer (ptllnd_buffer_t *buf)
401 ptllnd_ni_t *plni = buf->plb_ni->ni_data;
403 LASSERT (!buf->plb_posted);
405 plni->plni_nbuffers--;
406 list_del(&buf->plb_list);
407 LIBCFS_FREE(buf->plb_buffer, plni->plni_buffer_size);
408 LIBCFS_FREE(buf, sizeof(*buf));
412 ptllnd_size_buffers (lnet_ni_t *ni, int delta)
414 ptllnd_ni_t *plni = ni->ni_data;
415 ptllnd_buffer_t *buf;
420 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
421 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
423 plni->plni_nmsgs += delta;
424 LASSERT(plni->plni_nmsgs >= 0);
426 nmsgs = plni->plni_nmsgs + plni->plni_msgs_spare;
428 nbufs = (nmsgs * plni->plni_max_msg_size + plni->plni_buffer_size - 1) /
429 plni->plni_buffer_size;
431 while (nbufs > plni->plni_nbuffers) {
432 buf = ptllnd_create_buffer(ni);
437 rc = ptllnd_post_buffer(buf);
439 /* TODO - this path seems to orpahn the buffer
440 * in a state where its not posted and will never be
441 * However it does not leak the buffer as it's
442 * already been put onto the global buffer list
443 * and will be cleaned up
449 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
450 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
455 ptllnd_destroy_buffers (lnet_ni_t *ni)
457 ptllnd_ni_t *plni = ni->ni_data;
458 ptllnd_buffer_t *buf;
459 struct list_head *tmp;
460 struct list_head *nxt;
462 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
463 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
465 list_for_each_safe(tmp, nxt, &plni->plni_buffers) {
466 buf = list_entry(tmp, ptllnd_buffer_t, plb_list);
468 //CDEBUG(D_NET, "buf=%p posted=%d\n",buf,buf->plb_posted);
470 LASSERT (plni->plni_nbuffers > 0);
471 if (buf->plb_posted) {
472 time_t start = cfs_time_current_sec();
473 int w = plni->plni_long_wait;
475 LASSERT (plni->plni_nposted_buffers > 0);
477 #ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
478 (void) PtlMDUnlink(buf->plb_md);
480 while (buf->plb_posted) {
481 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
482 CWARN("Waited %ds to unlink buffer\n",
483 (int)(cfs_time_current_sec() - start));
489 while (buf->plb_posted) {
490 rc = PtlMDUnlink(buf->plb_md);
493 plni->plni_nposted_buffers--;
496 LASSERT (rc == PTL_MD_IN_USE);
497 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
498 CWARN("Waited %ds to unlink buffer\n",
499 cfs_time_current_sec() - start);
506 ptllnd_destroy_buffer(buf);
509 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
510 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
512 LASSERT (plni->plni_nposted_buffers == 0);
513 LASSERT (plni->plni_nbuffers == 0);
517 ptllnd_create_peer_hash (lnet_ni_t *ni)
519 ptllnd_ni_t *plni = ni->ni_data;
522 plni->plni_npeers = 0;
524 LIBCFS_ALLOC(plni->plni_peer_hash,
525 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
526 if (plni->plni_peer_hash == NULL) {
527 CERROR("Can't allocate ptllnd peer hash (size %d)\n",
528 plni->plni_peer_hash_size);
532 for (i = 0; i < plni->plni_peer_hash_size; i++)
533 CFS_INIT_LIST_HEAD(&plni->plni_peer_hash[i]);
539 ptllnd_destroy_peer_hash (lnet_ni_t *ni)
541 ptllnd_ni_t *plni = ni->ni_data;
544 LASSERT( plni->plni_npeers == 0);
546 for (i = 0; i < plni->plni_peer_hash_size; i++)
547 LASSERT (list_empty(&plni->plni_peer_hash[i]));
549 LIBCFS_FREE(plni->plni_peer_hash,
550 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
554 ptllnd_close_peers (lnet_ni_t *ni)
556 ptllnd_ni_t *plni = ni->ni_data;
560 for (i = 0; i < plni->plni_peer_hash_size; i++)
561 while (!list_empty(&plni->plni_peer_hash[i])) {
562 plp = list_entry(plni->plni_peer_hash[i].next,
563 ptllnd_peer_t, plp_list);
565 ptllnd_close_peer(plp, 0);
570 ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
573 case IOC_LIBCFS_DEBUG_PEER:
574 ptllnd_dump_debug(ni, *((lnet_process_id_t *)arg));
583 ptllnd_get_timestamp(void)
586 int rc = gettimeofday(&tv, NULL);
589 return ((__u64)tv.tv_sec) * 1000000 + tv.tv_usec;
593 ptllnd_shutdown (lnet_ni_t *ni)
595 ptllnd_ni_t *plni = ni->ni_data;
597 time_t start = cfs_time_current_sec();
598 int w = plni->plni_long_wait;
600 LASSERT (ptllnd_ni_count == 1);
601 plni->plni_max_tx_history = 0;
603 ptllnd_cull_tx_history(plni);
605 ptllnd_close_peers(ni);
606 ptllnd_destroy_buffers(ni);
608 while (plni->plni_npeers > 0) {
609 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
610 CWARN("Waited %ds for peers to shutdown\n",
611 (int)(cfs_time_current_sec() - start));
617 LASSERT (plni->plni_ntxs == 0);
618 LASSERT (plni->plni_nrxs == 0);
620 rc = PtlEQFree(plni->plni_eqh);
621 LASSERT (rc == PTL_OK);
623 rc = PtlNIFini(plni->plni_nih);
624 LASSERT (rc == PTL_OK);
626 ptllnd_destroy_peer_hash(ni);
627 LIBCFS_FREE(plni, sizeof(*plni));
632 ptllnd_startup (lnet_ni_t *ni)
637 /* could get limits from portals I guess... */
638 ni->ni_maxtxcredits =
639 ni->ni_peertxcredits = 1000;
641 if (ptllnd_ni_count != 0) {
642 CERROR("Can't have > 1 instance of ptllnd\n");
648 rc = ptllnd_history_init();
650 CERROR("Can't init history\n");
654 LIBCFS_ALLOC(plni, sizeof(*plni));
656 CERROR("Can't allocate ptllnd state\n");
663 plni->plni_stamp = ptllnd_get_timestamp();
666 plni->plni_ntx_history = 0;
667 plni->plni_watchdog_peeridx = 0;
668 plni->plni_watchdog_nextt = cfs_time_current_sec();
669 CFS_INIT_LIST_HEAD(&plni->plni_zombie_txs);
670 CFS_INIT_LIST_HEAD(&plni->plni_tx_history);
673 * Initilize buffer related data structures
675 CFS_INIT_LIST_HEAD(&plni->plni_buffers);
676 plni->plni_nbuffers = 0;
677 plni->plni_nposted_buffers = 0;
679 rc = ptllnd_get_tunables(ni);
683 rc = ptllnd_create_peer_hash(ni);
687 /* NB I most probably won't get the PID I requested here. It doesn't
688 * matter because I don't need a fixed PID (only connection acceptors
689 * need a "well known" PID). */
691 rc = PtlNIInit(PTL_IFACE_DEFAULT, plni->plni_ptllnd_pid,
692 NULL, NULL, &plni->plni_nih);
693 if (rc != PTL_OK && rc != PTL_IFACE_DUP) {
694 CERROR("PtlNIInit failed: %s(%d)\n",
695 ptllnd_errtype2str(rc), rc);
700 rc = PtlEQAlloc(plni->plni_nih, plni->plni_eq_size,
701 PTL_EQ_HANDLER_NONE, &plni->plni_eqh);
703 CERROR("PtlEQAlloc failed: %s(%d)\n",
704 ptllnd_errtype2str(rc), rc);
710 * Fetch the Portals NID
712 rc = PtlGetId(plni->plni_nih, &plni->plni_portals_id);
714 CERROR ("PtlGetID failed : %s(%d)\n",
715 ptllnd_errtype2str(rc), rc);
721 * Create the new NID. Based on the LND network type
722 * and the lower ni's address data.
724 ni->ni_nid = ptllnd_ptl2lnetnid(ni, plni->plni_portals_id.nid);
726 CDEBUG(D_NET, "ptl id =%s\n", ptllnd_ptlid2str(plni->plni_portals_id));
727 CDEBUG(D_NET, "lnet id =%s (passed back)\n",
728 libcfs_id2str((lnet_process_id_t) {
729 .nid = ni->ni_nid, .pid = the_lnet.ln_pid}));
731 rc = ptllnd_size_buffers(ni, 0);
738 ptllnd_destroy_buffers(ni);
739 PtlEQFree(plni->plni_eqh);
741 PtlNIFini(plni->plni_nih);
743 ptllnd_destroy_peer_hash(ni);
745 LIBCFS_FREE(plni, sizeof(*plni));
747 ptllnd_history_fini();
749 CDEBUG(D_NET, "<<< rc=%d\n",rc);
753 const char *ptllnd_evtype2str(int type)
755 #define DO_TYPE(x) case x: return #x;
758 DO_TYPE(PTL_EVENT_GET_START);
759 DO_TYPE(PTL_EVENT_GET_END);
760 DO_TYPE(PTL_EVENT_PUT_START);
761 DO_TYPE(PTL_EVENT_PUT_END);
762 DO_TYPE(PTL_EVENT_REPLY_START);
763 DO_TYPE(PTL_EVENT_REPLY_END);
764 DO_TYPE(PTL_EVENT_ACK);
765 DO_TYPE(PTL_EVENT_SEND_START);
766 DO_TYPE(PTL_EVENT_SEND_END);
767 DO_TYPE(PTL_EVENT_UNLINK);
769 return "<unknown event type>";
774 const char *ptllnd_msgtype2str(int type)
776 #define DO_TYPE(x) case x: return #x;
779 DO_TYPE(PTLLND_MSG_TYPE_INVALID);
780 DO_TYPE(PTLLND_MSG_TYPE_PUT);
781 DO_TYPE(PTLLND_MSG_TYPE_GET);
782 DO_TYPE(PTLLND_MSG_TYPE_IMMEDIATE);
783 DO_TYPE(PTLLND_MSG_TYPE_HELLO);
784 DO_TYPE(PTLLND_MSG_TYPE_NOOP);
785 DO_TYPE(PTLLND_MSG_TYPE_NAK);
787 return "<unknown msg type>";
792 const char *ptllnd_errtype2str(int type)
794 #define DO_TYPE(x) case x: return #x;
799 DO_TYPE(PTL_NO_SPACE);
800 DO_TYPE(PTL_ME_IN_USE);
801 DO_TYPE(PTL_NAL_FAILED);
802 DO_TYPE(PTL_NO_INIT);
803 DO_TYPE(PTL_IFACE_DUP);
804 DO_TYPE(PTL_IFACE_INVALID);
805 DO_TYPE(PTL_HANDLE_INVALID);
806 DO_TYPE(PTL_MD_INVALID);
807 DO_TYPE(PTL_ME_INVALID);
808 DO_TYPE(PTL_PROCESS_INVALID);
809 DO_TYPE(PTL_PT_INDEX_INVALID);
810 DO_TYPE(PTL_SR_INDEX_INVALID);
811 DO_TYPE(PTL_EQ_INVALID);
812 DO_TYPE(PTL_EQ_DROPPED);
813 DO_TYPE(PTL_EQ_EMPTY);
814 DO_TYPE(PTL_MD_NO_UPDATE);
816 DO_TYPE(PTL_AC_INDEX_INVALID);
817 DO_TYPE(PTL_MD_ILLEGAL);
818 DO_TYPE(PTL_ME_LIST_TOO_LONG);
819 DO_TYPE(PTL_MD_IN_USE);
820 DO_TYPE(PTL_NI_INVALID);
821 DO_TYPE(PTL_PID_INVALID);
822 DO_TYPE(PTL_PT_FULL);
823 DO_TYPE(PTL_VAL_FAILED);
824 DO_TYPE(PTL_NOT_IMPLEMENTED);
826 DO_TYPE(PTL_EQ_IN_USE);
827 DO_TYPE(PTL_PID_IN_USE);
828 DO_TYPE(PTL_INV_EQ_SIZE);
831 return "<unknown error type>";