Offending patch has changed the logic for handling default
configuration for dv_flow_en device argument.
This change has introduced a regression to Windows support.
On Windows, mlx5 PMD only supports flow API implementation
with dv_flow_en set to 1. With the change, this argument value was
changed based on device capabilities.
On newer NICs, dv_flow_en would be set to HW Steering flow engine
which is not supported on Windows.
On older NICs, it would be set to Verbs engine, which is also not
supported.
This patch fixes that by introducing platform-specific initialization
and fixup of relevant device arguments i.e., dv_flow_en and
allow_duplicate_pattern.
On Linux the existing logic is kept. On Windows dv_flow_en and
allow_duplicate_pattern are set by default to 1 (same as before
the offending patch).
Fixes: 170ebe941be3 ("net/mlx5: fix flow devargs handling for future HW")
Signed-off-by: Maayan Kashani <[email protected]>
Signed-off-by: Dariusz Sosnowski <[email protected]>
Acked-by: Bing Zhao <[email protected]>
---
drivers/net/mlx5/linux/mlx5_os.c | 98 ++++++++++++++++++++++++++++
drivers/net/mlx5/linux/mlx5_os.h | 1 +
drivers/net/mlx5/mlx5.c | 100 ++++++++---------------------
drivers/net/mlx5/mlx5.h | 9 +++
drivers/net/mlx5/windows/mlx5_os.c | 23 +++++++
5 files changed, 158 insertions(+), 73 deletions(-)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 76edd19c70..01adcfc916 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -3371,3 +3371,101 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
dev->data->mac_addrs,
MLX5_MAX_MAC_ADDRESSES, priv->mac_own, vf);
}
+
+static bool
+mlx5_hws_is_supported(struct mlx5_dev_ctx_shared *sh)
+{
+ return (sh->cdev->config.devx &&
+ sh->cdev->config.hca_attr.wqe_based_flow_table_sup);
+}
+
+static bool
+mlx5_sws_is_any_supported(struct mlx5_dev_ctx_shared *sh)
+{
+ struct mlx5_common_device *cdev = sh->cdev;
+ struct mlx5_hca_attr *hca_attr = &cdev->config.hca_attr;
+
+ if (hca_attr->rx_sw_owner_v2 || hca_attr->rx_sw_owner)
+ return true;
+
+ if (hca_attr->tx_sw_owner_v2 || hca_attr->tx_sw_owner)
+ return true;
+
+ if (hca_attr->eswitch_manager && (hca_attr->esw_sw_owner_v2 ||
hca_attr->esw_sw_owner))
+ return true;
+
+ return false;
+}
+
+/**
+ * Initialize default shared configuration for arguments related to flow
engine.
+ *
+ * @param[in] sh
+ * Pointer to shared configuration.
+ * @param[in] sh
+ * Pointer to shared device context.
+ */
+void
+mlx5_os_default_flow_config(struct mlx5_sh_config *config, struct
mlx5_dev_ctx_shared *sh)
+{
+ bool hws_is_supported = mlx5_hws_is_supported(sh);
+ bool sws_is_supported = mlx5_sws_is_any_supported(sh);
+
+ if (!sws_is_supported && hws_is_supported)
+ config->dv_flow_en = 2;
+ else
+ config->dv_flow_en = 1;
+
+ if (config->dv_flow_en == 2)
+ config->allow_duplicate_pattern = 0;
+ else
+ config->allow_duplicate_pattern = 1;
+}
+
+static bool
+mlx5_kvargs_is_used(struct mlx5_kvargs_ctrl *mkvlist, const char *key)
+{
+ const struct rte_kvargs_pair *pair;
+ uint32_t i;
+
+ for (i = 0; i < mkvlist->kvlist->count; ++i) {
+ pair = &mkvlist->kvlist->pairs[i];
+ if (strcmp(pair->key, key) == 0 && mkvlist->is_used[i])
+ return true;
+ }
+ return false;
+}
+
+void mlx5_os_fixup_flow_en(struct mlx5_sh_config *config,
+ struct mlx5_dev_ctx_shared *sh)
+{
+ bool hws_is_supported = mlx5_hws_is_supported(sh);
+ bool sws_is_supported = mlx5_sws_is_any_supported(sh);
+
+ /* Inform user if DV flow is not supported. */
+ if (config->dv_flow_en == 1 && !sws_is_supported && hws_is_supported) {
+ DRV_LOG(WARNING, "DV flow is not supported. Changing to HWS
mode.");
+ config->dv_flow_en = 2;
+ }
+}
+
+void
+mlx5_os_fixup_duplicate_pattern(struct mlx5_sh_config *config,
+ struct mlx5_kvargs_ctrl *mkvlist,
+ const char *key)
+{
+ /* Handle allow_duplicate_pattern based on final dv_flow_en mode.
+ * HWS mode (dv_flow_en=2) doesn't support duplicate patterns.
+ * Warn only if user explicitly requested an incompatible setting.
+ */
+ bool allow_dup_pattern_set = mkvlist != NULL &&
+ mlx5_kvargs_is_used(mkvlist, key);
+ if (config->dv_flow_en == 2) {
+ if (config->allow_duplicate_pattern == 1 &&
allow_dup_pattern_set)
+ DRV_LOG(WARNING, "Duplicate pattern is not supported
with HWS. Disabling it.");
+ config->allow_duplicate_pattern = 0;
+ } else if (!allow_dup_pattern_set) {
+ /* Non-HWS mode: set default to 1 only if not explicitly set by
user */
+ config->allow_duplicate_pattern = 1;
+ }
+}
diff --git a/drivers/net/mlx5/linux/mlx5_os.h b/drivers/net/mlx5/linux/mlx5_os.h
index 4ef0916173..4d073048fb 100644
--- a/drivers/net/mlx5/linux/mlx5_os.h
+++ b/drivers/net/mlx5/linux/mlx5_os.h
@@ -42,4 +42,5 @@ enum mlx5_tunnel_offloads {
MLX5_TUNNELED_OFFLOADS_GENEVE_CAP = 0,
#endif
};
+
#endif /* RTE_PMD_MLX5_OS_H_ */
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 4e0bc26754..e795948187 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1461,45 +1461,6 @@ mlx5_dev_args_check_handler(const char *key, const char
*val, void *opaque)
return 0;
}
-static bool
-mlx5_hws_is_supported(struct mlx5_dev_ctx_shared *sh)
-{
- return (sh->cdev->config.devx &&
- sh->cdev->config.hca_attr.wqe_based_flow_table_sup);
-}
-
-static bool
-mlx5_sws_is_any_supported(struct mlx5_dev_ctx_shared *sh)
-{
- struct mlx5_common_device *cdev = sh->cdev;
- struct mlx5_hca_attr *hca_attr = &cdev->config.hca_attr;
-
- if (hca_attr->rx_sw_owner_v2 || hca_attr->rx_sw_owner)
- return true;
-
- if (hca_attr->tx_sw_owner_v2 || hca_attr->tx_sw_owner)
- return true;
-
- if (hca_attr->eswitch_manager && (hca_attr->esw_sw_owner_v2 ||
hca_attr->esw_sw_owner))
- return true;
-
- return false;
-}
-
-static bool
-mlx5_kvargs_is_used(struct mlx5_kvargs_ctrl *mkvlist, const char *key)
-{
- const struct rte_kvargs_pair *pair;
- uint32_t i;
-
- for (i = 0; i < mkvlist->kvlist->count; ++i) {
- pair = &mkvlist->kvlist->pairs[i];
- if (strcmp(pair->key, key) == 0 && mkvlist->is_used[i])
- return true;
- }
- return false;
-}
-
/**
* Parse user device parameters and adjust them according to device
* capabilities.
@@ -1540,8 +1501,6 @@ mlx5_shared_dev_ctx_args_config(struct
mlx5_dev_ctx_shared *sh,
int ret = 0;
size_t alignment = rte_mem_page_size();
uint32_t max_queue_umem_size = MLX5_WQE_SIZE *
mlx5_dev_get_max_wq_size(sh);
- bool hws_is_supported = mlx5_hws_is_supported(sh);
- bool sws_is_supported = mlx5_sws_is_any_supported(sh);
if (alignment == (size_t)-1) {
alignment = (1 << MLX5_LOG_PAGE_SIZE);
@@ -1550,17 +1509,10 @@ mlx5_shared_dev_ctx_args_config(struct
mlx5_dev_ctx_shared *sh,
/* Default configuration. */
memset(config, 0, sizeof(*config));
+ mlx5_os_default_flow_config(config, sh);
config->vf_nl_en = 1;
config->dv_esw_en = 1;
- if (!sws_is_supported && hws_is_supported)
- config->dv_flow_en = 2;
- else
- config->dv_flow_en = 1;
config->decap_en = 1;
- if (config->dv_flow_en == 2)
- config->allow_duplicate_pattern = 0;
- else
- config->allow_duplicate_pattern = 1;
config->fdb_def_rule = 1;
config->cnt_svc.cycle_time = MLX5_CNT_SVC_CYCLE_TIME_DEFAULT;
config->cnt_svc.service_core = rte_get_main_lcore();
@@ -1576,30 +1528,7 @@ mlx5_shared_dev_ctx_args_config(struct
mlx5_dev_ctx_shared *sh,
}
}
/* Adjust parameters according to device capabilities. */
- if (config->dv_flow_en && !sh->dev_cap.dv_flow_en) {
- DRV_LOG(WARNING, "DV flow is not supported.");
- config->dv_flow_en = 0;
- }
- /* Inform user if DV flow is not supported. */
- if (config->dv_flow_en == 1 && !sws_is_supported && hws_is_supported) {
- DRV_LOG(WARNING, "DV flow is not supported. Changing to HWS
mode.");
- config->dv_flow_en = 2;
- }
- /* Handle allow_duplicate_pattern based on final dv_flow_en mode.
- * HWS mode (dv_flow_en=2) doesn't support duplicate patterns.
- * Warn only if user explicitly requested an incompatible setting.
- */
- bool allow_dup_pattern_set = mkvlist != NULL &&
- mlx5_kvargs_is_used(mkvlist, MLX5_ALLOW_DUPLICATE_PATTERN);
- if (config->dv_flow_en == 2) {
- if (config->allow_duplicate_pattern == 1 &&
allow_dup_pattern_set)
- DRV_LOG(WARNING, "Duplicate pattern is not supported
with HWS. Disabling it.");
- config->allow_duplicate_pattern = 0;
- } else if (!allow_dup_pattern_set) {
- /* Non-HWS mode: set default to 1 only if not explicitly set by
user */
- config->allow_duplicate_pattern = 1;
- }
-
+ mlx5_fixup_flow_config(config, sh, mkvlist);
if (config->dv_esw_en && !sh->dev_cap.dv_esw_en) {
DRV_LOG(DEBUG, "E-Switch DV flow is not supported.");
config->dv_esw_en = 0;
@@ -3802,6 +3731,31 @@ mlx5_read_queue_counter(struct mlx5_devx_obj *q_counter,
const char *ctr_name,
return ret;
}
+/**
+ * Fix up shared configuration passed by user based on device capabilities.
+ *
+ * @param[in] config
+ * Pointer to shared configuration.
+ * @param[in] sh
+ * Pointer to shared device context.
+ * @param[in] mkvlist
+ * Key/value list of passed options
+ */
+void
+mlx5_fixup_flow_config(struct mlx5_sh_config *config,
+ struct mlx5_dev_ctx_shared *sh,
+ struct mlx5_kvargs_ctrl *mkvlist)
+{
+ if (config->dv_flow_en && !sh->dev_cap.dv_flow_en) {
+ DRV_LOG(WARNING, "DV flow is not supported.");
+ config->dv_flow_en = 0;
+ }
+
+ /* Apply platform-dependent logic. */
+ mlx5_os_fixup_flow_en(config, sh);
+ mlx5_os_fixup_duplicate_pattern(config, mkvlist,
MLX5_ALLOW_DUPLICATE_PATTERN);
+}
+
/**
* Callback to remove a device.
*
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index c54266ec26..e5f3701bc3 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -2296,6 +2296,9 @@ struct mlx5_physical_device *
mlx5_get_locked_physical_device(struct mlx5_priv *priv);
void mlx5_unlock_physical_device(void);
int mlx5_read_queue_counter(struct mlx5_devx_obj *q_counter, const char
*ctr_name, uint64_t *stat);
+void mlx5_fixup_flow_config(struct mlx5_sh_config *config,
+ struct mlx5_dev_ctx_shared *sh,
+ struct mlx5_kvargs_ctrl *mkvlist);
/* mlx5_ethdev.c */
@@ -2603,6 +2606,12 @@ int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int
enable);
int mlx5_os_set_nonblock_channel_fd(int fd);
void mlx5_os_mac_addr_flush(struct rte_eth_dev *dev);
void mlx5_os_net_cleanup(void);
+void mlx5_os_default_flow_config(struct mlx5_sh_config *config, struct
mlx5_dev_ctx_shared *sh);
+void mlx5_os_fixup_flow_en(struct mlx5_sh_config *config,
+ struct mlx5_dev_ctx_shared *sh);
+void mlx5_os_fixup_duplicate_pattern(struct mlx5_sh_config *config,
+ struct mlx5_kvargs_ctrl *mkvlist,
+ const char *key);
/* mlx5_txpp.c */
diff --git a/drivers/net/mlx5/windows/mlx5_os.c
b/drivers/net/mlx5/windows/mlx5_os.c
index 55b647eddc..4952b674c0 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -892,3 +892,26 @@ mlx5_os_net_cleanup(void)
}
const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
+
+void
+mlx5_os_default_flow_config(struct mlx5_sh_config *config __rte_unused,
+ struct mlx5_dev_ctx_shared *sh __rte_unused)
+{
+ config->dv_flow_en = 1;
+ config->allow_duplicate_pattern = 1;
+}
+
+void
+mlx5_os_fixup_flow_en(struct mlx5_sh_config *config __rte_unused,
+ struct mlx5_dev_ctx_shared *sh __rte_unused)
+{
+ /* Nothing to fix up */
+}
+
+void
+mlx5_os_fixup_duplicate_pattern(struct mlx5_sh_config *config __rte_unused,
+ struct mlx5_kvargs_ctrl *mkvlist __rte_unused,
+ const char *key __rte_unused)
+{
+ /* Nothing to fix up */
+}
--
2.47.3