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 111D4A04DB; Thu, 15 Oct 2020 11:54:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 934FA1DCD4; Thu, 15 Oct 2020 11:54:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 8A54E1C2DE for ; Thu, 15 Oct 2020 11:54:17 +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 09F9nYkO002740; Thu, 15 Oct 2020 02:54:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=pfpt0220; bh=XbucEjRDlchSEJdFebEELTWJozdMtPzQz0zUbAGvcWk=; b=BYsUD+326dzr8ExdW2B7RUI8FQ/kmlOX7jCVEom4+My282HHAA5PJMuUD7CcIcK2pAbu iLNCZAlREPPvvqBTk/9NTclf5ceA4Ddz1UABGkaEF4BiIkDrST/4ho/dMgmRKf/dEV7v czlFT0EEczXC1wp1VTO7EEhNKf/lba0CKoXJFGjyBbhr/q3QxRyxFWb3ehWfS2OnnyHB 9RZ8xQlA2m6ahPgiPy47P844DbIB/2EWkII0ml08VdMmd+oIMezCnHFPxjunbJtKDMNj WgJUeWbCG3tcRL97rufnCp5fIYKie3YHGEJkBTVmSmJHfjfcRvcZMsV674DIl0T77r25 pg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 343aanu68g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 15 Oct 2020 02:54:16 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Oct 2020 02:54:15 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.168) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 15 Oct 2020 02:54:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSxvC4LfuTMIc74m2lkl+YITiTyKW8Xzxg+bq6c67BVeVFJEP/SC2bCE7vdMEspAy0z9vjaN/xWEqNN/f50fyIjA91r3RfwCuIva2yWpoEaVS3FfROheBe+wr+eJNqjAeDNdlG4sgoRgh7rZtC08FVvCFhSYGIeHD5Sxt+1uv7p0nywGB8LQ7GWyNG5837LIlwF/dd2s3hDwyAjiE9A2Cj5g75QlA4XCtC8v1VWgyh+0FXI1ahr+50zp36dGmaBwhK6ZXHilKcAK5teNYR0tYfxE32+coPIdYV4aRn4rEAulHPDgipx6RdRNsmzhHKx/EQ6GNyx65/QRYROZszyFcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XbucEjRDlchSEJdFebEELTWJozdMtPzQz0zUbAGvcWk=; b=U+xW+9kcOJBl3N/QYjkIqAAxnhArh9sbaKlGcrD1ADdGDJ52fmBzy65+P/PP3LxrEuZWPKCJ5Qkk0IDFWFqjDxF0YWUD0qDnO95i22H3RjAoH/Vl/8tpu26PYIubQo1kjwloAuD+KjwCsNbbZXGEVnutzJ4BGdZzezoQgmFhFRIp7mq8OdKmsdFs8sh8XqDW4jfZ7cC67U1OzFX+SGKJYGyXEbO/POjvGMxhSZjY86KxEOEIdIwt+QflLlxQ6Q4TrP2sdSkLtDg9PtYRu4eq9vYkCiQZ32iePuan8GfiQ+Rz1/FGfUkYCU2VNeAmcK5iaUNJbqjmdmztQBxHUMTXQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XbucEjRDlchSEJdFebEELTWJozdMtPzQz0zUbAGvcWk=; b=rr+WQsScev7bg8E43zV2bsTKRiBy8FnEKeBPo4WOgmmm8Iz51WhLknZnNlWhfBlnmywARSTYVt/7uN/6tIMflZyeIMy6CeAZL46D0Xltq2FkJW7wNbnR08DA1BH/ooQBZjXupgoctc/+lx2J5YQPh3OgbCoF/M9RkHmqw1HcTkU= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=marvell.com; Received: from BN8PR18MB2386.namprd18.prod.outlook.com (2603:10b6:408:68::25) by BN6PR1801MB2066.namprd18.prod.outlook.com (2603:10b6:405:64::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.29; Thu, 15 Oct 2020 09:54:12 +0000 Received: from BN8PR18MB2386.namprd18.prod.outlook.com ([fe80::25af:7baf:528d:1dab]) by BN8PR18MB2386.namprd18.prod.outlook.com ([fe80::25af:7baf:528d:1dab%5]) with mapi id 15.20.3455.035; Thu, 15 Oct 2020 09:54:12 +0000 Date: Thu, 15 Oct 2020 15:24:00 +0530 From: Nithin Dabilpuram To: "Burakov, Anatoly" CC: , Message-ID: <20201015095400.GB32207@outlook.office365.com> References: <20201012081106.10610-1-ndabilpuram@marvell.com> <20201012081106.10610-2-ndabilpuram@marvell.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (34cd43c) (2019-09-21) X-Originating-IP: [1.6.215.26] X-ClientProxiedBy: SG2PR02CA0012.apcprd02.prod.outlook.com (2603:1096:3:17::24) To BN8PR18MB2386.namprd18.prod.outlook.com (2603:10b6:408:68::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from outlook.office365.com (1.6.215.26) by SG2PR02CA0012.apcprd02.prod.outlook.com (2603:1096:3:17::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Thu, 15 Oct 2020 09:54:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2eda514-adaf-4467-c870-08d870f044b3 X-MS-TrafficTypeDiagnostic: BN6PR1801MB2066: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EmDkWsZEgr2Qfh4Puqik4S2jgSN/qrM5RVJSPt8wu7VRdgzDwviGf6X1JXlclcqnX2tt75vicPSPQUHDTeaVJijlEUMeKSpRTLK8LlGcNhG5/0+3NvGBsnWHCXY1riHQrlrzE+9DHFypBPLh953g/oCMzDdyT+k1PajlupDiH0F0QwEukfJGhNoLjba6Wf45c4A7ffTv+/kMAS6VC+yJDcw3EYubs5LMF666F0XRm9h+mmObMYxCERueQyE++iTfTMcVcApukaByTRYxCEpHo2UABZGI8V1aXTW+tByqGzkwSTue4XzjcDuaFlQRnvJo+TV2n4VVXyirEpcK3vgZFVvV6EW47yxCQhXVqXQ4DyX9H71xGCY7f9OjuzlkEmEPHtdJYOANJeHO4n+kyV/fKZHGdmIk+7aZK1MXvKgy36wBakBnfkAJFboSe2uQ6bWY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR18MB2386.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(346002)(396003)(39860400002)(376002)(9686003)(478600001)(16526019)(86362001)(4326008)(186003)(26005)(66476007)(34490700002)(66556008)(33656002)(66946007)(5660300002)(55016002)(8676002)(6916009)(8936002)(2906002)(1006002)(52116002)(53546011)(1076003)(956004)(6506007)(7696005)(316002)(6666004)(36456003)(42976004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rjqh8De6GlOWKGGC0oUs9+qJzGLed5CXaODEGGdCkMI60GYv38c/BH6uoHbKfmoGqJvdDgQBT4/pKutxi4aN6+xAvjZrs9emdSyT5vPg7VXp/mrJZHWyL460Fe0Ls4nqyrWR2tA4zMHnP+HQx29seD0M6jp/G/W/BC/aahF75McxRwM1GGwytBY5mQgf0CuxszvBmDt1IkI7nhSnoqqNBiz+HDy9GeBhMv5ZZEivnIvh1jL5SFIZwyVQWpQkOlugM54g9c/1PhrrkewhS+TTgl+xM8kYiIJBpgaNX0WrCcQE+43VUHgamWUIgHWvYHDEGueC09jPuZTOLh0Ydnqjbgsmkv72csi3sZIar5US8DD8EzH1RWrql6H3cP20sH48+kh+bxrxu8gwS381LmJB2xlg8FTHYqls1T4LbB9/cTYif1X06tn7YZYrqVJfVBjheC5vaEivSwqI76Yfa7VHHDyNMHfoWh1dBK5hYdEEDaerPcNmX6+oaAhqEkamcIq4Mrq3kQ9ES58v0XwP3uUR2jfTvVuZPNrEu4bBEWUlz+MAG4J/aURtxe4YXCmuZDVntiUt+bDf8dpWrZ/l3LWgObaqnl8egAUC/dHZHkCxJE07LV4KcMNcWjixrO3r+OVDkTL2+azF73LJYC/n1Alw4A== X-MS-Exchange-CrossTenant-Network-Message-Id: b2eda514-adaf-4467-c870-08d870f044b3 X-MS-Exchange-CrossTenant-AuthSource: BN8PR18MB2386.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 09:54:12.3068 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NFMgQhvC+nnQX6NCZvUzEaNstXUPrDpfpLyhwWjxEuFGciuVYzP2EI62mDep26Dud0Wy2XXRMJpQiO+aLst6jw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1801MB2066 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-10-15_03:2020-10-14, 2020-10-15 signatures=0 Subject: Re: [dpdk-dev] [EXT] Re: [PATCH 1/2] test: add test case to validate VFIO DMA map/unmap 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" On Wed, Oct 14, 2020 at 03:39:36PM +0100, Burakov, Anatoly wrote: > External Email > > ---------------------------------------------------------------------- > On 12-Oct-20 9:11 AM, Nithin Dabilpuram wrote: > > Add test case in test_memory to test VFIO DMA map/unmap. > > > > Signed-off-by: Nithin Dabilpuram > > --- > > app/test/test_memory.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 79 insertions(+) > > > > diff --git a/app/test/test_memory.c b/app/test/test_memory.c > > index 7d5ae99..1c56455 100644 > > --- a/app/test/test_memory.c > > +++ b/app/test/test_memory.c > > @@ -4,11 +4,16 @@ > > #include > > #include > > +#include > > +#include > > +#include > > #include > > +#include > > #include > > #include > > #include > > +#include > > #include "test.h" > > @@ -70,6 +75,71 @@ check_seg_fds(const struct rte_memseg_list *msl, const struct rte_memseg *ms, > > } > > static int > > +test_memory_vfio_dma_map(void) > > +{ > > + uint64_t sz = 2 * sysconf(_SC_PAGESIZE), sz1, sz2; > > i think we now have a function for that, rte_page_size() ? > > Also, i would prefer > > uint64_t sz1, sz2, sz = 2 * rte_page_size(); > > Easier to parse IMO. Ack, will use rte_mem_page_size(). > > > + uint64_t unmap1, unmap2; > > + uint8_t *mem; > > + int ret; > > + > > + /* Check if vfio is enabled in both kernel and eal */ > > + ret = rte_vfio_is_enabled("vfio"); > > + if (!ret) > > + return 1; > > No need, rte_vfio_container_dma_map() should set errno to ENODEV if vfio is > not enabled. Ack. > > > + > > + /* Allocate twice size of page */ > > + mem = mmap(NULL, sz, PROT_READ | PROT_WRITE, > > + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); > > + if (mem == MAP_FAILED) { > > + printf("Failed to allocate memory for external heap\n"); > > + return -1; > > + } > > + > > + /* Force page allocation */ > > + memset(mem, 0, sz); > > + > > + /* map the whole region */ > > + ret = rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD, > > + (uint64_t)mem, (rte_iova_t)mem, sz); > > should be (uintptr_t) perhaps? > > Also, this can return -1 with rte_errno == ENOTSUP, i think this happens if > there are no devices attached (or if there's no VFIO support, like it would > be on FreeBSD or Windows). Ok. Will return 1 if NOTSUP. > > > + if (ret) { > > + printf("Failed to dma map whole region, ret=%d\n", ret); > > + goto fail; > > + } > > + > > + unmap1 = (uint64_t)mem + (sz / 2); > > + sz1 = sz / 2; > > + unmap2 = (uint64_t)mem; > > + sz2 = sz / 2; > > + /* unmap the partial region */ > > + ret = rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD, > > + unmap1, (rte_iova_t)unmap1, sz1); > > + if (ret) { > > + if (rte_errno == ENOTSUP) { > > + printf("Partial dma unmap not supported\n"); > > + unmap2 = (uint64_t)mem; > > + sz2 = sz; > > + } else { > > + printf("Failed to unmap send half region, ret=%d(%d)\n", > > I think "send half" is a typo? Also, here and in other places, i would > prefer a rte_strerror() instead of raw rte_errno number. Ack. > > > + ret, rte_errno); > > + goto fail; > > + } > > + } > > + > > + /* unmap the remaining region */ > > + ret = rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD, > > + unmap2, (rte_iova_t)unmap2, sz2); > > + if (ret) { > > + printf("Failed to unmap remaining region, ret=%d(%d)\n", ret, > > + rte_errno); > > + goto fail; > > + } > > + > > +fail: > > + munmap(mem, sz); > > + return ret; > > +} > > + > > +static int > > test_memory(void) > > { > > uint64_t s; > > @@ -101,6 +171,15 @@ test_memory(void) > > return -1; > > } > > + /* test for vfio dma map/unmap */ > > + ret = test_memory_vfio_dma_map(); > > + if (ret == 1) { > > + printf("VFIO dma map/unmap unsupported\n"); > > + } else if (ret < 0) { > > + printf("Error vfio dma map/unmap, ret=%d\n", ret); > > + return -1; > > + } > > + > > This looks odd in this autotest. Perhaps create a new autotest for VFIO? Ack, will add test_vfio.c > > > return 0; > > } > > > > > -- > Thanks, > Anatoly