]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/nldev: Connect QP number to .doit callback
authorLeon Romanovsky <leonro@mellanox.com>
Mon, 18 Feb 2019 20:25:51 +0000 (22:25 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 19 Feb 2019 17:13:39 +0000 (10:13 -0700)
This patch adds ability to query specific QP based on its LQPN (local
QPN), which is assigned by HW and needs special treatment while inserting
into restrack DB.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/nldev.c
drivers/infiniband/core/restrack.c

index e6c7cc51055692dc9bfc41665efbfc84f8c50c33..8b4f86ce50ce85e75e28c6d3c92ce346ed4a6888 100644 (file)
@@ -921,6 +921,7 @@ static const struct nldev_fill_res_entry fill_entries[RDMA_RESTRACK_MAX] = {
                .nldev_cmd = RDMA_NLDEV_CMD_RES_QP_GET,
                .nldev_attr = RDMA_NLDEV_ATTR_RES_QP,
                .entry = RDMA_NLDEV_ATTR_RES_QP_ENTRY,
+               .id = RDMA_NLDEV_ATTR_RES_LQPN,
        },
        [RDMA_RESTRACK_CM_ID] = {
                .fill_res_func = fill_res_cm_id_entry,
index a5ea3988b4c32b0954a9e2583eb6a2de09e0d807..fa804093fafb8f27d4ed43c88bdad5979f1ff912 100644 (file)
@@ -225,7 +225,16 @@ static void rdma_restrack_add(struct rdma_restrack_entry *res)
 
        kref_init(&res->kref);
        init_completion(&res->comp);
-       ret = rt_xa_alloc_cyclic(&rt->xa, &res->id, res, &rt->next_id);
+       if (res->type != RDMA_RESTRACK_QP)
+               ret = rt_xa_alloc_cyclic(&rt->xa, &res->id, res, &rt->next_id);
+       else {
+               /* Special case to ensure that LQPN points to right QP */
+               struct ib_qp *qp = container_of(res, struct ib_qp, res);
+
+               ret = xa_insert(&rt->xa, qp->qp_num, res, GFP_KERNEL);
+               res->id = ret ? 0 : qp->qp_num;
+       }
+
        if (!ret)
                res->valid = true;
 }