Whamcloud - gitweb
LU-17705 ptlrpc: replace synchronize_rcu() with rcu_barrier()
[fs/lustre-release.git] / lnet / lnet / lo.c
1 // SPDX-License-Identifier: GPL-2.0
2
3 /* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4  * Use is subject to license terms.
5  *
6  * Copyright (c) 2017, Intel Corporation.
7  */
8
9 /* This file is part of Lustre, http://www.lustre.org/ */
10
11 #define DEBUG_SUBSYSTEM S_LNET
12 #include <lnet/lib-lnet.h>
13
14 static int
15 lolnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
16 {
17         LASSERT(!lntmsg->msg_routing);
18         LASSERT(!lntmsg->msg_target_is_router);
19
20         return lnet_parse(ni, &lntmsg->msg_hdr, &ni->ni_nid, lntmsg, 0);
21 }
22
23 static int
24 lolnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
25            int delayed, unsigned int niov,
26            struct bio_vec *kiov,
27            unsigned int offset, unsigned int mlen, unsigned int rlen)
28 {
29         struct lnet_msg *sendmsg = private;
30
31         if (lntmsg) {                   /* not discarding */
32                 lnet_copy_kiov2kiov(niov, kiov, offset,
33                                     sendmsg->msg_niov,
34                                     sendmsg->msg_kiov,
35                                     sendmsg->msg_offset, mlen);
36
37                 lnet_finalize(lntmsg, 0);
38         }
39
40         lnet_finalize(sendmsg, 0);
41         return 0;
42 }
43
44 static int lolnd_instanced;
45
46 static void
47 lolnd_shutdown(struct lnet_ni *ni)
48 {
49         CDEBUG (D_NET, "shutdown\n");
50         LASSERT(lolnd_instanced);
51
52         lolnd_instanced = 0;
53 }
54
55 static int
56 lolnd_startup(struct lnet_ni *ni)
57 {
58         LASSERT (ni->ni_net->net_lnd == &the_lolnd);
59         LASSERT (!lolnd_instanced);
60         lolnd_instanced = 1;
61
62         return (0);
63 }
64
65 const struct lnet_lnd the_lolnd = {
66         .lnd_type       = LOLND,
67         .lnd_startup    = lolnd_startup,
68         .lnd_shutdown   = lolnd_shutdown,
69         .lnd_send       = lolnd_send,
70         .lnd_recv       = lolnd_recv
71 };