netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Alex Vesker <valex@mellanox.com>,
	Erez Shitrit <erezsh@mellanox.com>,
	Maor Gottlieb <maorg@mellanox.com>,
	Mark Bloch <markb@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 16/18] net/mlx5: Add API to set the namespace steering mode
Date: Mon, 2 Sep 2019 07:23:27 +0000	[thread overview]
Message-ID: <20190902072213.7683-17-saeedm@mellanox.com> (raw)
In-Reply-To: <20190902072213.7683-1-saeedm@mellanox.com>

From: Maor Gottlieb <maorg@mellanox.com>

Add API to set the flow steering root namesapce mode.
Setting new mode should be called before any steering operation
is executed on the namespace.
This API is going to be used by steering users such switchdev.

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../net/ethernet/mellanox/mlx5/core/fs_core.c | 49 +++++++++++++++++++
 .../net/ethernet/mellanox/mlx5/core/fs_core.h | 12 ++++-
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index c2d6e9f4cb90..3bbb49354829 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -2995,5 +2995,54 @@ EXPORT_SYMBOL(mlx5_packet_reformat_dealloc);
 int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
 				 struct mlx5_flow_root_namespace *peer_ns)
 {
+	if (peer_ns && ns->mode != peer_ns->mode) {
+		mlx5_core_err(ns->dev,
+			      "Can't peer namespace of different steering mode\n");
+		return -EINVAL;
+	}
+
 	return ns->cmds->set_peer(ns, peer_ns);
 }
+
+/* This function should be called only at init stage of the namespace.
+ * It is not safe to call this function while steering operations
+ * are executed in the namespace.
+ */
+int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
+				 enum mlx5_flow_steering_mode mode)
+{
+	struct mlx5_flow_root_namespace *root;
+	const struct mlx5_flow_cmds *cmds;
+	int err;
+
+	root = find_root(&ns->node);
+	if (&root->ns != ns)
+	/* Can't set cmds to non root namespace */
+		return -EINVAL;
+
+	if (root->table_type != FS_FT_FDB)
+		return -EOPNOTSUPP;
+
+	if (root->mode == mode)
+		return 0;
+
+	if (mode == MLX5_FLOW_STEERING_MODE_SMFS)
+		cmds = mlx5_fs_cmd_get_dr_cmds();
+	else
+		cmds = mlx5_fs_cmd_get_fw_cmds();
+	if (!cmds)
+		return -EOPNOTSUPP;
+
+	err = cmds->create_ns(root);
+	if (err) {
+		mlx5_core_err(root->dev, "Failed to create flow namespace (%d)\n",
+			      err);
+		return err;
+	}
+
+	root->cmds->destroy_ns(root);
+	root->cmds = cmds;
+	root->mode = mode;
+
+	return 0;
+}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
index a133ec5487ae..00717eba2256 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
@@ -98,9 +98,15 @@ enum fs_fte_status {
 	FS_FTE_STATUS_EXISTING = 1UL << 0,
 };
 
+enum mlx5_flow_steering_mode {
+	MLX5_FLOW_STEERING_MODE_DMFS,
+	MLX5_FLOW_STEERING_MODE_SMFS
+};
+
 struct mlx5_flow_steering {
 	struct mlx5_core_dev *dev;
-	struct kmem_cache               *fgs_cache;
+	enum   mlx5_flow_steering_mode	mode;
+	struct kmem_cache		*fgs_cache;
 	struct kmem_cache               *ftes_cache;
 	struct mlx5_flow_root_namespace *root_ns;
 	struct mlx5_flow_root_namespace *fdb_root_ns;
@@ -235,6 +241,7 @@ struct mlx5_flow_group {
 
 struct mlx5_flow_root_namespace {
 	struct mlx5_flow_namespace	ns;
+	enum   mlx5_flow_steering_mode	mode;
 	struct mlx5_fs_dr_domain	fs_dr_domain;
 	enum   fs_flow_table_type	table_type;
 	struct mlx5_core_dev		*dev;
@@ -258,6 +265,9 @@ const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
 int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
 				 struct mlx5_flow_root_namespace *peer_ns);
 
+int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
+				 enum mlx5_flow_steering_mode mode);
+
 int mlx5_init_fs(struct mlx5_core_dev *dev);
 void mlx5_cleanup_fs(struct mlx5_core_dev *dev);
 
-- 
2.21.0


  parent reply	other threads:[~2019-09-02  7:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-02  7:22 [pull request][net-next 00/18] Mellanox, mlx5 software managed steering Saeed Mahameed
2019-09-02  7:22 ` [net-next 01/18] net/mlx5: Add flow steering actions to fs_cmd shim layer Saeed Mahameed
2019-09-02 19:10   ` David Miller
2019-09-03 20:08     ` Saeed Mahameed
2019-09-02  7:22 ` [net-next 02/18] net/mlx5: DR, Add the internal direct rule types definitions Saeed Mahameed
2019-09-02  7:22 ` [net-next 03/18] net/mlx5: DR, Add direct rule command utilities Saeed Mahameed
2019-09-02  7:22 ` [net-next 04/18] net/mlx5: DR, ICM pool memory allocator Saeed Mahameed
2019-09-02  7:23 ` [net-next 05/18] net/mlx5: DR, Expose an internal API to issue RDMA operations Saeed Mahameed
2019-09-02  7:23 ` [net-next 06/18] net/mlx5: DR, Add Steering entry (STE) utilities Saeed Mahameed
2019-09-02  7:23 ` [net-next 07/18] net/mlx5: DR, Expose steering domain functionality Saeed Mahameed
2019-09-02  7:23 ` [net-next 08/18] net/mlx5: DR, Expose steering table functionality Saeed Mahameed
2019-09-02  7:23 ` [net-next 09/18] net/mlx5: DR, Expose steering matcher functionality Saeed Mahameed
2019-09-02  7:23 ` [net-next 10/18] net/mlx5: DR, Expose steering action functionality Saeed Mahameed
2019-09-02  7:23 ` [net-next 11/18] net/mlx5: DR, Expose steering rule functionality Saeed Mahameed
2019-09-02  7:23 ` [net-next 12/18] net/mlx5: DR, Add required FW steering functionality Saeed Mahameed
2019-09-02  7:23 ` [net-next 13/18] net/mlx5: DR, Expose APIs for direct rule managing Saeed Mahameed
2019-09-02  7:23 ` [net-next 14/18] net/mlx5: DR, Add CONFIG_MLX5_SW_STEERING for software steering support Saeed Mahameed
2019-09-02  7:23 ` [net-next 15/18] net/mlx5: Add direct rule fs_cmd implementation Saeed Mahameed
2019-09-02  7:23 ` Saeed Mahameed [this message]
2019-09-02  7:23 ` [net-next 17/18] net/mlx5: Add support to use SMFS in switchdev mode Saeed Mahameed
2019-09-02  7:23 ` [net-next 18/18] net/mlx5: Add devlink flow_steering_mode parameter Saeed Mahameed

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=20190902072213.7683-17-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=erezsh@mellanox.com \
    --cc=maorg@mellanox.com \
    --cc=markb@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=valex@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).