4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/ulnds/ptllnd/ptllnd.h
36 * Author: Eric Barton <eeb@bartonsoftware.com>
40 #define DEBUG_SUBSYSTEM S_LND
42 #include <lnet/lib-lnet.h>
43 #include <lnet/ptllnd_wire.h>
45 #include <portals/p30.h>
46 #include <lnet/ptllnd.h> /* Depends on portals/p30.h */
49 /* Hack to record history
50 * This should really be done by CDEBUG(D_NETTRACE... */
54 struct timeval he_time;
62 void ptllnd_dump_history();
63 void ptllnd_history(const char *fn, const char *file, const int line,
64 const char *fmt, ...);
65 #define PTLLND_HISTORY(fmt, a...) \
66 ptllnd_history(__FUNCTION__, __FILE__, __LINE__, fmt, ## a)
69 #define PTLLND_MD_OPTIONS (PTL_MD_LUSTRE_COMPLETION_SEMANTICS |\
70 PTL_MD_EVENT_START_DISABLE)
74 ptl_pid_t plni_ptllnd_pid; /* Portals PID of peers I may connect to */
75 int plni_peer_credits;
76 int plni_max_msg_size;
79 int plni_peer_hash_size;
82 int plni_max_tx_history;
83 int plni_abort_on_protocol_mismatch;
84 int plni_abort_on_nak;
88 int plni_watchdog_interval;
92 cfs_list_t plni_active_txs;
93 cfs_list_t plni_zombie_txs;
97 ptl_handle_ni_t plni_nih;
98 ptl_handle_eq_t plni_eqh;
99 ptl_process_id_t plni_portals_id; /* Portals ID of interface */
101 cfs_list_t *plni_peer_hash;
104 int plni_watchdog_nextt;
105 int plni_watchdog_peeridx;
107 cfs_list_t plni_tx_history;
108 int plni_ntx_history;
110 cfs_list_t plni_buffers;
112 int plni_nposted_buffers;
116 #define PTLLND_CREDIT_HIGHWATER(plni) ((plni)->plni_peer_credits - 1)
122 lnet_process_id_t plp_id;
123 ptl_process_id_t plp_ptlid;
124 int plp_credits; /* # msg buffers reserved for me at peer */
126 /* credits for msg buffers I've posted for this peer...
127 * outstanding - free buffers I've still to inform my peer about
128 * sent - free buffers I've told my peer about
129 * lazy - additional buffers (over and above plni_peer_credits)
130 * posted to prevent peer blocking on sending a non-RDMA
131 * messages to me when LNET isn't eagerly responsive to
132 * the network (i.e. liblustre doesn't have control).
133 * extra_lazy - lazy credits not required any more. */
134 int plp_outstanding_credits;
135 int plp_sent_credits;
136 int plp_lazy_credits;
137 int plp_extra_lazy_credits;
139 int plp_max_msg_size;
141 int plp_sent_hello:1;
142 int plp_recvd_hello:1;
147 cfs_list_t plp_noopq;
148 cfs_list_t plp_activeq;
156 ptl_handle_md_t plb_md;
162 ptllnd_peer_t *rx_peer;
172 ptllnd_peer_t *tx_peer;
173 lnet_msg_t *tx_lnetmsg;
174 lnet_msg_t *tx_lnetreplymsg;
175 unsigned int tx_niov;
176 ptl_md_iovec_t *tx_iov;
177 ptl_handle_md_t tx_bulkmdh;
178 ptl_handle_md_t tx_reqmdh;
179 struct timeval tx_bulk_posted;
180 struct timeval tx_bulk_done;
181 struct timeval tx_req_posted;
182 struct timeval tx_req_done;
183 int tx_completing; /* someone already completing */
184 int tx_msgsize; /* # bytes in tx_msg */
185 time_t tx_deadline; /* time to complete by */
186 kptl_msg_t tx_msg; /* message to send */
189 #define PTLLND_RDMA_WRITE 0x100 /* pseudo message type */
190 #define PTLLND_RDMA_READ 0x101 /* (no msg actually sent) */
192 /* Hack to extract object type from event's user_ptr relies on (and checks)
193 * that structs are somewhat aligned. */
194 #define PTLLND_EVENTARG_TYPE_TX 0x1
195 #define PTLLND_EVENTARG_TYPE_BUF 0x2
196 #define PTLLND_EVENTARG_TYPE_MASK 0x3
199 ptllnd_obj2eventarg (void *obj, int type)
201 unsigned long ptr = (unsigned long)obj;
203 LASSERT ((ptr & PTLLND_EVENTARG_TYPE_MASK) == 0);
204 LASSERT ((type & ~PTLLND_EVENTARG_TYPE_MASK) == 0);
206 return (void *)(ptr | type);
210 ptllnd_eventarg2type (void *arg)
212 unsigned long ptr = (unsigned long)arg;
214 return (ptr & PTLLND_EVENTARG_TYPE_MASK);
218 ptllnd_eventarg2obj (void *arg)
220 unsigned long ptr = (unsigned long)arg;
222 return (void *)(ptr & ~PTLLND_EVENTARG_TYPE_MASK);
225 int ptllnd_parse_int_tunable(int *value, char *name, int dflt);
226 void ptllnd_cull_tx_history(ptllnd_ni_t *plni);
227 int ptllnd_startup(lnet_ni_t *ni);
228 void ptllnd_shutdown(lnet_ni_t *ni);
229 int ptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
230 int ptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *msg);
231 int ptllnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
232 int delayed, unsigned int niov,
233 struct iovec *iov, lnet_kiov_t *kiov,
234 unsigned int offset, unsigned int mlen, unsigned int rlen);
235 int ptllnd_eager_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg,
236 void **new_privatep);
238 ptllnd_tx_t *ptllnd_new_tx(ptllnd_peer_t *peer, int type, int payload_nob);
239 int ptllnd_setasync(lnet_ni_t *ni, lnet_process_id_t id, int n);
240 void ptllnd_wait(lnet_ni_t *ni, int milliseconds);
241 void ptllnd_check_sends(ptllnd_peer_t *peer);
242 void ptllnd_debug_peer(lnet_ni_t *ni, lnet_process_id_t id);
243 void ptllnd_destroy_peer(ptllnd_peer_t *peer);
244 void ptllnd_close_peer(ptllnd_peer_t *peer, int error);
245 int ptllnd_post_buffer(ptllnd_buffer_t *buf);
246 int ptllnd_size_buffers (lnet_ni_t *ni, int delta);
247 const char *ptllnd_evtype2str(int type);
248 const char *ptllnd_msgtype2str(int type);
249 const char *ptllnd_errtype2str(int type);
250 char *ptllnd_ptlid2str(ptl_process_id_t id);
251 void ptllnd_dump_debug(lnet_ni_t *ni, lnet_process_id_t id);
255 ptllnd_peer_addref (ptllnd_peer_t *peer)
257 LASSERT (peer->plp_refcount > 0);
258 peer->plp_refcount++;
262 ptllnd_peer_decref (ptllnd_peer_t *peer)
264 LASSERT (peer->plp_refcount > 0);
265 peer->plp_refcount--;
266 if (peer->plp_refcount == 0)
267 ptllnd_destroy_peer(peer);
270 static inline lnet_nid_t
271 ptllnd_ptl2lnetnid(lnet_ni_t *ni, ptl_nid_t portals_nid)
273 return LNET_MKNID(LNET_NIDNET(ni->ni_nid), portals_nid);
276 static inline ptl_nid_t
277 ptllnd_lnet2ptlnid(lnet_nid_t lnet_nid)
279 return LNET_NIDADDR(lnet_nid);
283 * A note about lprintf():
284 * Normally printf() is redirected to stdout of the console
285 * from which yod launched the catamount application. However
286 * there is a lot of initilziation code that runs before this
287 * redirection is hooked up, and printf() seems to go to the bit bucket
289 * To get any kind of debug output and init time lprintf() can
290 * be used to output to the console from which bookqk was used to
291 * boot the catamount node. This works for debugging some simple