Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Laguna <lukasz.laguna@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: marcin.bernatowicz@linux.intel.com, lukasz.laguna@intel.com,
	satyanarayana.k.v.p@intel.com, michal.wajdeczko@intel.com,
	adam.miszczak@linux.intel.com, jakub1.kolakowski@intel.com
Subject: [PATCH i-g-t v2 2/4] lib/xe/xe_sriov_provisioning: Add helper to get VF's provisioned quota
Date: Fri,  7 Feb 2025 10:40:29 +0100	[thread overview]
Message-ID: <20250207094031.15942-3-lukasz.laguna@intel.com> (raw)
In-Reply-To: <20250207094031.15942-1-lukasz.laguna@intel.com>

Add helper allowing to get VF's provisioned quota based on provisioned
ranges exposed in debugfs.

v2:
 - release allocated struct (Marcin)

Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
Reviewed-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
---
 lib/xe/xe_sriov_provisioning.c | 59 ++++++++++++++++++++++++++++++++++
 lib/xe/xe_sriov_provisioning.h |  6 ++++
 2 files changed, 65 insertions(+)

diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
index 22035ffd8..f7d8c63d1 100644
--- a/lib/xe/xe_sriov_provisioning.c
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -6,6 +6,8 @@
 #include <errno.h>
 
 #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"
@@ -296,3 +298,60 @@ 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;
+
+	free(ranges);
+
+	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;
+}
diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
index b4300ec2e..171e4f028 100644
--- a/lib/xe/xe_sriov_provisioning.h
+++ b/lib/xe/xe_sriov_provisioning.h
@@ -90,4 +90,10 @@ 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);
+
 #endif /* __XE_SRIOV_PROVISIONING_H__ */
-- 
2.40.0


  parent reply	other threads:[~2025-02-07  9:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07  9:40 [PATCH i-g-t v2 0/4] Verify VF configuration data against provisioned values Lukasz Laguna
2025-02-07  9:40 ` [PATCH i-g-t v2 1/4] lib/xe/xe_sriov_debugfs: Add helper to read VF's configuration data Lukasz Laguna
2025-02-10 10:43   ` Bernatowicz, Marcin
2025-02-10 10:57     ` Bernatowicz, Marcin
2025-02-07  9:40 ` Lukasz Laguna [this message]
2025-02-07  9:40 ` [PATCH i-g-t v2 3/4] lib/igt_sriov_device: Add helper to iterate over VFs in specified range Lukasz Laguna
2025-02-11 11:23   ` Bernatowicz, Marcin
2025-02-07  9:40 ` [PATCH i-g-t v2 4/4] tests/xe_sriov_auto_provisioning: Add subtest to verify VF's configuration Lukasz Laguna
2025-02-10 10:52   ` Bernatowicz, Marcin
2025-02-08  0:26 ` ✓ i915.CI.BAT: success for Verify VF configuration data against provisioned values (rev2) Patchwork
2025-02-08  1:22 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-02-08 16:45 ` ✗ i915.CI.Full: " Patchwork
2025-02-08 19:19 ` ✗ Xe.CI.Full: " Patchwork

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=20250207094031.15942-3-lukasz.laguna@intel.com \
    --to=lukasz.laguna@intel.com \
    --cc=adam.miszczak@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jakub1.kolakowski@intel.com \
    --cc=marcin.bernatowicz@linux.intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=satyanarayana.k.v.p@intel.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