History

RDMA/mlx5: Add flow actions support to raw create flow

Support attaching flow actions to a flow rule via raw create flow. For now only NIC RX path is supported. This change requires to export flow resources management functions so we can maintain proper bookkeeping of flow actions.

Mark Bloch committed 8 years ago

Commit fa76d241 parent b823dd64 files · +50 −8Browse files

Unified · Split

4 files
  1. drivers/infiniband/core/uverbs_cmd.c +7 −4
  2. drivers/infiniband/hw/mlx5/flow.c +36 −4
  3. include/rdma/uverbs_std_types.h +6 −0
  4. include/uapi/rdma/mlx5_user_ioctl_cmds.h +1 −0
drivers/infiniband/core/uverbs_cmd.c+7−4
@@ -2747,7 +2747,7 @@ out_put: · 2746 unmodified lines
27472747 return ret ? ret : in_len;
27482748 }
27492749
2750−static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
2750+struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
27512751 {
27522752 struct ib_uflow_resources *resources;
27532753
@@ -2777,6 +2777,7 @@ err: · 23 unmodified lines
27772777
27782778 return NULL;
27792779 }
2780+EXPORT_SYMBOL(flow_resources_alloc);
27802781
27812782 void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res)
27822783 {
@@ -2795,10 +2796,11 @@ void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res) · 12 unmodified lines
27952796 kfree(uflow_res->counters);
27962797 kfree(uflow_res);
27972798 }
2799+EXPORT_SYMBOL(ib_uverbs_flow_resources_free);
27982800
2799−static void flow_resources_add(struct ib_uflow_resources *uflow_res,
2800− enum ib_flow_spec_type type,
2801− void *ibobj)
2801+void flow_resources_add(struct ib_uflow_resources *uflow_res,
2802+ enum ib_flow_spec_type type,
2803+ void *ibobj)
28022804 {
28032805 WARN_ON(uflow_res->num >= uflow_res->max);
28042806
@@ -2819,6 +2821,7 @@ static void flow_resources_add(struct ib_uflow_resources *uflow_res, · 14 unmodified lines
28192821
28202822 uflow_res->num++;
28212823 }
2824+EXPORT_SYMBOL(flow_resources_add);
28222825
28232826 static int kern_spec_to_ib_spec_action(struct ib_uverbs_file *ufile,
28242827 struct ib_uverbs_flow_spec *kern_spec,
drivers/infiniband/hw/mlx5/flow.c+36−4
@@ -58,12 +58,15 @@ static const struct uverbs_attr_spec mlx5_ib_flow_type[] = { · 57 unmodified lines
5858 },
5959 };
6060
61+#define MLX5_IB_CREATE_FLOW_MAX_FLOW_ACTIONS 2
6162 static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
6263 struct ib_uverbs_file *file, struct uverbs_attr_bundle *attrs)
6364 {
6465 struct mlx5_flow_act flow_act = {.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG};
6566 struct mlx5_ib_flow_handler *flow_handler;
6667 struct mlx5_ib_flow_matcher *fs_matcher;
68+ struct ib_uobject **arr_flow_actions;
69+ struct ib_uflow_resources *uflow_res;
6770 void *devx_obj;
6871 int dest_id, dest_type;
6972 void *cmd_in;
@@ -73,6 +76,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)( · 3 unmodified lines
7376 struct ib_uobject *uobj =
7477 uverbs_attr_get_uobject(attrs, MLX5_IB_ATTR_CREATE_FLOW_HANDLE);
7578 struct mlx5_ib_dev *dev = to_mdev(uobj->context->device);
79+ int len, ret, i;
7680
7781 if (!capable(CAP_NET_RAW))
7882 return -EPERM;
@@ -124,15 +128,38 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)( · 45 unmodified lines
124128 MLX5_IB_ATTR_CREATE_FLOW_MATCH_VALUE);
125129 fs_matcher = uverbs_attr_get_obj(attrs,
126130 MLX5_IB_ATTR_CREATE_FLOW_MATCHER);
131+
132+ uflow_res = flow_resources_alloc(MLX5_IB_CREATE_FLOW_MAX_FLOW_ACTIONS);
133+ if (!uflow_res)
134+ return -ENOMEM;
135+
136+ len = uverbs_attr_get_uobjs_arr(attrs,
137+ MLX5_IB_ATTR_CREATE_FLOW_ARR_FLOW_ACTIONS, &arr_flow_actions);
138+ for (i = 0; i < len; i++) {
139+ struct mlx5_ib_flow_action *maction =
140+ to_mflow_act(arr_flow_actions[i]->object);
141+
142+ ret = parse_flow_flow_action(maction, false, &flow_act);
143+ if (ret)
144+ goto err_out;
145+ flow_resources_add(uflow_res, IB_FLOW_SPEC_ACTION_HANDLE,
146+ arr_flow_actions[i]->object);
147+ }
148+
127149 flow_handler = mlx5_ib_raw_fs_rule_add(dev, fs_matcher, &flow_act,
128150 cmd_in, inlen,
129151 dest_id, dest_type);
130− if (IS_ERR(flow_handler))
131− return PTR_ERR(flow_handler);
152+ if (IS_ERR(flow_handler)) {
153+ ret = PTR_ERR(flow_handler);
154+ goto err_out;
155+ }
132156
133− ib_set_flow(uobj, &flow_handler->ibflow, qp, &dev->ib_dev, NULL);
157+ ib_set_flow(uobj, &flow_handler->ibflow, qp, &dev->ib_dev, uflow_res);
134158
135159 return 0;
160+err_out:
161+ ib_uverbs_flow_resources_free(uflow_res);
162+ return ret;
136163 }
137164
138165 static int flow_matcher_cleanup(struct ib_uobject *uobject,
@@ -459,7 +486,12 @@ DECLARE_UVERBS_NAMED_METHOD( · 320 unmodified lines
459486 UVERBS_ACCESS_READ),
460487 UVERBS_ATTR_IDR(MLX5_IB_ATTR_CREATE_FLOW_DEST_DEVX,
461488 MLX5_IB_OBJECT_DEVX_OBJ,
462− UVERBS_ACCESS_READ));
489+ UVERBS_ACCESS_READ),
490+ UVERBS_ATTR_IDRS_ARR(MLX5_IB_ATTR_CREATE_FLOW_ARR_FLOW_ACTIONS,
491+ UVERBS_OBJECT_FLOW_ACTION,
492+ UVERBS_ACCESS_READ, 1,
493+ MLX5_IB_CREATE_FLOW_MAX_FLOW_ACTIONS,
494+ UA_OPTIONAL));
463495
464496 DECLARE_UVERBS_NAMED_METHOD_DESTROY(
465497 MLX5_IB_METHOD_DESTROY_FLOW,
include/rdma/uverbs_std_types.h+6−0
@@ -166,6 +166,12 @@ struct ib_uflow_object { · 165 unmodified lines
166166 struct ib_uflow_resources *resources;
167167 };
168168
169+struct ib_uflow_resources *flow_resources_alloc(size_t num_specs);
170+void flow_resources_add(struct ib_uflow_resources *uflow_res,
171+ enum ib_flow_spec_type type,
172+ void *ibobj);
173+void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res);
174+
169175 static inline void ib_set_flow(struct ib_uobject *uobj, struct ib_flow *ibflow,
170176 struct ib_qp *qp, struct ib_device *device,
171177 struct ib_uflow_resources *uflow_res)
include/uapi/rdma/mlx5_user_ioctl_cmds.h+1−0
@@ -155,6 +155,7 @@ enum mlx5_ib_create_flow_attrs { · 154 unmodified lines
155155 MLX5_IB_ATTR_CREATE_FLOW_DEST_QP,
156156 MLX5_IB_ATTR_CREATE_FLOW_DEST_DEVX,
157157 MLX5_IB_ATTR_CREATE_FLOW_MATCHER,
158+ MLX5_IB_ATTR_CREATE_FLOW_ARR_FLOW_ACTIONS,
158159 };
159160
160161 enum mlx5_ib_destoy_flow_attrs {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t