All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Guy Levi <guyle@mellanox.com>, Mark Bloch <markb@mellanox.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>,
	linux-netdev <netdev@vger.kernel.org>
Subject: [PATCH rdma-next 26/27] RDMA/mlx5: Add NIC TX namespace when getting a flow table
Date: Sun, 29 Jul 2018 15:59:04 +0300	[thread overview]
Message-ID: <20180729125905.31989-27-leon@kernel.org> (raw)
In-Reply-To: <20180729125905.31989-1-leon@kernel.org>

From: Mark Bloch <markb@mellanox.com>

Add the ability to get a NIC TX flow table when using _get_flow_table().
This will allow to create a matcher and a flow rule on the NIC TX path.

Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/hw/mlx5/flow.c    |  1 +
 drivers/infiniband/hw/mlx5/main.c    | 38 ++++++++++++++++++++++++++----------
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  1 +
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/flow.c b/drivers/infiniband/hw/mlx5/flow.c
index b254b55e8de0..2422629f48c9 100644
--- a/drivers/infiniband/hw/mlx5/flow.c
+++ b/drivers/infiniband/hw/mlx5/flow.c
@@ -162,6 +162,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_FLOW_MATCHER_CREATE)(
 	if (!obj)
 		return -ENOMEM;
 
+	obj->ns_type = MLX5_FLOW_NAMESPACE_BYPASS;
 	obj->mask_len = uverbs_attr_get_len(
 		attrs, MLX5_IB_ATTR_FLOW_MATCHER_MATCH_MASK);
 	err = uverbs_copy_from(&obj->matcher_mask,
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 2b2af82dc32e..ba4bcbc3adb6 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3695,33 +3695,52 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
 }
 
 static struct mlx5_ib_flow_prio *_get_flow_table(struct mlx5_ib_dev *dev,
-						 int priority, bool mcast)
+						 struct mlx5_ib_flow_matcher *fs_matcher,
+						 bool mcast)
 {
-	int max_table_size;
 	struct mlx5_flow_namespace *ns = NULL;
 	struct mlx5_ib_flow_prio *prio;
+	int max_table_size = 0;
+	u32 flags = 0;
+	int priority;
+
+	if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_BYPASS) {
+		max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
+							       log_max_ft_size));
+		if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, decap))
+			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_DECAP;
+		if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
+					      reformat_l3_tunnel_to_l2))
+			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
+	} else { /* Can only be MLX5_FLOW_NAMESPACE_EGRESS */
+		max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev,
+							       log_max_ft_size));
+		if (MLX5_CAP_FLOWTABLE_NIC_TX(dev->mdev, reformat))
+			flags |= MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT;
+	}
 
-	max_table_size = BIT(MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev,
-			     log_max_ft_size));
 	if (max_table_size < MLX5_FS_MAX_ENTRIES)
 		return ERR_PTR(-ENOMEM);
 
 	if (mcast)
 		priority = MLX5_IB_FLOW_MCAST_PRIO;
 	else
-		priority = ib_prio_to_core_prio(priority, false);
+		priority = ib_prio_to_core_prio(fs_matcher->priority, false);
 
-	ns = mlx5_get_flow_namespace(dev->mdev, MLX5_FLOW_NAMESPACE_BYPASS);
+	ns = mlx5_get_flow_namespace(dev->mdev, fs_matcher->ns_type);
 	if (!ns)
 		return ERR_PTR(-ENOTSUPP);
 
-	prio = &dev->flow_db->prios[priority];
+	if (fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_BYPASS)
+		prio = &dev->flow_db->prios[priority];
+	else
+		prio = &dev->flow_db->egress_prios[priority];
 
 	if (prio->flow_table)
 		return prio;
 
 	return _get_prio(ns, prio, priority, MLX5_FS_MAX_ENTRIES,
-			 MLX5_FS_MAX_TYPES, 0);
+			 MLX5_FS_MAX_TYPES, flags);
 }
 
 static struct mlx5_ib_flow_handler *
