2 * Copyright(c) 2016 Intel Corporation.
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
24 * - Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * - Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
30 * - Neither the name of Intel Corporation nor the names of its
31 * contributors may be used to endorse or promote products derived
32 * from this software without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 #include <linux/slab.h>
49 #include <linux/vmalloc.h>
50 #include <rdma/ib_umem.h>
51 #include <rdma/rdma_vt.h>
57 * rvt_driver_mr_init - Init MR resources per driver
58 * @rdi: rvt dev struct
60 * Do any intilization needed when a driver registers with rdmavt.
62 * Return: 0 on success or errno on failure
64 int rvt_driver_mr_init(struct rvt_dev_info *rdi)
66 unsigned int lkey_table_size = rdi->dparms.lkey_table_size;
71 * The top hfi1_lkey_table_size bits are used to index the
72 * table. The lower 8 bits can be owned by the user (copied from
73 * the LKEY). The remaining bits act as a generation number or tag.
78 spin_lock_init(&rdi->lkey_table.lock);
80 /* ensure generation is at least 4 bits */
81 if (lkey_table_size > RVT_MAX_LKEY_TABLE_BITS) {
82 rvt_pr_warn(rdi, "lkey bits %u too large, reduced to %u\n",
83 lkey_table_size, RVT_MAX_LKEY_TABLE_BITS);
84 rdi->dparms.lkey_table_size = RVT_MAX_LKEY_TABLE_BITS;
85 lkey_table_size = rdi->dparms.lkey_table_size;
87 rdi->lkey_table.max = 1 << lkey_table_size;
88 rdi->lkey_table.shift = 32 - lkey_table_size;
89 lk_tab_size = rdi->lkey_table.max * sizeof(*rdi->lkey_table.table);
90 rdi->lkey_table.table = (struct rvt_mregion __rcu **)
91 vmalloc_node(lk_tab_size, rdi->dparms.node);
92 if (!rdi->lkey_table.table)
95 RCU_INIT_POINTER(rdi->dma_mr, NULL);
96 for (i = 0; i < rdi->lkey_table.max; i++)
97 RCU_INIT_POINTER(rdi->lkey_table.table[i], NULL);
99 rdi->dparms.props.max_mr = rdi->lkey_table.max;
104 *rvt_mr_exit: clean up MR
105 *@rdi: rvt dev structure
107 * called when drivers have unregistered or perhaps failed to register with us
109 void rvt_mr_exit(struct rvt_dev_info *rdi)
112 rvt_pr_err(rdi, "DMA MR not null!\n");
114 vfree(rdi->lkey_table.table);
117 static void rvt_deinit_mregion(struct rvt_mregion *mr)
124 percpu_ref_exit(&mr->refcount);
127 static void __rvt_mregion_complete(struct percpu_ref *ref)
129 struct rvt_mregion *mr = container_of(ref, struct rvt_mregion,
135 static int rvt_init_mregion(struct rvt_mregion *mr, struct ib_pd *pd,
136 int count, unsigned int percpu_flags)
139 struct rvt_dev_info *dev = ib_to_rvt(pd->device);
142 m = (count + RVT_SEGSZ - 1) / RVT_SEGSZ;
144 mr->map[i] = kzalloc_node(sizeof(*mr->map[0]), GFP_KERNEL,
150 init_completion(&mr->comp);
151 /* count returning the ptr to user */
152 if (percpu_ref_init(&mr->refcount, &__rvt_mregion_complete,
153 percpu_flags, GFP_KERNEL))
156 atomic_set(&mr->lkey_invalid, 0);
158 mr->max_segs = count;
161 rvt_deinit_mregion(mr);
166 * rvt_alloc_lkey - allocate an lkey
167 * @mr: memory region that this lkey protects
168 * @dma_region: 0->normal key, 1->restricted DMA key
170 * Returns 0 if successful, otherwise returns -errno.
172 * Increments mr reference count as required.
174 * Sets the lkey field mr for non-dma regions.
177 static int rvt_alloc_lkey(struct rvt_mregion *mr, int dma_region)
183 struct rvt_dev_info *dev = ib_to_rvt(mr->pd->device);
184 struct rvt_lkey_table *rkt = &dev->lkey_table;
187 spin_lock_irqsave(&rkt->lock, flags);
189 /* special case for dma_mr lkey == 0 */
191 struct rvt_mregion *tmr;
193 tmr = rcu_access_pointer(dev->dma_mr);
195 mr->lkey_published = 1;
196 /* Insure published written first */
197 rcu_assign_pointer(dev->dma_mr, mr);
203 /* Find the next available LKEY */
207 if (!rcu_access_pointer(rkt->table[r]))
209 r = (r + 1) & (rkt->max - 1);
213 rkt->next = (r + 1) & (rkt->max - 1);
215 * Make sure lkey is never zero which is reserved to indicate an
220 * bits are capped to ensure enough bits for generation number
222 mr->lkey = (r << (32 - dev->dparms.lkey_table_size)) |
223 ((((1 << (24 - dev->dparms.lkey_table_size)) - 1) & rkt->gen)
229 mr->lkey_published = 1;
230 /* Insure published written first */
231 rcu_assign_pointer(rkt->table[r], mr);
233 spin_unlock_irqrestore(&rkt->lock, flags);
238 spin_unlock_irqrestore(&rkt->lock, flags);
244 * rvt_free_lkey - free an lkey
245 * @mr: mr to free from tables
247 static void rvt_free_lkey(struct rvt_mregion *mr)
252 struct rvt_dev_info *dev = ib_to_rvt(mr->pd->device);
253 struct rvt_lkey_table *rkt = &dev->lkey_table;
256 spin_lock_irqsave(&rkt->lock, flags);
258 if (mr->lkey_published) {
259 mr->lkey_published = 0;
260 /* insure published is written before pointer */
261 rcu_assign_pointer(dev->dma_mr, NULL);
265 if (!mr->lkey_published)
267 r = lkey >> (32 - dev->dparms.lkey_table_size);
268 mr->lkey_published = 0;
269 /* insure published is written before pointer */
270 rcu_assign_pointer(rkt->table[r], NULL);
274 spin_unlock_irqrestore(&rkt->lock, flags);
276 percpu_ref_kill(&mr->refcount);
279 static struct rvt_mr *__rvt_alloc_mr(int count, struct ib_pd *pd)
285 /* Allocate struct plus pointers to first level page tables. */
286 m = (count + RVT_SEGSZ - 1) / RVT_SEGSZ;
287 mr = kzalloc(struct_size(mr, mr.map, m), GFP_KERNEL);
291 rval = rvt_init_mregion(&mr->mr, pd, count, 0);
295 * ib_reg_phys_mr() will initialize mr->ibmr except for
298 rval = rvt_alloc_lkey(&mr->mr, 0);
301 mr->ibmr.lkey = mr->mr.lkey;
302 mr->ibmr.rkey = mr->mr.lkey;
307 rvt_deinit_mregion(&mr->mr);
314 static void __rvt_free_mr(struct rvt_mr *mr)
316 rvt_free_lkey(&mr->mr);
317 rvt_deinit_mregion(&mr->mr);
322 * rvt_get_dma_mr - get a DMA memory region
323 * @pd: protection domain for this memory region
326 * Return: the memory region on success, otherwise returns an errno.
327 * Note that all DMA addresses should be created via the functions in
328 * struct dma_virt_ops.
330 struct ib_mr *rvt_get_dma_mr(struct ib_pd *pd, int acc)
336 if (ibpd_to_rvtpd(pd)->user)
337 return ERR_PTR(-EPERM);
339 mr = kzalloc(sizeof(*mr), GFP_KERNEL);
341 ret = ERR_PTR(-ENOMEM);
345 rval = rvt_init_mregion(&mr->mr, pd, 0, 0);
351 rval = rvt_alloc_lkey(&mr->mr, 1);
357 mr->mr.access_flags = acc;
363 rvt_deinit_mregion(&mr->mr);
370 * rvt_reg_user_mr - register a userspace memory region
371 * @pd: protection domain for this memory region
372 * @start: starting userspace address
373 * @length: length of region to register
374 * @mr_access_flags: access flags for this memory region
375 * @udata: unused by the driver
377 * Return: the memory region on success, otherwise returns an errno.
379 struct ib_mr *rvt_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
380 u64 virt_addr, int mr_access_flags,
381 struct ib_udata *udata)
384 struct ib_umem *umem;
385 struct sg_page_iter sg_iter;
390 return ERR_PTR(-EINVAL);
392 umem = ib_umem_get(pd->device, start, length, mr_access_flags);
396 n = ib_umem_num_pages(umem);
398 mr = __rvt_alloc_mr(n, pd);
400 ret = (struct ib_mr *)mr;
404 mr->mr.user_base = start;
405 mr->mr.iova = virt_addr;
406 mr->mr.length = length;
407 mr->mr.offset = ib_umem_offset(umem);
408 mr->mr.access_flags = mr_access_flags;
411 mr->mr.page_shift = PAGE_SHIFT;
414 for_each_sg_page (umem->sg_head.sgl, &sg_iter, umem->nmap, 0) {
417 vaddr = page_address(sg_page_iter_page(&sg_iter));
419 ret = ERR_PTR(-EINVAL);
422 mr->mr.map[m]->segs[n].vaddr = vaddr;
423 mr->mr.map[m]->segs[n].length = PAGE_SIZE;
424 trace_rvt_mr_user_seg(&mr->mr, m, n, vaddr, PAGE_SIZE);
425 if (++n == RVT_SEGSZ) {
436 ib_umem_release(umem);
442 * rvt_dereg_clean_qp_cb - callback from iterator
444 * @v - the mregion (as u64)
446 * This routine fields the callback for all QPs and
447 * for QPs in the same PD as the MR will call the
448 * rvt_qp_mr_clean() to potentially cleanup references.
450 static void rvt_dereg_clean_qp_cb(struct rvt_qp *qp, u64 v)
452 struct rvt_mregion *mr = (struct rvt_mregion *)v;
454 /* skip PDs that are not ours */
455 if (mr->pd != qp->ibqp.pd)
457 rvt_qp_mr_clean(qp, mr->lkey);
461 * rvt_dereg_clean_qps - find QPs for reference cleanup
462 * @mr - the MR that is being deregistered
464 * This routine iterates RC QPs looking for references
465 * to the lkey noted in mr.
467 static void rvt_dereg_clean_qps(struct rvt_mregion *mr)
469 struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device);
471 rvt_qp_iter(rdi, (u64)mr, rvt_dereg_clean_qp_cb);
475 * rvt_check_refs - check references
477 * @t - the caller identification
479 * This routine checks MRs holding a reference during
480 * when being de-registered.
482 * If the count is non-zero, the code calls a clean routine then
483 * waits for the timeout for the count to zero.
485 static int rvt_check_refs(struct rvt_mregion *mr, const char *t)
487 unsigned long timeout;
488 struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device);
492 rvt_dereg_clean_qps(mr);
493 /* @mr was indexed on rcu protected @lkey_table */
497 timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ);
500 "%s timeout mr %p pd %p lkey %x refcount %ld\n",
501 t, mr, mr->pd, mr->lkey,
502 atomic_long_read(&mr->refcount.count));
510 * rvt_mr_has_lkey - is MR
514 bool rvt_mr_has_lkey(struct rvt_mregion *mr, u32 lkey)
516 return mr && lkey == mr->lkey;
520 * rvt_ss_has_lkey - is mr in sge tests
521 * @ss - the sge state
524 * This code tests for an MR in the indicated
527 bool rvt_ss_has_lkey(struct rvt_sge_state *ss, u32 lkey)
535 rval = rvt_mr_has_lkey(ss->sge.mr, lkey);
537 for (i = 0; !rval && i < ss->num_sge - 1; i++)
538 rval = rvt_mr_has_lkey(ss->sg_list[i].mr, lkey);
543 * rvt_dereg_mr - unregister and free a memory region
544 * @ibmr: the memory region to free
547 * Note that this is called to free MRs created by rvt_get_dma_mr()
548 * or rvt_reg_user_mr().
550 * Returns 0 on success.
552 int rvt_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
554 struct rvt_mr *mr = to_imr(ibmr);
557 rvt_free_lkey(&mr->mr);
559 rvt_put_mr(&mr->mr); /* will set completion if last */
560 ret = rvt_check_refs(&mr->mr, __func__);
563 rvt_deinit_mregion(&mr->mr);
564 ib_umem_release(mr->umem);
571 * rvt_alloc_mr - Allocate a memory region usable with the
572 * @pd: protection domain for this memory region
573 * @mr_type: mem region type
574 * @max_num_sg: Max number of segments allowed
576 * Return: the memory region on success, otherwise return an errno.
578 struct ib_mr *rvt_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
583 if (mr_type != IB_MR_TYPE_MEM_REG)
584 return ERR_PTR(-EINVAL);
586 mr = __rvt_alloc_mr(max_num_sg, pd);
588 return (struct ib_mr *)mr;
594 * rvt_set_page - page assignment function called by ib_sg_to_pages
595 * @ibmr: memory region
596 * @addr: dma address of mapped page
598 * Return: 0 on success
600 static int rvt_set_page(struct ib_mr *ibmr, u64 addr)
602 struct rvt_mr *mr = to_imr(ibmr);
603 u32 ps = 1 << mr->mr.page_shift;
604 u32 mapped_segs = mr->mr.length >> mr->mr.page_shift;
607 if (unlikely(mapped_segs == mr->mr.max_segs))
610 m = mapped_segs / RVT_SEGSZ;
611 n = mapped_segs % RVT_SEGSZ;
612 mr->mr.map[m]->segs[n].vaddr = (void *)addr;
613 mr->mr.map[m]->segs[n].length = ps;
615 trace_rvt_mr_page_seg(&mr->mr, m, n, (void *)addr, ps);
621 * rvt_map_mr_sg - map sg list and set it the memory region
622 * @ibmr: memory region
623 * @sg: dma mapped scatterlist
624 * @sg_nents: number of entries in sg
625 * @sg_offset: offset in bytes into sg
627 * Overwrite rvt_mr length with mr length calculated by ib_sg_to_pages.
629 * Return: number of sg elements mapped to the memory region
631 int rvt_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
632 int sg_nents, unsigned int *sg_offset)
634 struct rvt_mr *mr = to_imr(ibmr);
638 mr->mr.page_shift = PAGE_SHIFT;
639 ret = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, rvt_set_page);
640 mr->mr.user_base = ibmr->iova;
641 mr->mr.iova = ibmr->iova;
642 mr->mr.offset = ibmr->iova - (u64)mr->mr.map[0]->segs[0].vaddr;
643 mr->mr.length = (size_t)ibmr->length;
644 trace_rvt_map_mr_sg(ibmr, sg_nents, sg_offset);
649 * rvt_fast_reg_mr - fast register physical MR
650 * @qp: the queue pair where the work request comes from
651 * @ibmr: the memory region to be registered
652 * @key: updated key for this memory region
653 * @access: access flags for this memory region
655 * Returns 0 on success.
657 int rvt_fast_reg_mr(struct rvt_qp *qp, struct ib_mr *ibmr, u32 key,
660 struct rvt_mr *mr = to_imr(ibmr);
662 if (qp->ibqp.pd != mr->mr.pd)
665 /* not applicable to dma MR or user MR */
666 if (!mr->mr.lkey || mr->umem)
669 if ((key & 0xFFFFFF00) != (mr->mr.lkey & 0xFFFFFF00))
675 mr->mr.access_flags = access;
676 mr->mr.iova = ibmr->iova;
677 atomic_set(&mr->mr.lkey_invalid, 0);
681 EXPORT_SYMBOL(rvt_fast_reg_mr);
684 * rvt_invalidate_rkey - invalidate an MR rkey
685 * @qp: queue pair associated with the invalidate op
686 * @rkey: rkey to invalidate
688 * Returns 0 on success.
690 int rvt_invalidate_rkey(struct rvt_qp *qp, u32 rkey)
692 struct rvt_dev_info *dev = ib_to_rvt(qp->ibqp.device);
693 struct rvt_lkey_table *rkt = &dev->lkey_table;
694 struct rvt_mregion *mr;
700 mr = rcu_dereference(
701 rkt->table[(rkey >> (32 - dev->dparms.lkey_table_size))]);
702 if (unlikely(!mr || mr->lkey != rkey || qp->ibqp.pd != mr->pd))
705 atomic_set(&mr->lkey_invalid, 1);
713 EXPORT_SYMBOL(rvt_invalidate_rkey);
716 * rvt_sge_adjacent - is isge compressible
717 * @last_sge: last outgoing SGE written
720 * If adjacent will update last_sge to add length.
722 * Return: true if isge is adjacent to last sge
724 static inline bool rvt_sge_adjacent(struct rvt_sge *last_sge,
727 if (last_sge && sge->lkey == last_sge->mr->lkey &&
728 ((uint64_t)(last_sge->vaddr + last_sge->length) == sge->addr)) {
730 if (unlikely((sge->addr - last_sge->mr->user_base +
731 sge->length > last_sge->mr->length)))
732 return false; /* overrun, caller will catch */
734 last_sge->length += sge->length;
736 last_sge->sge_length += sge->length;
737 trace_rvt_sge_adjacent(last_sge, sge);
744 * rvt_lkey_ok - check IB SGE for validity and initialize
745 * @rkt: table containing lkey to check SGE against
746 * @pd: protection domain
747 * @isge: outgoing internal SGE
748 * @last_sge: last outgoing SGE written
752 * Check the IB SGE for validity and initialize our internal version
755 * Increments the reference count when a new sge is stored.
757 * Return: 0 if compressed, 1 if added , otherwise returns -errno.
759 int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
760 struct rvt_sge *isge, struct rvt_sge *last_sge,
761 struct ib_sge *sge, int acc)
763 struct rvt_mregion *mr;
768 * We use LKEY == zero for kernel virtual addresses
769 * (see rvt_get_dma_mr() and dma_virt_ops).
771 if (sge->lkey == 0) {
772 struct rvt_dev_info *dev = ib_to_rvt(pd->ibpd.device);
776 if (rvt_sge_adjacent(last_sge, sge))
779 mr = rcu_dereference(dev->dma_mr);
786 isge->vaddr = (void *)sge->addr;
787 isge->length = sge->length;
788 isge->sge_length = sge->length;
793 if (rvt_sge_adjacent(last_sge, sge))
796 mr = rcu_dereference(rkt->table[sge->lkey >> rkt->shift]);
800 if (!READ_ONCE(mr->lkey_published))
803 if (unlikely(atomic_read(&mr->lkey_invalid) ||
804 mr->lkey != sge->lkey || mr->pd != &pd->ibpd))
807 off = sge->addr - mr->user_base;
808 if (unlikely(sge->addr < mr->user_base ||
809 off + sge->length > mr->length ||
810 (mr->access_flags & acc) != acc))
815 if (mr->page_shift) {
817 * page sizes are uniform power of 2 so no loop is necessary
818 * entries_spanned_by_off is the number of times the loop below
819 * would have executed.
821 size_t entries_spanned_by_off;
823 entries_spanned_by_off = off >> mr->page_shift;
824 off -= (entries_spanned_by_off << mr->page_shift);
825 m = entries_spanned_by_off / RVT_SEGSZ;
826 n = entries_spanned_by_off % RVT_SEGSZ;
830 while (off >= mr->map[m]->segs[n].length) {
831 off -= mr->map[m]->segs[n].length;
833 if (n >= RVT_SEGSZ) {
840 isge->vaddr = mr->map[m]->segs[n].vaddr + off;
841 isge->length = mr->map[m]->segs[n].length - off;
842 isge->sge_length = sge->length;
846 trace_rvt_sge_new(isge, sge);
854 EXPORT_SYMBOL(rvt_lkey_ok);
857 * rvt_rkey_ok - check the IB virtual address, length, and RKEY
858 * @qp: qp for validation
860 * @len: length of data
861 * @vaddr: virtual address to place data
862 * @rkey: rkey to check
865 * Return: 1 if successful, otherwise 0.
867 * increments the reference count upon success
869 int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
870 u32 len, u64 vaddr, u32 rkey, int acc)
872 struct rvt_dev_info *dev = ib_to_rvt(qp->ibqp.device);
873 struct rvt_lkey_table *rkt = &dev->lkey_table;
874 struct rvt_mregion *mr;
879 * We use RKEY == zero for kernel virtual addresses
880 * (see rvt_get_dma_mr() and dma_virt_ops).
884 struct rvt_pd *pd = ibpd_to_rvtpd(qp->ibqp.pd);
885 struct rvt_dev_info *rdi = ib_to_rvt(pd->ibpd.device);
889 mr = rcu_dereference(rdi->dma_mr);
896 sge->vaddr = (void *)vaddr;
898 sge->sge_length = len;
904 mr = rcu_dereference(rkt->table[rkey >> rkt->shift]);
908 /* insure mr read is before test */
909 if (!READ_ONCE(mr->lkey_published))
911 if (unlikely(atomic_read(&mr->lkey_invalid) ||
912 mr->lkey != rkey || qp->ibqp.pd != mr->pd))
915 off = vaddr - mr->iova;
916 if (unlikely(vaddr < mr->iova || off + len > mr->length ||
917 (mr->access_flags & acc) == 0))
922 if (mr->page_shift) {
924 * page sizes are uniform power of 2 so no loop is necessary
925 * entries_spanned_by_off is the number of times the loop below
926 * would have executed.
928 size_t entries_spanned_by_off;
930 entries_spanned_by_off = off >> mr->page_shift;
931 off -= (entries_spanned_by_off << mr->page_shift);
932 m = entries_spanned_by_off / RVT_SEGSZ;
933 n = entries_spanned_by_off % RVT_SEGSZ;
937 while (off >= mr->map[m]->segs[n].length) {
938 off -= mr->map[m]->segs[n].length;
940 if (n >= RVT_SEGSZ) {
947 sge->vaddr = mr->map[m]->segs[n].vaddr + off;
948 sge->length = mr->map[m]->segs[n].length - off;
949 sge->sge_length = len;
960 EXPORT_SYMBOL(rvt_rkey_ok);