Whamcloud - gitweb
9d1c49c0574def8f63d29ed642be9fc4ba0bb772
[fs/lustre-release.git] / lnet / include / lnet / api.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __LNET_API_H__
38 #define __LNET_API_H__
39
40 /** \defgroup lnet LNet
41  *
42  * The Lustre Networking subsystem.
43  *
44  * LNet is an asynchronous message-passing API, which provides an unreliable
45  * connectionless service that can't guarantee any order. It supports OFA IB,
46  * TCP/IP, and Cray Portals, and routes between heterogeneous networks.
47  *
48  * LNet can run both in OS kernel space and in userspace as a library.
49  * @{
50  */
51
52 #include <lnet/types.h>
53
54 /** \defgroup lnet_init_fini Initialization and cleanup
55  * The LNet must be properly initialized before any LNet calls can be made.
56  * @{ */
57 int LNetInit(void);
58 void LNetFini(void);
59
60 int LNetNIInit(lnet_pid_t requested_pid);
61 int LNetNIFini(void);
62 /** @} lnet_init_fini */
63
64 /** \defgroup lnet_addr LNet addressing and basic types
65  *
66  * Addressing scheme and basic data types of LNet.
67  *
68  * The LNet API is memory-oriented, so LNet must be able to address not only
69  * end-points but also memory region within a process address space.
70  * An ::lnet_nid_t addresses an end-point. An ::lnet_pid_t identifies a process
71  * in a node. A portal represents an opening in the address space of a
72  * process. Match bits is criteria to identify a region of memory inside a
73  * portal, and offset specifies an offset within the memory region.
74  *
75  * LNet creates a table of portals for each process during initialization.
76  * This table has MAX_PORTALS entries and its size can't be dynamically
77  * changed. A portal stays empty until the owning process starts to add
78  * memory regions to it. A portal is sometimes called an index because
79  * it's an entry in the portals table of a process.
80  *
81  * \see LNetMEAttach
82  * @{ */
83 int LNetGetId(unsigned int index, lnet_process_id_t *id);
84 int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, __u32 *order);
85 void LNetSnprintHandle(char *str, int str_len, lnet_handle_any_t handle);
86
87 /** @} lnet_addr */
88
89
90 /** \defgroup lnet_me Match entries
91  *
92  * A match entry (abbreviated as ME) describes a set of criteria to accept
93  * incoming requests.
94  *
95  * A portal is essentially a match list plus a set of attributes. A match
96  * list is a chain of MEs. Each ME includes a pointer to a memory descriptor
97  * and a set of match criteria. The match criteria can be used to reject
98  * incoming requests based on process ID or the match bits provided in the
99  * request. MEs can be dynamically inserted into a match list by LNetMEAttach()
100  * and LNetMEInsert(), and removed from its list by LNetMEUnlink().
101  * @{ */
102 int LNetMEAttach(unsigned int      portal,
103                  lnet_process_id_t match_id_in, 
104                  __u64             match_bits_in,
105                  __u64             ignore_bits_in, 
106                  lnet_unlink_t     unlink_in,
107                  lnet_ins_pos_t    pos_in, 
108                  lnet_handle_me_t *handle_out);
109
110 int LNetMEInsert(lnet_handle_me_t  current_in, 
111                  lnet_process_id_t match_id_in,
112                  __u64             match_bits_in, 
113                  __u64             ignore_bits_in,
114                  lnet_unlink_t     unlink_in, 
115                  lnet_ins_pos_t    position_in,
116                  lnet_handle_me_t *handle_out);
117
118 int LNetMEUnlink(lnet_handle_me_t current_in);
119 /** @} lnet_me */
120
121 /** \defgroup lnet_md Memory descriptors
122  *
123  * A memory descriptor contains information about a region of a user's
124  * memory (either in kernel or user space) and optionally points to an
125  * event queue where information about the operations performed on the
126  * memory descriptor are recorded. Memory descriptor is abbreviated as
127  * MD and can be used interchangeably with the memory region it describes.
128  *
129  * The LNet API provides two operations to create MDs: LNetMDAttach()
130  * and LNetMDBind(); one operation to unlink and release the resources
131  * associated with a MD: LNetMDUnlink().
132  * @{ */
133 int LNetMDAttach(lnet_handle_me_t  current_in, 
134                  lnet_md_t         md_in,
135                  lnet_unlink_t     unlink_in, 
136                  lnet_handle_md_t *handle_out);
137
138 int LNetMDBind(lnet_md_t         md_in,
139                lnet_unlink_t     unlink_in, 
140                lnet_handle_md_t *handle_out);
141
142 int LNetMDUnlink(lnet_handle_md_t md_in);
143 /** @} lnet_md */
144
145 /** \defgroup lnet_eq Events and event queues
146  *
147  * Event queues (abbreviated as EQ) are used to log operations performed on
148  * local MDs. In particular, they signal the completion of a data transmission
149  * into or out of a MD. They can also be used to hold acknowledgments for
150  * completed PUT operations and indicate when a MD has been unlinked. Multiple
151  * MDs can share a single EQ. An EQ may have an optional event handler
152  * associated with it. If an event handler exists, it will be run for each
153  * event that is deposited into the EQ.
154  *
155  * In addition to the lnet_handle_eq_t, the LNet API defines two types
156  * associated with events: The ::lnet_event_kind_t defines the kinds of events
157  * that can be stored in an EQ. The lnet_event_t defines a structure that
158  * holds the information about with an event.
159  *
160  * There are five functions for dealing with EQs: LNetEQAlloc() is used to
161  * create an EQ and allocate the resources needed, while LNetEQFree()
162  * releases these resources and free the EQ. LNetEQGet() retrieves the next
163  * event from an EQ, and LNetEQWait() can be used to block a process until
164  * an EQ has at least one event. LNetEQPoll() can be used to test or wait
165  * on multiple EQs.
166  * @{ */
167 int LNetEQAlloc(unsigned int       count_in,
168                 lnet_eq_handler_t  handler,
169                 lnet_handle_eq_t  *handle_out);
170
171 int LNetEQFree(lnet_handle_eq_t eventq_in);
172
173 int LNetEQGet(lnet_handle_eq_t  eventq_in, 
174               lnet_event_t     *event_out);
175
176
177 int LNetEQWait(lnet_handle_eq_t  eventq_in, 
178                lnet_event_t     *event_out);
179
180 int LNetEQPoll(lnet_handle_eq_t *eventqs_in, 
181                int               neq_in, 
182                int               timeout_ms,
183                lnet_event_t     *event_out, 
184                int              *which_eq_out);
185 /** @} lnet_eq */
186
187 /** \defgroup lnet_data Data movement operations
188  *
189  * The LNet API provides two data movement operations: LNetPut()
190  * and LNetGet().
191  * @{ */
192 int LNetPut(lnet_nid_t        self,
193             lnet_handle_md_t  md_in, 
194             lnet_ack_req_t    ack_req_in,
195             lnet_process_id_t target_in, 
196             unsigned int      portal_in,
197             __u64             match_bits_in,
198             unsigned int      offset_in, 
199             __u64             hdr_data_in);
200
201 int LNetGet(lnet_nid_t        self,
202             lnet_handle_md_t  md_in, 
203             lnet_process_id_t target_in,
204             unsigned int      portal_in, 
205             __u64             match_bits_in, 
206             unsigned int      offset_in);
207 /** @} lnet_data */
208
209
210 /** \defgroup lnet_misc Miscellaneous operations.
211  * Miscellaneous operations.
212  * @{ */
213
214 int LNetSetLazyPortal(int portal);
215 int LNetClearLazyPortal(int portal);
216 int LNetCtl(unsigned int cmd, void *arg);
217 int LNetSetAsync(lnet_process_id_t id, int nasync);
218
219 #ifndef __KERNEL__
220 /* Temporary workaround to allow uOSS and test programs force server
221  * mode in userspace. See comments near ln_server_mode_flag in
222  * lnet/lib-types.h */
223
224 void lnet_server_mode();
225 #endif
226 /** @} lnet_misc */
227
228 /** @} lnet */
229 #endif