Whamcloud - gitweb
b=14238, i=liangzhen, i=maxim:
[fs/lustre-release.git] / lnet / lnet / lo.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2004 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #define DEBUG_SUBSYSTEM S_LNET
23 #include <lnet/lib-lnet.h>
24
25 int
26 lolnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
27 {
28         LASSERT (!lntmsg->msg_routing);
29         LASSERT (!lntmsg->msg_target_is_router);
30         
31         return lnet_parse(ni, &lntmsg->msg_hdr, ni->ni_nid, lntmsg, 0);
32 }
33
34 int
35 lolnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
36             int delayed, unsigned int niov, 
37             struct iovec *iov, lnet_kiov_t *kiov,
38             unsigned int offset, unsigned int mlen, unsigned int rlen)
39 {
40         lnet_msg_t *sendmsg = private;
41
42         if (lntmsg != NULL) {                   /* not discarding */
43                 if (sendmsg->msg_iov != NULL) {
44                         if (iov != NULL)
45                                 lnet_copy_iov2iov(niov, iov, offset,
46                                                   sendmsg->msg_niov,
47                                                   sendmsg->msg_iov,
48                                                   sendmsg->msg_offset, mlen);
49                         else
50                                 lnet_copy_iov2kiov(niov, kiov, offset,
51                                                    sendmsg->msg_niov,
52                                                    sendmsg->msg_iov,
53                                                    sendmsg->msg_offset, mlen);
54                 } else {
55                         if (iov != NULL)
56                                 lnet_copy_kiov2iov(niov, iov, offset,
57                                                    sendmsg->msg_niov,
58                                                    sendmsg->msg_kiov,
59                                                    sendmsg->msg_offset, mlen);
60                         else
61                                 lnet_copy_kiov2kiov(niov, kiov, offset,
62                                                     sendmsg->msg_niov,
63                                                     sendmsg->msg_kiov,
64                                                     sendmsg->msg_offset, mlen);
65                 }
66
67                 lnet_finalize(ni, lntmsg, 0);
68         }
69         
70         lnet_finalize(ni, sendmsg, 0);
71         return 0;
72 }
73
74 static int lolnd_instanced;
75
76 void
77 lolnd_shutdown(lnet_ni_t *ni)
78 {
79         CDEBUG (D_NET, "shutdown\n");
80         LASSERT (lolnd_instanced);
81         
82         lolnd_instanced = 0;
83 }
84
85 int
86 lolnd_startup (lnet_ni_t *ni)
87 {
88         LASSERT (ni->ni_lnd == &the_lolnd);
89         LASSERT (!lolnd_instanced);
90         lolnd_instanced = 1;
91
92         return (0);
93 }
94
95 lnd_t the_lolnd = {
96         /* .lnd_list       = */ {&the_lolnd.lnd_list, &the_lolnd.lnd_list},
97         /* .lnd_refcount   = */ 0,
98         /* .lnd_type       = */ LOLND,
99         /* .lnd_startup    = */ lolnd_startup,
100         /* .lnd_shutdown   = */ lolnd_shutdown,
101         /* .lnt_ctl        = */ NULL, 
102         /* .lnd_send       = */ lolnd_send,
103         /* .lnd_recv       = */ lolnd_recv,
104         /* .lnd_eager_recv = */ NULL,
105         /* .lnd_notify     = */ NULL,
106 #ifdef __KERNEL__
107         /* .lnd_accept     = */ NULL
108 #else
109         /* .lnd_wait       = */ NULL
110 #endif
111 };
112