ucx1-sys 0.1.0

Rust FFI bindings to UCX.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2019.  ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/

#ifndef UCT_TL_H_
#define UCT_TL_H_

#if !defined(UCT_H_)
#  error "You should not include this header directly. Include uct.h instead."
#endif

#include "uct_def.h"

#include <ucs/type/status.h>
#include <ucs/datastruct/callbackq.h>
#include <ucs/config/types.h>
#include <sys/types.h>
#include <stddef.h>

BEGIN_C_DECLS

/** @file tl.h */

/* endpoint - put */

typedef ucs_status_t (*uct_ep_put_short_func_t)(uct_ep_h ep,
                                                const void *buffer,
                                                unsigned length,
                                                uint64_t remote_addr,
                                                uct_rkey_t rkey);

typedef ssize_t      (*uct_ep_put_bcopy_func_t)(uct_ep_h ep,
                                                uct_pack_callback_t pack_cb,
                                                void *arg,
                                                uint64_t remote_addr,
                                                uct_rkey_t rkey);

typedef ucs_status_t (*uct_ep_put_zcopy_func_t)(uct_ep_h ep,
                                                const uct_iov_t *iov,
                                                size_t iovcnt,
                                                uint64_t remote_addr,
                                                uct_rkey_t rkey,
                                                uct_completion_t *comp);

/* endpoint - get */

typedef ucs_status_t (*uct_ep_get_short_func_t)(uct_ep_h ep,
                                                void *buffer,
                                                unsigned length,
                                                uint64_t remote_addr,
                                                uct_rkey_t rkey);

typedef ucs_status_t (*uct_ep_get_bcopy_func_t)(uct_ep_h ep,
                                                uct_unpack_callback_t unpack_cb,
                                                void *arg,
                                                size_t length,
                                                uint64_t remote_addr,
                                                uct_rkey_t rkey,
                                                uct_completion_t *comp);

typedef ucs_status_t (*uct_ep_get_zcopy_func_t)(uct_ep_h ep,
                                                const uct_iov_t *iov,
                                                size_t iovcnt,
                                                uint64_t remote_addr,
                                                uct_rkey_t rkey,
                                                uct_completion_t *comp);

/* endpoint - active message */

typedef ucs_status_t (*uct_ep_am_short_func_t)(uct_ep_h ep,
                                               uint8_t id,
                                               uint64_t header,
                                               const void *payload,
                                               unsigned length);

typedef ucs_status_t (*uct_ep_am_short_iov_func_t)(uct_ep_h ep, uint8_t id,
                                                   const uct_iov_t *iov,
                                                   size_t iovcnt);

typedef ssize_t      (*uct_ep_am_bcopy_func_t)(uct_ep_h ep,
                                               uint8_t id,
                                               uct_pack_callback_t pack_cb,
                                               void *arg,
                                               unsigned flags);

typedef ucs_status_t (*uct_ep_am_zcopy_func_t)(uct_ep_h ep,
                                               uint8_t id,
                                               const void *header,
                                               unsigned header_length,
                                               const uct_iov_t *iov,
                                               size_t iovcnt,
                                               unsigned flags,
                                               uct_completion_t *comp);

/* endpoint - atomics */

typedef ucs_status_t (*uct_ep_atomic_cswap64_func_t)(uct_ep_h ep,
                                                     uint64_t compare,
                                                     uint64_t swap,
                                                     uint64_t remote_addr,
                                                     uct_rkey_t rkey,
                                                     uint64_t *result,
                                                     uct_completion_t *comp);

typedef ucs_status_t (*uct_ep_atomic_cswap32_func_t)(uct_ep_h ep,
                                                     uint32_t compare,
                                                     uint32_t swap,
                                                     uint64_t remote_addr,
                                                     uct_rkey_t rkey,
                                                     uint32_t *result,
                                                     uct_completion_t *comp);

typedef ucs_status_t (*uct_ep_atomic32_post_func_t)(uct_ep_h ep,
                                                    unsigned opcode,
                                                    uint32_t value,
                                                    uint64_t remote_addr,
                                                    uct_rkey_t rkey);

