From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 87150A045E for ; Thu, 30 May 2019 23:26:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 421341B95C; Thu, 30 May 2019 23:26:01 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BD9B11B94A for ; Thu, 30 May 2019 23:25:50 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 14:25:49 -0700 X-ExtLoop1: 1 Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by orsmga001.jf.intel.com with ESMTP; 30 May 2019 14:25:49 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Thu, 30 May 2019 22:25:22 +0100 Message-Id: <20190530212525.40370-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530212525.40370-1-bruce.richardson@intel.com> References: <20190530212525.40370-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 5/8] raw/ioat: add device info function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- app/test/meson.build | 3 +++ app/test/test_ioat_rawdev.c | 23 ++++++++++++++++++++ doc/guides/rawdevs/ioat_rawdev.rst | 34 ++++++++++++++++++++++++++++++ drivers/raw/ioat/ioat_rawdev.c | 11 ++++++++++ drivers/raw/ioat/rte_ioat_rawdev.h | 11 ++++++++++ 5 files changed, 82 insertions(+) diff --git a/app/test/meson.build b/app/test/meson.build index 9867619d3..9fe3ddc89 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -305,6 +305,9 @@ endif if dpdk_conf.has('RTE_LIBRTE_KNI') test_deps += 'kni' endif +if dpdk_conf.has('RTE_LIBRTE_PMD_IOAT_RAWDEV') + test_deps += 'pmd_ioat' +endif cflags = machine_args if cc.has_argument('-Wno-format-truncation') diff --git a/app/test/test_ioat_rawdev.c b/app/test/test_ioat_rawdev.c index bd1bb2827..ac1389f6e 100644 --- a/app/test/test_ioat_rawdev.c +++ b/app/test/test_ioat_rawdev.c @@ -11,9 +11,32 @@ test_ioat_rawdev(void) { return TEST_SKIPPED; } #else +#include +#include + +#include +#include +#include + static int test_ioat_rawdev(void) { + const int count = rte_rawdev_count(); + int i, found = 0; + + printf("Checking %d rawdevs\n", count); + 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); + } + + if (!found) { + printf("No IOAT rawdev found, skipping tests\n"); + return TEST_SKIPPED; + } + return 0; } diff --git a/doc/guides/rawdevs/ioat_rawdev.rst b/doc/guides/rawdevs/ioat_rawdev.rst index 476b0503f..b68cdffc3 100644 --- a/doc/guides/rawdevs/ioat_rawdev.rst +++ b/doc/guides/rawdevs/ioat_rawdev.rst @@ -45,3 +45,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 b6964bccd..90bed2810 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 -- 2.21.0