From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 4/8] raw/ioat: create device on probe and destroy on release
Date: Thu, 30 May 2019 22:25:21 +0100 [thread overview]
Message-ID: <20190530212525.40370-5-bruce.richardson@intel.com> (raw)
In-Reply-To: <20190530212525.40370-1-bruce.richardson@intel.com>
Add the create/destroy driver functions so that we can actually allocate
a rawdev and destroy it when done. No rawdev API functions are actually
implemented at this point.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
doc/guides/rawdevs/ioat_rawdev.rst | 11 ++++
drivers/raw/ioat/ioat_rawdev.c | 93 +++++++++++++++++++++++++++++-
drivers/raw/ioat/rte_ioat_rawdev.h | 20 +++++++
3 files changed, 121 insertions(+), 3 deletions(-)
diff --git a/doc/guides/rawdevs/ioat_rawdev.rst b/doc/guides/rawdevs/ioat_rawdev.rst
index 99e757498..476b0503f 100644
--- a/doc/guides/rawdevs/ioat_rawdev.rst
+++ b/doc/guides/rawdevs/ioat_rawdev.rst
@@ -34,3 +34,14 @@ them to a suitable DPDK-supported kernel driver. When querying the
status of the devices, they will appear under the category of "dma
devices", i.e. the command ``dpdk-devbind.py --status-dev dma`` can be used
to see the state of those devices alone.
+
+Device Probing and Initialization
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Once bound to a suitable kernel device driver, the HW devices will be found
+as part of the PCI scan done at application initialization time. No vdev
+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.
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index d9fc3091a..b6964bccd 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -2,6 +2,7 @@
* Copyright(c) 2019 Intel Corporation
*/
+#include <rte_cycles.h>
#include <rte_bus_pci.h>
#include <rte_rawdev_pmd.h>
@@ -26,15 +27,101 @@ static struct rte_pci_driver ioat_pmd_drv;
static int
ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
{
- RTE_SET_USED(name);
- RTE_SET_USED(dev);
+ static const struct rte_rawdev_ops ioat_rawdev_ops = {
+ };
+
+ struct rte_rawdev *rawdev = NULL;
+ struct rte_ioat_rawdev *ioat = NULL;
+ int ret = 0;
+ int retry = 0;
+
+ if (!name) {
+ IOAT_PMD_ERR("Invalid name of the device!");
+ ret = -EINVAL;
+ goto cleanup;
+ }
+
+ /* Allocate device structure */
+ rawdev = rte_rawdev_pmd_allocate(name, sizeof(struct rte_ioat_rawdev),
+ dev->device.numa_node);
+ if (rawdev == NULL) {
+ IOAT_PMD_ERR("Unable to allocate raw device");
+ ret = -EINVAL;
+ goto cleanup;
+ }
+
+ rawdev->dev_ops = &ioat_rawdev_ops;
+ rawdev->device = &dev->device;
+ rawdev->driver_name = dev->device.driver->name;
+
+ ioat = rawdev->dev_private;
+ ioat->rawdev = rawdev;
+ ioat->regs = dev->mem_resource[0].addr;
+ ioat->ring_size = 0;
+ ioat->desc_ring = NULL;
+ ioat->status_addr = rte_malloc_virt2iova(ioat) +
+ offsetof(struct rte_ioat_rawdev, status);
+
+ /* do device initialization - reset and set error behaviour */
+ if (ioat->regs->chancnt != 1)
+ IOAT_PMD_ERR("%s: Channel count == %d\n", __func__,
+ ioat->regs->chancnt);
+
+ if (ioat->regs->chanctrl & 0x100) { /* locked by someone else */
+ IOAT_PMD_WARN("%s: Channel appears locked\n", __func__);
+ ioat->regs->chanctrl = 0;
+ }
+
+ ioat->regs->chancmd = RTE_IOAT_CHANCMD_SUSPEND;
+ rte_delay_ms(1);
+ ioat->regs->chancmd = RTE_IOAT_CHANCMD_RESET;
+ rte_delay_ms(1);
+ while (ioat->regs->chancmd & RTE_IOAT_CHANCMD_RESET) {
+ ioat->regs->chainaddr = 0;
+ rte_delay_ms(1);
+ if (++retry >= 200) {
+ IOAT_PMD_ERR("%s: cannot reset device. CHANCMD=0x%llx, CHANSTS=0x%llx, CHANERR=0x%llx\n",
+ __func__,
+ (unsigned long long)ioat->regs->chancmd,
+ (unsigned long long)ioat->regs->chansts,
+ (unsigned long long)ioat->regs->chanerr);
+ ret = -EIO;
+ }
+ }
+ ioat->regs->chanctrl = RTE_IOAT_CHANCTRL_ANY_ERR_ABORT_EN |
+ RTE_IOAT_CHANCTRL_ERR_COMPLETION_EN;
+
return 0;
+
+cleanup:
+ if (rawdev)
+ rte_rawdev_pmd_release(rawdev);
+
+ return ret;
}
static int
ioat_rawdev_destroy(const char *name)
{
- RTE_SET_USED(name);
+ int ret;
+ struct rte_rawdev *rdev;
+
+ if (!name) {
+ IOAT_PMD_ERR("Invalid device name");
+ return -EINVAL;
+ }
+
+ rdev = rte_rawdev_pmd_get_named_dev(name);
+ if (!rdev) {
+ IOAT_PMD_ERR("Invalid device name (%s)", name);
+ return -EINVAL;
+ }
+
+ /* rte_rawdev_close is called by pmd_release */
+ ret = rte_rawdev_pmd_release(rdev);
+ if (ret)
+ IOAT_PMD_DEBUG("Device cleanup failed");
+
return 0;
}
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index e77406403..c3216a174 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -14,6 +14,9 @@
* @b EXPERIMENTAL: these structures and APIs may change without prior notice
*/
+#include <rte_memory.h>
+#include <rte_ioat_spec.h>
+
/** Name of the device driver */
#define IOAT_PMD_RAWDEV_NAME rawdev_ioat
/** String reported as the device driver name by rte_rawdev_info_get() */
@@ -21,4 +24,21 @@
/** Name used to adjust the log level for this driver */
#define IOAT_PMD_LOG_NAME "rawdev.ioat"
+/**
+ * @internal
+ * Structure representing a device instance
+ */
+struct rte_ioat_rawdev {
+ struct rte_rawdev *rawdev;
+ volatile struct rte_ioat_registers *regs;
+ phys_addr_t status_addr;
+ phys_addr_t ring_addr;
+
+ unsigned short ring_size;
+ struct rte_ioat_desc *desc_ring;
+
+ /* to report completions, the device will write status back here */
+ volatile uint64_t status __rte_cache_aligned;
+};
+
#endif
--
2.21.0
next prev parent reply other threads:[~2019-05-30 21:26 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 21:25 [dpdk-dev] [PATCH 0/8] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 1/8] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 2/8] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 3/8] raw/ioat: add register definition file Bruce Richardson
2019-05-30 23:53 ` Stephen Hemminger
2019-06-06 13:19 ` Bruce Richardson
2019-05-30 21:25 ` Bruce Richardson [this message]
2019-05-30 21:25 ` [dpdk-dev] [PATCH 5/8] raw/ioat: add device info function Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 6/8] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 7/8] raw/ioat: add statistics functions Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 8/8] raw/ioat: add local API to perform copies Bruce Richardson
2019-06-03 14:44 ` Thomas Monjalon
2019-06-04 12:23 ` Bruce Richardson
2019-06-05 13:52 ` Jerin Jacob Kollanukkaran
2019-06-05 13:57 ` Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 0/8] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 1/8] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 2/8] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 3/8] raw/ioat: add register definition file Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 4/8] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 5/8] raw/ioat: add device info function Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 6/8] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 7/8] raw/ioat: add statistics functions Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 8/8] raw/ioat: add local API to perform copies Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 0/8] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 1/8] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-06-27 11:55 ` Burakov, Anatoly
2019-06-28 12:43 ` Bruce Richardson
2019-07-01 7:38 ` Hu, Jiayu
2019-07-01 7:51 ` Thomas Monjalon
2019-07-01 8:29 ` Hu, Jiayu
2019-07-01 14:30 ` Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 2/8] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-06-27 11:57 ` Burakov, Anatoly
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 3/8] raw/ioat: add register definition file Bruce Richardson
2019-06-27 12:01 ` Burakov, Anatoly
2019-06-28 12:44 ` Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 4/8] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-06-27 12:09 ` Burakov, Anatoly
2019-06-28 16:21 ` Bruce Richardson
2019-06-27 12:28 ` Burakov, Anatoly
2019-06-28 12:46 ` Bruce Richardson
2019-06-28 12:59 ` Burakov, Anatoly
2019-06-28 13:15 ` Bruce Richardson
2019-06-28 13:28 ` Burakov, Anatoly
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 5/8] raw/ioat: add device info function Bruce Richardson
2019-06-27 12:16 ` Burakov, Anatoly
2019-06-28 21:09 ` Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 6/8] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-06-27 12:29 ` Burakov, Anatoly
2019-06-27 16:37 ` Pattan, Reshma
2019-06-28 21:21 ` Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 7/8] raw/ioat: add statistics functions Bruce Richardson
2019-06-27 12:38 ` Burakov, Anatoly
2019-07-01 10:11 ` Pattan, Reshma
2019-07-01 12:56 ` Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 8/8] raw/ioat: add local API to perform copies Bruce Richardson
2019-06-27 12:45 ` Burakov, Anatoly
2019-06-27 15:34 ` [dpdk-dev] [PATCH v3 0/8] raw/ioat: driver for Intel QuickData Technology Van Haaren, Harry
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 0/9] " Bruce Richardson
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 1/9] rawdev: allow devices to skip extra memory allocation Bruce Richardson
2019-07-02 11:34 ` Hemant Agrawal
2019-07-02 11:43 ` Shreyansh Jain
2019-07-02 12:41 ` Bruce Richardson
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 2/9] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 3/9] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 4/9] raw/ioat: add register definition file Bruce Richardson
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 5/9] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-07-02 9:39 ` Burakov, Anatoly
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 6/9] raw/ioat: add device info function Bruce Richardson
2019-07-02 2:33 ` Hu, Jiayu
2019-07-02 8:28 ` Bruce Richardson
2019-07-02 9:40 ` Burakov, Anatoly
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 7/9] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-07-02 9:49 ` Burakov, Anatoly
2019-07-02 9:59 ` Bruce Richardson
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 8/9] raw/ioat: add statistics functions Bruce Richardson
2019-07-02 9:50 ` Burakov, Anatoly
2019-07-01 15:56 ` [dpdk-dev] [PATCH v4 9/9] raw/ioat: add local API to perform copies Bruce Richardson
2019-07-01 15:58 ` [dpdk-dev] [PATCH v4 0/9] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 " Bruce Richardson
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 1/9] rawdev: allow devices to skip extra memory allocation Bruce Richardson
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 2/9] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-07-03 1:53 ` Hu, Jiayu
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 3/9] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-07-03 1:54 ` Hu, Jiayu
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 4/9] raw/ioat: add register definition file Bruce Richardson
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 5/9] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-07-03 1:57 ` Hu, Jiayu
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 6/9] raw/ioat: add device info function Bruce Richardson
2019-07-03 1:58 ` Hu, Jiayu
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 7/9] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-07-03 1:59 ` Hu, Jiayu
2019-07-03 16:21 ` Aaron Conole
2019-07-03 16:44 ` Bruce Richardson
2019-07-03 20:26 ` Aaron Conole
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 8/9] raw/ioat: add statistics functions Bruce Richardson
2019-07-03 2:00 ` Hu, Jiayu
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 9/9] raw/ioat: add local API to perform copies Bruce Richardson
2019-07-03 2:01 ` Hu, Jiayu
2019-07-04 7:45 ` [dpdk-dev] [PATCH v5 0/9] raw/ioat: driver for Intel QuickData Technology Thomas Monjalon
2019-07-04 22:17 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190530212525.40370-5-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).