1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * Types used by the library side routines that do not need to be
7 * exposed to the user application
13 #include "build_check.h"
15 #include <portals/types.h>
17 # include <linux/uio.h>
18 # include <linux/smp_lock.h>
19 # include <linux/types.h>
21 # define PTL_USE_LIB_FREELIST
22 # include <sys/types.h>
25 /* struct nal_cb_t is defined in lib-nal.h */
26 typedef struct nal_cb_t nal_cb_t;
28 typedef char *user_ptr;
29 typedef struct lib_msg_t lib_msg_t;
30 typedef struct lib_ptl_t lib_ptl_t;
31 typedef struct lib_ac_t lib_ac_t;
32 typedef struct lib_me_t lib_me_t;
33 typedef struct lib_md_t lib_md_t;
34 typedef struct lib_eq_t lib_eq_t;
36 #define WIRE_ATTR __attribute__((packed))
38 /* The wire handle's interface cookie only matches one network interface in
39 * one epoch (i.e. new cookie when the interface restarts or the node
40 * reboots). The object cookie only matches one object on that interface
41 * during that object's lifetime (i.e. no cookie re-use). */
43 __u64 wh_interface_cookie;
44 __u64 wh_object_cookie;
45 } WIRE_ATTR ptl_handle_wire_t;
47 /* byte-flip insensitive! */
48 #define PTL_WIRE_HANDLE_NONE \
49 ((const ptl_handle_wire_t) {.wh_interface_cookie = -1, .wh_object_cookie = -1})
59 /* The variant fields of the portals message header are aligned on an 8
60 * byte boundary in the message header. Note that all types used in these
61 * wire structs MUST be fixed size and the smaller types are placed at the
63 typedef struct ptl_ack {
64 ptl_handle_wire_t dst_wmd;
65 ptl_match_bits_t match_bits;
67 } WIRE_ATTR ptl_ack_t;
69 typedef struct ptl_put {
70 ptl_handle_wire_t ack_wmd;
71 ptl_match_bits_t match_bits;
72 ptl_hdr_data_t hdr_data;
73 ptl_pt_index_t ptl_index;
75 } WIRE_ATTR ptl_put_t;
77 typedef struct ptl_get {
78 ptl_handle_wire_t return_wmd;
79 ptl_match_bits_t match_bits;
80 ptl_pt_index_t ptl_index;
81 ptl_size_t src_offset;
82 ptl_size_t sink_length;
83 } WIRE_ATTR ptl_get_t;
85 typedef struct ptl_reply {
86 ptl_handle_wire_t dst_wmd;
87 } WIRE_ATTR ptl_reply_t;
89 typedef struct ptl_hello {
92 } WIRE_ATTR ptl_hello_t;
99 __u32 type; /* ptl_msg_type_t */
100 __u32 payload_length; /* payload data to follow */
101 /*<------__u64 aligned------->*/
109 } WIRE_ATTR ptl_hdr_t;
111 /* A HELLO message contains the portals magic number and protocol version
112 * code in the header's dest_nid, the peer's NID in the src_nid, and
113 * PTL_MSG_HELLO in the type field. All other common fields are zero
114 * (including payload_size; i.e. no payload).
115 * This is for use by byte-stream NALs (e.g. TCP/IP) to check the peer is
116 * running the same protocol and to find out its NID, so that hosts with
117 * multiple IP interfaces can have a single NID. These NALs should exchange
118 * HELLO messages when a connection is first established.
119 * Individual NALs can put whatever else they fancy in ptl_hdr_t::msg.
122 __u32 magic; /* PORTALS_PROTO_MAGIC */
123 __u16 version_major; /* increment on incompatible change */
124 __u16 version_minor; /* increment on compatible change */
125 } WIRE_ATTR ptl_magicversion_t;
127 #define PORTALS_PROTO_MAGIC 0xeebc0ded
129 #define PORTALS_PROTO_VERSION_MAJOR 0
130 #define PORTALS_PROTO_VERSION_MINOR 3
133 long recv_count, recv_length, send_count, send_length, drop_count,
134 drop_length, msgs_alloc, msgs_max;
137 /* temporary expedient: limit number of entries in discontiguous MDs */
138 #define PTL_MTU (512<<10)
139 #define PTL_MD_MAX_IOV 128
142 struct list_head msg_list;
144 ptl_handle_wire_t ack_wmd;
150 struct list_head *tbl;
158 struct list_head lh_hash_chain;
162 #define lh_entry(ptr, type, member) \
163 ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
166 struct list_head eq_list;
172 int (*event_callback) (ptl_event_t * event);
177 struct list_head me_list;
179 ptl_process_id_t match_id;
180 ptl_match_bits_t match_bits, ignore_bits;
186 struct list_head md_list;
195 unsigned int options;
196 unsigned int md_flags;
200 unsigned int md_niov; /* # frags */
202 struct iovec iov[PTL_MD_MAX_IOV];
203 ptl_kiov_t kiov[PTL_MD_MAX_IOV];
207 #define PTL_MD_FLAG_ZOMBIE (1 << 0)
208 #define PTL_MD_FLAG_AUTO_UNLINK (1 << 1)
210 static inline int lib_md_exhausted (lib_md_t *md)
212 return (md->threshold == 0 ||
213 ((md->options & PTL_MD_MAX_SIZE) != 0 &&
214 md->offset + md->max_size > md->length));
217 #ifdef PTL_USE_LIB_FREELIST
220 void *fl_objs; /* single contiguous array of objects */
221 int fl_nobjs; /* the number of them */
222 int fl_objsize; /* the size (including overhead) of each of them */
223 struct list_head fl_list; /* where they are enqueued */
228 struct list_head fo_list; /* enqueue on fl_list */
229 void *fo_contents; /* aligned contents */
234 /* info about peers we are trying to fail */
235 struct list_head tp_list; /* stash in ni.ni_test_peers */
236 ptl_nid_t tp_nid; /* matching nid */
237 unsigned int tp_threshold; /* # failures to simulate */
240 #define PTL_COOKIE_TYPE_MD 1
241 #define PTL_COOKIE_TYPE_ME 2
242 #define PTL_COOKIE_TYPE_EQ 3
243 #define PTL_COOKIE_TYPES 4
244 /* PTL_COOKIE_TYPES must be a power of 2, so the cookie type can be
245 * extracted by masking with (PTL_COOKIE_TYPES - 1) */
256 lib_counters_t counters;
258 int ni_lh_hash_size; /* size of lib handle hash table */
259 struct list_head *ni_lh_hash_table; /* all extant lib handles, this interface */
260 __u64 ni_next_object_cookie; /* cookie generator */
261 __u64 ni_interface_cookie; /* uniquely identifies this ni in this epoch */
263 struct list_head ni_test_peers;
265 #ifdef PTL_USE_LIB_FREELIST
266 lib_freelist_t ni_free_mes;
267 lib_freelist_t ni_free_msgs;
268 lib_freelist_t ni_free_mds;
269 lib_freelist_t ni_free_eqs;
271 struct list_head ni_active_msgs;
272 struct list_head ni_active_mds;
273 struct list_head ni_active_eqs;