All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next] RDMA/mlx5: Add support for drop action in DV steering
@ 2020-04-13 13:53 Leon Romanovsky
  2020-04-22 19:26 ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2020-04-13 13:53 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Daria Velikovsky, linux-rdma, Maor Gottlieb

From: Daria Velikovsky <daria@mellanox.com>

When drop action is used the matching packet will stop
processing in steering and will be dropped. This functionality
will allow users to drop matching packets.

Signed-off-by: Daria Velikovsky <daria@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/flow.c        | 37 +++++++++++++++---------
 include/uapi/rdma/mlx5_user_ioctl_cmds.h |  1 +
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/flow.c b/drivers/infiniband/hw/mlx5/flow.c
index 7db672fd1395..6111f8162e5f 100644
--- a/drivers/infiniband/hw/mlx5/flow.c
+++ b/drivers/infiniband/hw/mlx5/flow.c
@@ -69,38 +69,44 @@ static const struct uverbs_attr_spec mlx5_ib_flow_type[] = {

 static int get_dests(struct uverbs_attr_bundle *attrs,
 		     struct mlx5_ib_flow_matcher *fs_matcher, int *dest_id,
-		     int *dest_type, struct ib_qp **qp, bool *def_miss)
+		     int *dest_type, struct ib_qp **qp, u32 *flags)
 {
 	bool dest_devx, dest_qp;
 	void *devx_obj;
-	u32 flags;

 	dest_devx = uverbs_attr_is_valid(attrs,
 					 MLX5_IB_ATTR_CREATE_FLOW_DEST_DEVX);
 	dest_qp = uverbs_attr_is_valid(attrs,
 				       MLX5_IB_ATTR_CREATE_FLOW_DEST_QP);

-	*def_miss = false;
+	*flags = 0;
 	if (uverbs_attr_is_valid(attrs, MLX5_IB_ATTR_FLOW_MATCHER_FLOW_FLAGS)) {
 		int err;

-		err = uverbs_get_flags32(&flags, attrs,
-					 MLX5_IB_ATTR_CREATE_FLOW_FLAGS,
-					 MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DEFAULT_MISS);
+		err = uverbs_get_flags32(
+			flags, attrs, MLX5_IB_ATTR_CREATE_FLOW_FLAGS,
+			MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DEFAULT_MISS |
+				MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP);
 		if (err)
 			return err;
-		*def_miss = flags & MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DEFAULT_MISS;
+
+		/* Both flags are not allowed */
+		if (*flags & MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DEFAULT_MISS &&
+		    *flags & MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP)
+			return -EINVAL;
+
 	}

 	if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_BYPASS) {
-		if (dest_devx && (dest_qp || *def_miss))
+		if (dest_devx && (dest_qp || *flags))
 			return -EINVAL;
-		else if (dest_qp && *def_miss)
+		else if (dest_qp && *flags)
 			return -EINVAL;
 	}

-	/* Allow only DEVX object as dest when inserting to FDB */
-	if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_FDB && !dest_devx)
+	/* Allow only DEVX object, drop as dest for FDB */
+	if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_FDB && !(dest_devx ||
+	     (*flags & MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP)))
 		return -EINVAL;

 	/* Allow only DEVX object or QP as dest when inserting to RDMA_RX */
@@ -169,7 +175,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
 	void *devx_obj, *cmd_in;
 	struct ib_uobject *uobj;
 	struct mlx5_ib_dev *dev;
-	bool def_miss;
+	u32 flags;

 	if (!capable(CAP_NET_RAW))
 		return -EPERM;
@@ -179,12 +185,15 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
 	uobj =  uverbs_attr_get_uobject(attrs, MLX5_IB_ATTR_CREATE_FLOW_HANDLE);
 	dev = mlx5_udata_to_mdev(&attrs->driver_udata);

-	if (get_dests(attrs, fs_matcher, &dest_id, &dest_type, &qp, &def_miss))
+	if (get_dests(attrs, fs_matcher, &dest_id, &dest_type, &qp, &flags))
 		return -EINVAL;

