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