Skip to content

Commit

Permalink
net/mlx5: fix sibling device config check
Browse files Browse the repository at this point in the history
[ upstream commit dcbaafd ]

The MLX5 net driver supports "probe again". In probing again, it
creates a new ethdev under an existing infiniband device context.

Sibling devices sharing infiniband device context should have compatible
configurations, so some of the devargs given in the probe again, the
ones that are mainly relevant to the sharing device context are sent to
the mlx5_dev_check_sibling_config function which makes sure that they
compatible its siblings.
However, the arguments are adjusted according to the capability of the
device, and the function compares the arguments of the probe again
before the adjustment with the arguments of the siblings after the
adjustment. A user who sends the same values to all siblings may fail in
this comparison if he requested something that the device does not
support and adjusted.

This patch moves the call to the mlx5_dev_check_sibling_config function
after the relevant adjustments.

Fixes: 92d5dd4 ("net/mlx5: check sibling device configurations mismatch")
Fixes: 2d24151 ("net/mlx5: add devarg for extensive metadata support")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
  • Loading branch information
michaelbaum1 authored and kevintraynor committed Feb 28, 2022
1 parent e682857 commit 50f3a03
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
41 changes: 22 additions & 19 deletions drivers/net/mlx5/linux/mlx5_os.c
Expand Up @@ -1241,6 +1241,28 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
}
/* Override some values set by hardware configuration. */
mlx5_args(config, dpdk_dev->devargs);
/* Update final values for devargs before check sibling config. */
#if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR)
if (config->dv_flow_en) {
DRV_LOG(WARNING, "DV flow is not supported.");
config->dv_flow_en = 0;
}
#endif
#ifdef HAVE_MLX5DV_DR_ESWITCH
if (!(sh->cdev->config.hca_attr.eswitch_manager && config->dv_flow_en &&
(switch_info->representor || switch_info->master)))
config->dv_esw_en = 0;
#else
config->dv_esw_en = 0;
#endif
if (!priv->config.dv_esw_en &&
priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
DRV_LOG(WARNING,
"Metadata mode %u is not supported (no E-Switch).",
priv->config.dv_xmeta_en);
priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;
}
/* Check sibling device configurations. */
err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev);
if (err)
goto error;
Expand All @@ -1251,12 +1273,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
#if !defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) && \
!defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
DRV_LOG(DEBUG, "counters are not supported");
#endif
#if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR)
if (config->dv_flow_en) {
DRV_LOG(WARNING, "DV flow is not supported");
config->dv_flow_en = 0;
}
#endif
config->ind_table_max_size =
sh->device_attr.max_rwq_indirection_table_size;
Expand Down Expand Up @@ -1652,13 +1668,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
* Verbs context returned by ibv_open_device().
*/
mlx5_link_update(eth_dev, 0);
#ifdef HAVE_MLX5DV_DR_ESWITCH
if (!(config->hca_attr.eswitch_manager && config->dv_flow_en &&
(switch_info->representor || switch_info->master)))
config->dv_esw_en = 0;
#else
config->dv_esw_en = 0;
#endif
/* Detect minimal data bytes to inline. */
mlx5_set_min_inline(spawn, config);
/* Store device configuration on private structure. */
Expand Down Expand Up @@ -1725,12 +1734,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
err = -err;
goto error;
}
if (!priv->config.dv_esw_en &&
priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
DRV_LOG(WARNING, "metadata mode %u is not supported "
"(no E-Switch)", priv->config.dv_xmeta_en);
priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;
}
mlx5_set_metadata_mask(eth_dev);
if (priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY &&
!priv->sh->dv_regc0_mask) {
Expand Down
28 changes: 17 additions & 11 deletions drivers/net/mlx5/windows/mlx5_os.c
Expand Up @@ -423,6 +423,21 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
}
/* Override some values set by hardware configuration. */
mlx5_args(config, dpdk_dev->devargs);
/* Update final values for devargs before check sibling config. */
config->dv_esw_en = 0;
if (!config->dv_flow_en) {
DRV_LOG(ERR, "Windows flow mode must be DV flow enable.");
err = ENOTSUP;
goto error;
}
if (!priv->config.dv_esw_en &&
priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
DRV_LOG(WARNING,
"Metadata mode %u is not supported (no E-Switch).",
priv->config.dv_xmeta_en);
priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;
}
/* Check sibling device configurations. */
err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev);
if (err)
goto error;
Expand Down Expand Up @@ -584,7 +599,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
* Verbs context returned by ibv_open_device().
*/
mlx5_link_update(eth_dev, 0);
config->dv_esw_en = 0;
/* Detect minimal data bytes to inline. */
mlx5_set_min_inline(spawn, config);
/* Store device configuration on private structure. */
Expand All @@ -606,12 +620,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
}
/* No supported flow priority number detection. */
priv->sh->flow_max_priority = -1;
if (!priv->config.dv_esw_en &&
priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
DRV_LOG(WARNING, "metadata mode %u is not supported "
"(no E-Switch)", priv->config.dv_xmeta_en);
priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;
}
mlx5_set_metadata_mask(eth_dev);
if (priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY &&
!priv->sh->dv_regc0_mask) {
Expand Down Expand Up @@ -645,12 +653,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
goto error;
}
}
if (sh->devx && config->dv_flow_en) {
if (sh->devx) {
priv->obj_ops = devx_obj_ops;
} else {
DRV_LOG(ERR, "Flow mode %u is not supported "
"(Windows flow must be DevX with DV flow enabled).",
priv->config.dv_flow_en);
DRV_LOG(ERR, "Windows flow must be DevX.");
err = ENOTSUP;
goto error;
}
Expand Down

0 comments on commit 50f3a03

Please sign in to comment.