1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2022, Microsoft Corporation. All rights reserved.
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
)
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
;
18 if (udata
->inlen
< sizeof(ucmd
))
19 return ERR_PTR(-EINVAL
);
21 err
= ib_copy_from_udata(&ucmd
, udata
, min(sizeof(ucmd
), udata
->inlen
));
23 ibdev_dbg(&mdev
->ib_dev
,
24 "Failed to copy from udata for create wq, %d\n", err
);
28 wq
= kzalloc(sizeof(*wq
), GFP_KERNEL
);
30 return ERR_PTR(-ENOMEM
);
32 ibdev_dbg(&mdev
->ib_dev
, "ucmd wq_buf_addr 0x%llx\n", ucmd
.wq_buf_addr
);
34 err
= mana_ib_create_queue(mdev
, ucmd
.wq_buf_addr
, ucmd
.wq_buf_size
, &wq
->queue
);
36 ibdev_dbg(&mdev
->ib_dev
,
37 "Failed to create queue for create wq, %d\n", err
);
41 wq
->wqe
= init_attr
->max_wr
;
42 wq
->wq_buf_size
= ucmd
.wq_buf_size
;
43 wq
->rx_object
= INVALID_MANA_HANDLE
;
52 int mana_ib_modify_wq(struct ib_wq
*wq
, struct ib_wq_attr
*wq_attr
,
53 u32 wq_attr_mask
, struct ib_udata
*udata
)
55 /* modify_wq is not supported by this version of the driver */
59 int mana_ib_destroy_wq(struct ib_wq
*ibwq
, struct ib_udata
*udata
)
61 struct mana_ib_wq
*wq
= container_of(ibwq
, struct mana_ib_wq
, ibwq
);
62 struct ib_device
*ib_dev
= ibwq
->device
;
63 struct mana_ib_dev
*mdev
;
65 mdev
= container_of(ib_dev
, struct mana_ib_dev
, ib_dev
);
67 mana_ib_destroy_queue(mdev
, &wq
->queue
);
74 int mana_ib_create_rwq_ind_table(struct ib_rwq_ind_table
*ib_rwq_ind_table
,
75 struct ib_rwq_ind_table_init_attr
*init_attr
,
76 struct ib_udata
*udata
)
79 * There is no additional data in ind_table to be maintained by this
85 int mana_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table
*ib_rwq_ind_tbl
)
88 * There is no additional data in ind_table to be maintained by this