[v3,5/8] raw/ioat: add device info function

Message ID 20190627104055.8244-6-bruce.richardson@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series raw/ioat: driver for Intel QuickData Technology |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Bruce Richardson June 27, 2019, 10:40 a.m. UTC
  Add in the "info_get" function to the driver, to allow us to query the
device. This allows us to have the unit test pick up the presence of
supported hardware or not.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

---

V2: Test case is placed in driver self-test routine
---
 app/test/test_rawdev.c             | 11 ++++++++++
 doc/guides/rawdevs/ioat_rawdev.rst | 34 ++++++++++++++++++++++++++++++
 drivers/raw/ioat/ioat_rawdev.c     | 11 ++++++++++
 drivers/raw/ioat/rte_ioat_rawdev.h | 11 ++++++++++
 4 files changed, 67 insertions(+)
  

Comments

Anatoly Burakov June 27, 2019, 12:16 p.m. UTC | #1
On 27-Jun-19 11:40 AM, Bruce Richardson wrote:
> Add in the "info_get" function to the driver, to allow us to query the
> device. This allows us to have the unit test pick up the presence of
> supported hardware or not.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> ---
> 
> V2: Test case is placed in driver self-test routine
> ---
>   app/test/test_rawdev.c             | 11 ++++++++++
>   doc/guides/rawdevs/ioat_rawdev.rst | 34 ++++++++++++++++++++++++++++++
>   drivers/raw/ioat/ioat_rawdev.c     | 11 ++++++++++
>   drivers/raw/ioat/rte_ioat_rawdev.h | 11 ++++++++++
>   4 files changed, 67 insertions(+)
> 
> diff --git a/app/test/test_rawdev.c b/app/test/test_rawdev.c
> index 88549fb61..4db762b4c 100644
> --- a/app/test/test_rawdev.c
> +++ b/app/test/test_rawdev.c
> @@ -29,6 +29,17 @@ REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftest_skeleton);
>   static int
>   test_rawdev_selftest_ioat(void)
>   {
> +	const int count = rte_rawdev_count();
> +	int i;
> +
> +	for (i = 0; i < count; i++) {
> +		struct rte_rawdev_info info = { .dev_private = NULL };
> +		if (rte_rawdev_info_get(i, &info) == 0 &&
> +				strstr(info.driver_name, "ioat") != NULL)
> +			return 0;

TEST_SUCCESS? Also, didn't "ioat" have a macro for its name?

> +	}
> +
> +	printf("No IOAT rawdev found, skipping tests\n");
>   	return TEST_SKIPPED;
>   }
>   
> diff --git a/doc/guides/rawdevs/ioat_rawdev.rst b/doc/guides/rawdevs/ioat_rawdev.rst
> index 4b7fe8a8f..0ce984490 100644
> --- a/doc/guides/rawdevs/ioat_rawdev.rst
> +++ b/doc/guides/rawdevs/ioat_rawdev.rst
> @@ -83,3 +83,37 @@ parameters need to be passed to create or initialize the device.
>   Once probed successfully, the device will appear as a ``rawdev``, that is a
>   "raw device type" inside DPDK, and can be accessed using APIs from the
>   ``rte_rawdev`` library.
> +
> +Using IOAT Rawdev Devices
> +--------------------------
> +
> +To use the devices from an application, the rawdev API can be used, along
> +with definitions taken from the device-specific header file
> +``rte_ioat_rawdev.h``. This header is needed to get the definition of
> +structure parameters used by some of the rawdev APIs for IOAT rawdev
> +devices, as well as providing key functions for using the device for memory
> +copies.
> +
> +Getting Device Information
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +Basic information about each rawdev device can be got using the

According to certain unreliable sources [1], usage of "can be got" has 
not been used since the end of 19th century. I didn't think you were 
*that* old, Bruce!

> +``rte_rawdev_info_get()`` API. For most applications, this API will be
> +needed to verify that the rawdev in question is of the expected type. For
> +example, the following code in ``test_ioat_rawdev.c`` is used to identify
> +the IOAT rawdev device for use for the tests:
> +
> +.. code-block:: C
> +
> +        for (i = 0; i < count && !found; i++) {
> +                struct rte_rawdev_info info = { .dev_private = NULL };
> +                found = (rte_rawdev_info_get(i, &info) == 0 &&
> +                                strcmp(info.driver_name,
> +                                                IOAT_PMD_RAWDEV_NAME_STR) == 0);
> +        }

The code here doesn't match the actual implementation in the autotest.
  
