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 v3 4/4] tests/xe_sriov_auto_provisioning: Add subtest to verify VF's configuration
Date: Tue, 11 Feb 2025 17:29:19 +0100	[thread overview]
Message-ID: <20250211162919.15076-5-lukasz.laguna@intel.com> (raw)
In-Reply-To: <20250211162919.15076-1-lukasz.laguna@intel.com>

Added subtest checks if configuration data that VF got from GuC during
probe is the same as provisioned.

v2:
 - add missing flag in subtest function call (Marcin)
 - fix VFs range in subtest definition (Lukasz)
v3:
 - fix indentation (Marcin)

Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
 tests/intel/xe_sriov_auto_provisioning.c | 123 ++++++++++++++++++++++-
 1 file changed, 121 insertions(+), 2 deletions(-)

diff --git a/tests/intel/xe_sriov_auto_provisioning.c b/tests/intel/xe_sriov_auto_provisioning.c
index e13eb3644..d71bcbfec 100644
--- a/tests/intel/xe_sriov_auto_provisioning.c
+++ b/tests/intel/xe_sriov_auto_provisioning.c
@@ -33,6 +33,18 @@
  * SUBTEST: exclusive-ranges
  * Description:
  *   Verify that ranges of auto-provisioned resources are exclusive
+ *
+ * SUBTEST: selfconfig-basic
+ * Description:
+ *   Check if VF configuration data is the same as provisioned
+ *
+ * SUBTEST: selfconfig-reprovision-increase-numvfs
+ * Description:
+ *   Check if VF configuration data is updated properly after increasing number of VFs
+ *
+ * SUBTEST: selfconfig-reprovision-reduce-numvfs
+ * Description:
+ *   Check if VF configuration data is updated properly after decreasing number of VFs
  */
 
 IGT_TEST_DESCRIPTION("Xe tests for SR-IOV auto-provisioning");
@@ -216,6 +228,70 @@ static void exclusive_ranges(int pf_fd, unsigned int num_vfs)
 	igt_fail_on_f(fails, "exclusive ranges check failed\n");
 }
 
+#define REPROVISION_INCREASE_NUMVFS	(0x1 << 0)
+#define REPROVISION_REDUCE_NUMVFS	(0x1 << 1)
+
+static void check_selfconfig(int pf_fd, unsigned int vf_num, unsigned int flags)
+{
+	unsigned int gt_num, total_vfs = igt_sriov_get_total_vfs(pf_fd);
+	uint64_t provisioned, queried;
+	enum xe_sriov_shared_res res;
+	int vf_fd, fails = 0;
+
+	igt_sriov_disable_driver_autoprobe(pf_fd);
+	igt_sriov_enable_vfs(pf_fd, (flags & REPROVISION_REDUCE_NUMVFS) ? total_vfs : vf_num);
+	igt_sriov_enable_driver_autoprobe(pf_fd);
+
+	igt_sriov_bind_vf_drm_driver(pf_fd, vf_num);
+	vf_fd = igt_sriov_open_vf_drm_device(pf_fd, vf_num);
+	igt_assert_fd(vf_fd);
+
+	xe_for_each_gt(pf_fd, gt_num) {
+		xe_sriov_for_each_provisionable_shared_res(res, pf_fd, gt_num) {
+			provisioned = xe_sriov_pf_get_provisioned_quota(pf_fd, res, vf_num,
+									gt_num);
+			queried = xe_sriov_vf_debugfs_get_selfconfig(vf_fd, res, gt_num);
+
+			if (igt_debug_on_f(provisioned != queried,
+					   "%s selfconfig check failed on gt%u\n",
+					   xe_sriov_shared_res_to_string(res), gt_num))
+				fails++;
+		}
+	}
+
+	close(vf_fd);
+	igt_sriov_disable_vfs(pf_fd);
+
+	if (flags && !fails) {
+		igt_sriov_disable_driver_autoprobe(pf_fd);
+		igt_sriov_enable_vfs(pf_fd, (flags & REPROVISION_INCREASE_NUMVFS) ? total_vfs :
+										    vf_num);
+		igt_sriov_enable_driver_autoprobe(pf_fd);
+
+		igt_sriov_bind_vf_drm_driver(pf_fd, vf_num);
+		vf_fd = igt_sriov_open_vf_drm_device(pf_fd, vf_num);
+		igt_assert_fd(vf_fd);
+
+		xe_for_each_gt(pf_fd, gt_num) {
+			xe_sriov_for_each_provisionable_shared_res(res, pf_fd, gt_num) {
+				provisioned = xe_sriov_pf_get_provisioned_quota(pf_fd, res, vf_num,
+										gt_num);
+				queried = xe_sriov_vf_debugfs_get_selfconfig(vf_fd, res, gt_num);
+
+				if (igt_debug_on_f(provisioned != queried,
+						   "%s selfconfig check after reprovisioning failed on gt%u\n",
+						   xe_sriov_shared_res_to_string(res), gt_num))
+					fails++;
+			}
+		}
+
+		close(vf_fd);
+		igt_sriov_disable_vfs(pf_fd);
+	}
+
+	igt_fail_on_f(fails, "selfconfig check failed\n");
+}
+
 static bool extended_scope;
 
 static int opts_handler(int opt, int opt_index, void *data)
