RDMA/mlx5: Add support for flow tag to raw create flow
authorMark Bloch <markb@mellanox.com>
Wed, 10 Oct 2018 06:55:10 +0000 (09:55 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 16 Oct 2018 06:24:45 +0000 (00:24 -0600)
A user can provide a hint which will be attached to the packet and written
to the CQE on receive. This can be used as a way to offload operations
into the HW, for example parsing a packet which is a tunneled packet, and
if so, pass 0x1 as the hint. The software can use that hint to decapsulate
the packet and parse only the inner headers thus saving CPU cycles.

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>
drivers/infiniband/hw/mlx5/flow.c
include/uapi/rdma/mlx5_user_ioctl_cmds.h

index 4ee4af4507209f556553ee2a3f1ca8ffdea751f4..e57435cb6d9666ee38f559f01df5cdf4789ab347 100644 (file)
@@ -153,6 +153,16 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
                                   arr_flow_actions[i]->object);
        }
 
+       ret = uverbs_copy_from(&flow_act.flow_tag, attrs,
+                              MLX5_IB_ATTR_CREATE_FLOW_TAG);
+       if (!ret) {
+               if (flow_act.flow_tag >= BIT(24)) {
+                       ret = -EINVAL;
+                       goto err_out;
+               }
+               flow_act.has_flow_tag = true;
+       }
+
        flow_handler = mlx5_ib_raw_fs_rule_add(dev, fs_matcher, &flow_act,
                                               cmd_in, inlen,
                                               dest_id, dest_type);
@@ -513,7 +523,10 @@ DECLARE_UVERBS_NAMED_METHOD(
                             UVERBS_OBJECT_FLOW_ACTION,
                             UVERBS_ACCESS_READ, 1,
                             MLX5_IB_CREATE_FLOW_MAX_FLOW_ACTIONS,
-                            UA_OPTIONAL));
+                            UA_OPTIONAL),
+       UVERBS_ATTR_PTR_IN(MLX5_IB_ATTR_CREATE_FLOW_TAG,
+                          UVERBS_ATTR_TYPE(u32),
+                          UA_OPTIONAL));
 
 DECLARE_UVERBS_NAMED_METHOD_DESTROY(
        MLX5_IB_METHOD_DESTROY_FLOW,
index fb4a8b17cca8352b0c047eb2bd14a577f5ccf932..408e220034de2e0ae19daff2a897a740ca332f26 100644 (file)
@@ -157,6 +157,7 @@ enum mlx5_ib_create_flow_attrs {
        MLX5_IB_ATTR_CREATE_FLOW_DEST_DEVX,
        MLX5_IB_ATTR_CREATE_FLOW_MATCHER,
        MLX5_IB_ATTR_CREATE_FLOW_ARR_FLOW_ACTIONS,
+       MLX5_IB_ATTR_CREATE_FLOW_TAG,
 };
 
 enum mlx5_ib_destoy_flow_attrs {