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@intel.com, piotr.piorkowski@intel.com
Subject: [PATCH v2 1/3] lib/igt_sriov_device: Add helper to get SR-IOV function name
Date: Mon,  7 Sep 2026 14:46:56 +0200	[thread overview]
Message-ID: <20260907124658.613244-2-lukasz.laguna@intel.com> (raw)
In-Reply-To: <20260907124658.613244-1-lukasz.laguna@intel.com>

Introduce a helper to format SR-IOV function names. It returns "PF" for
physical function and "VF%u" for virtual functions.

Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
---
 lib/igt_sriov_device.c | 23 +++++++++++++++++++++++
 lib/igt_sriov_device.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
index 6c9fbdf70..392c80346 100644
--- a/lib/igt_sriov_device.c
+++ b/lib/igt_sriov_device.c
@@ -61,6 +61,29 @@ const char *igt_sriov_func_str(unsigned int vf_num)
 	return buf;
 }
 
+/**
+ * igt_sriov_function_name - Get SR-IOV function name
+ * @vf_num: VF number (1-based to identify single VF) or 0 for PF
+ * @buf: buffer
+ * @size: size of the buffer
+ *
+ * It formats the function name as "PF" when @vf_num is 0, or as "VF%u"
+ * when @vf_num is greater than 0.
+ *
+ * Return: formatted function name.
+ */
+const char *igt_sriov_function_name(unsigned int vf_num, char *buf, size_t size)
+{
+	int n;
+
+	n = vf_num ? snprintf(buf, size, "VF%u", vf_num) :
+		     snprintf(buf, size, "PF");
+
+	igt_assert(n >= 0 && (size_t)n < size);
+
+	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 4e4ba230a..a969d4172 100644
--- a/lib/igt_sriov_device.h
+++ b/lib/igt_sriov_device.h
@@ -36,6 +36,7 @@ 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);
+const char *igt_sriov_function_name(unsigned int vf_num, char *buf, size_t size);
 typedef void (*igt_sriov_exit_cleanup_fn)(int pf, int sig, void *user_data);
 void igt_sriov_install_exit_handler(int pf,
 				    igt_sriov_exit_cleanup_fn cleanup_fn,
-- 
2.43.0


  reply	other threads:[~2026-09-07 12:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 12:46 [PATCH v2 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna
2026-09-07 12:46 ` Lukasz Laguna [this message]
2026-09-08 13:16   ` [PATCH v2 1/3] lib/igt_sriov_device: Add helper to get SR-IOV function name Bernatowicz, Marcin
2026-09-07 12:46 ` [PATCH v2 2/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna
2026-09-10 10:26   ` Bernatowicz, Marcin
2026-09-07 12:46 ` [PATCH v2 3/3] intel-ci: Block igt@xe_sriov_mmio_regs.* Lukasz Laguna
2026-09-10 10:27   ` Bernatowicz, Marcin
2026-09-07 17:15 ` ✓ Xe.CI.BAT: success for tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev2) Patchwork
2026-09-07 17:51 ` ✓ i915.CI.BAT: " Patchwork
2026-09-07 21:01 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-08  0:07 ` ✗ 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=20260907124658.613244-2-lukasz.laguna@intel.com \
    --to=lukasz.laguna@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=marcin.bernatowicz@intel.com \
    --cc=piotr.piorkowski@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