1 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
2 /*
3 * Copyright(c) 2016 Intel Corporation.
4 */
5
6 #ifndef DEF_RVTMR_H
7 #define DEF_RVTMR_H
8
9 #include <rdma/rdma_vt.h>
10
11 struct rvt_mr {
12 struct ib_mr ibmr;
13 struct ib_umem *umem;
14 struct rvt_mregion mr; /* must be last */
15 };
16
to_imr(struct ib_mr * ibmr)17 static inline struct rvt_mr *to_imr(struct ib_mr *ibmr)
18 {
19 return container_of(ibmr, struct rvt_mr, ibmr);
20 }
21
22 int rvt_driver_mr_init(struct rvt_dev_info *rdi);
23 void rvt_mr_exit(struct rvt_dev_info *rdi);
24
25 /* Mem Regions */
26 struct ib_mr *rvt_get_dma_mr(struct ib_pd *pd, int acc);
27 struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
28 u64 virt_addr, int mr_access_flags,
29 struct ib_udata *udata);
30 int rvt_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
31 struct ib_mr *rvt_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
32 u32 max_num_sg);
33 int rvt_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
34 int sg_nents, unsigned int *sg_offset);
35
36 #endif /* DEF_RVTMR_H */
37