@@ -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_ */
@@ -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;
@@ -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,