[v4,6/9] raw/ioat: add device info function
Checks
Commit Message
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>
Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
---
V4: Use TEST_SUCCESS in place of 0, when returning from test case.
Minor documentation updates.
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
> -----Original Message-----
> From: Richardson, Bruce
> Sent: Monday, July 1, 2019 11:56 PM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; jerinj@marvell.com; Hu, Jiayu
> <jiayu.hu@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> Van Haaren, Harry <harry.van.haaren@intel.com>
> Subject: [PATCH v4 6/9] raw/ioat: add device info function
>
> 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>
> Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
> ---
> V4: Use TEST_SUCCESS in place of 0, when returning from test case.
> Minor documentation updates.
>
> 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/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
> index 86b5b2a77..2bfe2544d 100644
> --- a/drivers/raw/ioat/ioat_rawdev.c
> +++ b/drivers/raw/ioat/ioat_rawdev.c
> @@ -34,10 +34,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;
> +}
The CBDMA user may want to know the maximum copy length that the device
supports and the NUMA location of the device. So can ioat_dev_info_get()
return more device information?
Thanks,
Jiayu
On Tue, Jul 02, 2019 at 03:33:25AM +0100, Hu, Jiayu wrote:
>
> > -----Original Message-----
> > From: Richardson, Bruce
> > Sent: Monday, July 1, 2019 11:56 PM
> > To: dev@dpdk.org
> > Cc: thomas@monjalon.net; jerinj@marvell.com; Hu, Jiayu
> > <jiayu.hu@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> > Van Haaren, Harry <harry.van.haaren@intel.com>
> > Subject: [PATCH v4 6/9] raw/ioat: add device info function
> >
> > 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>
> > Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
> > ---
> > V4: Use TEST_SUCCESS in place of 0, when returning from test case.
> > Minor documentation updates.
> >
> > 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/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
> > index 86b5b2a77..2bfe2544d 100644
> > --- a/drivers/raw/ioat/ioat_rawdev.c
> > +++ b/drivers/raw/ioat/ioat_rawdev.c
> > @@ -34,10 +34,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;
> > +}
>
> The CBDMA user may want to know the maximum copy length that the device
> supports and the NUMA location of the device. So can ioat_dev_info_get()
> return more device information?
>
The NUMA node id is already part of the rawdev info structure returned to
the user.
As for maximum copy length, yes, that could be added. However, since it's
actually a characteristic of the hardware, it could be just a define inside
the header file rather than needing to be returned per instance. Unlike
with ethdevs and cryptodevs, rawdevs always have a device-specific
dependency so using defines from the header should work fine, and not
everything needs to come via dev_info.
Regards,
/Bruce
On 01-Jul-19 4:55 PM, 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>
> Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
> ---
> V4: Use TEST_SUCCESS in place of 0, when returning from test case.
> Minor documentation updates.
>
> V2: Test case is placed in driver self-test routine
> ---
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
@@ -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 TEST_SUCCESS;
+ }
+
+ printf("No IOAT rawdev found, skipping tests\n");
return TEST_SKIPPED;
}
@@ -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 queried 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 snippet can be used to identify an IOAT
+rawdev device for use by an application:
+
+.. 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.
@@ -34,10 +34,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;
@@ -25,6 +25,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