[PATCH i-g-t v1 2/4] lib/xe/xe_sriov_provisioning: Add helper to get VF's provisioned quota

K V P, Satyanarayana satyanarayana.k.v.p at intel.com
Mon Jan 27 07:46:09 UTC 2025


> From: Laguna, Lukasz <lukasz.laguna at intel.com>
> Sent: Friday, January 24, 2025 1:41 PM
> To: igt-dev at lists.freedesktop.org
> Cc: marcin.bernatowicz at linux.intel.com; Laguna, Lukasz
> <lukasz.laguna at intel.com>; K V P, Satyanarayana
> <satyanarayana.k.v.p at intel.com>; Wajdeczko, Michal
> <Michal.Wajdeczko at intel.com>; adam.miszczak at linux.intel.com; Kolakowski,
> Jakub1 <jakub1.kolakowski at intel.com>
> Subject: [PATCH i-g-t v1 2/4] lib/xe/xe_sriov_provisioning: Add helper to get
> VF's provisioned quota
> 
> Add helper allowing to get VF's provisioned quota based on provisioned
> ranges exposed in debugfs.
> 
> Signed-off-by: Lukasz Laguna <lukasz.laguna at intel.com>
> ---
Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p at intel.com>
>  lib/xe/xe_sriov_provisioning.c | 56
> ++++++++++++++++++++++++++++++++++
>  lib/xe/xe_sriov_provisioning.h |  6 ++++
>  2 files changed, 62 insertions(+)
> 
> diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
> index 5ba348131..aedf9bd91 100644
> --- a/lib/xe/xe_sriov_provisioning.c
> +++ b/lib/xe/xe_sriov_provisioning.c
> @@ -8,6 +8,7 @@
> 
>  #include "igt_core.h"
>  #include "igt_debugfs.h"
> +#include "igt_sriov_device.h"
>  #include "intel_chipset.h"
>  #include "linux_scaffold.h"
>  #include "xe/xe_mmio.h"
> @@ -299,6 +300,61 @@ bool xe_sriov_is_shared_res_provisionable(int pf,
> enum xe_sriov_shared_res res,
>  	return true;
>  }
> 
> +/**
> + * __xe_sriov_pf_get_provisioned_quota - Get VF's provisioned quota.
> + * @pf: PF device file descriptor
> + * @res: Shared resource type (see enum xe_sriov_shared_res)
> + * @vf_num: VF number (1-based)
> + * @gt_num: GT number
> + * @value: Pointer to store the read value
> + *
> + * Gets VF's provisioning value for the specified shared resource @res,
> + * VF number @vf_num and GT number @gt_num.
> + *
> + * Return: 0 on success, negative error code on failure.
> + */
> +int __xe_sriov_pf_get_provisioned_quota(int pf, enum xe_sriov_shared_res
> res,
> +					unsigned int vf_num, unsigned int
> gt_num,
> +					uint64_t *value)
> +{
> +	struct xe_sriov_provisioned_range *ranges;
> +	int ret;
> +
> +	ret = xe_sriov_pf_debugfs_read_check_ranges(pf, res, gt_num,
> &ranges,
> +
> igt_sriov_get_enabled_vfs(pf));
> +	if (igt_debug_on_f(ret, "%s: Failed ranges check on GT%u (%d)\n",
> +			   xe_sriov_debugfs_provisioned_attr_name(res),
> gt_num, ret))
> +		return ret;
> +
> +	*value = ranges[vf_num - 1].end - ranges[vf_num - 1].start + 1;
> +
> +	return 0;
> +}
> +
> +/**
> + * xe_sriov_pf_get_provisioned_quota - Get VF's provisioned quota.
> + * @pf: PF device file descriptor
> + * @res: Shared resource type (see enum xe_sriov_shared_res)
> + * @vf_num: VF number (1-based)
> + * @gt_num: GT number
> + *
> + * A throwing version of __xe_sriov_pf_get_provisioned_quota().
> + * Instead of returning an error code, it returns the quota value and asserts
> + * in case of an error.
> + *
> + * Return: The provisioned quota for the given shared resource.
> + *         Asserts in case of failure.
> + */
> +uint64_t xe_sriov_pf_get_provisioned_quota(int pf, enum
> xe_sriov_shared_res res,
> +					   unsigned int vf_num, unsigned int
> gt_num)
> +{
> +	uint64_t value;
> +
> +	igt_fail_on(__xe_sriov_pf_get_provisioned_quota(pf, res, vf_num,
> gt_num, &value));
> +
> +	return value;
> +}
> +
>  /**
>   * __xe_sriov_vf_get_shared_res_selfconfig - Read VF's configuration data.
>   * @vf: VF device file descriptor
> diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
> index 1a05c2c59..0381b564c 100644
> --- a/lib/xe/xe_sriov_provisioning.h
> +++ b/lib/xe/xe_sriov_provisioning.h
> @@ -90,6 +90,12 @@ void xe_sriov_pf_set_shared_res_attr(int pf, enum
> xe_sriov_shared_res res,
>  				     unsigned int vf_num, unsigned int gt_num,
>  				     uint64_t value);
> 
> +int __xe_sriov_pf_get_provisioned_quota(int pf, enum xe_sriov_shared_res
> res,
> +					unsigned int vf_num, unsigned int
> gt_num,
> +					uint64_t *value);
> +uint64_t xe_sriov_pf_get_provisioned_quota(int pf, enum
> xe_sriov_shared_res res,
> +					   unsigned int vf_num, unsigned int
> gt_num);
> +
>  int __xe_sriov_vf_get_shared_res_selfconfig(int vf, enum xe_sriov_shared_res
> res,
>  					    unsigned int gt_num, uint64_t
> *value);
>  uint64_t xe_sriov_vf_get_shared_res_selfconfig(int vf, enum
> xe_sriov_shared_res res,
> --
> 2.40.0



More information about the igt-dev mailing list