Commit 6cd080a6 authored by Yishai Hadas's avatar Yishai Hadas Committed by Jason Gunthorpe

IB: Support ib_flow creation in drivers

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: default avatarYishai Hadas <yishaih@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent fd44e385
...@@ -2771,6 +2771,9 @@ void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res) ...@@ -2771,6 +2771,9 @@ void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res)
{ {
unsigned int i; unsigned int i;
if (!uflow_res)
return;
for (i = 0; i < uflow_res->collection_num; i++) for (i = 0; i < uflow_res->collection_num; i++)
atomic_dec(&uflow_res->collection[i]->usecnt); atomic_dec(&uflow_res->collection[i]->usecnt);
...@@ -3585,6 +3588,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, ...@@ -3585,6 +3588,7 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
} }
atomic_inc(&qp->usecnt); atomic_inc(&qp->usecnt);
flow_id->qp = qp; flow_id->qp = qp;
flow_id->device = qp->device;
flow_id->uobject = uobj; flow_id->uobject = uobj;
uobj->object = flow_id; uobj->object = flow_id;
uflow = container_of(uobj, typeof(*uflow), uobject); uflow = container_of(uobj, typeof(*uflow), uobject);
......
...@@ -54,9 +54,10 @@ static int uverbs_free_flow(struct ib_uobject *uobject, ...@@ -54,9 +54,10 @@ static int uverbs_free_flow(struct ib_uobject *uobject,
struct ib_qp *qp = flow->qp; struct ib_qp *qp = flow->qp;
int ret; int ret;
ret = qp->device->destroy_flow(flow); ret = flow->device->destroy_flow(flow);
if (!ret) { if (!ret) {
atomic_dec(&qp->usecnt); if (qp)
atomic_dec(&qp->usecnt);
ib_uverbs_flow_resources_free(uflow->resources); ib_uverbs_flow_resources_free(uflow->resources);
} }
......
...@@ -2081,6 +2081,7 @@ struct ib_flow_attr { ...@@ -2081,6 +2081,7 @@ struct ib_flow_attr {
struct ib_flow { struct ib_flow {
struct ib_qp *qp; struct ib_qp *qp;
struct ib_device *device;
struct ib_uobject *uobject; struct ib_uobject *uobject;
}; };
......
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