From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Fu, Patrick" <patrick.fu@intel.com>,
"amorenoz@redhat.com" <amorenoz@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v3 1/8] bus/vdev: add DMA mapping ops
Date: Wed, 30 Sep 2020 05:47:17 +0000 [thread overview]
Message-ID: <MN2PR11MB40630676EEEBA3161FF616E69C330@MN2PR11MB4063.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200929161404.124580-2-maxime.coquelin@redhat.com>
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, September 30, 2020 12:14 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Fu, Patrick
> <patrick.fu@intel.com>; amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v3 1/8] bus/vdev: add DMA mapping ops
>
> Add DMA map/unmap operation callbacks to the vdev bus, which
> could be used by DMA capable vdev drivers.
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> drivers/bus/vdev/rte_bus_vdev.h | 46 +++++++++++++++++++++++++++--
> drivers/bus/vdev/vdev.c | 52 +++++++++++++++++++++++++++++++++
> 2 files changed, 95 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/bus/vdev/rte_bus_vdev.h
> b/drivers/bus/vdev/rte_bus_vdev.h
> index 78a032cea8..d14eeb41b0 100644
> --- a/drivers/bus/vdev/rte_bus_vdev.h
> +++ b/drivers/bus/vdev/rte_bus_vdev.h
> @@ -63,14 +63,54 @@ typedef int (rte_vdev_probe_t)(struct rte_vdev_device
> *dev);
> */
> typedef int (rte_vdev_remove_t)(struct rte_vdev_device *dev);
>
> +/**
> + * Driver-specific DMA mapping. After a successful call the device
> + * will be able to read/write from/to this segment.
> + *
> + * @param dev
> + * Pointer to the Virtual device.
> + * @param addr
> + * Starting virtual address of memory to be mapped.
> + * @param iova
> + * Starting IOVA address of memory to be mapped.
> + * @param len
> + * Length of memory segment being mapped.
> + * @return
> + * - 0 On success.
> + * - Negative value and rte_errno is set otherwise.
> + */
> +typedef int (rte_vdev_dma_map_t)(struct rte_vdev_device *dev, void *addr,
> + uint64_t iova, size_t len);
> +
> +/**
> + * Driver-specific DMA un-mapping. After a successful call the device
> + * will not be able to read/write from/to this segment.
> + *
> + * @param dev
> + * Pointer to the Virtual device.
> + * @param addr
> + * Starting virtual address of memory to be unmapped.
> + * @param iova
> + * Starting IOVA address of memory to be unmapped.
> + * @param len
> + * Length of memory segment being unmapped.
> + * @return
> + * - 0 On success.
> + * - Negative value and rte_errno is set otherwise.
> + */
> +typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void
> *addr,
> + uint64_t iova, size_t len);
> +
> /**
> * A virtual device driver abstraction.
> */
> struct rte_vdev_driver {
> TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
> - struct rte_driver driver; /**< Inherited general driver. */
> - rte_vdev_probe_t *probe; /**< Virtual device probe function.
> */
> - rte_vdev_remove_t *remove; /**< Virtual device remove function.
> */
> + struct rte_driver driver; /**< Inherited general driver. */
> + rte_vdev_probe_t *probe; /**< Virtual device probe function.
> */
> + rte_vdev_remove_t *remove; /**< Virtual device remove function.
> */
> + rte_vdev_dma_map_t *dma_map; /**< Virtual device DMA map
> function. */
> + rte_vdev_dma_unmap_t *dma_unmap; /**< Virtual device DMA unmap
> function. */
> };
>
> /**
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index d746149a2e..0e94ea9d26 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -134,6 +134,56 @@ vdev_parse(const char *name, void *addr)
> return driver == NULL;
> }
>
> +static int
> +vdev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t
> len)
> +{
> + struct rte_vdev_device *vdev = RTE_DEV_TO_VDEV(dev);
> + const struct rte_vdev_driver *driver;
> +
> + if (!vdev) {
> + rte_errno = EINVAL;
> + return -1;
> + }
> +
> + if (!vdev->device.driver) {
> + VDEV_LOG(DEBUG, "no driver attach to device %s", dev->name);
> + return 1;
> + }
> +
> + driver = container_of(vdev->device.driver, const struct
> rte_vdev_driver,
> + driver);
> +
> + if (driver->dma_map)
> + return driver->dma_map(vdev, addr, iova, len);
> +
> + return 0;
> +}
> +
> +static int
> +vdev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t
> len)
> +{
> + struct rte_vdev_device *vdev = RTE_DEV_TO_VDEV(dev);
> + const struct rte_vdev_driver *driver;
> +
> + if (!vdev) {
> + rte_errno = EINVAL;
> + return -1;
> + }
> +
> + if (!vdev->device.driver) {
> + VDEV_LOG(DEBUG, "no driver attach to device %s", dev->name);
> + return 1;
> + }
> +
> + driver = container_of(vdev->device.driver, const struct
> rte_vdev_driver,
> + driver);
> +
> + if (driver->dma_unmap)
> + return driver->dma_unmap(vdev, addr, iova, len);
> +
> + return 0;
> +}
> +
> static int
> vdev_probe_all_drivers(struct rte_vdev_device *dev)
> {
> @@ -551,6 +601,8 @@ static struct rte_bus rte_vdev_bus = {
> .plug = vdev_plug,
> .unplug = vdev_unplug,
> .parse = vdev_parse,
> + .dma_map = vdev_dma_map,
> + .dma_unmap = vdev_dma_unmap,
> .dev_iterate = rte_vdev_dev_iterate,
> };
>
> --
> 2.26.2
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
next prev parent reply other threads:[~2020-09-30 5:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 16:13 [dpdk-dev] [PATCH v3 0/8] virtio-user: introduce vhost-vdpa backend Maxime Coquelin
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 1/8] bus/vdev: add DMA mapping ops Maxime Coquelin
2020-09-30 5:47 ` Xia, Chenbo [this message]
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 2/8] net/virtio: introduce DMA ops Maxime Coquelin
2020-09-30 5:47 ` Xia, Chenbo
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 3/8] net/virtio: move backend type selection to ethdev Maxime Coquelin
2020-09-30 5:49 ` Xia, Chenbo
2020-10-16 5:42 ` Wang, Yinan
2020-10-16 5:58 ` Wang, Yinan
2020-10-20 1:52 ` Wang, Yinan
2020-10-20 7:11 ` Maxime Coquelin
2020-10-20 7:20 ` Adrian Moreno
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 4/8] net/virtio: introduce Vhost-vDPA backend type Maxime Coquelin
2020-09-30 5:49 ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 5/8] net/virtio: check protocol feature in user backend Maxime Coquelin
2020-09-30 5:49 ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 6/8] net/virtio: adapt Virtio-user status size Maxime Coquelin
2020-09-30 5:49 ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 7/8] net/virtio: split virtio-user start Maxime Coquelin
2020-09-30 5:49 ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 8/8] net/virtio: introduce Vhost-vDPA backend Maxime Coquelin
2020-09-30 5:49 ` Xia, Chenbo
2020-09-30 16:22 ` [dpdk-dev] [PATCH v3 0/8] virtio-user: introduce vhost-vdpa backend Maxime Coquelin
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=MN2PR11MB40630676EEEBA3161FF616E69C330@MN2PR11MB4063.namprd11.prod.outlook.com \
--to=chenbo.xia@intel.com \
--cc=amorenoz@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=patrick.fu@intel.com \
/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).