From: Saeed Mahameed <saeedm@mellanox.com>
To: Saeed Mahameed <saeedm@mellanox.com>,
Leon Romanovsky <leonro@mellanox.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Cc: Eli Cohen <eli@mellanox.com>, Paul Blakey <paulb@mellanox.com>
Subject: [PATCH mlx5-next 05/11] net/mlx5: E-Switch, Verify support QoS element type
Date: Mon, 29 Jul 2019 21:13:00 +0000 [thread overview]
Message-ID: <20190729211209.14772-6-saeedm@mellanox.com> (raw)
In-Reply-To: <20190729211209.14772-1-saeedm@mellanox.com>
From: Eli Cohen <eli@mellanox.com>
Check if firmware supports the requested element type before
attempting to create the element type.
In addition, explicitly specify the request element type and tsar type.
Signed-off-by: Eli Cohen <eli@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/eswitch.c | 31 +++++++++++++++++++
include/linux/mlx5/mlx5_ifc.h | 7 +++++
2 files changed, 38 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 1f3891fde2eb..2927fa1da92f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1393,19 +1393,50 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
return err;
}
+static bool element_type_supported(struct mlx5_eswitch *esw, int type)
+{
+ struct mlx5_core_dev *dev = esw->dev = esw->dev;
+
+ switch (type) {
+ case SCHEDULING_CONTEXT_ELEMENT_TYPE_TSAR:
+ return MLX5_CAP_QOS(dev, esw_element_type) &
+ ELEMENT_TYPE_CAP_MASK_TASR;
+ case SCHEDULING_CONTEXT_ELEMENT_TYPE_VPORT:
+ return MLX5_CAP_QOS(dev, esw_element_type) &
+ ELEMENT_TYPE_CAP_MASK_VPORT;
+ case SCHEDULING_CONTEXT_ELEMENT_TYPE_VPORT_TC:
+ return MLX5_CAP_QOS(dev, esw_element_type) &
+ ELEMENT_TYPE_CAP_MASK_VPORT_TC;
+ case SCHEDULING_CONTEXT_ELEMENT_TYPE_PARA_VPORT_TC:
+ return MLX5_CAP_QOS(dev, esw_element_type) &
+ ELEMENT_TYPE_CAP_MASK_PARA_VPORT_TC;
+ }
+ return false;
+}
+
/* Vport QoS management */
static int esw_create_tsar(struct mlx5_eswitch *esw)
{
u32 tsar_ctx[MLX5_ST_SZ_DW(scheduling_context)] = {0};
struct mlx5_core_dev *dev = esw->dev;
+ __be32 *attr;
int err;
if (!MLX5_CAP_GEN(dev, qos) || !MLX5_CAP_QOS(dev, esw_scheduling))
return 0;
+ if (!element_type_supported(esw, SCHEDULING_CONTEXT_ELEMENT_TYPE_TSAR))
+ return 0;
+
if (esw->qos.enabled)
return -EEXIST;
+ MLX5_SET(scheduling_context, tsar_ctx, element_type,
+ SCHEDULING_CONTEXT_ELEMENT_TYPE_TSAR);
+
+ attr = MLX5_ADDR_OF(scheduling_context, tsar_ctx, element_attributes);
+ *attr = cpu_to_be32(TSAR_ELEMENT_TSAR_TYPE_DWRR << 16);
+
err = mlx5_create_scheduling_element_cmd(dev,
SCHEDULING_HIERARCHY_E_SWITCH,
tsar_ctx,
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 9265c84ad353..30d15e80bcc7 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -2957,6 +2957,13 @@ enum {
SCHEDULING_CONTEXT_ELEMENT_TYPE_PARA_VPORT_TC = 0x3,
};
+enum {
+ ELEMENT_TYPE_CAP_MASK_TASR = 1 << 0,
+ ELEMENT_TYPE_CAP_MASK_VPORT = 1 << 1,
+ ELEMENT_TYPE_CAP_MASK_VPORT_TC = 1 << 2,
+ ELEMENT_TYPE_CAP_MASK_PARA_VPORT_TC = 1 << 3,
+};
+
struct mlx5_ifc_scheduling_context_bits {
u8 element_type[0x8];
u8 reserved_at_8[0x18];
--
2.21.0
next prev parent reply other threads:[~2019-07-29 21:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 21:12 [PATCH mlx5-next 00/11] Mellanox, mlx5-next updates 2019-07-29 Saeed Mahameed
2019-07-29 21:12 ` [PATCH mlx5-next 01/11] net/mlx5: Refactor and optimize flow counter bulk query Saeed Mahameed
2019-07-29 21:12 ` [PATCH mlx5-next 02/11] net/mlx5: Add flow counter bulk allocation hardware bits and command Saeed Mahameed
2019-07-29 21:12 ` [PATCH mlx5-next 03/11] net/mlx5: Fix offset of tisc bits reserved field Saeed Mahameed
2019-07-29 21:12 ` [PATCH mlx5-next 04/11] net/mlx5: Make load_one() and unload_one() symmetric Saeed Mahameed
2019-07-29 21:13 ` Saeed Mahameed [this message]
2019-07-29 21:13 ` [PATCH mlx5-next 06/11] net/mlx5: E-switch, Combine metadata enable/disable functionality Saeed Mahameed
2019-07-29 21:13 ` [PATCH mlx5-next 07/11] net/mlx5: E-switch, Initialize TSAR Qos hardware block before its user vports Saeed Mahameed
2019-07-29 21:13 ` [PATCH mlx5-next 08/11] net/mlx5: E-switch, Introduce helper function to enable/disable vports Saeed Mahameed
2019-07-29 21:13 ` [PATCH mlx5-next 09/11] net/mlx5: E-Switch, remove redundant error handling Saeed Mahameed
2019-07-29 21:13 ` [PATCH mlx5-next 10/11] net/mlx5: E-Switch, Remove redundant mc_promisc NULL check Saeed Mahameed
2019-07-29 21:13 ` [PATCH mlx5-next 11/11] net/mlx5: E-switch, Tide up eswitch config sequence Saeed Mahameed
2019-08-01 18:23 ` [PATCH mlx5-next 00/11] Mellanox, mlx5-next updates 2019-07-29 Saeed Mahameed
2019-08-01 18:23 ` 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=20190729211209.14772-6-saeedm@mellanox.com \
--to=saeedm@mellanox.com \
--cc=eli@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulb@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