From 5bc38358b544766ac69ab7ab7c9a2edcbb98b171 Mon Sep 17 00:00:00 2001 From: Michael Baum Date: Tue, 19 Oct 2021 23:55:51 +0300 Subject: [PATCH] net/mlx5: remove redundant flag in device config Device configure structure has flag named devx as same as SH structure with the same meaning. Remove the flag from the configuration structure and move all the usages to the SH flag. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 15 +++++++-------- drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow_dv.c | 18 +++++++++--------- drivers/net/mlx5/mlx5_trigger.c | 2 +- drivers/net/mlx5/windows/mlx5_os.c | 9 ++++----- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 8a28545b60..e8370b4fd8 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -718,7 +718,7 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) fallback = true; #else fallback = false; - if (!priv->config.devx || !priv->config.dv_flow_en || + if (!sh->devx || !priv->config.dv_flow_en || !priv->config.hca_attr.flow_counters_dump || !(priv->config.hca_attr.flow_counter_bulk_alloc_bitmap & 0x4) || (mlx5_flow_dv_discover_counter_offset_support(dev) == -ENOTSUP)) @@ -1024,7 +1024,6 @@ err_secondary: sh = mlx5_alloc_shared_dev_ctx(spawn, config); if (!sh) return NULL; - config->devx = sh->devx; #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR config->dest_tir = 1; #endif @@ -1332,7 +1331,7 @@ err_secondary: config->mps == MLX5_MPW_ENHANCED ? "enhanced " : config->mps == MLX5_MPW ? "legacy " : "", config->mps != MLX5_MPW_DISABLED ? "enabled" : "disabled"); - if (config->devx) { + if (sh->devx) { err = mlx5_devx_cmd_query_hca_attr(sh->ctx, &config->hca_attr); if (err) { err = -err; @@ -1475,13 +1474,13 @@ err_secondary: config->cqe_comp = 0; } if (config->cqe_comp_fmt == MLX5_CQE_RESP_FORMAT_FTAG_STRIDX && - (!config->devx || !config->hca_attr.mini_cqe_resp_flow_tag)) { + (!sh->devx || !config->hca_attr.mini_cqe_resp_flow_tag)) { DRV_LOG(WARNING, "Flow Tag CQE compression" " format isn't supported."); config->cqe_comp = 0; } if (config->cqe_comp_fmt == MLX5_CQE_RESP_FORMAT_L34H_STRIDX && - (!config->devx || !config->hca_attr.mini_cqe_resp_l3_l4_tag)) { + (!sh->devx || !config->hca_attr.mini_cqe_resp_l3_l4_tag)) { DRV_LOG(WARNING, "L3/L4 Header CQE compression" " format isn't supported."); config->cqe_comp = 0; @@ -1504,7 +1503,7 @@ err_secondary: config->hca_attr.log_max_static_sq_wq); DRV_LOG(DEBUG, "WQE rate PP mode is %ssupported", config->hca_attr.qos.wqe_rate_pp ? "" : "not "); - if (!config->devx) { + if (!sh->devx) { DRV_LOG(ERR, "DevX is required for packet pacing"); err = ENODEV; goto error; @@ -1551,7 +1550,7 @@ err_secondary: goto error; #endif } - if (config->devx) { + if (sh->devx) { uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; err = config->hca_attr.access_register_user ? @@ -1742,7 +1741,7 @@ err_secondary: if (err) goto error; } - if (config->devx && config->dv_flow_en && config->dest_tir) { + if (sh->devx && config->dv_flow_en && config->dest_tir) { priv->obj_ops = devx_obj_ops; priv->obj_ops.drop_action_create = ibv_obj_ops.drop_action_create; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index d850f18845..899655a768 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -265,7 +265,6 @@ struct mlx5_dev_config { unsigned int lacp_by_user:1; /* Enable user to manage LACP traffic. */ unsigned int swp:3; /* Tx generic tunnel checksum and TSO offload. */ - unsigned int devx:1; /* Whether devx interface is available or not. */ unsigned int dest_tir:1; /* Whether advanced DR API is available. */ unsigned int reclaim_mode:2; /* Memory reclaim mode. */ unsigned int rt_timestamp:1; /* realtime timestamp format. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index e31d4d8468..151d856d06 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -3290,7 +3290,7 @@ flow_dv_validate_action_count(struct rte_eth_dev *dev, bool shared, { struct mlx5_priv *priv = dev->data->dev_private; - if (!priv->config.devx) + if (!priv->sh->devx) goto notsup_err; if (action_flags & MLX5_FLOW_ACTION_COUNT) return rte_flow_error_set(error, EINVAL, @@ -5252,7 +5252,7 @@ flow_dv_validate_action_age(uint64_t action_flags, struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_action_age *age = action->conf; - if (!priv->config.devx || (priv->sh->cmng.counter_fallback && + if (!priv->sh->devx || (priv->sh->cmng.counter_fallback && !priv->sh->aso_age_mng)) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -5537,7 +5537,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action, "ratio value starts from 1"); - if (!priv->config.devx || (sample->ratio > 0 && !priv->sampler_en)) + if (!priv->sh->devx || (sample->ratio > 0 && !priv->sampler_en)) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -6121,7 +6121,7 @@ flow_dv_counter_alloc(struct rte_eth_dev *dev, uint32_t age) age ? MLX5_COUNTER_TYPE_AGE : MLX5_COUNTER_TYPE_ORIGIN; uint32_t cnt_idx; - if (!priv->config.devx) { + if (!priv->sh->devx) { rte_errno = ENOTSUP; return 0; } @@ -6443,7 +6443,7 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev) struct mlx5_aso_mtr_pool *pool; uint32_t mtr_idx = 0; - if (!priv->config.devx) { + if (!priv->sh->devx) { rte_errno = ENOTSUP; return 0; } @@ -12348,7 +12348,7 @@ flow_dv_aso_ct_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error) uint32_t ct_idx; MLX5_ASSERT(mng); - if (!priv->config.devx) { + if (!priv->sh->devx) { rte_errno = ENOTSUP; return 0; } @@ -12785,7 +12785,7 @@ flow_dv_translate(struct rte_eth_dev *dev, } break; case RTE_FLOW_ACTION_TYPE_COUNT: - if (!dev_conf->devx) { + if (!priv->sh->devx) { return rte_flow_error_set (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, @@ -15629,7 +15629,7 @@ flow_dv_query_count(struct rte_eth_dev *dev, uint32_t cnt_idx, void *data, struct mlx5_priv *priv = dev->data->dev_private; struct rte_flow_query_count *qc = data; - if (!priv->config.devx) + if (!priv->sh->devx) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, @@ -17242,7 +17242,7 @@ flow_dv_counter_query(struct rte_eth_dev *dev, uint32_t counter, bool clear, uint64_t inn_pkts, inn_bytes; int ret; - if (!priv->config.devx) + if (!priv->sh->devx) return -1; ret = _flow_dv_query_count(dev, counter, &inn_pkts, &inn_bytes); diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 3cbf5816a1..e93647aafd 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -1112,7 +1112,7 @@ mlx5_dev_start(struct rte_eth_dev *dev) dev->data->port_id, strerror(rte_errno)); goto error; } - if ((priv->config.devx && priv->config.dv_flow_en && + if ((priv->sh->devx && priv->config.dv_flow_en && priv->config.dest_tir) && priv->obj_ops.lb_dummy_queue_create) { ret = priv->obj_ops.lb_dummy_queue_create(dev); if (ret) diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index e0b6aec9b0..0b10053d2f 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -277,7 +277,7 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) fallback = true; #else fallback = false; - if (!priv->config.devx || !priv->config.dv_flow_en || + if (!sh->devx || !priv->config.dv_flow_en || !priv->config.hca_attr.flow_counters_dump || !(priv->config.hca_attr.flow_counter_bulk_alloc_bitmap & 0x4) || (mlx5_flow_dv_discover_counter_offset_support(dev) == -ENOTSUP)) @@ -354,7 +354,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, sh = mlx5_alloc_shared_dev_ctx(spawn, config); if (!sh) return NULL; - config->devx = sh->devx; /* Initialize the shutdown event in mlx5_dev_spawn to * support mlx5_is_removed for Windows. */ @@ -472,7 +471,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, DRV_LOG(WARNING, "Rx CQE compression isn't supported."); config->cqe_comp = 0; } - if (config->devx) { + if (sh->devx) { err = mlx5_devx_cmd_query_hca_attr(sh->ctx, &config->hca_attr); if (err) { err = -err; @@ -495,7 +494,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, (config->hw_vlan_strip ? "" : "not ")); config->hw_fcs_strip = config->hca_attr.scatter_fcs; } - if (config->devx) { + if (sh->devx) { uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; err = config->hca_attr.access_register_user ? @@ -679,7 +678,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; } } - if (config->devx && config->dv_flow_en) { + if (sh->devx && config->dv_flow_en) { priv->obj_ops = devx_obj_ops; } else { DRV_LOG(ERR, "Flow mode %u is not supported " -- 2.20.1