DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	Ray Kinsella <mdr@ashroe.eu>
Cc: dev <dev@dpdk.org>, "Xia, Chenbo" <chenbo.xia@intel.com>,
	 Olivier Matz <olivier.matz@6wind.com>,
	Adrian Moreno Zapata <amorenoz@redhat.com>,
	 Thomas Monjalon <thomas@monjalon.net>
Subject: Re: [dpdk-dev] [PATCH v2 02/44] bus/vdev: add driver IOVA VA mode requirement
Date: Wed, 20 Jan 2021 16:32:13 +0100	[thread overview]
Message-ID: <CAJFAV8whp5Kv-SxpqsYoRZxxwnuF8PaVf8=XKZi3Yn1UtgxnXg@mail.gmail.com> (raw)
In-Reply-To: <20210119212507.1043636-3-maxime.coquelin@redhat.com>

On Tue, Jan 19, 2021 at 10:25 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> This patch adds driver flag in vdev bus driver so that
> vdev drivers can require VA IOVA mode to be used, which
> for example the case of Virtio-user PMD.
>
> The patch implements the .get_iommu_class() callback, that
> is called before devices probing to determine the IOVA mode
> to be used.
>
> It also adds a check right before the device is probed to
> ensure compatible IOVa mode has been selected.
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/bus/vdev/rte_bus_vdev.h |  4 ++++
>  drivers/bus/vdev/vdev.c         | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+)
>
> diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vdev.h
> index f99a41f825..c8b41e649c 100644
> --- a/drivers/bus/vdev/rte_bus_vdev.h
> +++ b/drivers/bus/vdev/rte_bus_vdev.h
> @@ -113,8 +113,12 @@ struct rte_vdev_driver {
>         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. */
> +       uint32_t drv_flags;                /**< Flags RTE_VDEV_DRV_*. */

This will probably get broken in the future, but for now, can you
indent the comment in the same way as earlier lines?


The ABI check will complain about this change so we need an exception.

rte_vdev_driver is exposed only through driver API.
We could flag the whole structure like we did for ethdev.
But there is also the alternative of just flagging the required
symbols so that we won't miss later the inclusion of this structure in
an API used by final users.
How about:

diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore
index 1dc84fa74b..435913d908 100644
--- a/devtools/libabigail.abignore
+++ b/devtools/libabigail.abignore
@@ -11,6 +11,8 @@
 ; Explicit ignore for driver-only ABI
 [suppress_type]
         name = eth_dev_ops
+[suppress_function]
+        name_regexp = rte_vdev_(|un)register

 ; Ignore fields inserted in cacheline boundary of rte_cryptodev
 [suppress_type]


>  };
>
> +/** Device driver needs IOVA as VA and cannot work with IOVA as PA */
> +#define RTE_VDEV_DRV_NEED_IOVA_AS_VA 0x0001
> +
>  /**
>   * Register a virtual device driver.
>   *
> diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
> index acfd78828f..56f15e8201 100644
> --- a/drivers/bus/vdev/vdev.c
> +++ b/drivers/bus/vdev/vdev.c
> @@ -189,6 +189,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
>  {
>         const char *name;
>         struct rte_vdev_driver *driver;
> +       enum rte_iova_mode iova_mode;
>         int ret;
>
>         if (rte_dev_is_probed(&dev->device))
> @@ -199,6 +200,14 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev)
>
>         if (vdev_parse(name, &driver))
>                 return -1;
> +
> +       iova_mode = rte_eal_iova_mode();
> +       if ((driver->drv_flags & RTE_VDEV_DRV_NEED_IOVA_AS_VA) && (iova_mode == RTE_IOVA_PA)) {
> +               VDEV_LOG(ERR, "%s requires VA IOVA mode but current mode is PA, not initializing",
> +                               name);
> +               return -1;
> +       }
> +
>         ret = driver->probe(dev);
>         if (ret == 0)
>                 dev->device.driver = &driver->driver;
> @@ -594,6 +603,27 @@ vdev_unplug(struct rte_device *dev)
>         return rte_vdev_uninit(dev->name);
>  }
>
> +static enum rte_iova_mode
> +vdev_get_iommu_class(void)
> +{
> +       const char *name;
> +       struct rte_vdev_device *dev;
> +       struct rte_vdev_driver *driver;
> +
> +       TAILQ_FOREACH(dev, &vdev_device_list, next) {
> +               name = rte_vdev_device_name(dev);
> +               if (!name)
> +                       continue;

Afaics, a device in vdev_device_list always has a name.


> +               if (vdev_parse(name, &driver))
> +                       continue;
> +
> +               if (driver->drv_flags & RTE_VDEV_DRV_NEED_IOVA_AS_VA)
> +                       return RTE_IOVA_VA;
> +       }
> +
> +       return RTE_IOVA_DC;
> +}
> +
>  static struct rte_bus rte_vdev_bus = {
>         .scan = vdev_scan,
>         .probe = vdev_probe,
> @@ -603,6 +633,7 @@ static struct rte_bus rte_vdev_bus = {
>         .parse = vdev_parse,
>         .dma_map = vdev_dma_map,
>         .dma_unmap = vdev_dma_unmap,
> +       .get_iommu_class = vdev_get_iommu_class,
>         .dev_iterate = rte_vdev_dev_iterate,
>  };
>
> --
> 2.29.2
>


-- 
David Marchand


  reply	other threads:[~2021-01-20 15:32 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 21:24 [dpdk-dev] [PATCH v2 00/44] net/virtio: Virtio PMD rework Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 01/44] bus/vdev: add helper to get vdev from eth dev Maxime Coquelin
2021-01-20  0:56   ` Thomas Monjalon
2021-01-25 10:53     ` Maxime Coquelin
2021-01-25 11:04       ` Thomas Monjalon
2021-01-21  8:58   ` Xia, Chenbo
2021-01-25 14:51     ` Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 02/44] bus/vdev: add driver IOVA VA mode requirement Maxime Coquelin
2021-01-20 15:32   ` David Marchand [this message]
2021-01-20 17:47     ` Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 03/44] net/virtio: fix getting old status on reconnect Maxime Coquelin
2021-01-21  7:12   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 04/44] net/virtio: introduce Virtio bus type Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 05/44] net/virtio: refactor virtio-user device Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 06/44] net/virtio: introduce PCI device metadata Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 07/44] net/virtio: move PCI device init in dedicated file Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 08/44] net/virtio: move PCI specific dev init to PCI ethdev init Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 09/44] net/virtio: move MSIX detection to PCI ethdev Maxime Coquelin
2021-01-21  7:12   ` Xia, Chenbo
2021-01-25 12:41     ` Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 10/44] net/virtio: force IOVA as VA mode for Virtio-user Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 11/44] net/virtio: store PCI type in Virtio device metadata Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 12/44] net/virtio: add callback for device closing Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 13/44] net/virtio: validate features at bus level Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 14/44] net/virtio: remove bus type enum Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 15/44] net/virtio: move PCI-specific fields to PCI device Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 16/44] net/virtio: pack virtio HW struct Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 17/44] net/virtio: move legacy IO to Virtio PCI Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 18/44] net/virtio: introduce generic virtio header Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 19/44] net/virtio: move features definition to generic header Maxime Coquelin
2021-01-21  6:47   ` Xia, Chenbo
2021-01-25 12:35     ` Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 20/44] net/virtio: move virtqueue defines in " Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 21/44] net/virtio: move config definitions to " Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 22/44] net/virtio: make interrupt handling more generic Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 23/44] net/virtio: move vring alignment to generic header Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 24/44] net/virtio: remove last PCI refs in non-PCI code Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 25/44] net/virtio: make Vhost-user req sender consistent Maxime Coquelin
2021-01-21  8:50   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 26/44] net/virtio: add Virtio-user ops to set owner Maxime Coquelin
2021-01-22  3:27   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 27/44] net/virtio: add Virtio-user features ops Maxime Coquelin
2021-01-22  7:25   ` Xia, Chenbo
2021-01-25 14:53     ` Maxime Coquelin
2021-01-22  8:46   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 28/44] net/virtio: add Virtio-user protocol " Maxime Coquelin
2021-01-22  7:27   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 29/44] net/virtio: add Virtio-user memory tables ops Maxime Coquelin
2021-01-22  7:34   ` Xia, Chenbo
2021-01-25 14:56     ` Maxime Coquelin
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 30/44] net/virtio: add Virtio-user vring setting ops Maxime Coquelin
2021-01-22  7:49   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 31/44] net/virtio: add Virtio-user vring file ops Maxime Coquelin
2021-01-22  8:01   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 32/44] net/virtio: add Virtio-user vring address ops Maxime Coquelin
2021-01-22  8:02   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 33/44] net/virtio: add Virtio-user status ops Maxime Coquelin
2021-01-22  8:02   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 34/44] net/virtio: remove useless request ops Maxime Coquelin
2021-01-22  8:10   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 35/44] net/virtio: improve Virtio-user errors handling Maxime Coquelin
2021-01-22  8:10   ` Xia, Chenbo
2021-01-19 21:24 ` [dpdk-dev] [PATCH v2 36/44] net/virtio: move Vhost-user reqs to Vhost-user backend Maxime Coquelin
2021-01-21  8:56   ` Xia, Chenbo
2021-01-25 14:50     ` Maxime Coquelin
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 37/44] net/virtio: make server mode blocking Maxime Coquelin
2021-01-22  8:19   ` Xia, Chenbo
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 38/44] net/virtio: move protocol features to Vhost-user Maxime Coquelin
2021-01-22  8:20   ` Xia, Chenbo
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 39/44] net/virtio: introduce backend data Maxime Coquelin
2021-01-22  8:26   ` Xia, Chenbo
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 40/44] net/virtio: move Vhost-user specifics to its backend Maxime Coquelin
2021-01-22  8:49   ` Xia, Chenbo
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 41/44] net/virtio: move Vhost-kernel data " Maxime Coquelin
2021-01-22  8:55   ` Xia, Chenbo
2021-01-25 14:59     ` Maxime Coquelin
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 42/44] net/virtio: move Vhost-vDPA " Maxime Coquelin
2021-01-22  9:06   ` Xia, Chenbo
2021-01-25 15:02     ` Maxime Coquelin
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 43/44] net/virtio: improve Vhost-user error logging Maxime Coquelin
2021-01-22  9:11   ` Xia, Chenbo
2021-01-25 15:04     ` Maxime Coquelin
2021-01-26  6:10       ` Xia, Chenbo
2021-01-19 21:25 ` [dpdk-dev] [PATCH v2 44/44] net/virtio: handle Virtio-user setup failure properly Maxime Coquelin
2021-01-22  9:24   ` Xia, Chenbo
2021-01-25 16:16     ` 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='CAJFAV8whp5Kv-SxpqsYoRZxxwnuF8PaVf8=XKZi3Yn1UtgxnXg@mail.gmail.com' \
    --to=david.marchand@redhat.com \
    --cc=amorenoz@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=mdr@ashroe.eu \
    --cc=olivier.matz@6wind.com \
    --cc=thomas@monjalon.net \
    /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).