-	if (def_miss)
+	if (flags & MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DEFAULT_MISS)
 		flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_NS;

+	if (flags & MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP)
+		flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
+
 	len = uverbs_attr_get_uobjs_arr(attrs,
 		MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX, &arr_flow_actions);
 	if (len) {
diff --git a/include/uapi/rdma/mlx5_user_ioctl_cmds.h b/include/uapi/rdma/mlx5_user_ioctl_cmds.h
index 07cf54333193..8e316ef896b5 100644
--- a/include/uapi/rdma/mlx5_user_ioctl_cmds.h
+++ b/include/uapi/rdma/mlx5_user_ioctl_cmds.h
@@ -243,6 +243,7 @@ enum mlx5_ib_flow_type {

 enum mlx5_ib_create_flow_flags {
 	MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DEFAULT_MISS = 1 << 0,
+	MLX5_IB_ATTR_CREATE_FLOW_FLAGS_DROP = 1 << 1,
 };

 enum mlx5_ib_create_flow_attrs {
--
2.25.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH rdma-next] RDMA/mlx5: Add support for drop action in DV steering
  2020-04-13 13:53 [PATCH rdma-next] RDMA/mlx5: Add support for drop action in DV steering Leon Romanovsky
@ 2020-04-22 19:26 ` Jason Gunthorpe
  2020-04-26 16:23   ` Yishai Hadas
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2020-04-22 19:26 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Doug Ledford, Daria Velikovsky, linux-rdma, Maor Gottlieb

On Mon, Apr 13, 2020 at 04:53:28PM +0300, Leon Romanovsky wrote:
> From: Daria Velikovsky <daria@mellanox.com>
> 
> When drop action is used the matching packet will stop
> processing in steering and will be dropped. This functionality
> will allow users to drop matching packets.
> 
> Signed-off-by: Daria Velikovsky <daria@mellanox.com>
> Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/hw/mlx5/flow.c        | 37 +++++++++++++++---------
>  include/uapi/rdma/mlx5_user_ioctl_cmds.h |  1 +
>  2 files changed, 24 insertions(+), 14 deletions(-)

Where is the rdma-core part of this?

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH rdma-next] RDMA/mlx5: Add support for drop action in DV steering
  2020-04-22 19:26 ` Jason Gunthorpe
@ 2020-04-26 16:23   ` Yishai Hadas
  0 siblings, 0 replies; 3+ messages in thread
From: Yishai Hadas @ 2020-04-26 16:23 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, Doug Ledford, Daria Velikovsky, linux-rdma,
	Maor Gottlieb, Yishai Hadas, valex

On 4/22/2020 10:26 PM, Jason Gunthorpe wrote:
> On Mon, Apr 13, 2020 at 04:53:28PM +0300, Leon Romanovsky wrote:
>> From: Daria Velikovsky <daria@mellanox.com>
>>
>> When drop action is used the matching packet will stop
>> processing in steering and will be dropped. This functionality
>> will allow users to drop matching packets.
>>
>> Signed-off-by: Daria Velikovsky <daria@mellanox.com>
>> Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
>> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
>> ---
>>   drivers/infiniband/hw/mlx5/flow.c        | 37 +++++++++++++++---------
>>   include/uapi/rdma/mlx5_user_ioctl_cmds.h |  1 +
>>   2 files changed, 24 insertions(+), 14 deletions(-)
> 
> Where is the rdma-core part of this?
> 

I have just sent the matching PR for the rdma-core part [1].
[1] https://github.com/linux-rdma/rdma-core/pull/748

Yishai

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-26 16:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 13:53 [PATCH rdma-next] RDMA/mlx5: Add support for drop action in DV steering Leon Romanovsky
2020-04-22 19:26 ` Jason Gunthorpe
2020-04-26 16:23   ` Yishai Hadas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.