Lines Matching +full:protection +full:- +full:domain
2 * Copyright (c) 2012-2016 VMware, Inc. All rights reserved.
7 * 2-Clause License. This program is distributed in the hope that it
11 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
17 * The BSD 2-Clause License
23 * - Redistributions of source code must retain the above
27 * - Redistributions in binary form must reproduce the above
52 * pvrdma_get_dma_mr - get a DMA memory region
53 * @pd: protection domain
60 struct pvrdma_dev *dev = to_vdev(pd->device); in pvrdma_get_dma_mr()
70 dev_warn(&dev->pdev->dev, in pvrdma_get_dma_mr()
72 return ERR_PTR(-EOPNOTSUPP); in pvrdma_get_dma_mr()
77 return ERR_PTR(-ENOMEM); in pvrdma_get_dma_mr()
80 cmd->hdr.cmd = PVRDMA_CMD_CREATE_MR; in pvrdma_get_dma_mr()
81 cmd->pd_handle = to_vpd(pd)->pd_handle; in pvrdma_get_dma_mr()
82 cmd->access_flags = acc; in pvrdma_get_dma_mr()
83 cmd->flags = PVRDMA_MR_FLAG_DMA; in pvrdma_get_dma_mr()
87 dev_warn(&dev->pdev->dev, in pvrdma_get_dma_mr()
93 mr->mmr.mr_handle = resp->mr_handle; in pvrdma_get_dma_mr()
94 mr->ibmr.lkey = resp->lkey; in pvrdma_get_dma_mr()
95 mr->ibmr.rkey = resp->rkey; in pvrdma_get_dma_mr()
97 return &mr->ibmr; in pvrdma_get_dma_mr()
101 * pvrdma_reg_user_mr - register a userspace memory region
102 * @pd: protection domain
115 struct pvrdma_dev *dev = to_vdev(pd->device); in pvrdma_reg_user_mr()
124 if (length == 0 || length > dev->dsr->caps.max_mr_size) { in pvrdma_reg_user_mr()
125 dev_warn(&dev->pdev->dev, "invalid mem region length\n"); in pvrdma_reg_user_mr()
126 return ERR_PTR(-EINVAL); in pvrdma_reg_user_mr()
129 umem = ib_umem_get(pd->device, start, length, access_flags); in pvrdma_reg_user_mr()
131 dev_warn(&dev->pdev->dev, in pvrdma_reg_user_mr()
138 dev_warn(&dev->pdev->dev, "overflow %d pages in mem region\n", in pvrdma_reg_user_mr()
140 ret = -EINVAL; in pvrdma_reg_user_mr()
146 ret = -ENOMEM; in pvrdma_reg_user_mr()
150 mr->mmr.iova = virt_addr; in pvrdma_reg_user_mr()
151 mr->mmr.size = length; in pvrdma_reg_user_mr()
152 mr->umem = umem; in pvrdma_reg_user_mr()
154 ret = pvrdma_page_dir_init(dev, &mr->pdir, npages, false); in pvrdma_reg_user_mr()
156 dev_warn(&dev->pdev->dev, in pvrdma_reg_user_mr()
161 ret = pvrdma_page_dir_insert_umem(&mr->pdir, mr->umem, 0); in pvrdma_reg_user_mr()
166 cmd->hdr.cmd = PVRDMA_CMD_CREATE_MR; in pvrdma_reg_user_mr()
167 cmd->start = start; in pvrdma_reg_user_mr()
168 cmd->length = length; in pvrdma_reg_user_mr()
169 cmd->pd_handle = to_vpd(pd)->pd_handle; in pvrdma_reg_user_mr()
170 cmd->access_flags = access_flags; in pvrdma_reg_user_mr()
171 cmd->nchunks = npages; in pvrdma_reg_user_mr()
172 cmd->pdir_dma = mr->pdir.dir_dma; in pvrdma_reg_user_mr()
176 dev_warn(&dev->pdev->dev, in pvrdma_reg_user_mr()
181 mr->mmr.mr_handle = resp->mr_handle; in pvrdma_reg_user_mr()
182 mr->ibmr.lkey = resp->lkey; in pvrdma_reg_user_mr()
183 mr->ibmr.rkey = resp->rkey; in pvrdma_reg_user_mr()
185 return &mr->ibmr; in pvrdma_reg_user_mr()
188 pvrdma_page_dir_cleanup(dev, &mr->pdir); in pvrdma_reg_user_mr()
197 * pvrdma_alloc_mr - allocate a memory region
198 * @pd: protection domain
207 struct pvrdma_dev *dev = to_vdev(pd->device); in pvrdma_alloc_mr()
218 return ERR_PTR(-EINVAL); in pvrdma_alloc_mr()
222 return ERR_PTR(-ENOMEM); in pvrdma_alloc_mr()
224 mr->pages = kzalloc(size, GFP_KERNEL); in pvrdma_alloc_mr()
225 if (!mr->pages) { in pvrdma_alloc_mr()
226 ret = -ENOMEM; in pvrdma_alloc_mr()
230 ret = pvrdma_page_dir_init(dev, &mr->pdir, max_num_sg, false); in pvrdma_alloc_mr()
232 dev_warn(&dev->pdev->dev, in pvrdma_alloc_mr()
234 ret = -ENOMEM; in pvrdma_alloc_mr()
239 cmd->hdr.cmd = PVRDMA_CMD_CREATE_MR; in pvrdma_alloc_mr()
240 cmd->pd_handle = to_vpd(pd)->pd_handle; in pvrdma_alloc_mr()
241 cmd->access_flags = 0; in pvrdma_alloc_mr()
242 cmd->flags = PVRDMA_MR_FLAG_FRMR; in pvrdma_alloc_mr()
243 cmd->nchunks = max_num_sg; in pvrdma_alloc_mr()
247 dev_warn(&dev->pdev->dev, in pvrdma_alloc_mr()
252 mr->max_pages = max_num_sg; in pvrdma_alloc_mr()
253 mr->mmr.mr_handle = resp->mr_handle; in pvrdma_alloc_mr()
254 mr->ibmr.lkey = resp->lkey; in pvrdma_alloc_mr()
255 mr->ibmr.rkey = resp->rkey; in pvrdma_alloc_mr()
256 mr->page_shift = PAGE_SHIFT; in pvrdma_alloc_mr()
257 mr->umem = NULL; in pvrdma_alloc_mr()
259 return &mr->ibmr; in pvrdma_alloc_mr()
262 pvrdma_page_dir_cleanup(dev, &mr->pdir); in pvrdma_alloc_mr()
264 kfree(mr->pages); in pvrdma_alloc_mr()
271 * pvrdma_dereg_mr - deregister a memory region
280 struct pvrdma_dev *dev = to_vdev(ibmr->device); in pvrdma_dereg_mr()
286 cmd->hdr.cmd = PVRDMA_CMD_DESTROY_MR; in pvrdma_dereg_mr()
287 cmd->mr_handle = mr->mmr.mr_handle; in pvrdma_dereg_mr()
290 dev_warn(&dev->pdev->dev, in pvrdma_dereg_mr()
293 pvrdma_page_dir_cleanup(dev, &mr->pdir); in pvrdma_dereg_mr()
294 ib_umem_release(mr->umem); in pvrdma_dereg_mr()
296 kfree(mr->pages); in pvrdma_dereg_mr()
306 if (mr->npages == mr->max_pages) in pvrdma_set_page()
307 return -ENOMEM; in pvrdma_set_page()
309 mr->pages[mr->npages++] = addr; in pvrdma_set_page()
317 struct pvrdma_dev *dev = to_vdev(ibmr->device); in pvrdma_map_mr_sg()
320 mr->npages = 0; in pvrdma_map_mr_sg()
324 dev_warn(&dev->pdev->dev, "could not map sg to pages\n"); in pvrdma_map_mr_sg()