From: Bruce Richardson Date: Tue, 2 Jul 2019 09:56:08 +0000 (+0100) Subject: rawdev: pass the device id as parameter to selftest X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=863fd2930bbe9c982b042584d513d190487c983a;p=dpdk.git rawdev: pass the device id as parameter to selftest 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 Acked-by: Hemant Agrawal --- diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev.c b/drivers/raw/skeleton_rawdev/skeleton_rawdev.c index 709be7691a..42471fbd11 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev.c +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev.c @@ -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 diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev.h b/drivers/raw/skeleton_rawdev/skeleton_rawdev.h index 5045b59228..c3f92e72ab 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev.h +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev.h @@ -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__ */ diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c index a6be99aeee..9ecfdee818 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c @@ -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); diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index 2b2f45d7c2..15de2d413c 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -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 diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h index 5e6cf1d164..aa6af4a375 100644 --- a/lib/librte_rawdev/rte_rawdev_pmd.h +++ b/lib/librte_rawdev/rte_rawdev_pmd.h @@ -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 {