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 [sun.com URL with a
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>
46 .lnd_startup = ptllnd_startup,
47 .lnd_shutdown = ptllnd_shutdown,
48 .lnd_ctl = ptllnd_ctl,
49 .lnd_send = ptllnd_send,
50 .lnd_recv = ptllnd_recv,
51 .lnd_eager_recv = ptllnd_eager_recv,
52 .lnd_notify = ptllnd_notify,
53 .lnd_wait = ptllnd_wait,
54 .lnd_setasync = ptllnd_setasync,
57 static int ptllnd_ni_count = 0;
59 static struct list_head ptllnd_idle_history;
60 static struct list_head ptllnd_history_list;
63 ptllnd_history_fini(void)
67 while (!list_empty(&ptllnd_idle_history)) {
68 he = list_entry(ptllnd_idle_history.next,
69 ptllnd_he_t, he_list);
71 list_del(&he->he_list);
72 LIBCFS_FREE(he, sizeof(*he));
75 while (!list_empty(&ptllnd_history_list)) {
76 he = list_entry(ptllnd_history_list.next,
77 ptllnd_he_t, he_list);
79 list_del(&he->he_list);
80 LIBCFS_FREE(he, sizeof(*he));
85 ptllnd_history_init(void)
92 CFS_INIT_LIST_HEAD(&ptllnd_idle_history);
93 CFS_INIT_LIST_HEAD(&ptllnd_history_list);
95 rc = ptllnd_parse_int_tunable(&n, "PTLLND_HISTORY", 0);
99 for (i = 0; i < n; i++) {
100 LIBCFS_ALLOC(he, sizeof(*he));
102 ptllnd_history_fini();
106 list_add(&he->he_list, &ptllnd_idle_history);
109 PTLLND_HISTORY("Init");
115 ptllnd_history(const char *fn, const char *file, const int line,
116 const char *fmt, ...)
123 if (!list_empty(&ptllnd_idle_history)) {
124 he = list_entry(ptllnd_idle_history.next,
125 ptllnd_he_t, he_list);
126 } else if (!list_empty(&ptllnd_history_list)) {
127 he = list_entry(ptllnd_history_list.next,
128 ptllnd_he_t, he_list);
133 list_del(&he->he_list);
134 list_add_tail(&he->he_list, &ptllnd_history_list);
140 gettimeofday(&he->he_time, NULL);
143 vsnprintf(he->he_msg, sizeof(he->he_msg), fmt, ap);
148 ptllnd_dump_history(void)
152 PTLLND_HISTORY("dumping...");
154 while (!list_empty(&ptllnd_history_list)) {
155 he = list_entry(ptllnd_history_list.next,
156 ptllnd_he_t, he_list);
158 list_del(&he->he_list);
160 CDEBUG(D_WARNING, "%d %d.%06d (%s:%d:%s()) %s\n", he->he_seq,
161 (int)he->he_time.tv_sec, (int)he->he_time.tv_usec,
162 he->he_file, he->he_line, he->he_fn, he->he_msg);
164 list_add_tail(&he->he_list, &ptllnd_idle_history);
167 PTLLND_HISTORY("complete");
171 ptllnd_assert_wire_constants (void)
173 /* Wire protocol assertions generated by 'wirecheck'
174 * running on Linux fedora 2.6.11-co-0.6.4 #1 Mon Jun 19 05:36:13 UTC 2006 i686 i686 i386 GNU
175 * with gcc version 4.1.1 20060525 (Red Hat 4.1.1-1) */
179 CLASSERT (PTL_RESERVED_MATCHBITS == 0x100);
180 CLASSERT (LNET_MSG_MATCHBITS == 0);
181 CLASSERT (PTLLND_MSG_MAGIC == 0x50746C4E);
182 CLASSERT (PTLLND_MSG_VERSION == 0x04);
183 CLASSERT (PTLLND_RDMA_OK == 0x00);
184 CLASSERT (PTLLND_RDMA_FAIL == 0x01);
185 CLASSERT (PTLLND_MSG_TYPE_INVALID == 0x00);
186 CLASSERT (PTLLND_MSG_TYPE_PUT == 0x01);
187 CLASSERT (PTLLND_MSG_TYPE_GET == 0x02);
188 CLASSERT (PTLLND_MSG_TYPE_IMMEDIATE == 0x03);
189 CLASSERT (PTLLND_MSG_TYPE_NOOP == 0x04);
190 CLASSERT (PTLLND_MSG_TYPE_HELLO == 0x05);
191 CLASSERT (PTLLND_MSG_TYPE_NAK == 0x06);
193 /* Checks for struct kptl_msg_t */
194 CLASSERT ((int)sizeof(kptl_msg_t) == 136);
195 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_magic) == 0);
196 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_magic) == 4);
197 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_version) == 4);
198 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_version) == 2);
199 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_type) == 6);
200 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_type) == 1);
201 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_credits) == 7);
202 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_credits) == 1);
203 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_nob) == 8);
204 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_nob) == 4);
205 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_cksum) == 12);
206 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_cksum) == 4);
207 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcnid) == 16);
208 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcnid) == 8);
209 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcstamp) == 24);
210 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcstamp) == 8);
211 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstnid) == 32);
212 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstnid) == 8);
213 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dststamp) == 40);
214 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dststamp) == 8);
215 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_srcpid) == 48);
216 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_srcpid) == 4);
217 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_dstpid) == 52);
218 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_dstpid) == 4);
219 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.immediate) == 56);
220 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.immediate) == 72);
221 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.rdma) == 56);
222 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.rdma) == 80);
223 CLASSERT ((int)offsetof(kptl_msg_t, ptlm_u.hello) == 56);
224 CLASSERT ((int)sizeof(((kptl_msg_t *)0)->ptlm_u.hello) == 12);
226 /* Checks for struct kptl_immediate_msg_t */
227 CLASSERT ((int)sizeof(kptl_immediate_msg_t) == 72);
228 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_hdr) == 0);
229 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_hdr) == 72);
230 CLASSERT ((int)offsetof(kptl_immediate_msg_t, kptlim_payload[13]) == 85);
231 CLASSERT ((int)sizeof(((kptl_immediate_msg_t *)0)->kptlim_payload[13]) == 1);
233 /* Checks for struct kptl_rdma_msg_t */
234 CLASSERT ((int)sizeof(kptl_rdma_msg_t) == 80);
235 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_hdr) == 0);
236 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_hdr) == 72);
237 CLASSERT ((int)offsetof(kptl_rdma_msg_t, kptlrm_matchbits) == 72);
238 CLASSERT ((int)sizeof(((kptl_rdma_msg_t *)0)->kptlrm_matchbits) == 8);
240 /* Checks for struct kptl_hello_msg_t */
241 CLASSERT ((int)sizeof(kptl_hello_msg_t) == 12);
242 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_matchbits) == 0);
243 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_matchbits) == 8);
244 CLASSERT ((int)offsetof(kptl_hello_msg_t, kptlhm_max_msg_size) == 8);
245 CLASSERT ((int)sizeof(((kptl_hello_msg_t *)0)->kptlhm_max_msg_size) == 4);
249 ptllnd_parse_int_tunable(int *value, char *name, int dflt)
251 char *env = getenv(name);
259 *value = strtoull(env, &end, 0);
263 CERROR("Can't parse tunable %s=%s\n", name, env);
268 ptllnd_get_tunables(lnet_ni_t *ni)
270 ptllnd_ni_t *plni = ni->ni_data;
276 /* Other tunable defaults depend on this */
277 rc = ptllnd_parse_int_tunable(&plni->plni_debug, "PTLLND_DEBUG", 0);
281 rc = ptllnd_parse_int_tunable(&plni->plni_portal,
282 "PTLLND_PORTAL", PTLLND_PORTAL);
286 rc = ptllnd_parse_int_tunable(&temp,
287 "PTLLND_PID", PTLLND_PID);
290 plni->plni_ptllnd_pid = (ptl_pid_t)temp;
292 rc = ptllnd_parse_int_tunable(&plni->plni_peer_credits,
293 "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
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 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 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;
481 struct list_head *tmp;
482 struct list_head *nxt;
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 list_for_each_safe(tmp, nxt, &plni->plni_buffers) {
488 buf = 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 (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 (!list_empty(&plni->plni_peer_hash[i])) {
584 plp = 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>";