[PATCH i-g-t 1/4] lib/igt_sriov_device: Add helper to iterate over enabled VFs

Piotr Piórkowski piotr.piorkowski at intel.com
Mon Jul 21 10:05:27 UTC 2025


Lukasz Laguna <lukasz.laguna at intel.com> wrote on czw [2025-lip-17 11:08:09 +0200]:
> Helper allows to iterate over enabled VFs.
> 
> Signed-off-by: Lukasz Laguna <lukasz.laguna at intel.com>
> ---
>  lib/igt_sriov_device.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h
> index 912449086..930e97982 100644
> --- a/lib/igt_sriov_device.h
> +++ b/lib/igt_sriov_device.h
> @@ -87,6 +87,18 @@ igt_sriov_random_vf_in_range(int pf_fd, unsigned int start, unsigned int end)
>  	     ++__vf_num)
>  #define for_each_sriov_num_vfs for_each_sriov_vf
>  
> +/**
> + * for_each_sriov_enabled_vf - Helper for running code on each enabled VF
> + * @__pf_fd: PF device file descriptor
> + * @__vf_num: VFs iterator
> + *
> + * For loop that iterates over all enabled VFs associated with given PF @__pf_fd.
> + */
> +#define for_each_sriov_enabled_vf(__pf_fd, __vf_num) \
> +	for (unsigned int __vf_num = 1, __enabled_vfs = igt_sriov_get_enabled_vfs(__pf_fd); \
> +	     __vf_num <= __enabled_vfs; \
> +	     ++__vf_num)
> +
>  /**
>   * for_each_sriov_vf_in_range - Iterate over VFs in a specified range
>   * @__pf_fd: PF device file descriptor


LGTM:
Reviewed-by: Piotr Piórkowski <piotr.piorkowski at intel.com>
> -- 
> 2.40.0
> 

-- 


More information about the igt-dev mailing list