IB: Support ib_flow creation in drivers
authorYishai Hadas <yishaih@mellanox.com>
Mon, 23 Jul 2018 12:25:08 +0000 (15:25 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 24 Jul 2018 19:34:55 +0000 (13:34 -0600)
This patch considers the case that ib_flow is created by some device
driver with its specific parameters using the KABI infrastructure.

In that case both QP and ib_uflow_resources might not be applicable.
Downstream patches from this series use the above functionality.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_std_types.c
include/rdma/ib_verbs.h

index bd6eefaecbd63fc5a03d840836b233b0e4b39cd0..987ee38ab4b370d7a942c185c628aa4f0f569bde 100644 (file)
@@ -2771,6 +2771,9 @@ void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res)
 {
        unsigned int i;
 
+       if (!uflow_res)
+               return;
+
        for (i = 0; i < uflow_res->collection_num; i++)
                atomic_dec(&uflow_res->collection[i]->usecnt);
 
@@ -3585,6 +3588,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
        }
        atomic_inc(&qp->usecnt);
        flow_id->qp = qp;
+       flow_id->device = qp->device;
        flow_id->uobject = uobj;
        uobj->object = flow_id;
        uflow = container_of(uobj, typeof(*uflow), uobject);
index 718c8430d364cd0b3d37935c13730b6a93750712..c1e0492cc78a74cd2632b33ecc1ed8e4c5cf3c84 100644 (file)
@@ -54,9 +54,10 @@ static int uverbs_free_flow(struct ib_uobject *uobject,
        struct ib_qp *qp = flow->qp;
        int ret;
 
-       ret = qp->device->destroy_flow(flow);
+       ret = flow->device->destroy_flow(flow);
        if (!ret) {
-               atomic_dec(&qp->usecnt);
+               if (qp)
+                       atomic_dec(&qp->usecnt);
                ib_uverbs_flow_resources_free(uflow->resources);
        }
 
index 08348e53082cfeb24ff5c4b648cc35cd49a53506..24d6ec38feeaea4f4774cd17a6c5198c153cc301 100644 (file)
@@ -2081,6 +2081,7 @@ struct ib_flow_attr {
 
 struct ib_flow {
        struct ib_qp            *qp;
+       struct ib_device        *device;
        struct ib_uobject       *uobject;
 };