]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/staging/lustre/include/linux/lnet/lib-lnet.h
staging:lustre: merge socklnd_lib-linux.h into socklnd.h
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / lustre / include / linux / lnet / lib-lnet.h
CommitLineData
d7e09d03
PT
1/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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.
9 *
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).
15 *
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
19 *
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
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2012, Intel Corporation.
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/include/lnet/lib-lnet.h
37 *
38 * Top level include for library side routines
39 */
40
41#ifndef __LNET_LIB_LNET_H__
42#define __LNET_LIB_LNET_H__
43
9fdaf8c0
GKH
44#include "../libcfs/libcfs.h"
45#include "types.h"
46#include "lnet.h"
47#include "lib-types.h"
d7e09d03
PT
48
49extern lnet_t the_lnet; /* THE network */
50
d9c90615 51#if (BITS_PER_LONG == 32)
d7e09d03 52/* 2 CPTs, allowing more CPTs might make us under memory pressure */
d9c90615 53# define LNET_CPT_MAX_BITS 1
d7e09d03 54
d9c90615 55#else /* 64-bit system */
d7e09d03
PT
56/*
57 * 256 CPTs for thousands of CPUs, allowing more CPTs might make us
58 * under risk of consuming all lh_cookie.
59 */
d9c90615
JH
60# define LNET_CPT_MAX_BITS 8
61#endif /* BITS_PER_LONG == 32 */
d7e09d03
PT
62
63/* max allowed CPT number */
64#define LNET_CPT_MAX (1 << LNET_CPT_MAX_BITS)
65
66#define LNET_CPT_NUMBER (the_lnet.ln_cpt_number)
67#define LNET_CPT_BITS (the_lnet.ln_cpt_bits)
68#define LNET_CPT_MASK ((1ULL << LNET_CPT_BITS) - 1)
69
70/** exclusive lock */
71#define LNET_LOCK_EX CFS_PERCPT_LOCK_EX
72
62fbc9f7 73static inline int lnet_is_wire_handle_none(lnet_handle_wire_t *wh)
d7e09d03
PT
74{
75 return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE &&
76 wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE);
77}
78
62fbc9f7 79static inline int lnet_md_exhausted(lnet_libmd_t *md)
d7e09d03
PT
80{
81 return (md->md_threshold == 0 ||
82 ((md->md_options & LNET_MD_MAX_SIZE) != 0 &&
83 md->md_offset + md->md_max_size > md->md_length));
84}
85
62fbc9f7 86static inline int lnet_md_unlinkable(lnet_libmd_t *md)
d7e09d03
PT
87{
88 /* Should unlink md when its refcount is 0 and either:
2b06b70b
AO
89 * - md has been flagged for deletion (by auto unlink or
90 * LNetM[DE]Unlink, in the latter case md may not be exhausted).
d7e09d03
PT
91 * - auto unlink is on and md is exhausted.
92 */
93 if (md->md_refcount != 0)
94 return 0;
95
96 if ((md->md_flags & LNET_MD_FLAG_ZOMBIE) != 0)
97 return 1;
98
99 return ((md->md_flags & LNET_MD_FLAG_AUTO_UNLINK) != 0 &&
100 lnet_md_exhausted(md));
101}
102
103#define lnet_cpt_table() (the_lnet.ln_cpt_table)
104#define lnet_cpt_current() cfs_cpt_current(the_lnet.ln_cpt_table, 1)
105
106static inline int
107lnet_cpt_of_cookie(__u64 cookie)
108{
109 unsigned int cpt = (cookie >> LNET_COOKIE_TYPE_BITS) & LNET_CPT_MASK;
110
111 /* LNET_CPT_NUMBER doesn't have to be power2, which means we can
112 * get illegal cpt from it's invalid cookie */
113 return cpt < LNET_CPT_NUMBER ? cpt : cpt % LNET_CPT_NUMBER;
114}
115
116static inline void
117lnet_res_lock(int cpt)
118{
119 cfs_percpt_lock(the_lnet.ln_res_lock, cpt);
120}
121
122static inline void
123lnet_res_unlock(int cpt)
124{
125 cfs_percpt_unlock(the_lnet.ln_res_lock, cpt);
126}
127
128static inline int
129lnet_res_lock_current(void)
130{
131 int cpt = lnet_cpt_current();
132
133 lnet_res_lock(cpt);
134 return cpt;
135}
136
137static inline void
138lnet_net_lock(int cpt)
139{
140 cfs_percpt_lock(the_lnet.ln_net_lock, cpt);
141}
142
143static inline void
144lnet_net_unlock(int cpt)
145{
146 cfs_percpt_unlock(the_lnet.ln_net_lock, cpt);
147}
148
149static inline int
150lnet_net_lock_current(void)
151{
152 int cpt = lnet_cpt_current();
153
154 lnet_net_lock(cpt);
155 return cpt;
156}
157
158#define LNET_LOCK() lnet_net_lock(LNET_LOCK_EX)
159#define LNET_UNLOCK() lnet_net_unlock(LNET_LOCK_EX)
160
d7e09d03
PT
161#define lnet_ptl_lock(ptl) spin_lock(&(ptl)->ptl_lock)
162#define lnet_ptl_unlock(ptl) spin_unlock(&(ptl)->ptl_lock)
163#define lnet_eq_wait_lock() spin_lock(&the_lnet.ln_eq_wait_lock)
164#define lnet_eq_wait_unlock() spin_unlock(&the_lnet.ln_eq_wait_lock)
165#define lnet_ni_lock(ni) spin_lock(&(ni)->ni_lock)
166#define lnet_ni_unlock(ni) spin_unlock(&(ni)->ni_lock)
d7e09d03 167
d7e09d03
PT
168#define MAX_PORTALS 64
169
d7e09d03 170static inline lnet_eq_t *
62fbc9f7 171lnet_eq_alloc(void)
d7e09d03 172{
d7e09d03
PT
173 lnet_eq_t *eq;
174
175 LIBCFS_ALLOC(eq, sizeof(*eq));
02816395 176 return eq;
d7e09d03
PT
177}
178
179static inline void
180lnet_eq_free(lnet_eq_t *eq)
181{
d7e09d03
PT
182 LIBCFS_FREE(eq, sizeof(*eq));
183}
184
185static inline lnet_libmd_t *
62fbc9f7 186lnet_md_alloc(lnet_md_t *umd)
d7e09d03 187{
d7e09d03
PT
188 lnet_libmd_t *md;
189 unsigned int size;
190 unsigned int niov;
191
192 if ((umd->options & LNET_MD_KIOV) != 0) {
193 niov = umd->length;
194 size = offsetof(lnet_libmd_t, md_iov.kiov[niov]);
195 } else {
196 niov = ((umd->options & LNET_MD_IOVEC) != 0) ?
197 umd->length : 1;
198 size = offsetof(lnet_libmd_t, md_iov.iov[niov]);
199 }
200
201 LIBCFS_ALLOC(md, size);
202
203 if (md != NULL) {
204 /* Set here in case of early free */
205 md->md_options = umd->options;
206 md->md_niov = niov;
207 INIT_LIST_HEAD(&md->md_list);
208 }
209
02816395 210 return md;
d7e09d03
PT
211}
212
213static inline void
214lnet_md_free(lnet_libmd_t *md)
215{
d7e09d03
PT
216 unsigned int size;
217
218 if ((md->md_options & LNET_MD_KIOV) != 0)
219 size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]);
220 else
221 size = offsetof(lnet_libmd_t, md_iov.iov[md->md_niov]);
222
223 LIBCFS_FREE(md, size);
224}
225
226static inline lnet_me_t *
62fbc9f7 227lnet_me_alloc(void)
d7e09d03 228{
d7e09d03
PT
229 lnet_me_t *me;
230
231 LIBCFS_ALLOC(me, sizeof(*me));
02816395 232 return me;
d7e09d03
PT
233}
234
235static inline void
236lnet_me_free(lnet_me_t *me)
237{
d7e09d03
PT
238 LIBCFS_FREE(me, sizeof(*me));
239}
240
241static inline lnet_msg_t *
242lnet_msg_alloc(void)
243{
d7e09d03
PT
244 lnet_msg_t *msg;
245
246 LIBCFS_ALLOC(msg, sizeof(*msg));
247
248 /* no need to zero, LIBCFS_ALLOC does for us */
02816395 249 return msg;
d7e09d03
PT
250}
251
252static inline void
253lnet_msg_free(lnet_msg_t *msg)
254{
d7e09d03
PT
255 LASSERT(!msg->msg_onactivelist);
256 LIBCFS_FREE(msg, sizeof(*msg));
257}
258
d7e09d03
PT
259lnet_libhandle_t *lnet_res_lh_lookup(struct lnet_res_container *rec,
260 __u64 cookie);
261void lnet_res_lh_initialize(struct lnet_res_container *rec,
262 lnet_libhandle_t *lh);
263static inline void
264lnet_res_lh_invalidate(lnet_libhandle_t *lh)
265{
d7e09d03
PT
266 /* NB: cookie is still useful, don't reset it */
267 list_del(&lh->lh_hash_chain);
268}
269
270static inline void
62fbc9f7 271lnet_eq2handle(lnet_handle_eq_t *handle, lnet_eq_t *eq)
d7e09d03
PT
272{
273 if (eq == NULL) {
274 LNetInvalidateHandle(handle);
275 return;
276 }
277
278 handle->cookie = eq->eq_lh.lh_cookie;
279}
280
281static inline lnet_eq_t *
282lnet_handle2eq(lnet_handle_eq_t *handle)
283{
d7e09d03
PT
284 lnet_libhandle_t *lh;
285
286 lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie);
287 if (lh == NULL)
288 return NULL;
289
290 return lh_entry(lh, lnet_eq_t, eq_lh);
291}
292
293static inline void
62fbc9f7 294lnet_md2handle(lnet_handle_md_t *handle, lnet_libmd_t *md)
d7e09d03
PT
295{
296 handle->cookie = md->md_lh.lh_cookie;
297}
298
299static inline lnet_libmd_t *
300lnet_handle2md(lnet_handle_md_t *handle)
301{
302 /* ALWAYS called with resource lock held */
303 lnet_libhandle_t *lh;
304 int cpt;
305
306 cpt = lnet_cpt_of_cookie(handle->cookie);
307 lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
308 handle->cookie);
309 if (lh == NULL)
310 return NULL;
311
312 return lh_entry(lh, lnet_libmd_t, md_lh);
313}
314
315static inline lnet_libmd_t *
316lnet_wire_handle2md(lnet_handle_wire_t *wh)
317{
318 /* ALWAYS called with resource lock held */
319 lnet_libhandle_t *lh;
320 int cpt;
321
322 if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie)
323 return NULL;
324
325 cpt = lnet_cpt_of_cookie(wh->wh_object_cookie);
326 lh = lnet_res_lh_lookup(the_lnet.ln_md_containers[cpt],
327 wh->wh_object_cookie);
328 if (lh == NULL)
329 return NULL;
330
331 return lh_entry(lh, lnet_libmd_t, md_lh);
332}
333
334static inline void
62fbc9f7 335lnet_me2handle(lnet_handle_me_t *handle, lnet_me_t *me)
d7e09d03
PT
336{
337 handle->cookie = me->me_lh.lh_cookie;
338}
339
340static inline lnet_me_t *
341lnet_handle2me(lnet_handle_me_t *handle)
342{
343 /* ALWAYS called with resource lock held */
344 lnet_libhandle_t *lh;
345 int cpt;
346
347 cpt = lnet_cpt_of_cookie(handle->cookie);
348 lh = lnet_res_lh_lookup(the_lnet.ln_me_containers[cpt],
349 handle->cookie);
350 if (lh == NULL)
351 return NULL;
352
353 return lh_entry(lh, lnet_me_t, me_lh);
354}
355
356static inline void
357lnet_peer_addref_locked(lnet_peer_t *lp)
358{
62fbc9f7 359 LASSERT(lp->lp_refcount > 0);
d7e09d03
PT
360 lp->lp_refcount++;
361}
362
0ee98a9f 363void lnet_destroy_peer_locked(lnet_peer_t *lp);
d7e09d03
PT
364
365static inline void
366lnet_peer_decref_locked(lnet_peer_t *lp)
367{
62fbc9f7 368 LASSERT(lp->lp_refcount > 0);
d7e09d03
PT
369 lp->lp_refcount--;
370 if (lp->lp_refcount == 0)
371 lnet_destroy_peer_locked(lp);
372}
373
374static inline int
375lnet_isrouter(lnet_peer_t *lp)
376{
377 return lp->lp_rtr_refcount != 0;
378}
379
380static inline void
381lnet_ni_addref_locked(lnet_ni_t *ni, int cpt)
382{
383 LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER);
384 LASSERT(*ni->ni_refs[cpt] >= 0);
385
386 (*ni->ni_refs[cpt])++;
387}
388
389static inline void
390lnet_ni_addref(lnet_ni_t *ni)
391{
392 lnet_net_lock(0);
393 lnet_ni_addref_locked(ni, 0);
394 lnet_net_unlock(0);
395}
396
397static inline void
398lnet_ni_decref_locked(lnet_ni_t *ni, int cpt)
399{
400 LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER);
401 LASSERT(*ni->ni_refs[cpt] > 0);
402
403 (*ni->ni_refs[cpt])--;
404}
405
406static inline void
407lnet_ni_decref(lnet_ni_t *ni)
408{
409 lnet_net_lock(0);
410 lnet_ni_decref_locked(ni, 0);
411 lnet_net_unlock(0);
412}
413
414void lnet_ni_free(lnet_ni_t *ni);
415
416static inline int
417lnet_nid2peerhash(lnet_nid_t nid)
418{
72c0824a 419 return hash_long(nid, LNET_PEER_HASH_BITS);
d7e09d03
PT
420}
421
422static inline struct list_head *
423lnet_net2rnethash(__u32 net)
424{
425 return &the_lnet.ln_remote_nets_hash[(LNET_NETNUM(net) +
426 LNET_NETTYP(net)) &
427 ((1U << the_lnet.ln_remote_nets_hbits) - 1)];
428}
429
430extern lnd_t the_lolnd;
af3fa7c7 431extern int avoid_asym_router_failure;
d7e09d03 432
0ee98a9f
GKH
433int lnet_cpt_of_nid_locked(lnet_nid_t nid);
434int lnet_cpt_of_nid(lnet_nid_t nid);
435lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt);
436lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt);
437lnet_ni_t *lnet_net2ni(__u32 net);
d7e09d03 438
a649ad1d 439int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, unsigned long when);
2b06b70b
AO
440void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive,
441 unsigned long when);
e75fb87f
DO
442int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid,
443 unsigned int priority);
d7e09d03
PT
444int lnet_check_routes(void);
445int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
446void lnet_destroy_routes(void);
447int lnet_get_route(int idx, __u32 *net, __u32 *hops,
e75fb87f 448 lnet_nid_t *gateway, __u32 *alive, __u32 *priority);
d7e09d03
PT
449void lnet_proc_init(void);
450void lnet_proc_fini(void);
451int lnet_rtrpools_alloc(int im_a_router);
452void lnet_rtrpools_free(void);
62fbc9f7 453lnet_remotenet_t *lnet_find_net_locked(__u32 net);
d7e09d03
PT
454
455int lnet_islocalnid(lnet_nid_t nid);
456int lnet_islocalnet(__u32 net);
457
458void lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md,
459 unsigned int offset, unsigned int mlen);
460void lnet_msg_detach_md(lnet_msg_t *msg, int status);
461void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev);
462void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type);
463void lnet_msg_commit(lnet_msg_t *msg, int cpt);
464void lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status);
465
466void lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev);
467void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
468 unsigned int offset, unsigned int len);
469int lnet_send(lnet_nid_t nid, lnet_msg_t *msg, lnet_nid_t rtr_nid);
470void lnet_return_tx_credits_locked(lnet_msg_t *msg);
471void lnet_return_rx_credits_locked(lnet_msg_t *msg);
472
473/* portals functions */
474/* portals attributes */
475static inline int
476lnet_ptl_is_lazy(lnet_portal_t *ptl)
477{
478 return !!(ptl->ptl_options & LNET_PTL_LAZY);
479}
480
481static inline int
482lnet_ptl_is_unique(lnet_portal_t *ptl)
483{
484 return !!(ptl->ptl_options & LNET_PTL_MATCH_UNIQUE);
485}
486
487static inline int
488lnet_ptl_is_wildcard(lnet_portal_t *ptl)
489{
490 return !!(ptl->ptl_options & LNET_PTL_MATCH_WILDCARD);
491}
492
493static inline void
494lnet_ptl_setopt(lnet_portal_t *ptl, int opt)
495{
496 ptl->ptl_options |= opt;
497}
498
499static inline void
500lnet_ptl_unsetopt(lnet_portal_t *ptl, int opt)
501{
502 ptl->ptl_options &= ~opt;
503}
504
505/* match-table functions */
506struct list_head *lnet_mt_match_head(struct lnet_match_table *mtable,
09bce335 507 lnet_process_id_t id, __u64 mbits);
d7e09d03
PT
508struct lnet_match_table *lnet_mt_of_attach(unsigned int index,
509 lnet_process_id_t id, __u64 mbits,
510 __u64 ignore_bits,
511 lnet_ins_pos_t pos);
512int lnet_mt_match_md(struct lnet_match_table *mtable,
513 struct lnet_match_info *info, struct lnet_msg *msg);
514
515/* portals match/attach functions */
516void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
517 struct list_head *matches, struct list_head *drops);
518void lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md);
519int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg);
520
521/* initialized and finalize portals */
522int lnet_portals_create(void);
523void lnet_portals_destroy(void);
524
525/* message functions */
62fbc9f7 526int lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr,
09bce335 527 lnet_nid_t fromnid, void *private, int rdma_req);
d7e09d03
PT
528void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
529 unsigned int offset, unsigned int mlen, unsigned int rlen);
62fbc9f7 530lnet_msg_t *lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *get_msg);
d7e09d03
PT
531void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len);
532void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc);
533void lnet_drop_delayed_msg_list(struct list_head *head, char *reason);
534void lnet_recv_delayed_msg_list(struct list_head *head);
535
536int lnet_msg_container_setup(struct lnet_msg_container *container, int cpt);
537void lnet_msg_container_cleanup(struct lnet_msg_container *container);
538void lnet_msg_containers_destroy(void);
539int lnet_msg_containers_create(void);
540
62fbc9f7 541char *lnet_msgtyp2str(int type);
ac0a2871 542void lnet_print_hdr(lnet_hdr_t *hdr);
d7e09d03
PT
543int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold);
544
545void lnet_counters_get(lnet_counters_t *counters);
546void lnet_counters_reset(void);
547
f351bad2
AV
548unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov);
549int lnet_extract_iov(int dst_niov, struct kvec *dst,
550 int src_niov, struct kvec *src,
d7e09d03
PT
551 unsigned int offset, unsigned int len);
552
62fbc9f7
LN
553unsigned int lnet_kiov_nob(unsigned int niov, lnet_kiov_t *iov);
554int lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
d7e09d03
PT
555 int src_niov, lnet_kiov_t *src,
556 unsigned int offset, unsigned int len);
557
f351bad2 558void lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov,
09bce335 559 unsigned int doffset,
f351bad2 560 unsigned int nsiov, struct kvec *siov,
d7e09d03 561 unsigned int soffset, unsigned int nob);
f351bad2 562void lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov,
09bce335 563 unsigned int iovoffset,
d7e09d03
PT
564 unsigned int nkiov, lnet_kiov_t *kiov,
565 unsigned int kiovoffset, unsigned int nob);
62fbc9f7 566void lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov,
09bce335 567 unsigned int kiovoffset,
f351bad2 568 unsigned int niov, struct kvec *iov,
d7e09d03 569 unsigned int iovoffset, unsigned int nob);
62fbc9f7 570void lnet_copy_kiov2kiov(unsigned int ndkiov, lnet_kiov_t *dkiov,
09bce335 571 unsigned int doffset,
d7e09d03
PT
572 unsigned int nskiov, lnet_kiov_t *skiov,
573 unsigned int soffset, unsigned int nob);
574
575static inline void
576lnet_copy_iov2flat(int dlen, void *dest, unsigned int doffset,
f351bad2 577 unsigned int nsiov, struct kvec *siov, unsigned int soffset,
d7e09d03
PT
578 unsigned int nob)
579{
f351bad2 580 struct kvec diov = {/*.iov_base = */ dest, /*.iov_len = */ dlen};
d7e09d03
PT
581
582 lnet_copy_iov2iov(1, &diov, doffset,
583 nsiov, siov, soffset, nob);
584}
585
586static inline void
587lnet_copy_kiov2flat(int dlen, void *dest, unsigned int doffset,
2b06b70b
AO
588 unsigned int nsiov, lnet_kiov_t *skiov,
589 unsigned int soffset, unsigned int nob)
d7e09d03 590{
f351bad2 591 struct kvec diov = {/* .iov_base = */ dest, /* .iov_len = */ dlen};
d7e09d03
PT
592
593 lnet_copy_kiov2iov(1, &diov, doffset,
594 nsiov, skiov, soffset, nob);
595}
596
597static inline void
f351bad2 598lnet_copy_flat2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
d7e09d03
PT
599 int slen, void *src, unsigned int soffset, unsigned int nob)
600{
f351bad2 601 struct kvec siov = {/*.iov_base = */ src, /*.iov_len = */slen};
681fc807 602
d7e09d03
PT
603 lnet_copy_iov2iov(ndiov, diov, doffset,
604 1, &siov, soffset, nob);
605}
606
607static inline void
2b06b70b
AO
608lnet_copy_flat2kiov(unsigned int ndiov, lnet_kiov_t *dkiov,
609 unsigned int doffset, int slen, void *src,
610 unsigned int soffset, unsigned int nob)
d7e09d03 611{
f351bad2 612 struct kvec siov = {/* .iov_base = */ src, /* .iov_len = */ slen};
681fc807 613
d7e09d03
PT
614 lnet_copy_iov2kiov(ndiov, dkiov, doffset,
615 1, &siov, soffset, nob);
616}
617
618void lnet_me_unlink(lnet_me_t *me);
619
620void lnet_md_unlink(lnet_libmd_t *md);
621void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd);
622
623void lnet_register_lnd(lnd_t *lnd);
624void lnet_unregister_lnd(lnd_t *lnd);
d7e09d03 625
e327dc88 626int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
d7e09d03
PT
627 __u32 local_ip, __u32 peer_ip, int peer_port);
628void lnet_connect_console_error(int rc, lnet_nid_t peer_nid,
629 __u32 peer_ip, int port);
630int lnet_count_acceptor_nis(void);
631int lnet_acceptor_timeout(void);
632int lnet_acceptor_port(void);
633
634int lnet_count_acceptor_nis(void);
635int lnet_acceptor_port(void);
636
637int lnet_acceptor_start(void);
638void lnet_acceptor_stop(void);
639
1ad6a73e
JS
640int lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
641int lnet_ipif_enumerate(char ***names);
642void lnet_ipif_free_enumeration(char **names, int n);
643int lnet_sock_setbuf(struct socket *socket, int txbufsize, int rxbufsize);
644int lnet_sock_getbuf(struct socket *socket, int *txbufsize, int *rxbufsize);
645int lnet_sock_getaddr(struct socket *socket, bool remote, __u32 *ip, int *port);
646int lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout);
647int lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout);
648
649int lnet_sock_listen(struct socket **sockp, __u32 ip, int port, int backlog);
650int lnet_sock_accept(struct socket **newsockp, struct socket *sock);
651int lnet_sock_connect(struct socket **sockp, int *fatal,
652 __u32 local_ip, int local_port,
653 __u32 peer_ip, int peer_port);
654void libcfs_sock_release(struct socket *sock);
655
d7e09d03
PT
656int lnet_peers_start_down(void);
657int lnet_peer_buffer_credits(lnet_ni_t *ni);
658
659int lnet_router_checker_start(void);
660void lnet_router_checker_stop(void);
af3fa7c7 661void lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net);
d7e09d03
PT
662void lnet_swap_pinginfo(lnet_ping_info_t *info);
663
664int lnet_ping_target_init(void);
665void lnet_ping_target_fini(void);
666int lnet_ping(lnet_process_id_t id, int timeout_ms,
667 lnet_process_id_t *ids, int n_ids);
668
62fbc9f7
LN
669int lnet_parse_ip2nets(char **networksp, char *ip2nets);
670int lnet_parse_routes(char *route_str, int *im_a_router);
671int lnet_parse_networks(struct list_head *nilist, char *networks);
d7e09d03
PT
672
673int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt);
674lnet_peer_t *lnet_find_peer_locked(struct lnet_peer_table *ptable,
675 lnet_nid_t nid);
676void lnet_peer_tables_cleanup(void);
677void lnet_peer_tables_destroy(void);
678int lnet_peer_tables_create(void);
679void lnet_debug_peer(lnet_nid_t nid);
680
af3fa7c7
LZ
681static inline void lnet_peer_set_alive(lnet_peer_t *lp)
682{
683 lp->lp_last_alive = lp->lp_last_query = get_seconds();
684 if (!lp->lp_alive)
685 lnet_notify_locked(lp, 0, 1, lp->lp_last_alive);
686}
687
688
d7e09d03 689#endif