Whamcloud - gitweb
LU-17602 mdd: use correct fid in mdd_rename
[fs/lustre-release.git] / lnet / include / lnet / api.h
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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2016, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  */
31
32 #ifndef __LNET_API_H__
33 #define __LNET_API_H__
34
35 /** \defgroup lnet LNet
36  *
37  * The Lustre Networking subsystem.
38  *
39  * LNet is an asynchronous message-passing API, which provides an unreliable
40  * connectionless service that can't guarantee any order. It supports OFA IB,
41  * TCP/IP, and Cray Portals, and routes between heterogeneous networks.
42  * @{
43  */
44
45 #ifndef __KERNEL__
46 # error This include is only for kernel use.
47 #endif
48
49 #include <uapi/linux/lnet/lnet-types.h>
50
51 /** \defgroup lnet_init_fini Initialization and cleanup
52  * The LNet must be properly initialized before any LNet calls can be made.
53  * @{ */
54 int LNetNIInit(lnet_pid_t requested_pid);
55 int LNetNIFini(void);
56 /** @} lnet_init_fini */
57
58 /** \defgroup lnet_addr LNet addressing and basic types
59  *
60  * Addressing scheme and basic data types of LNet.
61  *
62  * The LNet API is memory-oriented, so LNet must be able to address not only
63  * end-points but also memory region within a process address space.
64  * An ::lnet_nid_t addresses an end-point. An ::lnet_pid_t identifies a process
65  * in a node. A portal represents an opening in the address space of a
66  * process. Match bits is criteria to identify a region of memory inside a
67  * portal, and offset specifies an offset within the memory region.
68  *
69  * LNet creates a table of portals for each process during initialization.
70  * This table has MAX_PORTALS entries and its size can't be dynamically
71  * changed. A portal stays empty until the owning process starts to add
72  * memory regions to it. A portal is sometimes called an index because
73  * it's an entry in the portals table of a process.
74  *
75  * \see LNetMEAttach
76  * @{ */
77 int LNetGetId(unsigned int index, struct lnet_processid *id, bool large_nids);
78 int LNetDist(struct lnet_nid *nid, struct lnet_nid *srcnid, __u32 *order);
79 void LNetPrimaryNID(struct lnet_nid *nid);
80 bool LNetIsPeerLocal(struct lnet_nid *nid);
81 bool LNetPeerDiscovered(struct lnet_nid *nid);
82
83 /** @} lnet_addr */
84
85
86 /** \defgroup lnet_me Match entries
87  *
88  * A match entry (abbreviated as ME) describes a set of criteria to accept
89  * incoming requests.
90  *
91  * A portal is essentially a match list plus a set of attributes. A match
92  * list is a chain of MEs. Each ME includes a pointer to a memory descriptor
93  * and a set of match criteria. The match criteria can be used to reject
94  * incoming requests based on process ID or the match bits provided in the
95  * request. MEs can be dynamically inserted into a match list by LNetMEAttach(),
96  * and must then be attached to an MD with LNetMDAttach().
97  * @{ */
98 struct lnet_me *
99 LNetMEAttach(unsigned int portal,
100              struct lnet_processid *match_id_in,
101              __u64 match_bits_in,
102              __u64 ignore_bits_in,
103              enum lnet_unlink unlink_in,
104              enum lnet_ins_pos pos_in);
105 /** @} lnet_me */
106
107 /** \defgroup lnet_md Memory descriptors
108  *
109  * A memory descriptor contains information about a region of a user's
110  * memory (either in kernel or user space) and optionally points to an
111  * event queue where information about the operations performed on the
112  * memory descriptor are recorded. Memory descriptor is abbreviated as
113  * MD and can be used interchangeably with the memory region it describes.
114  *
115  * The LNet API provides two operations to create MDs: LNetMDAttach()
116  * and LNetMDBind(); one operation to unlink and release the resources
117  * associated with a MD: LNetMDUnlink().
118  * @{ */
119 int LNetMDAttach(struct lnet_me *current_in,
120                  const struct lnet_md *md_in,
121                  enum lnet_unlink unlink_in,
122                  struct lnet_handle_md *md_handle_out);
123
124 int LNetMDBind(const struct lnet_md *md_in,
125                enum lnet_unlink unlink_in,
126                struct lnet_handle_md *md_handle_out);
127
128 int __LNetMDUnlink(struct lnet_handle_md md_in, bool discard);
129 #define LNetMDUnlink(handle) __LNetMDUnlink(handle, false)
130
131 void lnet_assert_handler_unused(lnet_handler_t handler);
132 /** @} lnet_md */
133
134 /** \defgroup lnet_data Data movement operations
135  *
136  * The LNet API provides two data movement operations: LNetPut()
137  * and LNetGet().
138  * @{ */
139 int LNetPut(struct lnet_nid             *self,
140             struct lnet_handle_md       md_in,
141             enum lnet_ack_req           ack_req_in,
142             struct lnet_processid       *target_in,
143             unsigned int                portal_in,
144             __u64                       match_bits_in,
145             unsigned int                offset_in,
146             __u64                       hdr_data_in);
147
148 int LNetGet(struct lnet_nid             *self,
149             struct lnet_handle_md       md_in,
150             struct lnet_processid       *target_in,
151             unsigned int                portal_in,
152             __u64                       match_bits_in,
153             unsigned int                offset_in,
154             bool                        recovery);
155 /** @} lnet_data */
156
157
158 /** \defgroup lnet_misc Miscellaneous operations.
159  * Miscellaneous operations.
160  * @{ */
161
162 int LNetSetLazyPortal(int portal);
163 int LNetClearLazyPortal(int portal);
164 int LNetCtl(unsigned int cmd, void *arg);
165 void LNetDebugPeer(struct lnet_processid *id);
166 int LNetGetPeerDiscoveryStatus(void);
167 int LNetAddPeer(struct lnet_nid *nids, u32 num_nids);
168
169 /** @} lnet_misc */
170
171 /** @} lnet */
172 #endif