Skip to content

Commit 350d0e4

Browse files
yishaihdledford
authored andcommitted
IB/mlx5: Track asynchronous events on a receive work queue
Track asynchronous events on a receive work queue by using the mlx5_core_create_rq_tracked API. In case a fatal error has occurred letting the IB layer know about by using the ib_wq event handler. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 466fa6d commit 350d0e4

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct mlx5_ib_wq {
227227

228228
struct mlx5_ib_rwq {
229229
struct ib_wq ibwq;
230-
u32 rqn;
230+
struct mlx5_core_qp core_qp;
231231
u32 rq_num_pas;
232232
u32 log_rq_stride;
233233
u32 log_rq_size;
@@ -664,6 +664,11 @@ static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp)
664664
return container_of(mqp, struct mlx5_ib_qp_base, mqp)->container_mibqp;
665665
}
666666

667+
static inline struct mlx5_ib_rwq *to_mibrwq(struct mlx5_core_qp *core_qp)
668+
{
669+
return container_of(core_qp, struct mlx5_ib_rwq, core_qp);
670+
}
671+
667672
static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mkey *mmkey)
668673
{
669674
return container_of(mmkey, struct mlx5_ib_mr, mmkey);

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4536,6 +4536,28 @@ int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd)
45364536
return 0;
45374537
}
45384538

4539+
static void mlx5_ib_wq_event(struct mlx5_core_qp *core_qp, int type)
4540+
{
4541+
struct mlx5_ib_rwq *rwq = to_mibrwq(core_qp);
4542+
struct mlx5_ib_dev *dev = to_mdev(rwq->ibwq.device);
4543+
struct ib_event event;
4544+
4545+
if (rwq->ibwq.event_handler) {
4546+
event.device = rwq->ibwq.device;
4547+
event.element.wq = &rwq->ibwq;
4548+
switch (type) {
4549+
case MLX5_EVENT_TYPE_WQ_CATAS_ERROR:
4550+
event.event = IB_EVENT_WQ_FATAL;
4551+
break;
4552+
default:
4553+
mlx5_ib_warn(dev, "Unexpected event type %d on WQ %06x\n", type, core_qp->qpn);
4554+
return;
4555+
}
4556+
4557+
rwq->ibwq.event_handler(&event, rwq->ibwq.wq_context);
4558+
}
4559+
}
4560+
45394561
static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd,
45404562
struct ib_wq_init_attr *init_attr)
45414563
{
@@ -4573,7 +4595,7 @@ static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd,
45734595
MLX5_SET64(wq, wq, dbr_addr, rwq->db.dma);
45744596
rq_pas0 = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
45754597
mlx5_ib_populate_pas(dev, rwq->umem, rwq->page_shift, rq_pas0, 0);
4576-
err = mlx5_core_create_rq(dev->mdev, in, inlen, &rwq->rqn);
4598+
err = mlx5_core_create_rq_tracked(dev->mdev, in, inlen, &rwq->core_qp);
45774599
kvfree(in);
45784600
return err;
45794601
}
@@ -4689,7 +4711,7 @@ struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
46894711
return ERR_PTR(-EINVAL);
46904712
}
46914713

4692-
rwq->ibwq.wq_num = rwq->rqn;
4714+
rwq->ibwq.wq_num = rwq->core_qp.qpn;
46934715
rwq->ibwq.state = IB_WQS_RESET;
46944716
if (udata->outlen) {
46954717
resp.response_length = offsetof(typeof(resp), response_length) +
@@ -4699,10 +4721,12 @@ struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
46994721
goto err_copy;
47004722
}
47014723

4724+
rwq->core_qp.event = mlx5_ib_wq_event;
4725+
rwq->ibwq.event_handler = init_attr->event_handler;
47024726
return &rwq->ibwq;
47034727

47044728
err_copy:
4705-
mlx5_core_destroy_rq(dev->mdev, rwq->rqn);
4729+
mlx5_core_destroy_rq_tracked(dev->mdev, &rwq->core_qp);
47064730
err_user_rq:
47074731
destroy_user_rq(pd, rwq);
47084732
err:
@@ -4715,7 +4739,7 @@ int mlx5_ib_destroy_wq(struct ib_wq *wq)
47154739
struct mlx5_ib_dev *dev = to_mdev(wq->device);
47164740
struct mlx5_ib_rwq *rwq = to_mrwq(wq);
47174741

4718-
mlx5_core_destroy_rq(dev->mdev, rwq->rqn);
4742+
mlx5_core_destroy_rq_tracked(dev->mdev, &rwq->core_qp);
47194743
destroy_user_rq(wq->pd, rwq);
47204744
kfree(rwq);
47214745

@@ -4847,7 +4871,7 @@ int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
48474871
MLX5_SET(modify_rq_in, in, rq_state, curr_wq_state);
48484872
MLX5_SET(rqc, rqc, state, wq_state);
48494873

4850-
err = mlx5_core_modify_rq(dev->mdev, rwq->rqn, in, inlen);
4874+
err = mlx5_core_modify_rq(dev->mdev, rwq->core_qp.qpn, in, inlen);
48514875
kvfree(in);
48524876
if (!err)
48534877
rwq->ibwq.state = (wq_state == MLX5_RQC_STATE_ERR) ? IB_WQS_ERR : wq_state;

0 commit comments

Comments
 (0)