From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>, kuba@kernel.org
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@mellanox.com>,
Parav Pandit <parav@mellanox.com>, Roi Dayan <roid@mellanox.com>,
Bodong Wang <bodong@mellanox.com>,
Mark Bloch <markb@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 14/16] net/mlx5: Split eswitch mode check to different helper function
Date: Wed, 25 Mar 2020 23:38:07 -0700 [thread overview]
Message-ID: <20200326063809.139919-15-saeedm@mellanox.com> (raw)
In-Reply-To: <20200326063809.139919-1-saeedm@mellanox.com>
From: Parav Pandit <parav@mellanox.com>
In order to check eswitch state under a lock, prepare code to split
capability check and eswitch state check into two helper functions.
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Bodong Wang <bodong@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
.../mellanox/mlx5/core/eswitch_offloads.c | 37 +++++++++++++++++--
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 088fb51123e2..53fcb00ddbac 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -2506,13 +2506,18 @@ static int mlx5_eswitch_check(const struct mlx5_core_dev *dev)
if(!MLX5_ESWITCH_MANAGER(dev))
return -EPERM;
- if (dev->priv.eswitch->mode == MLX5_ESWITCH_NONE &&
- !mlx5_core_is_ecpf_esw_manager(dev))
- return -EOPNOTSUPP;
-
return 0;
}
+static int eswitch_devlink_esw_mode_check(const struct mlx5_eswitch *esw)
+{
+ /* devlink commands in NONE eswitch mode are currently supported only
+ * on ECPF.
+ */
+ return (esw->mode == MLX5_ESWITCH_NONE &&
+ !mlx5_core_is_ecpf_esw_manager(esw->dev)) ? -EOPNOTSUPP : 0;
+}
+
int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
struct netlink_ext_ack *extack)
{
@@ -2524,6 +2529,10 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
if (err)
return err;
+ err = eswitch_devlink_esw_mode_check(dev->priv.eswitch);
+ if (err)
+ return err;
+
cur_mlx5_mode = dev->priv.eswitch->mode;
if (esw_mode_from_devlink(mode, &mlx5_mode))
@@ -2549,6 +2558,10 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
if (err)
return err;
+ err = eswitch_devlink_esw_mode_check(dev->priv.eswitch);
+ if (err)
+ return err;
+
return esw_mode_to_devlink(dev->priv.eswitch->mode, mode);
}
@@ -2564,6 +2577,10 @@ int mlx5_devlink_eswitch_inline_mode_set(struct devlink *devlink, u8 mode,
if (err)
return err;
+ err = eswitch_devlink_esw_mode_check(esw);
+ if (err)
+ return err;
+
switch (MLX5_CAP_ETH(dev, wqe_inline_mode)) {
case MLX5_CAP_INLINE_MODE_NOT_REQUIRED:
if (mode == DEVLINK_ESWITCH_INLINE_MODE_NONE)
@@ -2618,6 +2635,10 @@ int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode)
if (err)
return err;
+ err = eswitch_devlink_esw_mode_check(esw);
+ if (err)
+ return err;
+
return esw_inline_mode_to_devlink(esw->offloads.inline_mode, mode);
}
@@ -2633,6 +2654,10 @@ int mlx5_devlink_eswitch_encap_mode_set(struct devlink *devlink,
if (err)
return err;
+ err = eswitch_devlink_esw_mode_check(esw);
+ if (err)
+ return err;
+
if (encap != DEVLINK_ESWITCH_ENCAP_MODE_NONE &&
(!MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) ||
!MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap)))
@@ -2682,6 +2707,10 @@ int mlx5_devlink_eswitch_encap_mode_get(struct devlink *devlink,
if (err)
return err;
+ err = eswitch_devlink_esw_mode_check(esw);
+ if (err)
+ return err;
+
*encap = esw->offloads.encap;
return 0;
}
--
2.25.1
next prev parent reply other threads:[~2020-03-26 6:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 6:37 [pull request][net-next 00/16] Mellanox, mlx5 updates 2020-03-25 Saeed Mahameed
2020-03-26 6:37 ` [net-next 01/16] net/mlx5e: Fix actions_match_supported() return Saeed Mahameed
2020-03-26 6:37 ` [net-next 02/16] net/mlx5e: remove duplicated check chain_index in mlx5e_rep_setup_ft_cb Saeed Mahameed
2020-03-26 6:37 ` [net-next 03/16] net/mlx5: E-Switch, Enable restore table only if reg_c1 is supported Saeed Mahameed
2020-03-26 6:37 ` [net-next 04/16] net/mlx5: E-Switch, Enable chains only if regs loopback is enabled Saeed Mahameed
2020-03-26 6:37 ` [net-next 05/16] net/mlx5: E-Switch, free flow_group_in after creating the restore table Saeed Mahameed
2020-03-26 6:37 ` [net-next 06/16] net/mlx5: E-Switch, Use correct type for chain, prio and level values Saeed Mahameed
2020-03-26 6:38 ` [net-next 07/16] net/mlx5: Simplify matching group searches Saeed Mahameed
2020-03-26 6:38 ` [net-next 08/16] net/mlx5: Fix group version management Saeed Mahameed
2020-03-26 6:38 ` [net-next 09/16] net/mlx5: Avoid incrementing FTE version Saeed Mahameed
2020-03-26 6:38 ` [net-next 10/16] net/mlx5: Avoid group version scan when not necessary Saeed Mahameed
2020-03-26 6:38 ` [net-next 11/16] net/mlx5: Simplify mlx5_register_device to return void Saeed Mahameed
2020-03-26 6:38 ` [net-next 12/16] net/mlx5: Simplify mlx5_unload_one() and its callers Saeed Mahameed
2020-03-26 6:38 ` [net-next 13/16] devlink: Rely on driver eswitch thread safety instead of devlink Saeed Mahameed
2020-03-26 6:38 ` Saeed Mahameed [this message]
2020-03-26 6:38 ` [net-next 15/16] net/mlx5: E-switch, Extend eswitch enable to handle num_vfs change Saeed Mahameed
2020-03-26 6:38 ` [net-next 16/16] net/mlx5: E-switch, Protect eswitch mode changes Saeed Mahameed
2020-03-26 18:39 ` [pull request][net-next 00/16] Mellanox, mlx5 updates 2020-03-25 David Miller
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=20200326063809.139919-15-saeedm@mellanox.com \
--to=saeedm@mellanox.com \
--cc=bodong@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=markb@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=parav@mellanox.com \
--cc=roid@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).