1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2004 Cluster File Systems, Inc.
5 * Author: Eric Barton <eric@bartonsoftware.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 # define EXPORT_SYMTAB
28 #include <linux/config.h>
29 #include <linux/module.h>
30 #include <linux/kernel.h>
32 #include <linux/string.h>
33 #include <linux/stat.h>
34 #include <linux/errno.h>
35 #include <linux/smp_lock.h>
36 #include <linux/unistd.h>
37 #include <linux/uio.h>
39 #include <asm/system.h>
40 #include <asm/uaccess.h>
43 #include <linux/init.h>
45 #include <linux/file.h>
46 #include <linux/stat.h>
47 #include <linux/list.h>
48 #include <linux/kmod.h>
49 #include <linux/sysctl.h>
54 #define DEBUG_SUBSYSTEM S_LND
56 #include <libcfs/kp30.h>
57 #include <lnet/lnet.h>
58 #include <lnet/lib-lnet.h>
60 #include <ts_ib_core.h>
62 #include <ts_ib_sa_client.h>
67 typedef struct ib_qp ib_qp_t;
68 typedef struct ib_mr ib_mr_t;
69 typedef struct ib_fmr ib_fmr_t;
70 typedef struct ib_pd ib_pd_t;
71 typedef struct ib_cq ib_cq_t;
72 typedef struct ib_fmr_pool ib_fmr_pool_t;
79 typedef void ib_fmr_t;
82 typedef void ib_fmr_pool_t;
84 #define IB_ACCESS_LOCAL_WRITE TS_IB_ACCESS_LOCAL_WRITE
85 #define IB_WQ_SIGNAL_SELECTABLE TS_IB_ACCESS_LOCAL_WRITE
86 #define IB_TRANSPORT_RC TS_IB_TRANSPORT_RC
87 #define IB_QP_STATE_INIT TS_IB_QP_STATE_INIT
88 #define IB_QP_ATTRIBUTE_STATE TS_IB_QP_ATTRIBUTE_STATE
89 #define IB_QP_ATTRIBUTE_PORT TS_IB_QP_ATTRIBUTE_PORT
90 #define IB_QP_ATTRIBUTE_PKEY_INDEX TS_IB_QP_ATTRIBUTE_PKEY_INDEX
91 #define IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE TS_IB_QP_ATTRIBUTE_RDMA_ATOMIC_ENABLE
92 #define IB_ACCESS_LOCAL_WRITE TS_IB_ACCESS_LOCAL_WRITE
93 #define IB_ACCESS_REMOTE_WRITE TS_IB_ACCESS_REMOTE_WRITE
94 #define IB_ACCESS_REMOTE_READ TS_IB_ACCESS_REMOTE_READ
95 #define IB_CQ_CALLBACK_INTERRU TS_IB_CQ_CALLBACK_INTERRUPTPT
96 #define IB_CQ_PROVIDER_REARM TS_IB_CQ_PROVIDER_REARM
97 #define IB_CQ_CALLBACK_INTERRUPT TS_IB_CQ_CALLBACK_INTERRUPT
98 #define IB_COMPLETION_STATUS_SUCCESS TS_IB_COMPLETION_STATUS_SUCCESS
99 #define IB_OP_SEND TS_IB_OP_SEND
100 #define IB_OP_RDMA_WRITE TS_IB_OP_RDMA_WRITE
101 #define IB_OP_RDMA_READ TS_IB_OP_RDMA_READ
106 # define IBNAL_N_SCHED num_online_cpus() /* # schedulers */
108 # define IBNAL_N_SCHED 1 /* # schedulers */
112 //#define IBNAL_CALLBACK_CTXT IB_CQ_CALLBACK_PROCESS
113 #define IBNAL_CALLBACK_CTXT IB_CQ_CALLBACK_INTERRUPT
116 /* tunables fixed at compile time */
117 #define IBNAL_PEER_HASH_SIZE 101 /* # peer lists */
118 #define IBNAL_RESCHED 100 /* # scheduler loops before reschedule */
119 #define IBNAL_MSG_QUEUE_SIZE 8 /* # messages/RDMAs in-flight */
120 #define IBNAL_CREDIT_HIGHWATER 6 /* when to eagerly return credits */
121 #define IBNAL_MSG_SIZE (4<<10) /* max size of queued messages (inc hdr) */
122 #define IBNAL_RDMA_BASE 0x0eeb0000
125 #define IBNAL_RETRY 7 /* # times to retry */
126 #define IBNAL_RNR_RETRY 7 /* */
127 #define IBNAL_CM_RETRY 7 /* # times to retry connection */
128 #define IBNAL_FLOW_CONTROL 1
129 #define IBNAL_RESPONDER_RESOURCES 8
131 /************************/
132 /* derived constants... */
134 /* TX messages (shared by all connections) */
135 #define IBNAL_TX_MSGS() (*kibnal_tunables.kib_ntx)
136 #define IBNAL_TX_MSG_BYTES() (IBNAL_TX_MSGS() * IBNAL_MSG_SIZE)
137 #define IBNAL_TX_MSG_PAGES() ((IBNAL_TX_MSG_BYTES() + PAGE_SIZE - 1)/PAGE_SIZE)
139 /* RX messages (per connection) */
140 #define IBNAL_RX_MSGS (IBNAL_MSG_QUEUE_SIZE * 2)
141 #define IBNAL_RX_MSG_BYTES (IBNAL_RX_MSGS * IBNAL_MSG_SIZE)
142 #define IBNAL_RX_MSG_PAGES ((IBNAL_RX_MSG_BYTES + PAGE_SIZE - 1)/PAGE_SIZE)
144 /* we may have up to 2 completions per transmit +
145 1 completion per receive, per connection */
146 #define IBNAL_CQ_ENTRIES() ((2*IBNAL_TX_MSGS()) + \
147 (IBNAL_RX_MSGS * *kibnal_tunables.kib_concurrent_peers))
151 char **kib_ipif_basename; /* IPoIB interface base name */
152 int *kib_n_connd; /* # connection daemons */
153 int *kib_min_reconnect_interval; /* min connect retry seconds... */
154 int *kib_max_reconnect_interval; /* max connect retry seconds */
155 int *kib_concurrent_peers; /* max # peers */
156 int *kib_cksum; /* checksum kib_msg_t? */
157 int *kib_timeout; /* comms timeout (seconds) */
158 int *kib_keepalive; /* keepalive (seconds) */
159 int *kib_ntx; /* # tx descs */
160 int *kib_credits; /* # concurrent sends */
161 int *kib_peercredits; /* # concurrent sends to 1 peer */
163 struct ctl_table_header *kib_sysctl; /* sysctl interface */
168 int ibp_npages; /* # pages */
169 int ibp_mapped; /* mapped? */
170 __u64 ibp_vaddr; /* mapped region vaddr */
171 __u32 ibp_lkey; /* mapped region lkey */
172 __u32 ibp_rkey; /* mapped region rkey */
173 ib_mr_t *ibp_handle; /* mapped region handle */
174 struct page *ibp_pages[0];
179 int kib_init; /* initialisation state */
180 __u64 kib_incarnation; /* which one am I */
181 int kib_shutdown; /* shut down? */
182 atomic_t kib_nthreads; /* # live threads */
183 lnet_ni_t *kib_ni; /* _the_ openib interface */
185 __u64 kib_svc_id; /* service number I listen on */
186 tTS_IB_GID kib_svc_gid; /* device/port GID */
187 __u16 kib_svc_pkey; /* device/port pkey */
189 void *kib_listen_handle; /* IB listen handle */
191 rwlock_t kib_global_lock; /* stabilize peer/conn ops */
193 struct list_head *kib_peers; /* hash table of all my known peers */
194 int kib_peer_hash_size; /* size of kib_peers */
195 int kib_nonewpeers; /* prevent new peers? */
196 atomic_t kib_npeers; /* # peers extant */
197 atomic_t kib_nconns; /* # connections extant */
199 struct list_head kib_reaper_conns; /* connections to reap */
200 wait_queue_head_t kib_reaper_waitq; /* reaper sleeps here */
201 unsigned long kib_reaper_waketime; /* when reaper will wake */
202 spinlock_t kib_reaper_lock; /* serialise */
204 struct list_head kib_connd_peers; /* peers waiting for a connection */
205 struct list_head kib_connd_acceptq; /* accepted sockets to handle */
206 wait_queue_head_t kib_connd_waitq; /* connection daemons sleep here */
207 int kib_connd_connecting; /* # connds connecting */
208 spinlock_t kib_connd_lock; /* serialise */
210 wait_queue_head_t kib_sched_waitq; /* schedulers sleep here */
211 struct list_head kib_sched_txq; /* tx requiring attention */
212 struct list_head kib_sched_rxq; /* rx requiring attention */
213 spinlock_t kib_sched_lock; /* serialise */
215 struct kib_tx *kib_tx_descs; /* all the tx descriptors */
216 kib_pages_t *kib_tx_pages; /* premapped tx msg pages */
218 struct list_head kib_idle_txs; /* idle tx descriptors */
219 __u64 kib_next_tx_cookie; /* RDMA completion cookie */
220 spinlock_t kib_tx_lock; /* serialise */
222 int kib_hca_idx; /* my HCA number */
223 struct ib_device *kib_device; /* "the" device */
224 struct ib_device_properties kib_device_props; /* its properties */
225 int kib_port; /* port on the device */
226 struct ib_port_properties kib_port_props; /* its properties */
227 ib_pd_t *kib_pd; /* protection domain */
229 ib_fmr_pool_t *kib_fmr_pool; /* fast memory region pool */
231 ib_cq_t *kib_cq; /* completion queue */
235 #define IBNAL_INIT_NOTHING 0
236 #define IBNAL_INIT_DATA 1
237 #define IBNAL_INIT_LIB 2
238 #define IBNAL_INIT_PD 3
239 #define IBNAL_INIT_FMR 4
240 #define IBNAL_INIT_TXD 5
241 #define IBNAL_INIT_CQ 6
242 #define IBNAL_INIT_ALL 7
244 typedef struct kib_acceptsock /* accepted socket queued for connd */
246 struct list_head ibas_list; /* queue for attention */
247 struct socket *ibas_sock; /* the accepted socket */
250 /************************************************************************
251 * IB Wire message format.
252 * These are sent in sender's byte order (i.e. receiver flips).
253 * They may be sent via TCP/IP (service ID,GID,PKEY query/response),
254 * as private data in the connection request/response, or "normally".
257 typedef struct kib_svcrsp /* service response */
259 __u64 ibsr_svc_id; /* service's id */
260 __u8 ibsr_svc_gid[16]; /* service's gid */
261 __u16 ibsr_svc_pkey; /* service's pkey */
262 } WIRE_ATTR kib_svcrsp_t;
264 typedef struct kib_connparams
266 __u32 ibcp_queue_depth;
267 } WIRE_ATTR kib_connparams_t;
282 __u32 rd_key; /* remote key */
283 __u32 rd_nob; /* # of bytes */
284 __u64 rd_addr; /* remote io vaddr */
285 } WIRE_ATTR kib_rdma_desc_t;
289 lnet_hdr_t ibim_hdr; /* portals header */
290 char ibim_payload[0]; /* piggy-backed payload */
291 } WIRE_ATTR kib_immediate_msg_t;
295 lnet_hdr_t ibrm_hdr; /* portals header */
296 __u64 ibrm_cookie; /* opaque completion cookie */
297 kib_rdma_desc_t ibrm_desc; /* where to suck/blow */
298 } WIRE_ATTR kib_rdma_msg_t;
302 __u64 ibcm_cookie; /* opaque completion cookie */
303 __u32 ibcm_status; /* completion status */
304 } WIRE_ATTR kib_completion_msg_t;
308 /* First 2 fields fixed FOR ALL TIME */
309 __u32 ibm_magic; /* I'm an openibnal message */
310 __u16 ibm_version; /* this is my version number */
312 __u8 ibm_type; /* msg type */
313 __u8 ibm_credits; /* returned credits */
314 __u32 ibm_nob; /* # bytes in whole message */
315 __u32 ibm_cksum; /* checksum (0 == no checksum) */
316 __u64 ibm_srcnid; /* sender's NID */
317 __u64 ibm_srcstamp; /* sender's incarnation */
318 __u64 ibm_dstnid; /* destination's NID */
319 __u64 ibm_dststamp; /* destination's incarnation */
322 kib_connparams_t connparams;
323 kib_immediate_msg_t immediate;
325 kib_completion_msg_t completion;
327 } WIRE_ATTR kib_msg_t;
329 #define IBNAL_MSG_MAGIC LNET_PROTO_OPENIB_MAGIC /* unique magic */
330 #define IBNAL_MSG_VERSION_RDMAREPLYNOTRSRVD 2 /* previous protocol version */
331 #define IBNAL_MSG_VERSION 3 /* current protocol version */
333 #define IBNAL_MSG_SVCQRY 0xb0 /* service query */
334 #define IBNAL_MSG_SVCRSP 0xb1 /* service response */
335 #define IBNAL_MSG_CONNREQ 0xc0 /* connection request */
336 #define IBNAL_MSG_CONNACK 0xc1 /* connection acknowledge */
337 #define IBNAL_MSG_NOOP 0xd0 /* nothing (just credits) */
338 #define IBNAL_MSG_IMMEDIATE 0xd1 /* portals hdr + payload */
339 #define IBNAL_MSG_PUT_RDMA 0xd2 /* portals PUT hdr + source rdma desc */
340 #define IBNAL_MSG_PUT_DONE 0xd3 /* signal PUT rdma completion */
341 #define IBNAL_MSG_GET_RDMA 0xd4 /* portals GET hdr + sink rdma desc */
342 #define IBNAL_MSG_GET_DONE 0xd5 /* signal GET rdma completion */
344 /***********************************************************************/
346 typedef struct kib_rx /* receive message */
348 struct list_head rx_list; /* queue for attention */
349 struct kib_conn *rx_conn; /* owning conn */
350 int rx_nob; /* # bytes received (-1 while posted) */
351 __u64 rx_vaddr; /* pre-mapped buffer (hca vaddr) */
352 kib_msg_t *rx_msg; /* pre-mapped buffer (host vaddr) */
353 struct ib_receive_param rx_sp; /* receive work item */
354 struct ib_gather_scatter rx_gl; /* and it's memory */
357 typedef struct kib_tx /* transmit message */
359 struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */
360 struct kib_conn *tx_conn; /* owning conn */
361 int tx_mapped; /* mapped for RDMA? */
362 int tx_sending; /* # tx callbacks outstanding */
363 int tx_status; /* completion status */
364 unsigned long tx_deadline; /* completion deadline */
365 int tx_passive_rdma; /* peer sucks/blows */
366 int tx_passive_rdma_wait; /* waiting for peer to complete */
367 __u64 tx_passive_rdma_cookie; /* completion cookie */
368 lnet_msg_t *tx_lntmsg[2]; /* ptl msgs to finalize on completion */
369 kib_md_t tx_md; /* RDMA mapping (active/passive) */
370 __u64 tx_vaddr; /* pre-mapped buffer (hca vaddr) */
371 kib_msg_t *tx_msg; /* pre-mapped buffer (host vaddr) */
372 int tx_nsp; /* # send work items */
373 struct ib_send_param tx_sp[2]; /* send work items... */
374 struct ib_gather_scatter tx_gl[2]; /* ...and their memory */
377 #define KIB_TX_UNMAPPED 0
378 #define KIB_TX_MAPPED 1
379 #define KIB_TX_MAPPED_FMR 2
381 typedef struct kib_connreq
383 /* active connection-in-progress state */
384 struct kib_conn *cr_conn;
388 kib_svcrsp_t cr_svcrsp;
389 struct ib_path_record cr_path;
390 struct ib_cm_active_param cr_connparam;
393 typedef struct kib_conn
395 struct kib_peer *ibc_peer; /* owning peer */
396 struct list_head ibc_list; /* stash on peer's conn list */
397 __u64 ibc_incarnation; /* which instance of the peer */
398 int ibc_version; /* peer protocol version */
399 atomic_t ibc_refcount; /* # users */
400 int ibc_state; /* what's happening */
401 int ibc_nsends_posted; /* # uncompleted sends */
402 int ibc_credits; /* # credits I have */
403 int ibc_outstanding_credits; /* # credits to return */
404 int ibc_reserved_credits; /* # credits for ACK/DONE msgs */
405 unsigned long ibc_last_send; /* time of last send */
406 struct list_head ibc_tx_queue_nocred; /* sends that don't need a credit */
407 struct list_head ibc_tx_queue_rsrvd; /* sends that need a reserved cred */
408 struct list_head ibc_tx_queue; /* send queue */
409 struct list_head ibc_active_txs; /* active tx awaiting completion */
410 spinlock_t ibc_lock; /* serialise */
411 kib_rx_t *ibc_rxs; /* the rx descs */
412 kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */
413 ib_qp_t *ibc_qp; /* queue pair */
414 __u32 ibc_qpn; /* queue pair number */
415 tTS_IB_CM_COMM_ID ibc_comm_id; /* connection ID? */
416 kib_connreq_t *ibc_connreq; /* connection request state */
419 #define IBNAL_CONN_INIT_NOTHING 0 /* initial state */
420 #define IBNAL_CONN_INIT_QP 1 /* ibc_qp set up */
421 #define IBNAL_CONN_CONNECTING 2 /* started to connect */
422 #define IBNAL_CONN_ESTABLISHED 3 /* connection established */
423 #define IBNAL_CONN_DEATHROW 4 /* waiting to be closed */
424 #define IBNAL_CONN_ZOMBIE 5 /* waiting to be freed */
426 typedef struct kib_peer
428 struct list_head ibp_list; /* stash on global peer list */
429 struct list_head ibp_connd_list; /* schedule on kib_connd_peers */
430 lnet_nid_t ibp_nid; /* who's on the other end(s) */
431 __u32 ibp_ip; /* IP to query for peer conn params */
432 int ibp_port; /* port to qery for peer conn params */
433 __u64 ibp_incarnation; /* peer's incarnation */
434 atomic_t ibp_refcount; /* # users */
435 int ibp_persistence; /* "known" peer refs */
436 struct list_head ibp_conns; /* all active connections */
437 struct list_head ibp_tx_queue; /* msgs waiting for a conn */
438 int ibp_connecting; /* current active connection attempts */
439 int ibp_accepting; /* current passive connection attempts */
440 unsigned long ibp_reconnect_time; /* when reconnect may be attempted */
441 unsigned long ibp_reconnect_interval; /* exponential backoff */
442 int ibp_error; /* errno on closing this peer */
443 cfs_time_t ibp_last_alive; /* when (in jiffies) I was last alive */
446 extern kib_data_t kibnal_data;
447 extern kib_tunables_t kibnal_tunables;
449 /******************************************************************************/
451 /* these are purposely avoiding using local vars so they don't increase
452 * stack consumption. */
454 #define kibnal_conn_addref(conn) \
456 CDEBUG(D_NET, "conn[%p] (%d)++\n", \
457 (conn), atomic_read(&(conn)->ibc_refcount)); \
458 LASSERT(atomic_read(&(conn)->ibc_refcount) > 0); \
459 atomic_inc(&(conn)->ibc_refcount); \
462 #define kibnal_conn_decref(conn) \
464 unsigned long flags; \
466 CDEBUG(D_NET, "conn[%p] (%d)--\n", \
467 (conn), atomic_read(&(conn)->ibc_refcount)); \
468 LASSERT(atomic_read(&(conn)->ibc_refcount) > 0); \
469 if (atomic_dec_and_test(&(conn)->ibc_refcount)) { \
470 spin_lock_irqsave(&kibnal_data.kib_reaper_lock, flags); \
471 list_add_tail(&(conn)->ibc_list, \
472 &kibnal_data.kib_reaper_conns); \
473 wake_up(&kibnal_data.kib_reaper_waitq); \
474 spin_unlock_irqrestore(&kibnal_data.kib_reaper_lock, flags); \
478 #define kibnal_peer_addref(peer) \
480 CDEBUG(D_NET, "peer[%p] -> %s (%d)++\n", \
481 (peer), libcfs_nid2str((peer)->ibp_nid), \
482 atomic_read (&(peer)->ibp_refcount)); \
483 LASSERT(atomic_read(&(peer)->ibp_refcount) > 0); \
484 atomic_inc(&(peer)->ibp_refcount); \
487 #define kibnal_peer_decref(peer) \
489 CDEBUG(D_NET, "peer[%p] -> %s (%d)--\n", \
490 (peer), libcfs_nid2str((peer)->ibp_nid), \
491 atomic_read (&(peer)->ibp_refcount)); \
492 LASSERT(atomic_read(&(peer)->ibp_refcount) > 0); \
493 if (atomic_dec_and_test(&(peer)->ibp_refcount)) \
494 kibnal_destroy_peer(peer); \
497 /******************************************************************************/
499 static inline struct list_head *
500 kibnal_nid2peerlist (lnet_nid_t nid)
502 unsigned int hash = ((unsigned int)nid) % kibnal_data.kib_peer_hash_size;
504 return (&kibnal_data.kib_peers [hash]);
508 kibnal_peer_active(kib_peer_t *peer)
510 /* Am I in the peer hash table? */
511 return (!list_empty(&peer->ibp_list));
515 kibnal_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
519 LASSERT (tx->tx_nsp > 0); /* work items set up */
520 LASSERT (tx->tx_conn == NULL); /* only set here */
522 kibnal_conn_addref(conn);
524 tx->tx_deadline = jiffies + *kibnal_tunables.kib_timeout * HZ;
526 if (conn->ibc_version == IBNAL_MSG_VERSION_RDMAREPLYNOTRSRVD) {
527 /* All messages have simple credit control */
528 q = &conn->ibc_tx_queue;
530 LASSERT (conn->ibc_version == IBNAL_MSG_VERSION);
532 switch (tx->tx_msg->ibm_type) {
533 case IBNAL_MSG_PUT_RDMA:
534 case IBNAL_MSG_GET_RDMA:
535 /* RDMA request: reserve a buffer for the RDMA reply
537 q = &conn->ibc_tx_queue_rsrvd;
540 case IBNAL_MSG_PUT_DONE:
541 case IBNAL_MSG_GET_DONE:
542 /* RDMA completion: no credits; peer has reserved a
544 q = &conn->ibc_tx_queue_nocred;
548 case IBNAL_MSG_IMMEDIATE:
549 /* Otherwise: consume a credit before sending */
550 q = &conn->ibc_tx_queue;
559 list_add_tail(&tx->tx_list, q);
563 kibnal_send_keepalive(kib_conn_t *conn)
565 return (*kibnal_tunables.kib_keepalive > 0) &&
566 time_after(jiffies, conn->ibc_last_send +
567 *kibnal_tunables.kib_keepalive*HZ);
571 * We rely on tx/rx descriptor alignment to allow us to use the lowest bit
572 * of the work request id as a flag to determine if the completion is for a
573 * transmit or a receive. It seems that that the CQ entry's 'op' field
574 * isn't always set correctly on completions that occur after QP teardown. */
577 kibnal_ptr2wreqid (void *ptr, int isrx)
579 unsigned long lptr = (unsigned long)ptr;
581 LASSERT ((lptr & 1) == 0);
582 return (__u64)(lptr | (isrx ? 1 : 0));
586 kibnal_wreqid2ptr (__u64 wreqid)
588 return (void *)(((unsigned long)wreqid) & ~1UL);
592 kibnal_wreqid_is_rx (__u64 wreqid)
594 return (wreqid & 1) != 0;
597 #if (IB_NTXRXPARAMS == 3)
599 kibnal_ib_send(ib_qp_t *qp, struct ib_send_param *p)
601 return ib_send(qp, p, 1);
605 kibnal_ib_receive(ib_qp_t *qp, struct ib_receive_param *p)
607 return ib_receive(qp, p, 1);
609 #elif (IB_NTXRXPARAMS == 4)
611 kibnal_ib_send(ib_qp_t *qp, struct ib_send_param *p)
613 return ib_send(qp, p, 1, NULL);
617 kibnal_ib_receive(ib_qp_t *qp, struct ib_receive_param *p)
619 return ib_receive(qp, p, 1, NULL);
622 #error "IB_NTXRXPARAMS not set correctly"
625 int kibnal_startup (lnet_ni_t *ni);
626 void kibnal_shutdown (lnet_ni_t *ni);
627 int kibnal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
628 int kibnal_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
629 int kibnal_eager_recv (lnet_ni_t *ni, void *private,
630 lnet_msg_t *lntmsg, void **new_private);
631 int kibnal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
632 int delayed, unsigned int niov,
633 struct iovec *iov, lnet_kiov_t *kiov,
634 unsigned int offset, unsigned int mlen, unsigned int rlen);
635 int kibnal_accept(lnet_ni_t *ni, struct socket *sock);
637 extern void kibnal_init_msg(kib_msg_t *msg, int type, int body_nob);
638 extern void kibnal_pack_msg(kib_msg_t *msg, int version, int credits,
639 lnet_nid_t dstnid, __u64 dststamp);
640 extern int kibnal_unpack_msg(kib_msg_t *msg, int expected_version, int nob);
641 extern void kibnal_handle_svcqry (struct socket *sock);
642 extern int kibnal_make_svcqry (kib_conn_t *conn);
643 extern void kibnal_free_acceptsock (kib_acceptsock_t *as);
644 extern int kibnal_create_peer (kib_peer_t **peerp, lnet_nid_t nid);
645 extern void kibnal_destroy_peer (kib_peer_t *peer);
646 extern int kibnal_add_persistent_peer(lnet_nid_t nid, __u32 ip, int port);
647 extern int kibnal_del_peer (lnet_nid_t nid);
648 extern kib_peer_t *kibnal_find_peer_locked (lnet_nid_t nid);
649 extern void kibnal_unlink_peer_locked (kib_peer_t *peer);
650 extern void kibnal_peer_alive(kib_peer_t *peer);
651 extern int kibnal_close_stale_conns_locked (kib_peer_t *peer,
653 extern kib_conn_t *kibnal_create_conn (void);
654 extern void kibnal_destroy_conn (kib_conn_t *conn);
655 extern int kibnal_alloc_pages (kib_pages_t **pp, int npages, int access);
656 extern void kibnal_free_pages (kib_pages_t *p);
658 extern void kibnal_check_sends (kib_conn_t *conn);
660 extern tTS_IB_CM_CALLBACK_RETURN
661 kibnal_bad_conn_callback (tTS_IB_CM_EVENT event, tTS_IB_CM_COMM_ID cid,
662 void *param, void *arg);
663 extern tTS_IB_CM_CALLBACK_RETURN
664 kibnal_conn_callback (tTS_IB_CM_EVENT event, tTS_IB_CM_COMM_ID cid,
665 void *param, void *arg);
666 extern tTS_IB_CM_CALLBACK_RETURN
667 kibnal_passive_conn_callback (tTS_IB_CM_EVENT event, tTS_IB_CM_COMM_ID cid,
668 void *param, void *arg);
670 extern void kibnal_close_conn_locked (kib_conn_t *conn, int error);
671 extern void kibnal_destroy_conn (kib_conn_t *conn);
672 extern int kibnal_thread_start (int (*fn)(void *arg), void *arg);
673 extern int kibnal_scheduler(void *arg);
674 extern int kibnal_connd (void *arg);
675 extern int kibnal_reaper (void *arg);
676 extern void kibnal_callback (ib_cq_t *cq, struct ib_cq_entry *e, void *arg);
677 extern void kibnal_txlist_done (struct list_head *txlist, int status);
678 extern void kibnal_init_tx_msg (kib_tx_t *tx, int type, int body_nob);
679 extern int kibnal_close_conn (kib_conn_t *conn, int why);
680 extern void kibnal_start_active_rdma (int type, int status,
681 kib_rx_t *rx, lnet_msg_t *lntmsg,
683 struct iovec *iov, lnet_kiov_t *kiov,
684 int offset, int nob);
686 extern int kibnal_tunables_init(void);
687 extern void kibnal_tunables_fini(void);