From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: adam.miszczak@linux.intel.com, jakub1.kolakowski@intel.com,
lukasz.laguna@intel.com, michal.wajdeczko@intel.com,
Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Subject: [PATCH i-g-t v2 05/10] lib/igt_sriov_device: Add helper for PF/VF sysfs path formatting
Date: Tue, 25 Nov 2025 11:23:04 +0100 [thread overview]
Message-ID: <20251125102312.43142-6-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20251125102312.43142-1-marcin.bernatowicz@linux.intel.com>
Add igt_sriov_func_str() — a small utility that returns "pf" for
function 0 and "vf%u" for any VF index. This helper allows callers
to build SR-IOV sysfs paths without duplicating PF/VF conditional
logic.
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
lib/igt_sriov_device.c | 19 +++++++++++++++++++
lib/igt_sriov_device.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
index ffa996d6b..788ffbfa1 100644
--- a/lib/igt_sriov_device.c
+++ b/lib/igt_sriov_device.c
@@ -42,6 +42,25 @@ bool igt_sriov_is_pf(int device)
return value > 0;
}
+/**
+ * igt_sriov_func_str - Return "pf" or "vf%u" label for a function number
+ * @vf_num: 0 for PF, >0 for VF index
+ *
+ * Helper for constructing SR-IOV sysfs paths.
+ *
+ * Returns: "pf" for @vf_num == 0, otherwise "vf%u".
+ */
+const char *igt_sriov_func_str(unsigned int vf_num)
+{
+ static __thread char buf[16];
+
+ if (vf_num == 0)
+ return "pf";
+
+ snprintf(buf, sizeof(buf), "vf%u", vf_num);
+ return buf;
+}
+
static bool __pf_attr_get_u32(int pf, const char *attr, uint32_t *value)
{
int sysfs;
diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h
index 930e97982..84d29b1bb 100644
--- a/lib/igt_sriov_device.h
+++ b/lib/igt_sriov_device.h
@@ -34,6 +34,7 @@ int igt_sriov_device_sysfs_open(int pf, unsigned int vf_num);
bool igt_sriov_device_reset_exists(int pf, unsigned int vf_num);
bool igt_sriov_device_reset(int pf, unsigned int vf_num);
bool intel_is_vf_device(int device);
+const char *igt_sriov_func_str(unsigned int vf_num);
/**
* __is_valid_range - Helper to check VF range is valid
--
2.43.0
next prev parent reply other threads:[~2025-11-25 10:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 10:22 [PATCH i-g-t v2 00/10] Xe SR-IOV admin scheduling helpers and test updates Marcin Bernatowicz
2025-11-25 10:23 ` [PATCH i-g-t v2 01/10] lib/igt_sysfs_choice: Add helpers for sysfs enumerated choice attributes Marcin Bernatowicz
2026-01-15 7:24 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 02/10] lib/tests/igt_sysfs_choice: Add test coverage Marcin Bernatowicz
2026-01-15 10:31 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 03/10] lib/xe/xe_sriov_provisioning: Add string conversion helpers for scheduling priority Marcin Bernatowicz
2026-01-15 7:48 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 04/10] lib/xe/xe_sriov_provisioning: Add sched priority mask to string helper Marcin Bernatowicz
2026-01-15 8:04 ` Laguna, Lukasz
2025-11-25 10:23 ` Marcin Bernatowicz [this message]
2026-01-15 8:10 ` [PATCH i-g-t v2 05/10] lib/igt_sriov_device: Add helper for PF/VF sysfs path formatting Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 06/10] lib/xe/xe_sriov_admin: Add SR-IOV admin sysfs accessors Marcin Bernatowicz
2026-01-15 8:24 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 07/10] tests/intel/xe_sriov_scheduling: Avoid assert on scheduling params restore in cleanup Marcin Bernatowicz
2026-01-15 8:25 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 08/10] tests/intel/xe_sriov_scheduling: Prefer SR-IOV admin sysfs accessors Marcin Bernatowicz
2026-01-15 8:25 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 09/10] tests/intel/xe_pmu: " Marcin Bernatowicz
2026-01-15 8:27 ` Laguna, Lukasz
2025-11-25 10:23 ` [PATCH i-g-t v2 10/10] tests/intel/xe_sriov_admin_profile: Add SR-IOV admin sysfs scheduling attributes tests Marcin Bernatowicz
2026-01-15 10:05 ` Laguna, Lukasz
2026-01-15 10:10 ` Laguna, Lukasz
2025-11-25 17:27 ` ✓ i915.CI.BAT: success for Xe SR-IOV admin scheduling helpers and test updates (rev2) Patchwork
2025-11-25 17:50 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-25 20:25 ` ✗ Xe.CI.Full: failure " Patchwork
2025-11-26 6:39 ` ✗ i915.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=20251125102312.43142-6-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=adam.miszczak@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=michal.wajdeczko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.