Skip to content

Commit 86e1d46

Browse files
mark-blochjgunthorpe
authored andcommitted
RDMA/uverbs: Move flow resources initialization
Use ib_set_flow() when initializing flow related resources. Signed-off-by: Mark Bloch <markb@mellanox.com> Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent 70cd20a commit 86e1d46

File tree

5 files changed

+36
-38
lines changed

5 files changed

+36
-38
lines changed

drivers/infiniband/core/uverbs.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,6 @@ struct ib_ucq_object {
219219
u32 async_events_reported;
220220
};
221221

222-
struct ib_uflow_resources;
223-
struct ib_uflow_object {
224-
struct ib_uobject uobject;
225-
struct ib_uflow_resources *resources;
226-
};
227-
228222
extern const struct file_operations uverbs_event_fops;
229223
void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue);
230224
struct file *ib_uverbs_alloc_async_event_file(struct ib_uverbs_file *uverbs_file,

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,15 +2747,6 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
27472747
return ret ? ret : in_len;
27482748
}
27492749

2750-
struct ib_uflow_resources {
2751-
size_t max;
2752-
size_t num;
2753-
size_t collection_num;
2754-
size_t counters_num;
2755-
struct ib_counters **counters;
2756-
struct ib_flow_action **collection;
2757-
};
2758-
27592750
static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
27602751
{
27612752
struct ib_uflow_resources *resources;
@@ -3462,7 +3453,6 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
34623453
struct ib_uverbs_create_flow cmd;
34633454
struct ib_uverbs_create_flow_resp resp;
34643455
struct ib_uobject *uobj;
3465-
struct ib_uflow_object *uflow;
34663456
struct ib_flow *flow_id;
34673457
struct ib_uverbs_flow_attr *kern_flow_attr;
34683458
struct ib_flow_attr *flow_attr;
@@ -3601,13 +3591,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
36013591
err = PTR_ERR(flow_id);
36023592
goto err_free;
36033593
}
3604-
atomic_inc(&qp->usecnt);
3605-
flow_id->qp = qp;
3606-
flow_id->device = qp->device;
3607-
flow_id->uobject = uobj;
3608-
uobj->object = flow_id;
3609-
uflow = container_of(uobj, typeof(*uflow), uobject);
3610-
uflow->resources = uflow_res;
3594+
3595+
ib_set_flow(uobj, flow_id, qp, qp->device, uflow_res);
36113596

36123597
memset(&resp, 0, sizeof(resp));
36133598
resp.flow_handle = uobj->id;

drivers/infiniband/hw/mlx5/flow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
128128
if (IS_ERR(flow_handler))
129129
return PTR_ERR(flow_handler);
130130

131-
ib_set_flow(uobj, &flow_handler->ibflow, qp, &dev->ib_dev);
131+
ib_set_flow(uobj, &flow_handler->ibflow, qp, &dev->ib_dev, NULL);
132132

133133
return 0;
134134
}

include/rdma/ib_verbs.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4162,20 +4162,6 @@ ib_get_vector_affinity(struct ib_device *device, int comp_vector)
41624162

41634163
}
41644164

4165-
static inline void ib_set_flow(struct ib_uobject *uobj, struct ib_flow *ibflow,
4166-
struct ib_qp *qp, struct ib_device *device)
4167-
{
4168-
uobj->object = ibflow;
4169-
ibflow->uobject = uobj;
4170-
4171-
if (qp) {
4172-
atomic_inc(&qp->usecnt);
4173-
ibflow->qp = qp;
4174-
}
4175-
4176-
ibflow->device = device;
4177-
}
4178-
41794165
/**
41804166
* rdma_roce_rescan_device - Rescan all of the network devices in the system
41814167
* and add their gids, as needed, to the relevant RoCE devices.

include/rdma/uverbs_std_types.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,38 @@ static inline void uverbs_flow_action_fill_action(struct ib_flow_action *action,
152152
uobj->object = action;
153153
}
154154

155+
struct ib_uflow_resources {
156+
size_t max;
157+
size_t num;
158+
size_t collection_num;
159+
size_t counters_num;
160+
struct ib_counters **counters;
161+
struct ib_flow_action **collection;
162+
};
163+
164+
struct ib_uflow_object {
165+
struct ib_uobject uobject;
166+
struct ib_uflow_resources *resources;
167+
};
168+
169+
static inline void ib_set_flow(struct ib_uobject *uobj, struct ib_flow *ibflow,
170+
struct ib_qp *qp, struct ib_device *device,
171+
struct ib_uflow_resources *uflow_res)
172+
{
173+
struct ib_uflow_object *uflow;
174+
175+
uobj->object = ibflow;
176+
ibflow->uobject = uobj;
177+
178+
if (qp) {
179+
atomic_inc(&qp->usecnt);
180+
ibflow->qp = qp;
181+
}
182+
183+
ibflow->device = device;
184+
uflow = container_of(uobj, typeof(*uflow), uobject);
185+
uflow->resources = uflow_res;
186+
}
187+
155188
#endif
156189

0 commit comments

Comments
 (0)