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 rc = ptllnd_parse_int_tunable(&plni->plni_portal,
255 "PTLLND_PORTAL", PTLLND_PORTAL);
259 rc = ptllnd_parse_int_tunable(&temp,
260 "PTLLND_PID", PTLLND_PID);
263 plni->plni_ptllnd_pid = (ptl_pid_t)temp;
265 rc = ptllnd_parse_int_tunable(&plni->plni_peer_credits,
266 "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
270 rc = ptllnd_parse_int_tunable(&max_msg_size,
271 "PTLLND_MAX_MSG_SIZE",
272 PTLLND_MAX_ULND_MSG_SIZE);
276 rc = ptllnd_parse_int_tunable(&msgs_per_buffer,
277 "PTLLND_MSGS_PER_BUFFER",
278 PTLLND_MSGS_PER_BUFFER);
282 rc = ptllnd_parse_int_tunable(&plni->plni_msgs_spare,
288 rc = ptllnd_parse_int_tunable(&plni->plni_peer_hash_size,
289 "PTLLND_PEER_HASH_SIZE",
290 PTLLND_PEER_HASH_SIZE);
295 rc = ptllnd_parse_int_tunable(&plni->plni_eq_size,
296 "PTLLND_EQ_SIZE", PTLLND_EQ_SIZE);
300 rc = ptllnd_parse_int_tunable(&plni->plni_checksum,
301 "PTLLND_CHECKSUM", 0);
305 rc = ptllnd_parse_int_tunable(&plni->plni_max_tx_history,
306 "PTLLND_TX_HISTORY", PTLLND_TX_HISTORY);
310 rc = ptllnd_parse_int_tunable(&plni->plni_abort_on_nak,
311 "PTLLND_ABORT_ON_NAK",
312 PTLLND_ABORT_ON_NAK);
316 rc = ptllnd_parse_int_tunable(&plni->plni_dump_on_nak,
317 "PTLLND_DUMP_ON_NAK",
322 plni->plni_max_msg_size = max_msg_size & ~7;
323 if (plni->plni_max_msg_size < PTLLND_MIN_BUFFER_SIZE)
324 plni->plni_max_msg_size = PTLLND_MIN_BUFFER_SIZE;
325 CLASSERT ((PTLLND_MIN_BUFFER_SIZE & 7) == 0);
326 CLASSERT (sizeof(kptl_msg_t) <= PTLLND_MIN_BUFFER_SIZE);
328 plni->plni_buffer_size = plni->plni_max_msg_size * msgs_per_buffer;
330 CDEBUG(D_NET, "portal = %d\n",plni->plni_portal);
331 CDEBUG(D_NET, "ptllnd_pid = %d\n",plni->plni_ptllnd_pid);
332 CDEBUG(D_NET, "max_msg_size = %d\n",max_msg_size);
333 CDEBUG(D_NET, "msgs_per_buffer = %d\n",msgs_per_buffer);
334 CDEBUG(D_NET, "msgs_spare = %d\n",plni->plni_msgs_spare);
335 CDEBUG(D_NET, "peer_hash_size = %d\n",plni->plni_peer_hash_size);
336 CDEBUG(D_NET, "eq_size = %d\n",plni->plni_eq_size);
337 CDEBUG(D_NET, "max_msg_size = %d\n",plni->plni_max_msg_size);
338 CDEBUG(D_NET, "buffer_size = %d\n",plni->plni_buffer_size);
344 ptllnd_create_buffer (lnet_ni_t *ni)
346 ptllnd_ni_t *plni = ni->ni_data;
347 ptllnd_buffer_t *buf;
349 LIBCFS_ALLOC(buf, sizeof(*buf));
351 CERROR("Can't allocate buffer descriptor\n");
357 CFS_INIT_LIST_HEAD(&buf->plb_list);
359 LIBCFS_ALLOC(buf->plb_buffer, plni->plni_buffer_size);
360 if (buf->plb_buffer == NULL) {
361 CERROR("Can't allocate buffer size %d\n",
362 plni->plni_buffer_size);
363 LIBCFS_FREE(buf, sizeof(*buf));
367 list_add(&buf->plb_list, &plni->plni_buffers);
368 plni->plni_nbuffers++;
374 ptllnd_destroy_buffer (ptllnd_buffer_t *buf)
376 ptllnd_ni_t *plni = buf->plb_ni->ni_data;
378 LASSERT (!buf->plb_posted);
380 plni->plni_nbuffers--;
381 list_del(&buf->plb_list);
382 LIBCFS_FREE(buf->plb_buffer, plni->plni_buffer_size);
383 LIBCFS_FREE(buf, sizeof(*buf));
387 ptllnd_size_buffers (lnet_ni_t *ni, int delta)
389 ptllnd_ni_t *plni = ni->ni_data;
390 ptllnd_buffer_t *buf;
395 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
396 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
398 plni->plni_nmsgs += delta;
399 LASSERT(plni->plni_nmsgs >= 0);
401 nmsgs = plni->plni_nmsgs + plni->plni_msgs_spare;
403 nbufs = (nmsgs * plni->plni_max_msg_size + plni->plni_buffer_size - 1) /
404 plni->plni_buffer_size;
406 while (nbufs > plni->plni_nbuffers) {
407 buf = ptllnd_create_buffer(ni);
412 rc = ptllnd_post_buffer(buf);
414 /* TODO - this path seems to orpahn the buffer
415 * in a state where its not posted and will never be
416 * However it does not leak the buffer as it's
417 * already been put onto the global buffer list
418 * and will be cleaned up
424 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
425 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
430 ptllnd_destroy_buffers (lnet_ni_t *ni)
432 ptllnd_ni_t *plni = ni->ni_data;
433 ptllnd_buffer_t *buf;
434 struct list_head *tmp;
435 struct list_head *nxt;
437 CDEBUG(D_NET, "nposted_buffers = %d (before)\n",plni->plni_nposted_buffers);
438 CDEBUG(D_NET, "nbuffers = %d (before)\n",plni->plni_nbuffers);
440 list_for_each_safe(tmp, nxt, &plni->plni_buffers) {
441 buf = list_entry(tmp, ptllnd_buffer_t, plb_list);
443 //CDEBUG(D_NET, "buf=%p posted=%d\n",buf,buf->plb_posted);
445 LASSERT (plni->plni_nbuffers > 0);
446 if (buf->plb_posted) {
447 time_t start = cfs_time_current_sec();
448 int w = PTLLND_WARN_LONG_WAIT;
450 LASSERT (plni->plni_nposted_buffers > 0);
452 #ifdef LUSTRE_PORTALS_UNLINK_SEMANTICS
453 (void) PtlMDUnlink(buf->plb_md);
455 while (buf->plb_posted) {
456 if (cfs_time_current_sec() > start + w) {
457 CWARN("Waited %ds to unlink buffer\n", w);
460 ptllnd_wait(ni, w*1000);
463 while (buf->plb_posted) {
464 rc = PtlMDUnlink(buf->plb_md);
467 plni->plni_nposted_buffers--;
470 LASSERT (rc == PTL_MD_IN_USE);
471 if (cfs_time_current_sec() > start + w) {
472 CWARN("Waited %ds to unlink buffer\n", w);
475 ptllnd_wait(ni, w*1000);
479 ptllnd_destroy_buffer(buf);
482 CDEBUG(D_NET, "nposted_buffers = %d (after)\n",plni->plni_nposted_buffers);
483 CDEBUG(D_NET, "nbuffers = %d (after)\n",plni->plni_nbuffers);
485 LASSERT (plni->plni_nposted_buffers == 0);
486 LASSERT (plni->plni_nbuffers == 0);
490 ptllnd_create_peer_hash (lnet_ni_t *ni)
492 ptllnd_ni_t *plni = ni->ni_data;
495 plni->plni_npeers = 0;
497 LIBCFS_ALLOC(plni->plni_peer_hash,
498 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
499 if (plni->plni_peer_hash == NULL) {
500 CERROR("Can't allocate ptllnd peer hash (size %d)\n",
501 plni->plni_peer_hash_size);
505 for (i = 0; i < plni->plni_peer_hash_size; i++)
506 CFS_INIT_LIST_HEAD(&plni->plni_peer_hash[i]);
512 ptllnd_destroy_peer_hash (lnet_ni_t *ni)
514 ptllnd_ni_t *plni = ni->ni_data;
517 LASSERT( plni->plni_npeers == 0);
519 for (i = 0; i < plni->plni_peer_hash_size; i++)
520 LASSERT (list_empty(&plni->plni_peer_hash[i]));
522 LIBCFS_FREE(plni->plni_peer_hash,
523 plni->plni_peer_hash_size * sizeof(*plni->plni_peer_hash));
527 ptllnd_close_peers (lnet_ni_t *ni)
529 ptllnd_ni_t *plni = ni->ni_data;
533 for (i = 0; i < plni->plni_peer_hash_size; i++)
534 while (!list_empty(&plni->plni_peer_hash[i])) {
535 plp = list_entry(plni->plni_peer_hash[i].next,
536 ptllnd_peer_t, plp_list);
538 ptllnd_close_peer(plp, 0);
543 ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
546 case IOC_LIBCFS_DEBUG_PEER:
547 ptllnd_debug_peer(ni, *((lnet_process_id_t *)arg));
556 ptllnd_get_timestamp(void)
559 int rc = gettimeofday(&tv, NULL);
562 return ((__u64)tv.tv_sec) * 1000000 + tv.tv_usec;
566 ptllnd_shutdown (lnet_ni_t *ni)
568 ptllnd_ni_t *plni = ni->ni_data;
570 time_t start = cfs_time_current_sec();
571 int w = PTLLND_WARN_LONG_WAIT;
573 LASSERT (ptllnd_ni_count == 1);
574 plni->plni_max_tx_history = 0;
576 ptllnd_cull_tx_history(plni);
578 ptllnd_close_peers(ni);
579 ptllnd_destroy_buffers(ni);
581 while (plni->plni_npeers > 0) {
582 if (cfs_time_current_sec() > start + w) {
583 CWARN("Waited %ds for peers to shutdown\n", w);
586 ptllnd_wait(ni, w*1000);
589 LASSERT (plni->plni_ntxs == 0);
590 LASSERT (plni->plni_nrxs == 0);
592 rc = PtlEQFree(plni->plni_eqh);
593 LASSERT (rc == PTL_OK);
595 rc = PtlNIFini(plni->plni_nih);
596 LASSERT (rc == PTL_OK);
598 ptllnd_destroy_peer_hash(ni);
599 LIBCFS_FREE(plni, sizeof(*plni));
604 ptllnd_startup (lnet_ni_t *ni)
609 /* could get limits from portals I guess... */
610 ni->ni_maxtxcredits =
611 ni->ni_peertxcredits = 1000;
613 if (ptllnd_ni_count != 0) {
614 CERROR("Can't have > 1 instance of ptllnd\n");
620 rc = ptllnd_history_init();
622 CERROR("Can't init history\n");
626 LIBCFS_ALLOC(plni, sizeof(*plni));
628 CERROR("Can't allocate ptllnd state\n");
635 plni->plni_stamp = ptllnd_get_timestamp();
638 plni->plni_ntx_history = 0;
639 CFS_INIT_LIST_HEAD(&plni->plni_zombie_txs);
640 CFS_INIT_LIST_HEAD(&plni->plni_tx_history);
643 * Initilize buffer related data structures
645 CFS_INIT_LIST_HEAD(&plni->plni_buffers);
646 plni->plni_nbuffers = 0;
647 plni->plni_nposted_buffers = 0;
649 rc = ptllnd_get_tunables(ni);
653 rc = ptllnd_create_peer_hash(ni);
657 /* NB I most probably won't get the PID I requested here. It doesn't
658 * matter because I don't need a fixed PID (only connection acceptors
659 * need a "well known" PID). */
661 rc = PtlNIInit(PTL_IFACE_DEFAULT, plni->plni_ptllnd_pid,
662 NULL, NULL, &plni->plni_nih);
663 if (rc != PTL_OK && rc != PTL_IFACE_DUP) {
664 CERROR("PtlNIInit failed: %d\n", rc);
669 rc = PtlEQAlloc(plni->plni_nih, plni->plni_eq_size,
670 PTL_EQ_HANDLER_NONE, &plni->plni_eqh);
672 CERROR("PtlEQAlloc failed: %d\n", rc);
678 * Fetch the Portals NID
680 if(rc != PtlGetId(plni->plni_nih,&plni->plni_portals_id)){
681 CERROR ("PtlGetID failed : %d\n", rc);
686 CDEBUG(D_NET, "lnet nid=" LPX64 " (passed in)\n",ni->ni_nid);
689 * Create the new NID. Based on the LND network type
690 * and the lower ni's address data.
692 ni->ni_nid = ptllnd_ptl2lnetnid(ni, plni->plni_portals_id.nid);
694 CDEBUG(D_NET, "ptl id =%s\n", ptllnd_ptlid2str(plni->plni_portals_id));
695 CDEBUG(D_NET, "lnet id =%s (passed back)\n",
696 libcfs_id2str((lnet_process_id_t) {
697 .nid = ni->ni_nid, .pid = the_lnet.ln_pid}));
699 rc = ptllnd_size_buffers(ni, 0);
706 ptllnd_destroy_buffers(ni);
707 PtlEQFree(plni->plni_eqh);
709 PtlNIFini(plni->plni_nih);
711 ptllnd_destroy_peer_hash(ni);
713 LIBCFS_FREE(plni, sizeof(*plni));
715 ptllnd_history_fini();
717 CDEBUG(D_NET, "<<< rc=%d\n",rc);
721 const char *ptllnd_evtype2str(int type)
723 #define DO_TYPE(x) case x: return #x;
726 DO_TYPE(PTL_EVENT_GET_START);
727 DO_TYPE(PTL_EVENT_GET_END);
728 DO_TYPE(PTL_EVENT_PUT_START);
729 DO_TYPE(PTL_EVENT_PUT_END);
730 DO_TYPE(PTL_EVENT_REPLY_START);
731 DO_TYPE(PTL_EVENT_REPLY_END);
732 DO_TYPE(PTL_EVENT_ACK);
733 DO_TYPE(PTL_EVENT_SEND_START);
734 DO_TYPE(PTL_EVENT_SEND_END);
735 DO_TYPE(PTL_EVENT_UNLINK);
737 return "<unknown event type>";
742 const char *ptllnd_msgtype2str(int type)
744 #define DO_TYPE(x) case x: return #x;
747 DO_TYPE(PTLLND_MSG_TYPE_INVALID);
748 DO_TYPE(PTLLND_MSG_TYPE_PUT);
749 DO_TYPE(PTLLND_MSG_TYPE_GET);
750 DO_TYPE(PTLLND_MSG_TYPE_IMMEDIATE);
751 DO_TYPE(PTLLND_MSG_TYPE_HELLO);
752 DO_TYPE(PTLLND_MSG_TYPE_NOOP);
753 DO_TYPE(PTLLND_MSG_TYPE_NAK);
755 return "<unknown msg type>";
760 const char *ptllnd_errtype2str(int type)
762 #define DO_TYPE(x) case x: return #x;
767 DO_TYPE(PTL_NO_SPACE);
768 DO_TYPE(PTL_ME_IN_USE);
769 DO_TYPE(PTL_NAL_FAILED);
770 DO_TYPE(PTL_NO_INIT);
771 DO_TYPE(PTL_IFACE_DUP);
772 DO_TYPE(PTL_IFACE_INVALID);
773 DO_TYPE(PTL_HANDLE_INVALID);
774 DO_TYPE(PTL_MD_INVALID);
775 DO_TYPE(PTL_ME_INVALID);
776 DO_TYPE(PTL_PROCESS_INVALID);
777 DO_TYPE(PTL_PT_INDEX_INVALID);
778 DO_TYPE(PTL_SR_INDEX_INVALID);
779 DO_TYPE(PTL_EQ_INVALID);
780 DO_TYPE(PTL_EQ_DROPPED);
781 DO_TYPE(PTL_EQ_EMPTY);
782 DO_TYPE(PTL_MD_NO_UPDATE);
784 DO_TYPE(PTL_AC_INDEX_INVALID);
785 DO_TYPE(PTL_MD_ILLEGAL);
786 DO_TYPE(PTL_ME_LIST_TOO_LONG);
787 DO_TYPE(PTL_MD_IN_USE);
788 DO_TYPE(PTL_NI_INVALID);
789 DO_TYPE(PTL_PID_INVALID);
790 DO_TYPE(PTL_PT_FULL);
791 DO_TYPE(PTL_VAL_FAILED);
792 DO_TYPE(PTL_NOT_IMPLEMENTED);
794 DO_TYPE(PTL_EQ_IN_USE);
795 DO_TYPE(PTL_PID_IN_USE);
796 DO_TYPE(PTL_INV_EQ_SIZE);
799 return "<unknown error type>";