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 #include <rdma/vmw_pvrdma-abi.h>
58 * pvrdma_query_device - query device
71 if (uhw->inlen || uhw->outlen) in pvrdma_query_device()
72 return -EINVAL; in pvrdma_query_device()
74 props->fw_ver = dev->dsr->caps.fw_ver; in pvrdma_query_device()
75 props->sys_image_guid = dev->dsr->caps.sys_image_guid; in pvrdma_query_device()
76 props->max_mr_size = dev->dsr->caps.max_mr_size; in pvrdma_query_device()
77 props->page_size_cap = dev->dsr->caps.page_size_cap; in pvrdma_query_device()
78 props->vendor_id = dev->dsr->caps.vendor_id; in pvrdma_query_device()
79 props->vendor_part_id = dev->pdev->device; in pvrdma_query_device()
80 props->hw_ver = dev->dsr->caps.hw_ver; in pvrdma_query_device()
81 props->max_qp = dev->dsr->caps.max_qp; in pvrdma_query_device()
82 props->max_qp_wr = dev->dsr->caps.max_qp_wr; in pvrdma_query_device()
83 props->device_cap_flags = dev->dsr->caps.device_cap_flags; in pvrdma_query_device()
84 props->max_send_sge = dev->dsr->caps.max_sge; in pvrdma_query_device()
85 props->max_recv_sge = dev->dsr->caps.max_sge; in pvrdma_query_device()
86 props->max_sge_rd = PVRDMA_GET_CAP(dev, dev->dsr->caps.max_sge, in pvrdma_query_device()
87 dev->dsr->caps.max_sge_rd); in pvrdma_query_device()
88 props->max_srq = dev->dsr->caps.max_srq; in pvrdma_query_device()
89 props->max_srq_wr = dev->dsr->caps.max_srq_wr; in pvrdma_query_device()
90 props->max_srq_sge = dev->dsr->caps.max_srq_sge; in pvrdma_query_device()
91 props->max_cq = dev->dsr->caps.max_cq; in pvrdma_query_device()
92 props->max_cqe = dev->dsr->caps.max_cqe; in pvrdma_query_device()
93 props->max_mr = dev->dsr->caps.max_mr; in pvrdma_query_device()
94 props->max_pd = dev->dsr->caps.max_pd; in pvrdma_query_device()
95 props->max_qp_rd_atom = dev->dsr->caps.max_qp_rd_atom; in pvrdma_query_device()
96 props->max_qp_init_rd_atom = dev->dsr->caps.max_qp_init_rd_atom; in pvrdma_query_device()
97 props->atomic_cap = in pvrdma_query_device()
98 dev->dsr->caps.atomic_ops & in pvrdma_query_device()
101 props->masked_atomic_cap = props->atomic_cap; in pvrdma_query_device()
102 props->max_ah = dev->dsr->caps.max_ah; in pvrdma_query_device()
103 props->max_pkeys = dev->dsr->caps.max_pkeys; in pvrdma_query_device()
104 props->local_ca_ack_delay = dev->dsr->caps.local_ca_ack_delay; in pvrdma_query_device()
105 if ((dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_LOCAL_INV) && in pvrdma_query_device()
106 (dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_REMOTE_INV) && in pvrdma_query_device()
107 (dev->dsr->caps.bmme_flags & PVRDMA_BMME_FLAG_FAST_REG_WR)) { in pvrdma_query_device()
108 props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; in pvrdma_query_device()
109 props->max_fast_reg_page_list_len = PVRDMA_GET_CAP(dev, in pvrdma_query_device()
111 dev->dsr->caps.max_fast_reg_page_list_len); in pvrdma_query_device()
114 props->device_cap_flags |= IB_DEVICE_PORT_ACTIVE_EVENT | in pvrdma_query_device()
121 * pvrdma_query_port - query device port attributes
139 cmd->hdr.cmd = PVRDMA_CMD_QUERY_PORT; in pvrdma_query_port()
140 cmd->port_num = port; in pvrdma_query_port()
144 dev_warn(&dev->pdev->dev, in pvrdma_query_port()
151 props->state = pvrdma_port_state_to_ib(resp->attrs.state); in pvrdma_query_port()
152 props->max_mtu = pvrdma_mtu_to_ib(resp->attrs.max_mtu); in pvrdma_query_port()
153 props->active_mtu = pvrdma_mtu_to_ib(resp->attrs.active_mtu); in pvrdma_query_port()
154 props->gid_tbl_len = resp->attrs.gid_tbl_len; in pvrdma_query_port()
155 props->port_cap_flags = in pvrdma_query_port()
156 pvrdma_port_cap_flags_to_ib(resp->attrs.port_cap_flags); in pvrdma_query_port()
157 props->port_cap_flags |= IB_PORT_CM_SUP; in pvrdma_query_port()
158 props->ip_gids = true; in pvrdma_query_port()
159 props->max_msg_sz = resp->attrs.max_msg_sz; in pvrdma_query_port()
160 props->bad_pkey_cntr = resp->attrs.bad_pkey_cntr; in pvrdma_query_port()
161 props->qkey_viol_cntr = resp->attrs.qkey_viol_cntr; in pvrdma_query_port()
162 props->pkey_tbl_len = resp->attrs.pkey_tbl_len; in pvrdma_query_port()
163 props->lid = resp->attrs.lid; in pvrdma_query_port()
164 props->sm_lid = resp->attrs.sm_lid; in pvrdma_query_port()
165 props->lmc = resp->attrs.lmc; in pvrdma_query_port()
166 props->max_vl_num = resp->attrs.max_vl_num; in pvrdma_query_port()
167 props->sm_sl = resp->attrs.sm_sl; in pvrdma_query_port()
168 props->subnet_timeout = resp->attrs.subnet_timeout; in pvrdma_query_port()
169 props->init_type_reply = resp->attrs.init_type_reply; in pvrdma_query_port()
170 props->active_width = pvrdma_port_width_to_ib(resp->attrs.active_width); in pvrdma_query_port()
171 props->active_speed = pvrdma_port_speed_to_ib(resp->attrs.active_speed); in pvrdma_query_port()
172 props->phys_state = resp->attrs.phys_state; in pvrdma_query_port()
178 * pvrdma_query_gid - query device gid
191 if (index >= dev->dsr->caps.gid_tbl_len) in pvrdma_query_gid()
192 return -EINVAL; in pvrdma_query_gid()
194 memcpy(gid, &dev->sgid_tbl[index], sizeof(union ib_gid)); in pvrdma_query_gid()
200 * pvrdma_query_pkey - query device port's P_Key table
217 cmd->hdr.cmd = PVRDMA_CMD_QUERY_PKEY; in pvrdma_query_pkey()
218 cmd->port_num = port; in pvrdma_query_pkey()
219 cmd->index = index; in pvrdma_query_pkey()
224 dev_warn(&to_vdev(ibdev)->pdev->dev, in pvrdma_query_pkey()
247 dev_warn(&to_vdev(ibdev)->pdev->dev, in pvrdma_modify_device()
249 return -EOPNOTSUPP; in pvrdma_modify_device()
253 spin_lock_irqsave(&to_vdev(ibdev)->desc_lock, flags); in pvrdma_modify_device()
254 memcpy(ibdev->node_desc, props->node_desc, 64); in pvrdma_modify_device()
255 spin_unlock_irqrestore(&to_vdev(ibdev)->desc_lock, flags); in pvrdma_modify_device()
259 mutex_lock(&to_vdev(ibdev)->port_mutex); in pvrdma_modify_device()
260 to_vdev(ibdev)->sys_image_guid = in pvrdma_modify_device()
261 cpu_to_be64(props->sys_image_guid); in pvrdma_modify_device()
262 mutex_unlock(&to_vdev(ibdev)->port_mutex); in pvrdma_modify_device()
269 * pvrdma_modify_port - modify device port attributes
285 dev_warn(&vdev->pdev->dev, in pvrdma_modify_port()
287 return -EOPNOTSUPP; in pvrdma_modify_port()
290 mutex_lock(&vdev->port_mutex); in pvrdma_modify_port()
295 vdev->port_cap_mask |= props->set_port_cap_mask; in pvrdma_modify_port()
296 vdev->port_cap_mask &= ~props->clr_port_cap_mask; in pvrdma_modify_port()
299 vdev->ib_active = false; in pvrdma_modify_port()
302 mutex_unlock(&vdev->port_mutex); in pvrdma_modify_port()
307 * pvrdma_alloc_ucontext - allocate ucontext
315 struct ib_device *ibdev = uctx->device; in pvrdma_alloc_ucontext()
325 if (!vdev->ib_active) in pvrdma_alloc_ucontext()
326 return -EAGAIN; in pvrdma_alloc_ucontext()
328 context->dev = vdev; in pvrdma_alloc_ucontext()
329 ret = pvrdma_uar_alloc(vdev, &context->uar); in pvrdma_alloc_ucontext()
331 return -ENOMEM; in pvrdma_alloc_ucontext()
334 if (vdev->dsr_version < PVRDMA_PPN64_VERSION) in pvrdma_alloc_ucontext()
335 cmd->pfn = context->uar.pfn; in pvrdma_alloc_ucontext()
337 cmd->pfn64 = context->uar.pfn; in pvrdma_alloc_ucontext()
339 cmd->hdr.cmd = PVRDMA_CMD_CREATE_UC; in pvrdma_alloc_ucontext()
342 dev_warn(&vdev->pdev->dev, in pvrdma_alloc_ucontext()
347 context->ctx_handle = resp->ctx_handle; in pvrdma_alloc_ucontext()
350 uresp.qp_tab_size = vdev->dsr->caps.max_qp; in pvrdma_alloc_ucontext()
353 pvrdma_uar_free(vdev, &context->uar); in pvrdma_alloc_ucontext()
354 pvrdma_dealloc_ucontext(&context->ibucontext); in pvrdma_alloc_ucontext()
355 return -EFAULT; in pvrdma_alloc_ucontext()
361 pvrdma_uar_free(vdev, &context->uar); in pvrdma_alloc_ucontext()
366 * pvrdma_dealloc_ucontext - deallocate ucontext
376 cmd->hdr.cmd = PVRDMA_CMD_DESTROY_UC; in pvrdma_dealloc_ucontext()
377 cmd->ctx_handle = context->ctx_handle; in pvrdma_dealloc_ucontext()
379 ret = pvrdma_cmd_post(context->dev, &req, NULL, 0); in pvrdma_dealloc_ucontext()
381 dev_warn(&context->dev->pdev->dev, in pvrdma_dealloc_ucontext()
385 pvrdma_uar_free(to_vdev(ibcontext->device), &context->uar); in pvrdma_dealloc_ucontext()
389 * pvrdma_mmap - create mmap region
398 unsigned long start = vma->vm_start; in pvrdma_mmap()
399 unsigned long size = vma->vm_end - vma->vm_start; in pvrdma_mmap()
400 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; in pvrdma_mmap()
402 dev_dbg(&context->dev->pdev->dev, "create mmap region\n"); in pvrdma_mmap()
405 dev_warn(&context->dev->pdev->dev, in pvrdma_mmap()
407 return -EINVAL; in pvrdma_mmap()
412 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); in pvrdma_mmap()
413 if (io_remap_pfn_range(vma, start, context->uar.pfn, size, in pvrdma_mmap()
414 vma->vm_page_prot)) in pvrdma_mmap()
415 return -EAGAIN; in pvrdma_mmap()
421 * pvrdma_alloc_pd - allocate protection domain
425 * @return: the ib_pd protection domain pointer on success, otherwise errno.
429 struct ib_device *ibdev = ibpd->device; in pvrdma_alloc_pd()
442 if (!atomic_add_unless(&dev->num_pds, 1, dev->dsr->caps.max_pd)) in pvrdma_alloc_pd()
443 return -ENOMEM; in pvrdma_alloc_pd()
445 cmd->hdr.cmd = PVRDMA_CMD_CREATE_PD; in pvrdma_alloc_pd()
446 cmd->ctx_handle = context ? context->ctx_handle : 0; in pvrdma_alloc_pd()
449 dev_warn(&dev->pdev->dev, in pvrdma_alloc_pd()
450 "failed to allocate protection domain, error: %d\n", in pvrdma_alloc_pd()
455 pd->privileged = !udata; in pvrdma_alloc_pd()
456 pd->pd_handle = resp->pd_handle; in pvrdma_alloc_pd()
457 pd->pdn = resp->pd_handle; in pvrdma_alloc_pd()
458 pd_resp.pdn = resp->pd_handle; in pvrdma_alloc_pd()
462 dev_warn(&dev->pdev->dev, in pvrdma_alloc_pd()
463 "failed to copy back protection domain\n"); in pvrdma_alloc_pd()
464 pvrdma_dealloc_pd(&pd->ibpd, udata); in pvrdma_alloc_pd()
465 return -EFAULT; in pvrdma_alloc_pd()
473 atomic_dec(&dev->num_pds); in pvrdma_alloc_pd()
478 * pvrdma_dealloc_pd - deallocate protection domain
479 * @pd: the protection domain to be released
486 struct pvrdma_dev *dev = to_vdev(pd->device); in pvrdma_dealloc_pd()
491 cmd->hdr.cmd = PVRDMA_CMD_DESTROY_PD; in pvrdma_dealloc_pd()
492 cmd->pd_handle = to_vpd(pd)->pd_handle; in pvrdma_dealloc_pd()
496 dev_warn(&dev->pdev->dev, in pvrdma_dealloc_pd()
497 "could not dealloc protection domain, error: %d\n", in pvrdma_dealloc_pd()
500 atomic_dec(&dev->num_pds); in pvrdma_dealloc_pd()
505 * pvrdma_create_ah - create an address handle
515 struct rdma_ah_attr *ah_attr = init_attr->ah_attr; in pvrdma_create_ah()
516 struct pvrdma_dev *dev = to_vdev(ibah->device); in pvrdma_create_ah()
522 return -EINVAL; in pvrdma_create_ah()
525 if ((ah_attr->type != RDMA_AH_ATTR_TYPE_ROCE) || in pvrdma_create_ah()
526 rdma_is_multicast_addr((struct in6_addr *)grh->dgid.raw)) in pvrdma_create_ah()
527 return -EINVAL; in pvrdma_create_ah()
529 if (!atomic_add_unless(&dev->num_ahs, 1, dev->dsr->caps.max_ah)) in pvrdma_create_ah()
530 return -ENOMEM; in pvrdma_create_ah()
532 ah->av.port_pd = to_vpd(ibah->pd)->pd_handle | (port_num << 24); in pvrdma_create_ah()
533 ah->av.src_path_bits = rdma_ah_get_path_bits(ah_attr); in pvrdma_create_ah()
534 ah->av.src_path_bits |= 0x80; in pvrdma_create_ah()
535 ah->av.gid_index = grh->sgid_index; in pvrdma_create_ah()
536 ah->av.hop_limit = grh->hop_limit; in pvrdma_create_ah()
537 ah->av.sl_tclass_flowlabel = (grh->traffic_class << 20) | in pvrdma_create_ah()
538 grh->flow_label; in pvrdma_create_ah()
539 memcpy(ah->av.dgid, grh->dgid.raw, 16); in pvrdma_create_ah()
540 memcpy(ah->av.dmac, ah_attr->roce.dmac, ETH_ALEN); in pvrdma_create_ah()
546 * pvrdma_destroy_ah - destroy an address handle
553 struct pvrdma_dev *dev = to_vdev(ah->device); in pvrdma_destroy_ah()
555 atomic_dec(&dev->num_ahs); in pvrdma_destroy_ah()