Whamcloud - gitweb
land b_eq on HEAD
[fs/lustre-release.git] / lnet / include / lnet / types.h
1 #ifndef _P30_TYPES_H_
2 #define _P30_TYPES_H_
3
4 #ifdef __linux__
5 # include <asm/types.h>
6 # include <asm/timex.h>
7 #else
8 # include <sys/types.h>
9 typedef u_int32_t __u32;
10 typedef u_int64_t __u64;
11 #endif
12
13 #ifdef __KERNEL__
14 # include <linux/time.h>
15 #else
16 # include <sys/time.h>
17 # define do_gettimeofday(tv) gettimeofday(tv, NULL)
18 #endif
19
20 #include <portals/errno.h>
21
22 typedef __u64 ptl_nid_t;
23 typedef __u32 ptl_pid_t;
24 typedef __u32 ptl_pt_index_t;
25 typedef __u32 ptl_ac_index_t;
26 typedef __u64 ptl_match_bits_t;
27 typedef __u64 ptl_hdr_data_t;
28 typedef __u32 ptl_size_t;
29
30 typedef struct {
31         unsigned long nal_idx;                  /* which network interface */
32         __u64         cookie;                   /* which thing on that interface */
33 } ptl_handle_any_t;
34
35 typedef ptl_handle_any_t ptl_handle_ni_t;
36 typedef ptl_handle_any_t ptl_handle_eq_t;
37 typedef ptl_handle_any_t ptl_handle_md_t;
38 typedef ptl_handle_any_t ptl_handle_me_t;
39
40 #define PTL_HANDLE_NONE \
41     ((const ptl_handle_any_t){.nal_idx = -1, .cookie = -1})
42 #define PTL_EQ_NONE PTL_HANDLE_NONE
43
44 static inline int PtlHandleEqual (ptl_handle_any_t h1, ptl_handle_any_t h2)
45 {
46         return (h1.nal_idx == h2.nal_idx && h1.cookie == h2.cookie);
47 }
48
49 #define PTL_NID_ANY      ((ptl_nid_t) -1)
50 #define PTL_PID_ANY      ((ptl_pid_t) -1)
51
52 typedef struct {
53         ptl_nid_t nid;
54         ptl_pid_t pid;   /* node id / process id */
55 } ptl_process_id_t;
56
57 typedef enum {
58         PTL_RETAIN = 0,
59         PTL_UNLINK
60 } ptl_unlink_t;
61
62 typedef enum {
63         PTL_INS_BEFORE,
64         PTL_INS_AFTER
65 } ptl_ins_pos_t;
66
67 typedef struct {
68         struct page     *kiov_page;
69         unsigned int     kiov_len;
70         unsigned int     kiov_offset;
71 } ptl_kiov_t;
72
73 typedef struct {
74         void            *start;
75         ptl_size_t       length;
76         int              threshold;
77         int              max_size;
78         unsigned int     options;
79         void            *user_ptr;
80         ptl_handle_eq_t  eventq;
81         unsigned int     niov;
82 } ptl_md_t;
83
84 /* Options for the MD structure */
85 #define PTL_MD_OP_PUT           (1 << 0)
86 #define PTL_MD_OP_GET           (1 << 1)
87 #define PTL_MD_MANAGE_REMOTE    (1 << 2)
88 #define PTL_MD_AUTO_UNLINK      (1 << 3)
89 #define PTL_MD_TRUNCATE         (1 << 4)
90 #define PTL_MD_ACK_DISABLE      (1 << 5)
91 #define PTL_MD_IOV              (1 << 6)
92 #define PTL_MD_MAX_SIZE         (1 << 7)
93 #define PTL_MD_KIOV             (1 << 8)
94
95 #define PTL_MD_THRESH_INF       (-1)
96
97 typedef enum {
98         PTL_EVENT_GET,
99         PTL_EVENT_PUT,
100         PTL_EVENT_REPLY,
101         PTL_EVENT_ACK,
102         PTL_EVENT_SENT,
103         PTL_EVENT_UNLINK,
104 } ptl_event_kind_t;
105
106 #define PTL_SEQ_BASETYPE        long
107 typedef unsigned PTL_SEQ_BASETYPE ptl_seq_t;
108 #define PTL_SEQ_GT(a,b) (((signed PTL_SEQ_BASETYPE)((a) - (b))) > 0)
109
110 /* XXX
111  * cygwin need the pragma line, not clear if it's needed in other places.
112  * checking!!!
113  */
114 #ifdef __CYGWIN__
115 #pragma pack(push, 4)
116 #endif
117 typedef struct {
118         ptl_event_kind_t   type;
119         ptl_err_t          status;
120         int                unlinked;
121         ptl_process_id_t   initiator;
122         ptl_pt_index_t     portal;
123         ptl_match_bits_t   match_bits;
124         ptl_size_t         rlength;
125         ptl_size_t         mlength;
126         ptl_size_t         offset;
127         ptl_md_t           mem_desc;
128         ptl_hdr_data_t     hdr_data;
129         struct timeval     arrival_time;
130
131         volatile ptl_seq_t sequence;
132 } ptl_event_t;
133 #ifdef __CYGWIN__
134 #pragma pop
135 #endif
136
137 typedef enum {
138         PTL_ACK_REQ,
139         PTL_NOACK_REQ
140 } ptl_ack_req_t;
141
142 typedef struct {
143         volatile ptl_seq_t sequence;
144         ptl_size_t size;
145         ptl_event_t *base;
146         ptl_handle_any_t cb_eq_handle;
147 } ptl_eq_t;
148
149 typedef struct {
150         ptl_eq_t *eq;
151 } ptl_ni_t;
152
153 typedef struct {
154         int max_match_entries;    /* max number of match entries */
155         int max_mem_descriptors;  /* max number of memory descriptors */
156         int max_event_queues;     /* max number of event queues */
157         int max_atable_index;     /* maximum access control list table index */
158         int max_ptable_index;     /* maximum portals table index */
159 } ptl_ni_limits_t;
160
161 /*
162  * Status registers
163  */
164 typedef enum {
165         PTL_SR_DROP_COUNT,
166         PTL_SR_DROP_LENGTH,
167         PTL_SR_RECV_COUNT,
168         PTL_SR_RECV_LENGTH,
169         PTL_SR_SEND_COUNT,
170         PTL_SR_SEND_LENGTH,
171         PTL_SR_MSGS_MAX,
172 } ptl_sr_index_t;
173
174 typedef int ptl_sr_value_t;
175
176 #endif