]>
Commit | Line | Data |
---|---|---|
a4b75251 TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
2 | /* Copyright 2016-2020, Intel Corporation */ | |
3 | ||
4 | /* | |
5 | * librpmem.h -- definitions of librpmem entry points (EXPERIMENTAL) | |
6 | * | |
7 | * This library provides low-level support for remote access to persistent | |
8 | * memory utilizing RDMA-capable RNICs. | |
9 | * | |
10 | * See librpmem(7) for details. | |
11 | */ | |
12 | ||
13 | #ifndef LIBRPMEM_H | |
14 | #define LIBRPMEM_H 1 | |
15 | ||
16 | #include <sys/types.h> | |
17 | #include <stdint.h> | |
18 | ||
19 | #ifdef __cplusplus | |
20 | extern "C" { | |
21 | #endif | |
22 | ||
23 | typedef struct rpmem_pool RPMEMpool; | |
24 | ||
25 | #define RPMEM_POOL_HDR_SIG_LEN 8 | |
26 | #define RPMEM_POOL_HDR_UUID_LEN 16 /* uuid byte length */ | |
27 | #define RPMEM_POOL_USER_FLAGS_LEN 16 | |
28 | ||
29 | struct rpmem_pool_attr { | |
30 | char signature[RPMEM_POOL_HDR_SIG_LEN]; /* pool signature */ | |
31 | uint32_t major; /* format major version number */ | |
32 | uint32_t compat_features; /* mask: compatible "may" features */ | |
33 | uint32_t incompat_features; /* mask: "must support" features */ | |
34 | uint32_t ro_compat_features; /* mask: force RO if unsupported */ | |
35 | unsigned char poolset_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* pool uuid */ | |
36 | unsigned char uuid[RPMEM_POOL_HDR_UUID_LEN]; /* first part uuid */ | |
37 | unsigned char next_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* next pool uuid */ | |
38 | unsigned char prev_uuid[RPMEM_POOL_HDR_UUID_LEN]; /* prev pool uuid */ | |
39 | unsigned char user_flags[RPMEM_POOL_USER_FLAGS_LEN]; /* user flags */ | |
40 | }; | |
41 | ||
42 | RPMEMpool *rpmem_create(const char *target, const char *pool_set_name, | |
43 | void *pool_addr, size_t pool_size, unsigned *nlanes, | |
44 | const struct rpmem_pool_attr *create_attr); | |
45 | ||
46 | RPMEMpool *rpmem_open(const char *target, const char *pool_set_name, | |
47 | void *pool_addr, size_t pool_size, unsigned *nlanes, | |
48 | struct rpmem_pool_attr *open_attr); | |
49 | ||
50 | int rpmem_set_attr(RPMEMpool *rpp, const struct rpmem_pool_attr *attr); | |
51 | ||
52 | int rpmem_close(RPMEMpool *rpp); | |
53 | ||
54 | #define RPMEM_PERSIST_RELAXED (1U << 0) | |
55 | #define RPMEM_FLUSH_RELAXED (1U << 0) | |
56 | ||
57 | int rpmem_flush(RPMEMpool *rpp, size_t offset, size_t length, unsigned lane, | |
58 | unsigned flags); | |
59 | int rpmem_drain(RPMEMpool *rpp, unsigned lane, unsigned flags); | |
60 | ||
61 | int rpmem_persist(RPMEMpool *rpp, size_t offset, size_t length, | |
62 | unsigned lane, unsigned flags); | |
63 | int rpmem_read(RPMEMpool *rpp, void *buff, size_t offset, size_t length, | |
64 | unsigned lane); | |
65 | int rpmem_deep_persist(RPMEMpool *rpp, size_t offset, size_t length, | |
66 | unsigned lane); | |
67 | ||
68 | #define RPMEM_REMOVE_FORCE 0x1 | |
69 | #define RPMEM_REMOVE_POOL_SET 0x2 | |
70 | ||
71 | int rpmem_remove(const char *target, const char *pool_set, int flags); | |
72 | ||
73 | /* | |
74 | * RPMEM_MAJOR_VERSION and RPMEM_MINOR_VERSION provide the current version of | |
75 | * the librpmem API as provided by this header file. Applications can verify | |
76 | * that the version available at run-time is compatible with the version used | |
77 | * at compile-time by passing these defines to rpmem_check_version(). | |
78 | */ | |
79 | #define RPMEM_MAJOR_VERSION 1 | |
80 | #define RPMEM_MINOR_VERSION 3 | |
81 | const char *rpmem_check_version(unsigned major_required, | |
82 | unsigned minor_required); | |
83 | ||
84 | const char *rpmem_errormsg(void); | |
85 | ||
86 | /* minimum size of a pool */ | |
87 | #define RPMEM_MIN_POOL ((size_t)(1024 * 8)) /* 8 KB */ | |
88 | ||
89 | /* | |
90 | * This limit is set arbitrary to incorporate a pool header and required | |
91 | * alignment plus supply. | |
92 | */ | |
93 | #define RPMEM_MIN_PART ((size_t)(1024 * 1024 * 2)) /* 2 MiB */ | |
94 | ||
95 | #ifdef __cplusplus | |
96 | } | |
97 | #endif | |
98 | #endif /* librpmem.h */ |