Skip to contentSkip to conversation

net/mlx5: fix default flow engine on Windows

PATCH In review Dariusz Sosnowski 2 participants 2 messages Mar 9 – Mar 10 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: fix default flow engine on Windows

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")
---
 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(-)
drivers/net/mlx5/linux/mlx5_os.c +98 -0
index 76edd19c70..01adcfc916 100644
@@ -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;
+	}
+}
drivers/net/mlx5/linux/mlx5_os.h +1 -0
index 4ef0916173..4d073048fb 100644
@@ -42,4 +42,5 @@ enum mlx5_tunnel_offloads {
 	MLX5_TUNNELED_OFFLOADS_GENEVE_CAP = 0,
 #endif
 };
+
 #endif /* RTE_PMD_MLX5_OS_H_ */
drivers/net/mlx5/mlx5.c +27 -73

133 lines not on this page · raw message

drivers/net/mlx5/mlx5.h +9 -0
index c54266ec26..e5f3701bc3 100644
@@ -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 */
 
drivers/net/mlx5/windows/mlx5_os.c +23 -0
index 55b647eddc..4952b674c0 100644
@@ -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 */
+}
Signature · 1 line
2.47.3
#1 lore raw

Hi,

Quoted 18 lines · Dariusz Sosnowski

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).

Quoted 5 lines
Fixes 170ebe941be3 ("net/mlx5: fix flow devargs handling for future HW")

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh