Whamcloud - gitweb
b=16098
[fs/lustre-release.git] / lnet / include / lnet / types.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  2008 Sun Microsystems, Inc. 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_TYPES_H__
38 #define __LNET_TYPES_H__
39
40 #include <libcfs/libcfs.h>
41
42 #define LNET_RESERVED_PORTAL      0  /* portals reserved for lnet's own use */
43
44 typedef __u64 lnet_nid_t;
45 typedef __u32 lnet_pid_t;
46
47 #define LNET_NID_ANY      ((lnet_nid_t) -1)
48 #define LNET_PID_ANY      ((lnet_pid_t) -1)
49
50 #ifdef CRAY_XT3
51 typedef __u32 lnet_uid_t;
52 #define LNET_UID_ANY      ((lnet_uid_t) -1)
53 #endif
54
55 #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
56 #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
57
58 #define LNET_TIME_FOREVER    (-1)
59
60 typedef struct {
61         __u64         cookie;
62 } lnet_handle_any_t;
63
64 typedef lnet_handle_any_t lnet_handle_eq_t;
65 typedef lnet_handle_any_t lnet_handle_md_t;
66 typedef lnet_handle_any_t lnet_handle_me_t;
67
68 #define LNET_INVALID_HANDLE \
69     ((const lnet_handle_any_t){.cookie = -1})
70 #define LNET_EQ_NONE LNET_INVALID_HANDLE
71
72 static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2)
73 {
74         return (h1.cookie == h2.cookie);
75 }
76
77 typedef struct {
78         lnet_nid_t nid;
79         lnet_pid_t pid;   /* node id / process id */
80 } lnet_process_id_t;
81
82 typedef enum {
83         LNET_RETAIN = 0,
84         LNET_UNLINK
85 } lnet_unlink_t;
86
87 typedef enum {
88         LNET_INS_BEFORE,
89         LNET_INS_AFTER
90 } lnet_ins_pos_t;
91
92 typedef struct {
93         void            *start;
94         unsigned int     length;
95         int              threshold;
96         int              max_size;
97         unsigned int     options;
98         void            *user_ptr;
99         lnet_handle_eq_t eq_handle;
100 } lnet_md_t;
101
102 /* Max Transfer Unit (minimum supported everywhere) */
103 #define LNET_MTU_BITS   20
104 #define LNET_MTU        (1<<LNET_MTU_BITS)
105
106 /* limit on the number of entries in discontiguous MDs */
107 #define LNET_MAX_IOV    256
108
109 /* Max payload size */
110 #ifndef LNET_MAX_PAYLOAD
111 # error "LNET_MAX_PAYLOAD must be defined in config.h"
112 #else
113 # if (LNET_MAX_PAYLOAD < LNET_MTU)
114 #  error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
115 # elif defined(__KERNEL__)
116 #  if (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
117 /*  PAGE_SIZE is a constant: check with cpp! */
118 #   error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
119 #  endif
120 # endif
121 #endif
122
123 /* Options for the MD structure */
124 #define LNET_MD_OP_PUT               (1 << 0)
125 #define LNET_MD_OP_GET               (1 << 1)
126 #define LNET_MD_MANAGE_REMOTE        (1 << 2)
127 /* unused                            (1 << 3) */
128 #define LNET_MD_TRUNCATE             (1 << 4)
129 #define LNET_MD_ACK_DISABLE          (1 << 5)
130 #define LNET_MD_IOVEC                (1 << 6)
131 #define LNET_MD_MAX_SIZE             (1 << 7)
132 #define LNET_MD_KIOV                 (1 << 8)
133
134 /* For compatibility with Cray Portals */
135 #define LNET_MD_PHYS                         0
136
137 #define LNET_MD_THRESH_INF       (-1)
138
139 /* NB lustre portals uses struct iovec internally! */
140 typedef struct iovec lnet_md_iovec_t;
141
142 typedef struct {
143         cfs_page_t      *kiov_page;
144         unsigned int     kiov_len;
145         unsigned int     kiov_offset;
146 } lnet_kiov_t;
147
148 typedef enum {
149         LNET_EVENT_GET,
150         LNET_EVENT_PUT,
151         LNET_EVENT_REPLY,
152         LNET_EVENT_ACK,
153         LNET_EVENT_SEND,
154         LNET_EVENT_UNLINK,
155 } lnet_event_kind_t;
156
157 #define LNET_SEQ_BASETYPE       long
158 typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
159 #define LNET_SEQ_GT(a,b)        (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
160
161 /* XXX
162  * cygwin need the pragma line, not clear if it's needed in other places.
163  * checking!!!
164  */
165 #ifdef __CYGWIN__
166 #pragma pack(push, 4)
167 #endif
168 typedef struct {
169         lnet_process_id_t   target;
170         lnet_process_id_t   initiator;
171         lnet_nid_t          sender;
172         lnet_event_kind_t   type;
173         unsigned int        pt_index;
174         __u64               match_bits;
175         unsigned int        rlength;
176         unsigned int        mlength;
177         lnet_handle_md_t    md_handle;
178         lnet_md_t           md;
179         __u64               hdr_data;
180         int                 status;
181         int                 unlinked;
182         unsigned int        offset;
183 #ifdef CRAY_XT3
184         lnet_uid_t          uid;
185 #endif
186
187         volatile lnet_seq_t sequence;
188 } lnet_event_t;
189 #ifdef __CYGWIN__
190 #pragma pop
191 #endif
192
193 typedef enum {
194         LNET_ACK_REQ,
195         LNET_NOACK_REQ
196 } lnet_ack_req_t;
197
198 typedef void (*lnet_eq_handler_t)(lnet_event_t *event);
199 #define LNET_EQ_HANDLER_NONE NULL
200
201 #endif