Whamcloud - gitweb
LU-9480 lnet: add enhanced statistics
[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, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  */
32
33 #ifndef __LNET_API_H__
34 #define __LNET_API_H__
35
36 /** \defgroup lnet LNet
37  *
38  * The Lustre Networking subsystem.
39  *
40  * LNet is an asynchronous message-passing API, which provides an unreliable
41  * connectionless service that can't guarantee any order. It supports OFA IB,
42  * TCP/IP, and Cray Portals, and routes between heterogeneous networks.
43  * @{
44  */
45
46 #ifndef __KERNEL__
47 # error This include is only for kernel use.
48 #endif
49
50 #include <uapi/linux/lnet/lnet-types.h>
51
52 /** \defgroup lnet_init_fini Initialization and cleanup
53  * The LNet must be properly initialized before any LNet calls can be made.
54  * @{ */
55 int LNetNIInit(lnet_pid_t requested_pid);
56 int LNetNIFini(void);
57 /** @} lnet_init_fini */
58
59 /** \defgroup lnet_addr LNet addressing and basic types
60  *
61  * Addressing scheme and basic data types of LNet.
62  *
63  * The LNet API is memory-oriented, so LNet must be able to address not only
64  * end-points but also memory region within a process address space.
65  * An ::lnet_nid_t addresses an end-point. An ::lnet_pid_t identifies a process
66  * in a node. A portal represents an opening in the address space of a
67  * process. Match bits is criteria to identify a region of memory inside a
68  * portal, and offset specifies an offset within the memory region.
69  *
70  * LNet creates a table of portals for each process during initialization.
71  * This table has MAX_PORTALS entries and its size can't be dynamically
72  * changed. A portal stays empty until the owning process starts to add
73  * memory regions to it. A portal is sometimes called an index because
74  * it's an entry in the portals table of a process.
75  *
76  * \see LNetMEAttach
77  * @{ */
78 int LNetGetId(unsigned int index, struct lnet_process_id *id);
79 int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, __u32 *order);
80 lnet_nid_t LNetPrimaryNID(lnet_nid_t nid);
81 bool LNetIsPeerLocal(lnet_nid_t 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 LNetMEInsert(), and removed from its list by LNetMEUnlink().
97  * @{ */
98 int LNetMEAttach(unsigned int      portal,
99                  struct lnet_process_id match_id_in,
100                  __u64             match_bits_in,
101                  __u64             ignore_bits_in,
102                  enum lnet_unlink       unlink_in,
103                  enum lnet_ins_pos      pos_in,
104                  struct lnet_handle_me  *handle_out);
105
106 int LNetMEInsert(struct lnet_handle_me  current_in,
107                  struct lnet_process_id match_id_in,
108                  __u64             match_bits_in,
109                  __u64             ignore_bits_in,
110                  enum lnet_unlink  unlink_in,
111                  enum lnet_ins_pos position_in,
112                  struct lnet_handle_me *handle_out);
113
114 int LNetMEUnlink(struct lnet_handle_me current_in);
115 /** @} lnet_me */
116
117 /** \defgroup lnet_md Memory descriptors
118  *
119  * A memory descriptor contains information about a region of a user's
120  * memory (either in kernel or user space) and optionally points to an
121  * event queue where information about the operations performed on the
122  * memory descriptor are recorded. Memory descriptor is abbreviated as
123  * MD and can be used interchangeably with the memory region it describes.
124  *
125  * The LNet API provides two operations to create MDs: LNetMDAttach()
126  * and LNetMDBind(); one operation to unlink and release the resources
127  * associated with a MD: LNetMDUnlink().
128  * @{ */
129 int LNetMDAttach(struct lnet_handle_me current_in,
130                  struct lnet_md    md_in,
131                  enum lnet_unlink  unlink_in,
132                  struct lnet_handle_md *md_handle_out);
133
134 int LNetMDBind(struct lnet_md    md_in,
135                enum lnet_unlink unlink_in,
136                struct lnet_handle_md *md_handle_out);
137
138 int LNetMDUnlink(struct lnet_handle_md md_in);
139 /** @} lnet_md */
140
141 /** \defgroup lnet_eq Events and event queues
142  *
143  * Event queues (abbreviated as EQ) are used to log operations performed on
144  * local MDs. In particular, they signal the completion of a data transmission
145  * into or out of a MD. They can also be used to hold acknowledgments for
146  * completed PUT operations and indicate when a MD has been unlinked. Multiple
147  * MDs can share a single EQ. An EQ may have an optional event handler
148  * associated with it. If an event handler exists, it will be run for each
149  * event that is deposited into the EQ.
150  *
151  * In addition to the struct lnet_handle_eq, the LNet API defines two types
152  * associated with events: The ::lnet_event_kind defines the kinds of events
153  * that can be stored in an EQ. The struct lnet_event defines a structure that
154  * holds the information about with an event.
155  *
156  * There are five functions for dealing with EQs: LNetEQAlloc() is used to
157  * create an EQ and allocate the resources needed, while LNetEQFree()
158  * releases these resources and free the EQ. LNetEQGet() retrieves the next
159  * event from an EQ, and LNetEQWait() can be used to block a process until
160  * an EQ has at least one event. LNetEQPoll() can be used to test or wait
161  * on multiple EQs.
162  * @{ */
163 int LNetEQAlloc(unsigned int       count_in,
164                 lnet_eq_handler_t  handler,
165                 struct lnet_handle_eq *handle_out);
166
167 int LNetEQFree(struct lnet_handle_eq eventq_in);
168
169 int LNetEQGet(struct lnet_handle_eq eventq_in,
170               struct lnet_event *event_out);
171
172 int LNetEQWait(struct lnet_handle_eq eventq_in,
173                struct lnet_event *event_out);
174
175 int LNetEQPoll(struct lnet_handle_eq *eventqs_in,
176                int               neq_in,
177                signed long       timeout,
178                struct lnet_event *event_out,
179                int              *which_eq_out);
180 /** @} lnet_eq */
181
182 /** \defgroup lnet_data Data movement operations
183  *
184  * The LNet API provides two data movement operations: LNetPut()
185  * and LNetGet().
186  * @{ */
187 int LNetPut(lnet_nid_t        self,
188             struct lnet_handle_md md_in,
189             enum lnet_ack_req   ack_req_in,
190             struct lnet_process_id target_in,
191             unsigned int      portal_in,
192             __u64             match_bits_in,
193             unsigned int      offset_in,
194             __u64             hdr_data_in);
195
196 int LNetGet(lnet_nid_t        self,
197             struct lnet_handle_md md_in,
198             struct lnet_process_id target_in,
199             unsigned int      portal_in,
200             __u64             match_bits_in,
201             unsigned int      offset_in);
202 /** @} lnet_data */
203
204
205 /** \defgroup lnet_misc Miscellaneous operations.
206  * Miscellaneous operations.
207  * @{ */
208
209 int LNetSetLazyPortal(int portal);
210 int LNetClearLazyPortal(int portal);
211 int LNetCtl(unsigned int cmd, void *arg);
212 void LNetDebugPeer(struct lnet_process_id id);
213
214 /** @} lnet_misc */
215
216 /** @} lnet */
217 #endif