From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9712542672;
	Fri, 29 Sep 2023 17:17:35 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 85FD7402B1;
	Fri, 29 Sep 2023 17:17:35 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id 357944026E
 for <dev@dpdk.org>; Fri, 29 Sep 2023 17:17:34 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1696000653;
 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=kjrfs1ctN+NVyTYFy8HExjAedPb4RrFAaf3OzRphM2M=;
 b=L5NQx9YtvcilMZfP9CJJ1qp+9FqPwoxpJcnKJ3ucBcJuWrcxnbLKTZEeyYNipGuXKh4IX4
 dTEpAgqKsrPkWGcLCTC5ZZWcFRnts41Q48ZXnbnfFMM1YXA7CZAE//QqHN6ybom/Rda0Oe
 jGr3cq6eYLjWEoxo/X6/mmTZeQSpXLY=
Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com
 [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id
 us-mta-636-rNgi3oFNMwao3jMb2AsFqw-1; Fri, 29 Sep 2023 11:17:32 -0400
X-MC-Unique: rNgi3oFNMwao3jMb2AsFqw-1
Received: by mail-lf1-f70.google.com with SMTP id
 2adb3069b0e04-50338ca1663so20565315e87.0
 for <dev@dpdk.org>; Fri, 29 Sep 2023 08:17:31 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1696000650; x=1696605450;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=kjrfs1ctN+NVyTYFy8HExjAedPb4RrFAaf3OzRphM2M=;
 b=pnNj79YzaU84jDixfHlFS0WpUiaE09PJ7Ek7VhKtSnO2yUkeDoK6LJ62PQg9rhPYZm
 +L0Z5fAFqIGcKvVqt+rfjg+BGZmIyBKhdtpT5xzMaQBgcCCRflwtUqzeFdx8cRdIMsu/
 EQA4Sb7J9Ubxso04Vf5G69OheaMglRbGcqg3FkshdS2iGqvtibSEKCmvjygzafwdiGUM
 Ld92VgWFk0c8wtcOXcLf4ktBlFFXEU4J0r5pcFjDogkjfCFnwxvqKqYz7/tQGb4EOV+s
 J2qgWRzJFfp8BthvKCxWOFwmyKJPxqudkpx4md0Ar794fBeRscGIRYwUZAh7VBrf8V0J
 hiCA==
X-Gm-Message-State: AOJu0YwN8O+kjB4fIlrP6/nJZKAfnpr3LL6BsYSE9fDoGpVLjl0i1UST
 hVg9LvqUDt35r7nwvXGK1QEpYQCk+zXP56nGYnLkL4jgtLC2LS9qf6h7IXjVJlfh6xHc/XXBfQ2
 0+RzoQZBWoJ/zSb33FUQ3MiBDsig=
X-Received: by 2002:a05:6512:3610:b0:503:182e:1def with SMTP id
 f16-20020a056512361000b00503182e1defmr3145612lfs.69.1696000650546; 
 Fri, 29 Sep 2023 08:17:30 -0700 (PDT)
X-Google-Smtp-Source: AGHT+IFqcXee934mcVeISU1UhH3G10Ojzlc6ZvPASyVUr9NlYDnYpsiBZnHYPkljN3x100i5C1xx/fhv95xuWGnD2kY=
X-Received: by 2002:a05:6512:3610:b0:503:182e:1def with SMTP id
 f16-20020a056512361000b00503182e1defmr3145598lfs.69.1696000650212; Fri, 29
 Sep 2023 08:17:30 -0700 (PDT)
MIME-Version: 1.0
References: <20230705065235.4767-1-abhijit.gangurde@amd.com>
 <20230711055147.872889-1-abhijit.gangurde@amd.com>
In-Reply-To: <20230711055147.872889-1-abhijit.gangurde@amd.com>
From: David Marchand <david.marchand@redhat.com>
Date: Fri, 29 Sep 2023 17:17:18 +0200
Message-ID: <CAJFAV8xBJFp7Qsw1GO9J78rU4v+6DVWyAdykYJBxvyCks2EwgA@mail.gmail.com>
Subject: Re: [PATCH v3] bus/cdx: provide driver flag for optional resource
 mapping
To: Abhijit Gangurde <abhijit.gangurde@amd.com>
Cc: Nipun.Gupta@amd.com, nikhil.agarwal@amd.com, dev@dpdk.org, 
 Ferruh.Yigit@amd.com, thomas@monjalon.net
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Tue, Jul 11, 2023 at 7:52=E2=80=AFAM Abhijit Gangurde
<abhijit.gangurde@amd.com> wrote:
> @@ -383,10 +384,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 =3D cdx_vfio_map_resource(dev);
> -       if (ret !=3D 0) {
> -               CDX_BUS_ERR("CDX map device failed: %d", ret);
> -               goto error_map_device;
> +       if (dr->drv_flags & RTE_CDX_DRV_NEED_MAPPING) {
> +               ret =3D cdx_vfio_map_resource(dev);
> +               if (ret !=3D 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..4ca12f90c4
> --- /dev/null
> +++ b/drivers/bus/cdx/rte_bus_cdx.h
> @@ -0,0 +1,52 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright (C) 2023, Advanced Micro Devices, Inc.
> + */
> +
> +#ifndef RTE_BUS_CDX_H
> +#define 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.
> + *
> + * 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.

Why should we export this function in the application ABI, if it is
only used by drivers?


> + *
> + * @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.
> + */
> +__rte_experimental
> +int rte_cdx_map_device(struct rte_cdx_device *dev);
>


--=20
David Marchand