Whamcloud - gitweb
smash the HEAD with the contents of b_cmd. HEAD_PRE_CMD_SMASH and
[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 #ifdef __linux__
7 # include <asm/types.h>
8 # if defined(__powerpc__) && !defined(__KERNEL__)
9 #  define __KERNEL__
10 #  include <asm/timex.h>
11 #  undef __KERNEL__
12 # else
13 #  include <asm/timex.h>
14 # endif
15 #else
16 # include <sys/types.h>
17 typedef u_int32_t __u32;
18 typedef u_int64_t __u64;
19 #endif
20
21 #ifdef __KERNEL__
22 # include <linux/time.h>
23 #else
24 # include <sys/time.h>
25 # define do_gettimeofday(tv) gettimeofday(tv, NULL);
26 #endif
27
28 #include <portals/errno.h>
29
30 /* This implementation uses the same type for API function return codes and
31  * the completion status in an event  */
32 #define PTL_NI_OK  PTL_OK
33 typedef ptl_err_t ptl_ni_fail_t;
34
35 typedef __u64 ptl_nid_t;
36 typedef __u32 ptl_pid_t;
37 typedef __u32 ptl_pt_index_t;
38 typedef __u32 ptl_ac_index_t;
39 typedef __u64 ptl_match_bits_t;
40 typedef __u64 ptl_hdr_data_t;
41 typedef __u32 ptl_size_t;
42
43 #define PTL_TIME_FOREVER    (-1)
44 #define PTL_EQ_HANDLER_NONE NULL
45
46 typedef struct {
47         unsigned long nal_idx;                  /* which network interface */
48         __u64         cookie;                   /* which thing on that interface */
49 } ptl_handle_any_t;
50
51 typedef ptl_handle_any_t ptl_handle_ni_t;
52 typedef ptl_handle_any_t ptl_handle_eq_t;
53 typedef ptl_handle_any_t ptl_handle_md_t;
54 typedef ptl_handle_any_t ptl_handle_me_t;
55
56 #define PTL_INVALID_HANDLE \
57     ((const ptl_handle_any_t){.nal_idx = -1, .cookie = -1})
58 #define PTL_EQ_NONE PTL_INVALID_HANDLE
59
60 static inline int PtlHandleIsEqual (ptl_handle_any_t h1, ptl_handle_any_t h2)
61 {
62         return (h1.nal_idx == h2.nal_idx && h1.cookie == h2.cookie);
63 }
64
65 #define PTL_NID_ANY      ((ptl_nid_t) -1)
66 #define PTL_PID_ANY      ((ptl_pid_t) -1)
67
68 typedef struct {
69         ptl_nid_t nid;
70         ptl_pid_t pid;   /* node id / process id */
71 } ptl_process_id_t;
72
73 typedef enum {
74         PTL_RETAIN = 0,
75         PTL_UNLINK
76 } ptl_unlink_t;
77
78 typedef enum {
79         PTL_INS_BEFORE,
80         PTL_INS_AFTER
81 } ptl_ins_pos_t;
82
83 typedef struct {
84         struct page     *kiov_page;
85         unsigned int     kiov_len;
86         unsigned int     kiov_offset;
87 } ptl_kiov_t;
88
89 typedef struct {
90         void            *start;
91         ptl_size_t       length;
92         int              threshold;
93         int              max_size;
94         unsigned int     options;
95         void            *user_ptr;
96         ptl_handle_eq_t  eventq;
97         unsigned int     niov;
98 } ptl_md_t;
99
100 /* Options for the MD structure */
101 #define PTL_MD_OP_PUT               (1 << 0)
102 #define PTL_MD_OP_GET               (1 << 1)
103 #define PTL_MD_MANAGE_REMOTE        (1 << 2)
104 /* unused                           (1 << 3) */
105 #define PTL_MD_TRUNCATE             (1 << 4)
106 #define PTL_MD_ACK_DISABLE          (1 << 5)
107 #define PTL_MD_IOVEC                (1 << 6)
108 #define PTL_MD_MAX_SIZE             (1 << 7)
109 #define PTL_MD_KIOV                 (1 << 8)
110 #define PTL_MD_EVENT_START_DISABLE  (1 << 9)
111 #define PTL_MD_EVENT_END_DISABLE    (1 << 10)
112
113 /* For compatibility with Cray Portals */
114 #define PTL_MD_LUSTRE_COMPLETION_SEMANTICS  0
115
116 #define PTL_MD_THRESH_INF       (-1)
117
118 typedef enum {
119         PTL_EVENT_GET_START,
120         PTL_EVENT_GET_END,
121
122         PTL_EVENT_PUT_START,
123         PTL_EVENT_PUT_END,
124
125         PTL_EVENT_REPLY_START,
126         PTL_EVENT_REPLY_END,
127
128         PTL_EVENT_ACK,
129
130         PTL_EVENT_SEND_START,
131         PTL_EVENT_SEND_END,
132
133         PTL_EVENT_UNLINK,
134 } ptl_event_kind_t;
135
136 #define PTL_SEQ_BASETYPE        long
137 typedef unsigned PTL_SEQ_BASETYPE ptl_seq_t;
138 #define PTL_SEQ_GT(a,b) (((signed PTL_SEQ_BASETYPE)((a) - (b))) > 0)
139
140 /* XXX
141  * cygwin need the pragma line, not clear if it's needed in other places.
142  * checking!!!
143  */
144 #ifdef __CYGWIN__
145 #pragma pack(push, 4)
146 #endif
147 typedef struct {
148         ptl_event_kind_t   type;
149         ptl_process_id_t   initiator;
150         ptl_pt_index_t     portal;
151         ptl_match_bits_t   match_bits;
152         ptl_size_t         rlength;
153         ptl_size_t         mlength;
154         ptl_size_t         offset;
155         ptl_md_t           mem_desc;
156         ptl_hdr_data_t     hdr_data;
157         int                unlinked;
158         ptl_ni_fail_t      ni_fail_type;
159
160         volatile ptl_seq_t sequence;
161 } ptl_event_t;
162 #ifdef __CYGWIN__
163 #pragma pop
164 #endif
165
166 typedef enum {
167         PTL_ACK_REQ,
168         PTL_NOACK_REQ
169 } ptl_ack_req_t;
170
171 typedef struct {
172         volatile ptl_seq_t sequence;
173         ptl_size_t size;
174         ptl_event_t *base;
175         ptl_handle_any_t cb_eq_handle;
176 } ptl_eq_t;
177
178 typedef struct {
179         ptl_eq_t *eq;
180 } ptl_ni_t;
181
182 typedef struct {
183         int max_match_entries;    /* max number of match entries */
184         int max_mem_descriptors;  /* max number of memory descriptors */
185         int max_event_queues;     /* max number of event queues */
186         int max_atable_index;     /* maximum access control list table index */
187         int max_ptable_index;     /* maximum portals table index */
188 } ptl_ni_limits_t;
189
190 /*
191  * Status registers
192  */
193 typedef enum {
194         PTL_SR_DROP_COUNT,
195         PTL_SR_DROP_LENGTH,
196         PTL_SR_RECV_COUNT,
197         PTL_SR_RECV_LENGTH,
198         PTL_SR_SEND_COUNT,
199         PTL_SR_SEND_LENGTH,
200         PTL_SR_MSGS_MAX,
201 } ptl_sr_index_t;
202
203 typedef int ptl_sr_value_t;
204
205 #endif