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