Bruce Richardson June 28, 2019, 9:09 p.m. UTC | #2
On Thu, Jun 27, 2019 at 01:16:01PM +0100, Burakov, Anatoly wrote:
> On 27-Jun-19 11:40 AM, Bruce Richardson wrote:
> > Add in the "info_get" function to the driver, to allow us to query the
> > device. This allows us to have the unit test pick up the presence of
> > supported hardware or not.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > ---
> > 
> > V2: Test case is placed in driver self-test routine
> > ---
> >   app/test/test_rawdev.c             | 11 ++++++++++
> >   doc/guides/rawdevs/ioat_rawdev.rst | 34 ++++++++++++++++++++++++++++++
> >   drivers/raw/ioat/ioat_rawdev.c     | 11 ++++++++++
> >   drivers/raw/ioat/rte_ioat_rawdev.h | 11 ++++++++++
> >   4 files changed, 67 insertions(+)
> > 
> > diff --git a/app/test/test_rawdev.c b/app/test/test_rawdev.c
> > index 88549fb61..4db762b4c 100644
> > --- a/app/test/test_rawdev.c
> > +++ b/app/test/test_rawdev.c
> > @@ -29,6 +29,17 @@ REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftest_skeleton);
> >   static int
> >   test_rawdev_selftest_ioat(void)
> >   {
> > +	const int count = rte_rawdev_count();
> > +	int i;
> > +
> > +	for (i = 0; i < count; i++) {
> > +		struct rte_rawdev_info info = { .dev_private = NULL };
> > +		if (rte_rawdev_info_get(i, &info) == 0 &&
> > +				strstr(info.driver_name, "ioat") != NULL)
> > +			return 0;
> 
> TEST_SUCCESS? Also, didn't "ioat" have a macro for its name?
> 

Ack on the TEST_SUCCESS part.

For the seond point, yes, there is a macro for the name, but to get it one
has to include the header file for the driver, which will not be available
if the driver is not being built. Therefore, I just use a basic check for
the "ioat" name, rather than cluttering up the code with lots of
conditionals for handling cases where the driver won't be built.

/Bruce
  

Patch

diff --git a/app/test/test_rawdev.c b/app/test/test_rawdev.c
index 88549fb61..4db762b4c 100644
--- a/app/test/test_rawdev.c
+++ b/app/test/test_rawdev.c
@@ -29,6 +29,17 @@  REGISTER_TEST_COMMAND(rawdev_autotest, test_rawdev_selftest_skeleton);
 static int
 test_rawdev_selftest_ioat(void)
 {
+	const int count = rte_rawdev_count();
+	int i;
+
+	for (i = 0; i < count; i++) {
+		struct rte_rawdev_info info = { .dev_private = NULL };
+		if (rte_rawdev_info_get(i, &info) == 0 &&
+				strstr(info.driver_name, "ioat") != NULL)
+			return 0;
+	}
+
+	printf("No IOAT rawdev found, skipping tests\n");
 	return TEST_SKIPPED;
 }
 
diff --git a/doc/guides/rawdevs/ioat_rawdev.rst b/doc/guides/rawdevs/ioat_rawdev.rst
index 4b7fe8a8f..0ce984490 100644
--- a/doc/guides/rawdevs/ioat_rawdev.rst
+++ b/doc/guides/rawdevs/ioat_rawdev.rst
@@ -83,3 +83,37 @@  parameters need to be passed to create or initialize the device.
 Once probed successfully, the device will appear as a ``rawdev``, that is a
 "raw device type" inside DPDK, and can be accessed using APIs from the
 ``rte_rawdev`` library.
+
+Using IOAT Rawdev Devices
+--------------------------
+
+To use the devices from an application, the rawdev API can be used, along
+with definitions taken from the device-specific header file
+``rte_ioat_rawdev.h``. This header is needed to get the definition of
+structure parameters used by some of the rawdev APIs for IOAT rawdev
+devices, as well as providing key functions for using the device for memory
+copies.
+
+Getting Device Information
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Basic information about each rawdev device can be got using the
+``rte_rawdev_info_get()`` API. For most applications, this API will be
+needed to verify that the rawdev in question is of the expected type. For
+example, the following code in ``test_ioat_rawdev.c`` is used to identify
+the IOAT rawdev device for use for the tests:
+
+.. code-block:: C
+
+        for (i = 0; i < count && !found; i++) {
+                struct rte_rawdev_info info = { .dev_private = NULL };
+                found = (rte_rawdev_info_get(i, &info) == 0 &&
+                                strcmp(info.driver_name,
+                                                IOAT_PMD_RAWDEV_NAME_STR) == 0);
+        }
+
+When calling the ``rte_rawdev_info_get()`` API for an IOAT rawdev device,
+the ``dev_private`` field in the ``rte_rawdev_info`` struct should either
+be NULL, or else be set to point to a structure of type
+``rte_ioat_rawdev_config``, in which case the size of the configured device
+input ring will be returned in that structure.
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index d13391dd5..08e7586c6 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -24,10 +24,21 @@  static struct rte_pci_driver ioat_pmd_drv;
 #define IOAT_PMD_ERR(fmt, args...)    IOAT_PMD_LOG(ERR, fmt, ## args)
 #define IOAT_PMD_WARN(fmt, args...)   IOAT_PMD_LOG(WARNING, fmt, ## args)
 
+static void
+ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info)
+{
+	struct rte_ioat_rawdev_config *cfg = dev_info;
+	struct rte_ioat_rawdev *ioat = dev->dev_private;
+
+	if (cfg != NULL)
+		cfg->ring_size = ioat->ring_size;
+}
+
 static int
 ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
 {
 	static const struct rte_rawdev_ops ioat_rawdev_ops = {
+			.dev_info_get = ioat_dev_info_get,
 	};
 
 	struct rte_rawdev *rawdev = NULL;
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index c3216a174..7e0d72ca3 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -24,6 +24,17 @@ 
 /** Name used to adjust the log level for this driver */
 #define IOAT_PMD_LOG_NAME "rawdev.ioat"
 
+/**
+ * Configuration structure for an ioat rawdev instance
+ *
+ * This structure is to be passed as the ".dev_private" parameter when
+ * calling the rte_rawdev_get_info() and rte_rawdev_configure() APIs on
+ * an ioat rawdev instance.
+ */
+struct rte_ioat_rawdev_config {
+	unsigned short ring_size;
+};
+
 /**
  * @internal
  * Structure representing a device instance