xref: /linux/include/rdma/frmr_pools.h (revision 4b0b946019e7376752456380b67e54eea2f10a7c)
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2  *
3  * Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4  */
5 
6 #ifndef FRMR_POOLS_H
7 #define FRMR_POOLS_H
8 
9 #include <linux/types.h>
10 #include <asm/page.h>
11 
12 struct ib_device;
13 struct ib_mr;
14 
15 struct ib_frmr_key {
16 	u64 vendor_key;
17 	/* A pool with non-zero kernel_vendor_key is a kernel-only pool. */
18 	u64 kernel_vendor_key;
19 	size_t num_dma_blocks;
20 	int access_flags;
21 	u8 ats:1;
22 };
23 
24 struct ib_frmr_pool_ops {
25 	int (*create_frmrs)(struct ib_device *device, struct ib_frmr_key *key,
26 			    u32 *handles, u32 count);
27 	void (*destroy_frmrs)(struct ib_device *device, u32 *handles,
28 			      u32 count);
29 	int (*build_key)(struct ib_device *device, const struct ib_frmr_key *in,
30 			 struct ib_frmr_key *out);
31 };
32 
33 int ib_frmr_pools_init(struct ib_device *device,
34 		       const struct ib_frmr_pool_ops *pool_ops);
35 void ib_frmr_pools_cleanup(struct ib_device *device);
36 int ib_frmr_pool_pop(struct ib_device *device, struct ib_mr *mr);
37 int ib_frmr_pool_push(struct ib_device *device, struct ib_mr *mr);
38 
39 #endif /* FRMR_POOLS_H */
40