The devices backed by mlx5 PMD might share the same multiport Infiniband device context. It regards representors and slaves of bonding device. These ports are spawned with devargs. These patch check whether configuration deduced from these devargs is compatible with configurations if devices sharing the same context. It prevents the incorrect whitelists, like:
-w 82:00.0,representor=0,dv_flow_en=1 -w 82:00.0,representor=1,dv_flow_en=0 The representors with indices [0-1] are supposed to spawned over the same PCi device, but there is dv_flow_en parameter mismatch. Signed-off-by: Viacheslav Ovsiienko <viachesl...@mellanox.com> --- drivers/net/mlx5/mlx5.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 71b30d9..951b9f5 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1519,6 +1519,53 @@ struct mlx5_dev_spawn_data { } /** + * Check sibling device configurations. + * + * Sibling devices sharing the Infiniband device context + * should have compatible configurations. This regards + * representors and bonding slaves. + * + * @param priv + * Private device descriptor. + * @param config + * Configuration of the device is going to be created. + * + * @return + * 0 on success, EINVAL otherwise + */ +static int +mlx5_dev_check_sibling_config(struct mlx5_priv *priv, + struct mlx5_dev_config *config) +{ + struct mlx5_ibv_shared *sh = priv->sh; + struct mlx5_dev_config *sh_conf = NULL; + uint16_t port_id; + + assert(sh); + /* Nothing to compare for the single/first device. */ + if (sh->refcnt == 1) + return 0; + /* Find the device with shared context. */ + MLX5_ETH_FOREACH_DEV(port_id) { + struct mlx5_priv *opriv = + rte_eth_devices[port_id].data->dev_private; + + if (opriv && opriv != priv && opriv->sh == sh) { + sh_conf = &opriv->config; + break; + } + } + if (!sh_conf) + return 0; + if (sh_conf->dv_flow_en ^ config->dv_flow_en) { + DRV_LOG(ERR, "\"dv_flow_en\" configuration mismatch" + " for shared %s context", sh->ibdev_name); + rte_errno = EINVAL; + return rte_errno; + } + return 0; +} +/** * Spawn an Ethernet device from Verbs information. * * @param dpdk_dev @@ -1886,6 +1933,9 @@ struct mlx5_dev_spawn_data { strerror(rte_errno)); goto error; } + err = mlx5_dev_check_sibling_config(priv, &config); + if (err) + goto error; config.hw_csum = !!(sh->device_attr.device_cap_flags_ex & IBV_DEVICE_RAW_IP_CSUM); DRV_LOG(DEBUG, "checksum offloading is %ssupported", -- 1.8.3.1