From: Tariq Toukan <tariqt@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>
Cc: <netdev@vger.kernel.org>, Saeed Mahameed <saeedm@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>,
Carolina Jubran <cjubran@nvidia.com>,
Cosmin Ratiu <cratiu@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>
Subject: [PATCH net-next 02/12] net/mlx5: Simplify QoS normalization by removing error handling
Date: Thu, 7 Nov 2024 21:43:47 +0200 [thread overview]
Message-ID: <20241107194357.683732-3-tariqt@nvidia.com> (raw)
In-Reply-To: <20241107194357.683732-1-tariqt@nvidia.com>
From: Carolina Jubran <cjubran@nvidia.com>
This change updates esw_qos_normalize_min_rate to not return errors,
significantly simplifying the code.
Normalization failures are software bugs, and it's unnecessary to
handle them with rollback mechanisms. Instead,
`esw_qos_update_sched_node_bw_share` and `esw_qos_normalize_min_rate`
now return void, with any errors logged as warnings to indicate
potential software issues.
This approach avoids compensating for hidden bugs and removes error
handling from all places that perform normalization, streamlining
future patches.
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/esw/qos.c | 72 +++++--------------
1 file changed, 17 insertions(+), 55 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
index 940e1c2d1e39..0c371f27c693 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c
@@ -208,64 +208,49 @@ static u32 esw_qos_calc_bw_share(u32 min_rate, u32 divider, u32 fw_max)
return min_t(u32, max_t(u32, DIV_ROUND_UP(min_rate, divider), MLX5_MIN_BW_SHARE), fw_max);
}
-static int esw_qos_update_sched_node_bw_share(struct mlx5_esw_sched_node *node,
- u32 divider,
- struct netlink_ext_ack *extack)
+static void esw_qos_update_sched_node_bw_share(struct mlx5_esw_sched_node *node,
+ u32 divider,
+ struct netlink_ext_ack *extack)
{
u32 fw_max_bw_share = MLX5_CAP_QOS(node->esw->dev, max_tsar_bw_share);
u32 bw_share;
- int err;
bw_share = esw_qos_calc_bw_share(node->min_rate, divider, fw_max_bw_share);
if (bw_share == node->bw_share)
- return 0;
-
- err = esw_qos_sched_elem_config(node, node->max_rate, bw_share, extack);
- if (err)
- return err;
+ return;
+ esw_qos_sched_elem_config(node, node->max_rate, bw_share, extack);
node->bw_share = bw_share;
-
- return err;
}
-static int esw_qos_normalize_min_rate(struct mlx5_eswitch *esw,
- struct mlx5_esw_sched_node *parent,
- struct netlink_ext_ack *extack)
+static void esw_qos_normalize_min_rate(struct mlx5_eswitch *esw,
+ struct mlx5_esw_sched_node *parent,
+ struct netlink_ext_ack *extack)
{
struct list_head *nodes = parent ? &parent->children : &esw->qos.domain->nodes;
u32 divider = esw_qos_calculate_min_rate_divider(esw, parent);
struct mlx5_esw_sched_node *node;
list_for_each_entry(node, nodes, entry) {
- int err;
-
if (node->esw != esw || node->ix == esw->qos.root_tsar_ix)
continue;
- err = esw_qos_update_sched_node_bw_share(node, divider, extack);
- if (err)
- return err;
+ esw_qos_update_sched_node_bw_share(node, divider, extack);
if (list_empty(&node->children))
continue;
- err = esw_qos_normalize_min_rate(node->esw, node, extack);
- if (err)
- return err;
+ esw_qos_normalize_min_rate(node->esw, node, extack);
}
-
- return 0;
}
static int esw_qos_set_vport_min_rate(struct mlx5_vport *vport,
u32 min_rate, struct netlink_ext_ack *extack)
{
struct mlx5_esw_sched_node *vport_node = vport->qos.sched_node;
- u32 fw_max_bw_share, previous_min_rate;
bool min_rate_supported;
- int err;
+ u32 fw_max_bw_share;
esw_assert_qos_lock_held(vport_node->esw);
fw_max_bw_share = MLX5_CAP_QOS(vport->dev, max_tsar_bw_share);
@@ -276,13 +261,10 @@ static int esw_qos_set_vport_min_rate(struct mlx5_vport *vport,
if (min_rate == vport_node->min_rate)
return 0;
- previous_min_rate = vport_node->min_rate;
vport_node->min_rate = min_rate;
- err = esw_qos_normalize_min_rate(vport_node->parent->esw, vport_node->parent, extack);
- if (err)
- vport_node->min_rate = previous_min_rate;
+ esw_qos_normalize_min_rate(vport_node->parent->esw, vport_node->parent, extack);
- return err;
+ return 0;
}
static int esw_qos_set_vport_max_rate(struct mlx5_vport *vport,
@@ -316,8 +298,6 @@ static int esw_qos_set_node_min_rate(struct mlx5_esw_sched_node *node,
u32 min_rate, struct netlink_ext_ack *extack)
{
struct mlx5_eswitch *esw = node->esw;
- u32 previous_min_rate;
- int err;
if (!MLX5_CAP_QOS(esw->dev, esw_bw_share) ||
MLX5_CAP_QOS(esw->dev, max_tsar_bw_share) < MLX5_MIN_BW_SHARE)
@@ -326,19 +306,10 @@ static int esw_qos_set_node_min_rate(struct mlx5_esw_sched_node *node,
if (min_rate == node->min_rate)
return 0;
- previous_min_rate = node->min_rate;
node->min_rate = min_rate;
- err = esw_qos_normalize_min_rate(esw, NULL, extack);
- if (err) {
- NL_SET_ERR_MSG_MOD(extack, "E-Switch node min rate setting failed");
-
- /* Attempt restoring previous configuration */
- node->min_rate = previous_min_rate;
- if (esw_qos_normalize_min_rate(esw, NULL, extack))
- NL_SET_ERR_MSG_MOD(extack, "E-Switch BW share restore failed");
- }
+ esw_qos_normalize_min_rate(esw, NULL, extack);
- return err;
+ return 0;
}
static int esw_qos_set_node_max_rate(struct mlx5_esw_sched_node *node,
@@ -552,17 +523,11 @@ __esw_qos_create_vports_sched_node(struct mlx5_eswitch *esw, struct mlx5_esw_sch
goto err_alloc_node;
}
- err = esw_qos_normalize_min_rate(esw, NULL, extack);
- if (err) {
- NL_SET_ERR_MSG_MOD(extack, "E-Switch nodes normalization failed");
- goto err_min_rate;
- }
+ esw_qos_normalize_min_rate(esw, NULL, extack);
trace_mlx5_esw_node_qos_create(esw->dev, node, node->ix);
return node;
-err_min_rate:
- __esw_qos_free_node(node);
err_alloc_node:
if (mlx5_destroy_scheduling_element_cmd(esw->dev,
SCHEDULING_HIERARCHY_E_SWITCH,
@@ -609,10 +574,7 @@ static int __esw_qos_destroy_node(struct mlx5_esw_sched_node *node, struct netli
NL_SET_ERR_MSG_MOD(extack, "E-Switch destroy TSAR_ID failed");
__esw_qos_free_node(node);
- err = esw_qos_normalize_min_rate(esw, NULL, extack);
- if (err)
- NL_SET_ERR_MSG_MOD(extack, "E-Switch nodes normalization failed");
-
+ esw_qos_normalize_min_rate(esw, NULL, extack);
return err;
}
--
2.44.0
next prev parent reply other threads:[~2024-11-07 19:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 19:43 [PATCH net-next 00/12] mlx5 esw qos refactor and SHAMPO cleanup Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 01/12] net/mlx5: E-switch, refactor eswitch mode change Tariq Toukan
2024-11-07 19:43 ` Tariq Toukan [this message]
2024-11-07 19:43 ` [PATCH net-next 03/12] net/mlx5: Generalize max_rate and min_rate setting for nodes Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 04/12] net/mlx5: Refactor scheduling element configuration bitmasks Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 05/12] net/mlx5: Generalize scheduling element operations Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 06/12] net/mlx5: Integrate esw_qos_vport_enable logic into rate operations Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 07/12] net/mlx5: Make vport QoS enablement more flexible for future extensions Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 08/12] net/mlx5e: SHAMPO, Simplify UMR allocation for headers Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 09/12] net/mlx5e: SHAMPO, Fix page_index calculation inconsistency Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 10/12] net/mlx5e: SHAMPO, Change frag page setup order during allocation Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 11/12] net/mlx5e: SHAMPO, Drop info array Tariq Toukan
2024-11-07 19:43 ` [PATCH net-next 12/12] net/mlx5e: SHAMPO, Rework header allocation loop Tariq Toukan
2024-11-12 3:40 ` [PATCH net-next 00/12] mlx5 esw qos refactor and SHAMPO cleanup patchwork-bot+netdevbpf
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=20241107194357.683732-3-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.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.