Commit c804af2c authored by Yamin Friedman's avatar Yamin Friedman Committed by Jason Gunthorpe

IB/srpt: use new shared CQ mechanism

Have the driver use shared CQs provided by the rdma core driver.  This
provides the advantage of improved efficiency handling interrupts.

Link: https://lore.kernel.org/r/20200722135629.49467-3-maxg@mellanox.comSigned-off-by: default avatarYamin Friedman <yaminf@mellanox.com>
Reviewed-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent c6e66307
...@@ -869,7 +869,7 @@ static int srpt_zerolength_write(struct srpt_rdma_ch *ch) ...@@ -869,7 +869,7 @@ static int srpt_zerolength_write(struct srpt_rdma_ch *ch)
static void srpt_zerolength_write_done(struct ib_cq *cq, struct ib_wc *wc) static void srpt_zerolength_write_done(struct ib_cq *cq, struct ib_wc *wc)
{ {
struct srpt_rdma_ch *ch = cq->cq_context; struct srpt_rdma_ch *ch = wc->qp->qp_context;
pr_debug("%s-%d wc->status %d\n", ch->sess_name, ch->qp->qp_num, pr_debug("%s-%d wc->status %d\n", ch->sess_name, ch->qp->qp_num,
wc->status); wc->status);
...@@ -1322,7 +1322,7 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) ...@@ -1322,7 +1322,7 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
*/ */
static void srpt_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) static void srpt_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc)
{ {
struct srpt_rdma_ch *ch = cq->cq_context; struct srpt_rdma_ch *ch = wc->qp->qp_context;
struct srpt_send_ioctx *ioctx = struct srpt_send_ioctx *ioctx =
container_of(wc->wr_cqe, struct srpt_send_ioctx, rdma_cqe); container_of(wc->wr_cqe, struct srpt_send_ioctx, rdma_cqe);
...@@ -1683,7 +1683,7 @@ srpt_handle_new_iu(struct srpt_rdma_ch *ch, struct srpt_recv_ioctx *recv_ioctx) ...@@ -1683,7 +1683,7 @@ srpt_handle_new_iu(struct srpt_rdma_ch *ch, struct srpt_recv_ioctx *recv_ioctx)
static void srpt_recv_done(struct ib_cq *cq, struct ib_wc *wc) static void srpt_recv_done(struct ib_cq *cq, struct ib_wc *wc)
{ {
struct srpt_rdma_ch *ch = cq->cq_context; struct srpt_rdma_ch *ch = wc->qp->qp_context;
struct srpt_recv_ioctx *ioctx = struct srpt_recv_ioctx *ioctx =
container_of(wc->wr_cqe, struct srpt_recv_ioctx, ioctx.cqe); container_of(wc->wr_cqe, struct srpt_recv_ioctx, ioctx.cqe);
...@@ -1744,7 +1744,7 @@ static void srpt_process_wait_list(struct srpt_rdma_ch *ch) ...@@ -1744,7 +1744,7 @@ static void srpt_process_wait_list(struct srpt_rdma_ch *ch)
*/ */
static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc) static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc)
{ {
struct srpt_rdma_ch *ch = cq->cq_context; struct srpt_rdma_ch *ch = wc->qp->qp_context;
struct srpt_send_ioctx *ioctx = struct srpt_send_ioctx *ioctx =
container_of(wc->wr_cqe, struct srpt_send_ioctx, ioctx.cqe); container_of(wc->wr_cqe, struct srpt_send_ioctx, ioctx.cqe);
enum srpt_command_state state; enum srpt_command_state state;
...@@ -1791,7 +1791,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) ...@@ -1791,7 +1791,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
goto out; goto out;
retry: retry:
ch->cq = ib_alloc_cq_any(sdev->device, ch, ch->rq_size + sq_size, ch->cq = ib_cq_pool_get(sdev->device, ch->rq_size + sq_size, -1,
IB_POLL_WORKQUEUE); IB_POLL_WORKQUEUE);
if (IS_ERR(ch->cq)) { if (IS_ERR(ch->cq)) {
ret = PTR_ERR(ch->cq); ret = PTR_ERR(ch->cq);
...@@ -1799,6 +1799,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) ...@@ -1799,6 +1799,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
ch->rq_size + sq_size, ret); ch->rq_size + sq_size, ret);
goto out; goto out;
} }
ch->cq_size = ch->rq_size + sq_size;
qp_init->qp_context = (void *)ch; qp_init->qp_context = (void *)ch;
qp_init->event_handler qp_init->event_handler
...@@ -1843,7 +1844,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) ...@@ -1843,7 +1844,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
if (retry) { if (retry) {
pr_debug("failed to create queue pair with sq_size = %d (%d) - retrying\n", pr_debug("failed to create queue pair with sq_size = %d (%d) - retrying\n",
sq_size, ret); sq_size, ret);
ib_free_cq(ch->cq); ib_cq_pool_put(ch->cq, ch->cq_size);
sq_size = max(sq_size / 2, MIN_SRPT_SQ_SIZE); sq_size = max(sq_size / 2, MIN_SRPT_SQ_SIZE);
goto retry; goto retry;
} else { } else {
...@@ -1869,14 +1870,14 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch) ...@@ -1869,14 +1870,14 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
err_destroy_cq: err_destroy_cq:
ch->qp = NULL; ch->qp = NULL;
ib_free_cq(ch->cq); ib_cq_pool_put(ch->cq, ch->cq_size);
goto out; goto out;
} }
static void srpt_destroy_ch_ib(struct srpt_rdma_ch *ch) static void srpt_destroy_ch_ib(struct srpt_rdma_ch *ch)
{ {
ib_destroy_qp(ch->qp); ib_destroy_qp(ch->qp);
ib_free_cq(ch->cq); ib_cq_pool_put(ch->cq, ch->cq_size);
} }
/** /**
......
...@@ -300,6 +300,7 @@ struct srpt_rdma_ch { ...@@ -300,6 +300,7 @@ struct srpt_rdma_ch {
} rdma_cm; } rdma_cm;
}; };
struct ib_cq *cq; struct ib_cq *cq;
u32 cq_size;
struct ib_cqe zw_cqe; struct ib_cqe zw_cqe;
struct rcu_head rcu; struct rcu_head rcu;
struct kref kref; struct kref kref;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment