All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Saeed Mahameed <saeedm@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Eran Ben Elisha <eranbe@mellanox.com>
Subject: Re: [net-next 10/16] net/mlx5: Support PCIe buffer congestion handling via Devlink
Date: Thu, 19 Jul 2018 10:24:00 +0200	[thread overview]
Message-ID: <20180719082400.GG2184@nanopsycho.orion> (raw)
In-Reply-To: <20180719010107.22363-11-saeedm@mellanox.com>

Thu, Jul 19, 2018 at 03:01:01AM CEST, saeedm@mellanox.com wrote:
>From: Eran Ben Elisha <eranbe@mellanox.com>
>
>Add support for two driver parameters via devlink params interface:
>- Congestion action
>	HW mechanism in the PCIe buffer which monitors the amount of
>	consumed PCIe buffer per host.  This mechanism supports the
>	following actions in case of threshold overflow:
>	- Disabled - NOP (Default)
>	- Drop
>	- Mark - Mark CE bit in the CQE of received packet
>- Congestion mode
>	- Aggressive - Aggressive static trigger threshold (Default)
>	- Dynamic - Dynamically change the trigger threshold
>
>Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
>Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
>Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
>---
> .../net/ethernet/mellanox/mlx5/core/devlink.c | 105 +++++++++++++++++-
> 1 file changed, 104 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>index 9800c98b01d3..1f04decef043 100644
>--- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>+++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>@@ -153,12 +153,115 @@ static int mlx5_devlink_query_tx_overflow_sense(struct mlx5_core_dev *mdev,
> 	return 0;
> }
> 
>+static int mlx5_devlink_set_congestion_action(struct devlink *devlink, u32 id,
>+					      struct devlink_param_gset_ctx *ctx)
>+{
>+	struct mlx5_core_dev *dev = devlink_priv(devlink);
>+	u8 max = MLX5_DEVLINK_CONGESTION_ACTION_MAX;
>+	u8 sense;
>+	int err;
>+
>+	if (!MLX5_CAP_MCAM_FEATURE(dev, mark_tx_action_cqe) &&
>+	    !MLX5_CAP_MCAM_FEATURE(dev, mark_tx_action_cnp))
>+		max = MLX5_DEVLINK_CONGESTION_ACTION_MARK - 1;
>+
>+	if (ctx->val.vu8 > max)

This should not be num. It should be a string. Same for "mode".


>+		return -ERANGE;
>+
>+	err = mlx5_devlink_query_tx_overflow_sense(dev, &sense);
>+	if (err)
>+		return err;
>+
>+	if (ctx->val.vu8 == MLX5_DEVLINK_CONGESTION_ACTION_DISABLED &&
>+	    sense != MLX5_DEVLINK_CONGESTION_MODE_AGGRESSIVE)
>+		return -EINVAL;
>+
>+	return mlx5_devlink_set_tx_lossy_overflow(dev, ctx->val.vu8);
>+}
>+
>+static int mlx5_devlink_get_congestion_action(struct devlink *devlink, u32 id,
>+					      struct devlink_param_gset_ctx *ctx)
>+{
>+	struct mlx5_core_dev *dev = devlink_priv(devlink);
>+
>+	return mlx5_devlink_query_tx_lossy_overflow(dev, &ctx->val.vu8);
>+}
>+
>+static int mlx5_devlink_set_congestion_mode(struct devlink *devlink, u32 id,
>+					    struct devlink_param_gset_ctx *ctx)
>+{
>+	struct mlx5_core_dev *dev = devlink_priv(devlink);
>+	u8 tx_lossy_overflow;
>+	int err;
>+
>+	if (ctx->val.vu8 > MLX5_DEVLINK_CONGESTION_MODE_MAX)
>+		return -ERANGE;
>+
>+	err = mlx5_devlink_query_tx_lossy_overflow(dev, &tx_lossy_overflow);
>+	if (err)
>+		return err;
>+
>+	if (ctx->val.vu8 != MLX5_DEVLINK_CONGESTION_MODE_AGGRESSIVE &&
>+	    tx_lossy_overflow == MLX5_DEVLINK_CONGESTION_ACTION_DISABLED)
>+		return -EINVAL;
>+
>+	return mlx5_devlink_set_tx_overflow_sense(dev, ctx->val.vu8);
>+}
>+
>+static int mlx5_devlink_get_congestion_mode(struct devlink *devlink, u32 id,
>+					    struct devlink_param_gset_ctx *ctx)
>+{
>+	struct mlx5_core_dev *dev = devlink_priv(devlink);
>+
>+	return mlx5_devlink_query_tx_overflow_sense(dev, &ctx->val.vu8);
>+}
>+
>+enum mlx5_devlink_param_id {
>+	MLX5_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
>+	MLX5_DEVLINK_PARAM_ID_CONGESTION_ACTION,
>+	MLX5_DEVLINK_PARAM_ID_CONGESTION_MODE,
>+};
>+
>+static const struct devlink_param mlx5_devlink_params[] = {
>+	DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CONGESTION_ACTION,
>+			     "congestion_action",
>+			     DEVLINK_PARAM_TYPE_U8,
>+			     BIT(DEVLINK_PARAM_CMODE_RUNTIME),
>+			     mlx5_devlink_get_congestion_action,
>+			     mlx5_devlink_set_congestion_action, NULL),
>+	DEVLINK_PARAM_DRIVER(MLX5_DEVLINK_PARAM_ID_CONGESTION_MODE,
>+			     "congestion_mode",
>+			     DEVLINK_PARAM_TYPE_U8,
>+			     BIT(DEVLINK_PARAM_CMODE_RUNTIME),
>+			     mlx5_devlink_get_congestion_mode,
>+			     mlx5_devlink_set_congestion_mode, NULL),
>+};
>+
> int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
> {
>-	return devlink_register(devlink, dev);
>+	int err;
>+
>+	err = devlink_register(devlink, dev);
>+	if (err)
>+		return err;
>+
>+	err = devlink_params_register(devlink, mlx5_devlink_params,
>+				      ARRAY_SIZE(mlx5_devlink_params));
>+	if (err) {
>+		dev_err(dev, "devlink_params_register failed, err = %d\n", err);
>+		goto unregister;
>+	}
>+
>+	return 0;
>+
>+unregister:
>+	devlink_unregister(devlink);
>+	return err;
> }
> 
> void mlx5_devlink_unregister(struct devlink *devlink)
> {
>+	devlink_params_unregister(devlink, mlx5_devlink_params,
>+				  ARRAY_SIZE(mlx5_devlink_params));
> 	devlink_unregister(devlink);
> }
>-- 
>2.17.0
>

  parent reply	other threads:[~2018-07-19  9:08 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19  1:00 [pull request][net-next 00/16] Mellanox, mlx5e updates 2018-07-18 Saeed Mahameed
2018-07-19  1:00 ` [net-next 01/16] net/mlx5: FW tracer, implement tracer logic Saeed Mahameed
2018-07-19  1:00 ` [net-next 02/16] net/mlx5: FW tracer, create trace buffer and copy strings database Saeed Mahameed
2018-07-19  1:00 ` [net-next 03/16] net/mlx5: FW tracer, register log buffer memory key Saeed Mahameed
2018-07-19  1:00 ` [net-next 04/16] net/mlx5: FW tracer, events handling Saeed Mahameed
2018-07-19  1:00 ` [net-next 05/16] net/mlx5: FW tracer, parse traces and kernel tracing support Saeed Mahameed
2018-07-19  1:00 ` [net-next 06/16] net/mlx5: FW tracer, Enable tracing Saeed Mahameed
2018-07-19  1:00 ` [net-next 07/16] net/mlx5: FW tracer, Add debug prints Saeed Mahameed
2018-07-19  1:00 ` [net-next 08/16] net/mlx5: Move all devlink related functions calls to devlink.c Saeed Mahameed
2018-07-19  1:01 ` [net-next 09/16] net/mlx5: Add MPEGC register configuration functionality Saeed Mahameed
2018-07-19  1:01 ` [net-next 10/16] net/mlx5: Support PCIe buffer congestion handling via Devlink Saeed Mahameed
2018-07-19  1:49   ` Jakub Kicinski
2018-07-24 10:31     ` Eran Ben Elisha
2018-07-24 19:51       ` Jakub Kicinski
2018-07-25 12:31         ` Eran Ben Elisha
2018-07-25 15:23           ` Alexander Duyck
2018-07-26  0:43             ` Jakub Kicinski
2018-07-26  7:14               ` Jiri Pirko
2018-07-26 14:00                 ` Alexander Duyck
2018-07-28 16:06                   ` Bjorn Helgaas
2018-07-29  9:23                     ` Moshe Shemesh
2018-07-29 22:00                       ` Alexander Duyck
2018-07-30 14:07                         ` Bjorn Helgaas
2018-07-30 15:02                           ` Alexander Duyck
2018-07-30 22:00                             ` Jakub Kicinski
2018-07-31  2:33                             ` Bjorn Helgaas
2018-07-31  3:19                               ` Alexander Duyck
2018-07-31 11:06                                 ` Bjorn Helgaas
2018-08-01 18:28                                   ` Moshe Shemesh
2018-07-19  8:24   ` Jiri Pirko [this message]
2018-07-19  8:49     ` Eran Ben Elisha
2018-07-19  1:01 ` [net-next 11/16] net/mlx5e: Set ECN for received packets using CQE indication Saeed Mahameed
2018-07-19  1:01 ` [net-next 12/16] net/mlx5e: Remove redundant WARN when we cannot find neigh entry Saeed Mahameed
2018-07-19  1:01 ` [net-next 13/16] net/mlx5e: Support offloading tc double vlan headers match Saeed Mahameed
2018-07-19  1:01 ` [net-next 14/16] net/mlx5e: Refactor tc vlan push/pop actions offloading Saeed Mahameed
2018-07-19  1:01 ` [net-next 15/16] net/mlx5e: Support offloading double vlan push/pop tc actions Saeed Mahameed
2018-07-19  1:01 ` [net-next 16/16] net/mlx5e: Use PARTIAL_GSO for UDP segmentation Saeed Mahameed
2018-07-23 21:35 ` [pull request][net-next 00/16] Mellanox, mlx5e updates 2018-07-18 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=20180719082400.GG2184@nanopsycho.orion \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --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.