rawdev: add self test
authorShreyansh Jain <shreyansh.jain@nxp.com>
Wed, 31 Jan 2018 09:13:14 +0000 (14:43 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 31 Jan 2018 14:35:56 +0000 (15:35 +0100)
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
lib/librte_rawdev/rte_rawdev.c
lib/librte_rawdev/rte_rawdev.h
lib/librte_rawdev/rte_rawdev_pmd.h
lib/librte_rawdev/rte_rawdev_version.map

index b52293c..d314ef9 100644 (file)
@@ -363,6 +363,16 @@ rte_rawdev_firmware_unload(uint16_t dev_id)
        return (*dev->dev_ops->firmware_unload)(dev);
 }
 
+int __rte_experimental
+rte_rawdev_selftest(uint16_t dev_id)
+{
+       RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
+       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)();
+}
+
 int __rte_experimental
 rte_rawdev_start(uint16_t dev_id)
 {
index faa13f8..2e14919 100644 (file)
@@ -589,6 +589,19 @@ rte_rawdev_firmware_load(uint16_t dev_id, rte_rawdev_obj_t firmware_image);
 int __rte_experimental
 rte_rawdev_firmware_unload(uint16_t dev_id);
 
+/**
+ * Trigger the rawdev self test.
+ *
+ * @param dev_id
+ *   The identifier of the device
+ * @return
+ *   - 0: Selftest successful
+ *   - -ENOTSUP if the device doesn't support selftest
+ *   - other values < 0 on failure.
+ */
+int __rte_experimental
+rte_rawdev_selftest(uint16_t dev_id);
+
 #ifdef __cplusplus
 }
 #endif
index 41b3a3b..408adf0 100644 (file)
@@ -477,6 +477,14 @@ typedef int (*rawdev_firmware_load_t)(struct rte_rawdev *dev,
  */
 typedef int (*rawdev_firmware_unload_t)(struct rte_rawdev *dev);
 
+/**
+ * Start rawdev selftest
+ *
+ * @return
+ *   Return 0 on success
+ */
+typedef int (*rawdev_selftest_t)(void);
+
 /** Rawdevice operations function pointer table */
 struct rte_rawdev_ops {
        /**< Get device info. */
@@ -530,6 +538,9 @@ struct rte_rawdev_ops {
        rawdev_firmware_load_t firmware_load;
        /**< Unload firmware */
        rawdev_firmware_unload_t firmware_unload;
+
+       /**< Device selftest function */
+       rawdev_selftest_t dev_selftest;
 };
 
 /**
index 8de9abd..af4465e 100644 (file)
@@ -19,6 +19,7 @@ EXPERIMENTAL {
        rte_rawdev_queue_setup;
        rte_rawdev_queue_release;
        rte_rawdev_reset;
+       rte_rawdev_selftest;
        rte_rawdev_set_attr;
        rte_rawdev_socket_id;
        rte_rawdev_start;