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 3/4] lib/igt_sriov_device: Add helper to iterate over VFs in specified range
Date: Tue, 11 Feb 2025 17:29:18 +0100	[thread overview]
Message-ID: <20250211162919.15076-4-lukasz.laguna@intel.com> (raw)
In-Reply-To: <20250211162919.15076-1-lukasz.laguna@intel.com>

Helper allows to iterate over VFs within the specified range.

v2:
 - fix macro (Marcin)

Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
---
 lib/igt_sriov_device.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h
index de25a7d98..2b6acb6d7 100644
--- a/lib/igt_sriov_device.h
+++ b/lib/igt_sriov_device.h
@@ -86,6 +86,25 @@ 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_vf_in_range - Iterate over VFs in a specified range
+ * @__pf_fd: PF device file descriptor
+ * @__start: Starting VF number in the range
+ * @__end: Ending VF number in the range
+ * @__vf_num: Variable to store the random VF number
+ *
+ * For loop that iterates over VFs associated with given PF @__pf_fd,
+ * within the specified range [__start, __end]. The loop runs only if
+ * the range is valid.
+ */
+#define for_each_sriov_vf_in_range(__pf_fd, __start, __end, __vf_num) \
+	for (unsigned int __vf_num = __is_valid_range((__start), (__end), \
+						      igt_sriov_get_total_vfs(__pf_fd)) ? \
+						      (__start) : 0; \
+	     __vf_num && __vf_num <= (__end); \
+	     ++__vf_num)
+#define for_each_sriov_num_vfs_in_range for_each_sriov_vf_in_range
+
 /**
  * for_random_sriov_vf_in_range - Iterate over a random VF in a specified range
  * @__pf_fd: PF device file descriptor
-- 
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 ` Lukasz Laguna [this message]
2025-02-12  8:09   ` [PATCH i-g-t v3 3/4] lib/igt_sriov_device: Add helper to iterate over VFs in specified range Bernatowicz, Marcin
2025-02-11 16:29 ` [PATCH i-g-t v3 4/4] tests/xe_sriov_auto_provisioning: Add subtest to verify VF's configuration Lukasz Laguna
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-4-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