DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "BillXiang" <xiangwencheng@dayudpu.com>
Cc: "Tyler Retzlaff" <roretzla@linux.microsoft.com>,
	"Anatoly Burakov" <anatoly.burakov@intel.com>, <dev@dpdk.org>
Subject: Re: [PATCH v3] vfio: combine container_create and group_bind
Date: Thu, 10 Oct 2024 11:21:02 -0700	[thread overview]
Message-ID: <20241010112102.29242cd8@hermes.local> (raw)
In-Reply-To: <20240703115943.44539-1-xiangwencheng@dayudpu.com>

On Wed,  3 Jul 2024 19:59:43 +0800
"BillXiang" <xiangwencheng@dayudpu.com> wrote:

> From: BillXiang <xiangwencheng@dayudpu.com>
> 
> For multi-devices in one group we can only create and bind to one
> container. With this new function, device driver does not need to
> save the binding info additionally between different devices.
> 
> Signed-off-by: BillXiang <xiangwencheng@dayudpu.com>

Ok, but where is the device driver using it?
DPDK upstream doesn't want to keep API's for drivers that are not upstream.

> ---
>  lib/eal/include/rte_vfio.h | 17 +++++++++++++++++
>  lib/eal/linux/eal_vfio.c   | 24 ++++++++++++++++++++++++
>  lib/eal/version.map        |  3 +++
>  3 files changed, 44 insertions(+)
> 
> diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h
> index b774625d9f..f6743b3620 100644
> --- a/lib/eal/include/rte_vfio.h
> +++ b/lib/eal/include/rte_vfio.h
> @@ -407,6 +407,23 @@ int
>  rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr,
>  		uint64_t iova, uint64_t len);
>  
> +/**
> + * Get vfio group fd bound with container fd for certain iommu group.
> + *
> + * @param iommu_group_num
> + *   iommu group num
> + * @param vfio_group_fd
> + *   vfio group fd of the iommu group.
> + * @param vfio_container_fd
> + *   vfio container fd of the iommu group.
> + * @return
> + *    0 if successful
> + *   <0 if failed
> + */
> +__rte_experimental
> +int
> +rte_vfio_get_fd(int iommu_group_num, int *vfio_group_fd, int *vfio_container_fd);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c
> index 4e69e72e3b..08510df7e2 100644
> --- a/lib/eal/linux/eal_vfio.c
> +++ b/lib/eal/linux/eal_vfio.c
> @@ -2196,3 +2196,27 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova,
>  
>  	return container_dma_unmap(vfio_cfg, vaddr, iova, len);
>  }
> +
> +int
> +rte_vfio_get_fd(int iommu_group_num, int *vfio_group_fd, int *vfio_container_fd)
> +{
> +	struct vfio_config *vfio_cfg;
> +	vfio_cfg = get_vfio_cfg_by_group_num(iommu_group_num);
> +	/* do not create new container if the group has bound with one */

prefer blank line after declaration

> +	if (vfio_cfg) {
> +		*vfio_container_fd = vfio_cfg->vfio_container_fd;
> +	} else {
> +		*vfio_container_fd = rte_vfio_container_create();
> +		if (*vfio_container_fd < 0)
> +			goto err;

If no unwind necessary, then skip the goto and just return -1;

> +
> +		vfio_cfg = get_vfio_cfg_by_container_fd(*vfio_container_fd);
> +	}
> +	*vfio_group_fd = vfio_get_group_fd(vfio_cfg, iommu_group_num);
> +	if (*vfio_group_fd < 0)
> +		goto err;

ditto

> +
> +	return 0;
> +err:
> +	return -1;
> +}



> diff --git a/lib/eal/version.map b/lib/eal/version.map
> index 3df50c3fbb..f26b65a504 100644
> --- a/lib/eal/version.map
> +++ b/lib/eal/version.map
> @@ -396,6 +396,9 @@ EXPERIMENTAL {
>  
>  	# added in 24.03
>  	rte_vfio_get_device_info; # WINDOWS_NO_EXPORT
> +
> +	# added in 24.07
> +	rte_vfio_get_fd; # WINDOWS_NO_EXPORT
>  };
>  
>  INTERNAL {


      parent reply	other threads:[~2024-10-10 18:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 11:59 BillXiang
2024-07-09  8:49 ` David Marchand
2024-07-10  7:09   ` BillXiang
2024-10-10 18:21 ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241010112102.29242cd8@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.com \
    --cc=xiangwencheng@dayudpu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).