From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 67044A052A; Tue, 26 Jan 2021 10:24:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CE5E1412D0; Tue, 26 Jan 2021 10:24:41 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 32AFD141232 for ; Tue, 26 Jan 2021 10:24:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611653077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RKfcIi2KuJsUoQStKnrYN79g4JJazhBbXS/wkb3m9sI=; b=IBat6oP4CKl1KMEiUcMT6pBAR+a8kYvga5JDpGdieb6pOEhxM3j/5yNas9sXTNhMXKjRCT LDipPh7SjQ2vo+scdCLfXbEg2Zg1LAoBQIbRxpLi5YpJAqmyWp0NR6l4JtUDGelKwMQzyU /d/nUD5P+DWU2D2AxjfNOyk+cOXLg0k= 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-435-vYHxGokqN92tvkLNqCURMg-1; Tue, 26 Jan 2021 04:24:35 -0500 X-MC-Unique: vYHxGokqN92tvkLNqCURMg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88AB88066EE; Tue, 26 Jan 2021 09:24:34 +0000 (UTC) Received: from [10.36.110.31] (unknown [10.36.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 365DD5D9C2; Tue, 26 Jan 2021 09:24:33 +0000 (UTC) To: "Xia, Chenbo" , "dev@dpdk.org" , "olivier.matz@6wind.com" , "amorenoz@redhat.com" , "david.marchand@redhat.com" References: <20210125171444.167241-1-maxime.coquelin@redhat.com> <20210125171444.167241-3-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: Date: Tue, 26 Jan 2021 10:24:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 02/44] bus/vdev: add driver IOVA VA mode requirement X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 1/26/21 10:23 AM, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Tuesday, January 26, 2021 1:14 AM >> To: dev@dpdk.org; Xia, Chenbo ; olivier.matz@6wind.com; >> amorenoz@redhat.com; david.marchand@redhat.com >> Cc: Maxime Coquelin >> Subject: [PATCH v3 02/44] bus/vdev: add driver IOVA VA mode requirement >> >> 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. > > s/IOVa/IOVA Just spotted it while reworking the commit message :) >> >> Signed-off-by: Maxime Coquelin >> --- >> drivers/bus/vdev/rte_bus_vdev.h | 4 ++++ >> drivers/bus/vdev/vdev.c | 29 +++++++++++++++++++++++++++++ >> 2 files changed, 33 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_*. */ > > I remember David mentioned that the comment above should be consistent with others, which > also makes sense to me > > Thanks, > Chenbo > >> }; >> >> +/** 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..9a673347ae 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,25 @@ 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 (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 +631,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 >