@@ -242,9 +318,17 @@ static const char help_str[] =
 igt_main_args("", long_opts, help_str, opts_handler, NULL)
 {
 	enum xe_sriov_shared_res res;
-	unsigned int gt;
+	unsigned int gt, total_vfs;
 	bool autoprobe;
 	int pf_fd;
+	static struct subtest_variants {
+		const char *name;
+		unsigned int flags;
+	} reprovisioning_variant[] = {
+		{ "increase", REPROVISION_INCREASE_NUMVFS },
+		{ "reduce", REPROVISION_REDUCE_NUMVFS },
+		{ NULL },
+	};
 
 	igt_fixture {
 		struct xe_sriov_provisioned_range *ranges;
@@ -264,6 +348,7 @@ igt_main_args("", long_opts, help_str, opts_handler, NULL)
 			}
 		}
 		autoprobe = igt_sriov_is_driver_autoprobe_enabled(pf_fd);
+		total_vfs = igt_sriov_get_total_vfs(pf_fd);
 	}
 
 	igt_describe("Verify that auto-provisioned resources are allocated by PF driver in fairly manner");
@@ -298,7 +383,6 @@ igt_main_args("", long_opts, help_str, opts_handler, NULL)
 
 	igt_describe("Verify that ranges of auto-provisioned resources are exclusive");
 	igt_subtest_with_dynamic_f("exclusive-ranges") {
-		unsigned int total_vfs = igt_sriov_get_total_vfs(pf_fd);
 
 		igt_skip_on(total_vfs < 2);
 
@@ -315,6 +399,41 @@ igt_main_args("", long_opts, help_str, opts_handler, NULL)
 		}
 	}
 
+	igt_describe("Check if VF configuration data is the same as provisioned");
+	igt_subtest_with_dynamic("selfconfig-basic") {
+		if (extended_scope)
+			for_each_sriov_vf(pf_fd, vf)
+				igt_dynamic_f("vf-%u", vf)
+					check_selfconfig(pf_fd, vf, 0);
+
+		for_random_sriov_vf(pf_fd, vf) {
+			igt_dynamic_f("vf-random") {
+				igt_debug("vf=%u\n", vf);
+				check_selfconfig(pf_fd, vf, 0);
+			}
+		}
+	}
+
+	for (const struct subtest_variants *s = reprovisioning_variant; s->name; s++) {
+		igt_describe("Check if VF configuration data is the same as reprovisioned");
+		igt_subtest_with_dynamic_f("selfconfig-reprovision-%s-numvfs", s->name) {
+
+			igt_require(total_vfs > 1);
+
+			if (extended_scope)
+				for_each_sriov_vf_in_range(pf_fd, 1, total_vfs - 1, vf)
+					igt_dynamic_f("vf-%u", vf)
+						check_selfconfig(pf_fd, vf, s->flags);
+
+			for_random_sriov_vf_in_range(pf_fd, 1, total_vfs - 1, vf) {
+				igt_dynamic_f("vf-random") {
+					igt_debug("vf=%u\n", vf);
+					check_selfconfig(pf_fd, vf, s->flags);
+				}
+			}
+		}
+	}
+
 	igt_fixture {
 		igt_sriov_disable_vfs(pf_fd);
 		/* abort to avoid execution of next tests with enabled VFs */
-- 
2.40.0


  parent reply	other threads:[~2025-02-11 16:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11 16:29 [PATCH i-g-t v3 0/4] Verify VF configuration data against provisioned values Lukasz Laguna
2025-02-11 16:29 ` [PATCH i-g-t v3 1/4] lib/xe/xe_sriov_debugfs: Add helper to read VF's configuration data Lukasz Laguna
2025-02-11 16:29 ` [PATCH i-g-t v3 2/4] lib/xe/xe_sriov_provisioning: Add helper to get VF's provisioned quota Lukasz Laguna
2025-02-11 16:29 ` [PATCH i-g-t v3 3/4] lib/igt_sriov_device: Add helper to iterate over VFs in specified range Lukasz Laguna
2025-02-12  8:09   ` Bernatowicz, Marcin
2025-02-11 16:29 ` Lukasz Laguna [this message]
2025-02-11 18:18 ` ✓ Xe.CI.BAT: success for Verify VF configuration data against provisioned values (rev3) Patchwork
2025-02-11 18:34 ` ✓ i915.CI.BAT: " Patchwork
2025-02-11 21:14 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-12  1:36 ` ✗ 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=20250211162919.15076-5-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