[4/6] common/mlx5: fix class combination validation

Message ID 20210831203732.3411134-5-michaelba@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series mlx5: some independent fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Michael Baum Aug. 31, 2021, 8:37 p.m. UTC
  The common probe function gets as a user argument the classes it should
create, and checks whether the combination is valid.

In case the device already exists, it checks the integration of the
above with the classes that the device has.
However, the function does not check the combination when the device
does not exist and it has to create it.

Check if the combination is valid for all cases.

Fixes: ad435d320473 ("common/mlx5: add bus-agnostic layer")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 drivers/common/mlx5/mlx5_common.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
  

Patch

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 459cf4bcc4..f6e440dca1 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -317,14 +317,16 @@  mlx5_common_dev_probe(struct rte_device *eal_dev)
 		dev->dev = eal_dev;
 		TAILQ_INSERT_HEAD(&devices_list, dev, next);
 		new_device = true;
-	} else {
-		/* Validate combination here. */
-		ret = is_valid_class_combination(classes |
-						 dev->classes_loaded);
-		if (ret != 0) {
-			DRV_LOG(ERR, "Unsupported mlx5 classes combination.");
-			return ret;
-		}
+	}
+	/*
+	 * Validate combination here.
+	 * For new device, the classes_loaded field is 0 and it check only
+	 * the classes given as user device arguments.
+	 */
+	ret = is_valid_class_combination(classes | dev->classes_loaded);
+	if (ret != 0) {
+		DRV_LOG(ERR, "Unsupported mlx5 classes combination.");
+		goto class_err;
 	}
 	ret = drivers_probe(dev, classes);
 	if (ret)