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 1/5] lib/xe/xe_sriov_provisioning: Add string conversion helpers for scheduling priority
Date: Fri, 14 Nov 2025 20:07:51 +0100 [thread overview]
Message-ID: <20251114190757.2295174-2-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20251114190757.2295174-1-marcin.bernatowicz@linux.intel.com>
Introduce helper functions to convert between xe_sriov_sched_priority
enum values and their string representations.
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/xe/xe_sriov_provisioning.c | 58 ++++++++++++++++++++++++++++++++++
lib/xe/xe_sriov_provisioning.h | 2 ++
2 files changed, 60 insertions(+)
diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
index 2ca73d2ef..532335abe 100644
--- a/lib/xe/xe_sriov_provisioning.c
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -5,6 +5,7 @@
#include <errno.h>
+#include "drmtest.h"
#include "igt_core.h"
#include "igt_debugfs.h"
#include "igt_sriov_device.h"
@@ -635,6 +636,63 @@ void xe_sriov_set_sched_if_idle(int pf, unsigned int gt_num, bool value)
igt_fail_on(__xe_sriov_set_sched_if_idle(pf, gt_num, value));
}
+static const char * const xe_sriov_sched_priority_str[] = {
+ [XE_SRIOV_SCHED_PRIORITY_LOW] = "low",
+ [XE_SRIOV_SCHED_PRIORITY_NORMAL] = "normal",
+ [XE_SRIOV_SCHED_PRIORITY_HIGH] = "high",
+};
+
+_Static_assert(ARRAY_SIZE(xe_sriov_sched_priority_str) == (XE_SRIOV_SCHED_PRIORITY_HIGH + 1),
+ "sched priority table must cover 0..HIGH");
+
+/**
+ * xe_sriov_sched_priority_to_string - Convert scheduling priority enum to string
+ * @prio: SR-IOV scheduling priority value
+ *
+ * Converts an enumeration value of type &enum xe_sriov_sched_priority
+ * into its corresponding string representation.
+ *
+ * Return: A pointer to a constant string literal ("low", "normal", or "high"),
+ * or %NULL if the value is invalid or unrecognized.
+ */
+const char *xe_sriov_sched_priority_to_string(enum xe_sriov_sched_priority prio)
+{
+ switch (prio) {
+ case XE_SRIOV_SCHED_PRIORITY_LOW:
+ case XE_SRIOV_SCHED_PRIORITY_NORMAL:
+ case XE_SRIOV_SCHED_PRIORITY_HIGH:
+ return xe_sriov_sched_priority_str[prio];
+ }
+
+ return NULL;
+}
+
+/**
+ * xe_sriov_sched_priority_from_string - Parse scheduling priority from string
+ * @s: NUL-terminated string to parse
+ * @prio: Output pointer to store parsed enum value
+ *
+ * Parses a string representing a scheduling priority ("low", "normal", "high")
+ * into the corresponding &enum xe_sriov_sched_priority value.
+ *
+ * Return: 0 on success, -EINVAL if the string is invalid or unrecognized.
+ */
+int xe_sriov_sched_priority_from_string(const char *s,
+ enum xe_sriov_sched_priority *prio)
+{
+ igt_assert(s && prio);
+
+ for (size_t i = 0; i < ARRAY_SIZE(xe_sriov_sched_priority_str); i++) {
+ const char *name = xe_sriov_sched_priority_str[i];
+
+ if (name && !strcmp(s, name)) {
+ *prio = (enum xe_sriov_sched_priority)i;
+ return 0;
+ }
+ }
+ return -EINVAL;
+}
+
/**
* __xe_sriov_get_sched_priority - Get the scheduling priority for a given VF
* @pf: PF device file descriptor
diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
index 1e1dca866..65f0597fe 100644
--- a/lib/xe/xe_sriov_provisioning.h
+++ b/lib/xe/xe_sriov_provisioning.h
@@ -138,6 +138,8 @@ int __xe_sriov_get_sched_if_idle(int pf, unsigned int gt_num, bool *value);
bool xe_sriov_get_sched_if_idle(int pf, unsigned int gt_num);
int __xe_sriov_set_sched_if_idle(int pf, unsigned int gt_num, bool value);
void xe_sriov_set_sched_if_idle(int pf, unsigned int gt_num, bool value);
+const char *xe_sriov_sched_priority_to_string(enum xe_sriov_sched_priority value);
+int xe_sriov_sched_priority_from_string(const char *s, enum xe_sriov_sched_priority *value);
int __xe_sriov_get_sched_priority(int pf, unsigned int vf_num,
unsigned int gt_num,
enum xe_sriov_sched_priority *value);
--
2.43.0
next prev parent reply other threads:[~2025-11-14 19:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 19:07 [PATCH i-g-t 0/5] Xe SR-IOV admin scheduling helpers and test updates Marcin Bernatowicz
2025-11-14 19:07 ` Marcin Bernatowicz [this message]
2025-11-14 19:07 ` [PATCH i-g-t 2/5] lib/xe/xe_sriov_provisioning: Add sched priority mask to string helper Marcin Bernatowicz
2025-11-14 20:15 ` Michal Wajdeczko
2025-11-17 11:00 ` Bernatowicz, Marcin
2025-11-14 19:07 ` [PATCH i-g-t 3/5] lib/xe/xe_sriov_admin: Add SR-IOV admin sysfs accessors Marcin Bernatowicz
2025-11-14 19:53 ` Michal Wajdeczko
2025-11-17 9:31 ` Bernatowicz, Marcin
2025-11-14 19:07 ` [PATCH i-g-t 4/5] tests/intel/xe_sriov_scheduling: Avoid assert on scheduling params restore in cleanup Marcin Bernatowicz
2025-11-14 19:07 ` [PATCH i-g-t 5/5] tests/intel/xe_sriov_scheduling: Prefer SR-IOV admin sysfs accessors Marcin Bernatowicz
2025-11-14 19:57 ` Michal Wajdeczko
2025-11-17 8:51 ` Bernatowicz, Marcin
2025-11-14 23:29 ` ✓ Xe.CI.BAT: success for Xe SR-IOV admin scheduling helpers and test updates Patchwork
2025-11-15 9:54 ` ✓ Xe.CI.Full: " Patchwork
2025-11-15 15:11 ` ✓ 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=20251114190757.2295174-2-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.