Skip to content

Commit

Permalink
RDMA/rtrs: Replace duplicate check with is_pollqueue helper
Browse files Browse the repository at this point in the history
[ Upstream commit 36332de ]

if (con->cid >= con->sess->irq_con_num) check can be replaced with a
is_pollqueue helper.

Link: https://lore.kernel.org/r/20210922125333.351454-5-haris.iqbal@ionos.com
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jinpuwang authored and gregkh committed Aug 17, 2022
1 parent 9c663e7 commit 001f93b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/infiniband/ulp/rtrs/rtrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,18 @@ static void qp_event_handler(struct ib_event *ev, void *ctx)
}
}

static bool is_pollqueue(struct rtrs_con *con)
{
return con->cid >= con->sess->irq_con_num;
}

static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,
enum ib_poll_context poll_ctx)
{
struct rdma_cm_id *cm_id = con->cm_id;
struct ib_cq *cq;

if (con->cid >= con->sess->irq_con_num)
if (is_pollqueue(con))
cq = ib_alloc_cq(cm_id->device, con, nr_cqe, cq_vector,
poll_ctx);
else
Expand Down Expand Up @@ -288,7 +293,7 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con,
err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr,
max_send_sge);
if (err) {
if (con->cid >= con->sess->irq_con_num)
if (is_pollqueue(con))
ib_free_cq(con->cq);
else
ib_cq_pool_put(con->cq, con->nr_cqe);
Expand All @@ -308,7 +313,7 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con)
con->qp = NULL;
}
if (con->cq) {
if (con->cid >= con->sess->irq_con_num)
if (is_pollqueue(con))
ib_free_cq(con->cq);
else
ib_cq_pool_put(con->cq, con->nr_cqe);
Expand Down

0 comments on commit 001f93b

Please sign in to comment.