Skip to content

Commit c5f9092

Browse files
yishaihdledford
authored andcommitted
IB/mlx5: Add Receive Work Queue Indirection table operations
Some mlx5 based hardwares support a RQ table object. This RQ table points to a few RQ objects. We implement the receive work queue indirection table API (create and destroy) by using this hardware object. Signed-off-by: Yishai Hadas <[email protected]> Signed-off-by: Matan Barak <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent de019a9 commit c5f9092

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,12 +2453,16 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
24532453
dev->ib_dev.create_wq = mlx5_ib_create_wq;
24542454
dev->ib_dev.modify_wq = mlx5_ib_modify_wq;
24552455
dev->ib_dev.destroy_wq = mlx5_ib_destroy_wq;
2456+
dev->ib_dev.create_rwq_ind_table = mlx5_ib_create_rwq_ind_table;
2457+
dev->ib_dev.destroy_rwq_ind_table = mlx5_ib_destroy_rwq_ind_table;
24562458
dev->ib_dev.uverbs_ex_cmd_mask |=
24572459
(1ull << IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
24582460
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW) |
24592461
(1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |
24602462
(1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ) |
2461-
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ);
2463+
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ) |
2464+
(1ull << IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
2465+
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL);
24622466
}
24632467
err = init_node_data(dev);
24642468
if (err)

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ enum {
247247
MLX5_WQ_KERNEL
248248
};
249249

250+
struct mlx5_ib_rwq_ind_table {
251+
struct ib_rwq_ind_table ib_rwq_ind_tbl;
252+
u32 rqtn;
253+
};
254+
250255
/*
251256
* Connect-IB can trigger up to four concurrent pagefaults
252257
* per-QP.
@@ -657,6 +662,11 @@ static inline struct mlx5_ib_rwq *to_mrwq(struct ib_wq *ibwq)
657662
return container_of(ibwq, struct mlx5_ib_rwq, ibwq);
658663
}
659664

665+
static inline struct mlx5_ib_rwq_ind_table *to_mrwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl)
666+
{
667+
return container_of(ib_rwq_ind_tbl, struct mlx5_ib_rwq_ind_table, ib_rwq_ind_tbl);
668+
}
669+
660670
static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq)
661671
{
662672
return container_of(msrq, struct mlx5_ib_srq, msrq);
@@ -797,6 +807,10 @@ struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
797807
int mlx5_ib_destroy_wq(struct ib_wq *wq);
798808
int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
799809
u32 wq_attr_mask, struct ib_udata *udata);
810+
struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
811+
struct ib_rwq_ind_table_init_attr *init_attr,
812+
struct ib_udata *udata);
813+
int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);
800814

801815
#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
802816
extern struct workqueue_struct *mlx5_ib_page_fault_wq;

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4415,6 +4415,84 @@ int mlx5_ib_destroy_wq(struct ib_wq *wq)
44154415
return 0;
44164416
}
44174417

4418+
struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
4419+
struct ib_rwq_ind_table_init_attr *init_attr,
4420+
struct ib_udata *udata)
4421+
{
4422+
struct mlx5_ib_dev *dev = to_mdev(device);
4423+
struct mlx5_ib_rwq_ind_table *rwq_ind_tbl;
4424+
int sz = 1 << init_attr->log_ind_tbl_size;
4425+
struct mlx5_ib_create_rwq_ind_tbl_resp resp = {};
4426+
size_t min_resp_len;
4427+
int inlen;
4428+
int err;
4429+
int i;
4430+
u32 *in;
4431+
void *rqtc;
4432+
4433+
if (udata->inlen > 0 &&
4434+
!ib_is_udata_cleared(udata, 0,
4435+
udata->inlen))
4436+
return ERR_PTR(-EOPNOTSUPP);
4437+
4438+
min_resp_len = offsetof(typeof(resp), reserved) + sizeof(resp.reserved);
4439+
if (udata->outlen && udata->outlen < min_resp_len)
4440+
return ERR_PTR(-EINVAL);
4441+
4442+
rwq_ind_tbl = kzalloc(sizeof(*rwq_ind_tbl), GFP_KERNEL);
4443+
if (!rwq_ind_tbl)
4444+
return ERR_PTR(-ENOMEM);
4445+
4446+
inlen = MLX5_ST_SZ_BYTES(create_rqt_in) + sizeof(u32) * sz;
4447+
in = mlx5_vzalloc(inlen);
4448+
if (!in) {
4449+
err = -ENOMEM;
4450+
goto err;
4451+
}
4452+
4453+
rqtc = MLX5_ADDR_OF(create_rqt_in, in, rqt_context);
4454+
4455+
MLX5_SET(rqtc, rqtc, rqt_actual_size, sz);
4456+
MLX5_SET(rqtc, rqtc, rqt_max_size, sz);
4457+
4458+
for (i = 0; i < sz; i++)
4459+
MLX5_SET(rqtc, rqtc, rq_num[i], init_attr->ind_tbl[i]->wq_num);
4460+
4461+
err = mlx5_core_create_rqt(dev->mdev, in, inlen, &rwq_ind_tbl->rqtn);
4462+
kvfree(in);
4463+
4464+
if (err)
4465+
goto err;
4466+
4467+
rwq_ind_tbl->ib_rwq_ind_tbl.ind_tbl_num = rwq_ind_tbl->rqtn;
4468+
if (udata->outlen) {
4469+
resp.response_length = offsetof(typeof(resp), response_length) +
4470+
sizeof(resp.response_length);
4471+
err = ib_copy_to_udata(udata, &resp, resp.response_length);
4472+
if (err)
4473+
goto err_copy;
4474+
}
4475+
4476+
return &rwq_ind_tbl->ib_rwq_ind_tbl;
4477+
4478+
err_copy:
4479+
mlx5_core_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn);
4480+
err:
4481+
kfree(rwq_ind_tbl);
4482+
return ERR_PTR(err);
4483+
}
4484+
4485+
int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl)
4486+
{
4487+
struct mlx5_ib_rwq_ind_table *rwq_ind_tbl = to_mrwq_ind_table(ib_rwq_ind_tbl);
4488+
struct mlx5_ib_dev *dev = to_mdev(ib_rwq_ind_tbl->device);
4489+
4490+
mlx5_core_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn);
4491+
4492+
kfree(rwq_ind_tbl);
4493+
return 0;
4494+
}
4495+
44184496
int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
44194497
u32 wq_attr_mask, struct ib_udata *udata)
44204498
{

drivers/infiniband/hw/mlx5/user.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ struct mlx5_ib_create_wq_resp {
179179
__u32 reserved;
180180
};
181181

182+
struct mlx5_ib_create_rwq_ind_tbl_resp {
183+
__u32 response_length;
184+
__u32 reserved;
185+
};
186+
182187
struct mlx5_ib_modify_wq {
183188
__u32 comp_mask;
184189
__u32 reserved;

0 commit comments

Comments
 (0)