From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: Lukasz Laguna <lukasz.laguna@intel.com>, igt-dev@lists.freedesktop.org
Cc: marcin.bernatowicz@intel.com, piotr.piorkowski@intel.com
Subject: Re: [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name
Date: Tue, 10 Nov 2026 10:48:36 +0100 [thread overview]
Message-ID: <a8f45efb-d8d1-41c0-8314-67d60a9b548b@linux.intel.com> (raw)
In-Reply-To: <20261110082838.2034264-2-lukasz.laguna@intel.com>
LGTM,
Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
On 11/10/2026 9:28 AM, Lukasz Laguna wrote:
> Introduce helpers to format SR-IOV function names in lowercase and
> uppercase variants. They format PF as "pf" or "PF" and VFs as "vf%u" or
> "VF%u" depending on the variant.
>
> Keep igt_sriov_func_str() as a compatibility wrapper around the
> lowercase, so existing callers continue to work while the code migrates
> to the new API.
>
> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
> ---
> lib/igt_sriov_device.c | 53 +++++++++++++++++++++++++++++++++++++++---
> lib/igt_sriov_device.h | 2 ++
> 2 files changed, 52 insertions(+), 3 deletions(-)
>
> diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
> index 6c9fbdf70..de446aca1 100644
> --- a/lib/igt_sriov_device.c
> +++ b/lib/igt_sriov_device.c
> @@ -54,13 +54,60 @@ const char *igt_sriov_func_str(unsigned int vf_num)
> {
> static __thread char buf[16];
>
> - if (vf_num == 0)
> - return "pf";
> + return igt_sriov_function_name_lower(vf_num, buf, sizeof(buf));
> +}
> +
> +static const char *sriov_function_name(unsigned int vf_num, bool uppercase,
> + char *buf, size_t size)
> +{
> + int ret;
> +
> + igt_assert(buf && size);
> +
> + if (vf_num)
> + ret = snprintf(buf, size, uppercase ? "VF%u" : "vf%u", vf_num);
> + else
> + ret = snprintf(buf, size, uppercase ? "PF" : "pf");
> +
> + igt_assert(ret >= 0 && (size_t)ret < size);
>
> - snprintf(buf, sizeof(buf), "vf%u", vf_num);
> return buf;
> }
>
> +/**
> + * igt_sriov_function_name_lower - Get SR-IOV function name in lowercase
> + * @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_lower(unsigned int vf_num, char *buf,
> + size_t size)
> +{
> + return sriov_function_name(vf_num, false, buf, size);
> +}
> +
> +/**
> + * igt_sriov_function_name_upper - Get SR-IOV function name in uppercase
> + * @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_upper(unsigned int vf_num, char *buf,
> + size_t size)
> +{
> + return sriov_function_name(vf_num, true, buf, size);
> +}
> +
> 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..0e94c521a 100644
> --- a/lib/igt_sriov_device.h
> +++ b/lib/igt_sriov_device.h
> @@ -36,6 +36,8 @@ 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_lower(unsigned int vf_num, char *buf, size_t size);
> +const char *igt_sriov_function_name_upper(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,
next prev parent reply other threads:[~2026-11-10 9:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:28 [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna
2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna
2026-11-10 9:48 ` Bernatowicz, Marcin [this message]
2026-11-10 11:42 ` Kamil Konieczny
2026-11-10 8:28 ` [PATCH v4 2/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna
2026-11-10 8:28 ` [PATCH v4 3/3] intel-ci: Block igt@xe_sriov_mmio_regs.* Lukasz Laguna
2026-11-10 17:30 ` ✗ Fi.CI.BUILD: failure for tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev5) 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=a8f45efb-d8d1-41c0-8314-67d60a9b548b@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=lukasz.laguna@intel.com \
--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