1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
29 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef __LNET_API_H__
38 #define __LNET_API_H__
40 /** \defgroup lnet LNet
42 * The Lustre Networking subsystem.
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.
48 * LNet can run both in OS kernel space and in userspace as a library.
52 #include <lnet/types.h>
54 /** \defgroup lnet_init_fini Initialization and cleanup
55 * The LNet must be properly initialized before any LNet calls can be made.
60 int LNetNIInit(lnet_pid_t requested_pid);
62 /** @} lnet_init_fini */
64 /** \defgroup lnet_addr LNet addressing and basic types
66 * Addressing scheme and basic data types of LNet.
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.
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.
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);
90 /** \defgroup lnet_me Match entries
92 * A match entry (abbreviated as ME) describes a set of criteria to accept
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().
102 int LNetMEAttach(unsigned int portal,
103 lnet_process_id_t match_id_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);
110 int LNetMEInsert(lnet_handle_me_t current_in,
111 lnet_process_id_t match_id_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);
118 int LNetMEUnlink(lnet_handle_me_t current_in);
121 /** \defgroup lnet_md Memory descriptors
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.
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().
133 int LNetMDAttach(lnet_handle_me_t current_in,
135 lnet_unlink_t unlink_in,
136 lnet_handle_md_t *handle_out);
138 int LNetMDBind(lnet_md_t md_in,
139 lnet_unlink_t unlink_in,
140 lnet_handle_md_t *handle_out);
142 int LNetMDUnlink(lnet_handle_md_t md_in);
145 /** \defgroup lnet_eq Events and event queues
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.
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.
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
167 int LNetEQAlloc(unsigned int count_in,
168 lnet_eq_handler_t handler,
169 lnet_handle_eq_t *handle_out);
171 int LNetEQFree(lnet_handle_eq_t eventq_in);
173 int LNetEQGet(lnet_handle_eq_t eventq_in,
174 lnet_event_t *event_out);
177 int LNetEQWait(lnet_handle_eq_t eventq_in,
178 lnet_event_t *event_out);
180 int LNetEQPoll(lnet_handle_eq_t *eventqs_in,
183 lnet_event_t *event_out,
187 /** \defgroup lnet_data Data movement operations
189 * The LNet API provides two data movement operations: LNetPut()
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,
198 unsigned int offset_in,
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,
206 unsigned int offset_in);
210 /** \defgroup lnet_misc Miscellaneous operations.
211 * Miscellaneous operations.
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);
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 */
224 void lnet_server_mode();