Whamcloud - gitweb
Mass conversion of all copyright messages to Oracle.
[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 (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_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_WIRE_HANDLE_COOKIE_NONE   (-1)
69
70 static inline void LNetInvalidateHandle(lnet_handle_any_t *h)
71 {
72         h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE;
73 }
74
75 static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2)
76 {
77         return (h1.cookie == h2.cookie);
78 }
79
80 static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
81 {
82         return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie);
83 }
84
85 typedef struct {
86         lnet_nid_t nid;
87         lnet_pid_t pid;   /* node id / process id */
88 } lnet_process_id_t;
89
90 typedef enum {
91         LNET_RETAIN = 0,
92         LNET_UNLINK
93 } lnet_unlink_t;
94
95 typedef enum {
96         LNET_INS_BEFORE,
97         LNET_INS_AFTER
98 } lnet_ins_pos_t;
99
100 typedef struct {
101         void            *start;
102         unsigned int     length;
103         int              threshold;
104         int              max_size;
105         unsigned int     options;
106         void            *user_ptr;
107         lnet_handle_eq_t eq_handle;
108 } lnet_md_t;
109
110 /* Max Transfer Unit (minimum supported everywhere) */
111 #define LNET_MTU_BITS   20
112 #define LNET_MTU        (1<<LNET_MTU_BITS)
113
114 /* limit on the number of entries in discontiguous MDs */
115 #define LNET_MAX_IOV    256
116
117 /* Max payload size */
118 #ifndef LNET_MAX_PAYLOAD
119 # error "LNET_MAX_PAYLOAD must be defined in config.h"
120 #else
121 # if (LNET_MAX_PAYLOAD < LNET_MTU)
122 #  error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
123 # elif defined(__KERNEL__)
124 #  if (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
125 /*  PAGE_SIZE is a constant: check with cpp! */
126 #   error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
127 #  endif
128 # endif
129 #endif
130
131 /* Options for the MD structure */
132 #define LNET_MD_OP_PUT               (1 << 0)
133 #define LNET_MD_OP_GET               (1 << 1)
134 #define LNET_MD_MANAGE_REMOTE        (1 << 2)
135 /* unused                            (1 << 3) */
136 #define LNET_MD_TRUNCATE             (1 << 4)
137 #define LNET_MD_ACK_DISABLE          (1 << 5)
138 #define LNET_MD_IOVEC                (1 << 6)
139 #define LNET_MD_MAX_SIZE             (1 << 7)
140 #define LNET_MD_KIOV                 (1 << 8)
141
142 /* For compatibility with Cray Portals */
143 #define LNET_MD_PHYS                         0
144
145 #define LNET_MD_THRESH_INF       (-1)
146
147 /* NB lustre portals uses struct iovec internally! */
148 typedef struct iovec lnet_md_iovec_t;
149
150 typedef struct {
151         cfs_page_t      *kiov_page;
152         unsigned int     kiov_len;
153         unsigned int     kiov_offset;
154 } lnet_kiov_t;
155
156 typedef enum {
157         LNET_EVENT_GET,
158         LNET_EVENT_PUT,
159         LNET_EVENT_REPLY,
160         LNET_EVENT_ACK,
161         LNET_EVENT_SEND,
162         LNET_EVENT_UNLINK,
163 } lnet_event_kind_t;
164
165 #define LNET_SEQ_BASETYPE       long
166 typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
167 #define LNET_SEQ_GT(a,b)        (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
168
169 /* XXX
170  * cygwin need the pragma line, not clear if it's needed in other places.
171  * checking!!!
172  */
173 #ifdef __CYGWIN__
174 #pragma pack(push, 4)
175 #endif
176 typedef struct {
177         lnet_process_id_t   target;
178         lnet_process_id_t   initiator;
179         lnet_nid_t          sender;
180         lnet_event_kind_t   type;
181         unsigned int        pt_index;
182         __u64               match_bits;
183         unsigned int        rlength;
184         unsigned int        mlength;
185         lnet_handle_md_t    md_handle;
186         lnet_md_t           md;
187         __u64               hdr_data;
188         int                 status;
189         int                 unlinked;
190         unsigned int        offset;
191 #ifdef CRAY_XT3
192         lnet_uid_t          uid;
193 #endif
194
195         volatile lnet_seq_t sequence;
196 } lnet_event_t;
197 #ifdef __CYGWIN__
198 #pragma pop
199 #endif
200
201 typedef enum {
202         LNET_ACK_REQ,
203         LNET_NOACK_REQ
204 } lnet_ack_req_t;
205
206 typedef void (*lnet_eq_handler_t)(lnet_event_t *event);
207 #define LNET_EQ_HANDLER_NONE NULL
208
209 #endif