Whamcloud - gitweb
f07534baa286bfee83191352970dbab8c9a32c45
[fs/lustre-release.git] / lnet / include / lnet / types.h
1 #ifndef _P30_TYPES_H_
2 #define _P30_TYPES_H_
3
4 #include "build_check.h"
5
6 #include <libcfs/libcfs.h>
7 #include <portals/errno.h>
8
9 /* This implementation uses the same type for API function return codes and
10  * the completion status in an event  */
11 #define PTL_NI_OK  PTL_OK
12 typedef ptl_err_t ptl_ni_fail_t;
13
14 typedef __u32 ptl_uid_t;
15 typedef __u32 ptl_jid_t;
16 typedef __u64 ptl_nid_t;
17 typedef __u32 ptl_netid_t;
18 typedef __u32 ptl_pid_t;
19 typedef __u32 ptl_pt_index_t;
20 typedef __u32 ptl_ac_index_t;
21 typedef __u64 ptl_match_bits_t;
22 typedef __u64 ptl_hdr_data_t;
23 typedef __u32 ptl_size_t;
24
25 #define PTL_TIME_FOREVER    (-1)
26
27 typedef struct {
28         unsigned long nal_idx;                  /* which network interface */
29         __u64         cookie;                   /* which thing on that interface */
30 } ptl_handle_any_t;
31
32 typedef ptl_handle_any_t ptl_handle_ni_t;
33 typedef ptl_handle_any_t ptl_handle_eq_t;
34 typedef ptl_handle_any_t ptl_handle_md_t;
35 typedef ptl_handle_any_t ptl_handle_me_t;
36
37 #define PTL_INVALID_HANDLE \
38     ((const ptl_handle_any_t){.nal_idx = -1, .cookie = -1})
39 #define PTL_EQ_NONE PTL_INVALID_HANDLE
40
41 static inline int PtlHandleIsEqual (ptl_handle_any_t h1, ptl_handle_any_t h2)
42 {
43         return (h1.nal_idx == h2.nal_idx && h1.cookie == h2.cookie);
44 }
45
46 #define PTL_UID_ANY      ((ptl_uid_t) -1)
47 #define PTL_JID_ANY      ((ptl_jid_t) -1)
48 #define PTL_NID_ANY      ((ptl_nid_t) -1)
49 #define PTL_PID_ANY      ((ptl_pid_t) -1)
50
51 typedef struct {
52         ptl_nid_t nid;
53         ptl_pid_t pid;   /* node id / process id */
54 } ptl_process_id_t;
55
56 typedef enum {
57         PTL_RETAIN = 0,
58         PTL_UNLINK
59 } ptl_unlink_t;
60
61 typedef enum {
62         PTL_INS_BEFORE,
63         PTL_INS_AFTER
64 } ptl_ins_pos_t;
65
66 typedef struct {
67         void            *start;
68         ptl_size_t       length;
69         int              threshold;
70         int              max_size;
71         unsigned int     options;
72         void            *user_ptr;
73         ptl_handle_eq_t  eq_handle;
74 } ptl_md_t;
75
76 /* Options for the MD structure */
77 #define PTL_MD_OP_PUT               (1 << 0)
78 #define PTL_MD_OP_GET               (1 << 1)
79 #define PTL_MD_MANAGE_REMOTE        (1 << 2)
80 /* unused                           (1 << 3) */
81 #define PTL_MD_TRUNCATE             (1 << 4)
82 #define PTL_MD_ACK_DISABLE          (1 << 5)
83 #define PTL_MD_IOVEC                (1 << 6)
84 #define PTL_MD_MAX_SIZE             (1 << 7)
85 #define PTL_MD_KIOV                 (1 << 8)
86 #define PTL_MD_EVENT_START_DISABLE  (1 << 9)
87 #define PTL_MD_EVENT_END_DISABLE    (1 << 10)
88
89 /* For compatibility with Cray Portals */
90 #define PTL_MD_LUSTRE_COMPLETION_SEMANTICS  0
91 #define PTL_MD_PHYS                         0
92
93 #define PTL_MD_THRESH_INF       (-1)
94
95 /* NB lustre portals uses struct iovec internally! */
96 typedef struct iovec ptl_md_iovec_t;
97
98 typedef struct {
99         cfs_page_t      *kiov_page;
100         unsigned int     kiov_len;
101         unsigned int     kiov_offset;
102 } ptl_kiov_t;
103
104 typedef enum {
105         PTL_EVENT_GET_START,
106         PTL_EVENT_GET_END,
107
108         PTL_EVENT_PUT_START,
109         PTL_EVENT_PUT_END,
110
111         PTL_EVENT_REPLY_START,
112         PTL_EVENT_REPLY_END,
113
114         PTL_EVENT_ACK,
115
116         PTL_EVENT_SEND_START,
117         PTL_EVENT_SEND_END,
118
119         PTL_EVENT_UNLINK,
120 } ptl_event_kind_t;
121
122 #define PTL_SEQ_BASETYPE        long
123 typedef unsigned PTL_SEQ_BASETYPE ptl_seq_t;
124 #define PTL_SEQ_GT(a,b) (((signed PTL_SEQ_BASETYPE)((a) - (b))) > 0)
125
126 /* XXX
127  * cygwin need the pragma line, not clear if it's needed in other places.
128  * checking!!!
129  */
130 #ifdef __CYGWIN__
131 #pragma pack(push, 4)
132 #endif
133 typedef struct {
134         ptl_event_kind_t   type;
135         ptl_process_id_t   initiator;
136         ptl_uid_t          uid;
137         ptl_jid_t          jid;
138         ptl_pt_index_t     pt_index;
139         ptl_match_bits_t   match_bits;
140         ptl_size_t         rlength;
141         ptl_size_t         mlength;
142         ptl_size_t         offset;
143         ptl_handle_md_t    md_handle;
144         ptl_md_t           md;
145         ptl_hdr_data_t     hdr_data;
146         ptl_seq_t          link;
147         ptl_ni_fail_t      ni_fail_type;
148
149         int                unlinked;
150
151         volatile ptl_seq_t sequence;
152 } ptl_event_t;
153 #ifdef __CYGWIN__
154 #pragma pop
155 #endif
156
157 typedef enum {
158         PTL_ACK_REQ,
159         PTL_NOACK_REQ
160 } ptl_ack_req_t;
161
162 typedef void (*ptl_eq_handler_t)(ptl_event_t *event);
163 #define PTL_EQ_HANDLER_NONE NULL
164
165 typedef struct {
166         int max_mes;
167         int max_mds;
168         int max_eqs;
169         int max_ac_index;
170         int max_pt_index;
171         int max_md_iovecs;
172         int max_me_list;
173         int max_getput_md;
174 } ptl_ni_limits_t;
175
176 /*
177  * Status registers
178  */
179 typedef enum {
180         PTL_SR_DROP_COUNT,
181         PTL_SR_DROP_LENGTH,
182         PTL_SR_RECV_COUNT,
183         PTL_SR_RECV_LENGTH,
184         PTL_SR_SEND_COUNT,
185         PTL_SR_SEND_LENGTH,
186         PTL_SR_MSGS_MAX,
187 } ptl_sr_index_t;
188
189 typedef int ptl_sr_value_t;
190
191 typedef int ptl_interface_t;
192 #define PTL_IFACE_DEFAULT    (-1)
193
194 #endif