Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 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.sun.com/software/products/lustre/docs/GPLv2.pdf |
| 19 | * |
| 20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 21 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 22 | * have any questions. |
| 23 | * |
| 24 | * GPL HEADER END |
| 25 | */ |
| 26 | /* |
| 27 | * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
| 28 | * Use is subject to license terms. |
| 29 | */ |
| 30 | /* |
| 31 | * This file is part of Lustre, http://www.lustre.org/ |
| 32 | * Lustre is a trademark of Sun Microsystems, Inc. |
| 33 | */ |
| 34 | |
| 35 | #ifndef __LNET_API_H__ |
| 36 | #define __LNET_API_H__ |
| 37 | |
| 38 | /** \defgroup lnet LNet |
| 39 | * |
| 40 | * The Lustre Networking subsystem. |
| 41 | * |
| 42 | * LNet is an asynchronous message-passing API, which provides an unreliable |
| 43 | * connectionless service that can't guarantee any order. It supports OFA IB, |
| 44 | * TCP/IP, and Cray Portals, and routes between heterogeneous networks. |
| 45 | * |
| 46 | * LNet can run both in OS kernel space and in userspace as a library. |
| 47 | * @{ |
| 48 | */ |
| 49 | |
Greg Kroah-Hartman | 9fdaf8c | 2014-07-11 20:51:16 -0700 | [diff] [blame] | 50 | #include "../lnet/types.h" |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 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 LNetInit(void); |
| 56 | void LNetFini(void); |
| 57 | |
| 58 | int LNetNIInit(lnet_pid_t requested_pid); |
| 59 | int LNetNIFini(void); |
| 60 | /** @} lnet_init_fini */ |
| 61 | |
| 62 | /** \defgroup lnet_addr LNet addressing and basic types |
| 63 | * |
| 64 | * Addressing scheme and basic data types of LNet. |
| 65 | * |
| 66 | * The LNet API is memory-oriented, so LNet must be able to address not only |
| 67 | * end-points but also memory region within a process address space. |
| 68 | * An ::lnet_nid_t addresses an end-point. An ::lnet_pid_t identifies a process |
| 69 | * in a node. A portal represents an opening in the address space of a |
| 70 | * process. Match bits is criteria to identify a region of memory inside a |
| 71 | * portal, and offset specifies an offset within the memory region. |
| 72 | * |
| 73 | * LNet creates a table of portals for each process during initialization. |
| 74 | * This table has MAX_PORTALS entries and its size can't be dynamically |
| 75 | * changed. A portal stays empty until the owning process starts to add |
| 76 | * memory regions to it. A portal is sometimes called an index because |
| 77 | * it's an entry in the portals table of a process. |
| 78 | * |
| 79 | * \see LNetMEAttach |
| 80 | * @{ */ |
| 81 | int LNetGetId(unsigned int index, lnet_process_id_t *id); |
| 82 | int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, __u32 *order); |
| 83 | void LNetSnprintHandle(char *str, int str_len, lnet_handle_any_t handle); |
| 84 | |
| 85 | /** @} lnet_addr */ |
| 86 | |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 87 | /** \defgroup lnet_me Match entries |
| 88 | * |
| 89 | * A match entry (abbreviated as ME) describes a set of criteria to accept |
| 90 | * incoming requests. |
| 91 | * |
| 92 | * A portal is essentially a match list plus a set of attributes. A match |
| 93 | * list is a chain of MEs. Each ME includes a pointer to a memory descriptor |
| 94 | * and a set of match criteria. The match criteria can be used to reject |
| 95 | * incoming requests based on process ID or the match bits provided in the |
| 96 | * request. MEs can be dynamically inserted into a match list by LNetMEAttach() |
| 97 | * and LNetMEInsert(), and removed from its list by LNetMEUnlink(). |
| 98 | * @{ */ |
| 99 | int LNetMEAttach(unsigned int portal, |
| 100 | lnet_process_id_t match_id_in, |
| 101 | __u64 match_bits_in, |
| 102 | __u64 ignore_bits_in, |
| 103 | lnet_unlink_t unlink_in, |
| 104 | lnet_ins_pos_t pos_in, |
| 105 | lnet_handle_me_t *handle_out); |
| 106 | |
| 107 | int LNetMEInsert(lnet_handle_me_t current_in, |
| 108 | lnet_process_id_t match_id_in, |
| 109 | __u64 match_bits_in, |
| 110 | __u64 ignore_bits_in, |
| 111 | lnet_unlink_t unlink_in, |
| 112 | lnet_ins_pos_t position_in, |
| 113 | lnet_handle_me_t *handle_out); |
| 114 | |
| 115 | int LNetMEUnlink(lnet_handle_me_t current_in); |
| 116 | /** @} lnet_me */ |
| 117 | |
| 118 | /** \defgroup lnet_md Memory descriptors |
| 119 | * |
| 120 | * A memory descriptor contains information about a region of a user's |
| 121 | * memory (either in kernel or user space) and optionally points to an |
| 122 | * event queue where information about the operations performed on the |
| 123 | * memory descriptor are recorded. Memory descriptor is abbreviated as |
| 124 | * MD and can be used interchangeably with the memory region it describes. |
| 125 | * |
| 126 | * The LNet API provides two operations to create MDs: LNetMDAttach() |
| 127 | * and LNetMDBind(); one operation to unlink and release the resources |
| 128 | * associated with a MD: LNetMDUnlink(). |
| 129 | * @{ */ |
| 130 | int LNetMDAttach(lnet_handle_me_t current_in, |
| 131 | lnet_md_t md_in, |
| 132 | lnet_unlink_t unlink_in, |
| 133 | lnet_handle_md_t *handle_out); |
| 134 | |
| 135 | int LNetMDBind(lnet_md_t md_in, |
| 136 | lnet_unlink_t unlink_in, |
| 137 | lnet_handle_md_t *handle_out); |
| 138 | |
| 139 | int LNetMDUnlink(lnet_handle_md_t md_in); |
| 140 | /** @} lnet_md */ |
| 141 | |
| 142 | /** \defgroup lnet_eq Events and event queues |
| 143 | * |
| 144 | * Event queues (abbreviated as EQ) are used to log operations performed on |
| 145 | * local MDs. In particular, they signal the completion of a data transmission |
| 146 | * into or out of a MD. They can also be used to hold acknowledgments for |
| 147 | * completed PUT operations and indicate when a MD has been unlinked. Multiple |
| 148 | * MDs can share a single EQ. An EQ may have an optional event handler |
| 149 | * associated with it. If an event handler exists, it will be run for each |
| 150 | * event that is deposited into the EQ. |
| 151 | * |
| 152 | * In addition to the lnet_handle_eq_t, the LNet API defines two types |
| 153 | * associated with events: The ::lnet_event_kind_t defines the kinds of events |
| 154 | * that can be stored in an EQ. The lnet_event_t defines a structure that |
| 155 | * holds the information about with an event. |
| 156 | * |
| 157 | * There are five functions for dealing with EQs: LNetEQAlloc() is used to |
| 158 | * create an EQ and allocate the resources needed, while LNetEQFree() |
| 159 | * releases these resources and free the EQ. LNetEQGet() retrieves the next |
| 160 | * event from an EQ, and LNetEQWait() can be used to block a process until |
| 161 | * an EQ has at least one event. LNetEQPoll() can be used to test or wait |
| 162 | * on multiple EQs. |
| 163 | * @{ */ |
| 164 | int LNetEQAlloc(unsigned int count_in, |
| 165 | lnet_eq_handler_t handler, |
| 166 | lnet_handle_eq_t *handle_out); |
| 167 | |
| 168 | int LNetEQFree(lnet_handle_eq_t eventq_in); |
| 169 | |
| 170 | int LNetEQGet(lnet_handle_eq_t eventq_in, |
| 171 | lnet_event_t *event_out); |
| 172 | |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 173 | int LNetEQWait(lnet_handle_eq_t eventq_in, |
| 174 | lnet_event_t *event_out); |
| 175 | |
| 176 | int LNetEQPoll(lnet_handle_eq_t *eventqs_in, |
| 177 | int neq_in, |
| 178 | int timeout_ms, |
| 179 | lnet_event_t *event_out, |
| 180 | int *which_eq_out); |
| 181 | /** @} lnet_eq */ |
| 182 | |
| 183 | /** \defgroup lnet_data Data movement operations |
| 184 | * |
| 185 | * The LNet API provides two data movement operations: LNetPut() |
| 186 | * and LNetGet(). |
| 187 | * @{ */ |
| 188 | int LNetPut(lnet_nid_t self, |
| 189 | lnet_handle_md_t md_in, |
| 190 | lnet_ack_req_t ack_req_in, |
| 191 | lnet_process_id_t target_in, |
| 192 | unsigned int portal_in, |
| 193 | __u64 match_bits_in, |
| 194 | unsigned int offset_in, |
| 195 | __u64 hdr_data_in); |
| 196 | |
| 197 | int LNetGet(lnet_nid_t self, |
| 198 | lnet_handle_md_t md_in, |
| 199 | lnet_process_id_t target_in, |
| 200 | unsigned int portal_in, |
| 201 | __u64 match_bits_in, |
| 202 | unsigned int offset_in); |
| 203 | /** @} lnet_data */ |
| 204 | |
Peng Tao | d7e09d0 | 2013-05-02 16:46:55 +0800 | [diff] [blame] | 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 | int LNetSetAsync(lnet_process_id_t id, int nasync); |
| 213 | |
| 214 | /** @} lnet_misc */ |
| 215 | |
| 216 | /** @} lnet */ |
| 217 | #endif |