From patchwork Wed Oct 16 14:29:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna Attunuru X-Patchwork-Id: 61312 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 318001E8CE; Wed, 16 Oct 2019 16:29:17 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 077891D42A for ; Wed, 16 Oct 2019 16:29:14 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9GEPhLE016565; Wed, 16 Oct 2019 07:29:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0818; bh=J9FKRWn8wAdwO7/bpJPGpbsTCBtT8LcLMmzeySQFUfU=; b=M0P2vMuAXzd8tYOl0ISN+B6a5Tu5dK3Fd97B7GD3HALt7k0ofxR+Jrja/xe8v4JSiyDG fXrUwyEawIfOD/Ebk0aXPlQ4j1ZL1wdpMxYmhbOUmEAjqF4QKaiBzvjLQVI0x0ZJSeq5 KLk5tl7hDQb2RP77JZx94YV3nFLzVQQUC8eISNHuMaqFsIQJ+Y+mgGWBJWNr8IJ/x2Ie 8tbeMTbBaWWw15Eb0tUW/+ARilRvtx1EuqCQ0Ohcm37IiiVfznqwJ+4jLcVcU6CQgE1w TiJdfPqseJlYCKj73SH74Pog6dbFvDmzxqdyznmQyFb5BvIs5XPQjFBxcs23inyaE/Hj NA== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2vnpmbk89d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 16 Oct 2019 07:29:13 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 16 Oct 2019 07:29:12 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 16 Oct 2019 07:29:12 -0700 Received: from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72]) by maili.marvell.com (Postfix) with ESMTP id 22EEE3F7041; Wed, 16 Oct 2019 07:29:09 -0700 (PDT) From: To: CC: , , , , Vamsi Attunuru Date: Wed, 16 Oct 2019 19:59:01 +0530 Message-ID: <20191016142901.31059-1-vattunuru@marvell.com> X-Mailer: git-send-email 2.8.4 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-16_06:2019-10-16,2019-10-16 signatures=0 Subject: [dpdk-dev] [PATCH v1 1/1] bus/vdev: add get iommu class callback 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" From: Vamsi Attunuru When DPDK application is run with vdevs, EAL decides the iommu mode and accordingly application runs in either of the modes. For KNI kind of functionality with vdevs, since there is no backed device structure in kernel, iommu_mode = PA needs to be enforced during eal init. Patch adds get_iommu_class callback in vdev bus driver and returns iommu mode as PA when vdevs are used for kni functionality, callback returns iommu mode as DC in normal cases. Signed-off-by: Vamsi Attunuru --- Below support fixes the following patchset(add iova=va mode support in KNI) which is currently failing to create KNI devices when vdevs are passed. http://patches.dpdk.org/patch/57720/ drivers/bus/vdev/vdev.c | 15 +++++++++++++++ lib/librte_eal/common/eal_private.h | 14 -------------- lib/librte_eal/common/include/rte_eal.h | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index a89ea23..ab07738 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -546,6 +546,20 @@ vdev_unplug(struct rte_device *dev) return rte_vdev_uninit(dev->name); } +static enum rte_iova_mode +rte_vdev_get_iommu_class(void) +{ + struct rte_devargs *devargs = NULL; + + if (rte_eal_check_module("rte_kni") == 1) { + RTE_EAL_DEVARGS_FOREACH("vdev", devargs) { + return RTE_IOVA_PA; + } + } + + return RTE_IOVA_DC; +} + static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, @@ -554,6 +568,7 @@ static struct rte_bus rte_vdev_bus = { .unplug = vdev_unplug, .parse = vdev_parse, .dev_iterate = rte_vdev_dev_iterate, + .get_iommu_class = rte_vdev_get_iommu_class, }; RTE_REGISTER_BUS(vdev, rte_vdev_bus); diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 798ede5..4207bdb 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -133,20 +133,6 @@ int rte_eal_intr_init(void); int rte_eal_alarm_init(void); /** - * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, - * etc.) loaded. - * - * @param module_name - * The module's name which need to be checked - * - * @return - * -1 means some error happens(NULL pointer or open failure) - * 0 means the module not loaded - * 1 means the module loaded - */ -int rte_eal_check_module(const char *module_name); - -/** * Get virtual area of specified size from the OS. * * This function is private to the EAL. diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index b7cf912..4ea98e6 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -531,6 +531,20 @@ rte_eal_mbuf_user_pool_ops(void); const char * rte_eal_get_runtime_dir(void); +/** + * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, + * etc.) loaded. + * + * @param module_name + * The module's name which need to be checked + * + * @return + * -1 means some error happens(NULL pointer or open failure) + * 0 means the module not loaded + * 1 means the module loaded + */ +int rte_eal_check_module(const char *module_name); + #ifdef __cplusplus } #endif