]> git.droids-corp.org - dpdk.git/commitdiff
rawdev: pass the device id as parameter to selftest
authorBruce Richardson <bruce.richardson@intel.com>
Tue, 2 Jul 2019 09:56:08 +0000 (10:56 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 2 Jul 2019 15:04:30 +0000 (17:04 +0200)
When running self-tests, the driver needs to know the device on which to
run the tests, so we need to take the device ID as parameter. Only the
skeleton driver is providing this selftest capability right now, so we can
easily update it for this change.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/raw/skeleton_rawdev/skeleton_rawdev.c
drivers/raw/skeleton_rawdev/skeleton_rawdev.h
drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c
lib/librte_rawdev/rte_rawdev.c
lib/librte_rawdev/rte_rawdev_pmd.h

index 709be7691a8f517f03490b40870d53207a17707d..42471fbd118766035e08212e638032b1348dadb0 100644 (file)
@@ -583,6 +583,8 @@ skeleton_rawdev_create(const char *name,
                goto cleanup;
        }
 
+       ret = rawdev->dev_id; /* return the rawdev id of new device */
+
        rawdev->dev_ops = &skeleton_rawdev_ops;
        rawdev->device = &vdev->device;
 
@@ -720,19 +722,19 @@ skeleton_rawdev_probe(struct rte_vdev_device *vdev)
        /* In case of invalid argument, selftest != 1; ignore other values */
 
        ret = skeleton_rawdev_create(name, vdev, rte_socket_id());
-       if (!ret) {
+       if (ret >= 0) {
                /* In case command line argument for 'selftest' was passed;
                 * if invalid arguments were passed, execution continues but
                 * without selftest.
                 */
                if (selftest == 1)
-                       test_rawdev_skeldev();
+                       test_rawdev_skeldev(ret);
        }
 
        /* Device instance created; Second instance not possible */
        skeldev_init_once = 1;
 
-       return ret;
+       return ret < 0 ? ret : 0;
 }
 
 static int
index 5045b5922879829d9d4a7529346f71cb205279f1..c3f92e72abaad478ce8cc366ab0f0d82c730adc8 100644 (file)
@@ -131,6 +131,6 @@ skeleton_rawdev_get_priv(const struct rte_rawdev *rawdev)
        return rawdev->dev_private;
 }
 
-int test_rawdev_skeldev(void);
+int test_rawdev_skeldev(uint16_t dev_id);
 
 #endif /* __SKELETON_RAWDEV_H__ */
index a6be99aeee95deafacd26f358131e6ee6e66755f..9ecfdee8188900553fef39828a7bcd00f6277dd1 100644 (file)
@@ -426,8 +426,9 @@ static void skeldev_test_run(int (*setup)(void),
 }
 
 int
-test_rawdev_skeldev(void)
+test_rawdev_skeldev(uint16_t dev_id)
 {
+       test_dev_id = dev_id;
        testsuite_setup();
 
        SKELDEV_TEST_RUN(NULL, NULL, test_rawdev_count);
index 2b2f45d7c2967ecec20f288c5783c47d1f6e2d54..15de2d413c61b8d3dc611a78e4a41574db24725d 100644 (file)
@@ -378,7 +378,7 @@ rte_rawdev_selftest(uint16_t dev_id)
        struct rte_rawdev *dev = &rte_rawdevs[dev_id];
 
        RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_selftest, -ENOTSUP);
-       return (*dev->dev_ops->dev_selftest)();
+       return (*dev->dev_ops->dev_selftest)(dev_id);
 }
 
 int
index 5e6cf1d1649cc0e9dedf40b115d03eeea04cbe10..aa6af4a3751bc8a7ef192f2e750e1e4b7bb9b500 100644 (file)
@@ -499,7 +499,7 @@ typedef int (*rawdev_firmware_unload_t)(struct rte_rawdev *dev);
  * @return
  *   Return 0 on success
  */
-typedef int (*rawdev_selftest_t)(void);
+typedef int (*rawdev_selftest_t)(uint16_t dev_id);
 
 /** Rawdevice operations function pointer table */
 struct rte_rawdev_ops {