Whamcloud - gitweb
merge b_devel into HEAD, which will become 0.7.3
[fs/lustre-release.git] / lustre / portals / include / portals / 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 typedef __u64 ptl_nid_t;
21 typedef __u32 ptl_pid_t;
22 typedef __u32 ptl_pt_index_t;
23 typedef __u32 ptl_ac_index_t;
24 typedef __u64 ptl_match_bits_t;
25 typedef __u64 ptl_hdr_data_t;
26 typedef __u32 ptl_size_t;
27
28 typedef struct {
29         unsigned long nal_idx;                  /* which network interface */
30         __u64         cookie;                   /* which thing on that interface */
31 } ptl_handle_any_t;
32
33 typedef ptl_handle_any_t ptl_handle_ni_t;
34 typedef ptl_handle_any_t ptl_handle_eq_t;
35 typedef ptl_handle_any_t ptl_handle_md_t;
36 typedef ptl_handle_any_t ptl_handle_me_t;
37
38 #define PTL_HANDLE_NONE \
39     ((const ptl_handle_any_t){.nal_idx = -1, .cookie = -1})
40 #define PTL_EQ_NONE PTL_HANDLE_NONE
41
42 static inline int PtlHandleEqual (ptl_handle_any_t h1, ptl_handle_any_t h2)
43 {
44         return (h1.nal_idx == h2.nal_idx && h1.cookie == h2.cookie);
45 }
46
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         struct page     *kiov_page;
67         unsigned int     kiov_len;
68         unsigned int     kiov_offset;
69 } ptl_kiov_t;
70
71 typedef struct {
72         void            *start;
73         ptl_size_t       length;
74         int              threshold;
75         int              max_size;
76         unsigned int     options;
77         void            *user_ptr;
78         ptl_handle_eq_t  eventq;
79         unsigned int     niov;
80 } ptl_md_t;
81
82 /* Options for the MD structure */
83 #define PTL_MD_OP_PUT           (1 << 0)
84 #define PTL_MD_OP_GET           (1 << 1)
85 #define PTL_MD_MANAGE_REMOTE    (1 << 2)
86 #define PTL_MD_AUTO_UNLINK      (1 << 3)
87 #define PTL_MD_TRUNCATE         (1 << 4)
88 #define PTL_MD_ACK_DISABLE      (1 << 5)
89 #define PTL_MD_IOV              (1 << 6)
90 #define PTL_MD_MAX_SIZE         (1 << 7)
91 #define PTL_MD_KIOV             (1 << 8)
92
93 #define PTL_MD_THRESH_INF       (-1)
94
95 typedef enum {
96         PTL_EVENT_GET,
97         PTL_EVENT_PUT,
98         PTL_EVENT_REPLY,
99         PTL_EVENT_ACK,
100         PTL_EVENT_SENT
101 } ptl_event_kind_t;
102
103 #define PTL_SEQ_BASETYPE        long
104 typedef unsigned PTL_SEQ_BASETYPE ptl_seq_t;
105 #define PTL_SEQ_GT(a,b) (((signed PTL_SEQ_BASETYPE)((a) - (b))) > 0)
106
107 typedef struct {
108         ptl_event_kind_t type;
109         ptl_process_id_t initiator;
110         ptl_pt_index_t portal;
111         ptl_match_bits_t match_bits;
112         ptl_size_t rlength, mlength, offset;
113         ptl_handle_me_t unlinked_me;
114         ptl_md_t mem_desc;
115         ptl_hdr_data_t hdr_data;
116         struct timeval arrival_time;
117         volatile ptl_seq_t sequence;
118 } ptl_event_t;
119
120 typedef enum {
121         PTL_ACK_REQ,
122         PTL_NOACK_REQ
123 } ptl_ack_req_t;
124
125 typedef struct {
126         volatile ptl_seq_t sequence;
127         ptl_size_t size;
128         ptl_event_t *base;
129         ptl_handle_any_t cb_eq_handle;
130 } ptl_eq_t;
131
132 typedef struct {
133         ptl_eq_t *eq;
134 } ptl_ni_t;
135
136 typedef struct {
137         int max_match_entries;    /* max number of match entries */
138         int max_mem_descriptors;  /* max number of memory descriptors */
139         int max_event_queues;     /* max number of event queues */
140         int max_atable_index;     /* maximum access control list table index */
141         int max_ptable_index;     /* maximum portals table index */
142 } ptl_ni_limits_t;
143
144 /*
145  * Status registers
146  */
147 typedef enum {
148         PTL_SR_DROP_COUNT,
149         PTL_SR_DROP_LENGTH,
150         PTL_SR_RECV_COUNT,
151         PTL_SR_RECV_LENGTH,
152         PTL_SR_SEND_COUNT,
153         PTL_SR_SEND_LENGTH,
154         PTL_SR_MSGS_MAX,
155 } ptl_sr_index_t;
156
157 typedef int ptl_sr_value_t;
158
159 #endif