From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30834A04F1; Fri, 13 Dec 2019 15:14:04 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A17331BFAC; Fri, 13 Dec 2019 15:13:43 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 9197B1BF9C for ; Fri, 13 Dec 2019 15:13:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576246419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9f1DhzMsFTQb2Ey43L2zkluCSwQM0Tjn5LgKUdvc5wQ=; b=D+aSRzZO6mpaWFt2YwGBj0Nc4AWMp0NBdxPgtPXoMMEQwS9XpF+PYi2gZ+EOFZcnn5kIeJ IrqVYuzT4tI+x27LCUPtr04g4KEpM+dPEqyzzKKKv7lrgAWUEJmEr0ZjhJalJU998zhnzN xzqezE2o35RWLmKzQgzRzvVXIFXAWKc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-N6tHRgGRM9ykrDrNo0QXWQ-1; Fri, 13 Dec 2019 09:13:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55DC4800D5B; Fri, 13 Dec 2019 14:13:37 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-19.ams2.redhat.com [10.36.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id B196360C05; Fri, 13 Dec 2019 14:13:35 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com, anatoly.burakov@intel.com Cc: Maxime Coquelin Date: Fri, 13 Dec 2019 15:13:21 +0100 Message-Id: <20191213141322.32730-4-maxime.coquelin@redhat.com> In-Reply-To: <20191213141322.32730-1-maxime.coquelin@redhat.com> References: <20191213141322.32730-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: N6tHRgGRM9ykrDrNo0QXWQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH 3/4] bus/vdev: add DMA mapping supprt 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" This patch enables VDEVs to implement their own DMA map and unmap callbacks. It will be used by Virtio-user PMD to support external memory registered by applications like Seastar or VPP. Signed-off-by: Maxime Coquelin --- drivers/bus/vdev/rte_bus_vdev.h | 24 ++++++++++++++++ drivers/bus/vdev/vdev.c | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/drivers/bus/vdev/rte_bus_vdev.h b/drivers/bus/vdev/rte_bus_vde= v.h index 2bc46530c9..6f920cb064 100644 --- a/drivers/bus/vdev/rte_bus_vdev.h +++ b/drivers/bus/vdev/rte_bus_vdev.h @@ -53,6 +53,18 @@ rte_vdev_device_args(const struct rte_vdev_device *dev) /** Double linked list of virtual device drivers. */ TAILQ_HEAD(vdev_driver_list, rte_vdev_driver); =20 +/** + * Virtual device DMA map function. + */ +typedef int (rte_vdev_dma_map_t)(struct rte_vdev_device *dev, void *addr, +=09=09=09 uint64_t iova, size_t len); + +/** + * Virtual device DMA unmap function. + */ +typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr= , +=09=09=09 uint64_t iova, size_t len); + /** * Probe function called for each virtual device driver once. */ @@ -69,10 +81,22 @@ typedef int (rte_vdev_remove_t)(struct rte_vdev_device = *dev); struct rte_vdev_driver { =09TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */ =09struct rte_driver driver; /**< Inherited general driver. */ +=09rte_vdev_dma_map_t *dma_map; /**name); } =20 +static int +vdev_dma_map(struct rte_device *dev, void *addr, uint64_t iova, size_t len= ) +{ +=09struct rte_vdev_device *vdev =3D RTE_DEV_TO_VDEV(dev); +=09const struct rte_vdev_driver *vdrv; + +=09if (!dev || !dev->driver) { +=09=09rte_errno =3D EINVAL; +=09=09return -1; +=09} + +=09vdrv =3D RTE_DRV_TO_VDRV_CONST(dev->driver); +=09if (!vdrv) { +=09=09rte_errno =3D EINVAL; +=09=09return -1; +=09} + +=09if (vdrv->dma_map) +=09=09return vdrv->dma_map(vdev, addr, iova, len); + +=09rte_errno =3D ENOTSUP; +=09return -1; +} + +static int +vdev_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t l= en) +{ +=09struct rte_vdev_device *vdev =3D RTE_DEV_TO_VDEV(dev); +=09const struct rte_vdev_driver *vdrv; + +=09if (!dev || !dev->driver) { +=09=09rte_errno =3D EINVAL; +=09=09return -1; +=09} + +=09vdrv =3D RTE_DRV_TO_VDRV_CONST(dev->driver); +=09if (!vdrv) { +=09=09rte_errno =3D EINVAL; +=09=09return -1; +=09} + +=09if (vdrv->dma_map) +=09=09return vdrv->dma_unmap(vdev, addr, iova, len); + +=09rte_errno =3D ENOTSUP; +=09return -1; +} + static struct rte_bus rte_vdev_bus =3D { =09.scan =3D vdev_scan, =09.probe =3D vdev_probe, @@ -553,6 +601,8 @@ static struct rte_bus rte_vdev_bus =3D { =09.plug =3D vdev_plug, =09.unplug =3D vdev_unplug, =09.parse =3D vdev_parse, +=09.dma_map =3D vdev_dma_map, +=09.dma_unmap =3D vdev_dma_unmap, =09.dev_iterate =3D rte_vdev_dev_iterate, }; =20 --=20 2.21.0