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 596E242DD3; Tue, 4 Jul 2023 13:22:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF4CA40E03; Tue, 4 Jul 2023 13:22:25 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2060.outbound.protection.outlook.com [40.107.96.60]) by mails.dpdk.org (Postfix) with ESMTP id A904040042 for ; Tue, 4 Jul 2023 13:22:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ze6zWk9p5bD7lxmMl1m+a7RzhaQ0xd4EzNSOtBSLjCQZpJjMvzfXOZzq2t7K0I3NI/e9wi7cmAv7gE3afGR8mCXhKhAURtyJDKvWhDG7qVmKtPx4qdVJs1dPM5OArcj99n0Xs0pgCibjogu2vyY/IS4UGao0j33CqCLJZirbmmla331YngKAtQuxWPhY05N7u4u9G5LxyawW4RFSY57CJKSuzqXxScJjFAqSg0Z2+OQjlOiV8pBryWffFO/xglZ9+nkcm0hyaNtKM+ffETwl8mY528lSyeYLO2gekcSiXXN/7m9Td/UqjaM6zo/qhil/A6WlDNK7gcfy5hLfFDtPKA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ecx5uEecfrPRgBe+WMOrcnScTs0LwA+A+W1U6DmOrq4=; b=YFqEA4thYeM5zhkajL4Gdz9/9zNyootvSCYEDCGiVmB5tgf3jXAp8oJMw2Wx/HQ2/+CFSYCCD8QxdDd7KXE82Pd7xq4RzwbKa8iZqv7y5ZLMs3YhSojm3Q9F9DinipenKgzeNqXOp8XzmO8CvW+Be0ssCscEsyy7vjjI75GllpSJAJew0r1PibBdArHbFBbhbMlk1qZqDiWYUXa1zJEaWpCtVKQgvui4nS0Hy3gXG3vuNdk0ArK9rykU+mycEqX/+gc1K/1sjqv/nVqgKwzYY2kxM/FAxCotSAuctyvP38+UkYk2Sg+CFztlKgI9Y5xnYLwK1bsZuZlI11u9iML5Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ecx5uEecfrPRgBe+WMOrcnScTs0LwA+A+W1U6DmOrq4=; b=tzqMj12XnDKDjjzSYs1/yqdu6kkiVan1iK9LBOQOGJ2odS/tMW7rRVbQxMVIjyzeSCvx6omfT1RwaWI3uXHnwIA+xaWrFgnYfk+5guEKMB5PPb2iU/QKCBhxsFjC8sodKckr1H8nlhkw0Y0shkRgJaBcG624d+XWwu/FtdxAzVY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH3PR12MB8308.namprd12.prod.outlook.com (2603:10b6:610:131::8) by MW4PR12MB7120.namprd12.prod.outlook.com (2603:10b6:303:222::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Tue, 4 Jul 2023 11:22:21 +0000 Received: from CH3PR12MB8308.namprd12.prod.outlook.com ([fe80::e452:1914:1054:de79]) by CH3PR12MB8308.namprd12.prod.outlook.com ([fe80::e452:1914:1054:de79%7]) with mapi id 15.20.6565.016; Tue, 4 Jul 2023 11:22:21 +0000 Message-ID: <47ecd16b-b74e-a9f5-12ab-270b92e04a62@amd.com> Date: Tue, 4 Jul 2023 16:52:08 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] bus/cdx: provide driver flag for optional resource mapping Content-Language: en-US To: Abhijit Gangurde , nikhil.agarwal@amd.com Cc: dev@dpdk.org, david.marchand@redhat.com, ferruh.yigit@amd.com References: <20230626103958.3139-1-abhijit.gangurde@amd.com> From: "Gupta, Nipun" In-Reply-To: <20230626103958.3139-1-abhijit.gangurde@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN3PR01CA0076.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:9a::11) To CH3PR12MB8308.namprd12.prod.outlook.com (2603:10b6:610:131::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8308:EE_|MW4PR12MB7120:EE_ X-MS-Office365-Filtering-Correlation-Id: 71308281-759f-4605-f002-08db7c80eedd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yfsTrs3Xbq+R46z7aULnU7nOXnX8tgb1NshxZ+DZ+IIYubH34YJkK7Uo8jjetwiYAtPidK3LBjU8b9r5D9jK1tZU5fHhCEQUMWXjPpERq1zjywCQgL0TEZwYM16XPjKJivlUNifqLf7l0mtcXgpTaSNWfHBwbBSbtwj9uQ6YiKtkx8emYM2Clc8dH0ZE1LmaVkKJ3WhwUwPAx0hBbLBnBhKP/iebCan9fP0INBPMqFcANuBiLBMgNMs24DdiG9W035MGZwpF/A0LlIR37a7XJa5sI6W+MgPBFgyXo4phrf2iXoKi92tkMLwnwI4LxW3IZTHkVPhcAqjugTBIoebh2Z2ufua4i/Yiu1ZvxXGlQVDezw2s5IRoMHvw+Q3/7YcWksm/JSb034NxJxbiinhbaR4TMoHYkjW4R6zpG2K5DuM5Lbivdm6HWvAAjjXGnyXv6/D8avSikfs/d46Y3V1dvllMHlg93+pR2CiAXMB/qj+z73dlnbbF1Sdn6z9NsiWV8cjtyOV6pV/eoO74LGIZBVesVN8Nop75pTXYHxzcFL+XtaVRpuC/HSMHhA9mZ+w4jLdUvI5+WOYRvc428VlBWlm73xjDUKjg43ypyTcqc/jQXRk2WrtdNV+Z6ca0Vp1KRfqnJeM3RgpMlb+ToJ7tHw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR12MB8308.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(346002)(396003)(136003)(366004)(451199021)(31696002)(41300700001)(86362001)(38100700002)(6486002)(6666004)(2616005)(83380400001)(186003)(6506007)(53546011)(26005)(6512007)(2906002)(478600001)(36756003)(316002)(66476007)(4326008)(66556008)(66946007)(6636002)(8936002)(8676002)(31686004)(5660300002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U0JKMzV3amVBNzBkdjFKVGxWTFM2dWxHQU9oMXVmKzJnRmR6dUx1QU9ZOCtZ?= =?utf-8?B?WVJTUUUwWmk5T0tndzJjZW9pSEJJNjYyWU5aNkY2NU50TGZLaXRJbVRZT2lP?= =?utf-8?B?d2MxYnpURVpGTVJFdDREVVcwMk80SEE1RTdtQ0c4T3BLTDVUT2lEOTZMUDF0?= =?utf-8?B?WFR1QXlPaDJ3cnBwNFpJcWpBZGxoRUFZRHJySWtvVnYwUkpPano2a1d1RW9J?= =?utf-8?B?aUZUZ0NsVC9nYkZxZGFZMVlnUFArc1UxNjJrV0NNd2dqMTZ2cGE2YjdRM3ZV?= =?utf-8?B?VjJMUmZsYTB1dE5lRVUrc05kTFoyM05zQ0ZqQ0puS2VEYmlDbkNRMzZIUUZB?= =?utf-8?B?UU9sano4TVVs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OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71308281-759f-4605-f002-08db7c80eedd X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8308.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2023 11:22:21.1606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yMKSuKMohIfvBQQm4LxmKYbrg8ZtJRlK3cl/yR1G4nKpsPrO2lhpVO4pDChgNafj X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7120 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 On 6/26/2023 4:09 PM, Abhijit Gangurde wrote: > Provide driver flag which gives an option to map the cdx > device resource before probing the device driver. > Also, make rte_cdx_map_device() API as public to map > device resource separately. > > Signed-off-by: Abhijit Gangurde > --- > drivers/bus/cdx/bus_cdx_driver.h | 26 ++--------------- > drivers/bus/cdx/cdx.c | 11 ++++--- > drivers/bus/cdx/rte_bus_cdx.h | 50 ++++++++++++++++++++++++++++++++ > drivers/bus/cdx/version.map | 11 +++++-- > 4 files changed, 69 insertions(+), 29 deletions(-) > create mode 100644 drivers/bus/cdx/rte_bus_cdx.h > > diff --git a/drivers/bus/cdx/bus_cdx_driver.h b/drivers/bus/cdx/bus_cdx_driver.h > index fcacdb5896..1571131417 100644 > --- a/drivers/bus/cdx/bus_cdx_driver.h > +++ b/drivers/bus/cdx/bus_cdx_driver.h > @@ -37,6 +37,9 @@ struct rte_cdx_bus; > static const char DRV_EXP_TAG(name, cdx_tbl_export)[] __rte_used = \ > RTE_STR(table) > > +/** Device needs resource mapping */ > +#define RTE_CDX_DRV_NEED_MAPPING 0x0001 > + > /** > * A structure describing an ID for a CDX driver. Each driver provides a > * table of these IDs for each device that it supports. > @@ -107,29 +110,6 @@ struct rte_cdx_driver { > uint32_t drv_flags; /**< Flags RTE_CDX_DRV_*. */ > }; > > -/** > - * Map the CDX device resources in user space virtual memory address. > - * > - * @param dev > - * A pointer to a rte_cdx_device structure describing the device > - * to use. > - * > - * @return > - * 0 on success, <0 on error. > - */ > -__rte_internal > -int rte_cdx_map_device(struct rte_cdx_device *dev); > - > -/** > - * Unmap this device. > - * > - * @param dev > - * A pointer to a rte_cdx_device structure describing the device > - * to use. > - */ > -__rte_internal > -void rte_cdx_unmap_device(struct rte_cdx_device *dev); > - > /** > * Register a CDX driver. > * > diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c > index 28bbf92ed5..47dc4eabe7 100644 > --- a/drivers/bus/cdx/cdx.c > +++ b/drivers/bus/cdx/cdx.c > @@ -74,6 +74,7 @@ > #include > #include > #include > +#include > > #include > > @@ -380,10 +381,12 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr, > CDX_BUS_DEBUG(" probe device %s using driver: %s", dev_name, > dr->driver.name); > > - ret = cdx_vfio_map_resource(dev); > - if (ret != 0) { > - CDX_BUS_ERR("CDX map device failed: %d", ret); > - goto error_map_device; > + if (dr->drv_flags & RTE_CDX_DRV_NEED_MAPPING) { > + ret = cdx_vfio_map_resource(dev); > + if (ret != 0) { > + CDX_BUS_ERR("CDX map device failed: %d", ret); > + goto error_map_device; > + } > } > > /* call the driver probe() function */ > diff --git a/drivers/bus/cdx/rte_bus_cdx.h b/drivers/bus/cdx/rte_bus_cdx.h > new file mode 100644 > index 0000000000..b9280b5f7f > --- /dev/null > +++ b/drivers/bus/cdx/rte_bus_cdx.h > @@ -0,0 +1,50 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright (C) 2023, Advanced Micro Devices, Inc. > + */ > + > +#ifndef _RTE_BUS_CDX_H_ > +#define _RTE_BUS_CDX_H_ nit: there are no underscores before or after in other cdx header files. please change to RTE_BUS_CDX_H > + > +/** > + * @file > + * CDX device & driver interface > + */ > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +/* Forward declarations */ > +struct rte_cdx_device; > + > +/** > + * Map the CDX device resources in user space virtual memory address nit: all doxygen comments should end with a dot. > + * > + * Note that driver should not call this function when flag > + * RTE_CDX_DRV_NEED_MAPPING is set, as EAL will do that for > + * you when it's on. > + * > + * @param dev > + * A pointer to a rte_cdx_device structure describing the device > + * to use > + * > + * @return > + * 0 on success, negative on error and positive if no driver > + * is found for the device. > + */ > +int rte_cdx_map_device(struct rte_cdx_device *dev); > + > +/** > + * Unmap this device > + * > + * @param dev > + * A pointer to a rte_cdx_device structure describing the device > + * to use > + */ > +void rte_cdx_unmap_device(struct rte_cdx_device *dev); > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* _RTE_BUS_CDX_H_ */ > diff --git a/drivers/bus/cdx/version.map b/drivers/bus/cdx/version.map > index 0a15d39ae8..cc7b1f821b 100644 > --- a/drivers/bus/cdx/version.map > +++ b/drivers/bus/cdx/version.map > @@ -1,9 +1,16 @@ > -INTERNAL { > +DPDK_23 { > global: > > rte_cdx_map_device; > - rte_cdx_register; > rte_cdx_unmap_device; > + > + local: *; > +}; > + > +INTERNAL { > + global: > + > + rte_cdx_register; > rte_cdx_unregister; > rte_cdx_vfio_intr_disable; > rte_cdx_vfio_intr_enable;