1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright (c) 2022, Microsoft Corporation. All rights reserved. 4 */ 5 6 #include "mana_ib.h" 7 8 struct ib_wq *mana_ib_create_wq(struct ib_pd *pd, 9 struct ib_wq_init_attr *init_attr, 10 struct ib_udata *udata) 11 { 12 struct mana_ib_dev *mdev = 13 container_of(pd->device, struct mana_ib_dev, ib_dev); 14 struct mana_ib_create_wq ucmd; 15 struct mana_ib_wq *wq; 16 int err; 17 18 err = ib_copy_validate_udata_in(udata, ucmd, reserved); 19 if (err) 20 return ERR_PTR(err); 21 22 wq = kzalloc_obj(*wq); 23 if (!wq) 24 return ERR_PTR(-ENOMEM); 25 26 ibdev_dbg(&mdev->ib_dev, "ucmd wq_buf_addr 0x%llx\n", ucmd.wq_buf_addr); 27 28 err = mana_ib_create_queue(mdev, ucmd.wq_buf_addr, ucmd.wq_buf_size, &wq->queue); 29 if (err) { 30 ibdev_dbg(&mdev->ib_dev, 31 "Failed to create queue for create wq, %d\n", err); 32 goto err_free_wq; 33 } 34 35 wq->wqe = init_attr->max_wr; 36 wq->wq_buf_size = ucmd.wq_buf_size; 37 wq->rx_object = INVALID_MANA_HANDLE; 38 return &wq->ibwq; 39 40 err_free_wq: 41 kfree(wq); 42 43 return ERR_PTR(err); 44 } 45 46 int mana_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr, 47 u32 wq_attr_mask, struct ib_udata *udata) 48 { 49 /* modify_wq is not supported by this version of the driver */ 50 return -EOPNOTSUPP; 51 } 52 53 int mana_ib_destroy_wq(struct ib_wq *ibwq, struct ib_udata *udata) 54 { 55 struct mana_ib_wq *wq = container_of(ibwq, struct mana_ib_wq, ibwq); 56 struct ib_device *ib_dev = ibwq->device; 57 struct mana_ib_dev *mdev; 58 59 mdev = container_of(ib_dev, struct mana_ib_dev, ib_dev); 60 61 mana_ib_destroy_queue(mdev, &wq->queue); 62 63 kfree(wq); 64 65 return 0; 66 } 67 68 int mana_ib_create_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_table, 69 struct ib_rwq_ind_table_init_attr *init_attr, 70 struct ib_udata *udata) 71 { 72 /* 73 * There is no additional data in ind_table to be maintained by this 74 * driver, do nothing 75 */ 76 return 0; 77 } 78 79 int mana_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl) 80 { 81 /* 82 * There is no additional data in ind_table to be maintained by this 83 * driver, do nothing 84 */ 85 return 0; 86 } 87