4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/ulnds/ptllnd/ptllnd.c
36 * Author: Eric Barton <eeb@bartonsoftware.com>
43 .lnd_startup = ptllnd_startup,
44 .lnd_shutdown = ptllnd_shutdown,
45 .lnd_ctl = ptllnd_ctl,
46 .lnd_send = ptllnd_send,
47 .lnd_recv = ptllnd_recv,
48 .lnd_eager_recv = ptllnd_eager_recv,
49 .lnd_wait = ptllnd_wait,
50 .lnd_setasync = ptllnd_setasync,
53 static int ptllnd_ni_count = 0;
55 static cfs_list_t ptllnd_idle_history;
56 static cfs_list_t ptllnd_history_list;
59 ptllnd_history_fini(void)
63 while (!cfs_list_empty(&ptllnd_idle_history)) {
64 he = cfs_list_entry(ptllnd_idle_history.next,
65 ptllnd_he_t, he_list);
67 cfs_list_del(&he->he_list);
68 LIBCFS_FREE(he, sizeof(*he));
71 while (!cfs_list_empty(&ptllnd_history_list)) {
72 he = cfs_list_entry(ptllnd_history_list.next,
73 ptllnd_he_t, he_list);
75 cfs_list_del(&he->he_list);
76 LIBCFS_FREE(he, sizeof(*he));
81 ptllnd_history_init(void)
88 CFS_INIT_LIST_HEAD(&ptllnd_idle_history);
89 CFS_INIT_LIST_HEAD(&ptllnd_history_list);
91 rc = ptllnd_parse_int_tunable(&n, "PTLLND_HISTORY", 0);
95 for (i = 0; i < n; i++) {
96 LIBCFS_ALLOC(he, sizeof(*he));
98 ptllnd_history_fini();
102 cfs_list_add(&he->he_list, &ptllnd_idle_history);
105 PTLLND_HISTORY("Init");
111 ptllnd_history(const char *fn, const char *file, const int line,
112 const char *fmt, ...)
119 if (!cfs_list_empty(&ptllnd_idle_history)) {
120 he = cfs_list_entry(ptllnd_idle_history.next,
121 ptllnd_he_t, he_list);
122 } else if (!cfs_list_empty(&ptllnd_history_list)) {
123 he = cfs_list_entry(ptllnd_history_list.next,
124 ptllnd_he_t, he_list);
129 cfs_list_del(&he->he_list);
130 cfs_list_add_tail(&he->he_list, &ptllnd_history_list);
136 gettimeofday(&he->he_time, NULL);
139 vsnprintf(he->he_msg, sizeof(he->he_msg), fmt, ap);
144 ptllnd_dump_history(void)
148 PTLLND_HISTORY("dumping...");
150 while (!cfs_list_empty(&ptllnd_history_list)) {
151 he = cfs_list_entry(ptllnd_history_list.next,
152 ptllnd_he_t, he_list);
154 cfs_list_del(&he->he_list);
156 CDEBUG(D_WARNING, "%d %d.%06d (%s:%d:%s()) %s\n", he->he_seq,
157 (int)he->he_time.tv_sec, (int)he->he_time.tv_usec,
158 he->he_file, he->he_line, he->he_fn, he->he_msg);
160 cfs_list_add_tail(&he->he_list, &ptllnd_idle_history);
163 PTLLND_HISTORY("complete");
167 ptllnd_assert_wire_constants (void)
169 /* Wire protocol assertions generated by 'wirecheck'
170 * running on Linux fedora 2.6.11-co-0.6.4 #1 Mon Jun 19 05:36:13 UTC 2006 i686 i686 i386 GNU
171 * with gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) */
175 CLASSERT (PTL_RESERVED_MATCHBITS == 0x100);
176 CLASSERT (LNET_MSG_MATCHBITS == 0);
177 CLASSERT (PTLLND_MSG_MAGIC == 0x50746C4E);
178 CLASSERT (PTLLND_MSG_VERSION == 0x04);
179 CLASSERT (PTLLND_RDMA_OK == 0x00);
180 CLASSERT (PTLLND_RDMA_FAIL == 0x01);
181 CLASSERT (PTLLND_MSG_TYPE_INVALID == 0x00);
182 CLASSERT (PTLLND_MSG_TYPE_PUT == 0x01);
183 CLASSERT (PTLLND_MSG_TYPE_GET == 0x02);
184 CLASSERT (PTLLND_MSG_TYPE_IMMEDIATE == 0x03);
185 CLASSERT (PTLLND_MSG_TYPE_NOOP == 0x04);
186 CLASSERT (PTLLND_MSG_TYPE_HELLO == 0x05);
187 CLASSERT (PTLLND_MSG_TYPE_NAK == 0x06);
189 /* Checks for struct kptl_msg_t */
190 CLASSERT ((int)sizeof(kptl_msg_t) == 136);
191 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_magic) == 0);
192 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_magic) == 4);
193 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_version) == 4);
194 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_version) == 2);
195 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_type) == 6);
196 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_type) == 1);
197 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_credits) == 7);
198 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_credits) == 1);
199 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_nob) == 8);
200 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_nob) == 4);
201 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_cksum) == 12);
202 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_cksum) == 4);
203 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcnid) == 16);
204 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcnid) == 8);
205 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcstamp) == 24);
206 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcstamp) == 8);
207 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstnid) == 32);
208 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstnid) == 8);
209 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dststamp) == 40);
210 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dststamp) == 8);
211 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcpid) == 48);
212 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcpid) == 4);
213 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstpid) == 52);
214 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstpid) == 4);
215 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.immediate) == 56);
216 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.immediate) == 72);
217 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.rdma) == 56);
218 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.rdma) == 80);
219 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.hello) == 56);
220 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.hello) == 12);
222 /* Checks for struct kptl_immediate_msg_t */
223 CLASSERT ((int)sizeof(kptl_immediate_msg_t) == 72);
224 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_hdr) == 0);
225 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_hdr) == 72);
226 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_payload[13]) == 85);
227 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_payload[13]) == 1);
229 /* Checks for struct kptl_rdma_msg_t */
230 CLASSERT ((int)sizeof(kptl_rdma_msg_t) == 80);
231 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_hdr) == 0);
232 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_hdr) == 72);
233 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_matchbits) == 72);
234 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_matchbits) == 8);
236 /* Checks for struct kptl_hello_msg_t */
237 CLASSERT ((int)sizeof(kptl_hello_msg_t) == 12);
238 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_matchbits) == 0);
239 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_matchbits) == 8);
240 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_max_msg_size) == 8);
241 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_max_msg_size) == 4);
245 ptllnd_parse_int_tunable(int *value, char *name, int dflt)
247 char *env = getenv(name);
255 *value = strtoull(env, &end, 0);
259 CERROR("Can't parse tunable %s=%s\n", name, env);
264 ptllnd_get_tunables(lnet_ni_t *ni)
266 ptllnd_ni_t *plni = ni->ni_data;
272 /* Other tunable defaults depend on this */
273 rc = ptllnd_parse_int_tunable(&plni->plni_debug, "PTLLND_DEBUG", 0);
277 rc = ptllnd_parse_int_tunable(&plni->plni_portal,
278 "PTLLND_PORTAL", PTLLND_PORTAL);
282 rc = ptllnd_parse_int_tunable(&temp,
283 "PTLLND_PID", PTLLND_PID);
286 plni->plni_ptllnd_pid = (ptl_pid_t)temp;
288 rc = ptllnd_parse_int_tunable(&plni->plni_peer_credits,
289 "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
292 if (plni->plni_peer_credits > PTLLND_MSG_MAX_CREDITS) {
293 CERROR("PTLLND_PEERCREDITS must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
297 rc = ptllnd_parse_int_tunable(&max_msg_size,
298 "PTLLND_MAX_MSG_SIZE",
299 PTLLND_MAX_ULND_MSG_SIZE);
303 rc = ptllnd_parse_int_tunable(&msgs_per_buffer,
304 "PTLLND_MSGS_PER_BUFFER", 64);
308 rc = ptllnd_parse_int_tunable(&plni->plni_msgs_spare,
309 "PTLLND_MSGS_SPARE", 256);
313 rc = ptllnd_parse_int_tunable(&plni->plni_peer_hash_size,
314 "PTLLND_PEER_HASH_SIZE", 101);
319 rc = ptllnd_parse_int_tunable(&plni->plni_eq_size,
320 "PTLLND_EQ_SIZE", 1024);
324 rc = ptllnd_parse_int_tunable(&plni->plni_checksum,
325 "PTLLND_CHECKSUM", 0);
329 rc = ptllnd_parse_int_tunable(&plni->plni_max_tx_history,
331 plni->plni_debug ? 1024 : 0);
335 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_protocol_mismatch,
336 "PTLLND_ABORT_ON_PROTOCOL_MISMATCH", 1);
340 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_nak,
341 "PTLLND_ABORT_ON_NAK", 0);
345 rc = ptllnd_parse_int_tunable(&plni->plni_dump_on_nak,
346 "PTLLND_DUMP_ON_NAK", plni->plni_debug);
350 rc = ptllnd_parse_int_tunable(&plni->plni_watchdog_interval,
351 "PTLLND_WATCHDOG_INTERVAL", 1);
354 if (plni->plni_watchdog_interval <= 0)
355 plni->plni_watchdog_interval = 1;
357 rc = ptllnd_parse_int_tunable(&plni->plni_timeout,
358 "PTLLND_TIMEOUT", 50);
362 rc = ptllnd_parse_int_tunable(&plni->plni_long_wait,
364 plni->plni_debug ? 5 : plni->plni_timeout);
367 plni->plni_long_wait *= 1000; /* convert to mS */
369 plni->plni_max_msg_size = max_msg_size & ~7;
370 if (plni->plni_max_msg_size < PTLLND_MIN_BUFFER_SIZE)
371 plni->plni_max_msg_size = PTLLND_MIN_BUFFER_SIZE;
372 CLASSERT ((PTLLND_MIN_BUFFER_SIZE & 7) == 0);
373 CLASSERT (sizeof(kptl_msg_t) <= PTLLND_MIN_BUFFER_SIZE);
375 plni->plni_buffer_size = plni->plni_max_msg_size * msgs_per_buffer;
377 CDEBUG(D_NET, "portal = %d\n",plni->plni_portal);
378 CDEBUG(D_NET, "ptllnd_pid = %d\n",plni->plni_ptllnd_pid);
379 CDEBUG(D_NET, "max_msg_size = %d\n",max_msg_size);
380 CDEBUG(D_NET, "msgs_per_buffer = %d\n",msgs_per_buffer);
381 CDEBUG(D_NET, "msgs_spare = %d\n",plni->plni_msgs_spare);
382 CDEBUG(D_NET, "peer_hash_size = %d\n",plni->plni_peer_hash_size);
383 CDEBUG(D_NET, "eq_size = %d\n",plni->plni_eq_size);
384 CDEBUG(D_NET, "max_msg_size = %d\n",plni->plni_max_msg_size);
385 CDEBUG(D_NET, "buffer_size = %d\n",plni->plni_buffer_size);
391 ptllnd_create_buffer (lnet_ni_t *ni)
393 ptllnd_ni_t *plni = ni->ni_data;
394 ptllnd_buffer_t *buf;
396 LIBCFS_ALLOC(buf, sizeof(*buf));
398 CERROR("Can't allocate buffer descriptor\n");
404 CFS_INIT_LIST_HEAD(&buf->plb_list);
406 LIBCFS_ALLOC(buf->plb_buffer, plni->plni_buffer_size);
407 if (buf->plb_buffer == NULL) {
408 CERROR("Can't allocate buffer size %d\n",
409 plni->plni_buffer_size);
410 LIBCFS_FREE(buf, sizeof(*buf));
414 cfs_list_add(&buf->plb_list, &plni->plni_buffers);
415 plni->plni_nbuffers++;
421 ptllnd_destroy_buffer (ptllnd_buffer_t *buf)
423 ptllnd_ni_t *plni = buf->plb_ni->ni_data;
425 LASSERT (!buf->plb_posted);
427 plni->plni_nbuffers--;
428 cfs_list_del(&buf->plb_list);
429 LIBCFS_FREE(buf->plb_buffer, plni->plni_buffer_size);
430 LIBCFS_FREE(buf, sizeof(*buf));
434 ptllnd_size_buffers (lnet_ni_t *ni, int delta)
436 ptllnd_ni_t *plni = ni->ni_data;
437 ptllnd_buffer_t *buf;
442 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
443 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
445 plni->plni_nmsgs += delta;
446 LASSERT(plni->plni_nmsgs >= 0);
448 nmsgs = plni->plni_nmsgs + plni->plni_msgs_spare;
450 nbufs = (nmsgs * plni->plni_max_msg_size + plni->plni_buffer_size - 1) /
451 plni->plni_buffer_size;
453 while (nbufs > plni->plni_nbuffers) {
454 buf = ptllnd_create_buffer(ni);
459 rc = ptllnd_post_buffer(buf);
461 /* TODO - this path seems to orpahn the buffer
462 * in a state where its not posted and will never be
463 * However it does not leak the buffer as it's
464 * already been put onto the global buffer list
465 * and will be cleaned up
471 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
472 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
477 ptllnd_destroy_buffers (lnet_ni_t *ni)
479 ptllnd_ni_t *plni = ni->ni_data;
480 ptllnd_buffer_t *buf;
484 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
485 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
487 cfs_list_for_each_safe(tmp, nxt, &plni->plni_buffers) {
488 buf = cfs_list_entry(tmp, ptllnd_buffer_t, plb_list);
490 //CDEBUG(D_NET, "buf=%p posted=%d\n",buf,buf->plb_posted);
492 LASSERT (plni->plni_nbuffers > 0);
493 if (buf->plb_posted) {
494 time_t start = cfs_time_current_sec();
495 int w = plni->plni_long_wait;
497 LASSERT (plni->plni_nposted_buffers > 0);
499 #ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
500 (void) PtlMDUnlink(buf->plb_md);
502 while (buf->plb_posted) {
503 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
504 CWARN("Waited %ds to unlink buffer\n",
505 (int)(cfs_time_current_sec() - start));
511 while (buf->plb_posted) {
512 rc = PtlMDUnlink(buf->plb_md);
515 plni->plni_nposted_buffers--;
518 LASSERT (rc == PTL_MD_IN_USE);
519 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
520 CWARN("Waited %ds to unlink buffer\n",
521 cfs_time_current_sec() - start);
528 ptllnd_destroy_buffer(buf);
531 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
532 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
534 LASSERT (plni->plni_nposted_buffers == 0);
535 LASSERT (plni->plni_nbuffers == 0);
539 ptllnd_create_peer_hash (lnet_ni_t *ni)
541 ptllnd_ni_t *plni = ni->ni_data;
544 plni->plni_npeers = 0;
546 LIBCFS_ALLOC(plni->plni_peer_hash,
547 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
548 if (plni->plni_peer_hash == NULL) {
549 CERROR("Can't allocate ptllnd peer hash (size %d)\n",
550 plni->plni_peer_hash_size);
554 for (i = 0; i < plni->plni_peer_hash_size; i++)
555 CFS_INIT_LIST_HEAD(&plni->plni_peer_hash[i]);
561 ptllnd_destroy_peer_hash (lnet_ni_t *ni)
563 ptllnd_ni_t *plni = ni->ni_data;
566 LASSERT( plni->plni_npeers == 0);
568 for (i = 0; i < plni->plni_peer_hash_size; i++)
569 LASSERT (cfs_list_empty(&plni->plni_peer_hash[i]));
571 LIBCFS_FREE(plni->plni_peer_hash,
572 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
576 ptllnd_close_peers (lnet_ni_t *ni)
578 ptllnd_ni_t *plni = ni->ni_data;
582 for (i = 0; i < plni->plni_peer_hash_size; i++)
583 while (!cfs_list_empty(&plni->plni_peer_hash[i])) {
584 plp = cfs_list_entry(plni->plni_peer_hash[i].next,
585 ptllnd_peer_t, plp_list);
587 ptllnd_close_peer(plp, 0);
592 ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
595 case IOC_LIBCFS_DEBUG_PEER:
596 ptllnd_dump_debug(ni, *((lnet_process_id_t *)arg));
605 ptllnd_get_timestamp(void)
608 int rc = gettimeofday(&tv, NULL);
611 return ((__u64)tv.tv_sec) * 1000000 + tv.tv_usec;
615 ptllnd_shutdown (lnet_ni_t *ni)
617 ptllnd_ni_t *plni = ni->ni_data;
619 time_t start = cfs_time_current_sec();
620 int w = plni->plni_long_wait;
622 LASSERT (ptllnd_ni_count == 1);
623 plni->plni_max_tx_history = 0;
625 ptllnd_cull_tx_history(plni);
627 ptllnd_close_peers(ni);
628 ptllnd_destroy_buffers(ni);
630 while (plni->plni_npeers > 0) {
631 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
632 CWARN("Waited %ds for peers to shutdown\n",
633 (int)(cfs_time_current_sec() - start));
639 LASSERT (plni->plni_ntxs == 0);
640 LASSERT (plni->plni_nrxs == 0);
642 rc = PtlEQFree(plni->plni_eqh);
643 LASSERT (rc == PTL_OK);
645 rc = PtlNIFini(plni->plni_nih);
646 LASSERT (rc == PTL_OK);
648 ptllnd_destroy_peer_hash(ni);
649 LIBCFS_FREE(plni, sizeof(*plni));
654 ptllnd_startup (lnet_ni_t *ni)
659 /* could get limits from portals I guess... */
660 ni->ni_maxtxcredits =
661 ni->ni_peertxcredits = 1000;
663 if (ptllnd_ni_count != 0) {
664 CERROR("Can't have > 1 instance of ptllnd\n");
670 rc = ptllnd_history_init();
672 CERROR("Can't init history\n");
676 LIBCFS_ALLOC(plni, sizeof(*plni));
678 CERROR("Can't allocate ptllnd state\n");
685 plni->plni_stamp = ptllnd_get_timestamp();
688 plni->plni_ntx_history = 0;
689 plni->plni_watchdog_peeridx = 0;
690 plni->plni_watchdog_nextt = cfs_time_current_sec();
691 CFS_INIT_LIST_HEAD(&plni->plni_zombie_txs);
692 CFS_INIT_LIST_HEAD(&plni->plni_tx_history);
695 * Initilize buffer related data structures
697 CFS_INIT_LIST_HEAD(&plni->plni_buffers);
698 plni->plni_nbuffers = 0;
699 plni->plni_nposted_buffers = 0;
701 rc = ptllnd_get_tunables(ni);
705 rc = ptllnd_create_peer_hash(ni);
709 /* NB I most probably won't get the PID I requested here. It doesn't
710 * matter because I don't need a fixed PID (only connection acceptors
711 * need a "well known" PID). */
713 rc = PtlNIInit(PTL_IFACE_DEFAULT, plni->plni_ptllnd_pid,
714 NULL, NULL, &plni->plni_nih);
715 if (rc != PTL_OK && rc != PTL_IFACE_DUP) {
716 CERROR("PtlNIInit failed: %s(%d)\n",
717 ptllnd_errtype2str(rc), rc);
722 rc = PtlEQAlloc(plni->plni_nih, plni->plni_eq_size,
723 PTL_EQ_HANDLER_NONE, &plni->plni_eqh);
725 CERROR("PtlEQAlloc failed: %s(%d)\n",
726 ptllnd_errtype2str(rc), rc);
732 * Fetch the Portals NID
734 rc = PtlGetId(plni->plni_nih, &plni->plni_portals_id);
736 CERROR ("PtlGetID failed : %s(%d)\n",
737 ptllnd_errtype2str(rc), rc);
743 * Create the new NID. Based on the LND network type
744 * and the lower ni's address data.
746 ni->ni_nid = ptllnd_ptl2lnetnid(ni, plni->plni_portals_id.nid);
748 CDEBUG(D_NET, "ptl id =%s\n", ptllnd_ptlid2str(plni->plni_portals_id));
749 CDEBUG(D_NET, "lnet id =%s (passed back)\n",
750 libcfs_id2str((lnet_process_id_t) {
751 .nid = ni->ni_nid, .pid = the_lnet.ln_pid}));
753 rc = ptllnd_size_buffers(ni, 0);
760 ptllnd_destroy_buffers(ni);
761 PtlEQFree(plni->plni_eqh);
763 PtlNIFini(plni->plni_nih);
765 ptllnd_destroy_peer_hash(ni);
767 LIBCFS_FREE(plni, sizeof(*plni));
769 ptllnd_history_fini();
771 CDEBUG(D_NET, "<<< rc=%d\n",rc);
775 const char *ptllnd_evtype2str(int type)
777 #define DO_TYPE(x) case x: return #x;
780 DO_TYPE(PTL_EVENT_GET_START);
781 DO_TYPE(PTL_EVENT_GET_END);
782 DO_TYPE(PTL_EVENT_PUT_START);
783 DO_TYPE(PTL_EVENT_PUT_END);
784 DO_TYPE(PTL_EVENT_REPLY_START);
785 DO_TYPE(PTL_EVENT_REPLY_END);
786 DO_TYPE(PTL_EVENT_ACK);
787 DO_TYPE(PTL_EVENT_SEND_START);
788 DO_TYPE(PTL_EVENT_SEND_END);
789 DO_TYPE(PTL_EVENT_UNLINK);
791 return "<unknown event type>";
796 const char *ptllnd_msgtype2str(int type)
798 #define DO_TYPE(x) case x: return #x;
801 DO_TYPE(PTLLND_MSG_TYPE_INVALID);
802 DO_TYPE(PTLLND_MSG_TYPE_PUT);
803 DO_TYPE(PTLLND_MSG_TYPE_GET);
804 DO_TYPE(PTLLND_MSG_TYPE_IMMEDIATE);
805 DO_TYPE(PTLLND_MSG_TYPE_HELLO);
806 DO_TYPE(PTLLND_MSG_TYPE_NOOP);
807 DO_TYPE(PTLLND_MSG_TYPE_NAK);
809 return "<unknown msg type>";
814 const char *ptllnd_errtype2str(int type)
816 #define DO_TYPE(x) case x: return #x;
821 DO_TYPE(PTL_NO_SPACE);
822 DO_TYPE(PTL_ME_IN_USE);
823 DO_TYPE(PTL_NAL_FAILED);
824 DO_TYPE(PTL_NO_INIT);
825 DO_TYPE(PTL_IFACE_DUP);
826 DO_TYPE(PTL_IFACE_INVALID);
827 DO_TYPE(PTL_HANDLE_INVALID);
828 DO_TYPE(PTL_MD_INVALID);
829 DO_TYPE(PTL_ME_INVALID);
830 DO_TYPE(PTL_PROCESS_INVALID);
831 DO_TYPE(PTL_PT_INDEX_INVALID);
832 DO_TYPE(PTL_SR_INDEX_INVALID);
833 DO_TYPE(PTL_EQ_INVALID);
834 DO_TYPE(PTL_EQ_DROPPED);
835 DO_TYPE(PTL_EQ_EMPTY);
836 DO_TYPE(PTL_MD_NO_UPDATE);
838 DO_TYPE(PTL_AC_INDEX_INVALID);
839 DO_TYPE(PTL_MD_ILLEGAL);
840 DO_TYPE(PTL_ME_LIST_TOO_LONG);
841 DO_TYPE(PTL_MD_IN_USE);
842 DO_TYPE(PTL_NI_INVALID);
843 DO_TYPE(PTL_PID_INVALID);
844 DO_TYPE(PTL_PT_FULL);
845 DO_TYPE(PTL_VAL_FAILED);
846 DO_TYPE(PTL_NOT_IMPLEMENTED);
848 DO_TYPE(PTL_EQ_IN_USE);
849 DO_TYPE(PTL_PID_IN_USE);
850 DO_TYPE(PTL_INV_EQ_SIZE);
853 return "<unknown error type>";