1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lnet/ulnds/ptllnd/ptllnd.c
38 * Author: Eric Barton <eeb@bartonsoftware.com>
45 .lnd_startup = ptllnd_startup,
46 .lnd_shutdown = ptllnd_shutdown,
47 .lnd_ctl = ptllnd_ctl,
48 .lnd_send = ptllnd_send,
49 .lnd_recv = ptllnd_recv,
50 .lnd_eager_recv = ptllnd_eager_recv,
51 .lnd_notify = ptllnd_notify,
52 .lnd_wait = ptllnd_wait,
53 .lnd_setasync = ptllnd_setasync,
56 static int ptllnd_ni_count = 0;
58 static struct list_head ptllnd_idle_history;
59 static struct list_head ptllnd_history_list;
62 ptllnd_history_fini(void)
66 while (!list_empty(&ptllnd_idle_history)) {
67 he = list_entry(ptllnd_idle_history.next,
68 ptllnd_he_t, he_list);
70 list_del(&he->he_list);
71 LIBCFS_FREE(he, sizeof(*he));
74 while (!list_empty(&ptllnd_history_list)) {
75 he = list_entry(ptllnd_history_list.next,
76 ptllnd_he_t, he_list);
78 list_del(&he->he_list);
79 LIBCFS_FREE(he, sizeof(*he));
84 ptllnd_history_init(void)
91 CFS_INIT_LIST_HEAD(&ptllnd_idle_history);
92 CFS_INIT_LIST_HEAD(&ptllnd_history_list);
94 rc = ptllnd_parse_int_tunable(&n, "PTLLND_HISTORY", 0);
98 for (i = 0; i < n; i++) {
99 LIBCFS_ALLOC(he, sizeof(*he));
101 ptllnd_history_fini();
105 list_add(&he->he_list, &ptllnd_idle_history);
108 PTLLND_HISTORY("Init");
114 ptllnd_history(const char *fn, const char *file, const int line,
115 const char *fmt, ...)
122 if (!list_empty(&ptllnd_idle_history)) {
123 he = list_entry(ptllnd_idle_history.next,
124 ptllnd_he_t, he_list);
125 } else if (!list_empty(&ptllnd_history_list)) {
126 he = list_entry(ptllnd_history_list.next,
127 ptllnd_he_t, he_list);
132 list_del(&he->he_list);
133 list_add_tail(&he->he_list, &ptllnd_history_list);
139 gettimeofday(&he->he_time, NULL);
142 vsnprintf(he->he_msg, sizeof(he->he_msg), fmt, ap);
147 ptllnd_dump_history(void)
151 PTLLND_HISTORY("dumping...");
153 while (!list_empty(&ptllnd_history_list)) {
154 he = list_entry(ptllnd_history_list.next,
155 ptllnd_he_t, he_list);
157 list_del(&he->he_list);
159 CDEBUG(D_WARNING, "%d %d.%06d (%s:%d:%s()) %s\n", he->he_seq,
160 (int)he->he_time.tv_sec, (int)he->he_time.tv_usec,
161 he->he_file, he->he_line, he->he_fn, he->he_msg);
163 list_add_tail(&he->he_list, &ptllnd_idle_history);
166 PTLLND_HISTORY("complete");
170 ptllnd_assert_wire_constants (void)
172 /* Wire protocol assertions generated by 'wirecheck'
173 * running on Linux fedora 2.6.11-co-0.6.4 #1 Mon Jun 19 05:36:13 UTC 2006 i686 i686 i386 GNU
174 * with gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) */
178 CLASSERT (PTL_RESERVED_MATCHBITS == 0x100);
179 CLASSERT (LNET_MSG_MATCHBITS == 0);
180 CLASSERT (PTLLND_MSG_MAGIC == 0x50746C4E);
181 CLASSERT (PTLLND_MSG_VERSION == 0x04);
182 CLASSERT (PTLLND_RDMA_OK == 0x00);
183 CLASSERT (PTLLND_RDMA_FAIL == 0x01);
184 CLASSERT (PTLLND_MSG_TYPE_INVALID == 0x00);
185 CLASSERT (PTLLND_MSG_TYPE_PUT == 0x01);
186 CLASSERT (PTLLND_MSG_TYPE_GET == 0x02);
187 CLASSERT (PTLLND_MSG_TYPE_IMMEDIATE == 0x03);
188 CLASSERT (PTLLND_MSG_TYPE_NOOP == 0x04);
189 CLASSERT (PTLLND_MSG_TYPE_HELLO == 0x05);
190 CLASSERT (PTLLND_MSG_TYPE_NAK == 0x06);
192 /* Checks for struct kptl_msg_t */
193 CLASSERT ((int)sizeof(kptl_msg_t) == 136);
194 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_magic) == 0);
195 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_magic) == 4);
196 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_version) == 4);
197 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_version) == 2);
198 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_type) == 6);
199 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_type) == 1);
200 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_credits) == 7);
201 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_credits) == 1);
202 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_nob) == 8);
203 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_nob) == 4);
204 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_cksum) == 12);
205 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_cksum) == 4);
206 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcnid) == 16);
207 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcnid) == 8);
208 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcstamp) == 24);
209 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcstamp) == 8);
210 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstnid) == 32);
211 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstnid) == 8);
212 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dststamp) == 40);
213 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dststamp) == 8);
214 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcpid) == 48);
215 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcpid) == 4);
216 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstpid) == 52);
217 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstpid) == 4);
218 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.immediate) == 56);
219 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.immediate) == 72);
220 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.rdma) == 56);
221 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.rdma) == 80);
222 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.hello) == 56);
223 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.hello) == 12);
225 /* Checks for struct kptl_immediate_msg_t */
226 CLASSERT ((int)sizeof(kptl_immediate_msg_t) == 72);
227 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_hdr) == 0);
228 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_hdr) == 72);
229 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_payload[13]) == 85);
230 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_payload[13]) == 1);
232 /* Checks for struct kptl_rdma_msg_t */
233 CLASSERT ((int)sizeof(kptl_rdma_msg_t) == 80);
234 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_hdr) == 0);
235 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_hdr) == 72);
236 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_matchbits) == 72);
237 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_matchbits) == 8);
239 /* Checks for struct kptl_hello_msg_t */
240 CLASSERT ((int)sizeof(kptl_hello_msg_t) == 12);
241 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_matchbits) == 0);
242 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_matchbits) == 8);
243 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_max_msg_size) == 8);
244 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_max_msg_size) == 4);
248 ptllnd_parse_int_tunable(int *value, char *name, int dflt)
250 char *env = getenv(name);
258 *value = strtoull(env, &end, 0);
262 CERROR("Can't parse tunable %s=%s\n", name, env);
267 ptllnd_get_tunables(lnet_ni_t *ni)
269 ptllnd_ni_t *plni = ni->ni_data;
275 /* Other tunable defaults depend on this */
276 rc = ptllnd_parse_int_tunable(&plni->plni_debug, "PTLLND_DEBUG", 0);
280 rc = ptllnd_parse_int_tunable(&plni->plni_portal,
281 "PTLLND_PORTAL", PTLLND_PORTAL);
285 rc = ptllnd_parse_int_tunable(&temp,
286 "PTLLND_PID", PTLLND_PID);
289 plni->plni_ptllnd_pid = (ptl_pid_t)temp;
291 rc = ptllnd_parse_int_tunable(&plni->plni_peer_credits,
292 "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
295 /* kptl_msg_t::ptlm_credits is only a __u8 */
296 if (plni->plni_peer_credits > 255) {
297 CERROR("PTLLND_PEERCREDITS must be <= 255\n");
301 rc = ptllnd_parse_int_tunable(&max_msg_size,
302 "PTLLND_MAX_MSG_SIZE",
303 PTLLND_MAX_ULND_MSG_SIZE);
307 rc = ptllnd_parse_int_tunable(&msgs_per_buffer,
308 "PTLLND_MSGS_PER_BUFFER", 64);
312 rc = ptllnd_parse_int_tunable(&plni->plni_msgs_spare,
313 "PTLLND_MSGS_SPARE", 256);
317 rc = ptllnd_parse_int_tunable(&plni->plni_peer_hash_size,
318 "PTLLND_PEER_HASH_SIZE", 101);
323 rc = ptllnd_parse_int_tunable(&plni->plni_eq_size,
324 "PTLLND_EQ_SIZE", 1024);
328 rc = ptllnd_parse_int_tunable(&plni->plni_checksum,
329 "PTLLND_CHECKSUM", 0);
333 rc = ptllnd_parse_int_tunable(&plni->plni_max_tx_history,
335 plni->plni_debug ? 1024 : 0);
339 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_protocol_mismatch,
340 "PTLLND_ABORT_ON_PROTOCOL_MISMATCH", 1);
344 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_nak,
345 "PTLLND_ABORT_ON_NAK", 0);
349 rc = ptllnd_parse_int_tunable(&plni->plni_dump_on_nak,
350 "PTLLND_DUMP_ON_NAK", plni->plni_debug);
354 rc = ptllnd_parse_int_tunable(&plni->plni_watchdog_interval,
355 "PTLLND_WATCHDOG_INTERVAL", 1);
358 if (plni->plni_watchdog_interval <= 0)
359 plni->plni_watchdog_interval = 1;
361 rc = ptllnd_parse_int_tunable(&plni->plni_timeout,
362 "PTLLND_TIMEOUT", 50);
366 rc = ptllnd_parse_int_tunable(&plni->plni_long_wait,
368 plni->plni_debug ? 5 : plni->plni_timeout);
371 plni->plni_long_wait *= 1000; /* convert to mS */
373 plni->plni_max_msg_size = max_msg_size & ~7;
374 if (plni->plni_max_msg_size < PTLLND_MIN_BUFFER_SIZE)
375 plni->plni_max_msg_size = PTLLND_MIN_BUFFER_SIZE;
376 CLASSERT ((PTLLND_MIN_BUFFER_SIZE & 7) == 0);
377 CLASSERT (sizeof(kptl_msg_t) <= PTLLND_MIN_BUFFER_SIZE);
379 plni->plni_buffer_size = plni->plni_max_msg_size * msgs_per_buffer;
381 CDEBUG(D_NET, "portal = %d\n",plni->plni_portal);
382 CDEBUG(D_NET, "ptllnd_pid = %d\n",plni->plni_ptllnd_pid);
383 CDEBUG(D_NET, "max_msg_size = %d\n",max_msg_size);
384 CDEBUG(D_NET, "msgs_per_buffer = %d\n",msgs_per_buffer);
385 CDEBUG(D_NET, "msgs_spare = %d\n",plni->plni_msgs_spare);
386 CDEBUG(D_NET, "peer_hash_size = %d\n",plni->plni_peer_hash_size);
387 CDEBUG(D_NET, "eq_size = %d\n",plni->plni_eq_size);
388 CDEBUG(D_NET, "max_msg_size = %d\n",plni->plni_max_msg_size);
389 CDEBUG(D_NET, "buffer_size = %d\n",plni->plni_buffer_size);
395 ptllnd_create_buffer (lnet_ni_t *ni)
397 ptllnd_ni_t *plni = ni->ni_data;
398 ptllnd_buffer_t *buf;
400 LIBCFS_ALLOC(buf, sizeof(*buf));
402 CERROR("Can't allocate buffer descriptor\n");
408 CFS_INIT_LIST_HEAD(&buf->plb_list);
410 LIBCFS_ALLOC(buf->plb_buffer, plni->plni_buffer_size);
411 if (buf->plb_buffer == NULL) {
412 CERROR("Can't allocate buffer size %d\n",
413 plni->plni_buffer_size);
414 LIBCFS_FREE(buf, sizeof(*buf));
418 list_add(&buf->plb_list, &plni->plni_buffers);
419 plni->plni_nbuffers++;
425 ptllnd_destroy_buffer (ptllnd_buffer_t *buf)
427 ptllnd_ni_t *plni = buf->plb_ni->ni_data;
429 LASSERT (!buf->plb_posted);
431 plni->plni_nbuffers--;
432 list_del(&buf->plb_list);
433 LIBCFS_FREE(buf->plb_buffer, plni->plni_buffer_size);
434 LIBCFS_FREE(buf, sizeof(*buf));
438 ptllnd_size_buffers (lnet_ni_t *ni, int delta)
440 ptllnd_ni_t *plni = ni->ni_data;
441 ptllnd_buffer_t *buf;
446 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
447 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
449 plni->plni_nmsgs += delta;
450 LASSERT(plni->plni_nmsgs >= 0);
452 nmsgs = plni->plni_nmsgs + plni->plni_msgs_spare;
454 nbufs = (nmsgs * plni->plni_max_msg_size + plni->plni_buffer_size - 1) /
455 plni->plni_buffer_size;
457 while (nbufs > plni->plni_nbuffers) {
458 buf = ptllnd_create_buffer(ni);
463 rc = ptllnd_post_buffer(buf);
465 /* TODO - this path seems to orpahn the buffer
466 * in a state where its not posted and will never be
467 * However it does not leak the buffer as it's
468 * already been put onto the global buffer list
469 * and will be cleaned up
475 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
476 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
481 ptllnd_destroy_buffers (lnet_ni_t *ni)
483 ptllnd_ni_t *plni = ni->ni_data;
484 ptllnd_buffer_t *buf;
485 struct list_head *tmp;
486 struct list_head *nxt;
488 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
489 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
491 list_for_each_safe(tmp, nxt, &plni->plni_buffers) {
492 buf = list_entry(tmp, ptllnd_buffer_t, plb_list);
494 //CDEBUG(D_NET, "buf=%p posted=%d\n",buf,buf->plb_posted);
496 LASSERT (plni->plni_nbuffers > 0);
497 if (buf->plb_posted) {
498 time_t start = cfs_time_current_sec();
499 int w = plni->plni_long_wait;
501 LASSERT (plni->plni_nposted_buffers > 0);
503 #ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
504 (void) PtlMDUnlink(buf->plb_md);
506 while (buf->plb_posted) {
507 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
508 CWARN("Waited %ds to unlink buffer\n",
509 (int)(cfs_time_current_sec() - start));
515 while (buf->plb_posted) {
516 rc = PtlMDUnlink(buf->plb_md);
519 plni->plni_nposted_buffers--;
522 LASSERT (rc == PTL_MD_IN_USE);
523 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
524 CWARN("Waited %ds to unlink buffer\n",
525 cfs_time_current_sec() - start);
532 ptllnd_destroy_buffer(buf);
535 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
536 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
538 LASSERT (plni->plni_nposted_buffers == 0);
539 LASSERT (plni->plni_nbuffers == 0);
543 ptllnd_create_peer_hash (lnet_ni_t *ni)
545 ptllnd_ni_t *plni = ni->ni_data;
548 plni->plni_npeers = 0;
550 LIBCFS_ALLOC(plni->plni_peer_hash,
551 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
552 if (plni->plni_peer_hash == NULL) {
553 CERROR("Can't allocate ptllnd peer hash (size %d)\n",
554 plni->plni_peer_hash_size);
558 for (i = 0; i < plni->plni_peer_hash_size; i++)
559 CFS_INIT_LIST_HEAD(&plni->plni_peer_hash[i]);
565 ptllnd_destroy_peer_hash (lnet_ni_t *ni)
567 ptllnd_ni_t *plni = ni->ni_data;
570 LASSERT( plni->plni_npeers == 0);
572 for (i = 0; i < plni->plni_peer_hash_size; i++)
573 LASSERT (list_empty(&plni->plni_peer_hash[i]));
575 LIBCFS_FREE(plni->plni_peer_hash,
576 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
580 ptllnd_close_peers (lnet_ni_t *ni)
582 ptllnd_ni_t *plni = ni->ni_data;
586 for (i = 0; i < plni->plni_peer_hash_size; i++)
587 while (!list_empty(&plni->plni_peer_hash[i])) {
588 plp = list_entry(plni->plni_peer_hash[i].next,
589 ptllnd_peer_t, plp_list);
591 ptllnd_close_peer(plp, 0);
596 ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
599 case IOC_LIBCFS_DEBUG_PEER:
600 ptllnd_dump_debug(ni, *((lnet_process_id_t *)arg));
609 ptllnd_get_timestamp(void)
612 int rc = gettimeofday(&tv, NULL);
615 return ((__u64)tv.tv_sec) * 1000000 + tv.tv_usec;
619 ptllnd_shutdown (lnet_ni_t *ni)
621 ptllnd_ni_t *plni = ni->ni_data;
623 time_t start = cfs_time_current_sec();
624 int w = plni->plni_long_wait;
626 LASSERT (ptllnd_ni_count == 1);
627 plni->plni_max_tx_history = 0;
629 ptllnd_cull_tx_history(plni);
631 ptllnd_close_peers(ni);
632 ptllnd_destroy_buffers(ni);
634 while (plni->plni_npeers > 0) {
635 if (w > 0 && cfs_time_current_sec() > start + w/1000) {
636 CWARN("Waited %ds for peers to shutdown\n",
637 (int)(cfs_time_current_sec() - start));
643 LASSERT (plni->plni_ntxs == 0);
644 LASSERT (plni->plni_nrxs == 0);
646 rc = PtlEQFree(plni->plni_eqh);
647 LASSERT (rc == PTL_OK);
649 rc = PtlNIFini(plni->plni_nih);
650 LASSERT (rc == PTL_OK);
652 ptllnd_destroy_peer_hash(ni);
653 LIBCFS_FREE(plni, sizeof(*plni));
658 ptllnd_startup (lnet_ni_t *ni)
663 /* could get limits from portals I guess... */
664 ni->ni_maxtxcredits =
665 ni->ni_peertxcredits = 1000;
667 if (ptllnd_ni_count != 0) {
668 CERROR("Can't have > 1 instance of ptllnd\n");
674 rc = ptllnd_history_init();
676 CERROR("Can't init history\n");
680 LIBCFS_ALLOC(plni, sizeof(*plni));
682 CERROR("Can't allocate ptllnd state\n");
689 plni->plni_stamp = ptllnd_get_timestamp();
692 plni->plni_ntx_history = 0;
693 plni->plni_watchdog_peeridx = 0;
694 plni->plni_watchdog_nextt = cfs_time_current_sec();
695 CFS_INIT_LIST_HEAD(&plni->plni_zombie_txs);
696 CFS_INIT_LIST_HEAD(&plni->plni_tx_history);
699 * Initilize buffer related data structures
701 CFS_INIT_LIST_HEAD(&plni->plni_buffers);
702 plni->plni_nbuffers = 0;
703 plni->plni_nposted_buffers = 0;
705 rc = ptllnd_get_tunables(ni);
709 rc = ptllnd_create_peer_hash(ni);
713 /* NB I most probably won't get the PID I requested here. It doesn't
714 * matter because I don't need a fixed PID (only connection acceptors
715 * need a "well known" PID). */
717 rc = PtlNIInit(PTL_IFACE_DEFAULT, plni->plni_ptllnd_pid,
718 NULL, NULL, &plni->plni_nih);
719 if (rc != PTL_OK && rc != PTL_IFACE_DUP) {
720 CERROR("PtlNIInit failed: %s(%d)\n",
721 ptllnd_errtype2str(rc), rc);
726 rc = PtlEQAlloc(plni->plni_nih, plni->plni_eq_size,
727 PTL_EQ_HANDLER_NONE, &plni->plni_eqh);
729 CERROR("PtlEQAlloc failed: %s(%d)\n",
730 ptllnd_errtype2str(rc), rc);
736 * Fetch the Portals NID
738 rc = PtlGetId(plni->plni_nih, &plni->plni_portals_id);
740 CERROR ("PtlGetID failed : %s(%d)\n",
741 ptllnd_errtype2str(rc), rc);
747 * Create the new NID. Based on the LND network type
748 * and the lower ni's address data.
750 ni->ni_nid = ptllnd_ptl2lnetnid(ni, plni->plni_portals_id.nid);
752 CDEBUG(D_NET, "ptl id =%s\n", ptllnd_ptlid2str(plni->plni_portals_id));
753 CDEBUG(D_NET, "lnet id =%s (passed back)\n",
754 libcfs_id2str((lnet_process_id_t) {
755 .nid = ni->ni_nid, .pid = the_lnet.ln_pid}));
757 rc = ptllnd_size_buffers(ni, 0);
764 ptllnd_destroy_buffers(ni);
765 PtlEQFree(plni->plni_eqh);
767 PtlNIFini(plni->plni_nih);
769 ptllnd_destroy_peer_hash(ni);
771 LIBCFS_FREE(plni, sizeof(*plni));
773 ptllnd_history_fini();
775 CDEBUG(D_NET, "<<< rc=%d\n",rc);
779 const char *ptllnd_evtype2str(int type)
781 #define DO_TYPE(x) case x: return #x;
784 DO_TYPE(PTL_EVENT_GET_START);
785 DO_TYPE(PTL_EVENT_GET_END);
786 DO_TYPE(PTL_EVENT_PUT_START);
787 DO_TYPE(PTL_EVENT_PUT_END);
788 DO_TYPE(PTL_EVENT_REPLY_START);
789 DO_TYPE(PTL_EVENT_REPLY_END);
790 DO_TYPE(PTL_EVENT_ACK);
791 DO_TYPE(PTL_EVENT_SEND_START);
792 DO_TYPE(PTL_EVENT_SEND_END);
793 DO_TYPE(PTL_EVENT_UNLINK);
795 return "<unknown event type>";
800 const char *ptllnd_msgtype2str(int type)
802 #define DO_TYPE(x) case x: return #x;
805 DO_TYPE(PTLLND_MSG_TYPE_INVALID);
806 DO_TYPE(PTLLND_MSG_TYPE_PUT);
807 DO_TYPE(PTLLND_MSG_TYPE_GET);
808 DO_TYPE(PTLLND_MSG_TYPE_IMMEDIATE);
809 DO_TYPE(PTLLND_MSG_TYPE_HELLO);
810 DO_TYPE(PTLLND_MSG_TYPE_NOOP);
811 DO_TYPE(PTLLND_MSG_TYPE_NAK);
813 return "<unknown msg type>";
818 const char *ptllnd_errtype2str(int type)
820 #define DO_TYPE(x) case x: return #x;
825 DO_TYPE(PTL_NO_SPACE);
826 DO_TYPE(PTL_ME_IN_USE);
827 DO_TYPE(PTL_NAL_FAILED);
828 DO_TYPE(PTL_NO_INIT);
829 DO_TYPE(PTL_IFACE_DUP);
830 DO_TYPE(PTL_IFACE_INVALID);
831 DO_TYPE(PTL_HANDLE_INVALID);
832 DO_TYPE(PTL_MD_INVALID);
833 DO_TYPE(PTL_ME_INVALID);
834 DO_TYPE(PTL_PROCESS_INVALID);
835 DO_TYPE(PTL_PT_INDEX_INVALID);
836 DO_TYPE(PTL_SR_INDEX_INVALID);
837 DO_TYPE(PTL_EQ_INVALID);
838 DO_TYPE(PTL_EQ_DROPPED);
839 DO_TYPE(PTL_EQ_EMPTY);
840 DO_TYPE(PTL_MD_NO_UPDATE);
842 DO_TYPE(PTL_AC_INDEX_INVALID);
843 DO_TYPE(PTL_MD_ILLEGAL);
844 DO_TYPE(PTL_ME_LIST_TOO_LONG);
845 DO_TYPE(PTL_MD_IN_USE);
846 DO_TYPE(PTL_NI_INVALID);
847 DO_TYPE(PTL_PID_INVALID);
848 DO_TYPE(PTL_PT_FULL);
849 DO_TYPE(PTL_VAL_FAILED);
850 DO_TYPE(PTL_NOT_IMPLEMENTED);
852 DO_TYPE(PTL_EQ_IN_USE);
853 DO_TYPE(PTL_PID_IN_USE);
854 DO_TYPE(PTL_INV_EQ_SIZE);
857 return "<unknown error type>";