This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathlibrpma.h
2668 lines (2569 loc) · 82.6 KB
/
librpma.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
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2019-2020, Intel Corporation */
/*
* librpma.h -- definitions of librpma entry points
*
* This library provides low-level support for remote access to persistent
* memory utilizing RDMA-capable NICs.
*/
#ifndef LIBRPMA_H
#define LIBRPMA_H 1
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <infiniband/verbs.h>
/** 7
* librpma - remote persistent memory access library
*
* SYNOPSIS
*
* #include <librpma.h>
* cc ... -lrpma
*
* DESCRIPTION
*
* librpma is a C library to simplify accessing persistent memory (PMem)
* on remote hosts over Remote Direct Memory Access (RDMA).
*
* The librpma library provides two possible schemes of operation:
* Remote Memory Access and Messaging. Both of them are available over
* a connection established between two peers. Both of these schemes can make
* use of PMem as well as DRAM for the sake of building efficient and scalable
* Remote Persistent Memory Accessing (RPMA) applications.
*
* REMOTE MEMORY ACCESS
*
* The librpma library implements four basic API calls
* dedicated for accessing a remote memory:
* - rpma_read() - initiates transferring data from the remote memory
* to the local memory,
* - rpma_write() - initiates transferring data from the local memory
* to the remote memory),
* - rpma_write_atomic() - works like rpma_write(), but it allows transferring
* 8 bytes of data (RPMA_ATOMIC_WRITE_ALIGNMENT) and storing them atomically
* in the remote memory (see rpma_write_atomic(3) for details
* and restrictions), and:
* - rpma_flush() - initiates finalizing a transfer of data to the remote
* memory. Possible types of rpma_flush() operation:
* - RPMA_FLUSH_TYPE_PERSISTENT - flush data down to the persistent domain,
* - RPMA_FLUSH_TYPE_VISIBILITY - flush data deep enough to make it visible
* on the remote node.
*
* All the above functions use the attribute flags to set the completion
* notification indicator:
* - RPMA_F_COMPLETION_ON_ERROR - generates the completion only on error
* - RPMA_F_COMPLETION_ALWAYS - generates the completion regardless of a result
* of the operation.
*
* All of these operations are considered as finished
* when the respective completion is generated.
*
* DIRECT WRITE TO PMEM
*
* \f[B]Direct Write to PMem\f[R] is a feature of a platform and
* its configuration which allows an RDMA-capable network interface to write
* data to platform's PMem in a persistent way. It may be impossible because
* of e.g. caching mechanisms existing on the data's way. When \f[B]Direct Write
* to PMem\f[R] is impossible, operating in the way assuming it is possible may
* corrupt data on PMem, so this is why \f[B]Direct Write to PMem\f[R] is not
* enabled by default.
*
* On the current Intel platforms, the only thing you have to do in order
* to enable \f[B]Direct Write to PMem\f[R] is turning off
* Intel Direct Data I/O (DDIO). Sometimes, you can turn off DDIO either
* globally for the whole platform or for a specific PCIe Root Port.
* For details, please see the manual of your platform.
*
* When you have a platform which allows \f[B]Direct Write to PMem\f[R],
* you have to declare this is the case in your peer's configuration. The peer's
* configuration has to be transferred to all the peers which want to execute
* rpma_flush() with RPMA_FLUSH_TYPE_PERSISTENT against the platform's PMem and
* applied to the connection object which safeguards access to PMem.
*
* - rpma_peer_cfg_set_direct_write_to_pmem() - declare \f[B]Direct Write
* to PMem\f[R] support
* - rpma_peer_cfg_get_descriptor() - get the descriptor of the peer
* configuration
* - rpma_peer_cfg_from_descriptor() - create a peer configuration from
* the descriptor
* - rpma_conn_apply_remote_peer_cfg() - apply remote peer cfg to the connection
*
* For details on how to use these APIs please see
* https://github.com/pmem/rpma/tree/master/examples/05-flush-to-persistent.
*
* CLIENT OPERATION
* A client is the active side of the process of establishing a connection.
* A role of the peer during the process of establishing connection
* does not determine direction of the data flow (neither via
* Remote Memory Access nor via Messaging). After establishing the connection
* both peers have the same capabilities.
*
* The client, in order to establish a connection, has to perform the following
* steps:
*
* - rpma_conn_req_new() - create a new outgoing connection request object
* - rpma_conn_req_connect() - initiate processing the connection request
* - rpma_conn_next_event() - wait for the RPMA_CONN_ESTABLISHED event
*
* After establishing the connection both peers can perform
* Remote Memory Access and/or Messaging over the connection.
*
* The client, in order to close a connection, has to perform the following
* steps:
*
* - rpma_conn_disconnect() - initiate disconnection
* - rpma_conn_next_event() - wait for the RPMA_CONN_CLOSED event
* - rpma_conn_delete() - delete the closed connection
*
* SERVER OPERATION
* A server is the passive side of the process of establishing a connection.
* Note that after establishing the connection both peers have
* the same capabilities.
*
* The server, in order to establish a connection, has to perform the following
* steps:
*
* - rpma_ep_listen() - create a listening endpoint
* - rpma_ep_next_conn_req() - obtain an incoming connection request
* - rpma_conn_req_connect() - initiate connecting the connection request
* - rpma_conn_next_event() - wait for the RPMA_CONN_ESTABLISHED event
*
* After establishing the connection both peers can perform
* Remote Memory Access and/or Messaging over the connection.
*
* The server, in order to close a connection, has to perform the following
* steps:
*
* - rpma_conn_next_event() - wait for the RPMA_CONN_CLOSED event
* - rpma_conn_disconnect() - disconnect the connection
* - rpma_conn_delete() - delete the closed connection
*
* When no more incoming connections are expected, the server can stop waiting
* for them:
*
* - rpma_ep_shutdown() - stop listening and delete the endpoint
*
* MEMORY MANAGEMENT
*
* Every piece of memory (either volatile or persistent) must be registered
* and its usage must be specified in order to be used in Remote Memory Access
* or Messaging. This can be done using the following memory management
* librpma functions:
* - rpma_mr_reg() which registers a memory region and creates a local memory
* registration object and
* - rpma_mr_dereg() which deregisters the memory region and deletes
* the local memory registration object.
*
* A description of the registered memory region sometimes has to be
* transferred via network to the other side of the connection.
* In order to do that a network-transferable description
* of the provided memory region (called 'descriptor') has to be created
* using rpma_mr_get_descriptor(). On the other side of the connection
* the received descriptor should be decoded using
* rpma_mr_remote_from_descriptor(). It creates a remote memory region's
* structure that allows for Remote Memory Access.
*
* MESSAGING
*
* The librpma messaging API allows transferring messages
* (buffers of arbitrary data) between the peers.
* Transferring messages requires preparing buffers
* (memory regions) on the remote side to receive the sent data.
* The received data are written to those dedicated buffers
* and the sender does not have to have a respective remote
* memory region object to send a message.
* The memory buffers used for messaging have to be registered
* using rpma_mr_reg() prior to rpma_send() or rpma_recv() function call.
*
* The librpma library implements the following messaging API:
* - rpma_send() - initiates the send operation which transfers a message
* from the local memory to other side of the connection,
* - rpma_recv() - initiates the receive operation which prepares a buffer
* for a message sent from other side of the connection,
* - rpma_conn_req_recv() works as rpma_recv(), but it may be used
* before the connection is established.
*
* All of these operations are considered as finished
* when the respective completion is generated.
*
* COMPLETIONS
*
* RDMA operations generate complitions that notify a user
* that the respective operation has been completed.
*
* The following operations are available in librpma:
* - RPMA_OP_READ - RMA read operation
* - RPMA_OP_WRITE - RMA write operation
* - RPMA_OP_FLUSH - RMA flush operation
* - RPMA_OP_SEND - messaging send operation
* - RPMA_OP_RECV - messaging receive operation
*
* All operations generate completion on error. The operations posted
* with the \f[B]RPMA_F_COMPLETION_ALWAYS\f[R] flag also generate a completion
* on success. Completion codes are reused from the libibverbs library,
* where the IBV_WC_SUCCESS status indicates the successful completion
* of an operation. Completions are collected in the completion queue (CQ)
* (see the \f[B]QUEUES, PERFORMANCE AND RESOURCE USE\f[R] section
* for more details on queues).
*
* The librpma library implements the following API for handling completions:
* - rpma_conn_completion_wait() waits for incoming completions. If it
* succeeds the completions can be collected using rpma_conn_completion_get().
* - rpma_conn_completion_get() receives the next available completion
* of an already posted operation.
*
* PEER
*
* A peer is an abstraction representing an RDMA-capable device.
* All other RPMA objects have to be created in the context of a peer.
* A peer allows one to:
* - establish connections (Client Operation)
* - register memory regions (Memory Management)
* - create endpoints for listening for incoming connections (Server Operation)
*
* At the beginning, in order to create a peer, a user has to obtain
* an RDMA device context by the given IPv4/IPv6 address using
* rpma_utils_get_ibv_context(). Then a new peer object can be created
* using rpma_peer_new() and deleted using rpma_peer_delete().
*
* SYNCHRONOUS AND ASYNCHRONOUS MODES
* By default, all endpoints and connections operate in the synchronous mode
* where:
*
* - rpma_ep_next_conn_req(),
* - rpma_conn_completion_wait() and
* - rpma_conn_get_next_event()
*
* are blocking calls. You can make those API calls non-blocking by modifying
* the respective file descriptors:
*
* - rpma_ep_get_fd() - provides a file descriptor for rpma_ep_next_conn_req()
* - rpma_conn_get_completion_fd() - provides a file descriptor for
* rpma_conn_completion_wait()
* - rpma_conn_get_event_fd() - provides a file descriptor for
* rpma_conn_get_next_event()
*
* When you have a file descriptor, you can make it non-blocking using fcntl(2)
* as follows:
*
* int ret = fcntl(fd, F_GETFL);
* fcntl(fd, F_SETFL, flags | O_NONBLOCK);
*
* Such change makes the respective API call non-blocking automatically.
*
* The provided file descriptors can also be used for scalable I/O handling like
* epoll(7).
*
* Please see the example showing how to make use of RPMA file descriptors:
* https://github.com/pmem/rpma/tree/master/examples/06-multiple-connections
*
* .SH QUEUES, PERFORMANCE AND RESOURCE USE
*
* \f[B]Remote Memory Access\f[R] operations, \f[B]Messaging\f[R] operations
* and their \f[B]Completions\f[R] consume space in queues allocated
* in an RDMA-capable network interface (RNIC) hardware for each
* of the connections.
* You must be aware of the existence of these queues:
*
* - completion queue \f[B](CQ)\f[R] where completions of operations are placed,
* either when a completion was required by a user (RPMA_F_COMPLETION_ALWAYS)
* or a completion with an error occurred. All \f[B]Remote Memory Access\f[R]
* operations and \f[B]Messaging\f[R] operations can consume \f[B]CQ\f[R] space.
* - send queue \f[B](SQ)\f[R] where all \f[B]Remote Memory Access\f[R]
* operations and rpma_send() operations are placed before they are executed by
* RNIC.
* - receive queue \f[B](RQ)\f[R] where rpma_recv() entries are placed before
* they are consumed by the rpma_send() coming from another side
* of the connection.
*
* You must assume \f[B]SQ\f[R] and \f[B]RQ\f[R] entries occupy the place
* in their respective queue till:
*
* - a respective operation's completion is generated or
* - a completion of an operation, which was scheduled later, is generated.
*
* You must also be aware that RNIC has limited resources so it is impossible
* to store a very long set of queues for many possibly existing connections.
* If all of the queues will not fit into RNIC's resources it will start using
* the platform's memory for this purpose. In this case, the performance will
* be degraded because of inevitable cache misses.
*
* Because the length of queues has so profound impact on the performance of
* RPMA application you can configure the length of each of the queues
* separately for each of the connections:
*
* - rpma_conn_cfg_set_cq_size() - set length of \f[B]CQ\f[R]
* - rpma_conn_cfg_set_sq_size() - set length of \f[B]SQ\f[R]
* - rpma_conn_cfg_set_rq_size() - set length of \f[B]RQ\f[R]
*
* When the connection configuration object is ready it has to be used for
* either rpma_conn_req_new() or rpma_ep_next_conn_req() for the settings
* to take effect.
*
* THREAD SAFETY
*
* Most of the core librpma API calls are thread-safe but there are also very
* important exceptions mainly related to connection's configuration,
* establishment and tear-down. Here you can find a complete list of
* NOT thread-safe API calls:
*
* - rpma_conn_apply_remote_peer_cfg()
* - rpma_conn_cfg_get_cq_size()
* - rpma_conn_cfg_get_rq_size()
* - rpma_conn_cfg_get_sq_size()
* - rpma_conn_cfg_get_timeout()
* - rpma_conn_cfg_set_cq_size()
* - rpma_conn_cfg_set_rq_size()
* - rpma_conn_cfg_set_sq_size()
* - rpma_conn_cfg_set_timeout()
* - rpma_conn_delete()
* - rpma_conn_disconnect()
* - rpma_conn_get_private_data()
* - rpma_conn_next_event()
* - rpma_conn_req_connect()
* - rpma_conn_req_delete()
* - rpma_conn_req_new()
* - rpma_ep_listen()
* - rpma_ep_next_conn_req()
* - rpma_ep_shutdown()
* - rpma_peer_cfg_get_descriptor()
* - rpma_peer_cfg_get_descriptor_size()
* - rpma_peer_cfg_get_direct_write_to_pmem()
* - rpma_peer_cfg_set_direct_write_to_pmem()
* - rpma_utils_get_ibv_context()
*
* Other librpma API calls are thread-safe. However, creating RPMA library
* resources usually involves dynamic memory allocation and destroying
* resources usually involves a dynamic memory release. The same resource
* cannot be destroyed more than once, at any thread, and a resource cannot be
* used after it was destroyed. It is the user's responsibility to follow those
* rules and not doing so may result in a segmentation fault or undefined
* behaviour.
*
* .SH ON-DEMAND PAGING SUPPORT
*
* On-Demand-Paging (ODP) is a technique that simplifies the memory
* registration process (for example, applications no longer need to pin down
* the underlying physical pages of the address space and track the validity
* of the mappings). On-Demand Paging is available if both the hardware
* and the kernel support it. The detailed description of ODP can be found here:
* https://community.mellanox.com/s/article/understanding-on-demand-paging--odp-x
*
* State of ODP support can be checked using
* the rpma_utils_ibv_context_is_odp_capable() function
* that queries the RDMA device context's capabilities
* and checks if it supports On-Demand Paging.
*
* The librpma library uses ODP automatically if it is supported.
* ODP support is required to register PMem memory region mapped
* from File System DAX (FSDAX).
*
* DEBUGGING AND ERROR HANDLING
*
* If a librpma function may fail, it returns a negative error code.
* Checking if the returned value is non-negative is the only
* programmatically available way to verify if the API call succeeded.
* The exact meaning of all error codes is described in the manual
* of each function.
*
* The librpma library implements the logging API which may give additional
* information in case of an error and during normal operation as well,
* according to the current logging threshold levels.
*
* The function that will handle all generated log messages can be set
* using rpma_log_set_function(). The logging function can be either
* the default logging function (built into the library)
* or a user-defined, thread-safe, function. The default logging function
* can write messages to syslog(3) and stderr(3).
* The logging threshold level can be set or got using
* rpma_log_set_threshold() or rpma_log_get_threshold() respectively.
*
* There is an example of the usage of the logging functions:
* https://github.com/pmem/rpma/tree/master/examples/log
*
* EXAMPLES
*
* See https://github.com/pmem/rpma/tree/master/examples for examples of using
* the librpma API.
*
* ACKNOWLEDGEMENTS
*
* librpma is built on the top of libibverbs and librdmacm APIs.
*
* SEE ALSO
*
* https://pmem.io/rpma/
*/
#define RPMA_W_WAIT_FOR_COMPLETION (1)
#define RPMA_E_UNKNOWN (-100000) /* Unknown error */
#define RPMA_E_NOSUPP (-100001) /* Not supported */
#define RPMA_E_PROVIDER (-100002) /* Provider error occurred */
#define RPMA_E_NOMEM (-100003) /* Out of memory */
#define RPMA_E_INVAL (-100004) /* Invalid argument */
#define RPMA_E_NO_COMPLETION (-100005) /* No next completion available */
#define RPMA_E_NO_EVENT (-100006) /* No next event available */
#define RPMA_E_AGAIN (-100007) /* Temporary error */
/* picking up an RDMA-capable device */
#define RPMA_DEFAULT_TIMEOUT_MS 1000
/* pick a type of an ibv_context to lookup for */
enum rpma_util_ibv_context_type {
RPMA_UTIL_IBV_CONTEXT_LOCAL, /* lookup for a local device */
RPMA_UTIL_IBV_CONTEXT_REMOTE /* lookup for a remote device */
};
/** 3
* rpma_utils_get_ibv_context - obtain an RDMA device context by IP address
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct ibv_context;
* enum rpma_util_ibv_context_type {
* RPMA_UTIL_IBV_CONTEXT_LOCAL,
* RPMA_UTIL_IBV_CONTEXT_REMOTE
* };
*
* int rpma_utils_get_ibv_context(const char *addr,
* enum rpma_util_ibv_context_type type,
* struct ibv_context **dev_ptr);
*
* DESCRIPTION
* rpma_utils_get_ibv_context() obtains an RDMA device context
* by the given IPv4/IPv6 address (either local or remote) using
* the TCP RDMA port space (RDMA_PS_TCP) - reliable, connection-oriented
* and message-based QP communication.
* Possible values of the 'type' argument:
* - RPMA_UTIL_IBV_CONTEXT_LOCAL - lookup for a device
* based on the given local address
* - RPMA_UTIL_IBV_CONTEXT_REMOTE - lookup for a device
* based on the given remote address
*
* RETURN VALUE
* The rpma_utils_get_ibv_context() function returns 0 on success or a negative
* error code on failure. rpma_utils_get_ibv_context() does not set *dev_ptr
* value on failure.
*
* ERRORS
* rpma_utils_get_ibv_context() can fail with the following errors:
*
* - RPMA_E_INVAL - addr or dev_ptr is NULL or type is unknown
* - RPMA_E_NOMEM - out of memory
* - RPMA_E_PROVIDER - rdma_getaddrinfo(), rdma_create_id(), rdma_bind_addr()
* or rdma_resolve_addr() failed, the exact cause of the error
* can be read from the log
*
* SEE ALSO
* rpma_peer_new(3), rpma_utils_ibv_context_is_odp_capable(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_utils_get_ibv_context(const char *addr,
enum rpma_util_ibv_context_type type,
struct ibv_context **dev_ptr);
/** 3
* rpma_utils_ibv_context_is_odp_capable - is On-Demand Paging supported
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct ibv_context;
* int rpma_utils_ibv_context_is_odp_capable(struct ibv_context *dev,
* int *is_odp_capable);
*
* DESCRIPTION
* rpma_utils_ibv_context_is_odp_capable() queries the RDMA device context's
* capabilities and check if it supports On-Demand Paging.
*
* RETURN VALUE
* The rpma_utils_ibv_context_is_odp_capable() function returns 0 on success or
* a negative error code on failure. The *is_odp_capable value on failure is
* undefined.
*
* ERRORS
* rpma_utils_ibv_context_is_odp_capable() can fail with the following errors:
*
* - RPMA_E_INVAL - dev or is_odp_capable is NULL
* - RPMA_E_PROVIDER - ibv_query_device_ex() failed, the exact cause
* of the error can be read from the log
*
* SEE ALSO
* rpma_utils_get_ibv_context(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_utils_ibv_context_is_odp_capable(struct ibv_context *dev,
int *is_odp_capable);
/* peer configuration */
struct rpma_peer_cfg;
/** 3
* rpma_peer_cfg_new - create a new peer configuration object
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_new(struct rpma_peer_cfg **pcfg_ptr);
*
* DESCRIPTION
* rpma_peer_cfg_new() creates a new peer configuration object.
*
* RETURN VALUE
* The rpma_peer_cfg_new() function returns 0 on success or a negative
* error code on failure. rpm_peer_cfg_new() does not set
* *pcfg_ptr value on failure.
*
* ERRORS
* rpma_peer_cfg_new() can fail with the following errors:
*
* - RPMA_E_INVAL - pcfg_ptr is NULL
* - RPMA_E_NOMEM - out of memory
*
* SEE ALSO
* rpma_conn_apply_remote_peer_cfg(3), rpma_peer_cfg_delete(3),
* rpma_peer_cfg_from_descriptor(3), rpma_peer_cfg_get_descriptor(3),
* rpma_peer_cfg_get_descriptor_size(3),
* rpma_peer_cfg_get_direct_write_to_pmem(3),
* rpma_peer_cfg_set_direct_write_to_pmem(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_peer_cfg_new(struct rpma_peer_cfg **pcfg_ptr);
/** 3
* rpma_peer_cfg_delete - delete the peer configuration object
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_delete(struct rpma_peer_cfg **pcfg_ptr);
*
* DESCRIPTION
* rpma_peer_cfg_delete() deletes the peer configuration object.
*
* RETURN VALUE
* The rpma_peer_cfg_delete() function returns 0 on success or a negative
* error code on failure. rpm_peer_cfg_delete() does not set
* *pcfg_ptr value to NULL on failure.
*
* ERRORS
* rpma_peer_cfg_delete() can fail with the following error:
*
* - RPMA_E_INVAL - pcfg_ptr is NULL
*
* SEE ALSO
* rpma_peer_cfg_new(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_peer_cfg_delete(struct rpma_peer_cfg **pcfg_ptr);
/** 3
* rpma_peer_cfg_set_direct_write_to_pmem - declare direct write to PMEM support
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_set_direct_write_to_pmem(struct rpma_peer_cfg *pcfg,
* bool supported);
*
* DESCRIPTION
* rpma_peer_cfg_set_direct_write_to_pmem() declares the support
* of the direct write to PMEM.
*
* RETURN VALUE
* The rpma_peer_cfg_set_direct_write_to_pmem() function returns 0 on success
* or a negative error code on failure.
*
* ERRORS
* rpma_peer_cfg_set_direct_write_to_pmem() can fail with the following error:
*
* - RPMA_E_INVAL - pcfg is NULL
*
* SEE ALSO
* rpma_conn_apply_remote_peer_cfg(3), rpma_peer_cfg_get_descriptor(3),
* rpma_peer_cfg_get_direct_write_to_pmem(3), rpma_peer_cfg_new(3), librpma(7)
* and https://pmem.io/rpma/
*/
int rpma_peer_cfg_set_direct_write_to_pmem(struct rpma_peer_cfg *pcfg,
bool supported);
/** 3
* rpma_peer_cfg_get_direct_write_to_pmem - check direct write to PMEM support
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_get_direct_write_to_pmem(
* const struct rpma_peer_cfg *pcfg, bool *supported);
*
* DESCRIPTION
* rpma_peer_cfg_get_direct_write_to_pmem() checks the support
* of the direct write to PMEM.
*
* RETURN VALUE
* The rpma_peer_cfg_get_direct_write_to_pmem() function returns 0 on success
* or a negative error code on failure.
*
* ERRORS
* rpma_peer_cfg_get_direct_write_to_pmem() can fail with the following error:
*
* - RPMA_E_INVAL - pcfg or supported are NULL
*
* SEE ALSO
* rpma_peer_cfg_from_descriptor(3), rpma_peer_cfg_new(3),
* rpma_peer_cfg_set_direct_write_to_pmem(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_peer_cfg_get_direct_write_to_pmem(const struct rpma_peer_cfg *pcfg,
bool *supported);
/** 3
* rpma_peer_cfg_get_descriptor - get the descriptor of the peer configuration
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_get_descriptor(const struct rpma_peer_cfg *pcfg,
* void *desc);
*
* DESCRIPTION
* rpma_peer_cfg_get_descriptor() gets the descriptor of the peer configuration.
*
* RETURN VALUE
* The rpma_peer_cfg_get_descriptor() function returns 0 on success or
* a negative error code on failure.
*
* ERRORS
* rpma_peer_cfg_get_descriptor() can fail with the following error:
*
* - RPMA_E_INVAL - pcfg or desc are NULL
*
* SEE ALSO
* rpma_peer_cfg_from_descriptor(3), rpma_peer_cfg_new(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_peer_cfg_get_descriptor(const struct rpma_peer_cfg *pcfg, void *desc);
/** 3
* rpma_peer_cfg_get_descriptor_size - get size of the peer cfg descriptor
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_get_descriptor_size(const struct rpma_peer_cfg *pcfg,
* size_t *desc_size);
*
* DESCRIPTION
* rpma_peer_cfg_get_descriptor_size() gets size of the peer configuration
* descriptor.
*
* RETURN VALUE
* The rpma_peer_cfg_get_descriptor_size() function returns 0 on success or
* a negative error code on failure.
*
* ERRORS
* rpma_peer_cfg_get_descriptor_size() can fail with the following error:
*
* - RPMA_E_INVAL - pcfg or desc_size is NULL
*
* SEE ALSO
* rpma_peer_cfg_get_descriptor(3), rpma_peer_cfg_new(3), librpma(7) and
* https://pmem.io/rpma/
*/
int
rpma_peer_cfg_get_descriptor_size(const struct rpma_peer_cfg *pcfg,
size_t *desc_size);
/** 3
* rpma_peer_cfg_from_descriptor - create a peer cfg from the descriptor
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer_cfg;
* int rpma_peer_cfg_from_descriptor(const void *desc, size_t desc_size,
* struct rpma_peer_cfg **pcfg_ptr);
*
* DESCRIPTION
* rpma_peer_cfg_from_descriptor() creates a peer configuration object
* from the descriptor.
*
* RETURN VALUE
* The rpma_peer_cfg_from_descriptor() function returns 0 on success
* or a negative error code on failure. rpma_peer_cfg_from_descriptor()
* does not set *pcfg_ptr value on failure.
*
* ERRORS
* rpma_peer_cfg_from_descriptor() can fail with the following errors:
*
* - RPMA_E_INVAL - desc or pcfg_ptr are NULL
* - RPMA_E_NOMEM - out of memory
*
* SEE ALSO
* rpma_conn_apply_remote_peer_cfg(3), rpma_peer_cfg_get_descriptor(3),
* rpma_peer_cfg_new(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_peer_cfg_from_descriptor(const void *desc, size_t desc_size,
struct rpma_peer_cfg **pcfg_ptr);
/* peer */
struct rpma_peer;
/** 3
* rpma_peer_new - create a peer object
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct ibv_context;
* struct rpma_peer;
* int rpma_peer_new(struct ibv_context *ibv_ctx,
* struct rpma_peer **peer_ptr);
*
* DESCRIPTION
* rpma_peer_new() creates a new peer object.
*
* RETURN VALUE
* The rpma_peer_new() function returns 0 on success or a negative error code
* on failure. rpma_peer_new() does not set *peer_ptr value on failure.
*
* ERRORS
* rpma_peer_new() can fail with the following errors:
*
* - RPMA_E_INVAL - ibv_ctx or peer_ptr is NULL
* - RPMA_E_NOMEM - creating a verbs protection domain failed with ENOMEM.
* - RPMA_E_PROVIDER - creating a verbs protection domain failed with error
* other than ENOMEM.
* - RPMA_E_UNKNOWN - creating a verbs protection domain failed without error
* value.
* - RPMA_E_NOMEM - out of memory
*
* SEE ALSO
* rpma_conn_req_new(3), rpma_ep_listen(3), rpma_mr_reg(3), rpma_peer_delete(3),
* rpma_utils_get_ibv_context(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_peer_new(struct ibv_context *ibv_ctx, struct rpma_peer **peer_ptr);
/** 3
* rpma_peer_delete - delete a peer object
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer;
* int rpma_peer_delete(struct rpma_peer **peer_ptr);
*
* DESCRIPTION
* rpma_peer_delete() deletes the peer object.
*
* RETURN VALUE
* The rpma_peer_delete() function returns 0 on success or a negative error
* code on failure. rpm_peer_delete() does not set *peer_ptr value
* to NULL on failure.
*
* RETURN VALUE
* The rpma_peer_delete() function returns 0 on success or a negative error code
* on failure. rpma_peer_delete() does not set *peer_ptr to NULL on failure.
*
* ERRORS
* rpma_peer_delete() can fail with the following error:
*
* - RPMA_E_PROVIDER - deleting the verbs protection domain failed.
*
* SEE ALSO
* rpma_peer_new(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_peer_delete(struct rpma_peer **peer_ptr);
/* memory-related structures */
struct rpma_mr_local;
struct rpma_mr_remote;
#define RPMA_MR_USAGE_READ_SRC (1 << 0)
#define RPMA_MR_USAGE_READ_DST (1 << 1)
#define RPMA_MR_USAGE_WRITE_SRC (1 << 2)
#define RPMA_MR_USAGE_WRITE_DST (1 << 3)
#define RPMA_MR_USAGE_FLUSH_TYPE_VISIBILITY (1 << 4)
#define RPMA_MR_USAGE_FLUSH_TYPE_PERSISTENT (1 << 5)
#define RPMA_MR_USAGE_SEND (1 << 6)
#define RPMA_MR_USAGE_RECV (1 << 7)
/** 3
* rpma_mr_reg - create a local memory registration object
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_peer;
* struct rpma_mr_local;
*
* int rpma_mr_reg(struct rpma_peer *peer, void *ptr, size_t size,
* int usage, struct rpma_mr_local **mr_ptr);
*
* DESCRIPTION
* rpma_mr_reg() registers a memory region and creates a local memory
* registration object. The usage parameter specifies the operations
* that can be performed on the given memory region which should be expressed
* as bitwise-inclusive OR of the following:
* - RPMA_MR_USAGE_READ_SRC - memory used as a source of the read operation
* - RPMA_MR_USAGE_READ_DST - memory used as a destination of the read operation
* - RPMA_MR_USAGE_WRITE_SRC - memory used as a source of the write operation
* - RPMA_MR_USAGE_WRITE_DST - memory used as a destination of
* the write operation
* - RPMA_MR_USAGE_FLUSH_TYPE_VISIBILITY - memory with available flush operation
* - RPMA_MR_USAGE_FLUSH_TYPE_PERSISTENT - memory with available
* persistent flush operation
* - RPMA_MR_USAGE_SEND - memory used for send operation
* - RPMA_MR_USAGE_RECV - memory used for receive operation
*
* RETURN VALUE
* The rpma_mr_reg() function returns 0 on success or a negative error code
* on failure. rpma_mr_reg() does not set *mr_ptr value on failure.
*
* ERRORS
* rpma_mr_reg() can fail with the following errors:
*
* - RPMA_E_INVAL - peer or ptr or mr_ptr is NULL
* - RPMA_E_INVAL - size equals 0
* - RPMA_E_NOMEM - out of memory
* - RPMA_E_PROVIDER - memory registration failed
*
* SEE ALSO
* rpma_conn_req_recv(3), rpma_mr_dereg(3), rpma_mr_get_descriptor(3),
* rpma_mr_get_descriptor_size(3), rpma_peer_new(3), rpma_read(3), rpma_recv(3),
* rpma_send(3), rpma_write(3), rpma_write_atomic(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_mr_reg(struct rpma_peer *peer, void *ptr, size_t size,
int usage, struct rpma_mr_local **mr_ptr);
/** 3
* rpma_mr_dereg - delete a local memory registration object
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_mr_local;
* int rpma_mr_dereg(struct rpma_mr_local **mr_ptr);
*
* DESCRIPTION
* rpma_mr_dereg() deregisters a memory region
* and deletes a local memory registration object.
*
* RETURN VALUE
* The rpma_mr_dereg() function returns 0 on success or a negative error code
* on failure. rpma_mr_dereg() does not set *mr_ptr value to NULL on failure.
*
* ERRORS
* rpma_mr_dereg() can fail with the following errors:
*
* - RPMA_E_INVAL - mr_ptr is NULL
* - RPMA_E_PROVIDER - memory deregistration failed
*
* SEE ALSO
* rpma_mr_reg(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_mr_dereg(struct rpma_mr_local **mr_ptr);
/** 3
* rpma_mr_get_descriptor - get a descriptor of a memory region
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_mr_local;
* int rpma_mr_get_descriptor(const struct rpma_mr_local *mr, void *desc);
*
* DESCRIPTION
* rpma_mr_get_descriptor() writes a network-transferable description
* of the provided local memory region (called 'descriptor').
* Once the descriptor is transferred to the other side it should be decoded
* by rpma_mr_remote_from_descriptor() to create a remote memory region's
* structure which allows for Remote Memory Access.
* Please see librpma(7) for details.
*
* RETURN VALUE
* The rpma_mr_get_descriptor() function returns 0 on success or a negative
* error code on failure.
*
* ERRORS
* rpma_mr_get_descriptor() can fail with the following error:
*
* - RPMA_E_INVAL - mr or desc is NULL
*
* SEE ALSO
* rpma_mr_get_descriptor_size(3), rpma_mr_reg(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_mr_get_descriptor(const struct rpma_mr_local *mr, void *desc);
/** 3
* rpma_mr_remote_from_descriptor - create a memory region from a descriptor
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_mr_remote;
* int rpma_mr_remote_from_descriptor(const void *desc,
* size_t desc_size, struct rpma_mr_remote **mr_ptr);
*
* DESCRIPTION
* Create a remote memory region's structure based on the provided descriptor
* with a network-transferable description of the memory region local to
* the remote peer.
*
* RETURN VALUE
* The rpma_mr_remote_from_descriptor() function returns 0 on success
* or a negative error code on failure. rpma_mr_remote_from_descriptor()
* does not set *mr_ptr value on failure.
*
* ERRORS
* rpma_mr_remote_from_descriptor() can fail with the following errors:
*
* - RPMA_E_INVAL - desc or mr_ptr is NULL
* - RPMA_E_INVAL - incompatible descriptor size
* - RPMA_E_NOSUPP - deserialized information does not represent a valid memory
* region
* - RPMA_E_NOMEM - out of memory
*
* SEE ALSO
* rpma_mr_remote_delete(3), rpma_mr_remote_get_flush_type(3),
* rpma_mr_remote_get_size(3), rpma_flush(3), rpma_read(3), rpma_write(3),
* rpma_write_atomic(3), librpma(7) and https://pmem.io/rpma/
*/
int rpma_mr_remote_from_descriptor(const void *desc,
size_t desc_size, struct rpma_mr_remote **mr_ptr);
/** 3
* rpma_mr_get_descriptor_size - get size of the memory region descriptor
*
* SYNOPSIS
*
* #include <librpma.h>
*
* struct rpma_mr_local;
* int rpma_mr_get_descriptor_size(const struct rpma_mr_local *mr,
* size_t *desc_size);
*
* DESCRIPTION
* rpma_mr_get_descriptor_size() gets size of the memory region descriptor.
*
* RETURN VALUE
* The rpma_mr_get_descriptor_size() function returns 0 on success
* or a negative error code on failure. rpma_mr_get_descriptor_size()
* does not set *desc_size value on failure.
*
* ERRORS
* rpma_mr_get_descriptor_size() can fail with the following error:
*
* - RPMA_E_INVAL - mr or desc_size is NULL
*
* SEE ALSO
* rpma_mr_get_descriptor(3), rpma_mr_reg(3), librpma(7) and
* https://pmem.io/rpma/
*/
int rpma_mr_get_descriptor_size(const struct rpma_mr_local *mr,
size_t *desc_size);
/** 3
* rpma_mr_remote_get_size - get a remote memory region size