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