typedef ucs_status_t (*uct_ep_atomic64_post_func_t)(uct_ep_h ep,
                                                    unsigned opcode,
                                                    uint64_t value,
                                                    uint64_t remote_addr,
                                                    uct_rkey_t rkey);

typedef ucs_status_t (*uct_ep_atomic32_fetch_func_t)(uct_ep_h ep,
                                                     unsigned opcode,
                                                     uint32_t value,
                                                     uint32_t *result,
                                                     uint64_t remote_addr,
                                                     uct_rkey_t rkey,
                                                     uct_completion_t *comp);

typedef ucs_status_t (*uct_ep_atomic64_fetch_func_t)(uct_ep_h ep,
                                                     unsigned opcode,
                                                     uint64_t value,
                                                     uint64_t *result,
                                                     uint64_t remote_addr,
                                                     uct_rkey_t rkey,
                                                     uct_completion_t *comp);

/* endpoint - tagged operations */

typedef ucs_status_t (*uct_ep_tag_eager_short_func_t)(uct_ep_h ep,
                                                      uct_tag_t tag,
                                                      const void *data,
                                                      size_t length);

typedef ssize_t      (*uct_ep_tag_eager_bcopy_func_t)(uct_ep_h ep,
                                                      uct_tag_t tag,
                                                      uint64_t imm,
                                                      uct_pack_callback_t pack_cb,
                                                      void *arg,
                                                      unsigned flags);

typedef ucs_status_t (*uct_ep_tag_eager_zcopy_func_t)(uct_ep_h ep,
                                                      uct_tag_t tag,
                                                      uint64_t imm,
                                                      const uct_iov_t *iov,
                                                      size_t iovcnt,
                                                      unsigned flags,
                                                      uct_completion_t *comp);

typedef ucs_status_ptr_t (*uct_ep_tag_rndv_zcopy_func_t)(uct_ep_h ep,
                                                         uct_tag_t tag,
                                                         const void *header,
                                                         unsigned header_length,
                                                         const uct_iov_t *iov,
                                                         size_t iovcnt,
                                                         unsigned flags,
                                                         uct_completion_t *comp);

typedef ucs_status_t (*uct_ep_tag_rndv_cancel_func_t)(uct_ep_h ep, void *op);

typedef ucs_status_t (*uct_ep_tag_rndv_request_func_t)(uct_ep_h ep,
                                                       uct_tag_t tag,
                                                       const void* header,
                                                       unsigned header_length,
                                                       unsigned flags);

/* interface - tagged operations */

typedef ucs_status_t (*uct_iface_tag_recv_zcopy_func_t)(uct_iface_h iface,
                                                        uct_tag_t tag,
                                                        uct_tag_t tag_mask,
                                                        const uct_iov_t *iov,
                                                        size_t iovcnt,
                                                        uct_tag_context_t *ctx);

typedef ucs_status_t (*uct_iface_tag_recv_cancel_func_t)(uct_iface_h iface,
                                                         uct_tag_context_t *ctx,
                                                         int force);

/* endpoint - pending queue */

typedef ucs_status_t (*uct_ep_pending_add_func_t)(uct_ep_h ep,
                                                  uct_pending_req_t *n,
                                                  unsigned flags);

typedef void         (*uct_ep_pending_purge_func_t)(uct_ep_h ep,
                                                    uct_pending_purge_callback_t cb,
                                                    void *arg);

/* endpoint - synchronization */

typedef ucs_status_t (*uct_ep_flush_func_t)(uct_ep_h ep,
                                            unsigned flags,
                                            uct_completion_t *comp);

typedef ucs_status_t (*uct_ep_fence_func_t)(uct_ep_h ep, unsigned flags);

typedef ucs_status_t (*uct_ep_check_func_t)(uct_ep_h ep,
                                            unsigned flags,
                                            uct_completion_t *comp);

/* endpoint - connection establishment */

