-
Notifications
You must be signed in to change notification settings - Fork 371
/
fabric.h
817 lines (729 loc) · 18.9 KB
/
fabric.h
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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
/*
* Copyright (c) 2013-2017 Intel Corporation. All rights reserved.
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
* (C) Copyright 2020 Hewlett Packard Enterprise Development LP
* Copyright (c) 2022 DataDirect Networks, Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef FABRIC_H
#define FABRIC_H
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <rdma/fi_errno.h>
#ifdef __GNUC__
#define FI_DEPRECATED_FUNC __attribute__((deprecated))
#define FI_DEPRECATED_FIELD __attribute__((deprecated))
#define FI_FORMAT_PRINTF(string, first) \
__attribute__ ((__format__ (__printf__, (string), (first))))
#elif defined(_MSC_VER)
#define FI_DEPRECATED_FUNC __declspec(deprecated)
#define FI_DEPRECATED_FIELD
#define FI_FORMAT_PRINTF(string, first)
#else
#define FI_DEPRECATED_FUNC
#define FI_DEPRECATED_FIELD
#define FI_FORMAT_PRINTF(string, first)
#endif
#if defined(__GNUC__) && !defined(__clang__)
#define EXTERNALLY_VISIBLE externally_visible
#else
#define EXTERNALLY_VISIBLE
#endif
#if defined(_WIN32)
#include <BaseTsd.h>
#include <windows.h>
typedef SSIZE_T ssize_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef container_of
#define container_of(ptr, type, field) \
((type *) ((char *)ptr - offsetof(type, field)))
#endif
#ifndef count_of
#define count_of(x) \
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#endif
#define FI_MAJOR_VERSION 1
#define FI_MINOR_VERSION 22
#define FI_REVISION_VERSION 0
enum {
FI_PATH_MAX = 256,
FI_NAME_MAX = 64,
FI_VERSION_MAX = 64
};
#define FI_VERSION(major, minor) (((major) << 16) | (minor))
#define FI_MAJOR(version) (version >> 16)
#define FI_MINOR(version) (version & 0xFFFF)
#define FI_VERSION_GE(v1, v2) (v1 >= v2)
#define FI_VERSION_LT(v1, v2) (v1 < v2)
uint32_t fi_version(void);
struct fid;
struct fid_fabric;
struct fid_domain;
struct fid_av;
struct fid_wait;
struct fid_poll;
struct fid_eq;
struct fid_cq;
struct fid_cntr;
struct fid_ep;
struct fid_pep;
struct fid_stx;
struct fid_mr;
struct fid_nic;
typedef struct fid *fid_t;
/*
* Flags
* The 64-bit flag field is used as follows:
* 1-grow up common (usable with multiple operations)
* 59-grow down operation specific (used for single call/class)
* 60 - 63 provider specific
*/
#define FI_MSG (1ULL << 1)
#define FI_RMA (1ULL << 2)
#define FI_TAGGED (1ULL << 3)
#define FI_ATOMIC (1ULL << 4)
#define FI_ATOMICS FI_ATOMIC
#define FI_MULTICAST (1ULL << 5)
#define FI_COLLECTIVE (1ULL << 6)
#define FI_READ (1ULL << 8)
#define FI_WRITE (1ULL << 9)
#define FI_RECV (1ULL << 10)
#define FI_SEND (1ULL << 11)
#define FI_TRANSMIT FI_SEND
#define FI_REMOTE_READ (1ULL << 12)
#define FI_REMOTE_WRITE (1ULL << 13)
#define FI_MULTI_RECV (1ULL << 16)
#define FI_REMOTE_CQ_DATA (1ULL << 17)
#define FI_MORE (1ULL << 18)
#define FI_PEEK (1ULL << 19)
#define FI_TRIGGER (1ULL << 20)
#define FI_FENCE (1ULL << 21)
/* #define FI_PRIORITY (1ULL << 22) */
#define FI_COMPLETION (1ULL << 24)
#define FI_EVENT FI_COMPLETION
#define FI_INJECT (1ULL << 25)
#define FI_INJECT_COMPLETE (1ULL << 26)
#define FI_TRANSMIT_COMPLETE (1ULL << 27)
#define FI_DELIVERY_COMPLETE (1ULL << 28)
#define FI_AFFINITY (1ULL << 29)
#define FI_COMMIT_COMPLETE (1ULL << 30)
#define FI_MATCH_COMPLETE (1ULL << 31)
#define FI_PEER_TRANSFER (1ULL << 36)
#define FI_MR_DMABUF (1ULL << 40)
#define FI_AV_USER_ID (1ULL << 41)
#define FI_PEER (1ULL << 43)
/* #define FI_XPU_TRIGGER (1ULL << 44) */
#define FI_HMEM_HOST_ALLOC (1ULL << 45)
#define FI_HMEM_DEVICE_ONLY (1ULL << 46)
#define FI_HMEM (1ULL << 47)
/* #define FI_VARIABLE_MSG (1ULL << 48) */
#define FI_RMA_PMEM (1ULL << 49)
#define FI_SOURCE_ERR (1ULL << 50)
#define FI_LOCAL_COMM (1ULL << 51)
#define FI_REMOTE_COMM (1ULL << 52)
#define FI_SHARED_AV (1ULL << 53)
#define FI_PROV_ATTR_ONLY (1ULL << 54)
#define FI_NUMERICHOST (1ULL << 55)
#define FI_RMA_EVENT (1ULL << 56)
#define FI_SOURCE (1ULL << 57)
#define FI_NAMED_RX_CTX (1ULL << 58)
#define FI_DIRECTED_RECV (1ULL << 59)
/* Tagged messages, buffered receives, CQ flags */
#define FI_CLAIM (1ULL << 59)
#define FI_DISCARD (1ULL << 58)
#define FI_AUTH_KEY (1ULL << 57)
struct fi_ioc {
void *addr;
size_t count;
};
/*
* Format for transport addresses to insert into address vectors
*/
enum {
FI_FORMAT_UNSPEC, /* void * */
FI_SOCKADDR, /* struct sockaddr */
FI_SOCKADDR_IN, /* struct sockaddr_in */
FI_SOCKADDR_IN6, /* struct sockaddr_in6 */
FI_SOCKADDR_IB, /* struct sockaddr_ib */
/* PSMX provider is deprecated.
* We will keep this value in order to save binary compatibility.
*/
FI_ADDR_PSMX, /* uint64_t */
FI_ADDR_GNI,
FI_ADDR_BGQ,
FI_ADDR_MLX,
FI_ADDR_STR, /* formatted char * */
FI_ADDR_PSMX2, /* uint64_t[2] */
FI_ADDR_IB_UD, /* uint64_t[4] */
FI_ADDR_EFA,
FI_ADDR_PSMX3, /* uint64_t[4] */
FI_ADDR_OPX,
FI_ADDR_CXI,
FI_ADDR_UCX,
};
#define FI_ADDR_UNSPEC ((uint64_t) -1)
#define FI_ADDR_NOTAVAIL ((uint64_t) -1)
#define FI_KEY_NOTAVAIL ((uint64_t) -1)
#define FI_SHARED_CONTEXT SIZE_MAX
#define FI_AV_AUTH_KEY SIZE_MAX
typedef uint64_t fi_addr_t;
enum fi_av_type {
FI_AV_UNSPEC,
FI_AV_MAP,
FI_AV_TABLE
};
/* Named enum for backwards compatibility */
enum fi_mr_mode {
FI_MR_UNSPEC,
FI_MR_BASIC, /* (1 << 0) */
FI_MR_SCALABLE, /* (1 << 1) */
};
#define FI_MR_LOCAL (1 << 2)
#define FI_MR_RAW (1 << 3)
#define FI_MR_VIRT_ADDR (1 << 4)
#define FI_MR_ALLOCATED (1 << 5)
#define FI_MR_PROV_KEY (1 << 6)
#define FI_MR_MMU_NOTIFY (1 << 7)
#define FI_MR_RMA_EVENT (1 << 8)
#define FI_MR_ENDPOINT (1 << 9)
#define FI_MR_HMEM (1 << 10)
#define FI_MR_COLLECTIVE (1 << 11)
enum fi_progress {
FI_PROGRESS_UNSPEC,
FI_PROGRESS_AUTO,
FI_PROGRESS_MANUAL,
FI_PROGRESS_CONTROL_UNIFIED,
};
enum fi_threading {
FI_THREAD_UNSPEC,
FI_THREAD_SAFE,
FI_THREAD_FID,
FI_THREAD_DOMAIN,
FI_THREAD_COMPLETION,
FI_THREAD_ENDPOINT,
};
enum fi_resource_mgmt {
FI_RM_UNSPEC,
FI_RM_DISABLED,
FI_RM_ENABLED
};
#define FI_ORDER_NONE 0ULL
#define FI_ORDER_RAR (1ULL << 0)
#define FI_ORDER_RAW (1ULL << 1)
#define FI_ORDER_RAS (1ULL << 2)
#define FI_ORDER_WAR (1ULL << 3)
#define FI_ORDER_WAW (1ULL << 4)
#define FI_ORDER_WAS (1ULL << 5)
#define FI_ORDER_SAR (1ULL << 6)
#define FI_ORDER_SAW (1ULL << 7)
#define FI_ORDER_SAS (1ULL << 8)
#define FI_ORDER_STRICT 0x1FF
#define FI_ORDER_RMA_RAR (1ULL << 32)
#define FI_ORDER_RMA_RAW (1ULL << 33)
#define FI_ORDER_RMA_WAR (1ULL << 34)
#define FI_ORDER_RMA_WAW (1ULL << 35)
#define FI_ORDER_ATOMIC_RAR (1ULL << 36)
#define FI_ORDER_ATOMIC_RAW (1ULL << 37)
#define FI_ORDER_ATOMIC_WAR (1ULL << 38)
#define FI_ORDER_ATOMIC_WAW (1ULL << 39)
#define FI_ORDER_DATA (1ULL << 16)
enum fi_ep_type {
FI_EP_UNSPEC,
FI_EP_MSG,
FI_EP_DGRAM,
FI_EP_RDM,
/* FI_EP_SOCK_STREAM, */
/* FI_EP_SOCK_DGRAM, */
};
/* Endpoint protocol
* If two providers support the same protocol, then they shall interoperate
* when the protocol capabilities match.
*/
enum {
FI_PROTO_UNSPEC,
FI_PROTO_RDMA_CM_IB_RC,
FI_PROTO_IWARP,
FI_PROTO_IB_UD,
/* PSMX provider is deprecated.
* We will keep this value in order to save binary compatibility.
*/
FI_PROTO_PSMX,
FI_PROTO_UDP,
FI_PROTO_SOCK_TCP,
/* MXM provider is deprecated.
* We will keep this value in order to save binary compatibility.
*/
FI_PROTO_MXM,
FI_PROTO_IWARP_RDM,
FI_PROTO_IB_RDM,
FI_PROTO_GNI,
FI_PROTO_RXM,
FI_PROTO_RXD,
FI_PROTO_MLX,
FI_PROTO_NETWORKDIRECT,
FI_PROTO_PSMX2,
FI_PROTO_SHM,
FI_PROTO_MRAIL,
FI_PROTO_RSTREAM,
FI_PROTO_RDMA_CM_IB_XRC,
FI_PROTO_EFA,
FI_PROTO_PSMX3,
FI_PROTO_RXM_TCP,
FI_PROTO_OPX,
FI_PROTO_CXI,
FI_PROTO_XNET,
FI_PROTO_COLL,
FI_PROTO_UCX,
FI_PROTO_SM2,
FI_PROTO_CXI_RNR,
};
enum {
FI_TC_UNSPEC = 0,
FI_TC_DSCP = 0x100,
FI_TC_LABEL = 0x200,
FI_TC_BEST_EFFORT = FI_TC_LABEL,
FI_TC_LOW_LATENCY,
FI_TC_DEDICATED_ACCESS,
FI_TC_BULK_DATA,
FI_TC_SCAVENGER,
FI_TC_NETWORK_CTRL,
};
static inline uint32_t fi_tc_dscp_set(uint8_t dscp)
{
return ((uint32_t) dscp) | FI_TC_DSCP;
}
static inline uint8_t fi_tc_dscp_get(uint32_t tclass)
{
return tclass & FI_TC_DSCP ? (uint8_t) tclass : 0;
}
/* Mode bits */
#define FI_CONTEXT (1ULL << 59)
#define FI_MSG_PREFIX (1ULL << 58)
#define FI_ASYNC_IOV (1ULL << 57)
#define FI_RX_CQ_DATA (1ULL << 56)
#define FI_LOCAL_MR (1ULL << 55)
/* #define FI_NOTIFY_FLAGS_ONLY (1ULL << 54) */
/* #define FI_RESTRICTED_COMP (1ULL << 53) */
#define FI_CONTEXT2 (1ULL << 52)
#define FI_BUFFERED_RECV (1ULL << 51)
/* #define FI_PEER_TRANSFER (1ULL << 36) */
struct fi_tx_attr {
uint64_t caps;
uint64_t mode;
uint64_t op_flags;
uint64_t msg_order;
uint64_t comp_order;
size_t inject_size;
size_t size;
size_t iov_limit;
size_t rma_iov_limit;
uint32_t tclass;
};
struct fi_rx_attr {
uint64_t caps;
uint64_t mode;
uint64_t op_flags;
uint64_t msg_order;
uint64_t comp_order;
size_t total_buffered_recv;
size_t size;
size_t iov_limit;
};
struct fi_ep_attr {
enum fi_ep_type type;
uint32_t protocol;
uint32_t protocol_version;
size_t max_msg_size;
size_t msg_prefix_size;
size_t max_order_raw_size;
size_t max_order_war_size;
size_t max_order_waw_size;
uint64_t mem_tag_format;
size_t tx_ctx_cnt;
size_t rx_ctx_cnt;
size_t auth_key_size;
uint8_t *auth_key;
};
struct fi_domain_attr {
struct fid_domain *domain;
char *name;
enum fi_threading threading;
enum fi_progress control_progress;
enum fi_progress data_progress;
enum fi_resource_mgmt resource_mgmt;
enum fi_av_type av_type;
int mr_mode;
size_t mr_key_size;
size_t cq_data_size;
size_t cq_cnt;
size_t ep_cnt;
size_t tx_ctx_cnt;
size_t rx_ctx_cnt;
size_t max_ep_tx_ctx;
size_t max_ep_rx_ctx;
size_t max_ep_stx_ctx;
size_t max_ep_srx_ctx;
size_t cntr_cnt;
size_t mr_iov_limit;
uint64_t caps;
uint64_t mode;
uint8_t *auth_key;
size_t auth_key_size;
size_t max_err_data;
size_t mr_cnt;
uint32_t tclass;
size_t max_ep_auth_key;
};
struct fi_fabric_attr {
struct fid_fabric *fabric;
char *name;
char *prov_name;
uint32_t prov_version;
uint32_t api_version;
};
struct fi_info {
struct fi_info *next;
uint64_t caps;
uint64_t mode;
uint32_t addr_format;
size_t src_addrlen;
size_t dest_addrlen;
void *src_addr;
void *dest_addr;
fid_t handle;
struct fi_tx_attr *tx_attr;
struct fi_rx_attr *rx_attr;
struct fi_ep_attr *ep_attr;
struct fi_domain_attr *domain_attr;
struct fi_fabric_attr *fabric_attr;
struct fid_nic *nic;
};
struct fi_device_attr {
char *name;
char *device_id;
char *device_version;
char *vendor_id;
char *driver;
char *firmware;
};
enum fi_bus_type {
FI_BUS_UNSPEC,
FI_BUS_UNKNOWN = FI_BUS_UNSPEC,
FI_BUS_PCI,
};
struct fi_pci_attr {
uint16_t domain_id;
uint8_t bus_id;
uint8_t device_id;
uint8_t function_id;
};
struct fi_bus_attr {
enum fi_bus_type bus_type;
union {
struct fi_pci_attr pci;
} attr;
};
enum fi_link_state {
FI_LINK_UNKNOWN,
FI_LINK_DOWN,
FI_LINK_UP,
};
struct fi_link_attr {
char *address;
size_t mtu;
size_t speed;
enum fi_link_state state;
char *network_type;
};
enum {
FI_CLASS_UNSPEC,
FI_CLASS_FABRIC,
FI_CLASS_DOMAIN,
FI_CLASS_EP,
FI_CLASS_SEP,
FI_CLASS_RX_CTX,
FI_CLASS_SRX_CTX,
FI_CLASS_TX_CTX,
FI_CLASS_STX_CTX,
FI_CLASS_PEP,
FI_CLASS_INTERFACE,
FI_CLASS_AV,
FI_CLASS_MR,
FI_CLASS_EQ,
FI_CLASS_CQ,
FI_CLASS_CNTR,
FI_CLASS_WAIT,
FI_CLASS_POLL,
FI_CLASS_CONNREQ,
FI_CLASS_MC,
FI_CLASS_NIC,
FI_CLASS_AV_SET,
FI_CLASS_MR_CACHE,
FI_CLASS_MEM_MONITOR,
FI_CLASS_PEER_CQ,
FI_CLASS_PEER_SRX,
FI_CLASS_LOG,
FI_CLASS_PEER_AV,
FI_CLASS_PEER_AV_SET,
FI_CLASS_PEER_CNTR,
FI_CLASS_PROFILE,
};
struct fi_eq_attr;
struct fi_wait_attr;
/* fi_bind()-specific flags */
#define FI_SELECTIVE_COMPLETION (1ULL << 59)
struct fi_ops {
size_t size;
int (*close)(struct fid *fid);
int (*bind)(struct fid *fid, struct fid *bfid, uint64_t flags);
int (*control)(struct fid *fid, int command, void *arg);
int (*ops_open)(struct fid *fid, const char *name,
uint64_t flags, void **ops, void *context);
int (*tostr)(const struct fid *fid, char *buf, size_t len);
int (*ops_set)(struct fid *fid, const char *name, uint64_t flags,
void *ops, void *context);
};
/* All fabric interface descriptors must start with this structure */
struct fid {
size_t fclass;
void *context;
struct fi_ops *ops;
};
int fi_getinfo(uint32_t version, const char *node, const char *service,
uint64_t flags, const struct fi_info *hints,
struct fi_info **info);
void fi_freeinfo(struct fi_info *info);
struct fi_info *fi_dupinfo(const struct fi_info *info);
static inline struct fi_info *fi_allocinfo(void)
{
return fi_dupinfo(NULL);
}
struct fi_ops_fabric {
size_t size;
int (*domain)(struct fid_fabric *fabric, struct fi_info *info,
struct fid_domain **dom, void *context);
int (*passive_ep)(struct fid_fabric *fabric, struct fi_info *info,
struct fid_pep **pep, void *context);
int (*eq_open)(struct fid_fabric *fabric, struct fi_eq_attr *attr,
struct fid_eq **eq, void *context);
int (*wait_open)(struct fid_fabric *fabric, struct fi_wait_attr *attr,
struct fid_wait **waitset);
int (*trywait)(struct fid_fabric *fabric, struct fid **fids,
int count);
int (*domain2)(struct fid_fabric *fabric, struct fi_info *info,
struct fid_domain **dom, uint64_t flags, void *context);
};
struct fid_fabric {
struct fid fid;
struct fi_ops_fabric *ops;
uint32_t api_version;
};
int fi_fabric(struct fi_fabric_attr *attr, struct fid_fabric **fabric,
void *context);
int fi_open(uint32_t version, const char *name, void *attr, size_t attr_len,
uint64_t flags, struct fid **fid, void *context);
struct fid_nic {
struct fid fid;
struct fi_device_attr *device_attr;
struct fi_bus_attr *bus_attr;
struct fi_link_attr *link_attr;
void *prov_attr;
};
#define FI_CHECK_OP(ops, opstype, op) \
(ops && (ops->size > offsetof(opstype, op)) && ops->op)
static inline int fi_close(struct fid *fid)
{
return fid->ops->close(fid);
}
struct fi_alias {
struct fid **fid;
uint64_t flags;
};
struct fi_fid_var {
int name;
void *val;
};
struct fi_mr_raw_attr {
uint64_t flags;
uint64_t *base_addr;
uint8_t *raw_key;
size_t *key_size;
};
struct fi_mr_map_raw {
uint64_t flags;
uint64_t base_addr;
uint8_t *raw_key;
size_t key_size;
uint64_t *key;
};
/* control commands */
enum {
FI_GETFIDFLAG, /* uint64_t flags */
FI_SETFIDFLAG, /* uint64_t flags */
FI_GETOPSFLAG, /* uint64_t flags */
FI_SETOPSFLAG, /* uint64_t flags */
FI_ALIAS, /* struct fi_alias * */
FI_GETWAIT, /* void * wait object */
FI_ENABLE, /* NULL */
FI_BACKLOG, /* integer * */
FI_GET_RAW_MR, /* fi_mr_raw_attr */
FI_MAP_RAW_MR, /* fi_mr_map_raw */
FI_UNMAP_KEY, /* uint64_t key */
FI_QUEUE_WORK, /* struct fi_deferred_work */
FI_CANCEL_WORK, /* struct fi_deferred_work */
FI_FLUSH_WORK, /* NULL */
FI_REFRESH, /* mr: fi_mr_modify */
FI_DUP, /* struct fid ** */
FI_GETWAITOBJ, /*enum fi_wait_obj * */
FI_GET_VAL, /* struct fi_fid_var */
FI_SET_VAL, /* struct fi_fid_var */
FI_EXPORT_FID, /* struct fi_fid_export */
};
static inline int fi_control(struct fid *fid, int command, void *arg)
{
return fid->ops->control(fid, command, arg);
}
static inline int fi_alias(struct fid *fid, struct fid **alias_fid, uint64_t flags)
{
struct fi_alias alias;
alias.fid = alias_fid;
alias.flags = flags;
return fi_control(fid, FI_ALIAS, &alias);
}
/* Provider specific names should set the uppermost bit. */
static inline int fi_get_val(struct fid *fid, int name, void *val)
{
struct fi_fid_var var;
var.name = name;
var.val = val;
return fi_control(fid, FI_GET_VAL, &var);
}
static inline int fi_set_val(struct fid *fid, int name, void *val)
{
struct fi_fid_var var;
var.name = name;
var.val = val;
return fi_control(fid, FI_SET_VAL, &var);
}
static inline int
fi_open_ops(struct fid *fid, const char *name, uint64_t flags,
void **ops, void *context)
{
return fid->ops->ops_open(fid, name, flags, ops, context);
}
static inline int
fi_set_ops(struct fid *fid, const char *name, uint64_t flags,
void *ops, void *context)
{
return FI_CHECK_OP(fid->ops, struct fi_ops, ops_set) ?
fid->ops->ops_set(fid, name, flags, ops, context) : -FI_ENOSYS;
}
enum fi_type {
FI_TYPE_INFO,
FI_TYPE_EP_TYPE,
FI_TYPE_CAPS,
FI_TYPE_OP_FLAGS,
FI_TYPE_ADDR_FORMAT,
FI_TYPE_TX_ATTR,
FI_TYPE_RX_ATTR,
FI_TYPE_EP_ATTR,
FI_TYPE_DOMAIN_ATTR,
FI_TYPE_FABRIC_ATTR,
FI_TYPE_THREADING,
FI_TYPE_PROGRESS,
FI_TYPE_PROTOCOL,
FI_TYPE_MSG_ORDER,
FI_TYPE_MODE,
FI_TYPE_AV_TYPE,
FI_TYPE_ATOMIC_TYPE,
FI_TYPE_ATOMIC_OP,
FI_TYPE_VERSION,
FI_TYPE_EQ_EVENT,
FI_TYPE_CQ_EVENT_FLAGS,
FI_TYPE_MR_MODE,
FI_TYPE_OP_TYPE,
FI_TYPE_FID,
FI_TYPE_COLLECTIVE_OP,
FI_TYPE_HMEM_IFACE,
FI_TYPE_CQ_FORMAT,
FI_TYPE_LOG_LEVEL,
FI_TYPE_LOG_SUBSYS,
FI_TYPE_AV_ATTR,
FI_TYPE_CQ_ATTR,
FI_TYPE_MR_ATTR,
FI_TYPE_CNTR_ATTR,
FI_TYPE_CQ_ERR_ENTRY,
};
char *fi_tostr(const void *data, enum fi_type datatype);
char *fi_tostr_r(char *buf, size_t len, const void *data,
enum fi_type datatype);
enum fi_param_type {
FI_PARAM_STRING,
FI_PARAM_INT,
FI_PARAM_BOOL,
FI_PARAM_SIZE_T,
};
struct fi_param {
const char *name;
enum fi_param_type type;
const char *help_string;
const char *value;
};
int fi_getparams(struct fi_param **params, int *count);
void fi_freeparams(struct fi_param *params);
/* Dummy definitions for removed flags/caps/types. For compiling old fabtests */
#define FI_VARIABLE_MSG 0ULL
#define FI_NOTIFY_FLAGS_ONLY 0ULL
#define FI_RESTRICTED_COMP 0ULL
#define FI_EP_SOCK_STREAM FI_EP_UNSPEC
#ifdef FABRIC_DIRECT
#include <rdma/fi_direct.h>
#endif /* FABRIC_DIRECT */
#ifndef FABRIC_DIRECT_
struct fi_context {
void *internal[4];
};
struct fi_context2 {
void *internal[8];
};
#endif
struct fi_recv_context {
struct fid_ep *ep;
void *context;
};
#ifdef __cplusplus
}
#endif
#endif /* FABRIC_H */