common/mlx5: fix class combination validation
authorMichael Baum <michaelba@nvidia.com>
Sun, 12 Sep 2021 10:36:26 +0000 (13:36 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 20 Sep 2021 21:15:08 +0000 (23:15 +0200)
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>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/common/mlx5/mlx5_common.c

index 459cf4b..f6e440d 100644 (file)
@@ -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)