typedef ucs_status_t (*uct_ep_create_func_t)(const uct_ep_params_t *params,
                                             uct_ep_h *ep_p);

typedef ucs_status_t (*uct_ep_connect_func_t)(
        uct_ep_h ep, const uct_ep_connect_params_t *params);

typedef ucs_status_t (*uct_ep_disconnect_func_t)(uct_ep_h ep, unsigned flags);

typedef ucs_status_t (*uct_cm_ep_conn_notify_func_t)(uct_ep_h ep);

typedef void         (*uct_ep_destroy_func_t)(uct_ep_h ep);

typedef ucs_status_t (*uct_ep_get_address_func_t)(uct_ep_h ep,
                                                  uct_ep_addr_t *addr);

typedef ucs_status_t (*uct_ep_connect_to_ep_func_t)(uct_ep_h ep,
                                                    const uct_device_addr_t *dev_addr,
                                                    const uct_ep_addr_t *ep_addr);

typedef ucs_status_t (*uct_iface_accept_func_t)(uct_iface_h iface,
                                                uct_conn_request_h conn_request);

typedef ucs_status_t (*uct_iface_reject_func_t)(uct_iface_h iface,
                                                uct_conn_request_h conn_request);

/* interface - synchronization */

typedef ucs_status_t (*uct_iface_flush_func_t)(uct_iface_h iface,
                                               unsigned flags,
                                               uct_completion_t *comp);

typedef ucs_status_t (*uct_iface_fence_func_t)(uct_iface_h iface, unsigned flags);

/* interface - progress control */

typedef void         (*uct_iface_progress_enable_func_t)(uct_iface_h iface,
                                                         unsigned flags);

typedef void         (*uct_iface_progress_disable_func_t)(uct_iface_h iface,
                                                          unsigned flags);

typedef unsigned     (*uct_iface_progress_func_t)(uct_iface_h iface);

/* interface - events */

typedef ucs_status_t (*uct_iface_event_fd_get_func_t)(uct_iface_h iface,
                                                      int *fd_p);

typedef ucs_status_t (*uct_iface_event_arm_func_t)(uct_iface_h iface,
                                                   unsigned events);

/* interface - management */

typedef void         (*uct_iface_close_func_t)(uct_iface_h iface);

typedef ucs_status_t (*uct_iface_query_func_t)(uct_iface_h iface,
                                               uct_iface_attr_t *iface_attr);

/* interface - connection establishment */

typedef ucs_status_t (*uct_iface_get_device_address_func_t)(uct_iface_h iface,
                                                            uct_device_addr_t *addr);

typedef ucs_status_t (*uct_iface_get_address_func_t)(uct_iface_h iface,
                                                     uct_iface_addr_t *addr);

typedef int          (*uct_iface_is_reachable_func_t)(const uct_iface_h iface,
                                                      const uct_device_addr_t *dev_addr,
                                                      const uct_iface_addr_t *iface_addr);


/**
 * Transport interface operations.
 * Every operation exposed in the API must appear in the table below, to allow
 * creating interface/endpoint with custom operations.
 */
