From: Gregory Etelson <getelson@nvidia.com>
To: <dev@dpdk.org>
Cc: getelson@nvidia.com, <mkashani@nvidia.com>,
rasland@nvidia.com, "Dariusz Sosnowski" <dsosnowski@nvidia.com>,
"Viacheslav Ovsiienko" <viacheslavo@nvidia.com>,
"Bing Zhao" <bingz@nvidia.com>, "Ori Kam" <orika@nvidia.com>,
"Suanming Mou" <suanmingm@nvidia.com>,
"Matan Azrad" <matan@nvidia.com>
Subject: [PATCH] net/mlx5: validate HWS context in meter operations
Date: Sun, 27 Oct 2024 17:42:05 +0200 [thread overview]
Message-ID: <20241027154205.198727-1-getelson@nvidia.com> (raw)
HWS context is created during port configuration.
PMD allowed meter operations before port configuration.
The patch rejects HWS meter operations before port configuration.
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
drivers/net/mlx5/mlx5.h | 18 ++++++++++++++
drivers/net/mlx5/mlx5_flow_hw.c | 7 +++++-
drivers/net/mlx5/mlx5_flow_meter.c | 40 ++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 0e026f7bbb..503366580b 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -2682,4 +2682,22 @@ int mlx5_quota_query(struct rte_eth_dev *dev, uint32_t queue,
int mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev);
void mlx5_free_srh_flex_parser(struct rte_eth_dev *dev);
+
+/* mlx5_flow_hw.c */
+struct rte_pmd_mlx5_host_action;
+
+struct mlx5dr_action *
+mlx5_flow_hw_get_dr_action(struct rte_eth_dev *dev,
+ struct rte_pmd_mlx5_host_action *action,
+ void **release_data);
+
+void
+mlx5_flow_hw_put_dr_action(struct rte_eth_dev *dev,
+ enum rte_flow_action_type type,
+ void *release_data);
+
+bool
+mlx5_hw_ctx_validate(const struct rte_eth_dev *dev,
+ struct rte_flow_error *error);
+
#endif /* RTE_PMD_MLX5_H_ */
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 5b34154bf1..9c33004c09 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -208,7 +208,12 @@ mlx5_destroy_multi_pattern_segment(struct mlx5_multi_pattern_segment *segment);
static __rte_always_inline enum mlx5_indirect_list_type
flow_hw_inlist_type_get(const struct rte_flow_action *actions);
-static bool
+static int
+flow_hw_allocate_actions(struct rte_eth_dev *dev,
+ uint64_t action_flags,
+ struct rte_flow_error *error);
+
+bool
mlx5_hw_ctx_validate(const struct rte_eth_dev *dev, struct rte_flow_error *error)
{
const struct mlx5_priv *priv = dev->data->dev_private;
diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index 19d8607070..299265f8bc 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -745,6 +745,10 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (!priv->mtr_en)
return -rte_mtr_error_set(error, ENOTSUP,
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -903,6 +907,12 @@ mlx5_flow_meter_profile_get(struct rte_eth_dev *dev,
{
struct mlx5_priv *priv = dev->data->dev_private;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL)) {
+ rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
+ return NULL;
+ }
if (!priv->mtr_en) {
rte_mtr_error_set(error, ENOTSUP,
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -939,6 +949,10 @@ mlx5_flow_meter_profile_hws_add(struct rte_eth_dev *dev,
struct mlx5_flow_meter_profile *fmp;
int ret;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (priv->shared_host)
return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
"Meter profiles cannot be created on guest port");
@@ -1167,6 +1181,10 @@ mlx5_flow_meter_policy_hws_validate(struct rte_eth_dev *dev,
int ret;
int i;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (!priv->mtr_en || !priv->sh->meter_aso_en)
return -rte_mtr_error_set(error, ENOTSUP,
RTE_MTR_ERROR_TYPE_METER_POLICY,
@@ -1496,6 +1514,12 @@ mlx5_flow_meter_policy_get(struct rte_eth_dev *dev,
struct mlx5_priv *priv = dev->data->dev_private;
uint32_t policy_idx;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL)) {
+ rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
+ return NULL;
+ }
if (!priv->mtr_en) {
rte_mtr_error_set(error, ENOTSUP,
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -1645,6 +1669,10 @@ mlx5_flow_meter_policy_hws_add(struct rte_eth_dev *dev,
[1] = { .type = RTE_FLOW_ITEM_TYPE_END }
};
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (!priv->mtr_policy_arr)
return mlx5_flow_meter_policy_add(dev, policy_id, policy, error);
mtr_policy = mlx5_flow_meter_policy_find(dev, policy_id, NULL);
@@ -2230,6 +2258,10 @@ mlx5_flow_meter_hws_create(struct rte_eth_dev *dev, uint32_t meter_id,
struct mlx5_hw_q_job *job;
int ret;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (!priv->mtr_profile_arr ||
!priv->mtr_policy_arr ||
!priv->mtr_bulk.aso)
@@ -2520,6 +2552,10 @@ mlx5_flow_meter_enable(struct rte_eth_dev *dev,
struct mlx5_flow_meter_info *fm;
int ret;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (!priv->mtr_en)
return -rte_mtr_error_set(error, ENOTSUP,
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -2609,6 +2645,10 @@ mlx5_flow_meter_profile_update(struct rte_eth_dev *dev,
MLX5_FLOW_METER_OBJ_MODIFY_FIELD_CIR;
int ret;
+ if (mlx5_hws_active(dev) && !mlx5_hw_ctx_validate(dev, NULL))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
+ "non-template flow engine was not configured");
if (!priv->mtr_en)
return -rte_mtr_error_set(error, ENOTSUP,
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
--
2.43.0
reply other threads:[~2024-10-27 15:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20241027154205.198727-1-getelson@nvidia.com \
--to=getelson@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=mkashani@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@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 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).