Whamcloud - gitweb
18e5b2a264819ff41af3c6bc293e36377ed84cc7
[fs/lustre-release.git] / lnet / klnds / ptllnd / ptllnd.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
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.
11  *
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).
17  *
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
21  *
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
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lnet/klnds/ptllnd/ptllnd.h
37  *
38  * Author: PJ Kirner <pjkirner@clusterfs.com>
39  */
40
41 #ifndef EXPORT_SYMTAB
42 # define EXPORT_SYMTAB
43 #endif
44 #ifndef AUTOCONF_INCLUDED
45 #include <linux/config.h>
46 #endif
47 #include <linux/module.h>
48 #include <linux/kernel.h>
49 #include <linux/mm.h>
50 #include <linux/string.h>
51 #include <linux/stat.h>
52 #include <linux/errno.h>
53 #include <linux/smp_lock.h>
54 #include <linux/unistd.h>
55 #include <linux/uio.h>
56
57 #include <asm/system.h>
58 #include <asm/uaccess.h>
59 #include <asm/io.h>
60
61 #include <linux/init.h>
62 #include <linux/fs.h>
63 #include <linux/file.h>
64 #include <linux/stat.h>
65 #include <linux/list.h>
66 #include <linux/kmod.h>
67 #include <linux/sysctl.h>
68 #include <linux/random.h>
69
70 #include <net/sock.h>
71 #include <linux/in.h>
72
73
74 #define DEBUG_SUBSYSTEM S_LND
75
76 #include <libcfs/libcfs.h>
77 #include <lnet/lnet.h>
78 #include <lnet/lib-lnet.h>
79 #include <lnet/lnet-sysctl.h>
80 #include <portals/p30.h>
81 #ifdef CRAY_XT3
82 #include <portals/ptltrace.h>
83 #endif
84 #include <lnet/ptllnd.h>        /* Depends on portals/p30.h */
85
86 /*
87  * Define this to enable console debug logging
88  * and simulation
89  */
90 //#define PJK_DEBUGGING
91
92 #ifdef CONFIG_SMP
93 # define PTLLND_N_SCHED         num_online_cpus()   /* # schedulers */
94 #else
95 # define PTLLND_N_SCHED         1                   /* # schedulers */
96 #endif
97
98 #define PTLLND_CREDIT_HIGHWATER ((*kptllnd_tunables.kptl_peercredits)-1)
99   /* when eagerly to return credits */
100
101 typedef struct
102 {
103         int             *kptl_ntx;              /* # tx descs to pre-allocate */
104         int             *kptl_max_nodes;        /* max # nodes all talking to me */
105         int             *kptl_max_procs_per_node; /* max # processes per node */
106         int             *kptl_checksum;         /* checksum kptl_msg_t? */
107         int             *kptl_timeout;          /* comms timeout (seconds) */
108         int             *kptl_portal;           /* portal number */
109         int             *kptl_pid;              /* portals PID (self + kernel peers) */
110         int             *kptl_rxb_npages;       /* number of pages for rx buffer */
111         int             *kptl_rxb_nspare;       /* number of spare rx buffers */
112         int             *kptl_credits;          /* number of credits */
113         int             *kptl_peercredits;      /* number of credits */
114         int             *kptl_max_msg_size;     /* max immd message size*/
115         int             *kptl_peer_hash_table_size; /* # slots in peer hash table */
116         int             *kptl_reschedule_loops; /* scheduler yield loops */
117         int             *kptl_ack_puts;         /* make portals ack PUTs */
118 #ifdef CRAY_XT3
119         int             *kptl_ptltrace_on_timeout; /* dump pltrace on timeout? */
120         char           **kptl_ptltrace_basename;  /* ptltrace dump file basename */
121 #endif
122 #ifdef PJK_DEBUGGING
123         int             *kptl_simulation_bitmap;/* simulation bitmap */
124 #endif
125
126 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
127         cfs_sysctl_table_header_t *kptl_sysctl; /* sysctl interface */
128 #endif
129 } kptl_tunables_t;
130
131 #include "lnet/ptllnd_wire.h"
132
133 /***********************************************************************/
134
135 typedef struct kptl_data kptl_data_t;
136 typedef struct kptl_rx_buffer kptl_rx_buffer_t;
137 typedef struct kptl_peer kptl_peer_t;
138
139 typedef struct {
140         char      eva_type;
141 } kptl_eventarg_t;
142
143 #define PTLLND_EVENTARG_TYPE_MSG    0x1
144 #define PTLLND_EVENTARG_TYPE_RDMA   0x2
145 #define PTLLND_EVENTARG_TYPE_BUF    0x3
146
147 typedef struct kptl_rx                          /* receive message */
148 {
149         struct list_head        rx_list;        /* queue for attention */
150         kptl_rx_buffer_t       *rx_rxb;         /* the rx buffer pointer */
151         kptl_msg_t             *rx_msg;         /* received message */
152         int                     rx_nob;         /* received message size */
153         unsigned long           rx_treceived;   /* time received */
154         ptl_process_id_t        rx_initiator;   /* sender's address */
155 #ifdef CRAY_XT3
156         ptl_uid_t               rx_uid;         /* sender's uid */
157 #endif
158         kptl_peer_t            *rx_peer;        /* pointer to peer */
159         char                    rx_space[0];    /* copy of incoming request */
160 } kptl_rx_t;
161
162 #define PTLLND_POSTRX_DONT_POST    0            /* don't post */
163 #define PTLLND_POSTRX_NO_CREDIT    1            /* post: no credits */
164 #define PTLLND_POSTRX_PEER_CREDIT  2            /* post: give peer back 1 credit */
165
166 typedef struct kptl_rx_buffer_pool
167 {
168         spinlock_t              rxbp_lock;
169         struct list_head        rxbp_list;      /* all allocated buffers */
170         int                     rxbp_count;     /* # allocated buffers */
171         int                     rxbp_reserved;  /* # requests to buffer */
172         int                     rxbp_shutdown;  /* shutdown flag */
173 } kptl_rx_buffer_pool_t;
174
175 struct kptl_rx_buffer
176 {
177         kptl_rx_buffer_pool_t  *rxb_pool;
178         struct list_head        rxb_list;       /* for the rxb_pool list */
179         struct list_head        rxb_repost_list;/* for the kptl_sched_rxbq list */
180         int                     rxb_posted:1;   /* on the net */
181         int                     rxb_idle:1;     /* all done */
182         kptl_eventarg_t         rxb_eventarg;   /* event->md.user_ptr */
183         int                     rxb_refcount;   /* reference count */
184         ptl_handle_md_t         rxb_mdh;        /* the portals memory descriptor (MD) handle */
185         char                   *rxb_buffer;     /* the buffer */
186
187 };
188
189 enum kptl_tx_type
190 {
191         TX_TYPE_RESERVED                = 0,
192         TX_TYPE_SMALL_MESSAGE           = 1,
193         TX_TYPE_PUT_REQUEST             = 2,
194         TX_TYPE_GET_REQUEST             = 3,
195         TX_TYPE_PUT_RESPONSE            = 4,
196         TX_TYPE_GET_RESPONSE            = 5,
197 };
198
199 typedef union {
200 #ifdef _USING_LUSTRE_PORTALS_
201         struct iovec iov[PTL_MD_MAX_IOV];
202         lnet_kiov_t kiov[PTL_MD_MAX_IOV];
203 #else
204         ptl_md_iovec_t iov[PTL_MD_MAX_IOV];
205 #endif
206 } kptl_fragvec_t;
207
208 typedef struct kptl_tx                           /* transmit message */
209 {
210         struct list_head        tx_list;      /* queue on idle_txs etc */
211         atomic_t                tx_refcount;  /* reference count*/
212         enum kptl_tx_type       tx_type;      /* small msg/{put,get}{req,resp} */
213         int                     tx_active:1;  /* queued on the peer */
214         int                     tx_idle:1;    /* on the free list */
215         int                     tx_acked:1;   /* portals ACK wanted (for debug only) */
216         kptl_eventarg_t         tx_msg_eventarg; /* event->md.user_ptr */
217         kptl_eventarg_t         tx_rdma_eventarg; /* event->md.user_ptr */
218         int                     tx_status;    /* the status of this tx descriptor */
219         ptl_handle_md_t         tx_rdma_mdh;  /* RDMA buffer */
220         ptl_handle_md_t         tx_msg_mdh;   /* the portals MD handle for the initial message */
221         lnet_msg_t             *tx_lnet_msg;  /* LNET message to finalize */
222         lnet_msg_t             *tx_lnet_replymsg; /* LNET reply message to finalize */
223         kptl_msg_t             *tx_msg;       /* the message data */
224         kptl_peer_t            *tx_peer;      /* the peer this is waiting on */
225         unsigned long           tx_deadline;  /* deadline */
226         unsigned long           tx_tposted;   /* time posted */
227         ptl_md_t                tx_rdma_md;   /* rdma descriptor */
228         kptl_fragvec_t         *tx_frags;     /* buffer fragments */
229 } kptl_tx_t;
230
231 enum kptllnd_peer_state
232 {
233         PEER_STATE_UNINITIALIZED        = 0,
234         PEER_STATE_ALLOCATED            = 1,
235         PEER_STATE_WAITING_HELLO        = 2,
236         PEER_STATE_ACTIVE               = 3,
237         PEER_STATE_CLOSING              = 4,
238         PEER_STATE_ZOMBIE               = 5,
239 };
240
241 struct kptl_peer
242 {
243         struct list_head        peer_list;
244         atomic_t                peer_refcount;          /* The current refrences */
245         enum kptllnd_peer_state peer_state;
246         spinlock_t              peer_lock;              /* serialize */
247         struct list_head        peer_noops;             /* PTLLND_MSG_TYPE_NOOP txs */
248         struct list_head        peer_sendq;             /* txs waiting for mh handles */
249         struct list_head        peer_activeq;           /* txs awaiting completion */
250         lnet_process_id_t       peer_id;                /* Peer's LNET id */
251         ptl_process_id_t        peer_ptlid;             /* Peer's portals id */
252         __u64                   peer_incarnation;       /* peer's incarnation */
253         __u64                   peer_myincarnation;     /* my incarnation at HELLO */
254         int                     peer_sent_hello;        /* have I sent HELLO? */
255         int                     peer_credits;           /* number of send credits */
256         int                     peer_outstanding_credits;/* number of peer credits to return */
257         int                     peer_sent_credits;      /* #msg buffers posted for peer */
258         int                     peer_max_msg_size;      /* peer's rx buffer size */
259         int                     peer_error;             /* errno on closing this peer */
260         int                     peer_retry_noop;        /* need to retry returning credits */
261         int                     peer_check_stamp;       /* watchdog check stamp */
262         cfs_time_t              peer_last_alive;        /* when (in jiffies) I was last alive */
263         __u64                   peer_next_matchbits;    /* Next value to register RDMA from peer */
264         __u64                   peer_last_matchbits_seen; /* last matchbits used to RDMA to peer */
265 };
266
267 struct kptl_data
268 {
269         int                     kptl_init;             /* initialisation state */
270         volatile int            kptl_shutdown;         /* shut down? */
271         atomic_t                kptl_nthreads;         /* # live threads */
272         lnet_ni_t              *kptl_ni;               /* _the_ LND instance */
273         ptl_handle_ni_t         kptl_nih;              /* network inteface handle */
274         ptl_process_id_t        kptl_portals_id;       /* Portals ID of interface */
275         __u64                   kptl_incarnation;      /* which one am I */
276         ptl_handle_eq_t         kptl_eqh;              /* Event Queue (EQ) */
277
278         spinlock_t              kptl_sched_lock;       /* serialise... */
279         wait_queue_head_t       kptl_sched_waitq;      /* schedulers sleep here */
280         struct list_head        kptl_sched_txq;        /* tx requiring attention */
281         struct list_head        kptl_sched_rxq;        /* rx requiring attention */
282         struct list_head        kptl_sched_rxbq;       /* rxb requiring reposting */
283
284         wait_queue_head_t       kptl_watchdog_waitq;   /* watchdog sleeps here */
285
286         kptl_rx_buffer_pool_t   kptl_rx_buffer_pool;   /* rx buffer pool */
287         cfs_mem_cache_t*        kptl_rx_cache;         /* rx descripter cache */
288
289         atomic_t                kptl_ntx;              /* # tx descs allocated */
290         spinlock_t              kptl_tx_lock;          /* serialise idle tx list*/
291         struct list_head        kptl_idle_txs;         /* idle tx descriptors */
292
293         rwlock_t                kptl_peer_rw_lock;     /* lock for peer table */
294         struct list_head       *kptl_peers;            /* hash table of all my known peers */
295         struct list_head        kptl_closing_peers;    /* peers being closed */
296         struct list_head        kptl_zombie_peers;     /* peers waiting for refs to drain */
297         int                     kptl_peer_hash_size;   /* size of kptl_peers */
298         int                     kptl_npeers;           /* # peers extant */
299         int                     kptl_n_active_peers;   /* # active peers */
300         int                     kptl_expected_peers;   /* # peers I can buffer HELLOs from */
301
302         kptl_msg_t             *kptl_nak_msg;          /* common NAK message */
303         spinlock_t              kptl_ptlid2str_lock;   /* serialise str ops */
304 };
305
306 enum 
307 {
308         PTLLND_INIT_NOTHING = 0,
309         PTLLND_INIT_DATA,
310         PTLLND_INIT_ALL,
311 };
312
313 extern kptl_tunables_t  kptllnd_tunables;
314 extern kptl_data_t      kptllnd_data;
315
316 static inline lnet_nid_t 
317 kptllnd_ptl2lnetnid(ptl_nid_t ptl_nid)
318 {
319 #ifdef _USING_LUSTRE_PORTALS_
320         return LNET_MKNID(LNET_NIDNET(kptllnd_data.kptl_ni->ni_nid), 
321                           LNET_NIDADDR(ptl_nid));
322 #else
323         return LNET_MKNID(LNET_NIDNET(kptllnd_data.kptl_ni->ni_nid), 
324                           ptl_nid);
325 #endif
326 }
327
328 static inline ptl_nid_t 
329 kptllnd_lnet2ptlnid(lnet_nid_t lnet_nid)
330 {
331 #ifdef _USING_LUSTRE_PORTALS_
332         return LNET_MKNID(LNET_NIDNET(kptllnd_data.kptl_portals_id.nid),
333                           LNET_NIDADDR(lnet_nid));
334 #else
335         return LNET_NIDADDR(lnet_nid);
336 #endif
337 }
338
339 int  kptllnd_startup(lnet_ni_t *ni);
340 void kptllnd_shutdown(lnet_ni_t *ni);
341 int  kptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
342 int  kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
343 int  kptllnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
344                   int delayed, unsigned int niov, 
345                   struct iovec *iov, lnet_kiov_t *kiov,
346                   unsigned int offset, unsigned int mlen, unsigned int rlen);
347 int  kptllnd_eager_recv(struct lnet_ni *ni, void *private, 
348                         lnet_msg_t *msg, void **new_privatep);
349 void kptllnd_eq_callback(ptl_event_t *evp);
350 int  kptllnd_scheduler(void *arg);
351 int  kptllnd_watchdog(void *arg);
352 int  kptllnd_thread_start(int (*fn)(void *arg), void *arg);
353 int  kptllnd_tunables_init(void);
354 void kptllnd_tunables_fini(void);
355
356 const char *kptllnd_evtype2str(int evtype);
357 const char *kptllnd_msgtype2str(int msgtype);
358 const char *kptllnd_errtype2str(int errtype);
359
360 static inline void *
361 kptllnd_eventarg2obj (kptl_eventarg_t *eva)
362 {
363         switch (eva->eva_type) {
364         default:
365                 LBUG();
366         case PTLLND_EVENTARG_TYPE_BUF:
367                 return list_entry(eva, kptl_rx_buffer_t, rxb_eventarg);
368         case PTLLND_EVENTARG_TYPE_RDMA:
369                 return list_entry(eva, kptl_tx_t, tx_rdma_eventarg);
370         case PTLLND_EVENTARG_TYPE_MSG:
371                 return list_entry(eva, kptl_tx_t, tx_msg_eventarg);
372         }
373 }
374
375 /*
376  * RX BUFFER SUPPORT FUNCTIONS
377  */
378 void kptllnd_rx_buffer_pool_init(kptl_rx_buffer_pool_t *rxbp);
379 void kptllnd_rx_buffer_pool_fini(kptl_rx_buffer_pool_t *rxbp);
380 int  kptllnd_rx_buffer_pool_reserve(kptl_rx_buffer_pool_t *rxbp, int count);
381 void kptllnd_rx_buffer_pool_unreserve(kptl_rx_buffer_pool_t *rxbp, int count);
382 void kptllnd_rx_buffer_callback(ptl_event_t *ev);
383 void kptllnd_rx_buffer_post(kptl_rx_buffer_t *rxb);
384
385 static inline int
386 kptllnd_rx_buffer_size(void)
387 {
388         return PAGE_SIZE * (*kptllnd_tunables.kptl_rxb_npages);
389 }
390
391 static inline void
392 kptllnd_rx_buffer_addref(kptl_rx_buffer_t *rxb)
393 {
394         unsigned long flags;
395         
396         spin_lock_irqsave(&rxb->rxb_pool->rxbp_lock, flags);
397         rxb->rxb_refcount++;
398         spin_unlock_irqrestore(&rxb->rxb_pool->rxbp_lock, flags);
399 }
400
401 static inline void
402 kptllnd_rx_buffer_decref_locked(kptl_rx_buffer_t *rxb)
403 {
404         if (--(rxb->rxb_refcount) == 0) {
405                 spin_lock(&kptllnd_data.kptl_sched_lock);
406         
407                 list_add_tail(&rxb->rxb_repost_list,
408                               &kptllnd_data.kptl_sched_rxbq);
409                 wake_up(&kptllnd_data.kptl_sched_waitq);
410
411                 spin_unlock(&kptllnd_data.kptl_sched_lock);
412         }
413 }
414
415 static inline void
416 kptllnd_rx_buffer_decref(kptl_rx_buffer_t *rxb)
417 {
418         unsigned long flags;
419         int           count;
420         
421         spin_lock_irqsave(&rxb->rxb_pool->rxbp_lock, flags);
422         count = --(rxb->rxb_refcount);
423         spin_unlock_irqrestore(&rxb->rxb_pool->rxbp_lock, flags);
424
425         if (count == 0)
426                 kptllnd_rx_buffer_post(rxb);
427 }
428
429 /*
430  * RX SUPPORT FUNCTIONS
431  */
432 void kptllnd_rx_parse(kptl_rx_t *rx);
433 void kptllnd_rx_done(kptl_rx_t *rx, int post_credit);
434
435 /*
436  * PEER SUPPORT FUNCTIONS
437  */
438 int kptllnd_get_peer_info(int index,
439                           lnet_process_id_t *id, 
440                           int *state, int *sent_hello,
441                           int *refcount, __u64 *incarnation,
442                           __u64 *next_matchbits, __u64 *last_matchbits_seen,
443                           int *nsendq, int *nactiveq,
444                           int *credits, int *outstanding_credits);
445 void kptllnd_peer_destroy(kptl_peer_t *peer);
446 int  kptllnd_peer_del(lnet_process_id_t id);
447 void kptllnd_peer_close_locked(kptl_peer_t *peer, int why);
448 void kptllnd_peer_close(kptl_peer_t *peer, int why);
449 void kptllnd_handle_closing_peers(void);
450 int  kptllnd_peer_connect(kptl_tx_t *tx, lnet_nid_t nid);
451 void kptllnd_peer_check_sends(kptl_peer_t *peer);
452 void kptllnd_peer_check_bucket(int idx, int stamp);
453 void kptllnd_tx_launch(kptl_peer_t *peer, kptl_tx_t *tx, int nfrag);
454 int  kptllnd_find_target(kptl_peer_t **peerp, lnet_process_id_t target);
455 kptl_peer_t *kptllnd_peer_handle_hello(ptl_process_id_t initiator,
456                                        kptl_msg_t *msg);
457 kptl_peer_t *kptllnd_id2peer_locked(lnet_process_id_t id);
458 void kptllnd_peer_alive(kptl_peer_t *peer);
459
460 static inline void
461 kptllnd_peer_addref (kptl_peer_t *peer)
462 {
463         atomic_inc(&peer->peer_refcount);
464 }
465
466 static inline void
467 kptllnd_peer_decref (kptl_peer_t *peer)
468 {
469         if (atomic_dec_and_test(&peer->peer_refcount))
470                 kptllnd_peer_destroy(peer);
471 }
472
473 static inline void
474 kptllnd_set_tx_peer(kptl_tx_t *tx, kptl_peer_t *peer) 
475 {
476         LASSERT (tx->tx_peer == NULL);
477         
478         kptllnd_peer_addref(peer);
479         tx->tx_peer = peer;
480 }
481
482 static inline struct list_head *
483 kptllnd_nid2peerlist(lnet_nid_t nid)
484 {
485         unsigned int hash = ((unsigned int)nid) %
486                             kptllnd_data.kptl_peer_hash_size;
487
488         return &kptllnd_data.kptl_peers[hash];
489 }
490
491 static inline kptl_peer_t *
492 kptllnd_id2peer(lnet_process_id_t id)
493 {
494         kptl_peer_t   *peer;
495         unsigned long  flags;
496
497         read_lock_irqsave(&kptllnd_data.kptl_peer_rw_lock, flags);
498         peer = kptllnd_id2peer_locked(id);
499         read_unlock_irqrestore(&kptllnd_data.kptl_peer_rw_lock, flags);
500
501         return peer;
502 }
503
504 static inline int
505 kptllnd_reserve_buffers(int n)
506 {
507         return kptllnd_rx_buffer_pool_reserve(&kptllnd_data.kptl_rx_buffer_pool,
508                                               n);
509 }
510
511 static inline int
512 kptllnd_peer_reserve_buffers(void)
513 {
514         return kptllnd_reserve_buffers(*kptllnd_tunables.kptl_peercredits);
515 }
516
517 static inline void
518 kptllnd_peer_unreserve_buffers(void)
519 {
520         kptllnd_rx_buffer_pool_unreserve(&kptllnd_data.kptl_rx_buffer_pool,
521                                          *kptllnd_tunables.kptl_peercredits);
522 }
523
524 /*
525  * TX SUPPORT FUNCTIONS
526  */
527 int  kptllnd_setup_tx_descs(void);
528 void kptllnd_cleanup_tx_descs(void);
529 void kptllnd_tx_fini(kptl_tx_t *tx);
530 kptl_tx_t *kptllnd_get_idle_tx(enum kptl_tx_type purpose);
531 void kptllnd_tx_callback(ptl_event_t *ev);
532 const char *kptllnd_tx_typestr(int type);
533
534 static inline void
535 kptllnd_tx_addref(kptl_tx_t *tx)
536 {
537         atomic_inc(&tx->tx_refcount);
538 }
539
540 static inline void 
541 kptllnd_tx_decref(kptl_tx_t *tx)
542 {
543         LASSERT (!in_interrupt());        /* Thread context only */
544
545         if (atomic_dec_and_test(&tx->tx_refcount))
546                 kptllnd_tx_fini(tx);
547 }
548
549 /*
550  * MESSAGE SUPPORT FUNCTIONS
551  */
552 void kptllnd_init_msg(kptl_msg_t *msg, int type, int body_nob);
553 void kptllnd_msg_pack(kptl_msg_t *msg, kptl_peer_t *peer);
554 int  kptllnd_msg_unpack(kptl_msg_t *msg, int nob);
555
556 /*
557  * MISC SUPPORT FUNCTIONS
558  */
559 void kptllnd_init_rdma_md(kptl_tx_t *tx, unsigned int niov,
560                           struct iovec *iov, lnet_kiov_t *kiov,
561                           unsigned int offset, unsigned int nob);
562 char *kptllnd_ptlid2str(ptl_process_id_t id);
563
564 void kptllnd_init_ptltrace(void);
565 void kptllnd_dump_ptltrace(void);
566
567 #ifdef PJK_DEBUGGING
568 #define SIMULATION_FAIL_TX_PUT_ALLOC   0       /* 0x00000001 */
569 #define SIMULATION_FAIL_TX_GET_ALLOC   1       /* 0x00000002 */
570 #define SIMULATION_FAIL_TX             2       /* 0x00000004 */
571 #define SIMULATION_FAIL_RX_ALLOC       3       /* 0x00000008 */
572
573 #define IS_SIMULATION_ENABLED(x) \
574         (((*kptllnd_tunables.kptl_simulation_bitmap) & 1<< SIMULATION_##x) != 0)
575 #else
576 #define IS_SIMULATION_ENABLED(x)       0
577 #endif