typedef struct uct_iface_ops {

    /* endpoint - put */
    uct_ep_put_short_func_t             ep_put_short;
    uct_ep_put_bcopy_func_t             ep_put_bcopy;
    uct_ep_put_zcopy_func_t             ep_put_zcopy;

    /* endpoint - get */
    uct_ep_get_short_func_t             ep_get_short;
    uct_ep_get_bcopy_func_t             ep_get_bcopy;
    uct_ep_get_zcopy_func_t             ep_get_zcopy;

    /* endpoint - active message */
    uct_ep_am_short_func_t              ep_am_short;
    uct_ep_am_short_iov_func_t          ep_am_short_iov;
    uct_ep_am_bcopy_func_t              ep_am_bcopy;
    uct_ep_am_zcopy_func_t              ep_am_zcopy;

    /* endpoint - atomics */
    uct_ep_atomic_cswap64_func_t        ep_atomic_cswap64;
    uct_ep_atomic_cswap32_func_t        ep_atomic_cswap32;
    uct_ep_atomic32_post_func_t         ep_atomic32_post;
    uct_ep_atomic64_post_func_t         ep_atomic64_post;
    uct_ep_atomic32_fetch_func_t        ep_atomic32_fetch;
    uct_ep_atomic64_fetch_func_t        ep_atomic64_fetch;

    /* endpoint - tagged operations */
    uct_ep_tag_eager_short_func_t       ep_tag_eager_short;
    uct_ep_tag_eager_bcopy_func_t       ep_tag_eager_bcopy;
    uct_ep_tag_eager_zcopy_func_t       ep_tag_eager_zcopy;
    uct_ep_tag_rndv_zcopy_func_t        ep_tag_rndv_zcopy;
    uct_ep_tag_rndv_cancel_func_t       ep_tag_rndv_cancel;
    uct_ep_tag_rndv_request_func_t      ep_tag_rndv_request;

    /* interface - tagged operations */
    uct_iface_tag_recv_zcopy_func_t     iface_tag_recv_zcopy;
    uct_iface_tag_recv_cancel_func_t    iface_tag_recv_cancel;

    /* endpoint - pending queue */
    uct_ep_pending_add_func_t           ep_pending_add;
    uct_ep_pending_purge_func_t         ep_pending_purge;

    /* endpoint - synchronization */
    uct_ep_flush_func_t                 ep_flush;
    uct_ep_fence_func_t                 ep_fence;
    uct_ep_check_func_t                 ep_check;

    /* endpoint - connection establishment */
    uct_ep_create_func_t                ep_create;
    uct_ep_connect_func_t               ep_connect;
    uct_ep_disconnect_func_t            ep_disconnect;
    uct_cm_ep_conn_notify_func_t        cm_ep_conn_notify;
    uct_ep_destroy_func_t               ep_destroy;
    uct_ep_get_address_func_t           ep_get_address;
    uct_ep_connect_to_ep_func_t         ep_connect_to_ep;
    uct_iface_accept_func_t             iface_accept;
    uct_iface_reject_func_t             iface_reject;

    /* interface - synchronization */
    uct_iface_flush_func_t              iface_flush;
    uct_iface_fence_func_t              iface_fence;

    /* interface - progress control */
    uct_iface_progress_enable_func_t    iface_progress_enable;
    uct_iface_progress_disable_func_t   iface_progress_disable;
    uct_iface_progress_func_t           iface_progress;

    /* interface - events */
    uct_iface_event_fd_get_func_t       iface_event_fd_get;
    uct_iface_event_arm_func_t          iface_event_arm;

    /* interface - management */
    uct_iface_close_func_t              iface_close;
    uct_iface_query_func_t              iface_query;

    /* interface - connection establishment */
    uct_iface_get_device_address_func_t iface_get_device_address;
    uct_iface_get_address_func_t        iface_get_address;
    uct_iface_is_reachable_func_t       iface_is_reachable;

} uct_iface_ops_t;


/**
 *  A progress engine and a domain for allocating communication resources.
 *  Different workers are progressed independently.
 */
typedef struct uct_worker {
    ucs_callbackq_t        progress_q;
} uct_worker_t;


/**
 * Communication interface context
 */
typedef struct uct_iface {
    uct_iface_ops_t          ops;
} uct_iface_t;


/**
 * Remote endpoint
 */
typedef struct uct_ep {
    uct_iface_h              iface;
} uct_ep_t;


/**
 * Listener for incoming connections
 */
typedef struct uct_listener {
    uct_cm_h                 cm;
} uct_listener_t;


typedef struct uct_recv_desc uct_recv_desc_t;
typedef void (*uct_desc_release_callback_t)(uct_recv_desc_t *self, void * desc);


/**
 * Receive descriptor
 */
struct uct_recv_desc {
    uct_desc_release_callback_t cb;
};


#define uct_recv_desc(_desc) \
    ( *( ( (uct_recv_desc_t**)(_desc) ) - 1) )

END_C_DECLS

#endif