1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2005 Cluster File Systems, Inc. All rights reserved.
5 * Author: Eric Barton <eeb@bartonsoftware.com>
7 * This file is part of the Lustre file system, http://www.lustre.org
8 * Lustre is a trademark of Cluster File Systems, Inc.
10 * This file is confidential source code owned by Cluster File Systems.
11 * No viewing, modification, compilation, redistribution, or any other
12 * form of use is permitted except through a signed license agreement.
14 * If you have not signed such an agreement, then you have no rights to
15 * this file. Please destroy it immediately and contact CFS.
20 #define DEBUG_SUBSYSTEM S_LND
22 #include <lnet/lib-lnet.h>
23 #include <lnet/ptllnd_wire.h>
25 #include <portals/p30.h>
26 #include <lnet/ptllnd.h> /* Depends on portals/p30.h */
29 /* Hack to record history
30 * This should really be done by CDEBUG(D_NETTRACE... */
33 struct list_head he_list;
34 struct timeval he_time;
42 void ptllnd_dump_history();
43 void ptllnd_history(const char *fn, const char *file, const int line,
44 const char *fmt, ...);
45 #define PTLLND_HISTORY(fmt, a...) \
46 ptllnd_history(__FUNCTION__, __FILE__, __LINE__, fmt, ## a)
49 #define PTLLND_MD_OPTIONS (PTL_MD_LUSTRE_COMPLETION_SEMANTICS |\
50 PTL_MD_EVENT_START_DISABLE)
54 ptl_pid_t plni_ptllnd_pid; /* Portals PID of peers I may connect to */
55 int plni_peer_credits;
56 int plni_max_msg_size;
59 int plni_peer_hash_size;
62 int plni_max_tx_history;
63 int plni_abort_on_protocol_mismatch;
64 int plni_abort_on_nak;
68 int plni_watchdog_interval;
72 struct list_head plni_active_txs;
73 struct list_head plni_zombie_txs;
77 ptl_handle_ni_t plni_nih;
78 ptl_handle_eq_t plni_eqh;
79 ptl_process_id_t plni_portals_id; /* Portals ID of interface */
81 struct list_head *plni_peer_hash;
84 int plni_watchdog_nextt;
85 int plni_watchdog_peeridx;
87 struct list_head plni_tx_history;
90 struct list_head plni_buffers;
92 int plni_nposted_buffers;
96 #define PTLLND_CREDIT_HIGHWATER(plni) ((plni)->plni_peer_credits - 1)
100 struct list_head plp_list;
102 lnet_process_id_t plp_id;
103 ptl_process_id_t plp_ptlid;
104 int plp_credits; /* # msg buffers reserved for me at peer */
106 /* credits for msg buffers I've posted for this peer...
107 * outstanding - free buffers I've still to inform my peer about
108 * sent - free buffers I've told my peer about
109 * lazy - additional buffers (over and above plni_peer_credits)
110 * posted to prevent peer blocking on sending a non-RDMA
111 * messages to me when LNET isn't eagerly responsive to
112 * the network (i.e. liblustre doesn't have control).
113 * extra_lazy - lazy credits not required any more. */
114 int plp_outstanding_credits;
115 int plp_sent_credits;
116 int plp_lazy_credits;
117 int plp_extra_lazy_credits;
119 int plp_max_msg_size;
121 int plp_recvd_hello:1;
125 struct list_head plp_txq;
126 struct list_head plp_activeq;
131 struct list_head plb_list;
134 ptl_handle_md_t plb_md;
140 ptllnd_peer_t *rx_peer;
147 struct list_head tx_list;
150 ptllnd_peer_t *tx_peer;
151 lnet_msg_t *tx_lnetmsg;
152 lnet_msg_t *tx_lnetreplymsg;
153 unsigned int tx_niov;
154 ptl_md_iovec_t *tx_iov;
155 ptl_handle_md_t tx_bulkmdh;
156 ptl_handle_md_t tx_reqmdh;
157 struct timeval tx_bulk_posted;
158 struct timeval tx_bulk_done;
159 struct timeval tx_req_posted;
160 struct timeval tx_req_done;
161 int tx_completing; /* someone already completing */
162 int tx_msgsize; /* # bytes in tx_msg */
163 time_t tx_deadline; /* time to complete by */
164 kptl_msg_t tx_msg; /* message to send */
167 #define PTLLND_RDMA_WRITE 0x100 /* pseudo message type */
168 #define PTLLND_RDMA_READ 0x101 /* (no msg actually sent) */
170 /* Hack to extract object type from event's user_ptr relies on (and checks)
171 * that structs are somewhat aligned. */
172 #define PTLLND_EVENTARG_TYPE_TX 0x1
173 #define PTLLND_EVENTARG_TYPE_BUF 0x2
174 #define PTLLND_EVENTARG_TYPE_MASK 0x3
177 ptllnd_obj2eventarg (void *obj, int type)
179 unsigned long ptr = (unsigned long)obj;
181 LASSERT ((ptr & PTLLND_EVENTARG_TYPE_MASK) == 0);
182 LASSERT ((type & ~PTLLND_EVENTARG_TYPE_MASK) == 0);
184 return (void *)(ptr | type);
188 ptllnd_eventarg2type (void *arg)
190 unsigned long ptr = (unsigned long)arg;
192 return (ptr & PTLLND_EVENTARG_TYPE_MASK);
196 ptllnd_eventarg2obj (void *arg)
198 unsigned long ptr = (unsigned long)arg;
200 return (void *)(ptr & ~PTLLND_EVENTARG_TYPE_MASK);
203 int ptllnd_parse_int_tunable(int *value, char *name, int dflt);
204 void ptllnd_cull_tx_history(ptllnd_ni_t *plni);
205 int ptllnd_startup(lnet_ni_t *ni);
206 void ptllnd_shutdown(lnet_ni_t *ni);
207 int ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
208 int ptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *msg);
209 int ptllnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
210 int delayed, unsigned int niov,
211 struct iovec *iov, lnet_kiov_t *kiov,
212 unsigned int offset, unsigned int mlen, unsigned int rlen);
213 int ptllnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
214 void **new_privatep);
216 ptllnd_tx_t *ptllnd_new_tx(ptllnd_peer_t *peer, int type, int payload_nob);
217 void ptllnd_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive);
218 int ptllnd_setasync(lnet_ni_t *ni, lnet_process_id_t id, int n);
219 void ptllnd_wait(lnet_ni_t *ni, int milliseconds);
220 void ptllnd_check_sends(ptllnd_peer_t *peer);
221 void ptllnd_debug_peer(lnet_ni_t *ni, lnet_process_id_t id);
222 void ptllnd_destroy_peer(ptllnd_peer_t *peer);
223 void ptllnd_close_peer(ptllnd_peer_t *peer, int error);
224 int ptllnd_post_buffer(ptllnd_buffer_t *buf);
225 int ptllnd_size_buffers (lnet_ni_t *ni, int delta);
226 const char *ptllnd_evtype2str(int type);
227 const char *ptllnd_msgtype2str(int type);
228 const char *ptllnd_errtype2str(int type);
229 char *ptllnd_ptlid2str(ptl_process_id_t id);
230 void ptllnd_dump_debug(lnet_ni_t *ni, lnet_process_id_t id);
234 ptllnd_peer_addref (ptllnd_peer_t *peer)
236 LASSERT (peer->plp_refcount > 0);
237 peer->plp_refcount++;
241 ptllnd_peer_decref (ptllnd_peer_t *peer)
243 LASSERT (peer->plp_refcount > 0);
244 peer->plp_refcount--;
245 if (peer->plp_refcount == 0)
246 ptllnd_destroy_peer(peer);
249 static inline lnet_nid_t
250 ptllnd_ptl2lnetnid(lnet_ni_t *ni, ptl_nid_t portals_nid)
252 return LNET_MKNID(LNET_NIDNET(ni->ni_nid), portals_nid);
255 static inline ptl_nid_t
256 ptllnd_lnet2ptlnid(lnet_nid_t lnet_nid)
258 return LNET_NIDADDR(lnet_nid);
262 * A note about lprintf():
263 * Normally printf() is redirected to stdout of the console
264 * from which yod launched the catamount application. However
265 * there is a lot of initilziation code that runs before this
266 * redirection is hooked up, and printf() seems to go to the bit bucket
268 * To get any kind of debug output and init time lprintf() can
269 * be used to output to the console from which bookqk was used to
270 * boot the catamount node. This works for debugging some simple