vt.c (82ffd0454bd9bd57780966d47bfd56d579dd4fb3) | vt.c (21a428a019c9a6d133e745b529b9bf18c1187e70) |
---|---|
1/* 2 * Copyright(c) 2016 - 2018 Intel Corporation. 3 * 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. 6 * 7 * GPL LICENSE SUMMARY 8 * --- 77 unchanged lines hidden (view full) --- 86 * We also allocate a port array based on the number of ports. 87 * 88 * Return: pointer to allocated rdi 89 */ 90struct rvt_dev_info *rvt_alloc_device(size_t size, int nports) 91{ 92 struct rvt_dev_info *rdi; 93 | 1/* 2 * Copyright(c) 2016 - 2018 Intel Corporation. 3 * 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. 6 * 7 * GPL LICENSE SUMMARY 8 * --- 77 unchanged lines hidden (view full) --- 86 * We also allocate a port array based on the number of ports. 87 * 88 * Return: pointer to allocated rdi 89 */ 90struct rvt_dev_info *rvt_alloc_device(size_t size, int nports) 91{ 92 struct rvt_dev_info *rdi; 93 |
94 rdi = (struct rvt_dev_info *)ib_alloc_device(size); | 94 rdi = container_of(_ib_alloc_device(size), struct rvt_dev_info, ibdev); |
95 if (!rdi) 96 return rdi; 97 98 rdi->ports = kcalloc(nports, 99 sizeof(struct rvt_ibport **), 100 GFP_KERNEL); 101 if (!rdi->ports) 102 ib_dealloc_device(&rdi->ibdev); --- 196 unchanged lines hidden (view full) --- 299 * @ibdev: Verbs IB dev 300 * @udata: User data allocated 301 */ 302static struct ib_ucontext *rvt_alloc_ucontext(struct ib_device *ibdev, 303 struct ib_udata *udata) 304{ 305 struct rvt_ucontext *context; 306 | 95 if (!rdi) 96 return rdi; 97 98 rdi->ports = kcalloc(nports, 99 sizeof(struct rvt_ibport **), 100 GFP_KERNEL); 101 if (!rdi->ports) 102 ib_dealloc_device(&rdi->ibdev); --- 196 unchanged lines hidden (view full) --- 299 * @ibdev: Verbs IB dev 300 * @udata: User data allocated 301 */ 302static struct ib_ucontext *rvt_alloc_ucontext(struct ib_device *ibdev, 303 struct ib_udata *udata) 304{ 305 struct rvt_ucontext *context; 306 |
307 context = kmalloc(sizeof(*context), GFP_KERNEL); | 307 context = kzalloc(sizeof(*context), GFP_KERNEL); |
308 if (!context) 309 return ERR_PTR(-ENOMEM); 310 return &context->ibucontext; 311} 312 313/** 314 *rvt_dealloc_ucontext - Free a user context 315 *@context - Free this --- 115 unchanged lines hidden (view full) --- 431 .query_pkey = rvt_query_pkey, 432 .query_port = rvt_query_port, 433 .query_qp = rvt_query_qp, 434 .query_srq = rvt_query_srq, 435 .reg_user_mr = rvt_reg_user_mr, 436 .req_notify_cq = rvt_req_notify_cq, 437 .resize_cq = rvt_resize_cq, 438 .unmap_fmr = rvt_unmap_fmr, | 308 if (!context) 309 return ERR_PTR(-ENOMEM); 310 return &context->ibucontext; 311} 312 313/** 314 *rvt_dealloc_ucontext - Free a user context 315 *@context - Free this --- 115 unchanged lines hidden (view full) --- 431 .query_pkey = rvt_query_pkey, 432 .query_port = rvt_query_port, 433 .query_qp = rvt_query_qp, 434 .query_srq = rvt_query_srq, 435 .reg_user_mr = rvt_reg_user_mr, 436 .req_notify_cq = rvt_req_notify_cq, 437 .resize_cq = rvt_resize_cq, 438 .unmap_fmr = rvt_unmap_fmr, |
439 INIT_RDMA_OBJ_SIZE(ib_pd, rvt_pd, ibpd), |
|
439}; 440 441static noinline int check_support(struct rvt_dev_info *rdi, int verb) 442{ 443 switch (verb) { 444 case MISC: 445 /* 446 * These functions are not part of verbs specifically but are 447 * required for rdmavt to function. 448 */ | 440}; 441 442static noinline int check_support(struct rvt_dev_info *rdi, int verb) 443{ 444 switch (verb) { 445 case MISC: 446 /* 447 * These functions are not part of verbs specifically but are 448 * required for rdmavt to function. 449 */ |
449 if ((!rdi->driver_f.port_callback) || | 450 if ((!rdi->ibdev.ops.init_port) || |
450 (!rdi->driver_f.get_pci_dev)) 451 return -EINVAL; 452 break; 453 454 case MODIFY_DEVICE: 455 /* 456 * rdmavt does not support modify device currently drivers must 457 * provide. --- 181 unchanged lines hidden (view full) --- 639 (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | 640 (1ull << IB_USER_VERBS_CMD_POST_SRQ_RECV); 641 rdi->ibdev.node_type = RDMA_NODE_IB_CA; 642 if (!rdi->ibdev.num_comp_vectors) 643 rdi->ibdev.num_comp_vectors = 1; 644 645 rdi->ibdev.driver_id = driver_id; 646 /* We are now good to announce we exist */ | 451 (!rdi->driver_f.get_pci_dev)) 452 return -EINVAL; 453 break; 454 455 case MODIFY_DEVICE: 456 /* 457 * rdmavt does not support modify device currently drivers must 458 * provide. --- 181 unchanged lines hidden (view full) --- 640 (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) | 641 (1ull << IB_USER_VERBS_CMD_POST_SRQ_RECV); 642 rdi->ibdev.node_type = RDMA_NODE_IB_CA; 643 if (!rdi->ibdev.num_comp_vectors) 644 rdi->ibdev.num_comp_vectors = 1; 645 646 rdi->ibdev.driver_id = driver_id; 647 /* We are now good to announce we exist */ |
647 ret = ib_register_device(&rdi->ibdev, dev_name(&rdi->ibdev.dev), 648 rdi->driver_f.port_callback); | 648 ret = ib_register_device(&rdi->ibdev, dev_name(&rdi->ibdev.dev)); |
649 if (ret) { 650 rvt_pr_err(rdi, "Failed to register driver with ib core.\n"); 651 goto bail_wss; 652 } 653 654 rvt_create_mad_agents(rdi); 655 656 rvt_pr_info(rdi, "Registration with rdmavt done.\n"); --- 54 unchanged lines hidden --- | 649 if (ret) { 650 rvt_pr_err(rdi, "Failed to register driver with ib core.\n"); 651 goto bail_wss; 652 } 653 654 rvt_create_mad_agents(rdi); 655 656 rvt_pr_info(rdi, "Registration with rdmavt done.\n"); --- 54 unchanged lines hidden --- |