@@ -3820,7 +3839,6 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
 {
 	struct mlx5_flow_destination *dst;
 	struct mlx5_ib_flow_prio *ft_prio;
-	int priority = fs_matcher->priority;
 	struct mlx5_ib_flow_handler *handler;
 	bool mcast;
 	int err;
@@ -3838,7 +3856,7 @@ mlx5_ib_raw_fs_rule_add(struct mlx5_ib_dev *dev,
 	mcast = raw_fs_is_multicast(fs_matcher, cmd_in);
 	mutex_lock(&dev->flow_db->lock);
 
-	ft_prio = _get_flow_table(dev, priority, mcast);
+	ft_prio = _get_flow_table(dev, fs_matcher, mcast);
 	if (IS_ERR(ft_prio)) {
 		err = PTR_ERR(ft_prio);
 		goto unlock;
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 76f1c178cef7..639b5dccf079 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -187,6 +187,7 @@ struct mlx5_ib_flow_matcher {
 	struct mlx5_ib_match_params matcher_mask;
 	int			mask_len;
 	enum mlx5_ib_flow_type	flow_type;
+	u8			ns_type;
 	u16			priority;
 	struct mlx5_core_dev	*mdev;
 	atomic_t		usecnt;
-- 
2.14.4

  parent reply	other threads:[~2018-07-29 12:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-29 12:58 [PATCH rdma-next 00/27] Flow actions to mutate packets Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 01/27] net/mlx5: Cleanup flow namespace getter switch logic Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 02/27] net/mlx5: Add proper NIC TX steering flow tables support Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 03/27] net/mlx5: Export modify header alloc/dealloc functions Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 04/27] net/mlx5: Add support for more namespaces when allocating modify header Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 05/27] net/mlx5: Break encap/decap into two separated flow table creation flags Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 06/27] net/mlx5: Move header encap type to IFC header file Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 07/27] {net, RDMA}/mlx5: Rename encap to reformat packet Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 08/27] net/mlx5: Expose new packet reformat capabilities Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 09/27] net/mlx5: Pass a namespace for packet reformat ID allocation Leon Romanovsky
2018-07-29 12:58 ` [PATCH mlx5-next 10/27] net/mlx5: Export packet reformat alloc/dealloc functions Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 11/27] RDMA/mlx5: Add NIC TX steering support Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 12/27] RDMA/uverbs: Add UVERBS_ATTR_CONST_IN to the specs language Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 13/27] RDMA/mlx5: Add a new flow action verb, modify header Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 14/27] RDMA/mlx5: Enable attaching modify header to steering flows Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 15/27] RDMA/mlx5: Enable decap and packet reformat on flow tables Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 16/27] RDMA/uverbs: Add generic function to fill in flow action object Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 17/27] RDMA/mlx5: Add new flow action verb, packet reformat Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 18/27] RDMA/mlx5: Enable attaching DECAP action to steering flows Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 19/27] RDMA/mlx5: Extend packet reformat verbs Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 20/27] RDMA/mlx5: Enable reformat on NIC RX if supported Leon Romanovsky
2018-07-29 12:58 ` [PATCH rdma-next 21/27] RDMA/mlx5: Enable attaching packet reformat action to steering flows Leon Romanovsky
2018-07-29 12:59 ` [PATCH rdma-next 22/27] IB/uverbs: Add IDRs array attribute type to ioctl() interface Leon Romanovsky
2018-07-29 12:59 ` [PATCH rdma-next 23/27] RDMA/mlx5: Refactor flow action parsing to be more generic Leon Romanovsky
2018-07-29 12:59 ` [PATCH rdma-next 24/27] RDMA/mlx5: Refactor DEVX flow creation Leon Romanovsky
2018-07-29 12:59 ` [PATCH rdma-next 25/27] RDMA/mlx5: Add flow actions support to DEVX create flow Leon Romanovsky
2018-07-29 12:59 ` Leon Romanovsky [this message]
2018-07-29 12:59 ` [PATCH rdma-next 27/27] RDMA/mlx5: Allow creating a matcher for a NIC TX flow table Leon Romanovsky
2018-07-30 17:09 ` [PATCH rdma-next 00/27] Flow actions to mutate packets Jason Gunthorpe
2018-07-30 17:37   ` Mark Bloch
2018-07-31 14:11 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180729125905.31989-27-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=guyle@mellanox.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markb@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=saeedm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.